Question
During startup I occasionally get stuck in the function UTIL_SEQ_WaitEvt located in STM32_seq.c.
Here is the function running in my STM32WB55CG:
/**
* this function can be nested
*/
void UTIL_SEQ_WaitEvt( UTIL_SEQ_bm_t evt_id_bm )
{
UTIL_SEQ_bm_t event_waited_id_backup;
UTIL_SEQ_bm_t current_task_id_bm;
/** store in local the current_task_id_bm as the global variable CurrentTaskIdx
* may be overwritten in case there are nested call of UTIL_SEQ_Run()
*/
current_task_id_bm = (1 << CurrentTaskIdx);
/** backup the event id that was currently waited */
event_waited_id_backup = EvtWaited;
EvtWaited = evt_id_bm;
/**
* wait for the new event
* note: that means that if the previous waited event occurs, it will not exit
* the while loop below.
* The system is waiting only for the last waited event.
* When it will go out, it will wait again fro the previous one.
* It case it occurs while waiting for the second one, the while loop will exit immediately
*/
while((EvtSet & EvtWaited) == 0)
{
UTIL_SEQ_EvtIdle(current_task_id_bm, EvtWaited);
}
EvtSet &= (~EvtWaited);
EvtWaited = event_waited_id_backup;
return;
}The code repeatedly calls UTIL_SEQ_EvtIdle(current_task_id_bm, EvtWaited).
current_task_id_bm is set to: CFG_TASK_SYSTEM_HCI_ASYNCH_EVT_ID
EvtWaited is set to: CFG_IDLEEVT_HCI_CMD_EVT_RSP_ID
Since I am not getting stuck there every time, it feels like some kind of race condition.
The comment seems to mention never leaving the while loop but I am not understanding it if it is telling me how to fix or prevent it.
Thanks for any help.
