mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-02-20 18:40:31 +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
|
#ifdef HAVE_TIME
|
||||||
struct timeval timeout; // <-- next timeout
|
struct timeval timeout; // <-- next timeout
|
||||||
#endif
|
#endif
|
||||||
#ifdef EMBEDDED
|
#ifdef HAVE_TICK
|
||||||
uint32_t timeout; // timeout in system ticks
|
uint32_t timeout; // timeout in system ticks
|
||||||
#endif
|
#endif
|
||||||
void (*process)(struct timer *ts); // <-- do processing
|
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);
|
void run_loop_execute(void);
|
||||||
|
|
||||||
// hack to fix HCI timer handling
|
// hack to fix HCI timer handling
|
||||||
#ifdef EMBEDDED
|
#ifdef HAVE_TICK
|
||||||
uint32_t embedded_get_ticks(void);
|
uint32_t embedded_get_ticks(void);
|
||||||
uint32_t embedded_ticks_for_ms(uint32_t time_in_ms);
|
uint32_t embedded_ticks_for_ms(uint32_t time_in_ms);
|
||||||
#endif
|
#endif
|
||||||
|
@ -86,7 +86,7 @@ static void hci_connection_timeout_handler(timer_source_t *timer){
|
|||||||
hci_emit_l2cap_check_timeout(connection);
|
hci_emit_l2cap_check_timeout(connection);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef EMBEDDED
|
#ifdef HAVE_TICK
|
||||||
if (embedded_get_ticks() > connection->timestamp + embedded_ticks_for_ms(HCI_CONNECTION_TIMEOUT_MS)){
|
if (embedded_get_ticks() > connection->timestamp + embedded_ticks_for_ms(HCI_CONNECTION_TIMEOUT_MS)){
|
||||||
// connections might be timed out
|
// connections might be timed out
|
||||||
hci_emit_l2cap_check_timeout(connection);
|
hci_emit_l2cap_check_timeout(connection);
|
||||||
@ -100,7 +100,7 @@ static void hci_connection_timestamp(hci_connection_t *connection){
|
|||||||
#ifdef HAVE_TIME
|
#ifdef HAVE_TIME
|
||||||
gettimeofday(&connection->timestamp, NULL);
|
gettimeofday(&connection->timestamp, NULL);
|
||||||
#endif
|
#endif
|
||||||
#ifdef EMBEDDED
|
#ifdef HAVE_TICK
|
||||||
connection->timestamp = embedded_get_ticks();
|
connection->timestamp = embedded_get_ticks();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -230,7 +230,7 @@ typedef struct {
|
|||||||
// timer
|
// timer
|
||||||
struct timeval timestamp;
|
struct timeval timestamp;
|
||||||
#endif
|
#endif
|
||||||
#ifdef EMBEDDED
|
#ifdef HAVE_TICK
|
||||||
uint32_t timestamp; // timeout in system ticks
|
uint32_t timestamp; // timeout in system ticks
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@
|
|||||||
// the run loop
|
// the run loop
|
||||||
static linked_list_t data_sources;
|
static linked_list_t data_sources;
|
||||||
|
|
||||||
#ifdef EMBEDDED
|
#ifdef HAVE_TICK
|
||||||
static linked_list_t timers;
|
static linked_list_t timers;
|
||||||
static uint32_t system_ticks;
|
static uint32_t system_ticks;
|
||||||
#endif
|
#endif
|
||||||
@ -75,7 +75,7 @@ int embedded_remove_data_source(data_source_t *ds){
|
|||||||
* Add timer to run_loop (keep list sorted)
|
* Add timer to run_loop (keep list sorted)
|
||||||
*/
|
*/
|
||||||
void embedded_add_timer(timer_source_t *ts){
|
void embedded_add_timer(timer_source_t *ts){
|
||||||
#ifdef EMBEDDED
|
#ifdef HAVE_TICK
|
||||||
linked_item_t *it;
|
linked_item_t *it;
|
||||||
for (it = (linked_item_t *) &timers; it->next ; it = it->next){
|
for (it = (linked_item_t *) &timers; it->next ; it = it->next){
|
||||||
if (ts->timeout < ((timer_source_t *) it->next)->timeout) {
|
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
|
* Remove timer from run loop
|
||||||
*/
|
*/
|
||||||
int embedded_remove_timer(timer_source_t *ts){
|
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);
|
// 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);
|
return linked_list_remove(&timers, (linked_item_t *) ts);
|
||||||
#else
|
#else
|
||||||
@ -127,7 +127,7 @@ void embedded_execute() {
|
|||||||
ds->process(ds);
|
ds->process(ds);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef EMBEDDED
|
#ifdef HAVE_TICK
|
||||||
// process timers
|
// process timers
|
||||||
while (timers) {
|
while (timers) {
|
||||||
timer_source_t *ts = (timer_source_t *) 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){
|
static void embedded_tick_handler(void){
|
||||||
system_ticks++;
|
system_ticks++;
|
||||||
}
|
}
|
||||||
@ -165,7 +165,7 @@ void embedded_init(){
|
|||||||
|
|
||||||
data_sources = NULL;
|
data_sources = NULL;
|
||||||
|
|
||||||
#ifdef EMBEDDED
|
#ifdef HAVE_TICK
|
||||||
timers = NULL;
|
timers = NULL;
|
||||||
system_ticks = 0;
|
system_ticks = 0;
|
||||||
hal_tick_init();
|
hal_tick_init();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user