Mistake on this page?
Report an issue in GitHub or email us
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  *
9  * Copyright (c) 2019 Packetcraft, Inc.
10  *
11  * Licensed under the Apache License, Version 2.0 (the "License");
12  * you may not use this file except in compliance with the License.
13  * You may obtain a copy of the License at
14  *
15  * http://www.apache.org/licenses/LICENSE-2.0
16  *
17  * Unless required by applicable law or agreed to in writing, software
18  * distributed under the License is distributed on an "AS IS" BASIS,
19  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20  * See the License for the specific language governing permissions and
21  * limitations under the License.
22  */
23 /*************************************************************************************************/
24 #ifndef HCI_CORE_H
25 #define HCI_CORE_H
26 
27 #include "hci_core_ps.h"
28 #include "wsf_queue.h"
29 #include "wsf_os.h"
30 #include "hci_api.h"
31 #include "cfg_stack.h"
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
37 /**************************************************************************************************
38  Callback Function Types
39 **************************************************************************************************/
40 
41 /*! \brief HCI Reset sequence callback type */
42 typedef void(*hciResetSeq_t)(uint8_t *pMsg, uint16_t opcode);
43 
44 /**************************************************************************************************
45  Data Types
46 **************************************************************************************************/
47 
48 /*! \brief Per-connection structure for ACL packet accounting */
49 typedef struct
50 {
51  uint8_t *pTxAclPkt; /*!< \brief Fragmenting TX ACL packet pointer */
52  uint8_t *pNextTxFrag; /*!< \brief Next TX ACL packet fragment */
53  uint8_t *pRxAclPkt; /*!< \brief RX ACL packet pointer */
54  uint8_t *pNextRxFrag; /*!< \brief Next RX ACL packet fragment */
55  uint16_t handle; /*!< \brief Connection handle */
56  uint16_t txAclRemLen; /*!< \brief Fragmenting TX ACL packet remaining length */
57  uint16_t rxAclRemLen; /*!< \brief Fragmented RX ACL packet remaining length */
58  bool_t fragmenting; /*!< \brief TRUE if fragmenting a TX ACL packet */
59  bool_t flowDisabled; /*!< \brief TRUE if data flow disabled */
60  uint8_t queuedBufs; /*!< \brief Queued ACL buffers on this connection */
61  uint8_t outBufs; /*!< \brief Outstanding ACL buffers sent to controller */
63 
64 /*! \brief Per-connection structure for OSI packet accounting */
65 typedef struct
66 {
67  uint16_t handle; /*!< \brief Connection handle */
68 } hciCoreCis_t;
69 
70 /*! \brief Main control block for dual-chip implementation */
71 typedef struct
72 {
73  hciCoreConn_t conn[DM_CONN_MAX]; /*!< \brief Connection structures */
74  hciCoreCis_t cis[DM_CIS_MAX]; /*!< \brief CIS structures */
75  uint8_t leStates[HCI_LE_STATES_LEN]; /*!< \brief Controller LE supported states */
76  bdAddr_t bdAddr; /*!< \brief Bluetooth device address */
77  wsfQueue_t aclQueue; /*!< \brief HCI ACL TX queue */
78  hciCoreConn_t *pConnRx; /*!< \brief Connection struct for current transport RX packet */
79  uint16_t maxRxAclLen; /*!< \brief Maximum reassembled RX ACL packet length */
80  uint16_t bufSize; /*!< \brief Controller ACL data buffer size */
81  uint8_t aclQueueHi; /*!< \brief Disable flow when this many ACL buffers queued */
82  uint8_t aclQueueLo; /*!< \brief Enable flow when this many ACL buffers queued */
83  uint8_t availBufs; /*!< \brief Current avail ACL data buffers */
84  uint8_t numBufs; /*!< \brief Controller number of ACL data buffers */
85  uint8_t whiteListSize; /*!< \brief Controller white list size */
86  uint8_t numCmdPkts; /*!< \brief Controller command packed count */
87  uint64_t leSupFeat; /*!< \brief Controller LE supported features */
88  int8_t advTxPwr; /*!< \brief Controller advertising TX power */
89  uint8_t resListSize; /*!< \brief Controller resolving list size */
90  uint16_t maxAdvDataLen; /*!< \brief Controller maximum advertisement (or scan response) data length */
91  uint8_t numSupAdvSets; /*!< \brief Controller maximum number of advertising sets */
92  uint8_t perAdvListSize; /*!< \brief Controller periodic advertising list size */
93  hciLocalVerInfo_t locVerInfo; /*!< \brief Controller version information */
94  hciResetSeq_t extResetSeq; /*!< \brief HCI extended reset sequence callback */
95 } hciCoreCb_t;
96 
97 /**************************************************************************************************
98  Global Variables
99 **************************************************************************************************/
100 
101 /*! \brief Control block */
102 extern hciCoreCb_t hciCoreCb;
103 
104 /*! \brief Event mask */
105 extern const uint8_t hciEventMask[HCI_EVT_MASK_LEN];
106 
107 /*! \brief LE event mask */
108 extern const uint8_t hciLeEventMask[HCI_LE_EVT_MASK_LEN];
109 
110 /*! \brief Event mask page 2 */
111 extern const uint8_t hciEventMaskPage2[HCI_EVT_MASK_LEN];
112 
113 /*! \brief LE supported features configuration mask */
114 extern uint64_t hciLeSupFeatCfg;
115 
116 /**************************************************************************************************
117  Function Declarations
118 **************************************************************************************************/
119 
120 /*************************************************************************************************/
121 /*!
122  * \brief HCI core initialization.
123  *
124  * \return None.
125  */
126 /*************************************************************************************************/
127 void hciCoreInit(void);
128 
129 /*************************************************************************************************/
130 /*!
131  * \fn hciCoreResetStart
132  *
133  * \brief Start the HCI reset sequence.
134  *
135  * \return None.
136  */
137 /*************************************************************************************************/
138 void hciCoreResetStart(void);
139 
140 /*************************************************************************************************/
141 /*!
142  * \brief Perform internal processing on HCI connection open.
143  *
144  * \param handle Connection handle.
145  *
146  * \return None.
147  */
148 /*************************************************************************************************/
149 void hciCoreConnOpen(uint16_t handle);
150 
151 /*************************************************************************************************/
152 /*!
153  * \brief Perform internal processing on HCI connection close.
154  *
155  * \param handle Connection handle.
156  *
157  * \return None.
158  */
159 /*************************************************************************************************/
160 void hciCoreConnClose(uint16_t handle);
161 
162 /*************************************************************************************************/
163 /*!
164  * \brief Get a connection structure by handle
165  *
166  * \param handle Connection handle.
167  *
168  * \return Pointer to connection structure or NULL if not found.
169  */
170 /*************************************************************************************************/
171 hciCoreConn_t *hciCoreConnByHandle(uint16_t handle);
172 
173 /*************************************************************************************************/
174 /*!
175  * \brief Perform internal processing on HCI CIS connection open.
176  *
177  * \param handle Connection handle.
178  *
179  * \return None.
180  */
181 /*************************************************************************************************/
182 void hciCoreCisOpen(uint16_t handle);
183 
184 /*************************************************************************************************/
185 /*!
186  * \brief Perform internal processing on HCI CIS connection close.
187  *
188  * \param handle Connection handle.
189  *
190  * \return None.
191  */
192 /*************************************************************************************************/
193 void hciCoreCisClose(uint16_t handle);
194 
195 /*************************************************************************************************/
196 /*!
197  * \brief Get a CIS connection structure by handle
198  *
199  * \param handle Connection handle.
200  *
201  * \return Pointer to CIS connection structure or NULL if not found.
202  */
203 /*************************************************************************************************/
204 hciCoreCis_t *hciCoreCisByHandle(uint16_t handle);
205 
206 /*************************************************************************************************/
207 /*!
208  * \brief Send ACL data to transport.
209  *
210  * \param pConn Pointer to connection structure.
211  * \param pData WSF buffer containing an ACL packet.
212  *
213  * \return None.
214  */
215 /*************************************************************************************************/
216 void hciCoreSendAclData(hciCoreConn_t *pConn, uint8_t *pData);
217 
218 /*************************************************************************************************/
219 /*!
220  * \brief Service the TX data path.
221  *
222  * \param bufs Number of new buffers now available.
223  *
224  * \return None.
225  */
226 /*************************************************************************************************/
227 void hciCoreTxReady(uint8_t bufs);
228 
229 /*************************************************************************************************/
230 /*!
231  * \brief Send ACL packets, start of packet.
232  *
233  * \param pConn Pointer to connection structure.
234  * \param len ACL packet length.
235  * \param pData WSF buffer containing an ACL packet.
236  *
237  * \return None.
238  */
239 /*************************************************************************************************/
240 void hciCoreTxAclStart(hciCoreConn_t *pConn, uint16_t len, uint8_t *pData);
241 
242 /*************************************************************************************************/
243 /*!
244  * \brief Send ACL packets, continuation of fragmented packets.
245  *
246  * \param pConn Pointer to connection structure. If set non-NULL, then a fragment is
247  * sent from this connection structure. If NULL the function finds the next
248  * connection structure with a fragment to be sent.
249  *
250  * \return TRUE if packet sent, FALSE otherwise.
251  */
252 /*************************************************************************************************/
253 bool_t hciCoreTxAclContinue(hciCoreConn_t *pConn);
254 
255 /*************************************************************************************************/
256 /*!
257  * \brief This function is called from the HCI transport layer when transmission of an ACL
258  * packet is complete.
259  *
260  * \param pConn Pointer to connection structure.
261  * \param pData WSF buffer containing an ACL packet.
262  *
263  * \return None.
264  */
265 /*************************************************************************************************/
266 void hciCoreTxAclComplete(hciCoreConn_t *pConn, uint8_t *pData);
267 
268 /*************************************************************************************************/
269 /*!
270  * \brief Reassemble an ACL packet.
271  *
272  * \param pData Input ACL packet.
273  *
274  * \return pointer to ACL packet to send, or NULL if no packet to send.
275  */
276 /*************************************************************************************************/
277 uint8_t *hciCoreAclReassembly(uint8_t *pData);
278 
279 /*************************************************************************************************/
280 /*!
281  * \brief Check if a TX ACL packet is being fragmented.
282  *
283  * \param pConn Connection context.
284  *
285  * \return TRUE if fragmenting a TX ACL packet, FALSE otherwise.
286  */
287 /*************************************************************************************************/
289 
290 #ifdef __cplusplus
291 };
292 #endif
293 
294 #endif /* HCI_CORE_H */
hciCoreCis_t * hciCoreCisByHandle(uint16_t handle)
Get a CIS connection structure by handle.
uint8_t * pRxAclPkt
RX ACL packet pointer.
Definition: hci_core.h:53
hciCoreConn_t * hciCoreConnByHandle(uint16_t handle)
Get a connection structure by handle.
uint64_t hciLeSupFeatCfg
LE supported features configuration mask.
wsfQueue_t aclQueue
HCI ACL TX queue.
Definition: hci_core.h:77
HCI subsystem API.
void hciCoreCisOpen(uint16_t handle)
Perform internal processing on HCI CIS connection open.
Per-connection structure for OSI packet accounting.
Definition: hci_core.h:65
const uint8_t hciEventMask[HCI_EVT_MASK_LEN]
Event mask.
uint16_t bufSize
Controller ACL data buffer size.
Definition: hci_core.h:80
uint8_t availBufs
Current avail ACL data buffers.
Definition: hci_core.h:83
void hciCoreInit(void)
HCI core initialization.
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...
HCI core platform-specific interfaces for dual-chip.
bdAddr_t bdAddr
Bluetooth device address.
Definition: hci_core.h:76
uint8_t numCmdPkts
Controller command packed count.
Definition: hci_core.h:86
#define HCI_LE_STATES_LEN
Definition: hci_defs.h:1448
uint64_t leSupFeat
Controller LE supported features.
Definition: hci_core.h:87
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.
Main control block for dual-chip implementation.
Definition: hci_core.h:71
void hciCoreSendAclData(hciCoreConn_t *pConn, uint8_t *pData)
Send ACL data to transport.
#define HCI_LE_EVT_MASK_LEN
Definition: hci_defs.h:1435
uint16_t handle
Connection handle.
Definition: hci_core.h:55
int8_t advTxPwr
Controller advertising TX power.
Definition: hci_core.h:88
uint8_t numBufs
Controller number of ACL data buffers.
Definition: hci_core.h:84
uint8_t * pNextTxFrag
Next TX ACL packet fragment.
Definition: hci_core.h:52
void hciCoreTxAclStart(hciCoreConn_t *pConn, uint16_t len, uint8_t *pData)
Send ACL packets, start of packet.
void(* hciResetSeq_t)(uint8_t *pMsg, uint16_t opcode)
HCI Reset sequence callback type.
Definition: hci_core.h:42
hciCoreCb_t hciCoreCb
Control block.
uint8_t aclQueueLo
Enable flow when this many ACL buffers queued.
Definition: hci_core.h:82
uint8_t bdAddr_t[6]
BD address data type.
Definition: bda.h:67
const uint8_t hciEventMaskPage2[HCI_EVT_MASK_LEN]
Event mask page 2.
uint16_t txAclRemLen
Fragmenting TX ACL packet remaining length.
Definition: hci_core.h:56
uint8_t queuedBufs
Queued ACL buffers on this connection.
Definition: hci_core.h:60
#define HCI_EVT_MASK_LEN
Definition: hci_defs.h:1433
Queue structure.
Definition: wsf_queue.h:46
uint16_t maxAdvDataLen
Controller maximum advertisement (or scan response) data length.
Definition: hci_core.h:90
uint8_t * hciCoreAclReassembly(uint8_t *pData)
Reassemble an ACL packet.
uint8_t * pNextRxFrag
Next RX ACL packet fragment.
Definition: hci_core.h:54
bool_t fragmenting
TRUE if fragmenting a TX ACL packet.
Definition: hci_core.h:58
uint16_t rxAclRemLen
Fragmented RX ACL packet remaining length.
Definition: hci_core.h:57
void hciCoreConnOpen(uint16_t handle)
Perform internal processing on HCI connection open.
uint8_t resListSize
Controller resolving list size.
Definition: hci_core.h:89
void hciCoreTxReady(uint8_t bufs)
Service the TX data path.
uint8_t outBufs
Outstanding ACL buffers sent to controller.
Definition: hci_core.h:61
uint8_t numSupAdvSets
Controller maximum number of advertising sets.
Definition: hci_core.h:91
General purpose queue service.
#define DM_CONN_MAX
Maximum number of connections.
Definition: cfg_stack.h:81
hciLocalVerInfo_t locVerInfo
Controller version information.
Definition: hci_core.h:93
uint16_t handle
Connection handle.
Definition: hci_core.h:67
uint8_t * pTxAclPkt
Fragmenting TX ACL packet pointer.
Definition: hci_core.h:51
bool_t flowDisabled
TRUE if data flow disabled.
Definition: hci_core.h:59
hciCoreConn_t * pConnRx
Connection struct for current transport RX packet.
Definition: hci_core.h:78
void hciCoreResetStart(void)
Start the HCI reset sequence.
void hciCoreCisClose(uint16_t handle)
Perform internal processing on HCI CIS connection close.
Software foundation OS API.
Per-connection structure for ACL packet accounting.
Definition: hci_core.h:49
uint8_t aclQueueHi
Disable flow when this many ACL buffers queued.
Definition: hci_core.h:81
hciResetSeq_t extResetSeq
HCI extended reset sequence callback.
Definition: hci_core.h:94
void hciCoreConnClose(uint16_t handle)
Perform internal processing on HCI connection close.
#define DM_CIS_MAX
Maximum number of connected isochronous streams, it is shared by CIGs.
Definition: cfg_stack.h:107
uint8_t whiteListSize
Controller white list size.
Definition: hci_core.h:85
Local version information.
Definition: hci_api.h:921
uint16_t maxRxAclLen
Maximum reassembled RX ACL packet length.
Definition: hci_core.h:79
Stack configuration.
uint8_t perAdvListSize
Controller periodic advertising list size.
Definition: hci_core.h:92
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.