Skip to content

Replace typo STBTLE with SPBTLE #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# STM32duinoBLE

This library is a fork of ArduinoBLE library to add the support of STBTLE-RF and STBTLE-1S BLE modules.
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 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 STBTLE-1S BLE module
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:

https://github.com/stm32duino/wiki/wiki/STM32duinoBLE-with-STEVAL_MKSBOX1V1
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name=STM32duinoBLE
version=1.1.1
author=Arduino, SRA
maintainer=stm32duino
sentence=Fork of ArduinoBLE library to add the support of STBTLE-RF and STBTLE-1S BLE modules.
sentence=Fork of ArduinoBLE library to add the support of SPBTLE-RF and SPBTLE-1S BLE modules.
paragraph=This library supports creating a BLE peripheral and BLE central mode.
category=Communication
url=https://github.com/stm32duino/STM32duinoBLE
Expand Down
56 changes: 28 additions & 28 deletions src/utility/HCISpiTransport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,15 @@ int HCISpiTransportClass::begin()
digitalWrite(_ble_rst, HIGH);
delay(5);

#if defined(STBTLE_RF)
#if defined(SPBTLE_RF)
// Wait for Blue Initialize
wait_for_blue_initialize();
#endif /* STBTLE_RF */
#endif /* SPBTLE_RF */

#if defined(STBTLE_1S)
#if defined(SPBTLE_1S)
// Wait a while for the reset of the BLE module
delay(300);
#endif /* STBTLE_1S */
#endif /* SPBTLE_1S */

return 1;
}
Expand Down Expand Up @@ -132,11 +132,11 @@ int HCISpiTransportClass::available()
/* Write the header */
_spi->transfer(header_master, 5);

#if defined(STBTLE_RF)
#if defined(SPBTLE_RF)
/* device is ready */
if(header_master[0] == 0x02)
{
#endif /* STBTLE_RF */
#endif /* SPBTLE_RF */
uint16_t byte_count = (header_master[4] << 8) | header_master[3];

if(byte_count > 0)
Expand All @@ -156,7 +156,7 @@ int HCISpiTransportClass::available()
_write_index_initial++;
}

#if defined(STBTLE_RF)
#if defined(SPBTLE_RF)
/* Check if the message is a Blue Initialize */
/* If so we need to send the command to enable LL_ONLY */
if(byte_count == 6)
Expand All @@ -171,8 +171,8 @@ int HCISpiTransportClass::available()
ble_reset = 1;
}
}
#endif /* STBTLE_RF */
#if defined(STBTLE_1S)
#endif /* SPBTLE_RF */
#if defined(SPBTLE_1S)
/* Check if the message is a CMD_COMPLETE */
/* We suppose that the first CMD is always a HCI_RESET */
if(byte_count == 7)
Expand All @@ -188,7 +188,7 @@ int HCISpiTransportClass::available()
ble_reset = 1;
}
}
#endif /* STBTLE_1S */
#endif /* SPBTLE_1S */
} else
{
/* avoid to read more data that available size of the buffer */
Expand All @@ -207,9 +207,9 @@ int HCISpiTransportClass::available()
}
}
}
#if defined(STBTLE_RF)
#if defined(SPBTLE_RF)
}
#endif /* STBTLE_RF */
#endif /* SPBTLE_RF */

digitalWrite(_cs_pin, HIGH);

Expand All @@ -218,15 +218,15 @@ int HCISpiTransportClass::available()

