mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
change(esp_event): reformat files with astyle
This commit is contained in:
parent
389cf54d52
commit
417de470ec
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2018-2022 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2018-2024 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
@ -15,14 +15,14 @@ static esp_event_loop_handle_t s_default_loop = NULL;
|
|||||||
/* ---------------------------- Public API ---------------------------------- */
|
/* ---------------------------- Public API ---------------------------------- */
|
||||||
|
|
||||||
esp_err_t esp_event_handler_register(esp_event_base_t event_base, int32_t event_id,
|
esp_err_t esp_event_handler_register(esp_event_base_t event_base, int32_t event_id,
|
||||||
esp_event_handler_t event_handler, void* event_handler_arg)
|
esp_event_handler_t event_handler, void* event_handler_arg)
|
||||||
{
|
{
|
||||||
if (s_default_loop == NULL) {
|
if (s_default_loop == NULL) {
|
||||||
return ESP_ERR_INVALID_STATE;
|
return ESP_ERR_INVALID_STATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return esp_event_handler_register_with(s_default_loop, event_base, event_id,
|
return esp_event_handler_register_with(s_default_loop, event_base, event_id,
|
||||||
event_handler, event_handler_arg);
|
event_handler, event_handler_arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
esp_err_t esp_event_handler_instance_register(esp_event_base_t event_base,
|
esp_err_t esp_event_handler_instance_register(esp_event_base_t event_base,
|
||||||
@ -44,14 +44,14 @@ esp_err_t esp_event_handler_instance_register(esp_event_base_t event_base,
|
|||||||
}
|
}
|
||||||
|
|
||||||
esp_err_t esp_event_handler_unregister(esp_event_base_t event_base, int32_t event_id,
|
esp_err_t esp_event_handler_unregister(esp_event_base_t event_base, int32_t event_id,
|
||||||
esp_event_handler_t event_handler)
|
esp_event_handler_t event_handler)
|
||||||
{
|
{
|
||||||
if (s_default_loop == NULL) {
|
if (s_default_loop == NULL) {
|
||||||
return ESP_ERR_INVALID_STATE;
|
return ESP_ERR_INVALID_STATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return esp_event_handler_unregister_with(s_default_loop, event_base, event_id,
|
return esp_event_handler_unregister_with(s_default_loop, event_base, event_id,
|
||||||
event_handler);
|
event_handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
esp_err_t esp_event_handler_instance_unregister(esp_event_base_t event_base,
|
esp_err_t esp_event_handler_instance_unregister(esp_event_base_t event_base,
|
||||||
@ -66,31 +66,29 @@ esp_err_t esp_event_handler_instance_unregister(esp_event_base_t event_base,
|
|||||||
}
|
}
|
||||||
|
|
||||||
esp_err_t esp_event_post(esp_event_base_t event_base, int32_t event_id,
|
esp_err_t esp_event_post(esp_event_base_t event_base, int32_t event_id,
|
||||||
const void* event_data, size_t event_data_size, TickType_t ticks_to_wait)
|
const void* event_data, size_t event_data_size, TickType_t ticks_to_wait)
|
||||||
{
|
{
|
||||||
if (s_default_loop == NULL) {
|
if (s_default_loop == NULL) {
|
||||||
return ESP_ERR_INVALID_STATE;
|
return ESP_ERR_INVALID_STATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return esp_event_post_to(s_default_loop, event_base, event_id,
|
return esp_event_post_to(s_default_loop, event_base, event_id,
|
||||||
event_data, event_data_size, ticks_to_wait);
|
event_data, event_data_size, ticks_to_wait);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if CONFIG_ESP_EVENT_POST_FROM_ISR
|
#if CONFIG_ESP_EVENT_POST_FROM_ISR
|
||||||
esp_err_t esp_event_isr_post(esp_event_base_t event_base, int32_t event_id,
|
esp_err_t esp_event_isr_post(esp_event_base_t event_base, int32_t event_id,
|
||||||
const void* event_data, size_t event_data_size, BaseType_t* task_unblocked)
|
const void* event_data, size_t event_data_size, BaseType_t* task_unblocked)
|
||||||
{
|
{
|
||||||
if (s_default_loop == NULL) {
|
if (s_default_loop == NULL) {
|
||||||
return ESP_ERR_INVALID_STATE;
|
return ESP_ERR_INVALID_STATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return esp_event_isr_post_to(s_default_loop, event_base, event_id,
|
return esp_event_isr_post_to(s_default_loop, event_base, event_id,
|
||||||
event_data, event_data_size, task_unblocked);
|
event_data, event_data_size, task_unblocked);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
esp_err_t esp_event_loop_create_default(void)
|
esp_err_t esp_event_loop_create_default(void)
|
||||||
{
|
{
|
||||||
if (s_default_loop) {
|
if (s_default_loop) {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2018-2023 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2018-2024 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
@ -24,7 +24,7 @@
|
|||||||
#ifdef CONFIG_ESP_EVENT_LOOP_PROFILING
|
#ifdef CONFIG_ESP_EVENT_LOOP_PROFILING
|
||||||
// LOOP @<address, name> rx:<recieved events no.> dr:<dropped events no.>
|
// LOOP @<address, name> rx:<recieved events no.> dr:<dropped events no.>
|
||||||
#define LOOP_DUMP_FORMAT "LOOP @%p,%s rx:%" PRIu32 " dr:%" PRIu32 "\n"
|
#define LOOP_DUMP_FORMAT "LOOP @%p,%s rx:%" PRIu32 " dr:%" PRIu32 "\n"
|
||||||
// handler @<address> ev:<base, id> inv:<times invoked> time:<runtime>
|
// handler @<address> ev:<base, id> inv:<times invoked> time:<runtime>
|
||||||
#define HANDLER_DUMP_FORMAT " HANDLER @%p ev:%s,%s inv:%" PRIu32 " time:%lld us\n"
|
#define HANDLER_DUMP_FORMAT " HANDLER @%p ev:%s,%s inv:%" PRIu32 " time:%lld us\n"
|
||||||
|
|
||||||
#define PRINT_DUMP_INFO(dst, sz, ...) do { \
|
#define PRINT_DUMP_INFO(dst, sz, ...) do { \
|
||||||
@ -41,17 +41,15 @@ static const char* esp_event_any_base = "any";
|
|||||||
|
|
||||||
#ifdef CONFIG_ESP_EVENT_LOOP_PROFILING
|
#ifdef CONFIG_ESP_EVENT_LOOP_PROFILING
|
||||||
static SLIST_HEAD(esp_event_loop_instance_list_t, esp_event_loop_instance) s_event_loops =
|
static SLIST_HEAD(esp_event_loop_instance_list_t, esp_event_loop_instance) s_event_loops =
|
||||||
SLIST_HEAD_INITIALIZER(s_event_loops);
|
SLIST_HEAD_INITIALIZER(s_event_loops);
|
||||||
|
|
||||||
static portMUX_TYPE s_event_loops_spinlock = portMUX_INITIALIZER_UNLOCKED;
|
static portMUX_TYPE s_event_loops_spinlock = portMUX_INITIALIZER_UNLOCKED;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* ------------------------- Static Functions ------------------------------- */
|
/* ------------------------- Static Functions ------------------------------- */
|
||||||
|
|
||||||
#ifdef CONFIG_ESP_EVENT_LOOP_PROFILING
|
#ifdef CONFIG_ESP_EVENT_LOOP_PROFILING
|
||||||
|
|
||||||
|
|
||||||
static int esp_event_dump_prepare(void)
|
static int esp_event_dump_prepare(void)
|
||||||
{
|
{
|
||||||
esp_event_loop_instance_t* loop_it;
|
esp_event_loop_instance_t* loop_it;
|
||||||
@ -90,7 +88,7 @@ static int esp_event_dump_prepare(void)
|
|||||||
// Reserve slightly more memory than computed
|
// Reserve slightly more memory than computed
|
||||||
int allowance = 3;
|
int allowance = 3;
|
||||||
int size = (((loops + allowance) * (sizeof(LOOP_DUMP_FORMAT) + 10 + 20 + 2 * 11)) +
|
int size = (((loops + allowance) * (sizeof(LOOP_DUMP_FORMAT) + 10 + 20 + 2 * 11)) +
|
||||||
((handlers + allowance) * (sizeof(HANDLER_DUMP_FORMAT) + 10 + 2 * 20 + 11 + 20)));
|
((handlers + allowance) * (sizeof(HANDLER_DUMP_FORMAT) + 10 + 2 * 20 + 11 + 20)));
|
||||||
|
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
@ -103,7 +101,7 @@ static void esp_event_loop_run_task(void* args)
|
|||||||
|
|
||||||
ESP_LOGD(TAG, "running task for loop %p", event_loop);
|
ESP_LOGD(TAG, "running task for loop %p", event_loop);
|
||||||
|
|
||||||
while(1) {
|
while (1) {
|
||||||
err = esp_event_loop_run(event_loop, portMAX_DELAY);
|
err = esp_event_loop_run(event_loop, portMAX_DELAY);
|
||||||
if (err != ESP_OK) {
|
if (err != ESP_OK) {
|
||||||
break;
|
break;
|
||||||
@ -151,7 +149,7 @@ static void handler_execute(esp_event_loop_instance_t* loop, esp_event_handler_n
|
|||||||
esp_event_handler_node_t* handler_node;
|
esp_event_handler_node_t* handler_node;
|
||||||
SLIST_FOREACH(loop_node, &(loop->loop_nodes), next) {
|
SLIST_FOREACH(loop_node, &(loop->loop_nodes), next) {
|
||||||
SLIST_FOREACH(handler_node, &(loop_node->handlers), next) {
|
SLIST_FOREACH(handler_node, &(loop_node->handlers), next) {
|
||||||
if(handler_node == handler) {
|
if (handler_node == handler) {
|
||||||
handler->invoked++;
|
handler->invoked++;
|
||||||
handler->time += diff;
|
handler->time += diff;
|
||||||
}
|
}
|
||||||
@ -166,7 +164,9 @@ static esp_err_t handler_instances_add(esp_event_handler_nodes_t* handlers, esp_
|
|||||||
{
|
{
|
||||||
esp_event_handler_node_t *handler_instance = calloc(1, sizeof(*handler_instance));
|
esp_event_handler_node_t *handler_instance = calloc(1, sizeof(*handler_instance));
|
||||||
|
|
||||||
if (!handler_instance) return ESP_ERR_NO_MEM;
|
if (!handler_instance) {
|
||||||
|
return ESP_ERR_NO_MEM;
|
||||||
|
}
|
||||||
|
|
||||||
esp_event_handler_instance_context_t *context = calloc(1, sizeof(*context));
|
esp_event_handler_instance_context_t *context = calloc(1, sizeof(*context));
|
||||||
|
|
||||||
@ -181,13 +181,12 @@ static esp_err_t handler_instances_add(esp_event_handler_nodes_t* handlers, esp_
|
|||||||
|
|
||||||
if (SLIST_EMPTY(handlers)) {
|
if (SLIST_EMPTY(handlers)) {
|
||||||
SLIST_INSERT_HEAD(handlers, handler_instance, next);
|
SLIST_INSERT_HEAD(handlers, handler_instance, next);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
esp_event_handler_node_t *it = NULL, *last = NULL;
|
esp_event_handler_node_t *it = NULL, *last = NULL;
|
||||||
|
|
||||||
SLIST_FOREACH(it, handlers, next) {
|
SLIST_FOREACH(it, handlers, next) {
|
||||||
if (legacy) {
|
if (legacy) {
|
||||||
if(event_handler == it->handler_ctx->handler) {
|
if (event_handler == it->handler_ctx->handler) {
|
||||||
it->handler_ctx->arg = event_handler_arg;
|
it->handler_ctx->arg = event_handler_arg;
|
||||||
ESP_LOGW(TAG, "handler already registered, overwriting");
|
ESP_LOGW(TAG, "handler already registered, overwriting");
|
||||||
free(handler_instance);
|
free(handler_instance);
|
||||||
@ -211,16 +210,15 @@ static esp_err_t handler_instances_add(esp_event_handler_nodes_t* handlers, esp_
|
|||||||
}
|
}
|
||||||
|
|
||||||
static esp_err_t base_node_add_handler(esp_event_base_node_t* base_node,
|
static esp_err_t base_node_add_handler(esp_event_base_node_t* base_node,
|
||||||
int32_t id,
|
int32_t id,
|
||||||
esp_event_handler_t event_handler,
|
esp_event_handler_t event_handler,
|
||||||
void *event_handler_arg,
|
void *event_handler_arg,
|
||||||
esp_event_handler_instance_context_t **handler_ctx,
|
esp_event_handler_instance_context_t **handler_ctx,
|
||||||
bool legacy)
|
bool legacy)
|
||||||
{
|
{
|
||||||
if (id == ESP_EVENT_ANY_ID) {
|
if (id == ESP_EVENT_ANY_ID) {
|
||||||
return handler_instances_add(&(base_node->handlers), event_handler, event_handler_arg, handler_ctx, legacy);
|
return handler_instances_add(&(base_node->handlers), event_handler, event_handler_arg, handler_ctx, legacy);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
esp_err_t err = ESP_OK;
|
esp_err_t err = ESP_OK;
|
||||||
esp_event_id_node_t *it = NULL, *id_node = NULL, *last_id_node = NULL;
|
esp_event_id_node_t *it = NULL, *id_node = NULL, *last_id_node = NULL;
|
||||||
|
|
||||||
@ -248,8 +246,7 @@ static esp_err_t base_node_add_handler(esp_event_base_node_t* base_node,
|
|||||||
if (err == ESP_OK) {
|
if (err == ESP_OK) {
|
||||||
if (!last_id_node) {
|
if (!last_id_node) {
|
||||||
SLIST_INSERT_HEAD(&(base_node->id_nodes), id_node, next);
|
SLIST_INSERT_HEAD(&(base_node->id_nodes), id_node, next);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
SLIST_INSERT_AFTER(last_id_node, id_node, next);
|
SLIST_INSERT_AFTER(last_id_node, id_node, next);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -257,25 +254,23 @@ static esp_err_t base_node_add_handler(esp_event_base_node_t* base_node,
|
|||||||
}
|
}
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return handler_instances_add(&(id_node->handlers), event_handler, event_handler_arg, handler_ctx, legacy);
|
return handler_instances_add(&(id_node->handlers), event_handler, event_handler_arg, handler_ctx, legacy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static esp_err_t loop_node_add_handler(esp_event_loop_node_t* loop_node,
|
static esp_err_t loop_node_add_handler(esp_event_loop_node_t* loop_node,
|
||||||
esp_event_base_t base,
|
esp_event_base_t base,
|
||||||
int32_t id,
|
int32_t id,
|
||||||
esp_event_handler_t event_handler,
|
esp_event_handler_t event_handler,
|
||||||
void *event_handler_arg,
|
void *event_handler_arg,
|
||||||
esp_event_handler_instance_context_t **handler_ctx,
|
esp_event_handler_instance_context_t **handler_ctx,
|
||||||
bool legacy)
|
bool legacy)
|
||||||
{
|
{
|
||||||
if (base == esp_event_any_base && id == ESP_EVENT_ANY_ID) {
|
if (base == esp_event_any_base && id == ESP_EVENT_ANY_ID) {
|
||||||
return handler_instances_add(&(loop_node->handlers), event_handler, event_handler_arg, handler_ctx, legacy);
|
return handler_instances_add(&(loop_node->handlers), event_handler, event_handler_arg, handler_ctx, legacy);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
esp_err_t err = ESP_OK;
|
esp_err_t err = ESP_OK;
|
||||||
esp_event_base_node_t *it = NULL, *base_node = NULL, *last_base_node = NULL;
|
esp_event_base_node_t *it = NULL, *base_node = NULL, *last_base_node = NULL;
|
||||||
|
|
||||||
@ -287,9 +282,9 @@ static esp_err_t loop_node_add_handler(esp_event_loop_node_t* loop_node,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!last_base_node ||
|
if (!last_base_node ||
|
||||||
!base_node ||
|
!base_node ||
|
||||||
(base_node && !SLIST_EMPTY(&(base_node->id_nodes)) && id == ESP_EVENT_ANY_ID) ||
|
(base_node && !SLIST_EMPTY(&(base_node->id_nodes)) && id == ESP_EVENT_ANY_ID) ||
|
||||||
(last_base_node && last_base_node->base != base && !SLIST_EMPTY(&(last_base_node->id_nodes)) && id == ESP_EVENT_ANY_ID)) {
|
(last_base_node && last_base_node->base != base && !SLIST_EMPTY(&(last_base_node->id_nodes)) && id == ESP_EVENT_ANY_ID)) {
|
||||||
base_node = (esp_event_base_node_t*) calloc(1, sizeof(*base_node));
|
base_node = (esp_event_base_node_t*) calloc(1, sizeof(*base_node));
|
||||||
|
|
||||||
if (!base_node) {
|
if (!base_node) {
|
||||||
@ -307,8 +302,7 @@ static esp_err_t loop_node_add_handler(esp_event_loop_node_t* loop_node,
|
|||||||
if (err == ESP_OK) {
|
if (err == ESP_OK) {
|
||||||
if (!last_base_node) {
|
if (!last_base_node) {
|
||||||
SLIST_INSERT_HEAD(&(loop_node->base_nodes), base_node, next);
|
SLIST_INSERT_HEAD(&(loop_node->base_nodes), base_node, next);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
SLIST_INSERT_AFTER(last_base_node, base_node, next);
|
SLIST_INSERT_AFTER(last_base_node, base_node, next);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -347,13 +341,11 @@ static esp_err_t handler_instances_remove(esp_event_handler_nodes_t* handlers, e
|
|||||||
return ESP_ERR_NOT_FOUND;
|
return ESP_ERR_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static esp_err_t base_node_remove_handler(esp_event_base_node_t* base_node, int32_t id, esp_event_handler_instance_context_t* handler_ctx, bool legacy)
|
static esp_err_t base_node_remove_handler(esp_event_base_node_t* base_node, int32_t id, esp_event_handler_instance_context_t* handler_ctx, bool legacy)
|
||||||
{
|
{
|
||||||
if (id == ESP_EVENT_ANY_ID) {
|
if (id == ESP_EVENT_ANY_ID) {
|
||||||
return handler_instances_remove(&(base_node->handlers), handler_ctx, legacy);
|
return handler_instances_remove(&(base_node->handlers), handler_ctx, legacy);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
esp_event_id_node_t *it, *temp;
|
esp_event_id_node_t *it, *temp;
|
||||||
SLIST_FOREACH_SAFE(it, &(base_node->id_nodes), next, temp) {
|
SLIST_FOREACH_SAFE(it, &(base_node->id_nodes), next, temp) {
|
||||||
if (it->id == id) {
|
if (it->id == id) {
|
||||||
@ -377,8 +369,7 @@ static esp_err_t loop_node_remove_handler(esp_event_loop_node_t* loop_node, esp_
|
|||||||
{
|
{
|
||||||
if (base == esp_event_any_base && id == ESP_EVENT_ANY_ID) {
|
if (base == esp_event_any_base && id == ESP_EVENT_ANY_ID) {
|
||||||
return handler_instances_remove(&(loop_node->handlers), handler_ctx, legacy);
|
return handler_instances_remove(&(loop_node->handlers), handler_ctx, legacy);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
esp_event_base_node_t *it, *temp;
|
esp_event_base_node_t *it, *temp;
|
||||||
SLIST_FOREACH_SAFE(it, &(loop_node->base_nodes), next, temp) {
|
SLIST_FOREACH_SAFE(it, &(loop_node->base_nodes), next, temp) {
|
||||||
if (it->base == base) {
|
if (it->base == base) {
|
||||||
@ -469,7 +460,7 @@ esp_err_t esp_event_loop_create(const esp_event_loop_args_t* event_loop_args, es
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
loop->queue = xQueueCreate(event_loop_args->queue_size , sizeof(esp_event_post_instance_t));
|
loop->queue = xQueueCreate(event_loop_args->queue_size, sizeof(esp_event_post_instance_t));
|
||||||
if (loop->queue == NULL) {
|
if (loop->queue == NULL) {
|
||||||
ESP_LOGE(TAG, "create event loop queue failed");
|
ESP_LOGE(TAG, "create event loop queue failed");
|
||||||
goto on_err;
|
goto on_err;
|
||||||
@ -494,8 +485,8 @@ esp_err_t esp_event_loop_create(const esp_event_loop_args_t* event_loop_args, es
|
|||||||
// Create the loop task if requested
|
// Create the loop task if requested
|
||||||
if (event_loop_args->task_name != NULL) {
|
if (event_loop_args->task_name != NULL) {
|
||||||
BaseType_t task_created = xTaskCreatePinnedToCore(esp_event_loop_run_task, event_loop_args->task_name,
|
BaseType_t task_created = xTaskCreatePinnedToCore(esp_event_loop_run_task, event_loop_args->task_name,
|
||||||
event_loop_args->task_stack_size, (void*) loop,
|
event_loop_args->task_stack_size, (void*) loop,
|
||||||
event_loop_args->task_priority, &(loop->task), event_loop_args->task_core_id);
|
event_loop_args->task_priority, &(loop->task), event_loop_args->task_core_id);
|
||||||
|
|
||||||
if (task_created != pdPASS) {
|
if (task_created != pdPASS) {
|
||||||
ESP_LOGE(TAG, "create task for loop failed");
|
ESP_LOGE(TAG, "create task for loop failed");
|
||||||
@ -566,7 +557,7 @@ esp_err_t esp_event_loop_run(esp_event_loop_handle_t event_loop, TickType_t tick
|
|||||||
int64_t remaining_ticks = ticks_to_run;
|
int64_t remaining_ticks = ticks_to_run;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
while(xQueueReceive(loop->queue, &post, ticks_to_run) == pdTRUE) {
|
while (xQueueReceive(loop->queue, &post, ticks_to_run) == pdTRUE) {
|
||||||
// The event has already been unqueued, so ensure it gets executed.
|
// The event has already been unqueued, so ensure it gets executed.
|
||||||
xSemaphoreTakeRecursive(loop->mutex, portMAX_DELAY);
|
xSemaphoreTakeRecursive(loop->mutex, portMAX_DELAY);
|
||||||
|
|
||||||
@ -674,7 +665,7 @@ esp_err_t esp_event_loop_delete(esp_event_loop_handle_t event_loop)
|
|||||||
|
|
||||||
// Drop existing posts on the queue
|
// Drop existing posts on the queue
|
||||||
esp_event_post_instance_t post;
|
esp_event_post_instance_t post;
|
||||||
while(xQueueReceive(loop->queue, &post, 0) == pdTRUE) {
|
while (xQueueReceive(loop->queue, &post, 0) == pdTRUE) {
|
||||||
post_instance_delete(&post);
|
post_instance_delete(&post);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -693,8 +684,8 @@ esp_err_t esp_event_loop_delete(esp_event_loop_handle_t event_loop)
|
|||||||
}
|
}
|
||||||
|
|
||||||
esp_err_t esp_event_handler_register_with_internal(esp_event_loop_handle_t event_loop, esp_event_base_t event_base,
|
esp_err_t esp_event_handler_register_with_internal(esp_event_loop_handle_t event_loop, esp_event_base_t event_base,
|
||||||
int32_t event_id, esp_event_handler_t event_handler, void* event_handler_arg,
|
int32_t event_id, esp_event_handler_t event_handler, void* event_handler_arg,
|
||||||
esp_event_handler_instance_context_t** handler_ctx_arg, bool legacy)
|
esp_event_handler_instance_context_t** handler_ctx_arg, bool legacy)
|
||||||
{
|
{
|
||||||
assert(event_loop);
|
assert(event_loop);
|
||||||
assert(event_handler);
|
assert(event_handler);
|
||||||
@ -723,7 +714,7 @@ esp_err_t esp_event_handler_register_with_internal(esp_event_loop_handle_t event
|
|||||||
bool is_loop_level_handler = (event_base == esp_event_any_base) && (event_id == ESP_EVENT_ANY_ID);
|
bool is_loop_level_handler = (event_base == esp_event_any_base) && (event_id == ESP_EVENT_ANY_ID);
|
||||||
|
|
||||||
if (!last_loop_node ||
|
if (!last_loop_node ||
|
||||||
(last_loop_node && !SLIST_EMPTY(&(last_loop_node->base_nodes)) && is_loop_level_handler)) {
|
(last_loop_node && !SLIST_EMPTY(&(last_loop_node->base_nodes)) && is_loop_level_handler)) {
|
||||||
loop_node = (esp_event_loop_node_t*) calloc(1, sizeof(*loop_node));
|
loop_node = (esp_event_loop_node_t*) calloc(1, sizeof(*loop_node));
|
||||||
|
|
||||||
if (!loop_node) {
|
if (!loop_node) {
|
||||||
@ -740,15 +731,13 @@ esp_err_t esp_event_handler_register_with_internal(esp_event_loop_handle_t event
|
|||||||
if (err == ESP_OK) {
|
if (err == ESP_OK) {
|
||||||
if (!last_loop_node) {
|
if (!last_loop_node) {
|
||||||
SLIST_INSERT_HEAD(&(loop->loop_nodes), loop_node, next);
|
SLIST_INSERT_HEAD(&(loop->loop_nodes), loop_node, next);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
SLIST_INSERT_AFTER(last_loop_node, loop_node, next);
|
SLIST_INSERT_AFTER(last_loop_node, loop_node, next);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
free(loop_node);
|
free(loop_node);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
err = loop_node_add_handler(last_loop_node, event_base, event_id, event_handler, event_handler_arg, handler_ctx_arg, legacy);
|
err = loop_node_add_handler(last_loop_node, event_base, event_id, event_handler, event_handler_arg, handler_ctx_arg, legacy);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -758,20 +747,20 @@ on_err:
|
|||||||
}
|
}
|
||||||
|
|
||||||
esp_err_t esp_event_handler_register_with(esp_event_loop_handle_t event_loop, esp_event_base_t event_base,
|
esp_err_t esp_event_handler_register_with(esp_event_loop_handle_t event_loop, esp_event_base_t event_base,
|
||||||
int32_t event_id, esp_event_handler_t event_handler, void* event_handler_arg)
|
int32_t event_id, esp_event_handler_t event_handler, void* event_handler_arg)
|
||||||
{
|
{
|
||||||
return esp_event_handler_register_with_internal(event_loop, event_base, event_id, event_handler, event_handler_arg, NULL, true);
|
return esp_event_handler_register_with_internal(event_loop, event_base, event_id, event_handler, event_handler_arg, NULL, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
esp_err_t esp_event_handler_instance_register_with(esp_event_loop_handle_t event_loop, esp_event_base_t event_base,
|
esp_err_t esp_event_handler_instance_register_with(esp_event_loop_handle_t event_loop, esp_event_base_t event_base,
|
||||||
int32_t event_id, esp_event_handler_t event_handler, void* event_handler_arg,
|
int32_t event_id, esp_event_handler_t event_handler, void* event_handler_arg,
|
||||||
esp_event_handler_instance_t* handler_ctx_arg)
|
esp_event_handler_instance_t* handler_ctx_arg)
|
||||||
{
|
{
|
||||||
return esp_event_handler_register_with_internal(event_loop, event_base, event_id, event_handler, event_handler_arg, (esp_event_handler_instance_context_t**) handler_ctx_arg, false);
|
return esp_event_handler_register_with_internal(event_loop, event_base, event_id, event_handler, event_handler_arg, (esp_event_handler_instance_context_t**) handler_ctx_arg, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
esp_err_t esp_event_handler_unregister_with_internal(esp_event_loop_handle_t event_loop, esp_event_base_t event_base,
|
esp_err_t esp_event_handler_unregister_with_internal(esp_event_loop_handle_t event_loop, esp_event_base_t event_base,
|
||||||
int32_t event_id, esp_event_handler_instance_context_t* handler_ctx, bool legacy)
|
int32_t event_id, esp_event_handler_instance_context_t* handler_ctx, bool legacy)
|
||||||
{
|
{
|
||||||
assert(event_loop);
|
assert(event_loop);
|
||||||
assert(handler_ctx);
|
assert(handler_ctx);
|
||||||
@ -817,9 +806,11 @@ esp_err_t esp_event_handler_unregister_with(esp_event_loop_handle_t event_loop,
|
|||||||
}
|
}
|
||||||
|
|
||||||
esp_err_t esp_event_handler_instance_unregister_with(esp_event_loop_handle_t event_loop, esp_event_base_t event_base,
|
esp_err_t esp_event_handler_instance_unregister_with(esp_event_loop_handle_t event_loop, esp_event_base_t event_base,
|
||||||
int32_t event_id, esp_event_handler_instance_t handler_ctx_arg)
|
int32_t event_id, esp_event_handler_instance_t handler_ctx_arg)
|
||||||
{
|
{
|
||||||
if (!handler_ctx_arg) return ESP_ERR_INVALID_ARG;
|
if (!handler_ctx_arg) {
|
||||||
|
return ESP_ERR_INVALID_ARG;
|
||||||
|
}
|
||||||
|
|
||||||
return esp_event_handler_unregister_with_internal(event_loop, event_base, event_id, (esp_event_handler_instance_context_t*) handler_ctx_arg, false);
|
return esp_event_handler_unregister_with_internal(event_loop, event_base, event_id, (esp_event_handler_instance_context_t*) handler_ctx_arg, false);
|
||||||
}
|
}
|
||||||
@ -902,7 +893,7 @@ esp_err_t esp_event_post_to(esp_event_loop_handle_t event_loop, esp_event_base_t
|
|||||||
|
|
||||||
#if CONFIG_ESP_EVENT_POST_FROM_ISR
|
#if CONFIG_ESP_EVENT_POST_FROM_ISR
|
||||||
esp_err_t esp_event_isr_post_to(esp_event_loop_handle_t event_loop, esp_event_base_t event_base, int32_t event_id,
|
esp_err_t esp_event_isr_post_to(esp_event_loop_handle_t event_loop, esp_event_base_t event_base, int32_t event_id,
|
||||||
const void* event_data, size_t event_data_size, BaseType_t* task_unblocked)
|
const void* event_data, size_t event_data_size, BaseType_t* task_unblocked)
|
||||||
{
|
{
|
||||||
assert(event_loop);
|
assert(event_loop);
|
||||||
|
|
||||||
@ -976,7 +967,7 @@ esp_err_t esp_event_dump(FILE* file)
|
|||||||
events_recieved = atomic_load(&loop_it->events_recieved);
|
events_recieved = atomic_load(&loop_it->events_recieved);
|
||||||
events_dropped = atomic_load(&loop_it->events_dropped);
|
events_dropped = atomic_load(&loop_it->events_dropped);
|
||||||
|
|
||||||
PRINT_DUMP_INFO(dst, sz, LOOP_DUMP_FORMAT, loop_it, loop_it->task != NULL ? loop_it->name : "none" ,
|
PRINT_DUMP_INFO(dst, sz, LOOP_DUMP_FORMAT, loop_it, loop_it->task != NULL ? loop_it->name : "none",
|
||||||
events_recieved, events_dropped);
|
events_recieved, events_dropped);
|
||||||
|
|
||||||
int sz_bak = sz;
|
int sz_bak = sz;
|
||||||
@ -989,7 +980,7 @@ esp_err_t esp_event_dump(FILE* file)
|
|||||||
|
|
||||||
SLIST_FOREACH(base_node_it, &(loop_node_it->base_nodes), next) {
|
SLIST_FOREACH(base_node_it, &(loop_node_it->base_nodes), next) {
|
||||||
SLIST_FOREACH(handler_it, &(base_node_it->handlers), next) {
|
SLIST_FOREACH(handler_it, &(base_node_it->handlers), next) {
|
||||||
PRINT_DUMP_INFO(dst, sz, HANDLER_DUMP_FORMAT, handler_it->handler_ctx->handler, base_node_it->base ,
|
PRINT_DUMP_INFO(dst, sz, HANDLER_DUMP_FORMAT, handler_it->handler_ctx->handler, base_node_it->base,
|
||||||
"ESP_EVENT_ANY_ID", handler_it->invoked, handler_it->time);
|
"ESP_EVENT_ANY_ID", handler_it->invoked, handler_it->time);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -998,7 +989,7 @@ esp_err_t esp_event_dump(FILE* file)
|
|||||||
memset(id_str_buf, 0, sizeof(id_str_buf));
|
memset(id_str_buf, 0, sizeof(id_str_buf));
|
||||||
snprintf(id_str_buf, sizeof(id_str_buf), "%" PRIi32, id_node_it->id);
|
snprintf(id_str_buf, sizeof(id_str_buf), "%" PRIi32, id_node_it->id);
|
||||||
|
|
||||||
PRINT_DUMP_INFO(dst, sz, HANDLER_DUMP_FORMAT, handler_it->handler_ctx->handler, base_node_it->base ,
|
PRINT_DUMP_INFO(dst, sz, HANDLER_DUMP_FORMAT, handler_it->handler_ctx->handler, base_node_it->base,
|
||||||
id_str_buf, handler_it->invoked, handler_it->time);
|
id_str_buf, handler_it->invoked, handler_it->time);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,8 +22,7 @@ bool esp_event_is_handler_registered(esp_event_loop_handle_t event_loop, esp_eve
|
|||||||
|
|
||||||
SLIST_FOREACH(loop_node, &(loop->loop_nodes), next) {
|
SLIST_FOREACH(loop_node, &(loop->loop_nodes), next) {
|
||||||
SLIST_FOREACH(handler, &(loop_node->handlers), next) {
|
SLIST_FOREACH(handler, &(loop_node->handlers), next) {
|
||||||
if(event_base == ESP_EVENT_ANY_BASE && event_id == ESP_EVENT_ANY_ID && handler->handler_ctx->handler == event_handler)
|
if (event_base == ESP_EVENT_ANY_BASE && event_id == ESP_EVENT_ANY_ID && handler->handler_ctx->handler == event_handler) {
|
||||||
{
|
|
||||||
result = true;
|
result = true;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
@ -32,18 +31,16 @@ bool esp_event_is_handler_registered(esp_event_loop_handle_t event_loop, esp_eve
|
|||||||
SLIST_FOREACH(base_node, &(loop_node->base_nodes), next) {
|
SLIST_FOREACH(base_node, &(loop_node->base_nodes), next) {
|
||||||
if (base_node->base == event_base) {
|
if (base_node->base == event_base) {
|
||||||
SLIST_FOREACH(handler, &(base_node->handlers), next) {
|
SLIST_FOREACH(handler, &(base_node->handlers), next) {
|
||||||
if(event_id == ESP_EVENT_ANY_ID && handler->handler_ctx->handler == event_handler)
|
if (event_id == ESP_EVENT_ANY_ID && handler->handler_ctx->handler == event_handler) {
|
||||||
{
|
|
||||||
result = true;
|
result = true;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SLIST_FOREACH(id_node, &(base_node->id_nodes), next) {
|
SLIST_FOREACH(id_node, &(base_node->id_nodes), next) {
|
||||||
if(id_node->id == event_id) {
|
if (id_node->id == event_id) {
|
||||||
SLIST_FOREACH(handler, &(id_node->handlers), next) {
|
SLIST_FOREACH(handler, &(id_node->handlers), next) {
|
||||||
if(handler->handler_ctx->handler == event_handler)
|
if (handler->handler_ctx->handler == event_handler) {
|
||||||
{
|
|
||||||
result = true;
|
result = true;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,6 @@
|
|||||||
CONDITIONS OF ANY KIND, either express or implied.
|
CONDITIONS OF ANY KIND, either express or implied.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "esp_event.h"
|
#include "esp_event.h"
|
||||||
|
|
||||||
@ -20,7 +19,6 @@ extern "C" {
|
|||||||
#include "Mockqueue.h"
|
#include "Mockqueue.h"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
const uint32_t QUEUE_SIZE = 32;
|
const uint32_t QUEUE_SIZE = 32;
|
||||||
@ -45,7 +43,8 @@ void dummy_handler(void* event_handler_arg, esp_event_base_t event_base, int32_t
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: IDF-2693, function definition just to satisfy linker, implement esp_common instead
|
// TODO: IDF-2693, function definition just to satisfy linker, implement esp_common instead
|
||||||
const char *esp_err_to_name(esp_err_t code) {
|
const char *esp_err_to_name(esp_err_t code)
|
||||||
|
{
|
||||||
return "test";
|
return "test";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -141,11 +140,12 @@ TEST_CASE("test esp_event_loop_create with_task(void)")
|
|||||||
xQueueGiveMutexRecursive_StopIgnore();
|
xQueueGiveMutexRecursive_StopIgnore();
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("registering with ANY_BASE but specific ID fails") {
|
TEST_CASE("registering with ANY_BASE but specific ID fails")
|
||||||
|
{
|
||||||
esp_event_loop_handle_t loop = reinterpret_cast<esp_event_loop_handle_t>(1);
|
esp_event_loop_handle_t loop = reinterpret_cast<esp_event_loop_handle_t>(1);
|
||||||
CHECK(esp_event_handler_register_with(loop,
|
CHECK(esp_event_handler_register_with(loop,
|
||||||
ESP_EVENT_ANY_BASE,
|
ESP_EVENT_ANY_BASE,
|
||||||
47,
|
47,
|
||||||
dummy_handler,
|
dummy_handler,
|
||||||
nullptr) == ESP_ERR_INVALID_ARG);
|
nullptr) == ESP_ERR_INVALID_ARG);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2018-2021 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2018-2024 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
@ -208,11 +208,11 @@ esp_err_t esp_event_handler_register_with(esp_event_loop_handle_t event_loop,
|
|||||||
* - Others: Fail
|
* - Others: Fail
|
||||||
*/
|
*/
|
||||||
esp_err_t esp_event_handler_instance_register_with(esp_event_loop_handle_t event_loop,
|
esp_err_t esp_event_handler_instance_register_with(esp_event_loop_handle_t event_loop,
|
||||||
esp_event_base_t event_base,
|
esp_event_base_t event_base,
|
||||||
int32_t event_id,
|
int32_t event_id,
|
||||||
esp_event_handler_t event_handler,
|
esp_event_handler_t event_handler,
|
||||||
void *event_handler_arg,
|
void *event_handler_arg,
|
||||||
esp_event_handler_instance_t *instance);
|
esp_event_handler_instance_t *instance);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Register an instance of event handler to the default loop.
|
* @brief Register an instance of event handler to the default loop.
|
||||||
@ -243,10 +243,10 @@ esp_err_t esp_event_handler_instance_register_with(esp_event_loop_handle_t event
|
|||||||
* - Others: Fail
|
* - Others: Fail
|
||||||
*/
|
*/
|
||||||
esp_err_t esp_event_handler_instance_register(esp_event_base_t event_base,
|
esp_err_t esp_event_handler_instance_register(esp_event_base_t event_base,
|
||||||
int32_t event_id,
|
int32_t event_id,
|
||||||
esp_event_handler_t event_handler,
|
esp_event_handler_t event_handler,
|
||||||
void *event_handler_arg,
|
void *event_handler_arg,
|
||||||
esp_event_handler_instance_t *instance);
|
esp_event_handler_instance_t *instance);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Unregister a handler with the system event loop (legacy).
|
* @brief Unregister a handler with the system event loop (legacy).
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2018-2023 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2018-2024 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
@ -19,10 +19,10 @@ extern "C" {
|
|||||||
// Event loop library types
|
// Event loop library types
|
||||||
typedef const char* esp_event_base_t; /**< unique pointer to a subsystem that exposes events */
|
typedef const char* esp_event_base_t; /**< unique pointer to a subsystem that exposes events */
|
||||||
typedef void* esp_event_loop_handle_t; /**< a number that identifies an event with respect to a base */
|
typedef void* esp_event_loop_handle_t; /**< a number that identifies an event with respect to a base */
|
||||||
typedef void (*esp_event_handler_t)(void* event_handler_arg,
|
typedef void (*esp_event_handler_t)(void* event_handler_arg,
|
||||||
esp_event_base_t event_base,
|
esp_event_base_t event_base,
|
||||||
int32_t event_id,
|
int32_t event_id,
|
||||||
void* event_data); /**< function called when an event is posted to the queue */
|
void* event_data); /**< function called when an event is posted to the queue */
|
||||||
typedef void* esp_event_handler_instance_t; /**< context identifying an instance of a registered event handler */
|
typedef void* esp_event_handler_instance_t; /**< context identifying an instance of a registered event handler */
|
||||||
|
|
||||||
// Defines for registering/unregistering event handlers
|
// Defines for registering/unregistering event handlers
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||||
*/
|
*/
|
||||||
@ -30,7 +30,6 @@
|
|||||||
|
|
||||||
#include "test_utils.h"
|
#include "test_utils.h"
|
||||||
|
|
||||||
|
|
||||||
static const char* TAG = "test_event";
|
static const char* TAG = "test_event";
|
||||||
|
|
||||||
static const TickType_t ZERO_DELAY = 0;
|
static const TickType_t ZERO_DELAY = 0;
|
||||||
@ -154,7 +153,7 @@ static void test_event_simple_handler_registration_task(void* args)
|
|||||||
|
|
||||||
xSemaphoreTake(arg->start, portMAX_DELAY);
|
xSemaphoreTake(arg->start, portMAX_DELAY);
|
||||||
|
|
||||||
for(int i = 0; i < data->num; i++) {
|
for (int i = 0; i < data->num; i++) {
|
||||||
if (data->is_registration) {
|
if (data->is_registration) {
|
||||||
TEST_ESP_OK(esp_event_handler_register_with(data->loop, data->base, data->id, data->handles[i], NULL));
|
TEST_ESP_OK(esp_event_handler_register_with(data->loop, data->base, data->id, data->handles[i], NULL));
|
||||||
} else {
|
} else {
|
||||||
@ -261,7 +260,7 @@ TEST_CASE("can register/unregister handlers simultaneously", "[event]")
|
|||||||
registration_data[i].is_registration = true;
|
registration_data[i].is_registration = true;
|
||||||
|
|
||||||
for (int j = 0; j < TEST_CONFIG_ITEMS_TO_REGISTER; j++) {
|
for (int j = 0; j < TEST_CONFIG_ITEMS_TO_REGISTER; j++) {
|
||||||
registration_data[i].handles[j] = (void*) (i * TEST_CONFIG_ITEMS_TO_REGISTER) + (j + TEST_CONFIG_ITEMS_TO_REGISTER);
|
registration_data[i].handles[j] = (void*)(i * TEST_CONFIG_ITEMS_TO_REGISTER) + (j + TEST_CONFIG_ITEMS_TO_REGISTER);
|
||||||
}
|
}
|
||||||
|
|
||||||
registration_arg[i].start = xSemaphoreCreateBinary();
|
registration_arg[i].start = xSemaphoreCreateBinary();
|
||||||
@ -381,8 +380,7 @@ TEST_CASE("can post and run events simultaneously", "[event]")
|
|||||||
post_event_data_t* post_event_data = calloc(TEST_CONFIG_TASKS_TO_SPAWN, sizeof(*post_event_data));
|
post_event_data_t* post_event_data = calloc(TEST_CONFIG_TASKS_TO_SPAWN, sizeof(*post_event_data));
|
||||||
task_arg_t* post_event_arg = calloc(TEST_CONFIG_TASKS_TO_SPAWN, sizeof(*post_event_arg));
|
task_arg_t* post_event_arg = calloc(TEST_CONFIG_TASKS_TO_SPAWN, sizeof(*post_event_arg));
|
||||||
|
|
||||||
for (int i = 0; i < TEST_CONFIG_TASKS_TO_SPAWN; i++)
|
for (int i = 0; i < TEST_CONFIG_TASKS_TO_SPAWN; i++) {
|
||||||
{
|
|
||||||
post_event_data[i].base = s_test_base1;
|
post_event_data[i].base = s_test_base1;
|
||||||
post_event_data[i].id = TEST_EVENT_BASE1_EV1;
|
post_event_data[i].id = TEST_EVENT_BASE1_EV1;
|
||||||
post_event_data[i].loop = loop;
|
post_event_data[i].loop = loop;
|
||||||
@ -459,8 +457,7 @@ TEST_CASE("can post and run events simultaneously with instances", "[event]")
|
|||||||
post_event_data_t* post_event_data = calloc(TEST_CONFIG_TASKS_TO_SPAWN, sizeof(*post_event_data));
|
post_event_data_t* post_event_data = calloc(TEST_CONFIG_TASKS_TO_SPAWN, sizeof(*post_event_data));
|
||||||
task_arg_t* post_event_arg = calloc(TEST_CONFIG_TASKS_TO_SPAWN, sizeof(*post_event_arg));
|
task_arg_t* post_event_arg = calloc(TEST_CONFIG_TASKS_TO_SPAWN, sizeof(*post_event_arg));
|
||||||
|
|
||||||
for (int i = 0; i < TEST_CONFIG_TASKS_TO_SPAWN; i++)
|
for (int i = 0; i < TEST_CONFIG_TASKS_TO_SPAWN; i++) {
|
||||||
{
|
|
||||||
post_event_data[i].base = s_test_base1;
|
post_event_data[i].base = s_test_base1;
|
||||||
post_event_data[i].id = TEST_EVENT_BASE1_EV1;
|
post_event_data[i].id = TEST_EVENT_BASE1_EV1;
|
||||||
post_event_data[i].loop = loop;
|
post_event_data[i].loop = loop;
|
||||||
@ -514,7 +511,7 @@ static void loop_run_task(void* args)
|
|||||||
{
|
{
|
||||||
esp_event_loop_handle_t event_loop = (esp_event_loop_handle_t) args;
|
esp_event_loop_handle_t event_loop = (esp_event_loop_handle_t) args;
|
||||||
|
|
||||||
while(1) {
|
while (1) {
|
||||||
esp_event_loop_run(event_loop, portMAX_DELAY);
|
esp_event_loop_run(event_loop, portMAX_DELAY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -527,8 +524,8 @@ static void performance_test(bool dedicated_task)
|
|||||||
|
|
||||||
const char test_base[] = "qwertyuiopasdfghjklzxvbnmmnbvcxz";
|
const char test_base[] = "qwertyuiopasdfghjklzxvbnmmnbvcxz";
|
||||||
|
|
||||||
#define TEST_CONFIG_BASES (sizeof(test_base) - 1)
|
#define TEST_CONFIG_BASES (sizeof(test_base) - 1)
|
||||||
#define TEST_CONFIG_IDS (TEST_CONFIG_BASES / 2)
|
#define TEST_CONFIG_IDS (TEST_CONFIG_BASES / 2)
|
||||||
|
|
||||||
// Create loop
|
// Create loop
|
||||||
esp_event_loop_args_t loop_args = test_event_get_default_loop_args();
|
esp_event_loop_args_t loop_args = test_event_get_default_loop_args();
|
||||||
@ -583,7 +580,7 @@ static void performance_test(bool dedicated_task)
|
|||||||
int rand_b = rand() % bases;
|
int rand_b = rand() % bases;
|
||||||
|
|
||||||
int temp = post_bases[rand_a];
|
int temp = post_bases[rand_a];
|
||||||
post_bases[rand_a]= post_bases[rand_b];
|
post_bases[rand_a] = post_bases[rand_b];
|
||||||
post_bases[rand_b] = temp;
|
post_bases[rand_b] = temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -592,7 +589,7 @@ static void performance_test(bool dedicated_task)
|
|||||||
int rand_b = rand() % ids;
|
int rand_b = rand() % ids;
|
||||||
|
|
||||||
int temp = post_ids[rand_a];
|
int temp = post_ids[rand_a];
|
||||||
post_ids[rand_a]= post_ids[rand_b];
|
post_ids[rand_a] = post_ids[rand_b];
|
||||||
post_ids[rand_b] = temp;
|
post_ids[rand_b] = temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -617,7 +614,7 @@ static void performance_test(bool dedicated_task)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int average = (int) (running_sum / (running_count));
|
int average = (int)(running_sum / (running_count));
|
||||||
|
|
||||||
if (!dedicated_task) {
|
if (!dedicated_task) {
|
||||||
((esp_event_loop_instance_t*) loop)->task = mtask;
|
((esp_event_loop_instance_t*) loop)->task = mtask;
|
||||||
@ -700,7 +697,7 @@ static void test_handler_post_from_isr(void* event_handler_arg, esp_event_base_t
|
|||||||
SemaphoreHandle_t *sem = (SemaphoreHandle_t*) event_handler_arg;
|
SemaphoreHandle_t *sem = (SemaphoreHandle_t*) event_handler_arg;
|
||||||
// Event data is just the address value (maybe have been truncated due to casting).
|
// Event data is just the address value (maybe have been truncated due to casting).
|
||||||
int *data = (int*) event_data;
|
int *data = (int*) event_data;
|
||||||
TEST_ASSERT_EQUAL(*data, (int) (*sem));
|
TEST_ASSERT_EQUAL(*data, (int)(*sem));
|
||||||
xSemaphoreGive(*sem);
|
xSemaphoreGive(*sem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,7 +54,6 @@ components_not_formatted_temporary:
|
|||||||
- "/components/efuse/"
|
- "/components/efuse/"
|
||||||
- "/components/esp_coex/"
|
- "/components/esp_coex/"
|
||||||
- "/components/esp_eth/"
|
- "/components/esp_eth/"
|
||||||
- "/components/esp_event/"
|
|
||||||
- "/components/esp_gdbstub/"
|
- "/components/esp_gdbstub/"
|
||||||
- "/components/esp_hid/"
|
- "/components/esp_hid/"
|
||||||
- "/components/esp_http_client/"
|
- "/components/esp_http_client/"
|
||||||
|
Loading…
Reference in New Issue
Block a user