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
Laurent Meunier 2019-03-20 18:40:14 +01:00 committed by Martin Kojtal
parent d50f6e2690
commit e6cecda33b
1 changed files with 26 additions and 6 deletions

View File

@ -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,9 +439,14 @@ public:
* @see CordioHCITransportDriver::initialize * @see CordioHCITransportDriver::initialize
*/ */
virtual void initialize() { virtual void initialize() {
init_debug(); /* Check whether M0 sub-system was started already by
stm32wb_reset(); * checking if the system event was already received
transport_init(); * 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) { static bool sysevt_wait( void) {
/* Wait for 10sec max - if not return an error */ /* Wait for 10sec max - if not return an error */
if(sys_event_sem.wait(10000) < 1) { if(sys_event_sem.wait(10000) < 1) {
return false; return false;
} else { } 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;
} }
} }