Mistake on this page?
Report an issue in GitHub or email us
bb_ble_int.h
Go to the documentation of this file.
1 /*************************************************************************************************/
2 /*!
3  * \file
4  *
5  * \brief Internal BLE baseband interface file.
6  *
7  * Copyright (c) 2013-2019 Arm Ltd. All Rights Reserved.
8  *
9  * Copyright (c) 2019-2020 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 
25 #ifndef BB_BLE_INT_H
26 #define BB_BLE_INT_H
27 
28 #include "bb_ble_api.h"
29 #include "bb_ble_api_op.h"
30 #include "pal_bb_ble.h"
31 #include "pal_bb.h"
32 #include "ll_defs.h"
33 #include "wsf_assert.h"
34 #include "wsf_math.h"
35 #include "cfg_mac_ble.h"
36 
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40 
41 /**************************************************************************************************
42  Macros
43 **************************************************************************************************/
44 
45 /*! \brief Maximum length of an advertising packet. */
46 #define BB_ADVB_MAX_LEN WSF_MAX(BB_FIXED_ADVB_PKT_LEN, LL_ADVB_MAX_LEN)
47 
48 /*! \brief Mark the start of an ISR. */
49 #define BB_ISR_START() bbIsrStartTime = PalBbGetCurrentTime()
50 
51 /*! \brief Mark the ISR duration, recording the high watermark. */
52 #define BB_ISR_MARK(x) x = WSF_MAX(x, PalBbGetCurrentTime() - bbIsrStartTime)
53 
54 /*! \brief Event states for advertising operations. */
55 enum
56 {
57  BB_EVT_STATE_TX_ADV_IND, /*!< Advertising indication. */
58  BB_EVT_STATE_RX_SCAN_OR_CONN_INIT, /*!< Scan or connection init packet. */
59  BB_EVT_STATE_TX_SCAN_OR_CONN_RSP, /*!< Scan or connection response. */
60  BB_EVT_STATE_TX_CHAIN_IND /*!< Chain indication. */
61 };
62 
63 /*! \brief Event states for scanning operations. */
64 enum
65 {
66  BB_EVT_STATE_RX_ADV_IND, /*!< Advertising indication. */
67  BB_EVT_STATE_TX_SCAN_OR_CONN_INIT, /*!< Scan or connection init packet. */
68  BB_EVT_STATE_RX_SCAN_OR_CONN_RSP, /*!< Scan or connection response. */
69  BB_EVT_STATE_RX_CHAIN_IND /*!< Chain indication. */
70 };
71 
72 /**************************************************************************************************
73  Data Types
74 **************************************************************************************************/
75 
76 /*! \brief Execution operation function. */
77 typedef void (*bbBleExecOpFn_t)(BbOpDesc_t *pBod, BbBleData_t *pBle);
78 
79 /*! \brief BB control block. */
80 typedef struct
81 {
82  struct
83  {
84  bbBleExecOpFn_t execOpCback; /*!< Execute operation handler. */
85  bbBleExecOpFn_t cancelOpCback; /*!< Cancel operation handler. */
86  } opCbacks[BB_BLE_OP_NUM]; /*!< Operation handlers. */
87 
88  uint8_t evtState; /*!< Action state of the currently operating BOD. */
89  uint8_t advChIdx; /*!< Current advertising channel index. */
90  uint8_t numChUsed; /*!< Total number of channels visited. */
91  uint32_t lastScanStartUsec; /*!< Last scan start time in microseconds. */
92 
93  PalBbBleDataParam_t bbParam; /*!< Baseband data parameters. */
94 
95  uint16_t rxDataLen; /*!< Receive data buffer length. */
96  uint8_t *pRxDataBuf; /*!< Current Rx data buffer. */
97 
98  /* TODO combine with above? */
99  uint16_t rxCisDataLen; /*!< Receive CIS data buffer length. */
100  uint8_t *pRxCisDataBuf; /*!< Current Rx CIS data buffer. */
102 
103 /**************************************************************************************************
104  Global Variables
105 **************************************************************************************************/
106 
107 /* BB BLE Control Block. */
108 extern bbBleCtrlBlk_t bbBleCb;
109 
110 /* ISR start time. */
111 extern uint32_t bbIsrStartTime;
112 
113 /*************************************************************************************************/
114 /*!
115  * \brief Register operation handlers.
116  *
117  * \param opType Operation type.
118  * \param execOpCback Execute operation callback.
119  * \param cancelOpCback Cancel operation callback.
120  */
121 /*************************************************************************************************/
122 void bbBleRegisterOp(uint8_t opType, bbBleExecOpFn_t execOpCback, bbBleExecOpFn_t cancelOpCback);
123 
124 #ifdef __cplusplus
125 };
126 #endif
127 
128 /*************************************************************************************************/
129 /*!
130  * \brief Clear IFS in operation.
131  *
132  * The BB may choose not to enable IFS after the next Tx or Rx.
133  */
134 /*************************************************************************************************/
135 static inline void bbBleClrIfs(void)
136 {
137  /* PalBbBleOpParam_t opParams = { .ifsMode = PAL_BB_IFS_MODE_CLR, .ifsTime = 0, .pIfsChan = NULL }; */
138  PalBbBleOpParam_t opParams = { 0 };
139  PalBbBleSetOpParams(&opParams);
140 }
141 
142 /*************************************************************************************************/
143 /*!
144  * \brief Set TIFS in operation.
145  *
146  * The BB must enable TIFS after the next Tx or Rx.
147  */
148 /*************************************************************************************************/
149 static inline void bbBleSetTifs(void)
150 {
151  PalBbBleOpParam_t opParams = { .ifsMode = PAL_BB_IFS_MODE_TOGGLE_TIFS, .ifsTime = 0, .pIfsChan = NULL };
152  PalBbBleSetOpParams(&opParams);
153 }
154 
155 /*************************************************************************************************/
156 /*!
157  * \brief Set absolute time IFS in operation.
158  *
159  * \param ifsTime Due time of the next PDU.
160  * \param pIfsChan Channel of the next PDU.
161  *
162  * The BB must enable IFS with absolute time after the next Tx or Rx.
163  */
164 /*************************************************************************************************/
165 static inline void bbBleSetAbsIfs(uint32_t ifsTime, PalBbBleChan_t *pIfsChan)
166 {
167  PalBbBleOpParam_t opParams = { .ifsMode = PAL_BB_IFS_MODE_SAME_ABS, .ifsTime = ifsTime, .pIfsChan = pIfsChan };
168  PalBbBleSetOpParams(&opParams);
169 }
170 
171 #endif /* BB_BLE_INT_H */
Common math utilities.
BLE baseband interface file.
uint16_t rxDataLen
Definition: bb_ble_int.h:95
bbBleExecOpFn_t execOpCback
Definition: bb_ble_int.h:84
void bbBleRegisterOp(uint8_t opType, bbBleExecOpFn_t execOpCback, bbBleExecOpFn_t cancelOpCback)
Register operation handlers.
static void bbBleSetTifs(void)
Set TIFS in operation.
Definition: bb_ble_int.h:149
BLE MAC system configuration.
void(* bbBleExecOpFn_t)(BbOpDesc_t *pBod, BbBleData_t *pBle)
Execution operation function.
Definition: bb_ble_int.h:77
BB control block.
Definition: bb_ble_int.h:80
Bluetooth Low Energy protocol specific operation parameters.
uint16_t rxCisDataLen
Definition: bb_ble_int.h:99
Operation parameters.
Definition: pal_bb_ble.h:123
Assert macro.
uint8_t numChUsed
Definition: bb_ble_int.h:90
BLE channelization parameters.
Definition: pal_bb_ble.h:67
static void bbBleClrIfs(void)
Clear IFS in operation.
Definition: bb_ble_int.h:135
Link layer constant definitions.
PalBbBleDataParam_t bbParam
Definition: bb_ble_int.h:93
uint8_t evtState
Definition: bb_ble_int.h:88
void PalBbBleSetOpParams(const PalBbBleOpParam_t *pOpParam)
Set the operation parameters.
Baseband operation descriptor (BOD).
Definition: bb_api.h:149
PalBbIfsMode_t ifsMode
Definition: pal_bb_ble.h:125
static void bbBleSetAbsIfs(uint32_t ifsTime, PalBbBleChan_t *pIfsChan)
Set absolute time IFS in operation.
Definition: bb_ble_int.h:165
uint8_t * pRxCisDataBuf
Definition: bb_ble_int.h:100
uint8_t * pRxDataBuf
Definition: bb_ble_int.h:96
uint32_t lastScanStartUsec
Definition: bb_ble_int.h:91
BLE baseband interface file.
BLE data transfer parameters.
Definition: pal_bb_ble.h:113
Baseband interface file.
uint8_t advChIdx
Definition: bb_ble_int.h:89
BLE Baseband interface file.
bbBleExecOpFn_t cancelOpCback
Definition: bb_ble_int.h:85
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.