BLE test

Fork of X_NUCLEO_IDB0XA1 by ST

Committer:
hudikm
Date:
Mon Apr 10 14:44:06 2017 +0000
Revision:
308:eb2f149c9cc4
Parent:
291:79456beaef49
initial commit;

Who changed what in which revision?

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