added setter for system ticks - useful on systems that already have a clock

This commit is contained in:
matthias.ringwald@gmail.com 2014-02-04 22:46:37 +00:00
parent 25c5e98538
commit f51189dbdd
2 changed files with 6 additions and 2 deletions

View File

@ -108,6 +108,8 @@ void run_loop_execute(void);
uint32_t embedded_ticks_for_ms(uint32_t time_in_ms); uint32_t embedded_ticks_for_ms(uint32_t time_in_ms);
// Queries the current time in ticks. // Queries the current time in ticks.
uint32_t embedded_get_ticks(void); uint32_t embedded_get_ticks(void);
// Allows to update BTstack system ticks based on another already existing clock
void embedded_set_ticks(uint32_t ticks);
#endif #endif
#ifdef EMBEDDED #ifdef EMBEDDED
// Sets an internal flag that is checked in the critical section // Sets an internal flag that is checked in the critical section
@ -115,8 +117,6 @@ uint32_t embedded_get_ticks(void);
// handler of a data source to signal the run loop that a new data // handler of a data source to signal the run loop that a new data
// is available. // is available.
void embedded_trigger(void); void embedded_trigger(void);
// execute run loop once for run_loop_embedded. pols all data sources and handles timers
void embedded_execute_once(void);
#endif #endif
#if defined __cplusplus #if defined __cplusplus
} }

View File

@ -194,6 +194,10 @@ uint32_t embedded_get_ticks(void){
return system_ticks; return system_ticks;
} }
void embedded_set_ticks(uint32_t ticks){
system_ticks = ticks;
}
uint32_t embedded_ticks_for_ms(uint32_t time_in_ms){ uint32_t embedded_ticks_for_ms(uint32_t time_in_ms){
return time_in_ms / hal_tick_get_tick_period_in_ms(); return time_in_ms / hal_tick_get_tick_period_in_ms();
} }