mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-02-18 21:41:16 +00:00
replace EMBEDDED with HAVE_TICK where appropriate
This commit is contained in:
parent
0ff3056bc7
commit
e5780900c0
@ -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
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -230,7 +230,7 @@ typedef struct {
|
||||
// timer
|
||||
struct timeval timestamp;
|
||||
#endif
|
||||
#ifdef EMBEDDED
|
||||
#ifdef HAVE_TICK
|
||||
uint32_t timestamp; // timeout in system ticks
|
||||
#endif
|
||||
|
||||
|
@ -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();
|
||||
|
Loading…
x
Reference in New Issue
Block a user