Skip to content

Commit 0b39979

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

File tree

2 files changed

+63
-1
lines changed

2 files changed

+63
-1
lines changed

README.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,61 @@ https://github.com/stm32duino/Arduino_Core_STM32/wiki/STM32duinoBLE#stm32duinobl
1616
For more information about ArduinoBLE library please visit the official web page at:
1717
https://www.arduino.cc/en/Reference/ArduinoBLE
1818

19+
# Configuration
20+
21+
### Shield
22+
23+
The user can include the file `ble_spi_conf.h` to define which shield and configuration to use from the following list:
24+
25+
* [X-NUCLEO-IDB05A2](https://www.st.com/en/ecosystems/x-nucleo-idb05a2.html)
26+
* `IDB05A2_SPI_CLOCK_D3`: SPI clock on D3
27+
* `IDB05A2_SPI_CLOCK_D13` SPI clock on D13
28+
* [X-NUCLEO-IDB05A1](https://www.st.com/en/ecosystems/x-nucleo-idb05a1.html)
29+
* `IDB05A1_SPI_CLOCK_D3`: SPI clock on D3
30+
* `IDB05A1_SPI_CLOCK_D13`: SPI clock on D13
31+
* [X-NUCLEO-BNRG2A1](https://www.st.com/en/ecosystems/x-nucleo-bnrg2a1.html)
32+
* `BNRG2A1_CLOCK_D3`: SPI clock on D3
33+
* `BNRG2A1_CLOCK_D13`: SPI clock on D13
34+
* `CUSTOM_BLE_SPI`: define a custom configuration, it requires below definition:
35+
* `BLE_SPI_MISO`: SPI MISO pin
36+
* `BLE_SPI_MOSI`: SPI MOSI pin
37+
* `BLE_SPI_CLK`: SPI CLocK pin
38+
* `BLE_SPI_CS`: SPI Chip Select pin
39+
* `BLE_SPI_IRQ`: SPI IRQ pin
40+
* `BLE_SPI_FREQ`: SPI bus frequency
41+
* `BLE_SPI_MODE`: can be one of the below `SPIMode`:
42+
* `SPI_MODE0`
43+
* `SPI_MODE1`
44+
* `SPI_MODE2`
45+
* `SPI_MODE0`
46+
* `BLE_CHIP_TYPE`: can be one of the below `BLEChip_t`:
47+
* `SPBTLE_RF`
48+
* `SPBTLE_1S`
49+
* `BLUENRG_M2SP`
50+
* `BLUENRG_M0`
51+
* `BLUENRG_LP`
52+
* `BLE_RESET`: BLE reset pin
53+
54+
#### Examples
55+
56+
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`:
57+
```C
58+
#define IDB05A2_SPI_CLOCK_D3
59+
```
60+
This is equivalent to the below configuration using the `CUSTOM_BLE_SPI`:
61+
```C
62+
#define CUSTOM_BLE_SPI
63+
#define BLE_SPI_MISO D12
64+
#define BLE_SPI_MOSI D11
65+
#define BLE_SPI_CLK D3
66+
#define BLE_SPI_CS A1
67+
#define BLE_SPI_IRQ A0
68+
#define BLE_SPI_FREQ 8000000
69+
#define BLE_SPI_MODE SPI_MODE0
70+
#define BLE_CHIP_TYPE BLUENRG_M0
71+
#define BLE_RESET D7
72+
```
73+
1974
## License
2075
2176
```

src/utility/HCISpiTransport.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,14 @@
1919

2020
#include "HCISpiTransport.h"
2121

22-
#if defined(ARDUINO_STEVAL_MKBOXPRO)
22+
#if __has_include("ble_spi_conf.h")
23+
#include "ble_spi_conf.h"
24+
#endif
25+
26+
#if defined(CUSTOM_BLE_SPI)
27+
SPIClass SpiHCI(BLE_SPI_MOSI, BLE_SPI_MISO, BLE_SPI_CLK);
28+
HCISpiTransportClass HCISpiTransport(SpiHCI, BLE_CHIP_TYPE, BLE_SPI_CS, BLE_SPI_IRQ, BLE_RESET, BLE_SPI_FREQ, BLE_SPI_MODE);
29+
#elif defined(ARDUINO_STEVAL_MKBOXPRO)
2330
/* STEVAL-MKBOXPRO */
2431
SPIClass SpiHCI(PA7, PA6, PA5);
2532
HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_LP, PA2, PB11, PD4, 1000000, SPI_MODE3);

0 commit comments

Comments
 (0)