btstack/docs/manual/api_run_loop.tex
Milanka Ringwald 1a05cc744e added apis
2015-04-09 17:11:48 +02:00

74 lines
2.1 KiB
TeX

% !TEX root = btstack_gettingstarted.tex
\section{Run Loop API}
\label{appendix:api_run_loop}
$ $
\begin{lstlisting}
/**
* @brief Set timer based on current time in milliseconds.
*/
void run_loop_set_timer(timer_source_t *a, uint32_t timeout_in_ms);
/**
* @brief 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));
/**
* @brief Add/Remove timer source.
*/
void run_loop_add_timer(timer_source_t *timer);
int run_loop_remove_timer(timer_source_t *timer);
/**
* @brief 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);
/**
* @brief Set data source callback.
*/
void run_loop_set_data_source_handler(data_source_t *ds, int (*process)(data_source_t *_ds));
/**
* @brief Add/Remove data source.
*/
void run_loop_add_data_source(data_source_t *dataSource);
int run_loop_remove_data_source(data_source_t *dataSource);
/**
* @brief Execute configured run loop. This function does not return.
*/
void run_loop_execute(void);
// hack to fix HCI timer handling
#ifdef HAVE_TICK
/**
* @brief Sets how many milliseconds has one tick.
*/
uint32_t embedded_ticks_for_ms(uint32_t time_in_ms);
/**
* @brief Queries the current time in ticks.
*/
uint32_t embedded_get_ticks(void);
/**
* @brief Queries the current time in ms
*/
uint32_t embedded_get_time_ms(void);
/**
* @brief Allows to update BTstack system ticks based on another already existing clock.
*/
void embedded_set_ticks(uint32_t ticks);
#endif
#ifdef EMBEDDED
/**
* @brief Sets an internal flag that is checked in the critical section just before entering sleep mode. Has to be called by the interrupt handler of a data source to signal the run loop that a new data is available.
*/
void embedded_trigger(void);
/**
* @brief Execute run_loop once. It can be used to integrate BTstack's timer and data source processing into a foreign run loop (it is not recommended).
*/
void embedded_execute_once(void);
#endif
\end{lstlisting}
\pagebreak