1b7d596c1SMatthias Ringwald /* 2b7d596c1SMatthias Ringwald * Copyright (C) 2014 BlueKitchen GmbH 3b7d596c1SMatthias Ringwald * 4b7d596c1SMatthias Ringwald * Redistribution and use in source and binary forms, with or without 5b7d596c1SMatthias Ringwald * modification, are permitted provided that the following conditions 6b7d596c1SMatthias Ringwald * are met: 7b7d596c1SMatthias Ringwald * 8b7d596c1SMatthias Ringwald * 1. Redistributions of source code must retain the above copyright 9b7d596c1SMatthias Ringwald * notice, this list of conditions and the following disclaimer. 10b7d596c1SMatthias Ringwald * 2. Redistributions in binary form must reproduce the above copyright 11b7d596c1SMatthias Ringwald * notice, this list of conditions and the following disclaimer in the 12b7d596c1SMatthias Ringwald * documentation and/or other materials provided with the distribution. 13b7d596c1SMatthias Ringwald * 3. Neither the name of the copyright holders nor the names of 14b7d596c1SMatthias Ringwald * contributors may be used to endorse or promote products derived 15b7d596c1SMatthias Ringwald * from this software without specific prior written permission. 16b7d596c1SMatthias Ringwald * 4. Any redistribution, use, or modification is done solely for 17b7d596c1SMatthias Ringwald * personal benefit and not for any commercial purpose or for 18b7d596c1SMatthias Ringwald * monetary gain. 19b7d596c1SMatthias Ringwald * 20b7d596c1SMatthias Ringwald * THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS 21b7d596c1SMatthias Ringwald * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22b7d596c1SMatthias Ringwald * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23*2fca4dadSMilanka Ringwald * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BLUEKITCHEN 24*2fca4dadSMilanka Ringwald * GMBH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25b7d596c1SMatthias Ringwald * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26b7d596c1SMatthias Ringwald * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 27b7d596c1SMatthias Ringwald * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 28b7d596c1SMatthias Ringwald * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29b7d596c1SMatthias Ringwald * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 30b7d596c1SMatthias Ringwald * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31b7d596c1SMatthias Ringwald * SUCH DAMAGE. 32b7d596c1SMatthias Ringwald * 33b7d596c1SMatthias Ringwald * Please inquire about commercial licensing options at 34b7d596c1SMatthias Ringwald * [email protected] 35b7d596c1SMatthias Ringwald * 36b7d596c1SMatthias Ringwald */ 37b7d596c1SMatthias Ringwald 38b7d596c1SMatthias Ringwald /* 398f2a52f4SMatthias Ringwald * btstack_run_loop_embedded.h 40b7d596c1SMatthias Ringwald * Functionality special to the embedded run loop 41b7d596c1SMatthias Ringwald */ 42b7d596c1SMatthias Ringwald 4380e33422SMatthias Ringwald #ifndef BTSTACK_RUN_LOOP_EMBEDDED_H 4480e33422SMatthias Ringwald #define BTSTACK_RUN_LOOP_EMBEDDED_H 45b7d596c1SMatthias Ringwald 467907f069SMatthias Ringwald #include "btstack_config.h" 47b7d596c1SMatthias Ringwald #include "btstack_linked_list.h" 48a6efb919SMatthias Ringwald #include "btstack_run_loop.h" 49b7d596c1SMatthias Ringwald 50d0755cd6SMatthias Ringwald #ifdef HAVE_POSIX_TIME 51b7d596c1SMatthias Ringwald #include <sys/time.h> 52b7d596c1SMatthias Ringwald #endif 53b7d596c1SMatthias Ringwald #include <stdint.h> 54b7d596c1SMatthias Ringwald 55b7d596c1SMatthias Ringwald #if defined __cplusplus 56b7d596c1SMatthias Ringwald extern "C" { 57b7d596c1SMatthias Ringwald #endif 58b7d596c1SMatthias Ringwald 59b7d596c1SMatthias Ringwald /** 60528a4a3bSMatthias Ringwald * Provide btstack_run_loop_embedded instance 61b7d596c1SMatthias Ringwald */ 62528a4a3bSMatthias Ringwald const btstack_run_loop_t * btstack_run_loop_embedded_get_instance(void); 63b7d596c1SMatthias Ringwald 64b7d596c1SMatthias Ringwald // hack to fix HCI timer handling 65aec7654dSMatthias Ringwald #ifdef HAVE_EMBEDDED_TICK 66b7d596c1SMatthias Ringwald /** 67b7d596c1SMatthias Ringwald * @brief Sets how many milliseconds has one tick. 68b7d596c1SMatthias Ringwald */ 69528a4a3bSMatthias Ringwald uint32_t btstack_run_loop_embedded_ticks_for_ms(uint32_t time_in_ms); 70b7d596c1SMatthias Ringwald /** 71b7d596c1SMatthias Ringwald * @brief Queries the current time in ticks. 72b7d596c1SMatthias Ringwald */ 73528a4a3bSMatthias Ringwald uint32_t btstack_run_loop_embedded_get_ticks(void); 74b7d596c1SMatthias Ringwald #endif 75b7d596c1SMatthias Ringwald 76b7d596c1SMatthias Ringwald /** 77b7d596c1SMatthias Ringwald * @brief Sets an internal flag that is checked in the critical section just before entering sleep mode. Has to be called by the interrupt handler of a data source to signal the run loop that a new data is available. 78decb7d9bSMatthias Ringwald * @deprecated Please use btstack_run_loop_poll_data_sources_from_irq() instead 79b7d596c1SMatthias Ringwald */ 80528a4a3bSMatthias Ringwald void btstack_run_loop_embedded_trigger(void); 81decb7d9bSMatthias Ringwald 82b7d596c1SMatthias Ringwald /** 83decb7d9bSMatthias Ringwald * @brief Execute run_loop once. It can be used to integrate BTstack's timer and data source processing into a foreign run loop 84decb7d9bSMatthias Ringwald * 85decb7d9bSMatthias Ringwald * @note Not recommended. Instead, you can implement the btstack_run_loop_t interface with your own run loop and request 86decb7d9bSMatthias Ringwald * - processing of timers by calling btstack_run_loop_base_process_timers and 87decb7d9bSMatthias Ringwald * - poll data sources with by calling btstack_run_loop_base_poll_data_sources 88b7d596c1SMatthias Ringwald */ 89528a4a3bSMatthias Ringwald void btstack_run_loop_embedded_execute_once(void); 90b7d596c1SMatthias Ringwald 91b7d596c1SMatthias Ringwald /* API_END */ 92b7d596c1SMatthias Ringwald 93b7d596c1SMatthias Ringwald #if defined __cplusplus 94b7d596c1SMatthias Ringwald } 95b7d596c1SMatthias Ringwald #endif 96b7d596c1SMatthias Ringwald 9780e33422SMatthias Ringwald #endif // BTSTACK_RUN_LOOP_EMBEDDED_H 98