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