FreeRTOS: btstack_run_loop_freertos_trigger_exit allows to request run loop exit

This commit is contained in:
Matthias Ringwald 2020-05-15 16:46:29 +02:00
parent 3f054530e4
commit 9dc32eb425
3 changed files with 17 additions and 1 deletions

View File

@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- example/le_mitm: MITM implementation that forwards ATT PDUs and allows for pairing
- GAP: gap_set_security_level sets required security level for incoming and outgoing connections
- cc256x: allow to specify power vector for each modulation type
- FreeRTOS: btstack_run_loop_freertos_trigger_exit allows to request run loop exit
### Changed
- L2CAP ERTM: send extended features request only once per HCI connection

View File

@ -105,6 +105,7 @@ static EventGroupHandle_t btstack_run_loop_event_group;
// the run loop
static btstack_linked_list_t timers;
static btstack_linked_list_t data_sources;
static bool run_loop_exit_requested;
static uint32_t btstack_run_loop_freertos_get_time_ms(void){
return hal_time_ms();
@ -207,12 +208,18 @@ void btstack_run_loop_freertos_execute_code_on_main_thread_from_isr(void (*fn)(v
}
#endif
void btstack_run_loop_freertos_trigger_exit(void){
run_loop_exit_requested = true;
}
/**
* Execute run_loop
*/
static void btstack_run_loop_freertos_execute(void) {
log_debug("RL: execute");
run_loop_exit_requested = false;
while (true) {
// process data sources
@ -253,6 +260,9 @@ static void btstack_run_loop_freertos_execute(void) {
ts->process(ts);
}
// exit triggered by btstack_run_loop_freertos_trigger_exit (from data source, timer, run on main thread)
if (run_loop_exit_requested) break;
// wait for timeout or event group/task notification
log_debug("RL: wait with timeout %u", (int) timeout_ms);
#ifdef HAVE_FREERTOS_TASK_NOTIFICATIONS

View File

@ -76,7 +76,12 @@ 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.
*/
void btstack_run_loop_freertos_trigger_from_isr(void);
void btstack_run_loop_freertos_trigger_from_isr(void);
/**
* @brief Triggers exit of run loop from BTstack main thread, causes call to btstack_run_loop_execute to return
*/
void btstack_run_loop_freertos_trigger_exit(void);
/* API_END */