Microchip® Advanced Software Framework

btstack_run_loop.c File Reference
#include "btstack_run_loop.h"
#include <stdio.h>
#include <stdlib.h>
#include "btstack_debug.h"
#include "btstack_config.h"

Macros

#define __BTSTACK_FILE__   "btstack_run_loop.c"
 

Functions

void btstack_run_loop_add_data_source (btstack_data_source_t *ds)
 Add data_source to run_loop. More...
 
void btstack_run_loop_add_timer (btstack_timer_source_t *ts)
 Add timer to run_loop (keep list sorted) More...
 
static void btstack_run_loop_assert (void)
 
void btstack_run_loop_disable_data_source_callbacks (btstack_data_source_t *ds, uint16_t callbacks)
 Enable callbacks for a data source. More...
 
void btstack_run_loop_enable_data_source_callbacks (btstack_data_source_t *ds, uint16_t callbacks)
 Enable callbacks for a data source. More...
 
void btstack_run_loop_execute (void)
 Execute run_loop. More...
 
int btstack_run_loop_get_data_source_fd (btstack_data_source_t *ds)
 Get data source file descriptor. More...
 
uint32_t btstack_run_loop_get_time_ms (void)
 Get current time in ms. More...
 
void * btstack_run_loop_get_timer_context (btstack_timer_source_t *ts)
 Get context for this timer. More...
 
void btstack_run_loop_init (const btstack_run_loop_t *run_loop)
 Init main run loop. More...
 
int btstack_run_loop_remove_data_source (btstack_data_source_t *ds)
 Remove data_source from run loop. More...
 
int btstack_run_loop_remove_timer (btstack_timer_source_t *ts)
 Remove timer from run loop. More...
 
void btstack_run_loop_set_data_source_fd (btstack_data_source_t *ds, int fd)
 Set data source file descriptor. More...
 
void btstack_run_loop_set_data_source_handler (btstack_data_source_t *ds, void(*process)(btstack_data_source_t *_ds, btstack_data_source_callback_type_t callback_type))
 Set data source callback. More...
 
void btstack_run_loop_set_timer (btstack_timer_source_t *a, uint32_t timeout_in_ms)
 Set timer based on current time in milliseconds. More...
 
void btstack_run_loop_set_timer_context (btstack_timer_source_t *ts, void *context)
 Set context for this timer. More...
 
void btstack_run_loop_set_timer_handler (btstack_timer_source_t *ts, void(*process)(btstack_timer_source_t *_ts))
 Set callback that will be executed when timer expires. More...
 
void btstack_run_loop_timer_dump (void)
 

Variables

const btstack_run_loop_t btstack_run_loop_embedded
 
static const btstack_run_loop_tthe_run_loop = NULL
 

#define __BTSTACK_FILE__   "btstack_run_loop.c"

void btstack_run_loop_add_data_source ( btstack_data_source_t ds)

Add data_source to run_loop.

Add data source to run loop.

References btstack_run_loop::add_data_source, btstack_run_loop_assert(), and log_error.

Referenced by btstack_stdin_setup(), and btstack_uart_block_freertos_init().

void btstack_run_loop_disable_data_source_callbacks ( btstack_data_source_t data_source,
uint16_t  callbacks 
)

Enable callbacks for a data source.

Parameters
data_sourceto remove
callbacktypes to disable

References btstack_run_loop_assert(), btstack_run_loop::disable_data_source_callbacks, and log_error.

void btstack_run_loop_enable_data_source_callbacks ( btstack_data_source_t data_source,
uint16_t  callbacks 
)

Enable callbacks for a data source.

Parameters
data_sourceto remove
callbacktypes to enable

References btstack_run_loop_assert(), btstack_run_loop::enable_data_source_callbacks, and log_error.

Referenced by btstack_stdin_setup(), and btstack_uart_block_freertos_init().

void btstack_run_loop_execute ( void  )

Execute run_loop.

Execute configured run loop.

References btstack_run_loop_assert(), and btstack_run_loop::execute.

Referenced by bt_task().

int btstack_run_loop_get_data_source_fd ( btstack_data_source_t data_source)

Get data source file descriptor.

Parameters
data_source

References btstack_data_source::fd.

uint32_t btstack_run_loop_get_time_ms ( void  )

Get current time in ms.

Note
32-bit ms counter will overflow after approx. 52 days

References btstack_run_loop_assert(), and btstack_run_loop::get_time_ms.

Referenced by hci_transport_h5_block_received(), mdelay(), and printf_timestamp().

void* btstack_run_loop_get_timer_context ( btstack_timer_source_t ts)

Get context for this timer.

References btstack_timer_source::context.

Referenced by att_handle_value_indication_timeout(), and sm_timeout_handler().

void btstack_run_loop_init ( const btstack_run_loop_t run_loop)

Init main run loop.

Must be called before any other run loop call.

Use btstack_run_loop__get_instance() from btstack_run_loop_.h to get instance

References btstack_run_loop::init, and log_error.

Referenced by bt_task(), and main().

int btstack_run_loop_remove_data_source ( btstack_data_source_t ds)

Remove data_source from run loop.

Remove data source from run loop.

References btstack_run_loop_assert(), log_error, and btstack_run_loop::remove_data_source.

void btstack_run_loop_set_data_source_fd ( btstack_data_source_t data_source,
int  fd 
)

Set data source file descriptor.

Parameters
data_source
fdfile descriptor
Note
No effect if port doensn't have file descriptors

References btstack_data_source::fd.

void btstack_run_loop_set_data_source_handler ( btstack_data_source_t ds,
void(*)(btstack_data_source_t *_ds, btstack_data_source_callback_type_t callback_type)  process 
)

Set data source callback.

References btstack_data_source::process.

Referenced by btstack_stdin_setup(), and btstack_uart_block_freertos_init().

void btstack_run_loop_set_timer_context ( btstack_timer_source_t ts,
void *  context 
)

Set context for this timer.

References btstack_timer_source::context.

Referenced by create_connection_for_bd_addr_and_type(), and sm_timeout_start().

void btstack_run_loop_timer_dump ( void  )

const btstack_run_loop_t btstack_run_loop_embedded
const btstack_run_loop_t* the_run_loop = NULL
static