xref: /btstack/platform/freertos/btstack_run_loop_freertos.h (revision 7d5f53998d474b9e8db259b6e20afe96e52f8c76)
1*7d5f5399SMatthias Ringwald /*
2*7d5f5399SMatthias Ringwald  * Copyright (C) 2017 BlueKitchen GmbH
3*7d5f5399SMatthias Ringwald  *
4*7d5f5399SMatthias Ringwald  * Redistribution and use in source and binary forms, with or without
5*7d5f5399SMatthias Ringwald  * modification, are permitted provided that the following conditions
6*7d5f5399SMatthias Ringwald  * are met:
7*7d5f5399SMatthias Ringwald  *
8*7d5f5399SMatthias Ringwald  * 1. Redistributions of source code must retain the above copyright
9*7d5f5399SMatthias Ringwald  *    notice, this list of conditions and the following disclaimer.
10*7d5f5399SMatthias Ringwald  * 2. Redistributions in binary form must reproduce the above copyright
11*7d5f5399SMatthias Ringwald  *    notice, this list of conditions and the following disclaimer in the
12*7d5f5399SMatthias Ringwald  *    documentation and/or other materials provided with the distribution.
13*7d5f5399SMatthias Ringwald  * 3. Neither the name of the copyright holders nor the names of
14*7d5f5399SMatthias Ringwald  *    contributors may be used to endorse or promote products derived
15*7d5f5399SMatthias Ringwald  *    from this software without specific prior written permission.
16*7d5f5399SMatthias Ringwald  * 4. Any redistribution, use, or modification is done solely for
17*7d5f5399SMatthias Ringwald  *    personal benefit and not for any commercial purpose or for
18*7d5f5399SMatthias Ringwald  *    monetary gain.
19*7d5f5399SMatthias Ringwald  *
20*7d5f5399SMatthias Ringwald  * THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS
21*7d5f5399SMatthias Ringwald  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22*7d5f5399SMatthias Ringwald  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23*7d5f5399SMatthias Ringwald  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MATTHIAS
24*7d5f5399SMatthias Ringwald  * RINGWALD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25*7d5f5399SMatthias Ringwald  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26*7d5f5399SMatthias Ringwald  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
27*7d5f5399SMatthias Ringwald  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
28*7d5f5399SMatthias Ringwald  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29*7d5f5399SMatthias Ringwald  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
30*7d5f5399SMatthias Ringwald  * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31*7d5f5399SMatthias Ringwald  * SUCH DAMAGE.
32*7d5f5399SMatthias Ringwald  *
33*7d5f5399SMatthias Ringwald  * Please inquire about commercial licensing options at
34*7d5f5399SMatthias Ringwald  * [email protected]
35*7d5f5399SMatthias Ringwald  *
36*7d5f5399SMatthias Ringwald  */
37*7d5f5399SMatthias Ringwald 
38*7d5f5399SMatthias Ringwald /*
39*7d5f5399SMatthias Ringwald  * btstack_run_loop_freertos.h
40*7d5f5399SMatthias Ringwald  *
41*7d5f5399SMatthias Ringwald  * Functions relevant for BTstack WICED port
42*7d5f5399SMatthias Ringwald  */
43*7d5f5399SMatthias Ringwald 
44*7d5f5399SMatthias Ringwald #ifndef __BTSTACK_RUN_LOOP_FREERTOS_H
45*7d5f5399SMatthias Ringwald #define __BTSTACK_RUN_LOOP_FREERTOS_H
46*7d5f5399SMatthias Ringwald 
47*7d5f5399SMatthias Ringwald #include "btstack_config.h"
48*7d5f5399SMatthias Ringwald #include "btstack_run_loop.h"
49*7d5f5399SMatthias Ringwald 
50*7d5f5399SMatthias Ringwald #if defined __cplusplus
51*7d5f5399SMatthias Ringwald extern "C" {
52*7d5f5399SMatthias Ringwald #endif
53*7d5f5399SMatthias Ringwald 
54*7d5f5399SMatthias Ringwald /**
55*7d5f5399SMatthias Ringwald  * @brief Provide btstack_run_loop_freertos instance for use with btstack_run_loop_init
56*7d5f5399SMatthias Ringwald  */
57*7d5f5399SMatthias Ringwald const btstack_run_loop_t * btstack_run_loop_freertos_get_instance(void);
58*7d5f5399SMatthias Ringwald 
59*7d5f5399SMatthias Ringwald /*
60*7d5f5399SMatthias Ringwald  * @brief Execute code on BTstack run loop. Can be used to control BTstack from a different thread
61*7d5f5399SMatthias Ringwald  */
62*7d5f5399SMatthias Ringwald void btstack_run_loop_freertos_execute_code_on_main_thread(void (*fn)(void *arg), void * arg);
63*7d5f5399SMatthias Ringwald 
64*7d5f5399SMatthias Ringwald /*
65*7d5f5399SMatthias Ringwald  * @brief Execute code on BTstack run loop. Can be used to control BTstack from an ISR
66*7d5f5399SMatthias Ringwald  */
67*7d5f5399SMatthias Ringwald void btstack_run_loop_freertos_execute_code_on_main_thread_from_isr(void (*fn)(void *arg), void * arg);
68*7d5f5399SMatthias Ringwald 
69*7d5f5399SMatthias Ringwald /**
70*7d5f5399SMatthias Ringwald  * @brief Triggers processing of data sources from thread context.
71*7d5f5399SMatthias Ringwald  * Has to be called after enabling a poll data source to wake-pup run loop.
72*7d5f5399SMatthias Ringwald  */
73*7d5f5399SMatthias Ringwald void btstack_run_loop_freertos_trigger(void);
74*7d5f5399SMatthias Ringwald 
75*7d5f5399SMatthias Ringwald /**
76*7d5f5399SMatthias Ringwald  * @brief Triggers processing of data sources from an ISR.
77*7d5f5399SMatthias Ringwald  * Has to be called after enabling a poll data source to wake-pup run loop.
78*7d5f5399SMatthias Ringwald  */
79*7d5f5399SMatthias Ringwald void btstack_run_loop_freertos_trigger_from_isr(void);
80*7d5f5399SMatthias Ringwald 
81*7d5f5399SMatthias Ringwald /* API_END */
82*7d5f5399SMatthias Ringwald 
83*7d5f5399SMatthias Ringwald #if defined __cplusplus
84*7d5f5399SMatthias Ringwald }
85*7d5f5399SMatthias Ringwald #endif
86*7d5f5399SMatthias Ringwald 
87*7d5f5399SMatthias Ringwald #endif // __btstack_run_loop_WICED_H
88