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
+46-42Lines changed: 46 additions & 42 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,11 +8,11 @@ There are two main steps to enable the Mbed BLE Cordio port:
8
8
9
9
## Configure the target
10
10
11
-
Define all Mbed OS targets in the `targets/target.json` file:
11
+
1.Define all Mbed OS targets in the `targets/target.json` file:
12
12
13
-
* Add BLE support to the target:
13
+
1. Add BLE support to the target:
14
14
15
-
* Add the string `BLE` to the target's list of `features`. This adds the BLE API sources to the list of sources compiled for the target.
15
+
* Add the string `BLE` to the target's list of `features`. This adds the BLE API sources to the list of sources compiled for the target:
16
16
17
17
```
18
18
"TARGET_NAME": {
@@ -24,7 +24,7 @@ Define all Mbed OS targets in the `targets/target.json` file:
24
24
25
25
Compile the BLE Cordio port sources:
26
26
27
-
* Add the string `CORDIO` to the `extra_labels` property of the JSON file.
27
+
* Add the string `CORDIO` to the `extra_labels` property of the JSON file:
28
28
29
29
```
30
30
"TARGET_NAME": {
@@ -39,15 +39,15 @@ Include an HCI driver for the BLE module used by the target, and a factory funct
39
39
40
40
### Create source folder
41
41
42
-
1. Navigate to the folder of the BLE API that hosts target port `features/FEATURE_BLE/targets`.
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
46
### Create the HCI driver
47
47
48
48
The HCI driver is split in two entities: one which handle HCI communication with the Bluetooth module and the other handling the initialization, reset sequence and memory dedicated for the Bluetooth controller.
49
49
50
-
More information about the architecture can be found in the [HCI abstraction architecture](HCIAbstraction.md) document.
50
+
More information about the architecture can be found in [HCI abstraction architecture](HCIAbstraction.md).
51
51
52
52
#### HCITransport
53
53
@@ -89,7 +89,9 @@ It inherits publicly from the base class `CordioHCITransportDriver`.
89
89
90
90
***Sending data**: The function `write` sends data in input to the Bluetooth controller and return the number of bytes in the `data` buffer sent. Depending on the type of transport you implement, you may need to send the packet `type` to the controller before the packet data.
91
91
92
-
***Receiving data**: Inject HCI data from the Bluetooth controller to the system by invoking the function `on_data_received`. This function is a static one and is provided by the base class:
92
+
***Receiving data**: Inject HCI data from the Bluetooth controller to the system by invoking the function `on_data_received`. This function is a static one and is provided by the base class.
The functions `do_initialize` and `do_terminate` handle initialization and termination processes. These functions manage the state of the Bluetooth controller.
139
141
140
-
<spanclass="notes">**Note:** It is unnecessary to initialize or terminate the HCI transport in those function because it is handled by the base class. The HCI transport is initialized right before the call to `do_initialize` and is terminated right after the call to `do_terminate`.</span>
142
+
<spanclass="notes">**Note:** It is unnecessary to initialize or terminate the HCI transport in these functions, because that is handled by the base class. The HCI transport is initialized right before the call to `do_initialize` and is terminated right after the call to `do_terminate`.</span>
141
143
142
144
##### Memory pool
143
145
144
-
The function `get_buffer_pool_description` in the base class returns a buffer of 1040 bytes divided in different memory pools:
146
+
The function `get_buffer_pool_description` in the base class returns a buffer of 1040 bytes divided into different memory pools:
145
147
146
148
| Chunk size (bytes) | Number of chunks |
147
149
|--------------------|------------------|
@@ -153,6 +155,8 @@ The function `get_buffer_pool_description` in the base class returns a buffer of
153
155
154
156
Porting overrides this function if the memory provided by the base class doesn't match what is required by the Bluetooth controller driver.
@@ -194,17 +198,17 @@ The following parameters should be set in the controller (if supported):
194
198
195
199
###### Stack runtime parameters
196
200
197
-
At runtime, you can get some stack parameters from the controller:
201
+
At runtime, you can get stack parameters from the controller:
198
202
199
203
* Bluetooth address: Query this with `HciReadBdAddrCmd`. Copy the response into `hciCoreCb.bdAddr` with `BdaCpy`.
200
-
201
-
* Buffer size of the controller: Can be obtained by `HciLeReadBufSizeCmd`. The return parameter `HC_ACL_Data_Packet_Length` is copied to `hciCoreCb.bufSize`, and the response parameter `HC_Synchronous_Data_Packet_Length` shall be copied into `hciCoreCb.numBufs`. The value of `hciCoreCb.availBufs` shall be initialized with `hciCoreCb.numBufs`.
202
-
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`.
203
205
* Supported state: Query this with `HciLeReadSupStatesCmd`, and copy the response into `hciCoreCb.leStates`.
204
206
* Whitelist size: Query this with `HciLeReadWhiteListSizeCmd`, and copy the response into `hciCoreCb.whiteListSize`.
205
207
* LE features supported: Query this with `HciLeReadLocalSupFeatCmd`, and copy the response into `hciCoreCb.leSupFeat`.
206
208
* Resolving list size: Query this with `hciCoreReadResolvingListSize`, and copy the response into `hciCoreCb.resListSize`.
207
-
* Max data length: Query this with `hciCoreReadMaxDataLen`, and pass the response parameters `supportedMaxTxOctets` and `supportedMaxTxTime` to the function `HciLeWriteDefDataLen`:
209
+
* Max data length: Query this with `hciCoreReadMaxDataLen`, and pass the response parameters `supportedMaxTxOctets` and `supportedMaxTxTime` to the function `HciLeWriteDefDataLen`.
The HCI driver is injected to the `CordioBLE` class at manufacture.
415
419
416
-
Given that the CordioBLE class doesn't know what class constructs the driver nor how to construct it, the port provides a function returning a reference to the HCI driver.
420
+
Given that the `CordioBLE` class doesn't know which class constructs the driver nor how to construct it, the port provides a function returning a reference to the HCI driver.
417
421
418
422
This function is in the global namespace, and you can call it with:
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.
455
459
456
-
Bytes sent by the host over the board serial are forwarded to the controller with the help of the `HCITransportDriver`, while bytes sent by the controller are sent back to the host through the board serial.
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.
457
461
458
-
This application can be used to validate the transport driver and debug the initialization process on a PC host.
462
+
This application can be used to validate the transport driver and debug the initialization process.
0 commit comments