I'm running FreeRTOS on a ST Nucleo board with the BlueNRG shield.
The initialization of the BLE stack works, the devices advertises itself and I can establish a connection. My problem is that as soon as user event arrives (e.g. service discovery) the program ends up in the hardfault_handler()
.
I have 3 tasks running on my RTOS of which one should be a dedicated BLE task handling the user events.
void hci_user_evt_proc(void)
{
tHciDataPacket * hciReadPacket = NULL;
/* process any pending events read */
while (list_is_empty(&hciReadPktRxQueue) == FALSE)
{
list_remove_head (&hciReadPktRxQueue, (tListNode **)&hciReadPacket);
if (hciContext.UserEvtRx != NULL)
{
hciContext.UserEvtRx(hciReadPacket->dataBuff);
}
list_insert_tail(&hciReadPktPool, (tListNode *)hciReadPacket);
}
}
This is taken from an ST example code. The whole thing works if I either
- Just run this one task or
- Give the BLE task a higher priority
Both solutions have the same outcome - and don't have a multitasking system anymore.
I don't know if a have to adapt the example code to run in a multitask system or if I have to run the BLE process interrupt driven, but if yes, how would I do that and how can I elaborate the root cause of a hardfault
?
What I tried is to surround my user_evt_handler
with a vTaskSuspendAll/xTaskResumeAll
but that didn't change anything.