Fork of ble-x-nucleo-idb0xa1 with changes required by BleStarMbed
bluenrg/bluenrg-hci/ble_hci.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_hci.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 : Constants and functions for HCI layer. See Bluetooth Core |
lorevee | 0:ac0b0725c6fa | 7 | * v 4.0, Vol. 2, Part E. |
lorevee | 0:ac0b0725c6fa | 8 | ******************************************************************************** |
lorevee | 0:ac0b0725c6fa | 9 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS |
lorevee | 0:ac0b0725c6fa | 10 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. |
lorevee | 0:ac0b0725c6fa | 11 | * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, |
lorevee | 0:ac0b0725c6fa | 12 | * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE |
lorevee | 0:ac0b0725c6fa | 13 | * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING |
lorevee | 0:ac0b0725c6fa | 14 | * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. |
lorevee | 0:ac0b0725c6fa | 15 | *******************************************************************************/ |
lorevee | 0:ac0b0725c6fa | 16 | |
lorevee | 0:ac0b0725c6fa | 17 | #ifndef __BLE_HCI_H_ |
lorevee | 0:ac0b0725c6fa | 18 | #define __BLE_HCI_H_ |
lorevee | 0:ac0b0725c6fa | 19 | |
lorevee | 0:ac0b0725c6fa | 20 | |
lorevee | 0:ac0b0725c6fa | 21 | #ifdef __cplusplus |
lorevee | 0:ac0b0725c6fa | 22 | extern "C" { |
lorevee | 0:ac0b0725c6fa | 23 | #endif |
lorevee | 0:ac0b0725c6fa | 24 | |
lorevee | 0:ac0b0725c6fa | 25 | #include "ble_hal_types.h" |
lorevee | 0:ac0b0725c6fa | 26 | #include "ble_link_layer.h" |
lorevee | 0:ac0b0725c6fa | 27 | #include <ble_list.h> |
lorevee | 0:ac0b0725c6fa | 28 | |
lorevee | 0:ac0b0725c6fa | 29 | #define HCI_READ_PACKET_SIZE 128 //71 |
lorevee | 0:ac0b0725c6fa | 30 | |
lorevee | 0:ac0b0725c6fa | 31 | /** |
lorevee | 0:ac0b0725c6fa | 32 | * Maximum payload of HCI commands that can be sent. Change this value if needed. |
lorevee | 0:ac0b0725c6fa | 33 | * This value can be up to 255. |
lorevee | 0:ac0b0725c6fa | 34 | */ |
lorevee | 0:ac0b0725c6fa | 35 | #define HCI_MAX_PAYLOAD_SIZE 128 |
lorevee | 0:ac0b0725c6fa | 36 | |
lorevee | 0:ac0b0725c6fa | 37 | /*** Data types ***/ |
lorevee | 0:ac0b0725c6fa | 38 | |
lorevee | 0:ac0b0725c6fa | 39 | /* structure used to read received data */ |
lorevee | 0:ac0b0725c6fa | 40 | typedef struct _tHciDataPacket |
lorevee | 0:ac0b0725c6fa | 41 | { |
lorevee | 0:ac0b0725c6fa | 42 | tListNode currentNode; |
lorevee | 0:ac0b0725c6fa | 43 | uint8_t dataBuff[HCI_READ_PACKET_SIZE]; |
lorevee | 0:ac0b0725c6fa | 44 | uint8_t data_len; |
lorevee | 0:ac0b0725c6fa | 45 | } tHciDataPacket; |
lorevee | 0:ac0b0725c6fa | 46 | |
lorevee | 0:ac0b0725c6fa | 47 | struct hci_request { |
lorevee | 0:ac0b0725c6fa | 48 | uint16_t ogf; |
lorevee | 0:ac0b0725c6fa | 49 | uint16_t ocf; |
lorevee | 0:ac0b0725c6fa | 50 | int event; |
lorevee | 0:ac0b0725c6fa | 51 | void *cparam; |
lorevee | 0:ac0b0725c6fa | 52 | int clen; |
lorevee | 0:ac0b0725c6fa | 53 | void *rparam; |
lorevee | 0:ac0b0725c6fa | 54 | int rlen; |
lorevee | 0:ac0b0725c6fa | 55 | }; |
lorevee | 0:ac0b0725c6fa | 56 | |
lorevee | 0:ac0b0725c6fa | 57 | typedef enum |
lorevee | 0:ac0b0725c6fa | 58 | { |
lorevee | 0:ac0b0725c6fa | 59 | BUSY, |
lorevee | 0:ac0b0725c6fa | 60 | AVAILABLE |
lorevee | 0:ac0b0725c6fa | 61 | } HCI_CMD_STATUS_t; |
lorevee | 0:ac0b0725c6fa | 62 | |
lorevee | 0:ac0b0725c6fa | 63 | |
lorevee | 0:ac0b0725c6fa | 64 | /** |
lorevee | 0:ac0b0725c6fa | 65 | * This function must be used to pass the packet received from the HCI |
lorevee | 0:ac0b0725c6fa | 66 | * interface to the BLE Stack HCI state machine. |
lorevee | 0:ac0b0725c6fa | 67 | * |
lorevee | 0:ac0b0725c6fa | 68 | * @param[in] hciReadPacket The packet that is received from HCI interface. |
lorevee | 0:ac0b0725c6fa | 69 | * |
lorevee | 0:ac0b0725c6fa | 70 | */ |
lorevee | 0:ac0b0725c6fa | 71 | void HCI_Input(tHciDataPacket *hciReadPacket); |
lorevee | 0:ac0b0725c6fa | 72 | |
lorevee | 0:ac0b0725c6fa | 73 | /** |
lorevee | 0:ac0b0725c6fa | 74 | * Initialization function. Must be done before any data can be received from |
lorevee | 0:ac0b0725c6fa | 75 | * BLE controller. |
lorevee | 0:ac0b0725c6fa | 76 | */ |
lorevee | 0:ac0b0725c6fa | 77 | void HCI_Init(void); |
lorevee | 0:ac0b0725c6fa | 78 | |
lorevee | 0:ac0b0725c6fa | 79 | /** |
lorevee | 0:ac0b0725c6fa | 80 | * Callback used to pass events to application. |
lorevee | 0:ac0b0725c6fa | 81 | * |
lorevee | 0:ac0b0725c6fa | 82 | * @param[in] pckt The event. |
lorevee | 0:ac0b0725c6fa | 83 | * |
lorevee | 0:ac0b0725c6fa | 84 | */ |
lorevee | 0:ac0b0725c6fa | 85 | extern void HCI_Event_CB(void *pckt); |
lorevee | 0:ac0b0725c6fa | 86 | |
lorevee | 0:ac0b0725c6fa | 87 | /** |
lorevee | 0:ac0b0725c6fa | 88 | * Processing function that must be called after an event is received from |
lorevee | 0:ac0b0725c6fa | 89 | * HCI interface. Must be called outside ISR. It will call HCI_Event_CB if |
lorevee | 0:ac0b0725c6fa | 90 | * necessary. |
lorevee | 0:ac0b0725c6fa | 91 | */ |
lorevee | 0:ac0b0725c6fa | 92 | void HCI_Process(void); |
lorevee | 0:ac0b0725c6fa | 93 | |
lorevee | 0:ac0b0725c6fa | 94 | /** |
lorevee | 0:ac0b0725c6fa | 95 | * @brief Check if queue of HCI event is empty or not. |
lorevee | 0:ac0b0725c6fa | 96 | * @note This funtion can be used to check if the event queue from BlueNRG is empty. This |
lorevee | 0:ac0b0725c6fa | 97 | * is useful when checking if it is safe to go to sleep. |
lorevee | 0:ac0b0725c6fa | 98 | * @return TRUE if event queue is empty. FALSE otherwhise. |
lorevee | 0:ac0b0725c6fa | 99 | */ |
lorevee | 0:ac0b0725c6fa | 100 | BOOL HCI_Queue_Empty(void); |
lorevee | 0:ac0b0725c6fa | 101 | /** |
lorevee | 0:ac0b0725c6fa | 102 | * Iterrupt service routine that must be called when the BlueNRG |
lorevee | 0:ac0b0725c6fa | 103 | * reports a packet received or an event to the host through the |
lorevee | 0:ac0b0725c6fa | 104 | * BlueNRG interrupt line. |
lorevee | 0:ac0b0725c6fa | 105 | */ |
lorevee | 0:ac0b0725c6fa | 106 | #ifdef __DMA_LP__ |
lorevee | 0:ac0b0725c6fa | 107 | void HCI_Isr(uint8_t *buffer, uint8_t event_payload_len); |
lorevee | 0:ac0b0725c6fa | 108 | void HCI_Process_Notification_Request(void); |
lorevee | 0:ac0b0725c6fa | 109 | void HCI_Cmd_Status(HCI_CMD_STATUS_t Hci_Cmd_Status); |
lorevee | 0:ac0b0725c6fa | 110 | void HCI_Wait_For_Response(void); |
lorevee | 0:ac0b0725c6fa | 111 | #else |
lorevee | 0:ac0b0725c6fa | 112 | void HCI_Isr(void); |
lorevee | 0:ac0b0725c6fa | 113 | void HCI_HandleSPI(void); |
lorevee | 0:ac0b0725c6fa | 114 | |
lorevee | 0:ac0b0725c6fa | 115 | int hci_send_req(struct hci_request *r, BOOL async); |
lorevee | 0:ac0b0725c6fa | 116 | #endif /* __DMA_LP__ */ |
lorevee | 0:ac0b0725c6fa | 117 | |
lorevee | 0:ac0b0725c6fa | 118 | extern tListNode hciReadPktPool; |
lorevee | 0:ac0b0725c6fa | 119 | extern tListNode hciReadPktRxQueue; |
lorevee | 0:ac0b0725c6fa | 120 | |
lorevee | 0:ac0b0725c6fa | 121 | #ifdef __cplusplus |
lorevee | 0:ac0b0725c6fa | 122 | } |
lorevee | 0:ac0b0725c6fa | 123 | #endif |
lorevee | 0:ac0b0725c6fa | 124 | |
lorevee | 0:ac0b0725c6fa | 125 | |
lorevee | 0:ac0b0725c6fa | 126 | #endif /* __BLE_HCI_H_ */ |