diff --git a/platform/embedded/hci_transport_h4_dma.c b/platform/embedded/hci_transport_h4_dma.c index da8f6e634..521c7160c 100644 --- a/platform/embedded/hci_transport_h4_dma.c +++ b/platform/embedded/hci_transport_h4_dma.c @@ -50,6 +50,7 @@ #include "hci.h" #include "hci_transport.h" #include "run_loop.h" +#include "run_loop_embedded.h" #include "hal_uart_dma.h" diff --git a/platform/embedded/hci_transport_h4_ehcill_dma.c b/platform/embedded/hci_transport_h4_ehcill_dma.c index b3bda545d..f5e3ef3a1 100644 --- a/platform/embedded/hci_transport_h4_ehcill_dma.c +++ b/platform/embedded/hci_transport_h4_ehcill_dma.c @@ -55,6 +55,7 @@ #include "hci.h" #include "hci_transport.h" #include "run_loop.h" +#include "run_loop_embedded.h" #include "hal_uart_dma.h" diff --git a/platform/embedded/run_loop_embedded.c b/platform/embedded/run_loop_embedded.c index 91396db3c..0dd23a53b 100644 --- a/platform/embedded/run_loop_embedded.c +++ b/platform/embedded/run_loop_embedded.c @@ -54,6 +54,7 @@ #include "run_loop.h" +#include "run_loop_embedded.h" #include "bk_linked_list.h" #include "hal_tick.h" #include "hal_cpu.h" diff --git a/platform/embedded/run_loop_embedded.h b/platform/embedded/run_loop_embedded.h new file mode 100644 index 000000000..fc5f15e23 --- /dev/null +++ b/platform/embedded/run_loop_embedded.h @@ -0,0 +1,88 @@ +/* + * Copyright (C) 2014 BlueKitchen GmbH + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the copyright holders nor the names of + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * 4. Any redistribution, use, or modification is done solely for + * personal benefit and not for any commercial purpose or for + * monetary gain. + * + * THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MATTHIAS + * RINGWALD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF + * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * Please inquire about commercial licensing options at + * contact@bluekitchen-gmbh.com + * + */ + +/* + * run_loop_embedded.h + * Functionality special to the embedded run loop + */ + +#ifndef __RUN_LOOP_EMBEDDED_H +#define __RUN_LOOP_EMBEDDED_H + +#include "btstack-config.h" +#include "bk_linked_list.h" + +#ifdef HAVE_TIME +#include +#endif +#include + +#if defined __cplusplus +extern "C" { +#endif + + +// hack to fix HCI timer handling +#ifdef HAVE_TICK +/** + * @brief Sets how many milliseconds has one tick. + */ +uint32_t run_loop_embedded_ticks_for_ms(uint32_t time_in_ms); +/** + * @brief Queries the current time in ticks. + */ +uint32_t run_loop_embedded_get_ticks(void); +#endif + +#ifdef EMBEDDED +/** + * @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. + */ +void run_loop_embedded_trigger(void); +/** + * @brief Execute run_loop once. It can be used to integrate BTstack's timer and data source processing into a foreign run loop (it is not recommended). + */ +void run_loop_embedded_execute_once(void); +#endif + +/* API_END */ + +#if defined __cplusplus +} +#endif + +#endif // __RUN_LOOP_EMBEDDED_H diff --git a/port/arduino/BTstack.cpp b/port/arduino/BTstack.cpp index 865f7eea2..08752eacf 100644 --- a/port/arduino/BTstack.cpp +++ b/port/arduino/BTstack.cpp @@ -21,6 +21,7 @@ #include "hci_cmds.h" #include "utils.h" #include "run_loop.h" +#include "run_loop_embedded.h" #include "classic/sdp_util.h" #include "bt_control_em9301.h" @@ -40,7 +41,6 @@ #define PIN_LED 13 // prototypes -extern "C" void run_loop_embedded_execute_once(void); extern "C" void hal_uart_dma_process(void); enum { diff --git a/port/pic32-harmony/src/btstack_port.c b/port/pic32-harmony/src/btstack_port.c index ce42d5054..6cf045447 100644 --- a/port/pic32-harmony/src/btstack_port.c +++ b/port/pic32-harmony/src/btstack_port.c @@ -6,6 +6,7 @@ #include "system_config.h" #include "bt_control_csr.h" #include "run_loop.h" +#include "run_loop_embedded.h" #include "hci_dump.h" #include "hci.h" #include "hci_transport.h" @@ -19,7 +20,6 @@ #include "peripheral/usart/plib_usart.h" #include "system/ports/sys_ports.h" - // int btstack_main(int argc, const char * argv[]); diff --git a/src/run_loop.h b/src/run_loop.h index 40cc720a7..da7268859 100644 --- a/src/run_loop.h +++ b/src/run_loop.h @@ -127,28 +127,6 @@ int run_loop_remove_data_source(data_source_t *dataSource); */ void run_loop_execute(void); -// hack to fix HCI timer handling -#ifdef HAVE_TICK -/** - * @brief Sets how many milliseconds has one tick. - */ -uint32_t run_loop_embedded_ticks_for_ms(uint32_t time_in_ms); -/** - * @brief Queries the current time in ticks. - */ -uint32_t run_loop_embedded_get_ticks(void); -#endif -#ifdef EMBEDDED -/** - * @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. - */ -void run_loop_embedded_trigger(void); -/** - * @brief Execute run_loop once. It can be used to integrate BTstack's timer and data source processing into a foreign run loop (it is not recommended). - */ -void run_loop_embedded_execute_once(void); -#endif - /* API_END */ #if defined __cplusplus