Skip to content

Commit ae19ef2

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

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
@@ -15,6 +15,61 @@ https://github.com/stm32duino/Arduino_Core_STM32/wiki/STM32duinoBLE#stm32duinobl
1515
For more information about ArduinoBLE library please visit the official web page at:
1616
https://www.arduino.cc/en/Reference/ArduinoBLE
1717

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

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)