Skip to content

Commit

Permalink
Merge pull request stm32duino#18 from cparata/master
Browse files Browse the repository at this point in the history
Add support to X-NUCLEO-IDB05A2
  • Loading branch information
cparata authored Sep 30, 2020
2 parents 61138fc + 0d936a4 commit d952a0f
Show file tree
Hide file tree
Showing 12 changed files with 95 additions and 26 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# STM32duinoBLE

This library is a fork of ArduinoBLE library to add the support of SPBTLE-RF and SPBTLE-1S BLE modules.
It was successfully tested with the X-NUCLEO-IDB05A1 or X-NUCLEO-BNRG2A1 expansion board and a NUCLEO-F401RE
It was successfully tested with the X-NUCLEO-IDB05A2 or X-NUCLEO-IDB05A1 or X-NUCLEO-BNRG2A1 expansion board and a NUCLEO-F401RE
or NUCLEO-L476RG or NUCLEO-L053R8, with B-L475E-IOT01A and with STEVAL-MKSBOX1V1.
In order to use this library with STEVAL-MKSBOX1V1, you need to update the firmware of the SPBTLE-1S BLE module
mounted on that board as described in the following wiki page:
Expand Down
14 changes: 12 additions & 2 deletions examples/Central/LedControl/LedControl.ino
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,21 @@ HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, PD13, PE6, PA8, 8000000,
BLELocalDevice BLE(&HCISpiTransport);
const int buttonPin = PC13; // set buttonPin to digital pin PC13
#else
/* Shield IDB05A1 with SPI clock on D3 */
/* Shield IDB05A2 with SPI clock on D3 */
SPIClass SpiHCI(D11, D12, D3);
HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, A1, A0, D7, 8000000, SPI_MODE0);
HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_M0, A1, A0, D7, 8000000, SPI_MODE0);
BLELocalDevice BLE(&HCISpiTransport);
const int buttonPin = PC13; // set buttonPin to digital pin PC13
/* Shield IDB05A2 with SPI clock on D13 */
/*#define SpiHCI SPI
HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_M0, A1, A0, D7, 8000000, SPI_MODE0);
BLELocalDevice BLE(&HCISpiTransport);
const int buttonPin = PC13; // set buttonPin to digital pin PC13 */
/* Shield IDB05A1 with SPI clock on D3 */
/*SPIClass SpiHCI(D11, D12, D3);
HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, A1, A0, D7, 8000000, SPI_MODE0);
BLELocalDevice BLE(&HCISpiTransport);
const int buttonPin = PC13; // set buttonPin to digital pin PC13 */
/* Shield IDB05A1 with SPI clock on D13 */
/*#define SpiHCI SPI
HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, A1, A0, D7, 8000000, SPI_MODE0);
Expand Down
12 changes: 10 additions & 2 deletions examples/Central/PeripheralExplorer/PeripheralExplorer.ino
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,18 @@ SPIClass SpiHCI(PC12, PC11, PC10);
HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, PD13, PE6, PA8, 8000000, SPI_MODE0);
BLELocalDevice BLE(&HCISpiTransport);
#else
/* Shield IDB05A1 with SPI clock on D3 */
/* Shield IDB05A2 with SPI clock on D3 */
SPIClass SpiHCI(D11, D12, D3);
HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, A1, A0, D7, 8000000, SPI_MODE0);
HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_M0, A1, A0, D7, 8000000, SPI_MODE0);
BLELocalDevice BLE(&HCISpiTransport);
/* Shield IDB05A2 with SPI clock on D13 */
/*#define SpiHCI SPI
HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_M0, A1, A0, D7, 8000000, SPI_MODE0);
BLELocalDevice BLE(&HCISpiTransport); */
/* Shield IDB05A1 with SPI clock on D3 */
/*SPIClass SpiHCI(D11, D12, D3);
HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, A1, A0, D7, 8000000, SPI_MODE0);
BLELocalDevice BLE(&HCISpiTransport); */
/* Shield IDB05A1 with SPI clock on D13 */
/*#define SpiHCI SPI
HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, A1, A0, D7, 8000000, SPI_MODE0);
Expand Down
12 changes: 10 additions & 2 deletions examples/Central/Scan/Scan.ino
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,18 @@ SPIClass SpiHCI(PC12, PC11, PC10);
HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, PD13, PE6, PA8, 8000000, SPI_MODE0);
BLELocalDevice BLE(&HCISpiTransport);
#else
/* Shield IDB05A1 with SPI clock on D3 */
/* Shield IDB05A2 with SPI clock on D3 */
SPIClass SpiHCI(D11, D12, D3);
HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, A1, A0, D7, 8000000, SPI_MODE0);
HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_M0, A1, A0, D7, 8000000, SPI_MODE0);
BLELocalDevice BLE(&HCISpiTransport);
/* Shield IDB05A2 with SPI clock on D13 */
/*#define SpiHCI SPI
HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_M0, A1, A0, D7, 8000000, SPI_MODE0);
BLELocalDevice BLE(&HCISpiTransport); */
/* Shield IDB05A1 with SPI clock on D3 */
/*SPIClass SpiHCI(D11, D12, D3);
HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, A1, A0, D7, 8000000, SPI_MODE0);
BLELocalDevice BLE(&HCISpiTransport); */
/* Shield IDB05A1 with SPI clock on D13 */
/*#define SpiHCI SPI
HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, A1, A0, D7, 8000000, SPI_MODE0);
Expand Down
12 changes: 10 additions & 2 deletions examples/Central/ScanCallback/ScanCallback.ino
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,18 @@ SPIClass SpiHCI(PC12, PC11, PC10);
HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, PD13, PE6, PA8, 8000000, SPI_MODE0);
BLELocalDevice BLE(&HCISpiTransport);
#else
/* Shield IDB05A1 with SPI clock on D3 */
/* Shield IDB05A2 with SPI clock on D3 */
SPIClass SpiHCI(D11, D12, D3);
HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, A1, A0, D7, 8000000, SPI_MODE0);
HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_M0, A1, A0, D7, 8000000, SPI_MODE0);
BLELocalDevice BLE(&HCISpiTransport);
/* Shield IDB05A2 with SPI clock on D13 */
/*#define SpiHCI SPI
HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_M0, A1, A0, D7, 8000000, SPI_MODE0);
BLELocalDevice BLE(&HCISpiTransport); */
/* Shield IDB05A1 with SPI clock on D3 */
/*SPIClass SpiHCI(D11, D12, D3);
HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, A1, A0, D7, 8000000, SPI_MODE0);
BLELocalDevice BLE(&HCISpiTransport); */
/* Shield IDB05A1 with SPI clock on D13 */
/*#define SpiHCI SPI
HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, A1, A0, D7, 8000000, SPI_MODE0);
Expand Down
12 changes: 10 additions & 2 deletions examples/Central/SensorTagButton/SensorTagButton.ino
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,18 @@ SPIClass SpiHCI(PC12, PC11, PC10);
HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, PD13, PE6, PA8, 8000000, SPI_MODE0);
BLELocalDevice BLE(&HCISpiTransport);
#else
/* Shield IDB05A1 with SPI clock on D3 */
/* Shield IDB05A2 with SPI clock on D3 */
SPIClass SpiHCI(D11, D12, D3);
HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, A1, A0, D7, 8000000, SPI_MODE0);
HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_M0, A1, A0, D7, 8000000, SPI_MODE0);
BLELocalDevice BLE(&HCISpiTransport);
/* Shield IDB05A2 with SPI clock on D13 */
/*#define SpiHCI SPI
HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_M0, A1, A0, D7, 8000000, SPI_MODE0);
BLELocalDevice BLE(&HCISpiTransport); */
/* Shield IDB05A1 with SPI clock on D3 */
/*SPIClass SpiHCI(D11, D12, D3);
HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, A1, A0, D7, 8000000, SPI_MODE0);
BLELocalDevice BLE(&HCISpiTransport); */
/* Shield IDB05A1 with SPI clock on D13 */
/*#define SpiHCI SPI
HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, A1, A0, D7, 8000000, SPI_MODE0);
Expand Down
14 changes: 12 additions & 2 deletions examples/Peripheral/ButtonLED/ButtonLED.ino
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,21 @@ HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, PD13, PE6, PA8, 8000000,
BLELocalDevice BLE(&HCISpiTransport);
const int buttonPin = PC13; // set buttonPin to digital pin PC13
#else
/* Shield IDB05A1 with SPI clock on D3 */
/* Shield IDB05A2 with SPI clock on D3 */
SPIClass SpiHCI(D11, D12, D3);
HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, A1, A0, D7, 8000000, SPI_MODE0);
HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_M0, A1, A0, D7, 8000000, SPI_MODE0);
BLELocalDevice BLE(&HCISpiTransport);
const int buttonPin = PC13; // set buttonPin to digital pin PC13
/* Shield IDB05A2 with SPI clock on D13 */
/*#define SpiHCI SPI
HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_M0, A1, A0, D7, 8000000, SPI_MODE0);
BLELocalDevice BLE(&HCISpiTransport);
const int buttonPin = PC13; // set buttonPin to digital pin PC13 */
/* Shield IDB05A1 with SPI clock on D3 */
/*SPIClass SpiHCI(D11, D12, D3);
HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, A1, A0, D7, 8000000, SPI_MODE0);
BLELocalDevice BLE(&HCISpiTransport);
const int buttonPin = PC13; // set buttonPin to digital pin PC13 */
/* Shield IDB05A1 with SPI clock on D13 */
/*#define SpiHCI SPI
HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, A1, A0, D7, 8000000, SPI_MODE0);
Expand Down
12 changes: 10 additions & 2 deletions examples/Peripheral/CallbackLED/CallbackLED.ino
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,18 @@ SPIClass SpiHCI(PC12, PC11, PC10);
HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, PD13, PE6, PA8, 8000000, SPI_MODE0);
BLELocalDevice BLE(&HCISpiTransport);
#else
/* Shield IDB05A1 with SPI clock on D3 */
/* Shield IDB05A2 with SPI clock on D3 */
SPIClass SpiHCI(D11, D12, D3);
HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, A1, A0, D7, 8000000, SPI_MODE0);
HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_M0, A1, A0, D7, 8000000, SPI_MODE0);
BLELocalDevice BLE(&HCISpiTransport);
/* Shield IDB05A2 with SPI clock on D13 */
/*#define SpiHCI SPI
HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_M0, A1, A0, D7, 8000000, SPI_MODE0);
BLELocalDevice BLE(&HCISpiTransport); */
/* Shield IDB05A1 with SPI clock on D3 */
/*SPIClass SpiHCI(D11, D12, D3);
HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, A1, A0, D7, 8000000, SPI_MODE0);
BLELocalDevice BLE(&HCISpiTransport); */
/* Shield IDB05A1 with SPI clock on D13 */
/*SPIClass SpiHCI(D11, D12, D13);
HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, A1, A0, D7, 8000000, SPI_MODE0);
Expand Down
12 changes: 10 additions & 2 deletions examples/Peripheral/LED/LED.ino
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,18 @@ SPIClass SpiHCI(PC12, PC11, PC10);
HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, PD13, PE6, PA8, 8000000, SPI_MODE0);
BLELocalDevice BLE(&HCISpiTransport);
#else
/* Shield IDB05A1 with SPI clock on D3 */
/* Shield IDB05A2 with SPI clock on D3 */
SPIClass SpiHCI(D11, D12, D3);
HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, A1, A0, D7, 8000000, SPI_MODE0);
HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_M0, A1, A0, D7, 8000000, SPI_MODE0);
BLELocalDevice BLE(&HCISpiTransport);
/* Shield IDB05A2 with SPI clock on D13 */
/*#define SpiHCI SPI
HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_M0, A1, A0, D7, 8000000, SPI_MODE0);
BLELocalDevice BLE(&HCISpiTransport); */
/* Shield IDB05A1 with SPI clock on D3 */
/*SPIClass SpiHCI(D11, D12, D3);
HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, A1, A0, D7, 8000000, SPI_MODE0);
BLELocalDevice BLE(&HCISpiTransport); */
/* Shield IDB05A1 with SPI clock on D13 */
/*#define SpiHCI SPI
HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, A1, A0, D7, 8000000, SPI_MODE0);
Expand Down
4 changes: 2 additions & 2 deletions library.properties
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name=STM32duinoBLE
version=1.2.1
version=1.3.0
author=Arduino, SRA
maintainer=stm32duino
sentence=Fork of ArduinoBLE library to add the support of SPBTLE-RF and SPBTLE-1S BLE modules.
sentence=Fork of ArduinoBLE library to add the support of SPBTLE-RF, SPBTLE-1S, BLUENRG-M2SP and BLUENRG-M0 BLE modules.
paragraph=This library supports creating a BLE peripheral and BLE central mode.
category=Communication
url=https://github.com/stm32duino/STM32duinoBLE
Expand Down
12 changes: 6 additions & 6 deletions src/utility/HCISpiTransport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ int HCISpiTransportClass::begin()
digitalWrite(_ble_rst, HIGH);
delay(5);

if (_ble_chip == SPBTLE_RF)
if (_ble_chip == SPBTLE_RF || _ble_chip == BLUENRG_M0)
{
// Wait for Blue Initialize
wait_for_blue_initialize();
Expand Down Expand Up @@ -102,7 +102,7 @@ void HCISpiTransportClass::wait(unsigned long timeout)

int HCISpiTransportClass::available()
{
if(_ble_chip != SPBTLE_RF && _ble_chip !=SPBTLE_1S && _ble_chip !=BLUENRG_M2SP)
if(_ble_chip != SPBTLE_RF && _ble_chip != SPBTLE_1S && _ble_chip != BLUENRG_M2SP && _ble_chip != BLUENRG_M0)
{
return 0;
}
Expand Down Expand Up @@ -137,7 +137,7 @@ int HCISpiTransportClass::available()
/* Write the header */
_spi->transfer(header_master, 5);

