Cordio Stack and Cordio Profiles  r2p3-02rel0
hci_core.h
Go to the documentation of this file.
1 /*************************************************************************************************/
2 /*!
3  * \file
4  *
5  * \brief HCI core interfaces.
6  *
7  * Copyright (c) 2009-2018 Arm Ltd. All Rights Reserved.
8  * Arm Ltd. confidential and proprietary.
9  *
10  * IMPORTANT. Your use of this file is governed by a Software License Agreement
11  * ("Agreement") that must be accepted in order to download or otherwise receive a
12  * copy of this file. You may not use or copy this file for any purpose other than
13  * as described in the Agreement. If you do not agree to all of the terms of the
14  * Agreement do not use this file and delete all copies in your possession or control;
15  * if you do not have a copy of the Agreement, you must contact Arm Ltd. prior
16  * to any use, copying or further distribution of this software.
17  */
18 /*************************************************************************************************/
19 #ifndef HCI_CORE_H
20 #define HCI_CORE_H
21 
22 #include "hci_core_ps.h"
23 #include "wsf_queue.h"
24 #include "wsf_os.h"
25 #include "hci_api.h"
26 #include "cfg_stack.h"
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
32 /**************************************************************************************************
33  Callback Function Types
34 **************************************************************************************************/
35 
36 /*! \brief HCI Reset sequence callback type */
37 typedef void(*hciResetSeq_t)(uint8_t *pMsg, uint16_t opcode);
38 
39 /**************************************************************************************************
40  Data Types
41 **************************************************************************************************/
42 
43 /*! \brief Per-connection structure for ACL packet accounting */
44 typedef struct
45 {
46  uint8_t *pTxAclPkt; /*!< \brief Fragmenting TX ACL packet pointer */
47  uint8_t *pNextTxFrag; /*!< \brief Next TX ACL packet fragment */
48  uint8_t *pRxAclPkt; /*!< \brief RX ACL packet pointer */
49  uint8_t *pNextRxFrag; /*!< \brief Next RX ACL packet fragment */
50  uint16_t handle; /*!< \brief Connection handle */
51  uint16_t txAclRemLen; /*!< \brief Fragmenting TX ACL packet remaining length */
52  uint16_t rxAclRemLen; /*!< \brief Fragmented RX ACL packet remaining length */
53  bool_t fragmenting; /*!< \brief TRUE if fragmenting a TX ACL packet */
54  bool_t flowDisabled; /*!< \brief TRUE if data flow disabled */
55  uint8_t queuedBufs; /*!< \brief Queued ACL buffers on this connection */
56  uint8_t outBufs; /*!< \brief Outstanding ACL buffers sent to controller */
58 
59 /*! \brief Main control block for dual-chip implementation */
60 typedef struct
61 {
62  hciCoreConn_t conn[DM_CONN_MAX]; /*!< \brief Connection structures */
63  uint8_t leStates[HCI_LE_STATES_LEN]; /*!< \brief Controller LE supported states */
64  bdAddr_t bdAddr; /*!< \brief Bluetooth device address */
65  wsfQueue_t aclQueue; /*!< \brief HCI ACL TX queue */
66  hciCoreConn_t *pConnRx; /*!< \brief Connection struct for current transport RX packet */
67  uint16_t maxRxAclLen; /*!< \brief Maximum reassembled RX ACL packet length */
68  uint16_t bufSize; /*!< \brief Controller ACL data buffer size */
69  uint8_t aclQueueHi; /*!< \brief Disable flow when this many ACL buffers queued */
70  uint8_t aclQueueLo; /*!< \brief Enable flow when this many ACL buffers queued */
71  uint8_t availBufs; /*!< \brief Current avail ACL data buffers */
72  uint8_t numBufs; /*!< \brief Controller number of ACL data buffers */
73  uint8_t whiteListSize; /*!< \brief Controller white list size */
74  uint8_t numCmdPkts; /*!< \brief Controller command packed count */
75  uint16_t leSupFeat; /*!< \brief Controller LE supported features */
76  int8_t advTxPwr; /*!< \brief Controller advertising TX power */
77  uint8_t resListSize; /*!< \brief Controller resolving list size */
78  uint16_t maxAdvDataLen; /*!< \brief Controller maximum advertisement (or scan response) data length */
79  uint8_t numSupAdvSets; /*!< \brief Controller maximum number of advertising sets */
80  uint8_t perAdvListSize; /*!< \brief Controller periodic advertising list size */
81  hciResetSeq_t extResetSeq; /*!< \brief HCI extended reset sequence callback */
82 } hciCoreCb_t;
83 
84 /**************************************************************************************************
85  Global Variables
86 **************************************************************************************************/
87 
88 /*! \brief Control block */
89 extern hciCoreCb_t hciCoreCb;
90 
91 /*! \brief Event mask */
93 
94 /*! \brief LE event mask */
96 
97 /*! \brief Event mask page 2 */
99 
100 /*! \brief LE supported features configuration mask */
102 
103 /**************************************************************************************************
104  Function Declarations
105 **************************************************************************************************/
106 
107 /*************************************************************************************************/
108 /*!
109  * \brief HCI core initialization.
110  *
111  * \return None.
112  */
113 /*************************************************************************************************/
114 void hciCoreInit(void);
115 
116 /*************************************************************************************************/
117 /*!
118  * \fn hciCoreResetStart
119  *
120  * \brief Start the HCI reset sequence.
121  *
122  * \return None.
123  */
124 /*************************************************************************************************/
125 void hciCoreResetStart(void);
126 
127 /*************************************************************************************************/
128 /*!
129  * \brief Perform internal processing on HCI connection open.
130  *
131  * \param handle Connection handle.
132  *
133  * \return None.
134  */
135 /*************************************************************************************************/
136 void hciCoreConnOpen(uint16_t handle);
137 
138 /*************************************************************************************************/
139 /*!
140  * \brief Perform internal processing on HCI connection close.
141  *
142  * \param handle Connection handle.
143  *
144  * \return None.
145  */
146 /*************************************************************************************************/
147 void hciCoreConnClose(uint16_t handle);
148 
149 /*************************************************************************************************/
150 /*!
151  * \brief Get a connection structure by handle
152  *
153  * \param handle Connection handle.
154  *
155  * \return Pointer to connection structure or NULL if not found.
156  */
157 /*************************************************************************************************/
159 
160 /*************************************************************************************************/
161 /*!
162  * \brief Send ACL data to transport.
163  *
164  * \param pConn Pointer to connection structure.
165  * \param pData WSF buffer containing an ACL packet.
166  *
167  * \return None.
168  */
169 /*************************************************************************************************/
170 void hciCoreSendAclData(hciCoreConn_t *pConn, uint8_t *pData);
171 
172 /*************************************************************************************************/
173 /*!
174  * \brief Service the TX data path.
175  *
176  * \param bufs Number of new buffers now available.
177  *
178  * \return None.
179  */
180 /*************************************************************************************************/
181 void hciCoreTxReady(uint8_t bufs);
182 
183 /*************************************************************************************************/
184 /*!
185  * \brief Send ACL packets, start of packet.
186  *
187  * \param pConn Pointer to connection structure.
188  * \param len ACL packet length.
189  * \param pData WSF buffer containing an ACL packet.
190  *
191  * \return None.
192  */
193 /*************************************************************************************************/
194 void hciCoreTxAclStart(hciCoreConn_t *pConn, uint16_t len, uint8_t *pData);
195 
196 /*************************************************************************************************/
197 /*!
198  * \brief Send ACL packets, continuation of fragmented packets.
199  *
200  * \param pConn Pointer to connection structure. If set non-NULL, then a fragment is
201  * sent from this connection structure. If NULL the function finds the next
202  * connection structure with a fragment to be sent.
203  *
204  * \return TRUE if packet sent, FALSE otherwise.
205  */
206 /*************************************************************************************************/
208 
209 /*************************************************************************************************/
210 /*!
211  * \brief This function is called from the HCI transport layer when transmission of an ACL
212  * packet is complete.
213  *
214  * \param pConn Pointer to connection structure.
215  * \param pData WSF buffer containing an ACL packet.
216  *
217  * \return None.
218  */
219 /*************************************************************************************************/
220 void hciCoreTxAclComplete(hciCoreConn_t *pConn, uint8_t *pData);
221 
222 /*************************************************************************************************/
223 /*!
224  * \brief Reassemble an ACL packet.
225  *
226  * \param pData Input ACL packet.
227  *
228  * \return pointer to ACL packet to send, or NULL if no packet to send.
229  */
230 /*************************************************************************************************/
232 
233 /*************************************************************************************************/
234 /*!
235  * \brief Check if a TX ACL packet is being fragmented.
236  *
237  * \param pConn Connection context.
238  *
239  * \return TRUE if fragmenting a TX ACL packet, FALSE otherwise.
240  */
241 /*************************************************************************************************/
243 
244 #ifdef __cplusplus
245 };
246 #endif
247 
248 #endif /* HCI_CORE_H */
uint8_t outBufs
Outstanding ACL buffers sent to controller.
Definition: hci_core.h:56
uint8_t perAdvListSize
Controller periodic advertising list size.
Definition: hci_core.h:80
hciCoreConn_t * hciCoreConnByHandle(uint16_t handle)
Get a connection structure by handle.
HCI subsystem API.
uint16_t handle
Connection handle.
Definition: hci_core.h:50
uint16_t leSupFeat
Controller LE supported features.
Definition: hci_core.h:75
uint16_t hciLeSupFeatCfg
LE supported features configuration mask.
uint16_t rxAclRemLen
Fragmented RX ACL packet remaining length.
Definition: hci_core.h:52
const uint8_t hciEventMask[HCI_EVT_MASK_LEN]
Event mask.
uint8_t bool_t
Boolean data type.
Definition: wsf_types.h:78
uint16_t maxAdvDataLen
Controller maximum advertisement (or scan response) data length.
Definition: hci_core.h:78
uint8_t * pNextRxFrag
Next RX ACL packet fragment.
Definition: hci_core.h:49
void hciCoreInit(void)
HCI core initialization.
bdAddr_t bdAddr
Bluetooth device address.
Definition: hci_core.h:64
void hciCoreTxAclComplete(hciCoreConn_t *pConn, uint8_t *pData)
This function is called from the HCI transport layer when transmission of an ACL packet is complete...
uint8_t * pNextTxFrag
Next TX ACL packet fragment.
Definition: hci_core.h:47
#define HCI_LE_STATES_LEN
Length of LE states byte array.
Definition: hci_defs.h:1063
bool_t hciCoreTxAclDataFragmented(hciCoreConn_t *pConn)
Check if a TX ACL packet is being fragmented.
const uint8_t hciLeEventMask[HCI_LE_EVT_MASK_LEN]
LE event mask.
bool_t hciCoreTxAclContinue(hciCoreConn_t *pConn)
Send ACL packets, continuation of fragmented packets.
uint8_t aclQueueLo
Enable flow when this many ACL buffers queued.
Definition: hci_core.h:70
Main control block for dual-chip implementation.
Definition: hci_core.h:60
void hciCoreSendAclData(hciCoreConn_t *pConn, uint8_t *pData)
Send ACL data to transport.
#define HCI_LE_EVT_MASK_LEN
Length of LE event mask byte array.
Definition: hci_defs.h:1051
uint8_t numCmdPkts
Controller command packed count.
Definition: hci_core.h:74
bool_t flowDisabled
TRUE if data flow disabled.
Definition: hci_core.h:54
bool_t fragmenting
TRUE if fragmenting a TX ACL packet.
Definition: hci_core.h:53
uint16_t maxRxAclLen
Maximum reassembled RX ACL packet length.
Definition: hci_core.h:67
void hciCoreTxAclStart(hciCoreConn_t *pConn, uint16_t len, uint8_t *pData)
Send ACL packets, start of packet.
uint8_t numBufs
Controller number of ACL data buffers.
Definition: hci_core.h:72
void(* hciResetSeq_t)(uint8_t *pMsg, uint16_t opcode)
HCI Reset sequence callback type.
Definition: hci_core.h:37
hciCoreCb_t hciCoreCb
Control block.
wsfQueue_t aclQueue
HCI ACL TX queue.
Definition: hci_core.h:65
uint8_t aclQueueHi
Disable flow when this many ACL buffers queued.
Definition: hci_core.h:69
const uint8_t hciEventMaskPage2[HCI_EVT_MASK_LEN]
Event mask page 2.
hciCoreConn_t * pConnRx
Connection struct for current transport RX packet.
Definition: hci_core.h:66
#define HCI_EVT_MASK_LEN
Length of event mask byte array.
Definition: hci_defs.h:1049
Queue structure.
Definition: wsf_queue.h:41
uint8_t * hciCoreAclReassembly(uint8_t *pData)
Reassemble an ACL packet.
uint8_t bdAddr_t[BDA_ADDR_LEN]
BD address data type.
Definition: bda.h:62
uint8_t numSupAdvSets
Controller maximum number of advertising sets.
Definition: hci_core.h:79
uint16_t bufSize
Controller ACL data buffer size.
Definition: hci_core.h:68
void hciCoreConnOpen(uint16_t handle)
Perform internal processing on HCI connection open.
hciResetSeq_t extResetSeq
HCI extended reset sequence callback.
Definition: hci_core.h:81
uint8_t availBufs
Current avail ACL data buffers.
Definition: hci_core.h:71
uint8_t * pRxAclPkt
RX ACL packet pointer.
Definition: hci_core.h:48
void hciCoreTxReady(uint8_t bufs)
Service the TX data path.
int8_t advTxPwr
Controller advertising TX power.
Definition: hci_core.h:76
uint8_t * pTxAclPkt
Fragmenting TX ACL packet pointer.
Definition: hci_core.h:46
unsigned short uint16_t
Unsigned 16-bit value.
Definition: wsf_types.h:67
General purpose queue service.
#define DM_CONN_MAX
Maximum number of connections.
Definition: cfg_stack.h:74
uint8_t whiteListSize
Controller white list size.
Definition: hci_core.h:73
uint8_t resListSize
Controller resolving list size.
Definition: hci_core.h:77
void hciCoreResetStart(void)
Start the HCI reset sequence.
Software foundation OS API.
uint16_t txAclRemLen
Fragmenting TX ACL packet remaining length.
Definition: hci_core.h:51
uint8_t queuedBufs
Queued ACL buffers on this connection.
Definition: hci_core.h:55
Per-connection structure for ACL packet accounting.
Definition: hci_core.h:44
void hciCoreConnClose(uint16_t handle)
Perform internal processing on HCI connection close.
unsigned char uint8_t
Unsigned 8-bit value.
Definition: wsf_types.h:63
Stack configuration.
signed char int8_t
Signed 8-bit value.
Definition: wsf_types.h:61