register_component()
-if(GCC_NOT_5_2_0 AND CONFIG_EVENT_LOOP_PROFILING)
+if(GCC_NOT_5_2_0 AND CONFIG_ESP_EVENT_LOOP_PROFILING)
# uses C11 atomic feature
set_source_files_properties(esp_event.c PROPERTIES COMPILE_FLAGS -std=gnu11)
-endif()
\ No newline at end of file
+endif()
menu "Event Loop Library"
- config EVENT_LOOP_PROFILING
+ config ESP_EVENT_LOOP_PROFILING
bool "Enable event loop profiling"
default n
help
to/recieved by an event loop, number of callbacks involved, number of events dropped to to a full event
loop queue, run time of event handlers, and number of times/run time of each event handler.
- config POST_EVENTS_FROM_ISR
+ config ESP_EVENT_POST_FROM_ISR
bool "Support posting events from ISRs"
default y
help
Enable posting events from interrupt handlers.
- config POST_EVENTS_FROM_IRAM_ISR
+ config ESP_EVENT_POST_FROM_IRAM_ISR
bool "Support posting events from ISRs placed in IRAM"
default y
- depends on POST_EVENTS_FROM_ISR
+ depends on ESP_EVENT_POST_FROM_ISR
help
Enable posting events from interrupt handlers placed in IRAM. Enabling this option places API functions
esp_event_post and esp_event_post_to in IRAM.
COMPONENT_PRIV_INCLUDEDIRS := private_include
COMPONENT_SRCDIRS := .
-ifdef CONFIG_EVENT_LOOP_PROFILING
+ifdef CONFIG_ESP_EVENT_LOOP_PROFILING
PROFILING_ENABLED := 1
else
PROFILING_ENABLED := 0
}
-#if CONFIG_POST_EVENTS_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,
void* event_data, size_t event_data_size, BaseType_t* task_unblocked)
{
#include "esp_event_internal.h"
#include "esp_event_private.h"
-#ifdef CONFIG_EVENT_LOOP_PROFILING
+#ifdef CONFIG_ESP_EVENT_LOOP_PROFILING
#include "esp_timer.h"
#endif
/* ---------------------------- Definitions --------------------------------- */
-#ifdef CONFIG_EVENT_LOOP_PROFILING
+#ifdef CONFIG_ESP_EVENT_LOOP_PROFILING
// LOOP @<address, name> rx:<recieved events no.> dr:<dropped events no.>
#define LOOP_DUMP_FORMAT "LOOP @%p,%s rx:%u dr:%u\n"
// handler @<address> ev:<base, id> inv:<times invoked> time:<runtime>
static const char* TAG = "event";
static const char* esp_event_any_base = "any";
-#ifdef CONFIG_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 =
SLIST_HEAD_INITIALIZER(s_event_loops);
/* ------------------------- Static Functions ------------------------------- */
-#ifdef CONFIG_EVENT_LOOP_PROFILING
+#ifdef CONFIG_ESP_EVENT_LOOP_PROFILING
static int esp_event_dump_prepare()
{
ESP_LOGD(TAG, "running post %s:%d with handler %p on loop %p", post.base, post.id, handler->handler, loop);
-#ifdef CONFIG_EVENT_LOOP_PROFILING
+#ifdef CONFIG_ESP_EVENT_LOOP_PROFILING
int64_t start, diff;
start = esp_timer_get_time();
#endif
// Execute the handler
-#if CONFIG_POST_EVENTS_FROM_ISR
+#if CONFIG_ESP_EVENT_POST_FROM_ISR
(*(handler->handler))(handler->arg, post.base, post.id, post.data_allocd ? post.data.ptr : &post.data.val);
#else
(*(handler->handler))(handler->arg, post.base, post.id, post.data);
#endif
-#ifdef CONFIG_EVENT_LOOP_PROFILING
+#ifdef CONFIG_ESP_EVENT_LOOP_PROFILING
diff = esp_timer_get_time() - start;
xSemaphoreTake(loop->profiling_mutex, portMAX_DELAY);
static void inline __attribute__((always_inline)) post_instance_delete(esp_event_post_instance_t* post)
{
-#if CONFIG_POST_EVENTS_FROM_ISR
+#if CONFIG_ESP_EVENT_POST_FROM_ISR
if (post->data_allocd && post->data.ptr) {
free(post->data.ptr);
}
goto on_err;
}
-#ifdef CONFIG_EVENT_LOOP_PROFILING
+#ifdef CONFIG_ESP_EVENT_LOOP_PROFILING
loop->profiling_mutex = xSemaphoreCreateMutex();
if (loop->profiling_mutex == NULL) {
ESP_LOGE(TAG, "create event loop profiling mutex failed");
loop->running_task = NULL;
-#ifdef CONFIG_EVENT_LOOP_PROFILING
+#ifdef CONFIG_ESP_EVENT_LOOP_PROFILING
portENTER_CRITICAL(&s_event_loops_spinlock);
SLIST_INSERT_HEAD(&s_event_loops, loop, next);
portEXIT_CRITICAL(&s_event_loops_spinlock);
vSemaphoreDelete(loop->mutex);
}
-#ifdef CONFIG_EVENT_LOOP_PROFILING
+#ifdef CONFIG_ESP_EVENT_LOOP_PROFILING
if(loop->profiling_mutex != NULL) {
vSemaphoreDelete(loop->profiling_mutex);
}
esp_event_loop_instance_t* loop = (esp_event_loop_instance_t*) event_loop;
SemaphoreHandle_t loop_mutex = loop->mutex;
-#ifdef CONFIG_EVENT_LOOP_PROFILING
+#ifdef CONFIG_ESP_EVENT_LOOP_PROFILING
SemaphoreHandle_t loop_profiling_mutex = loop->profiling_mutex;
#endif
xSemaphoreTakeRecursive(loop->mutex, portMAX_DELAY);
-#ifdef CONFIG_EVENT_LOOP_PROFILING
+#ifdef CONFIG_ESP_EVENT_LOOP_PROFILING
xSemaphoreTakeRecursive(loop->profiling_mutex, portMAX_DELAY);
portENTER_CRITICAL(&s_event_loops_spinlock);
SLIST_REMOVE(&s_event_loops, loop, esp_event_loop_instance, next);
free(loop);
// Free loop mutex before deleting
xSemaphoreGiveRecursive(loop_mutex);
-#ifdef CONFIG_EVENT_LOOP_PROFILING
+#ifdef CONFIG_ESP_EVENT_LOOP_PROFILING
xSemaphoreGiveRecursive(loop_profiling_mutex);
vSemaphoreDelete(loop_profiling_mutex);
#endif
}
memcpy(event_data_copy, event_data, event_data_size);
-#if CONFIG_POST_EVENTS_FROM_ISR
+#if CONFIG_ESP_EVENT_POST_FROM_ISR
post.data.ptr = event_data_copy;
post.data_allocd = true;
#else
if (result != pdTRUE) {
post_instance_delete(&post);
-#ifdef CONFIG_EVENT_LOOP_PROFILING
+#ifdef CONFIG_ESP_EVENT_LOOP_PROFILING
atomic_fetch_add(&loop->events_dropped, 1);
#endif
return ESP_ERR_TIMEOUT;
}
-#ifdef CONFIG_EVENT_LOOP_PROFILING
+#ifdef CONFIG_ESP_EVENT_LOOP_PROFILING
atomic_fetch_add(&loop->events_recieved, 1);
#endif
return ESP_OK;
}
-#if CONFIG_POST_EVENTS_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,
void* event_data, size_t event_data_size, BaseType_t* task_unblocked)
{
if (result != pdTRUE) {
post_instance_delete(&post);
-#ifdef CONFIG_EVENT_LOOP_PROFILING
+#ifdef CONFIG_ESP_EVENT_LOOP_PROFILING
atomic_fetch_add(&loop->events_dropped, 1);
#endif
return ESP_FAIL;
}
-#ifdef CONFIG_EVENT_LOOP_PROFILING
+#ifdef CONFIG_ESP_EVENT_LOOP_PROFILING
atomic_fetch_add(&loop->events_recieved, 1);
#endif
esp_err_t esp_event_dump(FILE* file)
{
-#ifdef CONFIG_EVENT_LOOP_PROFILING
+#ifdef CONFIG_ESP_EVENT_LOOP_PROFILING
assert(file);
esp_event_loop_instance_t* loop_it;
size_t event_data_size,
TickType_t ticks_to_wait);
-#if CONFIG_POST_EVENTS_FROM_ISR
+#if CONFIG_ESP_EVENT_POST_FROM_ISR
/**
* @brief Special variant of esp_event_post for posting events from interrupt handlers.
*
* higher priority than currently running task has been unblocked by the posted event;
* a context switch should be requested before the interrupt is existed.
*
- * @note this function is only available when CONFIG_POST_EVENTS_FROM_ISR is enabled
+ * @note this function is only available when CONFIG_ESP_EVENT_POST_FROM_ISR is enabled
* @note when this function is called from an interrupt handler placed in IRAM, this function should
- * be placed in IRAM as well by enabling CONFIG_POST_EVENTS_FROM_IRAM_ISR
+ * be placed in IRAM as well by enabling CONFIG_ESP_EVENT_POST_FROM_IRAM_ISR
*
* @return
* - ESP_OK: Success
* higher priority than currently running task has been unblocked by the posted event;
* a context switch should be requested before the interrupt is existed.
*
- * @note this function is only available when CONFIG_POST_EVENTS_FROM_ISR is enabled
+ * @note this function is only available when CONFIG_ESP_EVENT_POST_FROM_ISR is enabled
* @note when this function is called from an interrupt handler placed in IRAM, this function should
- * be placed in IRAM as well by enabling CONFIG_POST_EVENTS_FROM_IRAM_ISR
+ * be placed in IRAM as well by enabling CONFIG_ESP_EVENT_POST_FROM_IRAM_ISR
*
* @return
* - ESP_OK: Success
*
* @param[in] file the file stream to output to
*
- * @note this function is a noop when CONFIG_EVENT_LOOP_PROFILING is disabled
+ * @note this function is a noop when CONFIG_ESP_EVENT_LOOP_PROFILING is disabled
*
* @return
* - ESP_OK: Success
} // extern "C"
#endif
-#endif // #ifndef ESP_EVENT_H_
\ No newline at end of file
+#endif // #ifndef ESP_EVENT_H_
-if POST_EVENTS_FROM_IRAM_ISR = y:
+if ESP_EVENT_POST_FROM_IRAM_ISR = y:
[mapping:esp_event]
archive: libesp_event.a
entries:
esp_event:esp_event_isr_post_to (noflash)
- default_event_loop:esp_event_isr_post (noflash)
\ No newline at end of file
+ default_event_loop:esp_event_isr_post (noflash)
typedef struct esp_event_handler_instance {
esp_event_handler_t handler; /**< event handler function*/
void* arg; /**< event handler argument */
-#ifdef CONFIG_EVENT_LOOP_PROFILING
+#ifdef CONFIG_ESP_EVENT_LOOP_PROFILING
uint32_t invoked; /**< number of times this handler has been invoked */
int64_t time; /**< total runtime of this handler across all calls */
#endif
SemaphoreHandle_t mutex; /**< mutex for updating the events linked list */
esp_event_loop_nodes_t loop_nodes; /**< set of linked lists containing the
registered handlers for the loop */
-#ifdef CONFIG_EVENT_LOOP_PROFILING
+#ifdef CONFIG_ESP_EVENT_LOOP_PROFILING
atomic_uint_least32_t events_recieved; /**< number of events successfully posted to the loop */
atomic_uint_least32_t events_dropped; /**< number of events dropped due to queue being full */
SemaphoreHandle_t profiling_mutex; /**< mutex used for profiliing */
#endif
} esp_event_loop_instance_t;
-#if CONFIG_POST_EVENTS_FROM_ISR
+#if CONFIG_ESP_EVENT_POST_FROM_ISR
typedef union esp_event_post_data {
uint32_t val;
void *ptr;
/// Event posted to the event queue
typedef struct esp_event_post_instance {
-#if CONFIG_POST_EVENTS_FROM_ISR
+#if CONFIG_ESP_EVENT_POST_FROM_ISR
bool data_allocd; /**< indicates whether data is alloc'd */
#endif
esp_event_base_t base; /**< the event base */
} // extern "C"
#endif
-#endif // #ifndef ESP_EVENT_INTERNAL_H_
\ No newline at end of file
+#endif // #ifndef ESP_EVENT_INTERNAL_H_
--- /dev/null
+# sdkconfig replacement configurations for deprecated options formatted as
+# CONFIG_DEPRECATED_OPTION CONFIG_NEW_OPTION
+
+CONFIG_EVENT_LOOP_PROFILING CONFIG_ESP_EVENT_LOOP_PROFILING
+CONFIG_POST_EVENTS_FROM_ISR CONFIG_ESP_EVENT_POST_FROM_ISR
+CONFIG_POST_EVENTS_FROM_IRAM_ISR CONFIG_ESP_EVENT_POST_FROM_IRAM_ISR
#define TIMER_SCALE (TIMER_BASE_CLK / TIMER_DIVIDER) // convert counter value to seconds
#define TIMER_INTERVAL0_SEC (2.0) // sample test interval for the first timer
-#if CONFIG_POST_EVENTS_FROM_ISR
+#if CONFIG_ESP_EVENT_POST_FROM_ISR
static void test_handler_post_from_isr(void* event_handler_arg, esp_event_base_t event_base, int32_t event_id, void* event_data)
{
SemaphoreHandle_t *sem = (SemaphoreHandle_t*) event_handler_arg;
}
#endif
-#if CONFIG_POST_EVENTS_FROM_ISR
+#if CONFIG_ESP_EVENT_POST_FROM_ISR
void IRAM_ATTR test_event_on_timer_alarm(void* para)
{
/* Retrieve the interrupt status and the counter value
portYIELD_FROM_ISR();
}
}
-#endif //CONFIG_POST_EVENTS_FROM_ISR
+#endif //CONFIG_ESP_EVENT_POST_FROM_ISR
TEST_CASE("can create and delete event loops", "[event]")
{
TEST_TEARDOWN();
-#ifdef CONFIG_EVENT_LOOP_PROFILING
+#ifdef CONFIG_ESP_EVENT_LOOP_PROFILING
ESP_LOGI(TAG, "events dispatched/second with profiling enabled: %d", average);
// Enabling profiling will slow down event dispatch, so the set threshold
// is not valid when it is enabled.
#else
TEST_PERFORMANCE_GREATER_THAN(EVENT_DISPATCH_PSRAM, "%d", average);
#endif // CONFIG_SPIRAM_SUPPORT
-#endif // CONFIG_EVENT_LOOP_PROFILING
+#endif // CONFIG_ESP_EVENT_LOOP_PROFILING
}
TEST_CASE("performance test - dedicated task", "[event]")
TEST_TEARDOWN();
}
-#if CONFIG_POST_EVENTS_FROM_ISR
+#if CONFIG_ESP_EVENT_POST_FROM_ISR
TEST_CASE("can post events from interrupt handler", "[event]")
{
SemaphoreHandle_t sem = xSemaphoreCreateBinary();
}
#endif
-#ifdef CONFIG_EVENT_LOOP_PROFILING
+#ifdef CONFIG_ESP_EVENT_LOOP_PROFILING
TEST_CASE("can dump event loop profile", "[event]")
{
/* this test aims to verify that dumping event loop statistics succeed */
Event loop profiling
--------------------
-A configuration option :ref:`CONFIG_EVENT_LOOP_PROFILING` can be enabled in order to activate statistics collection for all event loops created.
+A configuration option :ref:`CONFIG_ESP_EVENT_LOOP_PROFILING` can be enabled in order to activate statistics collection for all event loops created.
The function :cpp:func:`esp_event_dump` can be used to output the collected statistics to a file stream. More details on the information included in the dump
can be found in the :cpp:func:`esp_event_dump` API Reference.