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 */
|
||||
#define PRINT_HCI_DATA 1
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* BLE config parameters
|
||||
******************************************************************************/
|
||||
|
@ -76,6 +75,7 @@ static bool acl_data_wait(void);
|
|||
static void init_debug( void );
|
||||
static bool get_bd_address( uint8_t* bd_addr );
|
||||
static bool sysevt_wait( void);
|
||||
static bool sysevt_check( void);
|
||||
|
||||
|
||||
namespace ble {
|
||||
|
@ -439,9 +439,14 @@ public:
|
|||
* @see CordioHCITransportDriver::initialize
|
||||
*/
|
||||
virtual void initialize() {
|
||||
init_debug();
|
||||
stm32wb_reset();
|
||||
transport_init();
|
||||
/* 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();
|
||||
stm32wb_reset();
|
||||
transport_init();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -750,9 +755,24 @@ static void sysevt_received( void* pdata) {
|
|||
static bool sysevt_wait( void) {
|
||||
/* Wait for 10sec max - if not return an error */
|
||||
if(sys_event_sem.wait(10000) < 1) {
|
||||
return false;
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
/* 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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue