COMPONENT_BlueNRG_MS review updates

pull/12456/head
jeromecoutant 2020-03-13 10:14:39 +01:00
parent f68ac88671
commit f7852142c1
1 changed files with 20 additions and 20 deletions

View File

@ -45,7 +45,7 @@
#define HCI_RESET_RAND_CNT 4 #define HCI_RESET_RAND_CNT 4
#define VENDOR_SPECIFIC_EVENT 0xFF #define VENDOR_SPECIFIC_EVENT 0xFF
#define EVT_BLUE_INITIALIZED 0x0001 #define EVT_BLUENRG_MS_INITIALIZED 0x0001
#define ACI_READ_CONFIG_DATA_OPCODE 0xFC0D #define ACI_READ_CONFIG_DATA_OPCODE 0xFC0D
#define ACI_WRITE_CONFIG_DATA_OPCODE 0xFC0C #define ACI_WRITE_CONFIG_DATA_OPCODE 0xFC0C
#define ACI_GATT_INIT_OPCODE 0xFD01 #define ACI_GATT_INIT_OPCODE 0xFD01
@ -60,16 +60,16 @@
namespace ble { namespace ble {
namespace vendor { namespace vendor {
namespace bluenrg { namespace bluenrg_ms {
/** /**
* BlueNRG HCI driver implementation. * BlueNRG_MS HCI driver implementation.
* @see cordio::CordioHCIDriver * @see cordio::CordioHCIDriver
*/ */
class HCIDriver : public cordio::CordioHCIDriver { class HCIDriver : public cordio::CordioHCIDriver {
public: public:
/** /**
* Construction of the BlueNRG HCIDriver. * Construction of the BlueNRG_MS HCIDriver.
* @param transport: Transport of the HCI commands. * @param transport: Transport of the HCI commands.
* @param rst: Name of the reset pin * @param rst: Name of the reset pin
*/ */
@ -81,7 +81,7 @@ public:
*/ */
virtual void do_initialize() virtual void do_initialize()
{ {
bluenrg_reset(); bluenrg_ms_reset();
} }
/** /**
@ -99,7 +99,7 @@ public:
virtual void start_reset_sequence() virtual void start_reset_sequence()
{ {
reset_received = false; reset_received = false;
bluenrg_initialized = false; bluenrg_ms_initialized = false;
enable_link_layer_mode_ongoing = false; enable_link_layer_mode_ongoing = false;
/* send an HCI Reset command to start the sequence */ /* send an HCI Reset command to start the sequence */
HciResetCmd(); HciResetCmd();
@ -135,8 +135,8 @@ public:
/* initialize rand command count */ /* initialize rand command count */
randCnt = 0; randCnt = 0;
reset_received = true; reset_received = true;
// bluenrg_initialized event has to come after the hci reset event // bluenrg_ms_initialized event has to come after the hci reset event
bluenrg_initialized = false; bluenrg_ms_initialized = false;
} }
break; break;
@ -294,11 +294,11 @@ public:
pMsg += HCI_EVT_HDR_LEN; pMsg += HCI_EVT_HDR_LEN;
BSTREAM_TO_UINT16(opcode, pMsg); BSTREAM_TO_UINT16(opcode, pMsg);
if (opcode == EVT_BLUE_INITIALIZED) { if (opcode == EVT_BLUENRG_MS_INITIALIZED) {
if (bluenrg_initialized) { if (bluenrg_ms_initialized) {
return; return;
} }
bluenrg_initialized = true; bluenrg_ms_initialized = true;
if (reset_received) { if (reset_received) {
aciEnableLinkLayerModeOnly(); aciEnableLinkLayerModeOnly();
} }
@ -398,9 +398,9 @@ private:
} }
} }
void bluenrg_reset() void bluenrg_ms_reset()
{ {
/* Reset BlueNRG SPI interface. Hold reset line to 0 for 1500ms */ /* Reset BlueNRG_MS SPI interface. Hold reset line to 0 for 1500ms */
rst = 0; rst = 0;
wait_us(1500); wait_us(1500);
rst = 1; rst = 1;
@ -411,12 +411,12 @@ private:
mbed::DigitalOut rst; mbed::DigitalOut rst;
bool reset_received; bool reset_received;
bool bluenrg_initialized; bool bluenrg_ms_initialized;
bool enable_link_layer_mode_ongoing; bool enable_link_layer_mode_ongoing;
}; };
/** /**
* Transport driver of the ST BlueNRG shield. * Transport driver of the ST BlueNRG_MS shield.
* @important: With that driver, it is assumed that the SPI bus used is not shared * @important: With that driver, it is assumed that the SPI bus used is not shared
* with other SPI peripherals. The reasons behind this choice are simplicity and * with other SPI peripherals. The reasons behind this choice are simplicity and
* performance: * performance:
@ -438,7 +438,7 @@ private:
class TransportDriver : public cordio::CordioHCITransportDriver { class TransportDriver : public cordio::CordioHCITransportDriver {
public: public:
/** /**
* Construct the transport driver required by a BlueNRG module. * Construct the transport driver required by a BlueNRG_MS module.
* @param mosi Pin of the SPI mosi * @param mosi Pin of the SPI mosi
* @param miso Pin of the SPI miso * @param miso Pin of the SPI miso
* @param sclk Pin of the SPI clock * @param sclk Pin of the SPI clock
@ -462,7 +462,7 @@ public:
spi.format(8, 0); spi.format(8, 0);
spi.frequency(8000000); spi.frequency(8000000);
// Deselect the BlueNRG chip by keeping its nCS signal high // Deselect the BlueNRG_MS chip by keeping its nCS signal high
nCS = 1; nCS = 1;
wait_us(500); wait_us(500);
@ -600,7 +600,7 @@ exit:
rtos::Mutex _spi_mutex; rtos::Mutex _spi_mutex;
}; };
} // namespace bluenrg } // namespace bluenrg_ms
} // namespace vendor } // namespace vendor
} // namespace ble } // namespace ble
@ -609,14 +609,14 @@ exit:
*/ */
ble::vendor::cordio::CordioHCIDriver &ble_cordio_get_hci_driver() ble::vendor::cordio::CordioHCIDriver &ble_cordio_get_hci_driver()
{ {
static ble::vendor::bluenrg::TransportDriver transport_driver( static ble::vendor::bluenrg_ms::TransportDriver transport_driver(
MBED_CONF_BLUENRG_MS_SPI_MOSI, MBED_CONF_BLUENRG_MS_SPI_MOSI,
MBED_CONF_BLUENRG_MS_SPI_MISO, MBED_CONF_BLUENRG_MS_SPI_MISO,
MBED_CONF_BLUENRG_MS_SPI_SCK, MBED_CONF_BLUENRG_MS_SPI_SCK,
MBED_CONF_BLUENRG_MS_SPI_NCS, MBED_CONF_BLUENRG_MS_SPI_NCS,
MBED_CONF_BLUENRG_MS_SPI_IRQ MBED_CONF_BLUENRG_MS_SPI_IRQ
); );
static ble::vendor::bluenrg::HCIDriver hci_driver( static ble::vendor::bluenrg_ms::HCIDriver hci_driver(
transport_driver, transport_driver,
MBED_CONF_BLUENRG_MS_SPI_RESET MBED_CONF_BLUENRG_MS_SPI_RESET
); );