xref: /btstack/platform/freertos/btstack_run_loop_freertos.h (revision 9dc32eb425c45f51cd4be899bc05cae06f314fba)
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.h
407d5f5399SMatthias Ringwald  *
417d5f5399SMatthias Ringwald  * Functions relevant for BTstack WICED port
427d5f5399SMatthias Ringwald  */
437d5f5399SMatthias Ringwald 
4480e33422SMatthias Ringwald #ifndef BTSTACK_RUN_LOOP_FREERTOS_H
4580e33422SMatthias Ringwald #define BTSTACK_RUN_LOOP_FREERTOS_H
467d5f5399SMatthias Ringwald 
477d5f5399SMatthias Ringwald #include "btstack_config.h"
487d5f5399SMatthias Ringwald #include "btstack_run_loop.h"
497d5f5399SMatthias Ringwald 
507d5f5399SMatthias Ringwald #if defined __cplusplus
517d5f5399SMatthias Ringwald extern "C" {
527d5f5399SMatthias Ringwald #endif
537d5f5399SMatthias Ringwald 
547d5f5399SMatthias Ringwald /**
557d5f5399SMatthias Ringwald  * @brief Provide btstack_run_loop_freertos instance for use with btstack_run_loop_init
567d5f5399SMatthias Ringwald  */
577d5f5399SMatthias Ringwald const btstack_run_loop_t * btstack_run_loop_freertos_get_instance(void);
587d5f5399SMatthias Ringwald 
597d5f5399SMatthias Ringwald /*
607d5f5399SMatthias Ringwald  * @brief Execute code on BTstack run loop. Can be used to control BTstack from a different thread
617d5f5399SMatthias Ringwald  */
627d5f5399SMatthias Ringwald void btstack_run_loop_freertos_execute_code_on_main_thread(void (*fn)(void *arg), void * arg);
637d5f5399SMatthias Ringwald 
647d5f5399SMatthias Ringwald /*
657d5f5399SMatthias Ringwald  * @brief Execute code on BTstack run loop. Can be used to control BTstack from an ISR
667d5f5399SMatthias Ringwald  */
677d5f5399SMatthias Ringwald void btstack_run_loop_freertos_execute_code_on_main_thread_from_isr(void (*fn)(void *arg), void * arg);
687d5f5399SMatthias Ringwald 
697d5f5399SMatthias Ringwald /**
707d5f5399SMatthias Ringwald  * @brief Triggers processing of data sources from thread context.
717d5f5399SMatthias Ringwald  * Has to be called after enabling a poll data source to wake-pup run loop.
727d5f5399SMatthias Ringwald  */
737d5f5399SMatthias Ringwald void btstack_run_loop_freertos_trigger(void);
747d5f5399SMatthias Ringwald 
757d5f5399SMatthias Ringwald /**
767d5f5399SMatthias Ringwald  * @brief Triggers processing of data sources from an ISR.
777d5f5399SMatthias Ringwald  * Has to be called after enabling a poll data source to wake-pup run loop.
787d5f5399SMatthias Ringwald  */
797d5f5399SMatthias Ringwald void btstack_run_loop_freertos_trigger_from_isr(void);
80*9dc32eb4SMatthias Ringwald 
81*9dc32eb4SMatthias Ringwald /**
82*9dc32eb4SMatthias Ringwald  * @brief Triggers exit of run loop from BTstack main thread, causes call to btstack_run_loop_execute to return
83*9dc32eb4SMatthias Ringwald  */
84*9dc32eb4SMatthias Ringwald void btstack_run_loop_freertos_trigger_exit(void);
857d5f5399SMatthias Ringwald 
867d5f5399SMatthias Ringwald /* API_END */
877d5f5399SMatthias Ringwald 
887d5f5399SMatthias Ringwald #if defined __cplusplus
897d5f5399SMatthias Ringwald }
907d5f5399SMatthias Ringwald #endif
917d5f5399SMatthias Ringwald 
9280e33422SMatthias Ringwald #endif // btstack_run_loop_WICED_H
93