cancel
Showing results for 
Search instead for 
Did you mean: 

FreeRTOS implementation with X-Cube-BLE2

NafiurRahman
Associate II

I'm trying to implement a BLE task in my FreeRTOS application with the X-Nucleo-BNRG2A1 shield. I completed the BLE application (X-Cube-BLE2 package) without FreeRTOS and it has been working fine. For implementing the FreeRTOS, I have been looking into the BLE_HeartRateFreeRTOS example for reference. It looks like the hci_user_evt_proc() function is different in the BLE_HeartRateFreeRTOS example and the X-Cube-BLE2 default example. The BLE_HeartRateFreeRTOS hci_user_evt_proc() has a the following comment:

/**

  * Up to release version v1.2.0, a while loop was implemented to read out events from the queue as long as

  * it is not empty. However, in a bare metal implementation, this leads to calling in a "blocking" mode

  * hci_user_evt_proc() as long as events are received without giving the opportunity to run other tasks

  * in the background.

  * From now, the events are reported one by one. When it is checked there is still an event pending in the queue,

  * a request to the user is made to call again hci_user_evt_proc().

  * This gives the opportunity to the application to run other background tasks between each event.

  */

Moreover, the hci_user_evt_proc() function is called inside the HciUserEvtProcess() task where it waits for a Thread Flag. The Thread Flag is called from hci_notify_asynch_evt callback function. It looks like the hci_notify_asynch_evt function is also different from the X-Cube-BLE2 package. FYI:

static void HciUserEvtProcess(void *argument)

{

 UNUSED(argument);

 for(;;)

 {

  osThreadFlagsWait( 1, osFlagsWaitAny, osWaitForever);

  hci_user_evt_proc( );

 }

}

void hci_notify_asynch_evt(void* pdata)

{

 UNUSED(pdata);

 osThreadFlagsSet( HciUserEvtProcessId, 1 );

 return;

}

My question is, how do I implement FreeRTOS with my X-Nucleo-BLE2 package as the library files are different. Should I include the hci_user_evt_proc() inside a task with same priority with the other tasks so that other tasks will not be blocked? Or is there an update that I'm missing?

Looking for expert helps. @Sebastien DENOUAL​ I really appreciated your help in my previous application. Can you provide you expert advice once again?

0 REPLIES 0