Mistake on this page? 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  * 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  uint32_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  hciLocalVerInfo_t locVerInfo; /*!< \brief Controller version information */
82  hciResetSeq_t extResetSeq; /*!< \brief HCI extended reset sequence callback */
83 } hciCoreCb_t;
84 
85 /**************************************************************************************************
86  Global Variables
87 **************************************************************************************************/
88 
89 /*! \brief Control block */
90 extern hciCoreCb_t hciCoreCb;
91 
92 /*! \brief Event mask */
93 extern const uint8_t hciEventMask[HCI_EVT_MASK_LEN];
94 
95 /*! \brief LE event mask */
96 extern const uint8_t hciLeEventMask[HCI_LE_EVT_MASK_LEN];
97 
98 /*! \brief Event mask page 2 */
99 extern const uint8_t hciEventMaskPage2[HCI_EVT_MASK_LEN];
100 
101 /*! \brief LE supported features configuration mask */
102 extern uint32_t hciLeSupFeatCfg;
103 
104 /**************************************************************************************************
105  Function Declarations
106 **************************************************************************************************/
107 
108 /*************************************************************************************************/
109 /*!
110  * \brief HCI core initialization.
111  *
112  * \return None.
113  */
114 /*************************************************************************************************/
115 void hciCoreInit(void);
116 
117 /*************************************************************************************************/
118 /*!
119  * \fn hciCoreResetStart
120  *
121  * \brief Start the HCI reset sequence.
122  *
123  * \return None.
124  */
125 /*************************************************************************************************/
126 void hciCoreResetStart(void);
127 
128 /*************************************************************************************************/
129 /*!
130  * \brief Perform internal processing on HCI connection open.
131  *
132  * \param handle Connection handle.
133  *
134  * \return None.
135  */
136 /*************************************************************************************************/
137 void hciCoreConnOpen(uint16_t handle);
138 
139 /*************************************************************************************************/
140 /*!
141  * \brief Perform internal processing on HCI connection close.
142  *
143  * \param handle Connection handle.
144  *
145  * \return None.
146  */
147 /*************************************************************************************************/
148 void hciCoreConnClose(uint16_t handle);
149 
150 /*************************************************************************************************/
151 /*!
152  * \brief Get a connection structure by handle
153  *
154  * \param handle Connection handle.
155  *
156  * \return Pointer to connection structure or NULL if not found.
157  */
158 /*************************************************************************************************/
159 hciCoreConn_t *hciCoreConnByHandle(uint16_t handle);
160 
161 /*************************************************************************************************/
162 /*!
163  * \brief Send ACL data to transport.
164  *
165  * \param pConn Pointer to connection structure.
166  * \param pData WSF buffer containing an ACL packet.
167  *
168  * \return None.
169  */
170 /*************************************************************************************************/
171 void hciCoreSendAclData(hciCoreConn_t *pConn, uint8_t *pData);
172 
173 /*************************************************************************************************/
174 /*!
175  * \brief Service the TX data path.
176  *
177  * \param bufs Number of new buffers now available.
178  *
179  * \return None.
180  */
181 /*************************************************************************************************/
182 void hciCoreTxReady(uint8_t bufs);
183 
184 /*************************************************************************************************/
185 /*!
186  * \brief Send ACL packets, start of packet.
187  *
188  * \param pConn Pointer to connection structure.
189  * \param len ACL packet length.
190  * \param pData WSF buffer containing an ACL packet.
191  *
192  * \return None.
193  */
194 /*************************************************************************************************/
195 void hciCoreTxAclStart(hciCoreConn_t *pConn, uint16_t len, uint8_t *pData);
196 
197 /*************************************************************************************************/
198 /*!
199  * \brief Send ACL packets, continuation of fragmented packets.
200  *
201  * \param pConn Pointer to connection structure. If set non-NULL, then a fragment is
202  * sent from this connection structure. If NULL the function finds the next
203  * connection structure with a fragment to be sent.
204  *
205  * \return TRUE if packet sent, FALSE otherwise.
206  */
207 /*************************************************************************************************/
208 bool_t hciCoreTxAclContinue(hciCoreConn_t *pConn);
209 
210 /*************************************************************************************************/
211 /*!
212  * \brief This function is called from the HCI transport layer when transmission of an ACL
213  * packet is complete.
214  *
215  * \param pConn Pointer to connection structure.
216  * \param pData WSF buffer containing an ACL packet.
217  *
218  * \return None.
219  */
220 /*************************************************************************************************/
221 void hciCoreTxAclComplete(hciCoreConn_t *pConn, uint8_t *pData);
222 
223 /*************************************************************************************************/
224 /*!
225  * \brief Reassemble an ACL packet.
226  *
227  * \param pData Input ACL packet.
228  *
229  * \return pointer to ACL packet to send, or NULL if no packet to send.
230  */
231 /*************************************************************************************************/
232 uint8_t *hciCoreAclReassembly(uint8_t *pData);
233 
234 /*************************************************************************************************/
235 /*!
236  * \brief Check if a TX ACL packet is being fragmented.
237  *
238  * \param pConn Connection context.
239  *
240  * \return TRUE if fragmenting a TX ACL packet, FALSE otherwise.
241  */
242 /*************************************************************************************************/
244 
245 #ifdef __cplusplus
246 };
247 #endif
248 
249 #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 rxAclRemLen
Fragmented RX ACL packet remaining length.
Definition: hci_core.h:52
const uint8_t hciEventMask[HCI_EVT_MASK_LEN]
Event mask.
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.
uint32_t hciLeSupFeatCfg
LE supported features configuration mask.
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
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
hciLocalVerInfo_t locVerInfo
Controller version information.
Definition: hci_core.h:81
void hciCoreSendAclData(hciCoreConn_t *pConn, uint8_t *pData)
Send ACL data to transport.
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
uint8_t * hciCoreAclReassembly(uint8_t *pData)
Reassemble an ACL packet.
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:82
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
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.
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.
uint32_t leSupFeat
Controller LE supported features.
Definition: hci_core.h:75
Local version information.
Definition: hci_api.h:680
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.