Antonio Vilei / X_NUCLEO_IDB0XA1

Fork of X_NUCLEO_IDB0XA1 by ST Expansion SW Team

Committer:
Wolfgang Betz
Date:
Tue Oct 06 14:25:08 2015 +0200
Revision:
130:770ce14d3d15
Include mbed-classic version

Derived from
- repo (on Codex): gitolite@codex.cro.st.com:x-nucleodev/X-NUCLEO-IKC01A1-MBED.git
- branch: ble_wb
- SHA1 ID: 5ccc73e35868169e42132c0d1c056f908a6d70c0

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Wolfgang Betz 130:770ce14d3d15 1 /******************** (C) COPYRIGHT 2012 STMicroelectronics ********************
Wolfgang Betz 130:770ce14d3d15 2 * File Name : hal.h
Wolfgang Betz 130:770ce14d3d15 3 * Author : AMS - HEA&RF BU
Wolfgang Betz 130:770ce14d3d15 4 * Version : V1.0.0
Wolfgang Betz 130:770ce14d3d15 5 * Date : 19-July-2012
Wolfgang Betz 130:770ce14d3d15 6 * Description : Header file which defines Hardware abstraction layer APIs
Wolfgang Betz 130:770ce14d3d15 7 * used by the BLE stack. It defines the set of functions
Wolfgang Betz 130:770ce14d3d15 8 * which needs to be ported to the target platform.
Wolfgang Betz 130:770ce14d3d15 9 ********************************************************************************
Wolfgang Betz 130:770ce14d3d15 10 * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
Wolfgang Betz 130:770ce14d3d15 11 * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
Wolfgang Betz 130:770ce14d3d15 12 * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
Wolfgang Betz 130:770ce14d3d15 13 * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
Wolfgang Betz 130:770ce14d3d15 14 * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
Wolfgang Betz 130:770ce14d3d15 15 * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
Wolfgang Betz 130:770ce14d3d15 16 *******************************************************************************/
Wolfgang Betz 130:770ce14d3d15 17 #ifndef __HAL_H__
Wolfgang Betz 130:770ce14d3d15 18 #define __HAL_H__
Wolfgang Betz 130:770ce14d3d15 19
Wolfgang Betz 130:770ce14d3d15 20 /******************************************************************************
Wolfgang Betz 130:770ce14d3d15 21 * Includes
Wolfgang Betz 130:770ce14d3d15 22 *****************************************************************************/
Wolfgang Betz 130:770ce14d3d15 23 #include <hal_types.h>
Wolfgang Betz 130:770ce14d3d15 24 #include <ble_status.h>
Wolfgang Betz 130:770ce14d3d15 25
Wolfgang Betz 130:770ce14d3d15 26
Wolfgang Betz 130:770ce14d3d15 27 /******************************************************************************
Wolfgang Betz 130:770ce14d3d15 28 * Macros
Wolfgang Betz 130:770ce14d3d15 29 *****************************************************************************/
Wolfgang Betz 130:770ce14d3d15 30 /* Little Endian buffer to host endianess conversion */
Wolfgang Betz 130:770ce14d3d15 31 #define LE_TO_HOST_16(ptr) (uint16_t) ( ((uint16_t) \
Wolfgang Betz 130:770ce14d3d15 32 *((uint8_t *)ptr)) | \
Wolfgang Betz 130:770ce14d3d15 33 ((uint16_t) \
Wolfgang Betz 130:770ce14d3d15 34 *((uint8_t *)ptr + 1) << 8 ) )
Wolfgang Betz 130:770ce14d3d15 35
Wolfgang Betz 130:770ce14d3d15 36 #define LE_TO_HOST_32(ptr) (uint32_t) ( ((uint32_t) \
Wolfgang Betz 130:770ce14d3d15 37 *((uint8_t *)ptr)) | \
Wolfgang Betz 130:770ce14d3d15 38 ((uint32_t) \
Wolfgang Betz 130:770ce14d3d15 39 *((uint8_t *)ptr + 1) << 8) | \
Wolfgang Betz 130:770ce14d3d15 40 ((uint32_t) \
Wolfgang Betz 130:770ce14d3d15 41 *((uint8_t *)ptr + 2) << 16) | \
Wolfgang Betz 130:770ce14d3d15 42 ((uint32_t) \
Wolfgang Betz 130:770ce14d3d15 43 *((uint8_t *)ptr + 3) << 24) )
Wolfgang Betz 130:770ce14d3d15 44
Wolfgang Betz 130:770ce14d3d15 45 /* Big Endian buffer to host endianess conversion */
Wolfgang Betz 130:770ce14d3d15 46 #define BE_TO_HOST_16(ptr) (uint16_t) ( ((uint16_t) \
Wolfgang Betz 130:770ce14d3d15 47 *((uint8_t *)ptr)) << 8 | \
Wolfgang Betz 130:770ce14d3d15 48 ((uint16_t) \
Wolfgang Betz 130:770ce14d3d15 49 *((uint8_t *)ptr + 1) ) )
Wolfgang Betz 130:770ce14d3d15 50
Wolfgang Betz 130:770ce14d3d15 51 /* Store Value into a buffer in Little Endian Format */
Wolfgang Betz 130:770ce14d3d15 52 #define HOST_TO_LE_16(buf, val) ( ((buf)[0] = (uint8_t) (val) ) , \
Wolfgang Betz 130:770ce14d3d15 53 ((buf)[1] = (uint8_t) (val>>8) ) )
Wolfgang Betz 130:770ce14d3d15 54
Wolfgang Betz 130:770ce14d3d15 55 #define HOST_TO_LE_32(buf, val) ( ((buf)[0] = (uint8_t) (val) ) , \
Wolfgang Betz 130:770ce14d3d15 56 ((buf)[1] = (uint8_t) (val>>8) ) , \
Wolfgang Betz 130:770ce14d3d15 57 ((buf)[2] = (uint8_t) (val>>16) ) , \
Wolfgang Betz 130:770ce14d3d15 58 ((buf)[3] = (uint8_t) (val>>24) ) )
Wolfgang Betz 130:770ce14d3d15 59
Wolfgang Betz 130:770ce14d3d15 60
Wolfgang Betz 130:770ce14d3d15 61 /* Store Value into a buffer in Big Endian Format */
Wolfgang Betz 130:770ce14d3d15 62 #define HOST_TO_BE_16(buf, val) ( ((buf)[1] = (uint8_t) (val) ) , \
Wolfgang Betz 130:770ce14d3d15 63 ((buf)[0] = (uint8_t) (val>>8) ) )
Wolfgang Betz 130:770ce14d3d15 64
Wolfgang Betz 130:770ce14d3d15 65 #define DISABLE_INTERRUPTS() __disable_interrupt()
Wolfgang Betz 130:770ce14d3d15 66 #define ENABLE_INTERRUPTS() __enable_interrupt()
Wolfgang Betz 130:770ce14d3d15 67 #define SAVE_PRIMASK() uint32_t uwPRIMASK_Bit = __get_PRIMASK()
Wolfgang Betz 130:770ce14d3d15 68 #define ATOMIC_SECTION_BEGIN() uint32_t uwPRIMASK_Bit = __get_PRIMASK(); \
Wolfgang Betz 130:770ce14d3d15 69 __disable_interrupt(); \
Wolfgang Betz 130:770ce14d3d15 70 /* Must be called in the same or in a lower scope of SUSPEND_INTERRUPTS */
Wolfgang Betz 130:770ce14d3d15 71 #define ATOMIC_SECTION_END() __set_PRIMASK(uwPRIMASK_Bit)
Wolfgang Betz 130:770ce14d3d15 72
Wolfgang Betz 130:770ce14d3d15 73 /******************************************************************************
Wolfgang Betz 130:770ce14d3d15 74 * Types
Wolfgang Betz 130:770ce14d3d15 75 *****************************************************************************/
Wolfgang Betz 130:770ce14d3d15 76
Wolfgang Betz 130:770ce14d3d15 77 /******************************************************************************
Wolfgang Betz 130:770ce14d3d15 78 * Function Prototypes
Wolfgang Betz 130:770ce14d3d15 79 *****************************************************************************/
Wolfgang Betz 130:770ce14d3d15 80
Wolfgang Betz 130:770ce14d3d15 81 /**
Wolfgang Betz 130:770ce14d3d15 82 * Writes data to a serial interface.
Wolfgang Betz 130:770ce14d3d15 83 *
Wolfgang Betz 130:770ce14d3d15 84 * @param[in] data1 1st buffer
Wolfgang Betz 130:770ce14d3d15 85 * @param[in] data2 2nd buffer
Wolfgang Betz 130:770ce14d3d15 86 * @param[in] n_bytes1 number of bytes in 1st buffer
Wolfgang Betz 130:770ce14d3d15 87 * @param[in] n_bytes2 number of bytes in 2nd buffer
Wolfgang Betz 130:770ce14d3d15 88 */
Wolfgang Betz 130:770ce14d3d15 89 void Hal_Write_Serial(const void* data1, const void* data2, int32_t n_bytes1, int32_t n_bytes2);
Wolfgang Betz 130:770ce14d3d15 90
Wolfgang Betz 130:770ce14d3d15 91 /**
Wolfgang Betz 130:770ce14d3d15 92 * Enable interrupts from HCI controller.
Wolfgang Betz 130:770ce14d3d15 93 */
Wolfgang Betz 130:770ce14d3d15 94 void Enable_SPI_IRQ(void);
Wolfgang Betz 130:770ce14d3d15 95
Wolfgang Betz 130:770ce14d3d15 96 /**
Wolfgang Betz 130:770ce14d3d15 97 * Disable interrupts from BLE controller.
Wolfgang Betz 130:770ce14d3d15 98 */
Wolfgang Betz 130:770ce14d3d15 99 void Disable_SPI_IRQ(void);
Wolfgang Betz 130:770ce14d3d15 100
Wolfgang Betz 130:770ce14d3d15 101 void Hal_Init_Timer(void);
Wolfgang Betz 130:770ce14d3d15 102 uint32_t Hal_Get_Timer_Value(void);
Wolfgang Betz 130:770ce14d3d15 103 void Hal_Start_Timer(uint32_t timeout);
Wolfgang Betz 130:770ce14d3d15 104 void Hal_Stop_Timer(void);
Wolfgang Betz 130:770ce14d3d15 105
Wolfgang Betz 130:770ce14d3d15 106 #endif /* __HAL_H__ */