if(ble_reset)
{
#if defined(STBTLE_RF)
#if defined(SPBTLE_RF)
/* BLE chip was reset: we need to enable LL_ONLY */
enable_ll_only();
wait_for_enable_ll_only();
#endif /* STBTLE_RF */
#if defined(STBTLE_1S)
#endif /* SPBTLE_RF */
#if defined(SPBTLE_1S)
/* BLE chip was reset: we need to wait for a while */
delay(300);
#endif /* STBTLE_1S */
#endif /* SPBTLE_1S */

/* Now we can update the write index and close the initial phase */
_write_index = _write_index_initial;
Expand Down Expand Up @@ -287,16 +287,16 @@ size_t HCISpiTransportClass::write(const uint8_t* data, size_t length)

do
{
#if defined(STBTLE_1S)
#if defined(SPBTLE_1S)
uint32_t tickstart_data_available = millis();
#endif /* STBTLE_1S */
#endif /* SPBTLE_1S */
result = 0;

_spi->beginTransaction(SPISettings(_frequency, MSBFIRST, _spi_mode));

digitalWrite(_cs_pin, LOW);

#if defined(STBTLE_1S)
#if defined(SPBTLE_1S)
/*
* Wait until BlueNRG-1 is ready.
* When ready it will raise the IRQ pin.
Expand All @@ -316,33 +316,33 @@ size_t HCISpiTransportClass::write(const uint8_t* data, size_t length)
_spi->endTransaction();
break;
}
#endif /* STBTLE_1S */
#endif /* SPBTLE_1S */

/* Write the header */
_spi->transfer(header_master, 5);

#if defined(STBTLE_RF)
#if defined(SPBTLE_RF)
/* device is ready */
if(header_master[0] == 0x02)
{
if(header_master[1] >= length)
#endif /* STBTLE_RF */
#if defined(STBTLE_1S)
#endif /* SPBTLE_RF */
#if defined(SPBTLE_1S)
if((int)((((uint16_t)header_master[2])<<8) | ((uint16_t)header_master[1])) >= (int)length)
#endif /* STBTLE_1S */
#endif /* SPBTLE_1S */
{
/* Write the data */
_spi->transfer(my_data, length);
} else
{
result = -2;
}
#if defined(STBTLE_RF)
#if defined(SPBTLE_RF)
} else
{
result = -1;
}
#endif /* STBTLE_RF */
#endif /* SPBTLE_RF */

digitalWrite(_cs_pin, HIGH);

Expand All @@ -364,7 +364,7 @@ size_t HCISpiTransportClass::write(const uint8_t* data, size_t length)
}
}

#if defined(STBTLE_RF)
#if defined(SPBTLE_RF)
void HCISpiTransportClass::wait_for_blue_initialize()
{
int event_blue_initialize = 0;
Expand Down Expand Up @@ -535,7 +535,7 @@ void HCISpiTransportClass::enable_ll_only()
_spi->endTransaction();
} while (result < 0);
}
#endif /* STBTLE_RF */
#endif /* SPBTLE_RF */

#if defined(ARDUINO_STEVAL_MKSBOX1V1)
HCISpiTransportClass HCISpiTransport(SpiHCI, PD0, PD4, PA8, 1000000, SPI_MODE1); /* STEVAL_MKSBOX1V1 */
Expand Down
10 changes: 5 additions & 5 deletions src/utility/HCISpiTransport.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
#include "SPI.h"

#if defined(ARDUINO_STEVAL_MKSBOX1V1)
#define STBTLE_1S /* STEVAL_MKSBOX1V1 */
#define SPBTLE_1S /* STEVAL_MKSBOX1V1 */
#elif defined(ARDUINO_DISCO_L475VG_IOT)
#define STBTLE_RF /* B-L475E-IOT01A1 */
#define SPBTLE_RF /* B-L475E-IOT01A1 */
#else
#define STBTLE_RF /* Shield IDB05A1 */
#define SPBTLE_RF /* Shield IDB05A1 */
#endif /* ARDUINO_STEVAL_MKSBOX1V1 */

#define BLE_MODULE_SPI_BUFFER_SIZE 128
Expand All @@ -50,11 +50,11 @@ class HCISpiTransportClass : public HCITransportInterface {
virtual size_t write(const uint8_t* data, size_t length);

private:
#if defined(STBTLE_RF)
#if defined(SPBTLE_RF)
void wait_for_blue_initialize();
void wait_for_enable_ll_only();
void enable_ll_only();
#endif /* STBTLE_RF */
#endif /* SPBTLE_RF */
SPIClass* _spi;
uint8_t _cs_pin;
uint8_t _spi_irq;
Expand Down