btstack/docs/manual/api_run_loop.tex

55 lines
1.9 KiB
TeX
Raw Normal View History

2014-11-06 14:09:12 +00:00
% !TEX root = btstack_gettingstarted.tex
2015-04-09 14:49:03 +02:00
\section{Run Loop}
2014-11-06 14:09:12 +00:00
\label{appendix:api_run_loop}
$ $
\begin{lstlisting}
// Set timer based on current time in milliseconds.
void run_loop_set_timer(timer_source_t *a, uint32_t timeout_in_ms);
// Set callback that will be executed when timer expires.
void run_loop_set_timer_handler(timer_source_t *ts, void (*process)(timer_source_t *_ts));
// Add/Remove timer source.
void run_loop_add_timer(timer_source_t *timer);
int run_loop_remove_timer(timer_source_t *timer);
// Init must be called before any other run_loop call.
// Use RUN_LOOP_EMBEDDED for embedded devices.
void run_loop_init(RUN_LOOP_TYPE type);
// Set data source callback.
void run_loop_set_data_source_handler(data_source_t *ds, int (*process)(data_source_t *_ds));
// Add/Remove data source.
void run_loop_add_data_source(data_source_t *dataSource);
int run_loop_remove_data_source(data_source_t *dataSource);
// Execute configured run loop. This function does not return.
void run_loop_execute(void);
2015-04-09 14:49:03 +02:00
// hack to fix HCI timer handling
#ifdef HAVE_TICK
// Sets how many miliseconds has one tick.
2014-11-06 14:09:12 +00:00
uint32_t embedded_ticks_for_ms(uint32_t time_in_ms);
// Queries the current time in ticks.
uint32_t embedded_get_ticks(void);
2015-04-09 14:49:03 +02:00
// Queries the current time in ms
uint32_t embedded_get_time_ms(void);
// Allows to update BTstack system ticks based on another already
// existing clock.
void embedded_set_ticks(uint32_t ticks);
#endif
#ifdef EMBEDDED
2014-11-06 14:09:12 +00:00
// Sets an internal flag that is checked in the critical section
2015-04-09 14:49:03 +02:00
// just before entering sleep mode. Has to be called by the interupt
// handler of a data source to signal the run loop that a new data
// is available.
void embedded_trigger(void);
// Execute run_loop once. It can be used to integrate BTstack's
// timer and data source processing into a foreign run runloop
// (it is not recommended).
void embedded_execute_once(void);
#endif
2014-11-06 14:09:12 +00:00
\end{lstlisting}
2015-04-09 14:49:03 +02:00
\pagebreak