diff --git a/include/btstack/run_loop.h b/include/btstack/run_loop.h index f0c881038..ddb2d856a 100644 --- a/include/btstack/run_loop.h +++ b/include/btstack/run_loop.h @@ -68,7 +68,7 @@ typedef struct timer { #ifdef HAVE_TIME struct timeval timeout; // <-- next timeout #endif -#ifdef EMBEDDED +#ifdef HAVE_TICK uint32_t timeout; // timeout in system ticks #endif void (*process)(struct timer *ts); // <-- do processing @@ -94,7 +94,7 @@ int run_loop_remove_data_source(data_source_t *dataSource); void run_loop_execute(void); // hack to fix HCI timer handling -#ifdef EMBEDDED +#ifdef HAVE_TICK uint32_t embedded_get_ticks(void); uint32_t embedded_ticks_for_ms(uint32_t time_in_ms); #endif diff --git a/src/hci.c b/src/hci.c index 9ffcca2a2..e0f1736ad 100644 --- a/src/hci.c +++ b/src/hci.c @@ -86,7 +86,7 @@ static void hci_connection_timeout_handler(timer_source_t *timer){ hci_emit_l2cap_check_timeout(connection); } #endif -#ifdef EMBEDDED +#ifdef HAVE_TICK if (embedded_get_ticks() > connection->timestamp + embedded_ticks_for_ms(HCI_CONNECTION_TIMEOUT_MS)){ // connections might be timed out hci_emit_l2cap_check_timeout(connection); @@ -100,7 +100,7 @@ static void hci_connection_timestamp(hci_connection_t *connection){ #ifdef HAVE_TIME gettimeofday(&connection->timestamp, NULL); #endif -#ifdef EMBEDDED +#ifdef HAVE_TICK connection->timestamp = embedded_get_ticks(); #endif } diff --git a/src/hci.h b/src/hci.h index 391d00441..6b14907c0 100644 --- a/src/hci.h +++ b/src/hci.h @@ -230,7 +230,7 @@ typedef struct { // timer struct timeval timestamp; #endif -#ifdef EMBEDDED +#ifdef HAVE_TICK uint32_t timestamp; // timeout in system ticks #endif diff --git a/src/run_loop_embedded.c b/src/run_loop_embedded.c index d5bfd7b62..25a9485cc 100644 --- a/src/run_loop_embedded.c +++ b/src/run_loop_embedded.c @@ -52,7 +52,7 @@ // the run loop static linked_list_t data_sources; -#ifdef EMBEDDED +#ifdef HAVE_TICK static linked_list_t timers; static uint32_t system_ticks; #endif @@ -75,7 +75,7 @@ int embedded_remove_data_source(data_source_t *ds){ * Add timer to run_loop (keep list sorted) */ void embedded_add_timer(timer_source_t *ts){ -#ifdef EMBEDDED +#ifdef HAVE_TICK linked_item_t *it; for (it = (linked_item_t *) &timers; it->next ; it = it->next){ if (ts->timeout < ((timer_source_t *) it->next)->timeout) { @@ -93,7 +93,7 @@ void embedded_add_timer(timer_source_t *ts){ * Remove timer from run loop */ int embedded_remove_timer(timer_source_t *ts){ -#ifdef EMBEDDED +#ifdef HAVE_TICK // log_info("Removed timer %x at %u\n", (int) ts, (unsigned int) ts->timeout.tv_sec); return linked_list_remove(&timers, (linked_item_t *) ts); #else @@ -127,7 +127,7 @@ void embedded_execute() { ds->process(ds); } -#ifdef EMBEDDED +#ifdef HAVE_TICK // process timers while (timers) { timer_source_t *ts = (timer_source_t *) timers; @@ -140,7 +140,7 @@ void embedded_execute() { } } -#ifdef EMBEDDED +#ifdef HAVE_TICK static void embedded_tick_handler(void){ system_ticks++; } @@ -165,7 +165,7 @@ void embedded_init(){ data_sources = NULL; -#ifdef EMBEDDED +#ifdef HAVE_TICK timers = NULL; system_ticks = 0; hal_tick_init();