freertos: use xQueueCreateStatic instead of xQueueCreate if available

This commit is contained in:
Matthias Ringwald 2019-08-06 16:45:43 +02:00
parent 8291be9586
commit 0c9cde9532

View File

@ -76,6 +76,24 @@ typedef struct function_call {
static const btstack_run_loop_t btstack_run_loop_freertos; static const btstack_run_loop_t btstack_run_loop_freertos;
// pick allocation style, prefer static
#if( configSUPPORT_STATIC_ALLOCATION == 1 )
#define USE_STATIC_ALLOC
#elif( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
// ok, nothing to do
#else
#error "Either configSUPPORT_STATIC_ALLOCATION or configSUPPORT_DYNAMIC_ALLOCATION in FreeRTOSConfig.h must be 1"
#endif
// queue to receive events: up to 2 calls from transport, rest for app
#define RUN_LOOP_QUEUE_LENGTH 20
#define RUN_LOOP_QUEUE_ITEM_SIZE sizeof(function_call_t)
#ifdef USE_STATIC_ALLOC
static StaticQueue_t btstack_run_loop_queue_object;
static uint8_t btstack_run_loop_queue_storage[ RUN_LOOP_QUEUE_LENGTH * RUN_LOOP_QUEUE_ITEM_SIZE ];
#endif
static QueueHandle_t btstack_run_loop_queue; static QueueHandle_t btstack_run_loop_queue;
static TaskHandle_t btstack_run_loop_task; static TaskHandle_t btstack_run_loop_task;
@ -266,8 +284,11 @@ static void btstack_run_loop_freertos_disable_data_source_callbacks(btstack_data
static void btstack_run_loop_freertos_init(void){ static void btstack_run_loop_freertos_init(void){
timers = NULL; timers = NULL;
// queue to receive events: up to 2 calls from transport, up to 3 for app #ifdef USE_STATIC_ALLOC
btstack_run_loop_queue = xQueueCreate(20, sizeof(function_call_t)); btstack_run_loop_queue = xQueueCreateStatic(RUN_LOOP_QUEUE_LENGTH, RUN_LOOP_QUEUE_ITEM_SIZE, btstack_run_loop_queue_storage, &btstack_run_loop_queue_object);
#else
btstack_run_loop_queue = xQueueCreate(RUN_LOOP_QUEUE_LENGTH, RUN_LOOP_QUEUE_ITEM_SIZE);
#endif
#ifndef HAVE_FREERTOS_TASK_NOTIFICATIONS #ifndef HAVE_FREERTOS_TASK_NOTIFICATIONS
// event group to wake run loop // event group to wake run loop