Microchip® Advanced Software Framework

btstack_run_loop.h File Reference
#include "btstack_config.h"
#include "btstack_linked_list.h"
#include <stdint.h>

Data Structures

struct  btstack_data_source
 
struct  btstack_run_loop
 
struct  btstack_timer_source
 

Typedefs

typedef struct btstack_data_source btstack_data_source_t
 
typedef struct btstack_run_loop btstack_run_loop_t
 
typedef struct btstack_timer_source btstack_timer_source_t
 

Enumerations

enum  btstack_data_source_callback_type_t {
  DATA_SOURCE_CALLBACK_POLL = 1 << 0,
  DATA_SOURCE_CALLBACK_READ = 1 << 1,
  DATA_SOURCE_CALLBACK_WRITE = 1 << 2
}
 Callback types for run loop data sources. More...
 

Functions

void btstack_run_loop_add_data_source (btstack_data_source_t *data_source)
 Add data source to run loop. More...
 
void btstack_run_loop_add_timer (btstack_timer_source_t *timer)
 Add timer source. More...
 
void btstack_run_loop_disable_data_source_callbacks (btstack_data_source_t *data_source, uint16_t callbacks)
 Enable callbacks for a data source. More...
 
void btstack_run_loop_enable_data_source_callbacks (btstack_data_source_t *data_source, uint16_t callbacks)
 Enable callbacks for a data source. More...
 
void btstack_run_loop_execute (void)
 Execute configured run loop. More...
 
int btstack_run_loop_get_data_source_fd (btstack_data_source_t *data_source)
 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 *data_source)
 Remove data source from run loop. More...
 
int btstack_run_loop_remove_timer (btstack_timer_source_t *timer)
 Remove timer source. More...
 
void btstack_run_loop_set_data_source_fd (btstack_data_source_t *data_source, int fd)
 Set data source file descriptor. More...
 
void btstack_run_loop_set_data_source_handler (btstack_data_source_t *data_source, 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 *ts, 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)
 

Callback types for run loop data sources.

Enumerator
DATA_SOURCE_CALLBACK_POLL 
DATA_SOURCE_CALLBACK_READ 
DATA_SOURCE_CALLBACK_WRITE 

void btstack_run_loop_add_data_source ( btstack_data_source_t ds)

Add data source to run loop.

Parameters
data_sourceto add

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 configured run loop.

This function does not return.

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.

Parameters
data_sourceto remove

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 data_source,
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  )