I'm using CMSIS-RTOS2 (an RTOS FreeRTOS based for ARM), I just want to know if there are any function to clean a queue (put 0 in all positions). Just it, like "reboot" the queue.
#include "cmsis_os.h"
osMessageQueueId_t xGPS_QueueHandle;
const osMessageQueueAttr_t xGPS_Queue_attributes = {
.name = "xGPS_Queue"
};
xGPS_QueueHandle = osMessageQueueNew (250, sizeof(uint8_t), &xGPS_Queue_attributes);
I already found the answer!
The function:
osStatus_t osMessageQueueReset(osMessageQueueId_t mq_id)
In my case I need to use:
osMessageQueueReset(xGPS_QueueHandle);
The returned variable could be:
osOK: the message queue has been rest.
osErrorParameter: parameter mq_id is NULL or invalid.
osErrorResource: the message queue is in an invalid state.
osErrorISR: osMessageQueueReset cannot be called from interrupt service routines.
More details could be found in the documentation: https://www.keil.com/pack/doc/CMSIS/RTOS2/html/group__CMSIS__RTOS__Message.html#gac6dce7f9ad132d266292c2e979d861b4