Skip to content

Commit f340724

Browse files
committed
feat: ability to define HCI SPI transport configuration
Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
1 parent 713019a commit f340724

2 files changed

Lines changed: 63 additions & 0 deletions

File tree

README.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,68 @@ For more information about ArduinoBLE library please visit the official web page
2525
https://www.arduino.cc/en/Reference/ArduinoBLE
2626

2727
# Configuration
28+
29+
### STM32WB
30+
2831
STM32Cube_WPAN has several configuration options, which are set in the `app_conf.h`.
2932
This package has a default configuration named `app_conf_default.h`.
3033
The user can include the file `app_conf_custom.h` to customize the BLE application.
3134
Options wrapped in `#ifndef`, `#endif` in `app_conf_default.h` can be overwritten.
3235
Additional options can be added.
3336

37+
### Shield
38+
39+
The user can include the file `ble_spi_conf.h` to define which shield and configuration to use from the following list:
40+
41+
* [X-NUCLEO-IDB05A2](https://www.st.com/en/ecosystems/x-nucleo-idb05a2.html)
42+
* `IDB05A2_SPI_CLOCK_D3`: SPI clock on D3
43+
* `IDB05A2_SPI_CLOCK_D13` SPI clock on D13
44+
* [X-NUCLEO-IDB05A1](https://www.st.com/en/ecosystems/x-nucleo-idb05a1.html)
45+
* `IDB05A1_SPI_CLOCK_D3`: SPI clock on D3
46+
* `IDB05A1_SPI_CLOCK_D13`: SPI clock on D13
47+
* [X-NUCLEO-BNRG2A1](https://www.st.com/en/ecosystems/x-nucleo-bnrg2a1.html)
48+
* `BNRG2A1_CLOCK_D3`: SPI clock on D3
49+
* `BNRG2A1_CLOCK_D13`: SPI clock on D13
50+
* `CUSTOM_BLE_SPI`: define a custom configuration, it requires below definition:
51+
* `BLE_SPI_MISO`: SPI MISO pin
52+
* `BLE_SPI_MOSI`: SPI MOSI pin
53+
* `BLE_SPI_CLK`: SPI CLocK pin
54+
* `BLE_SPI_CS`: SPI Chip Select pin
55+
* `BLE_SPI_IRQ`: SPI IRQ pin
56+
* `BLE_SPI_FREQ`: SPI bus frequency
57+
* `BLE_SPI_MODE`: can be one of the below `SPIMode`:
58+
* `SPI_MODE0`
59+
* `SPI_MODE1`
60+
* `SPI_MODE2`
61+
* `SPI_MODE0`
62+
* `BLE_CHIP_TYPE`: can be one of the below `BLEChip_t`:
63+
* `SPBTLE_RF`
64+
* `SPBTLE_1S`
65+
* `BLUENRG_M2SP`
66+
* `BLUENRG_M0`
67+
* `BLUENRG_LP`
68+
* `BLE_RESET`: BLE reset pin
69+
70+
#### Examples
71+
72+
To use the [X-NUCLEO-IDB05A2](https://www.st.com/en/ecosystems/x-nucleo-idb05a2.html) with SPI clock on D3, define in `ble_spi_conf.h`:
73+
```C
74+
#define IDB05A2_SPI_CLOCK_D3
75+
```
76+
This is equivalent to the below configuration using the `CUSTOM_BLE_SPI`:
77+
```C
78+
#define CUSTOM_BLE_SPI
79+
#define BLE_SPI_MISO D12
80+
#define BLE_SPI_MOSI D11
81+
#define BLE_SPI_CLK D3
82+
#define BLE_SPI_CS A1
83+
#define BLE_SPI_IRQ A0
84+
#define BLE_SPI_FREQ 8000000
85+
#define BLE_SPI_MODE SPI_MODE0
86+
#define BLE_CHIP_TYPE BLUENRG_M0
87+
#define BLE_RESET D7
88+
```
89+
3490
## License
3591
3692
```

src/utility/HCISpiTransport.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121

2222
#include "HCISpiTransport.h"
2323

24+
#if __has_include("ble_spi_conf.h")
25+
#include "ble_spi_conf.h"
26+
#endif
27+
2428
#if defined(ARDUINO_STEVAL_MKBOXPRO)
2529
/* STEVAL-MKBOXPRO */
2630
SPIClass SpiHCI(PA7, PA6, PA5);
@@ -57,6 +61,9 @@ HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_M2SP, A1, A0, D7, 1000000,
5761
/* Shield BNRG2A1 with SPI clock on D13 */
5862
#define SpiHCI SPI
5963
HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_M2SP, A1, A0, D7, 1000000, SPI_MODE1);
64+
#elif defined(CUSTOM_BLE_SPI)
65+
SPIClass SpiHCI(BLE_SPI_MOSI, BLE_SPI_MISO, BLE_SPI_CLK);
66+
HCISpiTransportClass HCISpiTransport(SpiHCI, BLE_CHIP_TYPE, BLE_SPI_CS, BLE_SPI_IRQ, BLE_RESET, BLE_SPI_FREQ, BLE_SPI_MODE);
6067
#else
6168
#error "Unsupported board or shield selected!"
6269
#endif

0 commit comments

Comments
 (0)