filo123 wrote on Saturday, June 30, 2018:
I want to use a statically allocated queue set (yes - I know that there are other equivalent mechanisms). There is no xQueueCreateSetStatic so I have come up with this piece of code:
#if( ( configUSE_QUEUE_SETS == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) )
QueueSetHandle_t xQueueCreateSetStatic( const UBaseType_t uxEventQueueLength, uint8_t *pucQueueSetStorage, StaticQueue_t *pxStaticQueueSet )
{
QueueSetHandle_t pxQueue;
pxQueue = xQueueGenericCreateStatic( uxEventQueueLength, ( UBaseType_t ) sizeof( Queue_t * ), pucQueueSetStorage, pxStaticQueueSet, queueQUEUE_TYPE_SET );
return pxQueue;
}
#endif /* configUSE_QUEUE_SETS */
Questions:
- Is there a better/clearer way to implement this functionality?
- When using this function I have to pass a pointer to a buffer that will hold the queue set elements, internally each element has size
sizeof(Queue_t*)
, which is simply size of a pointer. Is it safe to usestatic uint8_t queue_set_storage[sizeof(void*)*N];
as the buffer? (GCC, Cortex-M)