You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: features/FEATURE_BLE/targets/TARGET_CORDIO/doc/PortingGuide.md
+26-19Lines changed: 26 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,12 +1,12 @@
1
-
# Porting guide
1
+
##Porting guide
2
2
3
3
There are two main steps to enable the Mbed BLE Cordio port:
4
4
5
5
1. Configure your target to include Cordio BLE port and Cordio libraries during the build process.
6
6
7
7
1. Implement the `CordioHCIDriver` class targeting the Bluetooth controller.
8
8
9
-
## Configure the target
9
+
###Configure the target
10
10
11
11
1. Define all Mbed OS targets in the `targets/target.json` file:
12
12
@@ -33,17 +33,17 @@ Compile the BLE Cordio port sources:
33
33
}
34
34
```
35
35
36
-
## Implement CordioHCIDriver:
36
+
###Implement CordioHCIDriver:
37
37
38
38
Include an HCI driver for the BLE module used by the target, and a factory function that creates the BLE instance you use.
39
39
40
-
### Create source folder
40
+
####Create source folder
41
41
42
42
1. Navigate to the folder of the BLE API that hosts the target port `features/FEATURE_BLE/targets`.
43
43
44
44
1. Create a folder containing the port code to isolate it from other code. Begin this folder's name with `TARGET_` and the rest of the name in capital letters.
45
45
46
-
### Create the HCI driver
46
+
####Create the HCI driver
47
47
48
48
The HCI driver is split in two entities. One handles HCI communication with the Bluetooth module. The other handles initialization, reset sequence, and memory dedicated to the Bluetooth controller.
49
49
@@ -182,31 +182,38 @@ Three functions handle the reset sequence process:
182
182
183
183
*`handle_reset_sequence`: Entry point to the state machine handling the reset process. Every time an HCI packet is received during the reset sequence, this function is called with the HCI packet received. Its purpose is to prepare the Bluetooth controller and set the parameters the stack needs to operate properly. You can override this function if necessary.
184
184
185
-
*`signal_reset_sequence_done`: Once the reset sequence is finished, you can call this function. You cannot override it.
185
+
*`signal_reset_sequence_done`: Once the reset sequence is completed, you can call this function. You cannot override it.
186
186
187
187
###### Controller parameters to set
188
188
189
189
This step tells the controller which events are relevant to the stack.
190
190
191
-
The following parameters should be set in the controller (if supported):
191
+
You should set the following parameters in the controller (if supported):
* 2nd page of events mask: Call `HciSetEventMaskPage2Cmd((uint8_t *) hciEventMaskPage2)`.
197
+
***2nd page of events mask:** Call `HciSetEventMaskPage2Cmd((uint8_t *) hciEventMaskPage2)`.
198
198
199
199
###### Stack runtime parameters
200
200
201
201
At runtime, you can get stack parameters from the controller:
202
202
203
-
* Bluetooth address: Query this with `HciReadBdAddrCmd`. Copy the response into `hciCoreCb.bdAddr` with `BdaCpy`.
204
-
* Buffer size of the controller: Query this with `HciLeReadBufSizeCmd`. The return parameter `HC_ACL_Data_Packet_Length` is copied to `hciCoreCb.bufSize`. Copy the response parameter `HC_Synchronous_Data_Packet_Length` into `hciCoreCb.numBufs`. The value of `hciCoreCb.availBufs` shall be initialized with `hciCoreCb.numBufs`.
205
-
* Supported state: Query this with `HciLeReadSupStatesCmd`, and copy the response into `hciCoreCb.leStates`.
206
-
* Whitelist size: Query this with `HciLeReadWhiteListSizeCmd`, and copy the response into `hciCoreCb.whiteListSize`.
207
-
* LE features supported: Query this with `HciLeReadLocalSupFeatCmd`, and copy the response into `hciCoreCb.leSupFeat`.
208
-
* Resolving list size: Query this with `hciCoreReadResolvingListSize`, and copy the response into `hciCoreCb.resListSize`.
209
-
* Max data length: Query this with `hciCoreReadMaxDataLen`, and pass the response parameters `supportedMaxTxOctets` and `supportedMaxTxTime` to the function `HciLeWriteDefDataLen`.
203
+
***Bluetooth address:** Query this with `HciReadBdAddrCmd`. Copy the response into `hciCoreCb.bdAddr` with `BdaCpy`.
204
+
205
+
***Buffer size of the controller:** Query this with `HciLeReadBufSizeCmd`.
206
+
* The return parameter `HC_ACL_Data_Packet_Length` is copied to `hciCoreCb.bufSize`. Copy the response parameter `HC_Synchronous_Data_Packet_Length` into `hciCoreCb.numBufs`. `hciCoreCb.numBufs` initializes the value of `hciCoreCb.availBufs`.
207
+
208
+
***Supported state:** Query this with `HciLeReadSupStatesCmd`, and copy the response into `hciCoreCb.leStates`.
209
+
210
+
***Whitelist size:** Query this with `HciLeReadWhiteListSizeCmd`, and copy the response into `hciCoreCb.whiteListSize`.
211
+
212
+
***LE features supported:** Query this with `HciLeReadLocalSupFeatCmd`, and copy the response into `hciCoreCb.leSupFeat`.
213
+
214
+
***Resolving list size:** Query this with `hciCoreReadResolvingListSize`, and copy the response into `hciCoreCb.resListSize`.
215
+
216
+
***Max data length:** Query this with `hciCoreReadMaxDataLen`, and pass the response parameters `supportedMaxTxOctets` and `supportedMaxTxTime` to the function `HciLeWriteDefDataLen`.
You can use the application [mbed-os-cordio-hci-passthrough](https://github.com/ARMmbed/mbed-os-cordio-hci-passthrough) to proxify a Bluetooth controller connected to an Mbed board.
459
466
460
-
The host sent bytes over the board serial, which the `HCITransport Driver`then forwards. Bytes sent by the controller go back to the host through the board serial.
467
+
The host sent bytes over the board serial, which the `HCITransport Driver` forwards. Bytes sent by the controller go back to the host through the board serial.
461
468
462
-
This application can be used to validate the transport driver and debug the initialization process.
469
+
You can use this application to validate the transport driver and debug the initialization process.
0 commit comments