mirror of https://github.com/ARMmbed/mbed-os.git
STM32WB: Handle re-init case of transport layer
Issue was seen when running BLE_GAP example from mbed-os-example-ble. In STM32WB, the M0 core cannot be reset except if the whole target is reset. So in case of re-initialization of the BLE stack, the transport layer should not be initialized again. The HCI reset command will do the job.pull/10326/head
parent
d50f6e2690
commit
e6cecda33b
|
@ -64,7 +64,6 @@
|
||||||
/* activate to add debug traces */
|
/* activate to add debug traces */
|
||||||
#define PRINT_HCI_DATA 1
|
#define PRINT_HCI_DATA 1
|
||||||
|
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* BLE config parameters
|
* BLE config parameters
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
@ -76,6 +75,7 @@ static bool acl_data_wait(void);
|
||||||
static void init_debug( void );
|
static void init_debug( void );
|
||||||
static bool get_bd_address( uint8_t* bd_addr );
|
static bool get_bd_address( uint8_t* bd_addr );
|
||||||
static bool sysevt_wait( void);
|
static bool sysevt_wait( void);
|
||||||
|
static bool sysevt_check( void);
|
||||||
|
|
||||||
|
|
||||||
namespace ble {
|
namespace ble {
|
||||||
|
@ -439,10 +439,15 @@ public:
|
||||||
* @see CordioHCITransportDriver::initialize
|
* @see CordioHCITransportDriver::initialize
|
||||||
*/
|
*/
|
||||||
virtual void initialize() {
|
virtual void initialize() {
|
||||||
|
/* Check whether M0 sub-system was started already by
|
||||||
|
* checking if the system event was already received
|
||||||
|
* before. If it was not, then go thru all init. */
|
||||||
|
if(!sysevt_check()) {
|
||||||
init_debug();
|
init_debug();
|
||||||
stm32wb_reset();
|
stm32wb_reset();
|
||||||
transport_init();
|
transport_init();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see CordioHCITransportDriver::terminate
|
* @see CordioHCITransportDriver::terminate
|
||||||
|
@ -752,6 +757,21 @@ static bool sysevt_wait( void) {
|
||||||
if(sys_event_sem.wait(10000) < 1) {
|
if(sys_event_sem.wait(10000) < 1) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
|
/* release immmediately, now that M0 runs */
|
||||||
|
sys_event_sem.release();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* returns true if ssyevt was already received, which means M0 core is
|
||||||
|
* already up and running */
|
||||||
|
static bool sysevt_check( void) {
|
||||||
|
/* Check if system is UP and runing already */
|
||||||
|
if(sys_event_sem.wait(10) < 1) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
/* release immmediately as M0 already runs */
|
||||||
|
sys_event_sem.release();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue