My fork of X_NUCLEO_IDB0XA1
Fork of X_NUCLEO_IDB0XA1 by
Embed:
(wiki syntax)
Show/hide line numbers
ble_hal.h
00001 /******************** (C) COPYRIGHT 2012 STMicroelectronics ******************** 00002 * File Name : hal.h 00003 * Author : AMS - HEA&RF BU 00004 * Version : V1.0.0 00005 * Date : 19-July-2012 00006 * Description : Header file which defines Hardware abstraction layer APIs 00007 * used by the BLE stack. It defines the set of functions 00008 * which needs to be ported to the target platform. 00009 ******************************************************************************** 00010 * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 00011 * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. 00012 * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, 00013 * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE 00014 * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING 00015 * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 00016 *******************************************************************************/ 00017 #ifndef __HAL_H__ 00018 #define __HAL_H__ 00019 00020 /****************************************************************************** 00021 * Includes 00022 *****************************************************************************/ 00023 #include <ble_hal_types.h> 00024 #include <ble_status.h> 00025 00026 00027 /****************************************************************************** 00028 * Macros 00029 *****************************************************************************/ 00030 /* Little Endian buffer to host endianess conversion */ 00031 #define LE_TO_HOST_16(ptr) (uint16_t) ( ((uint16_t) \ 00032 *((uint8_t *)ptr)) | \ 00033 ((uint16_t) \ 00034 *((uint8_t *)ptr + 1) << 8 ) ) 00035 00036 #define LE_TO_HOST_32(ptr) (uint32_t) ( ((uint32_t) \ 00037 *((uint8_t *)ptr)) | \ 00038 ((uint32_t) \ 00039 *((uint8_t *)ptr + 1) << 8) | \ 00040 ((uint32_t) \ 00041 *((uint8_t *)ptr + 2) << 16) | \ 00042 ((uint32_t) \ 00043 *((uint8_t *)ptr + 3) << 24) ) 00044 00045 /* Big Endian buffer to host endianess conversion */ 00046 #define BE_TO_HOST_16(ptr) (uint16_t) ( ((uint16_t) \ 00047 *((uint8_t *)ptr)) << 8 | \ 00048 ((uint16_t) \ 00049 *((uint8_t *)ptr + 1) ) ) 00050 00051 /* Store Value into a buffer in Little Endian Format */ 00052 #define HOST_TO_LE_16(buf, val) ( ((buf)[0] = (uint8_t) (val) ) , \ 00053 ((buf)[1] = (uint8_t) (val>>8) ) ) 00054 00055 #define HOST_TO_LE_32(buf, val) ( ((buf)[0] = (uint8_t) (val) ) , \ 00056 ((buf)[1] = (uint8_t) (val>>8) ) , \ 00057 ((buf)[2] = (uint8_t) (val>>16) ) , \ 00058 ((buf)[3] = (uint8_t) (val>>24) ) ) 00059 00060 00061 /* Store Value into a buffer in Big Endian Format */ 00062 #define HOST_TO_BE_16(buf, val) ( ((buf)[1] = (uint8_t) (val) ) , \ 00063 ((buf)[0] = (uint8_t) (val>>8) ) ) 00064 00065 #define DISABLE_INTERRUPTS() __disable_interrupt() 00066 #define ENABLE_INTERRUPTS() __enable_interrupt() 00067 #define SAVE_PRIMASK() uint32_t uwPRIMASK_Bit = __get_PRIMASK() 00068 #define ATOMIC_SECTION_BEGIN() uint32_t uwPRIMASK_Bit = __get_PRIMASK(); \ 00069 __disable_interrupt(); \ 00070 /* Must be called in the same or in a lower scope of SUSPEND_INTERRUPTS */ 00071 #define ATOMIC_SECTION_END() __set_PRIMASK(uwPRIMASK_Bit) 00072 00073 /****************************************************************************** 00074 * Types 00075 *****************************************************************************/ 00076 00077 /****************************************************************************** 00078 * Function Prototypes 00079 *****************************************************************************/ 00080 00081 /** 00082 * Writes data to a serial interface. 00083 * 00084 * @param[in] data1 1st buffer 00085 * @param[in] data2 2nd buffer 00086 * @param[in] n_bytes1 number of bytes in 1st buffer 00087 * @param[in] n_bytes2 number of bytes in 2nd buffer 00088 */ 00089 void Hal_Write_Serial(const void* data1, const void* data2, int32_t n_bytes1, int32_t n_bytes2); 00090 00091 /** 00092 * Enable interrupts from HCI controller. 00093 */ 00094 void Enable_SPI_IRQ(void); 00095 00096 /** 00097 * Disable interrupts from BLE controller. 00098 */ 00099 void Disable_SPI_IRQ(void); 00100 00101 void signalEventsToProcess(void); 00102 00103 void Hal_Init_Timer(void); 00104 uint32_t Hal_Get_Timer_Value(void); 00105 void Hal_Start_Timer(uint32_t timeout); 00106 void Hal_Stop_Timer(void); 00107 00108 #endif /* __HAL_H__ */
Generated on Wed Jul 13 2022 03:04:51 by 1.7.2