esp32: drop single_threaded attribute from function names

This commit is contained in:
Matthias Ringwald 2017-05-05 11:00:12 +02:00
parent 00948339ed
commit 7d5f53998d
4 changed files with 72 additions and 70 deletions

View File

@ -36,7 +36,7 @@
*/
/*
* btstack_run_loop_freertos_single_threaded.c
* btstack_run_loop_freertos.c
*
* Run loop on dedicated thread on FreeRTOS
*/
@ -45,7 +45,7 @@
#include "btstack_linked_list.h"
#include "btstack_debug.h"
#include "btstack_run_loop_freertos_single_threaded.h"
#include "btstack_run_loop_freertos.h"
// #include "hal_time_ms.h"
uint32_t hal_time_ms(void);
@ -60,7 +60,7 @@ typedef struct function_call {
void * arg;
} function_call_t;
static const btstack_run_loop_t btstack_run_loop_freertos_single_threaded;
static const btstack_run_loop_t btstack_run_loop_freertos;
static QueueHandle_t btstack_run_loop_queue;
static EventGroupHandle_t btstack_run_loop_event_group;
@ -72,19 +72,19 @@ static EventGroupHandle_t btstack_run_loop_event_group;
static btstack_linked_list_t timers;
static btstack_linked_list_t data_sources;
static uint32_t btstack_run_loop_freertos_single_threaded_get_time_ms(void){
static uint32_t btstack_run_loop_freertos_get_time_ms(void){
return hal_time_ms();
}
// set timer
static void btstack_run_loop_freertos_single_threaded_set_timer(btstack_timer_source_t *ts, uint32_t timeout_in_ms){
ts->timeout = btstack_run_loop_freertos_single_threaded_get_time_ms() + timeout_in_ms + 1;
static void btstack_run_loop_freertos_set_timer(btstack_timer_source_t *ts, uint32_t timeout_in_ms){
ts->timeout = btstack_run_loop_freertos_get_time_ms() + timeout_in_ms + 1;
}
/**
* Add timer to run_loop (keep list sorted)
*/
static void btstack_run_loop_freertos_single_threaded_add_timer(btstack_timer_source_t *ts){
static void btstack_run_loop_freertos_add_timer(btstack_timer_source_t *ts){
btstack_linked_item_t *it;
for (it = (btstack_linked_item_t *) &timers; it->next ; it = it->next){
// don't add timer that's already in there
@ -103,11 +103,11 @@ static void btstack_run_loop_freertos_single_threaded_add_timer(btstack_timer_so
/**
* Remove timer from run loop
*/
static int btstack_run_loop_freertos_single_threaded_remove_timer(btstack_timer_source_t *ts){
static int btstack_run_loop_freertos_remove_timer(btstack_timer_source_t *ts){
return btstack_linked_list_remove(&timers, (btstack_linked_item_t *) ts);
}
static void btstack_run_loop_freertos_single_threaded_dump_timer(void){
static void btstack_run_loop_freertos_dump_timer(void){
#ifdef ENABLE_LOG_INFO
btstack_linked_item_t *it;
int i = 0;
@ -123,7 +123,7 @@ void btstack_run_loop_freertos_trigger(void){
xEventGroupSetBits(btstack_run_loop_event_group, EVENT_GROUP_FLAG_RUN_LOOP);
}
void btstack_run_loop_freertos_single_threaded_execute_code_on_main_thread(void (*fn)(void *arg), void * arg){
void btstack_run_loop_freertos_execute_code_on_main_thread(void (*fn)(void *arg), void * arg){
function_call_t message;
message.fn = fn;
message.arg = arg;
@ -139,7 +139,7 @@ void btstack_run_loop_freertos_trigger_from_isr(void){
xEventGroupSetBits(btstack_run_loop_event_group, EVENT_GROUP_FLAG_RUN_LOOP);
}
void btstack_run_loop_freertos_single_threaded_execute_code_on_main_thread_from_isr(void (*fn)(void *arg), void * arg){
void btstack_run_loop_freertos_execute_code_on_main_thread_from_isr(void (*fn)(void *arg), void * arg){
function_call_t message;
message.fn = fn;
message.arg = arg;
@ -152,7 +152,7 @@ void btstack_run_loop_freertos_single_threaded_execute_code_on_main_thread_from_
/**
* Execute run_loop
*/
static void btstack_run_loop_freertos_single_threaded_task(void *pvParameter){
static void btstack_run_loop_freertos_task(void *pvParameter){
UNUSED(pvParameter);
log_debug("RL: execute");
@ -184,7 +184,7 @@ static void btstack_run_loop_freertos_single_threaded_task(void *pvParameter){
log_debug("RL: portMAX_DELAY %u", portMAX_DELAY);
while (timers) {
btstack_timer_source_t * ts = (btstack_timer_source_t *) timers;
uint32_t now = btstack_run_loop_freertos_single_threaded_get_time_ms();
uint32_t now = btstack_run_loop_freertos_get_time_ms();
log_debug("RL: now %u, expires %u", now, ts->timeout);
if (ts->timeout > now){
timeout_ms = ts->timeout - now;
@ -202,29 +202,29 @@ static void btstack_run_loop_freertos_single_threaded_task(void *pvParameter){
}
}
static void btstack_run_loop_freertos_single_threaded_execute(void) {
static void btstack_run_loop_freertos_execute(void) {
// use dedicated task, might not be needed in all cases
xTaskCreate(&btstack_run_loop_freertos_single_threaded_task, "btstack_task", 3072, NULL, 5, NULL);
// btstack_run_loop_freertos_single_threaded_task(NULL);
xTaskCreate(&btstack_run_loop_freertos_task, "btstack_task", 3072, NULL, 5, NULL);
// btstack_run_loop_freertos_task(NULL);
}
static void btstack_run_loop_freertos_single_threaded_add_data_source(btstack_data_source_t *ds){
static void btstack_run_loop_freertos_add_data_source(btstack_data_source_t *ds){
btstack_linked_list_add(&data_sources, (btstack_linked_item_t *) ds);
}
static int btstack_run_loop_freertos_single_threaded_remove_data_source(btstack_data_source_t *ds){
static int btstack_run_loop_freertos_remove_data_source(btstack_data_source_t *ds){
return btstack_linked_list_remove(&data_sources, (btstack_linked_item_t *) ds);
}
static void btstack_run_loop_freertos_single_threaded_enable_data_source_callbacks(btstack_data_source_t * ds, uint16_t callback_types){
static void btstack_run_loop_freertos_enable_data_source_callbacks(btstack_data_source_t * ds, uint16_t callback_types){
ds->flags |= callback_types;
}
static void btstack_run_loop_freertos_single_threaded_disable_data_source_callbacks(btstack_data_source_t * ds, uint16_t callback_types){
static void btstack_run_loop_freertos_disable_data_source_callbacks(btstack_data_source_t * ds, uint16_t callback_types){
ds->flags &= ~callback_types;
}
static void btstack_run_loop_freertos_single_threaded_init(void){
static void btstack_run_loop_freertos_init(void){
timers = NULL;
// queue to receive events: up to 2 calls from transport, up to 3 for app
@ -239,20 +239,20 @@ static void btstack_run_loop_freertos_single_threaded_init(void){
/**
* @brief Provide btstack_run_loop_posix instance for use with btstack_run_loop_init
*/
const btstack_run_loop_t * btstack_run_loop_freertos_single_threaded_get_instance(void){
return &btstack_run_loop_freertos_single_threaded;
const btstack_run_loop_t * btstack_run_loop_freertos_get_instance(void){
return &btstack_run_loop_freertos;
}
static const btstack_run_loop_t btstack_run_loop_freertos_single_threaded = {
&btstack_run_loop_freertos_single_threaded_init,
&btstack_run_loop_freertos_single_threaded_add_data_source,
&btstack_run_loop_freertos_single_threaded_remove_data_source,
&btstack_run_loop_freertos_single_threaded_enable_data_source_callbacks,
&btstack_run_loop_freertos_single_threaded_disable_data_source_callbacks,
&btstack_run_loop_freertos_single_threaded_set_timer,
&btstack_run_loop_freertos_single_threaded_add_timer,
&btstack_run_loop_freertos_single_threaded_remove_timer,
&btstack_run_loop_freertos_single_threaded_execute,
&btstack_run_loop_freertos_single_threaded_dump_timer,
&btstack_run_loop_freertos_single_threaded_get_time_ms,
static const btstack_run_loop_t btstack_run_loop_freertos = {
&btstack_run_loop_freertos_init,
&btstack_run_loop_freertos_add_data_source,
&btstack_run_loop_freertos_remove_data_source,
&btstack_run_loop_freertos_enable_data_source_callbacks,
&btstack_run_loop_freertos_disable_data_source_callbacks,
&btstack_run_loop_freertos_set_timer,
&btstack_run_loop_freertos_add_timer,
&btstack_run_loop_freertos_remove_timer,
&btstack_run_loop_freertos_execute,
&btstack_run_loop_freertos_dump_timer,
&btstack_run_loop_freertos_get_time_ms,
};

View File

@ -36,13 +36,13 @@
*/
/*
* btstack_run_loop_wiced.h
* btstack_run_loop_freertos.h
*
* Functions relevant for BTstack WICED port
*/
#ifndef __BTSTACK_RUN_LOOP_FREERTOS_SINGLE_THREADED_H
#define __BTSTACK_RUN_LOOP_FREERTOS_SINGLE_THREADED_H
#ifndef __BTSTACK_RUN_LOOP_FREERTOS_H
#define __BTSTACK_RUN_LOOP_FREERTOS_H
#include "btstack_config.h"
#include "btstack_run_loop.h"
@ -52,27 +52,29 @@ extern "C" {
#endif
/**
* @brief Provide btstack_run_loop_freertos_single_threaded instance for use with btstack_run_loop_init
* @brief Provide btstack_run_loop_freertos instance for use with btstack_run_loop_init
*/
const btstack_run_loop_t * btstack_run_loop_freertos_single_threaded_get_instance(void);
const btstack_run_loop_t * btstack_run_loop_freertos_get_instance(void);
/*
* @brief Execute code on BTstack run loop. Can be used to control BTstack from a different thread
*/
void btstack_run_loop_freertos_single_threaded_execute_code_on_main_thread(void (*fn)(void *arg), void * arg);
void btstack_run_loop_freertos_execute_code_on_main_thread(void (*fn)(void *arg), void * arg);
/*
* @brief Execute code on BTstack run loop. Can be used to control BTstack from an ISR
*/
void btstack_run_loop_freertos_single_threaded_execute_code_on_main_thread_from_isr(void (*fn)(void *arg), void * arg);
void btstack_run_loop_freertos_execute_code_on_main_thread_from_isr(void (*fn)(void *arg), void * arg);
/**
* @brief Triggers processing of data sources from thread context. Has to be called after enabling a poll data source to wake-pup run loop.
* @brief Triggers processing of data sources from thread context.
* Has to be called after enabling a poll data source to wake-pup run loop.
*/
void btstack_run_loop_freertos_trigger(void);
/**
* @brief Triggers processing of data sources from an ISR. Has to be called after enabling a poll data source to wake-pup run loop.
* @brief Triggers processing of data sources from an ISR.
* Has to be called after enabling a poll data source to wake-pup run loop.
*/
void btstack_run_loop_freertos_trigger_from_isr(void);

View File

@ -35,7 +35,7 @@
*
*/
#define __BTSTACK_FILE__ "btstack_uart_block_freertos_single_threaded.c"
#define __BTSTACK_FILE__ "btstack_uart_block_freertos.c"
/*
* btstack_uart_block_freertos.c
@ -47,7 +47,7 @@
#include "btstack_debug.h"
#include "btstack_uart_block.h"
#include "btstack_run_loop_freertos_single_threaded.h"
#include "btstack_run_loop_freertos.h"
#include "hal_uart_dma.h"
// uart config
@ -63,17 +63,17 @@ static void (*block_received)(void);
static int send_complete;
static int receive_complete;
static void btstack_uart_block_received_isr(void){
static void btstack_uart_block_freertos_received_isr(void){
receive_complete = 1;
btstack_run_loop_freertos_trigger_from_isr();
}
static void btstack_uart_block_sent_isr(void){
static void btstack_uart_block_freertos_sent_isr(void){
send_complete = 1;
btstack_run_loop_freertos_trigger_from_isr();
}
static void btstack_uart_block_process(btstack_data_source_t *ds, btstack_data_source_callback_type_t callback_type) {
static void btstack_uart_block_freertos_process(btstack_data_source_t *ds, btstack_data_source_callback_type_t callback_type) {
switch (callback_type){
case DATA_SOURCE_CALLBACK_POLL:
if (send_complete){
@ -91,63 +91,63 @@ static void btstack_uart_block_process(btstack_data_source_t *ds, btstack_data_s
}
//
static int btstack_uart_block_init(const btstack_uart_config_t * config){
static int btstack_uart_block_freertos_init(const btstack_uart_config_t * config){
uart_config = config;
hal_uart_dma_set_block_received(&btstack_uart_block_received_isr);
hal_uart_dma_set_block_sent(&btstack_uart_block_sent_isr);
hal_uart_dma_set_block_received(&btstack_uart_block_freertos_received_isr);
hal_uart_dma_set_block_sent(&btstack_uart_block_freertos_sent_isr);
// set up polling data_source
btstack_run_loop_set_data_source_handler(&transport_data_source, &btstack_uart_block_process);
btstack_run_loop_set_data_source_handler(&transport_data_source, &btstack_uart_block_freertos_process);
btstack_run_loop_enable_data_source_callbacks(&transport_data_source, DATA_SOURCE_CALLBACK_POLL);
btstack_run_loop_add_data_source(&transport_data_source);
return 0;
}
static int btstack_uart_block_open(void){
static int btstack_uart_block_freertos_open(void){
hal_uart_dma_init();
hal_uart_dma_set_baud(uart_config->baudrate);
return 0;
}
static int btstack_uart_block_close(void){
static int btstack_uart_block_freertos_close(void){
// close device
// ...
return 0;
}
static void btstack_uart_block_set_block_received( void (*block_handler)(void)){
static void btstack_uart_block_freertos_set_block_received( void (*block_handler)(void)){
block_received = block_handler;
}
static void btstack_uart_block_set_block_sent( void (*block_handler)(void)){
static void btstack_uart_block_freertos_set_block_sent( void (*block_handler)(void)){
block_sent = block_handler;
}
static int btstack_uart_block_set_parity(int parity){
static int btstack_uart_block_freertos_set_parity(int parity){
return 0;
}
// static void btstack_uart_block_set_sleep(uint8_t sleep){
// }
// static void btstack_uart_embedded_set_csr_irq_handler( void (*csr_irq_handler)(void)){
// static void btstack_uart_block_freertos_set_csr_irq_handler( void (*csr_irq_handler)(void)){
// }
static const btstack_uart_block_t btstack_uart_embedded = {
/* int (*init)(hci_transport_config_uart_t * config); */ &btstack_uart_block_init,
/* int (*open)(void); */ &btstack_uart_block_open,
/* int (*close)(void); */ &btstack_uart_block_close,
/* void (*set_block_received)(void (*handler)(void)); */ &btstack_uart_block_set_block_received,
/* void (*set_block_sent)(void (*handler)(void)); */ &btstack_uart_block_set_block_sent,
static const btstack_uart_block_t btstack_uart_block_freertos = {
/* int (*init)(hci_transport_config_uart_t * config); */ &btstack_uart_block_freertos_init,
/* int (*open)(void); */ &btstack_uart_block_freertos_open,
/* int (*close)(void); */ &btstack_uart_block_freertos_close,
/* void (*set_block_received)(void (*handler)(void)); */ &btstack_uart_block_freertos_set_block_received,
/* void (*set_block_sent)(void (*handler)(void)); */ &btstack_uart_block_freertos_set_block_sent,
/* int (*set_baudrate)(uint32_t baudrate); */ &hal_uart_dma_set_baud,
/* int (*set_parity)(int parity); */ &btstack_uart_block_set_parity,
/* int (*set_parity)(int parity); */ &btstack_uart_block_freertos_set_parity,
/* void (*receive_block)(uint8_t *buffer, uint16_t len); */ &hal_uart_dma_receive_block,
/* void (*send_block)(const uint8_t *buffer, uint16_t length); */ &hal_uart_dma_send_block,
/* int (*get_supported_sleep_modes); */ NULL,
/* void (*set_sleep)(btstack_uart_sleep_mode_t sleep_mode); */ NULL
};
const btstack_uart_block_t * btstack_uart_block_freertos_single_threaded_instance(void){
return &btstack_uart_embedded;
const btstack_uart_block_t * btstack_uart_block_freertos_instance(void){
return &btstack_uart_block_freertos;
}

View File

@ -46,7 +46,7 @@
#include "btstack_event.h"
#include "btstack_memory.h"
#include "btstack_run_loop.h"
#include "btstack_run_loop_freertos_single_threaded.h"
#include "btstack_run_loop_freertos.h"
#include "btstack_ring_buffer.h"
//#include "classic/btstack_link_key_db.h"
#include "hci.h"
@ -306,7 +306,7 @@ static void btstack_setup(void){
/// GET STARTED with BTstack ///
btstack_memory_init();
btstack_run_loop_init(btstack_run_loop_freertos_single_threaded_get_instance());
btstack_run_loop_init(btstack_run_loop_freertos_get_instance());
// init HCI
hci_init(transport_get_instance(), NULL);