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( ( configUSEQUEUESETS == 1 ) && ( configSUPPORTSTATICALLOCATION == 1 ) )
QueueSetHandle_t xQueueCreateSetStatic( const UBaseType_t uxEventQueueLength, uint8_t *pucQueueSetStorage, StaticQueue_t *pxStaticQueueSet )
pxQueue = xQueueGenericCreateStatic( uxEventQueueLength, ( UBaseType_t ) sizeof( Queue_t * ), pucQueueSetStorage, pxStaticQueueSet, queueQUEUE_TYPE_SET );
endif /* configUSEQUEUESETS */
1. Is there a better/clearer way to implement this functionality?
2. 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 use
static uint8_t queue_set_storage[sizeof(void*)*N]; as the buffer? (GCC, Cortex-M)
That looks fine. Your application could of course just call
xQueueGeneriCreateStatic() directly, but its not a documented API
function so could change in the future - hence the way you are doing is
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.