17d5f5399SMatthias Ringwald /* 27d5f5399SMatthias Ringwald * Copyright (C) 2017 BlueKitchen GmbH 37d5f5399SMatthias Ringwald * 47d5f5399SMatthias Ringwald * Redistribution and use in source and binary forms, with or without 57d5f5399SMatthias Ringwald * modification, are permitted provided that the following conditions 67d5f5399SMatthias Ringwald * are met: 77d5f5399SMatthias Ringwald * 87d5f5399SMatthias Ringwald * 1. Redistributions of source code must retain the above copyright 97d5f5399SMatthias Ringwald * notice, this list of conditions and the following disclaimer. 107d5f5399SMatthias Ringwald * 2. Redistributions in binary form must reproduce the above copyright 117d5f5399SMatthias Ringwald * notice, this list of conditions and the following disclaimer in the 127d5f5399SMatthias Ringwald * documentation and/or other materials provided with the distribution. 137d5f5399SMatthias Ringwald * 3. Neither the name of the copyright holders nor the names of 147d5f5399SMatthias Ringwald * contributors may be used to endorse or promote products derived 157d5f5399SMatthias Ringwald * from this software without specific prior written permission. 167d5f5399SMatthias Ringwald * 4. Any redistribution, use, or modification is done solely for 177d5f5399SMatthias Ringwald * personal benefit and not for any commercial purpose or for 187d5f5399SMatthias Ringwald * monetary gain. 197d5f5399SMatthias Ringwald * 207d5f5399SMatthias Ringwald * THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS 217d5f5399SMatthias Ringwald * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 227d5f5399SMatthias Ringwald * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 237d5f5399SMatthias Ringwald * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MATTHIAS 247d5f5399SMatthias Ringwald * RINGWALD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 257d5f5399SMatthias Ringwald * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 267d5f5399SMatthias Ringwald * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 277d5f5399SMatthias Ringwald * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 287d5f5399SMatthias Ringwald * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 297d5f5399SMatthias Ringwald * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 307d5f5399SMatthias Ringwald * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 317d5f5399SMatthias Ringwald * SUCH DAMAGE. 327d5f5399SMatthias Ringwald * 337d5f5399SMatthias Ringwald * Please inquire about commercial licensing options at 347d5f5399SMatthias Ringwald * [email protected] 357d5f5399SMatthias Ringwald * 367d5f5399SMatthias Ringwald */ 377d5f5399SMatthias Ringwald 387d5f5399SMatthias Ringwald /* 397d5f5399SMatthias Ringwald * btstack_run_loop_freertos.c 407d5f5399SMatthias Ringwald * 417d5f5399SMatthias Ringwald * Run loop on dedicated thread on FreeRTOS 42828fd804SMatthias Ringwald * The run loop is triggered from other task/ISRs either via Event Groups 43828fd804SMatthias Ringwald * or Task Notifications if HAVE_FREERTOS_TASK_NOTIFICATIONS is defined 447d5f5399SMatthias Ringwald */ 457d5f5399SMatthias Ringwald 46e501bae0SMatthias Ringwald #define BTSTACK_FILE__ "btstack_run_loop_freertos.c" 470c2f4953SMatthias Ringwald 487d5f5399SMatthias Ringwald #include <stddef.h> // NULL 497d5f5399SMatthias Ringwald 509155bf8cSMatthias Ringwald #include "btstack_run_loop_freertos.h" 519155bf8cSMatthias Ringwald 527d5f5399SMatthias Ringwald #include "btstack_linked_list.h" 537d5f5399SMatthias Ringwald #include "btstack_debug.h" 549155bf8cSMatthias Ringwald #include "btstack_util.h" 556d23ba05SMatthias Ringwald #include "hal_time_ms.h" 567d5f5399SMatthias Ringwald 576d23ba05SMatthias Ringwald // some SDKs, e.g. esp-idf, place FreeRTOS headers into an 'freertos' folder to avoid name collisions (e.g. list.h, queue.h, ..) 586d23ba05SMatthias Ringwald // wih this flag, the headers are properly found 597d5f5399SMatthias Ringwald 606d23ba05SMatthias Ringwald #ifdef HAVE_FREERTOS_INCLUDE_PREFIX 617d5f5399SMatthias Ringwald #include "freertos/FreeRTOS.h" 627d5f5399SMatthias Ringwald #include "freertos/task.h" 637d5f5399SMatthias Ringwald #include "freertos/queue.h" 647d5f5399SMatthias Ringwald #include "freertos/event_groups.h" 656d23ba05SMatthias Ringwald #else 666d23ba05SMatthias Ringwald #include "FreeRTOS.h" 676d23ba05SMatthias Ringwald #include "task.h" 686d23ba05SMatthias Ringwald #include "queue.h" 696d23ba05SMatthias Ringwald #include "event_groups.h" 706d23ba05SMatthias Ringwald #endif 717d5f5399SMatthias Ringwald 727d5f5399SMatthias Ringwald typedef struct function_call { 737d5f5399SMatthias Ringwald void (*fn)(void * arg); 747d5f5399SMatthias Ringwald void * arg; 757d5f5399SMatthias Ringwald } function_call_t; 767d5f5399SMatthias Ringwald 770c9cde95SMatthias Ringwald // pick allocation style, prefer static 780c9cde95SMatthias Ringwald #if( configSUPPORT_STATIC_ALLOCATION == 1 ) 790c9cde95SMatthias Ringwald #define USE_STATIC_ALLOC 800c9cde95SMatthias Ringwald #elif( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) 810c9cde95SMatthias Ringwald // ok, nothing to do 820c9cde95SMatthias Ringwald #else 830c9cde95SMatthias Ringwald #error "Either configSUPPORT_STATIC_ALLOCATION or configSUPPORT_DYNAMIC_ALLOCATION in FreeRTOSConfig.h must be 1" 840c9cde95SMatthias Ringwald #endif 850c9cde95SMatthias Ringwald 860c9cde95SMatthias Ringwald // queue to receive events: up to 2 calls from transport, rest for app 870c9cde95SMatthias Ringwald #define RUN_LOOP_QUEUE_LENGTH 20 880c9cde95SMatthias Ringwald #define RUN_LOOP_QUEUE_ITEM_SIZE sizeof(function_call_t) 890c9cde95SMatthias Ringwald 900c9cde95SMatthias Ringwald #ifdef USE_STATIC_ALLOC 910c9cde95SMatthias Ringwald static StaticQueue_t btstack_run_loop_queue_object; 920c9cde95SMatthias Ringwald static uint8_t btstack_run_loop_queue_storage[ RUN_LOOP_QUEUE_LENGTH * RUN_LOOP_QUEUE_ITEM_SIZE ]; 930c9cde95SMatthias Ringwald #endif 940c9cde95SMatthias Ringwald 957d5f5399SMatthias Ringwald static QueueHandle_t btstack_run_loop_queue; 96828fd804SMatthias Ringwald static TaskHandle_t btstack_run_loop_task; 97f51d404eSMatthias Ringwald 98f51d404eSMatthias Ringwald #ifndef HAVE_FREERTOS_TASK_NOTIFICATIONS 997d5f5399SMatthias Ringwald static EventGroupHandle_t btstack_run_loop_event_group; 100828fd804SMatthias Ringwald #endif 1017d5f5399SMatthias Ringwald 1027d5f5399SMatthias Ringwald // bit 0 event group reserved to wakeup run loop 1037d5f5399SMatthias Ringwald #define EVENT_GROUP_FLAG_RUN_LOOP 1 1047d5f5399SMatthias Ringwald 1057d5f5399SMatthias Ringwald // the run loop 1067d5f5399SMatthias Ringwald static btstack_linked_list_t timers; 1077d5f5399SMatthias Ringwald static btstack_linked_list_t data_sources; 1087d5f5399SMatthias Ringwald 1097d5f5399SMatthias Ringwald static uint32_t btstack_run_loop_freertos_get_time_ms(void){ 1107d5f5399SMatthias Ringwald return hal_time_ms(); 1117d5f5399SMatthias Ringwald } 1127d5f5399SMatthias Ringwald 1137d5f5399SMatthias Ringwald // set timer 1147d5f5399SMatthias Ringwald static void btstack_run_loop_freertos_set_timer(btstack_timer_source_t *ts, uint32_t timeout_in_ms){ 1157d5f5399SMatthias Ringwald ts->timeout = btstack_run_loop_freertos_get_time_ms() + timeout_in_ms + 1; 1167d5f5399SMatthias Ringwald } 1177d5f5399SMatthias Ringwald 1187d5f5399SMatthias Ringwald /** 1197d5f5399SMatthias Ringwald * Add timer to run_loop (keep list sorted) 1207d5f5399SMatthias Ringwald */ 1217d5f5399SMatthias Ringwald static void btstack_run_loop_freertos_add_timer(btstack_timer_source_t *ts){ 1227d5f5399SMatthias Ringwald btstack_linked_item_t *it; 1237d5f5399SMatthias Ringwald for (it = (btstack_linked_item_t *) &timers; it->next ; it = it->next){ 1247d5f5399SMatthias Ringwald // don't add timer that's already in there 1259155bf8cSMatthias Ringwald btstack_timer_source_t * next = (btstack_timer_source_t *) it->next; 1269155bf8cSMatthias Ringwald if (next == ts){ 1277d5f5399SMatthias Ringwald log_error( "btstack_run_loop_timer_add error: timer to add already in list!"); 1287d5f5399SMatthias Ringwald return; 1297d5f5399SMatthias Ringwald } 1309155bf8cSMatthias Ringwald // exit if new timeout before list timeout 1319155bf8cSMatthias Ringwald int32_t delta = btstack_time_delta(ts->timeout, next->timeout); 1329155bf8cSMatthias Ringwald if (delta < 0) break; 1337d5f5399SMatthias Ringwald } 1347d5f5399SMatthias Ringwald ts->item.next = it->next; 1357d5f5399SMatthias Ringwald it->next = (btstack_linked_item_t *) ts; 1367d5f5399SMatthias Ringwald } 1377d5f5399SMatthias Ringwald 1387d5f5399SMatthias Ringwald /** 1397d5f5399SMatthias Ringwald * Remove timer from run loop 1407d5f5399SMatthias Ringwald */ 141*d58a1b5fSMatthias Ringwald static bool btstack_run_loop_freertos_remove_timer(btstack_timer_source_t *ts){ 1427d5f5399SMatthias Ringwald return btstack_linked_list_remove(&timers, (btstack_linked_item_t *) ts); 1437d5f5399SMatthias Ringwald } 1447d5f5399SMatthias Ringwald 1457d5f5399SMatthias Ringwald static void btstack_run_loop_freertos_dump_timer(void){ 1467d5f5399SMatthias Ringwald #ifdef ENABLE_LOG_INFO 1477d5f5399SMatthias Ringwald btstack_linked_item_t *it; 1487d5f5399SMatthias Ringwald int i = 0; 1497d5f5399SMatthias Ringwald for (it = (btstack_linked_item_t *) timers; it ; it = it->next){ 1507d5f5399SMatthias Ringwald btstack_timer_source_t *ts = (btstack_timer_source_t*) it; 1517d5f5399SMatthias Ringwald log_info("timer %u, timeout %u\n", i, (unsigned int) ts->timeout); 1527d5f5399SMatthias Ringwald } 1537d5f5399SMatthias Ringwald #endif 1547d5f5399SMatthias Ringwald } 1557d5f5399SMatthias Ringwald 1567d5f5399SMatthias Ringwald // schedules execution from regular thread 1577d5f5399SMatthias Ringwald void btstack_run_loop_freertos_trigger(void){ 158828fd804SMatthias Ringwald #ifdef HAVE_FREERTOS_TASK_NOTIFICATIONS 159828fd804SMatthias Ringwald xTaskNotify(btstack_run_loop_task, EVENT_GROUP_FLAG_RUN_LOOP, eSetBits); 160828fd804SMatthias Ringwald #else 1617d5f5399SMatthias Ringwald xEventGroupSetBits(btstack_run_loop_event_group, EVENT_GROUP_FLAG_RUN_LOOP); 162828fd804SMatthias Ringwald #endif 1637d5f5399SMatthias Ringwald } 1647d5f5399SMatthias Ringwald 1657d5f5399SMatthias Ringwald void btstack_run_loop_freertos_execute_code_on_main_thread(void (*fn)(void *arg), void * arg){ 166f51d404eSMatthias Ringwald 167f51d404eSMatthias Ringwald // directly call function if already on btstack task 168f51d404eSMatthias Ringwald if (xTaskGetCurrentTaskHandle() == btstack_run_loop_task){ 169f51d404eSMatthias Ringwald (*fn)(arg); 170f51d404eSMatthias Ringwald return; 171f51d404eSMatthias Ringwald } 172f51d404eSMatthias Ringwald 1737d5f5399SMatthias Ringwald function_call_t message; 1747d5f5399SMatthias Ringwald message.fn = fn; 1757d5f5399SMatthias Ringwald message.arg = arg; 1767d5f5399SMatthias Ringwald BaseType_t res = xQueueSendToBack(btstack_run_loop_queue, &message, 0); // portMAX_DELAY); 1777d5f5399SMatthias Ringwald if (res != pdTRUE){ 1787d5f5399SMatthias Ringwald log_error("Failed to post fn %p", fn); 1797d5f5399SMatthias Ringwald } 1807d5f5399SMatthias Ringwald btstack_run_loop_freertos_trigger(); 1817d5f5399SMatthias Ringwald } 1827d5f5399SMatthias Ringwald 183828fd804SMatthias Ringwald #if defined(HAVE_FREERTOS_TASK_NOTIFICATIONS) || (INCLUDE_xEventGroupSetBitFromISR == 1) 1847d5f5399SMatthias Ringwald void btstack_run_loop_freertos_trigger_from_isr(void){ 1853b1180c9SMatthias Ringwald BaseType_t xHigherPriorityTaskWoken; 186828fd804SMatthias Ringwald #ifdef HAVE_FREERTOS_TASK_NOTIFICATIONS 187828fd804SMatthias Ringwald xTaskNotifyFromISR(btstack_run_loop_task, EVENT_GROUP_FLAG_RUN_LOOP, eSetBits, &xHigherPriorityTaskWoken); 188828fd804SMatthias Ringwald if (xHigherPriorityTaskWoken) { 189297a0e05SMatthias Ringwald #ifdef ESP_PLATFORM 190297a0e05SMatthias Ringwald portYIELD_FROM_ISR(); 191297a0e05SMatthias Ringwald #else 192828fd804SMatthias Ringwald portYIELD_FROM_ISR( xHigherPriorityTaskWoken ); 193297a0e05SMatthias Ringwald #endif 194828fd804SMatthias Ringwald } 195828fd804SMatthias Ringwald #else 1963b1180c9SMatthias Ringwald xEventGroupSetBitsFromISR(btstack_run_loop_event_group, EVENT_GROUP_FLAG_RUN_LOOP, &xHigherPriorityTaskWoken); 197828fd804SMatthias Ringwald #endif 1987d5f5399SMatthias Ringwald } 1997d5f5399SMatthias Ringwald 2007d5f5399SMatthias Ringwald void btstack_run_loop_freertos_execute_code_on_main_thread_from_isr(void (*fn)(void *arg), void * arg){ 2017d5f5399SMatthias Ringwald function_call_t message; 2027d5f5399SMatthias Ringwald message.fn = fn; 2037d5f5399SMatthias Ringwald message.arg = arg; 2047d5f5399SMatthias Ringwald BaseType_t xHigherPriorityTaskWoken; 2057d5f5399SMatthias Ringwald xQueueSendToBackFromISR(btstack_run_loop_queue, &message, &xHigherPriorityTaskWoken); 2067d5f5399SMatthias Ringwald btstack_run_loop_freertos_trigger_from_isr(); 2077d5f5399SMatthias Ringwald } 2087d5f5399SMatthias Ringwald #endif 2097d5f5399SMatthias Ringwald 2107d5f5399SMatthias Ringwald /** 2117d5f5399SMatthias Ringwald * Execute run_loop 2127d5f5399SMatthias Ringwald */ 2134a76e901SMatthias Ringwald static void btstack_run_loop_freertos_execute(void) { 2147d5f5399SMatthias Ringwald log_debug("RL: execute"); 2157d5f5399SMatthias Ringwald 2167d5f5399SMatthias Ringwald while (1) { 2177d5f5399SMatthias Ringwald 2187d5f5399SMatthias Ringwald // process data sources 2197d5f5399SMatthias Ringwald btstack_data_source_t *ds; 2207d5f5399SMatthias Ringwald btstack_data_source_t *next; 2217d5f5399SMatthias Ringwald for (ds = (btstack_data_source_t *) data_sources; ds != NULL ; ds = next){ 2227d5f5399SMatthias Ringwald next = (btstack_data_source_t *) ds->item.next; // cache pointer to next data_source to allow data source to remove itself 2237d5f5399SMatthias Ringwald if (ds->flags & DATA_SOURCE_CALLBACK_POLL){ 2247d5f5399SMatthias Ringwald ds->process(ds, DATA_SOURCE_CALLBACK_POLL); 2257d5f5399SMatthias Ringwald } 2267d5f5399SMatthias Ringwald } 2277d5f5399SMatthias Ringwald 2287d5f5399SMatthias Ringwald // process registered function calls on run loop thread 2297d5f5399SMatthias Ringwald while (1){ 2307d5f5399SMatthias Ringwald function_call_t message = { NULL, NULL }; 2317d5f5399SMatthias Ringwald BaseType_t res = xQueueReceive( btstack_run_loop_queue, &message, 0); 2327d5f5399SMatthias Ringwald if (res == pdFALSE) break; 2337d5f5399SMatthias Ringwald if (message.fn){ 2347d5f5399SMatthias Ringwald message.fn(message.arg); 2357d5f5399SMatthias Ringwald } 2367d5f5399SMatthias Ringwald } 2377d5f5399SMatthias Ringwald 2389155bf8cSMatthias Ringwald // process timers and get next timeout 2397d5f5399SMatthias Ringwald uint32_t timeout_ms = portMAX_DELAY; 2407d5f5399SMatthias Ringwald log_debug("RL: portMAX_DELAY %u", portMAX_DELAY); 2417d5f5399SMatthias Ringwald while (timers) { 2427d5f5399SMatthias Ringwald btstack_timer_source_t * ts = (btstack_timer_source_t *) timers; 2437d5f5399SMatthias Ringwald uint32_t now = btstack_run_loop_freertos_get_time_ms(); 2449155bf8cSMatthias Ringwald int32_t delta_ms = btstack_time_delta(ts->timeout, now); 2459155bf8cSMatthias Ringwald log_debug("RL: now %u, expires %u -> delta %d", now, ts->timeout, delta_ms); 2469155bf8cSMatthias Ringwald if (delta_ms > 0){ 2479155bf8cSMatthias Ringwald timeout_ms = delta_ms; 2487d5f5399SMatthias Ringwald break; 2497d5f5399SMatthias Ringwald } 2507d5f5399SMatthias Ringwald // remove timer before processing it to allow handler to re-register with run loop 251b7832c7fSMatthias Ringwald btstack_run_loop_freertos_remove_timer(ts); 2527d5f5399SMatthias Ringwald log_debug("RL: first timer %p", ts->process); 2537d5f5399SMatthias Ringwald ts->process(ts); 2547d5f5399SMatthias Ringwald } 2557d5f5399SMatthias Ringwald 256828fd804SMatthias Ringwald // wait for timeout or event group/task notification 2577d5f5399SMatthias Ringwald log_debug("RL: wait with timeout %u", (int) timeout_ms); 258828fd804SMatthias Ringwald #ifdef HAVE_FREERTOS_TASK_NOTIFICATIONS 259828fd804SMatthias Ringwald xTaskNotifyWait(pdFALSE, 0xffffffff, NULL, pdMS_TO_TICKS(timeout_ms)); 260828fd804SMatthias Ringwald #else 2617d5f5399SMatthias Ringwald xEventGroupWaitBits(btstack_run_loop_event_group, EVENT_GROUP_FLAG_RUN_LOOP, 1, 0, pdMS_TO_TICKS(timeout_ms)); 262828fd804SMatthias Ringwald #endif 2637d5f5399SMatthias Ringwald } 2647d5f5399SMatthias Ringwald } 2657d5f5399SMatthias Ringwald 2667d5f5399SMatthias Ringwald static void btstack_run_loop_freertos_add_data_source(btstack_data_source_t *ds){ 2677d5f5399SMatthias Ringwald btstack_linked_list_add(&data_sources, (btstack_linked_item_t *) ds); 2687d5f5399SMatthias Ringwald } 2697d5f5399SMatthias Ringwald 270*d58a1b5fSMatthias Ringwald static bool btstack_run_loop_freertos_remove_data_source(btstack_data_source_t *ds){ 2717d5f5399SMatthias Ringwald return btstack_linked_list_remove(&data_sources, (btstack_linked_item_t *) ds); 2727d5f5399SMatthias Ringwald } 2737d5f5399SMatthias Ringwald 2747d5f5399SMatthias Ringwald static void btstack_run_loop_freertos_enable_data_source_callbacks(btstack_data_source_t * ds, uint16_t callback_types){ 2757d5f5399SMatthias Ringwald ds->flags |= callback_types; 2767d5f5399SMatthias Ringwald } 2777d5f5399SMatthias Ringwald 2787d5f5399SMatthias Ringwald static void btstack_run_loop_freertos_disable_data_source_callbacks(btstack_data_source_t * ds, uint16_t callback_types){ 2797d5f5399SMatthias Ringwald ds->flags &= ~callback_types; 2807d5f5399SMatthias Ringwald } 2817d5f5399SMatthias Ringwald 2827d5f5399SMatthias Ringwald static void btstack_run_loop_freertos_init(void){ 2837d5f5399SMatthias Ringwald timers = NULL; 2847d5f5399SMatthias Ringwald 2850c9cde95SMatthias Ringwald #ifdef USE_STATIC_ALLOC 2860c9cde95SMatthias Ringwald btstack_run_loop_queue = xQueueCreateStatic(RUN_LOOP_QUEUE_LENGTH, RUN_LOOP_QUEUE_ITEM_SIZE, btstack_run_loop_queue_storage, &btstack_run_loop_queue_object); 2870c9cde95SMatthias Ringwald #else 2880c9cde95SMatthias Ringwald btstack_run_loop_queue = xQueueCreate(RUN_LOOP_QUEUE_LENGTH, RUN_LOOP_QUEUE_ITEM_SIZE); 2890c9cde95SMatthias Ringwald #endif 2907d5f5399SMatthias Ringwald 291828fd804SMatthias Ringwald #ifndef HAVE_FREERTOS_TASK_NOTIFICATIONS 2927d5f5399SMatthias Ringwald // event group to wake run loop 2937d5f5399SMatthias Ringwald btstack_run_loop_event_group = xEventGroupCreate(); 294828fd804SMatthias Ringwald #endif 2957d5f5399SMatthias Ringwald 296f51d404eSMatthias Ringwald // task to handle to optimize 'run on main thread' 297a6f770a0SMatthias Ringwald btstack_run_loop_task = xTaskGetCurrentTaskHandle(); 298a6f770a0SMatthias Ringwald 299f51d404eSMatthias Ringwald log_info("run loop init, task %p, queue item size %u", btstack_run_loop_task, (int) sizeof(function_call_t)); 3007d5f5399SMatthias Ringwald } 3017d5f5399SMatthias Ringwald 3027d5f5399SMatthias Ringwald /** 3037d5f5399SMatthias Ringwald * @brief Provide btstack_run_loop_posix instance for use with btstack_run_loop_init 3047d5f5399SMatthias Ringwald */ 3057d5f5399SMatthias Ringwald 3067d5f5399SMatthias Ringwald static const btstack_run_loop_t btstack_run_loop_freertos = { 3077d5f5399SMatthias Ringwald &btstack_run_loop_freertos_init, 3087d5f5399SMatthias Ringwald &btstack_run_loop_freertos_add_data_source, 3097d5f5399SMatthias Ringwald &btstack_run_loop_freertos_remove_data_source, 3107d5f5399SMatthias Ringwald &btstack_run_loop_freertos_enable_data_source_callbacks, 3117d5f5399SMatthias Ringwald &btstack_run_loop_freertos_disable_data_source_callbacks, 3127d5f5399SMatthias Ringwald &btstack_run_loop_freertos_set_timer, 3137d5f5399SMatthias Ringwald &btstack_run_loop_freertos_add_timer, 3147d5f5399SMatthias Ringwald &btstack_run_loop_freertos_remove_timer, 3157d5f5399SMatthias Ringwald &btstack_run_loop_freertos_execute, 3167d5f5399SMatthias Ringwald &btstack_run_loop_freertos_dump_timer, 3177d5f5399SMatthias Ringwald &btstack_run_loop_freertos_get_time_ms, 3187d5f5399SMatthias Ringwald }; 3193c4cc642SMatthias Ringwald 3203c4cc642SMatthias Ringwald const btstack_run_loop_t * btstack_run_loop_freertos_get_instance(void){ 3213c4cc642SMatthias Ringwald return &btstack_run_loop_freertos; 3223c4cc642SMatthias Ringwald } 323