if (_ble_chip == SPBTLE_RF)
if (_ble_chip == SPBTLE_RF || _ble_chip == BLUENRG_M0)
{
/* device is ready */
if(header_master[0] == 0x02)
Expand Down Expand Up @@ -262,7 +262,7 @@ int HCISpiTransportClass::available()

if(ble_reset)
{
if (_ble_chip == SPBTLE_RF)
if (_ble_chip == SPBTLE_RF || _ble_chip == BLUENRG_M0)
{
/* BLE chip was reset: we need to enable LL_ONLY */
enable_ll_only();
Expand Down Expand Up @@ -330,14 +330,14 @@ size_t HCISpiTransportClass::write(const uint8_t* data, size_t length)
int result = 0;
uint32_t tickstart = millis();

if(_ble_chip != SPBTLE_RF && _ble_chip !=SPBTLE_1S && _ble_chip !=BLUENRG_M2SP)
if(_ble_chip != SPBTLE_RF && _ble_chip != SPBTLE_1S && _ble_chip != BLUENRG_M2SP && _ble_chip != BLUENRG_M0)
{
return 0;
}

do
{
if (_ble_chip == SPBTLE_RF)
if (_ble_chip == SPBTLE_RF || _ble_chip == BLUENRG_M0)
{
result = 0;

Expand Down
3 changes: 2 additions & 1 deletion src/utility/HCISpiTransport.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
typedef enum BLEChip_s {
SPBTLE_RF,
SPBTLE_1S,
BLUENRG_M2SP
BLUENRG_M2SP,
BLUENRG_M0
} BLEChip_t;

#ifndef BLE_SPI_BYTE_ORDER
Expand Down

0 comments on commit d952a0f

Please sign in to comment.