xref: /btstack/platform/freertos/btstack_run_loop_freertos.c (revision c51a1d5a2d27174e1664798afd0c3660d7fa205a)
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"
70*c51a1d5aSMatthias Ringwald #include "semphr.h"
716d23ba05SMatthias Ringwald #endif
727d5f5399SMatthias Ringwald 
737d5f5399SMatthias Ringwald typedef struct function_call {
747d5f5399SMatthias Ringwald     void (*fn)(void * arg);
757d5f5399SMatthias Ringwald     void * arg;
767d5f5399SMatthias Ringwald } function_call_t;
777d5f5399SMatthias Ringwald 
780c9cde95SMatthias Ringwald // pick allocation style, prefer static
790c9cde95SMatthias Ringwald #if( configSUPPORT_STATIC_ALLOCATION == 1 )
800c9cde95SMatthias Ringwald #define USE_STATIC_ALLOC
810c9cde95SMatthias Ringwald #elif( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
820c9cde95SMatthias Ringwald // ok, nothing to do
830c9cde95SMatthias Ringwald #else
840c9cde95SMatthias Ringwald #error "Either configSUPPORT_STATIC_ALLOCATION or configSUPPORT_DYNAMIC_ALLOCATION in FreeRTOSConfig.h must be 1"
850c9cde95SMatthias Ringwald #endif
860c9cde95SMatthias Ringwald 
870c9cde95SMatthias Ringwald // queue to receive events: up to 2 calls from transport, rest for app
880c9cde95SMatthias Ringwald #define RUN_LOOP_QUEUE_LENGTH 20
890c9cde95SMatthias Ringwald #define RUN_LOOP_QUEUE_ITEM_SIZE sizeof(function_call_t)
900c9cde95SMatthias Ringwald 
910c9cde95SMatthias Ringwald #ifdef USE_STATIC_ALLOC
920c9cde95SMatthias Ringwald static StaticQueue_t btstack_run_loop_queue_object;
930c9cde95SMatthias Ringwald static uint8_t btstack_run_loop_queue_storage[ RUN_LOOP_QUEUE_LENGTH * RUN_LOOP_QUEUE_ITEM_SIZE ];
94*c51a1d5aSMatthias Ringwald static StaticSemaphore_t btstack_run_loop_callback_mutex_object;
950c9cde95SMatthias Ringwald #endif
960c9cde95SMatthias Ringwald 
977d5f5399SMatthias Ringwald static QueueHandle_t        btstack_run_loop_queue;
98828fd804SMatthias Ringwald static TaskHandle_t         btstack_run_loop_task;
99*c51a1d5aSMatthias Ringwald static SemaphoreHandle_t    btstack_run_loop_callbacks_mutex;
100f51d404eSMatthias Ringwald 
101f51d404eSMatthias Ringwald #ifndef HAVE_FREERTOS_TASK_NOTIFICATIONS
1027d5f5399SMatthias Ringwald static EventGroupHandle_t   btstack_run_loop_event_group;
103828fd804SMatthias Ringwald #endif
1047d5f5399SMatthias Ringwald 
1057d5f5399SMatthias Ringwald // bit 0 event group reserved to wakeup run loop
1067d5f5399SMatthias Ringwald #define EVENT_GROUP_FLAG_RUN_LOOP 1
1077d5f5399SMatthias Ringwald 
1087d5f5399SMatthias Ringwald // the run loop
1099dc32eb4SMatthias Ringwald static bool run_loop_exit_requested;
1107d5f5399SMatthias Ringwald 
1117d5f5399SMatthias Ringwald static uint32_t btstack_run_loop_freertos_get_time_ms(void){
1127d5f5399SMatthias Ringwald     return hal_time_ms();
1137d5f5399SMatthias Ringwald }
1147d5f5399SMatthias Ringwald 
1157d5f5399SMatthias Ringwald // set timer
1167d5f5399SMatthias Ringwald static void btstack_run_loop_freertos_set_timer(btstack_timer_source_t *ts, uint32_t timeout_in_ms){
1177d5f5399SMatthias Ringwald     ts->timeout = btstack_run_loop_freertos_get_time_ms() + timeout_in_ms + 1;
1187d5f5399SMatthias Ringwald }
1197d5f5399SMatthias Ringwald 
120*c51a1d5aSMatthias Ringwald static void btstack_run_loop_freertos_trigger_from_thread(void){
121828fd804SMatthias Ringwald #ifdef HAVE_FREERTOS_TASK_NOTIFICATIONS
122828fd804SMatthias Ringwald     xTaskNotify(btstack_run_loop_task, EVENT_GROUP_FLAG_RUN_LOOP, eSetBits);
123828fd804SMatthias Ringwald #else
1247d5f5399SMatthias Ringwald     xEventGroupSetBits(btstack_run_loop_event_group, EVENT_GROUP_FLAG_RUN_LOOP);
125828fd804SMatthias Ringwald #endif
1267d5f5399SMatthias Ringwald }
1277d5f5399SMatthias Ringwald 
128d145c914SMatthias Ringwald #if defined(HAVE_FREERTOS_TASK_NOTIFICATIONS) || (INCLUDE_xEventGroupSetBitFromISR == 1)
1294fd33db7SMatthias Ringwald static void btstack_run_loop_freertos_poll_data_sources_from_irq(void){
130d145c914SMatthias Ringwald     BaseType_t xHigherPriorityTaskWoken;
131d145c914SMatthias Ringwald #ifdef HAVE_FREERTOS_TASK_NOTIFICATIONS
132d145c914SMatthias Ringwald     xTaskNotifyFromISR(btstack_run_loop_task, EVENT_GROUP_FLAG_RUN_LOOP, eSetBits, &xHigherPriorityTaskWoken);
133d145c914SMatthias Ringwald     if (xHigherPriorityTaskWoken) {
134d145c914SMatthias Ringwald #ifdef ESP_PLATFORM
135d145c914SMatthias Ringwald         portYIELD_FROM_ISR();
136d145c914SMatthias Ringwald #else
137d145c914SMatthias Ringwald         portYIELD_FROM_ISR( xHigherPriorityTaskWoken );
138d145c914SMatthias Ringwald #endif
139d145c914SMatthias Ringwald     }
140d145c914SMatthias Ringwald #else
141d145c914SMatthias Ringwald     xEventGroupSetBitsFromISR(btstack_run_loop_event_group, EVENT_GROUP_FLAG_RUN_LOOP, &xHigherPriorityTaskWoken);
142d145c914SMatthias Ringwald #endif
143d145c914SMatthias Ringwald }
1447d5f5399SMatthias Ringwald #endif
1457d5f5399SMatthias Ringwald 
14638b6e836SMatthias Ringwald static void btstack_run_loop_freertos_trigger_exit_internal(void){
1479dc32eb4SMatthias Ringwald     run_loop_exit_requested = true;
1489dc32eb4SMatthias Ringwald }
1499dc32eb4SMatthias Ringwald 
1507d5f5399SMatthias Ringwald /**
1517d5f5399SMatthias Ringwald  * Execute run_loop
1527d5f5399SMatthias Ringwald  */
1534a76e901SMatthias Ringwald static void btstack_run_loop_freertos_execute(void) {
1547d5f5399SMatthias Ringwald     log_debug("RL: execute");
1557d5f5399SMatthias Ringwald 
1569dc32eb4SMatthias Ringwald     run_loop_exit_requested = false;
1579dc32eb4SMatthias Ringwald 
158ff3cc4a5SMatthias Ringwald     while (true) {
1597d5f5399SMatthias Ringwald 
1607d5f5399SMatthias Ringwald         // process data sources
161cd5f23a3SMatthias Ringwald         btstack_run_loop_base_poll_data_sources();
1627d5f5399SMatthias Ringwald 
163*c51a1d5aSMatthias Ringwald         // execute callbacks - protect list with mutex
164*c51a1d5aSMatthias Ringwald         while (1){
165*c51a1d5aSMatthias Ringwald             xSemaphoreTake(btstack_run_loop_callbacks_mutex, portMAX_DELAY);
166*c51a1d5aSMatthias Ringwald             btstack_context_callback_registration_t * callback_registration = (btstack_context_callback_registration_t *) btstack_linked_list_pop(&btstack_run_loop_base_callbacks);
167*c51a1d5aSMatthias Ringwald             xSemaphoreGive(btstack_run_loop_callbacks_mutex);
168*c51a1d5aSMatthias Ringwald             if (callback_registration == NULL){
169*c51a1d5aSMatthias Ringwald                 break;
170*c51a1d5aSMatthias Ringwald             }
171*c51a1d5aSMatthias Ringwald             (*callback_registration->callback)(callback_registration->context);
172*c51a1d5aSMatthias Ringwald         }
173*c51a1d5aSMatthias Ringwald 
174*c51a1d5aSMatthias Ringwald         // process registered function calls on run loop thread (deprecated)
175ff3cc4a5SMatthias Ringwald         while (true){
1767d5f5399SMatthias Ringwald             function_call_t message = { NULL, NULL };
1777d5f5399SMatthias Ringwald             BaseType_t res = xQueueReceive( btstack_run_loop_queue, &message, 0);
1787d5f5399SMatthias Ringwald             if (res == pdFALSE) break;
1797d5f5399SMatthias Ringwald             if (message.fn){
1807d5f5399SMatthias Ringwald                 message.fn(message.arg);
1817d5f5399SMatthias Ringwald             }
1827d5f5399SMatthias Ringwald         }
1837d5f5399SMatthias Ringwald 
184cd5f23a3SMatthias Ringwald         // process timers
1857d5f5399SMatthias Ringwald         uint32_t now = btstack_run_loop_freertos_get_time_ms();
186cd5f23a3SMatthias Ringwald         btstack_run_loop_base_process_timers(now);
1877d5f5399SMatthias Ringwald 
188*c51a1d5aSMatthias Ringwald         // exit triggered by btstack_run_loop_trigger_exit (main thread or other thread)
1899dc32eb4SMatthias Ringwald         if (run_loop_exit_requested) break;
1909dc32eb4SMatthias Ringwald 
191828fd804SMatthias Ringwald         // wait for timeout or event group/task notification
192cd5f23a3SMatthias Ringwald         int32_t timeout_next_timer_ms = btstack_run_loop_base_get_time_until_timeout(now);
193cd5f23a3SMatthias Ringwald 
194cd5f23a3SMatthias Ringwald         uint32_t timeout_ms = portMAX_DELAY;
195cd5f23a3SMatthias Ringwald         if (timeout_next_timer_ms >= 0){
196cd5f23a3SMatthias Ringwald             timeout_ms = (uint32_t) timeout_next_timer_ms;
197cd5f23a3SMatthias Ringwald         }
198cd5f23a3SMatthias Ringwald 
1997d5f5399SMatthias Ringwald         log_debug("RL: wait with timeout %u", (int) timeout_ms);
200828fd804SMatthias Ringwald #ifdef HAVE_FREERTOS_TASK_NOTIFICATIONS
201828fd804SMatthias Ringwald         xTaskNotifyWait(pdFALSE, 0xffffffff, NULL, pdMS_TO_TICKS(timeout_ms));
202828fd804SMatthias Ringwald #else
2037d5f5399SMatthias Ringwald         xEventGroupWaitBits(btstack_run_loop_event_group, EVENT_GROUP_FLAG_RUN_LOOP, 1, 0, pdMS_TO_TICKS(timeout_ms));
204828fd804SMatthias Ringwald #endif
2057d5f5399SMatthias Ringwald     }
2067d5f5399SMatthias Ringwald }
2077d5f5399SMatthias Ringwald 
208*c51a1d5aSMatthias Ringwald static void btstack_run_loop_freertos_execute_on_main_thread(btstack_context_callback_registration_t * callback_registration){
209*c51a1d5aSMatthias Ringwald     // protect list with mutex
210*c51a1d5aSMatthias Ringwald     xSemaphoreTake(btstack_run_loop_callbacks_mutex, portMAX_DELAY);
211*c51a1d5aSMatthias Ringwald     btstack_run_loop_base_add_callback(callback_registration);
212*c51a1d5aSMatthias Ringwald     xSemaphoreGive(btstack_run_loop_callbacks_mutex);
213*c51a1d5aSMatthias Ringwald     btstack_run_loop_freertos_trigger_from_thread();
214*c51a1d5aSMatthias Ringwald }
215*c51a1d5aSMatthias Ringwald 
2167d5f5399SMatthias Ringwald static void btstack_run_loop_freertos_init(void){
217cd5f23a3SMatthias Ringwald     btstack_run_loop_base_init();
2187d5f5399SMatthias Ringwald 
2190c9cde95SMatthias Ringwald #ifdef USE_STATIC_ALLOC
2200c9cde95SMatthias 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);
221*c51a1d5aSMatthias Ringwald     btstack_run_loop_mutex = xSemaphoreCreateMutexStatic(&btstack_run_loop_callback_mutex_object);
2220c9cde95SMatthias Ringwald #else
2230c9cde95SMatthias Ringwald     btstack_run_loop_queue = xQueueCreate(RUN_LOOP_QUEUE_LENGTH, RUN_LOOP_QUEUE_ITEM_SIZE);
224*c51a1d5aSMatthias Ringwald     btstack_run_loop_callbacks_mutex = xSemaphoreCreateMutex();
2250c9cde95SMatthias Ringwald #endif
2267d5f5399SMatthias Ringwald 
227828fd804SMatthias Ringwald #ifndef HAVE_FREERTOS_TASK_NOTIFICATIONS
2287d5f5399SMatthias Ringwald     // event group to wake run loop
2297d5f5399SMatthias Ringwald     btstack_run_loop_event_group = xEventGroupCreate();
230828fd804SMatthias Ringwald #endif
2317d5f5399SMatthias Ringwald 
232f51d404eSMatthias Ringwald     // task to handle to optimize 'run on main thread'
233a6f770a0SMatthias Ringwald     btstack_run_loop_task = xTaskGetCurrentTaskHandle();
234a6f770a0SMatthias Ringwald 
235f51d404eSMatthias Ringwald     log_info("run loop init, task %p, queue item size %u", btstack_run_loop_task, (int) sizeof(function_call_t));
2367d5f5399SMatthias Ringwald }
2377d5f5399SMatthias Ringwald 
2387d5f5399SMatthias Ringwald /**
2397d5f5399SMatthias Ringwald  * @brief Provide btstack_run_loop_posix instance for use with btstack_run_loop_init
2407d5f5399SMatthias Ringwald  */
2417d5f5399SMatthias Ringwald 
2427d5f5399SMatthias Ringwald static const btstack_run_loop_t btstack_run_loop_freertos = {
2437d5f5399SMatthias Ringwald     &btstack_run_loop_freertos_init,
244cd5f23a3SMatthias Ringwald     &btstack_run_loop_base_add_data_source,
245cd5f23a3SMatthias Ringwald     &btstack_run_loop_base_remove_data_source,
246cd5f23a3SMatthias Ringwald     &btstack_run_loop_base_enable_data_source_callbacks,
247cd5f23a3SMatthias Ringwald     &btstack_run_loop_base_disable_data_source_callbacks,
2487d5f5399SMatthias Ringwald     &btstack_run_loop_freertos_set_timer,
249cd5f23a3SMatthias Ringwald     &btstack_run_loop_base_add_timer,
250cd5f23a3SMatthias Ringwald     &btstack_run_loop_base_remove_timer,
2517d5f5399SMatthias Ringwald     &btstack_run_loop_freertos_execute,
252cd5f23a3SMatthias Ringwald     &btstack_run_loop_base_dump_timer,
2537d5f5399SMatthias Ringwald     &btstack_run_loop_freertos_get_time_ms,
2544fd33db7SMatthias Ringwald #if defined(HAVE_FREERTOS_TASK_NOTIFICATIONS) || (INCLUDE_xEventGroupSetBitFromISR == 1)
2554fd33db7SMatthias Ringwald     &btstack_run_loop_freertos_poll_data_sources_from_irq,
2564fd33db7SMatthias Ringwald #else
2574fd33db7SMatthias Ringwald     NULL,
2584fd33db7SMatthias Ringwald #endif
259*c51a1d5aSMatthias Ringwald     btstack_run_loop_freertos_execute_on_main_thread,
26038b6e836SMatthias Ringwald     &btstack_run_loop_freertos_trigger_exit_internal,
2617d5f5399SMatthias Ringwald };
2623c4cc642SMatthias Ringwald 
2633c4cc642SMatthias Ringwald const btstack_run_loop_t * btstack_run_loop_freertos_get_instance(void){
2643c4cc642SMatthias Ringwald     return &btstack_run_loop_freertos;
2653c4cc642SMatthias Ringwald }
266*c51a1d5aSMatthias Ringwald 
267*c51a1d5aSMatthias Ringwald 
268*c51a1d5aSMatthias Ringwald // @deprecated functions
269*c51a1d5aSMatthias Ringwald 
270*c51a1d5aSMatthias Ringwald // schedules execution from regular thread
271*c51a1d5aSMatthias Ringwald void btstack_run_loop_freertos_trigger(void){
272*c51a1d5aSMatthias Ringwald     btstack_run_loop_freertos_trigger_from_thread();
273*c51a1d5aSMatthias Ringwald }
274*c51a1d5aSMatthias Ringwald 
275*c51a1d5aSMatthias Ringwald void btstack_run_loop_freertos_execute_code_on_main_thread(void (*fn)(void *arg), void * arg){
276*c51a1d5aSMatthias Ringwald     // directly call function if already on btstack task
277*c51a1d5aSMatthias Ringwald     if (xTaskGetCurrentTaskHandle() == btstack_run_loop_task){
278*c51a1d5aSMatthias Ringwald         (*fn)(arg);
279*c51a1d5aSMatthias Ringwald         return;
280*c51a1d5aSMatthias Ringwald     }
281*c51a1d5aSMatthias Ringwald 
282*c51a1d5aSMatthias Ringwald     function_call_t message;
283*c51a1d5aSMatthias Ringwald     message.fn  = fn;
284*c51a1d5aSMatthias Ringwald     message.arg = arg;
285*c51a1d5aSMatthias Ringwald     BaseType_t res = xQueueSendToBack(btstack_run_loop_queue, &message, 0); // portMAX_DELAY);
286*c51a1d5aSMatthias Ringwald     if (res != pdTRUE){
287*c51a1d5aSMatthias Ringwald         log_error("Failed to post fn %p", fn);
288*c51a1d5aSMatthias Ringwald     }
289*c51a1d5aSMatthias Ringwald     btstack_run_loop_freertos_trigger();
290*c51a1d5aSMatthias Ringwald }
291*c51a1d5aSMatthias Ringwald 
292*c51a1d5aSMatthias Ringwald void btstack_run_loop_freertos_trigger_exit(void){
293*c51a1d5aSMatthias Ringwald     btstack_run_loop_freertos_trigger_exit_internal();
294*c51a1d5aSMatthias Ringwald }
295*c51a1d5aSMatthias Ringwald 
296*c51a1d5aSMatthias Ringwald #if defined(HAVE_FREERTOS_TASK_NOTIFICATIONS) || (INCLUDE_xEventGroupSetBitFromISR == 1)
297*c51a1d5aSMatthias Ringwald void btstack_run_loop_freertos_trigger_from_isr(void){
298*c51a1d5aSMatthias Ringwald     btstack_run_loop_freertos_trigger_from_isr();
299*c51a1d5aSMatthias Ringwald }
300*c51a1d5aSMatthias Ringwald #endif
301