refactor(system): reformated esp_timer, linux and log comp with astyle

This commit is contained in:
Marius Vikhammer
2024-02-04 14:50:54 +08:00
parent d749575648
commit 77dcb6d46e
19 changed files with 159 additions and 181 deletions

View File

@@ -52,7 +52,6 @@ typedef struct esp_timer* esp_timer_handle_t;
*/ */
typedef void (*esp_timer_cb_t)(void* arg); typedef void (*esp_timer_cb_t)(void* arg);
/** /**
* @brief Method for dispatching timer callback * @brief Method for dispatching timer callback
*/ */
@@ -75,7 +74,6 @@ typedef struct {
bool skip_unhandled_events; //!< Skip unhandled events for periodic timers bool skip_unhandled_events; //!< Skip unhandled events for periodic timers
} esp_timer_create_args_t; } esp_timer_create_args_t;
/** /**
* @brief Minimal initialization of esp_timer * @brief Minimal initialization of esp_timer
* *

View File

@@ -112,7 +112,6 @@ uint64_t esp_timer_impl_get_min_period_us(void);
*/ */
void esp_timer_impl_lock(void); void esp_timer_impl_lock(void);
/** /**
* @brief counterpart of esp_timer_impl_lock * @brief counterpart of esp_timer_impl_lock
*/ */

View File

@@ -1,5 +1,5 @@
/* /*
* SPDX-FileCopyrightText: 2017-2023 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2017-2024 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
@@ -62,8 +62,8 @@ typedef enum {
struct esp_timer { struct esp_timer {
uint64_t alarm; uint64_t alarm;
uint64_t period:56; uint64_t period: 56;
flags_t flags:8; flags_t flags: 8;
union { union {
esp_timer_cb_t callback; esp_timer_cb_t callback;
uint32_t event_id; uint32_t event_id;
@@ -95,13 +95,13 @@ __attribute__((unused)) static const char* TAG = "esp_timer";
// lists of currently armed timers for two dispatch methods: ISR and TASK // lists of currently armed timers for two dispatch methods: ISR and TASK
static LIST_HEAD(esp_timer_list, esp_timer) s_timers[ESP_TIMER_MAX] = { static LIST_HEAD(esp_timer_list, esp_timer) s_timers[ESP_TIMER_MAX] = {
[0 ... (ESP_TIMER_MAX - 1)] = LIST_HEAD_INITIALIZER(s_timers) [0 ...(ESP_TIMER_MAX - 1)] = LIST_HEAD_INITIALIZER(s_timers)
}; };
#if WITH_PROFILING #if WITH_PROFILING
// lists of unarmed timers for two dispatch methods: ISR and TASK, // lists of unarmed timers for two dispatch methods: ISR and TASK,
// used only to be able to dump statistics about all the timers // used only to be able to dump statistics about all the timers
static LIST_HEAD(esp_inactive_timer_list, esp_timer) s_inactive_timers[ESP_TIMER_MAX] = { static LIST_HEAD(esp_inactive_timer_list, esp_timer) s_inactive_timers[ESP_TIMER_MAX] = {
[0 ... (ESP_TIMER_MAX - 1)] = LIST_HEAD_INITIALIZER(s_timers) [0 ...(ESP_TIMER_MAX - 1)] = LIST_HEAD_INITIALIZER(s_timers)
}; };
#endif #endif
// task used to dispatch timer callbacks // task used to dispatch timer callbacks
@@ -109,7 +109,7 @@ static TaskHandle_t s_timer_task;
// lock protecting s_timers, s_inactive_timers // lock protecting s_timers, s_inactive_timers
static portMUX_TYPE s_timer_lock[ESP_TIMER_MAX] = { static portMUX_TYPE s_timer_lock[ESP_TIMER_MAX] = {
[0 ... (ESP_TIMER_MAX - 1)] = portMUX_INITIALIZER_UNLOCKED [0 ...(ESP_TIMER_MAX - 1)] = portMUX_INITIALIZER_UNLOCKED
}; };
#ifdef CONFIG_ESP_TIMER_SUPPORTS_ISR_DISPATCH_METHOD #ifdef CONFIG_ESP_TIMER_SUPPORTS_ISR_DISPATCH_METHOD
@@ -473,7 +473,7 @@ static bool timer_process_alarm(esp_timer_dispatch_t dispatch_method)
static void timer_task(void* arg) static void timer_task(void* arg)
{ {
while (true){ while (true) {
ulTaskNotifyTake(pdTRUE, portMAX_DELAY); ulTaskNotifyTake(pdTRUE, portMAX_DELAY);
// all deferred events are processed at a time // all deferred events are processed at a time
timer_process_alarm(ESP_TIMER_TASK); timer_process_alarm(ESP_TIMER_TASK);
@@ -582,7 +582,6 @@ esp_err_t esp_timer_init(void)
#define ESP_TIMER_INIT_MASK ESP_SYSTEM_INIT_ALL_CORES #define ESP_TIMER_INIT_MASK ESP_SYSTEM_INIT_ALL_CORES
#endif // CONFIG_ESP_TIMER_ISR_AFFINITY_* #endif // CONFIG_ESP_TIMER_ISR_AFFINITY_*
ESP_SYSTEM_INIT_FN(esp_timer_startup_init, SECONDARY, ESP_TIMER_INIT_MASK, 100) ESP_SYSTEM_INIT_FN(esp_timer_startup_init, SECONDARY, ESP_TIMER_INIT_MASK, 100)
{ {
return esp_timer_init(); return esp_timer_init();
@@ -640,7 +639,6 @@ static void print_timer_info(esp_timer_handle_t t, char** dst, size_t* dst_size)
*dst_size -= cb; *dst_size -= cb;
} }
esp_err_t esp_timer_dump(FILE* stream) esp_err_t esp_timer_dump(FILE* stream)
{ {
/* Since timer lock is a critical section, we don't want to print directly /* Since timer lock is a critical section, we don't want to print directly

View File

@@ -38,7 +38,8 @@ void IRAM_ATTR esp_timer_impl_set_alarm(uint64_t timestamp)
} }
#ifdef CONFIG_ESP_TIMER_SUPPORTS_ISR_DISPATCH_METHOD #ifdef CONFIG_ESP_TIMER_SUPPORTS_ISR_DISPATCH_METHOD
void IRAM_ATTR esp_timer_impl_try_to_set_next_alarm(void) { void IRAM_ATTR esp_timer_impl_try_to_set_next_alarm(void)
{
portENTER_CRITICAL_ISR(&s_time_update_lock); portENTER_CRITICAL_ISR(&s_time_update_lock);
unsigned now_alarm_idx; // ISR is called due to this current alarm unsigned now_alarm_idx; // ISR is called due to this current alarm
unsigned next_alarm_idx; // The following alarm after now_alarm_idx unsigned next_alarm_idx; // The following alarm after now_alarm_idx

View File

@@ -1,5 +1,5 @@
/* /*
* SPDX-FileCopyrightText: 2017-2023 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2017-2024 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
@@ -168,7 +168,7 @@ void IRAM_ATTR esp_timer_impl_set_alarm_id(uint64_t timestamp, unsigned alarm_id
// finish if either (alarm > counter) or the interrupt flag is already set. // finish if either (alarm > counter) or the interrupt flag is already set.
break; break;
} }
} while(1); } while (1);
} }
portEXIT_CRITICAL_SAFE(&s_time_update_lock); portEXIT_CRITICAL_SAFE(&s_time_update_lock);
} }

View File

@@ -1,5 +1,5 @@
/* /*
* SPDX-FileCopyrightText: 2017-2023 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2017-2024 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */

View File

@@ -1,5 +1,5 @@
/* /*
* SPDX-FileCopyrightText: 2010-2022 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2010-2024 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
@@ -71,19 +71,18 @@ void ets_timer_setfn(ETSTimer *ptimer, ETSTimerFunc *pfunction, void *parg)
.dispatch_method = ESP_TIMER_TASK .dispatch_method = ESP_TIMER_TASK
}; };
ESP_ERROR_CHECK( esp_timer_create(&create_args, (esp_timer_handle_t*)&(ptimer->timer_arg)) ); ESP_ERROR_CHECK(esp_timer_create(&create_args, (esp_timer_handle_t*) & (ptimer->timer_arg)));
} }
} }
void IRAM_ATTR ets_timer_arm_us(ETSTimer *ptimer, uint32_t time_us, bool repeat_flag) void IRAM_ATTR ets_timer_arm_us(ETSTimer *ptimer, uint32_t time_us, bool repeat_flag)
{ {
assert(timer_initialized(ptimer)); assert(timer_initialized(ptimer));
esp_timer_stop(ESP_TIMER(ptimer)); // no error check esp_timer_stop(ESP_TIMER(ptimer)); // no error check
if (!repeat_flag) { if (!repeat_flag) {
ESP_ERROR_CHECK( esp_timer_start_once(ESP_TIMER(ptimer), time_us) ); ESP_ERROR_CHECK(esp_timer_start_once(ESP_TIMER(ptimer), time_us));
} else { } else {
ESP_ERROR_CHECK( esp_timer_start_periodic(ESP_TIMER(ptimer), time_us) ); ESP_ERROR_CHECK(esp_timer_start_periodic(ESP_TIMER(ptimer), time_us));
} }
} }
@@ -93,9 +92,9 @@ void IRAM_ATTR ets_timer_arm(ETSTimer *ptimer, uint32_t time_ms, bool repeat_fla
assert(timer_initialized(ptimer)); assert(timer_initialized(ptimer));
esp_timer_stop(ESP_TIMER(ptimer)); // no error check esp_timer_stop(ESP_TIMER(ptimer)); // no error check
if (!repeat_flag) { if (!repeat_flag) {
ESP_ERROR_CHECK( esp_timer_start_once(ESP_TIMER(ptimer), time_us) ); ESP_ERROR_CHECK(esp_timer_start_once(ESP_TIMER(ptimer), time_us));
} else { } else {
ESP_ERROR_CHECK( esp_timer_start_periodic(ESP_TIMER(ptimer), time_us) ); ESP_ERROR_CHECK(esp_timer_start_periodic(ESP_TIMER(ptimer), time_us));
} }
} }
@@ -115,7 +114,6 @@ void IRAM_ATTR ets_timer_disarm(ETSTimer *ptimer)
} }
} }
void ets_timer_init(void) void ets_timer_init(void)
{ {
@@ -128,6 +126,6 @@ void ets_timer_deinit(void)
void os_timer_setfn(ETSTimer *ptimer, ETSTimerFunc *pfunction, void *parg) __attribute__((alias("ets_timer_setfn"))); void os_timer_setfn(ETSTimer *ptimer, ETSTimerFunc *pfunction, void *parg) __attribute__((alias("ets_timer_setfn")));
void os_timer_disarm(ETSTimer *ptimer) __attribute__((alias("ets_timer_disarm"))); void os_timer_disarm(ETSTimer *ptimer) __attribute__((alias("ets_timer_disarm")));
void os_timer_arm_us(ETSTimer *ptimer,uint32_t u_seconds,bool repeat_flag) __attribute__((alias("ets_timer_arm_us"))); void os_timer_arm_us(ETSTimer *ptimer, uint32_t u_seconds, bool repeat_flag) __attribute__((alias("ets_timer_arm_us")));
void os_timer_arm(ETSTimer *ptimer,uint32_t milliseconds,bool repeat_flag) __attribute__((alias("ets_timer_arm"))); void os_timer_arm(ETSTimer *ptimer, uint32_t milliseconds, bool repeat_flag) __attribute__((alias("ets_timer_arm")));
void os_timer_done(ETSTimer *ptimer) __attribute__((alias("ets_timer_done"))); void os_timer_done(ETSTimer *ptimer) __attribute__((alias("ets_timer_done")));

View File

@@ -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: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
@@ -23,12 +23,10 @@
#define SEC (1000000) #define SEC (1000000)
#ifdef CONFIG_ESP_TIMER_PROFILING #ifdef CONFIG_ESP_TIMER_PROFILING
#define WITH_PROFILING 1 #define WITH_PROFILING 1
#endif #endif
static void dummy_cb(void* arg) static void dummy_cb(void* arg)
{ {
} }
@@ -37,7 +35,7 @@ TEST_CASE("esp_timer orders timers correctly", "[esp_timer]")
{ {
uint64_t timeouts[] = { 10000, 1000, 10000, 5000, 20000, 1000 }; uint64_t timeouts[] = { 10000, 1000, 10000, 5000, 20000, 1000 };
size_t indices[] = { 3, 0, 4, 2, 5, 1 }; size_t indices[] = { 3, 0, 4, 2, 5, 1 };
const size_t num_timers = sizeof(timeouts)/sizeof(timeouts[0]); const size_t num_timers = sizeof(timeouts) / sizeof(timeouts[0]);
esp_timer_handle_t handles[num_timers]; esp_timer_handle_t handles[num_timers];
char* names[num_timers]; char* names[num_timers];
for (size_t i = 0; i < num_timers; ++i) { for (size_t i = 0; i < num_timers; ++i) {
@@ -96,7 +94,7 @@ static void set_alarm_task(void* arg)
int64_t now = start; int64_t now = start;
int count = 0; int count = 0;
const int delays[] = {50, 5000, 10000000}; const int delays[] = {50, 5000, 10000000};
const int delays_count = sizeof(delays)/sizeof(delays[0]); const int delays_count = sizeof(delays) / sizeof(delays[0]);
while (now - start < test_time_sec * 1000000) { while (now - start < test_time_sec * 1000000) {
now = esp_timer_impl_get_time(); now = esp_timer_impl_get_time();
esp_timer_impl_set_alarm(now + delays[count % delays_count]); esp_timer_impl_set_alarm(now + delays[count % delays_count]);
@@ -139,7 +137,7 @@ TEST_CASE("esp_timer produces correct delay", "[esp_timer]")
TEST_ESP_OK(esp_timer_create(&args, &timer1)); TEST_ESP_OK(esp_timer_create(&args, &timer1));
const int delays_ms[] = {20, 100, 200, 250}; const int delays_ms[] = {20, 100, 200, 250};
const size_t delays_count = sizeof(delays_ms)/sizeof(delays_ms[0]); const size_t delays_count = sizeof(delays_ms) / sizeof(delays_ms[0]);
ref_clock_init(); ref_clock_init();
for (size_t i = 0; i < delays_count; ++i) { for (size_t i = 0; i < delays_count; ++i) {
@@ -157,7 +155,7 @@ TEST_CASE("esp_timer produces correct delay", "[esp_timer]")
} }
ref_clock_deinit(); ref_clock_deinit();
TEST_ESP_OK( esp_timer_dump(stdout) ); TEST_ESP_OK(esp_timer_dump(stdout));
esp_timer_delete(timer1); esp_timer_delete(timer1);
} }
@@ -182,7 +180,7 @@ static void test_periodic_correct_delays_timer_func(void* arg)
p_args->intervals[p_args->cur_interval++] = ms_diff; p_args->intervals[p_args->cur_interval++] = ms_diff;
// Deliberately make timer handler run longer. // Deliberately make timer handler run longer.
// We check that this doesn't affect the result. // We check that this doesn't affect the result.
esp_rom_delay_us(10*1000); esp_rom_delay_us(10 * 1000);
if (p_args->cur_interval == NUM_INTERVALS) { if (p_args->cur_interval == NUM_INTERVALS) {
printf("done\n"); printf("done\n");
TEST_ESP_OK(esp_timer_stop(p_args->timer)); TEST_ESP_OK(esp_timer_stop(p_args->timer));
@@ -214,14 +212,13 @@ TEST_CASE("periodic esp_timer produces correct delays", "[esp_timer]")
TEST_ASSERT_INT32_WITHIN(portTICK_PERIOD_MS, (i + 1) * delay_ms, args.intervals[i]); TEST_ASSERT_INT32_WITHIN(portTICK_PERIOD_MS, (i + 1) * delay_ms, args.intervals[i]);
} }
ref_clock_deinit(); ref_clock_deinit();
TEST_ESP_OK( esp_timer_dump(stdout) ); TEST_ESP_OK(esp_timer_dump(stdout));
TEST_ESP_OK( esp_timer_delete(timer1) ); TEST_ESP_OK(esp_timer_delete(timer1));
vSemaphoreDelete(args.done); vSemaphoreDelete(args.done);
} }
#undef NUM_INTERVALS #undef NUM_INTERVALS
#define N 5 #define N 5
typedef struct { typedef struct {
@@ -306,7 +303,6 @@ TEST_CASE("multiple timers are ordered correctly", "[esp_timer]")
.t_start = now .t_start = now
}; };
esp_timer_create_args_t create_args = { esp_timer_create_args_t create_args = {
.callback = &test_timers_ordered_correctly_timer_func, .callback = &test_timers_ordered_correctly_timer_func,
.arg = &args1, .arg = &args1,
@@ -337,16 +333,16 @@ TEST_CASE("multiple timers are ordered correctly", "[esp_timer]")
ref_clock_deinit(); ref_clock_deinit();
TEST_ESP_OK( esp_timer_dump(stdout) ); TEST_ESP_OK(esp_timer_dump(stdout));
TEST_ESP_OK( esp_timer_delete(args1.timer) ); TEST_ESP_OK(esp_timer_delete(args1.timer));
TEST_ESP_OK( esp_timer_delete(args2.timer) ); TEST_ESP_OK(esp_timer_delete(args2.timer));
TEST_ESP_OK( esp_timer_delete(args3.timer) ); TEST_ESP_OK(esp_timer_delete(args3.timer));
} }
#undef N #undef N
static void test_short_intervals_timer_func(void* arg)
static void test_short_intervals_timer_func(void* arg) { {
SemaphoreHandle_t done = (SemaphoreHandle_t) arg; SemaphoreHandle_t done = (SemaphoreHandle_t) arg;
xSemaphoreGive(done); xSemaphoreGive(done);
printf("."); printf(".");
@@ -367,13 +363,13 @@ TEST_CASE("esp_timer for very short intervals", "[esp_timer]")
}; };
esp_timer_handle_t timer1, timer2; esp_timer_handle_t timer1, timer2;
ESP_ERROR_CHECK( esp_timer_create(&timer_args, &timer1) ); ESP_ERROR_CHECK(esp_timer_create(&timer_args, &timer1));
ESP_ERROR_CHECK( esp_timer_create(&timer_args, &timer2) ); ESP_ERROR_CHECK(esp_timer_create(&timer_args, &timer2));
const int timeout_ms = 10; const int timeout_ms = 10;
for (int timeout_delta_us = -150; timeout_delta_us < 150; timeout_delta_us++) { for (int timeout_delta_us = -150; timeout_delta_us < 150; timeout_delta_us++) {
printf("delta=%d", timeout_delta_us); printf("delta=%d", timeout_delta_us);
ESP_ERROR_CHECK( esp_timer_start_once(timer1, timeout_ms * 1000) ); ESP_ERROR_CHECK(esp_timer_start_once(timer1, timeout_ms * 1000));
ESP_ERROR_CHECK( esp_timer_start_once(timer2, timeout_ms * 1000 + timeout_delta_us) ); ESP_ERROR_CHECK(esp_timer_start_once(timer2, timeout_ms * 1000 + timeout_delta_us));
TEST_ASSERT_EQUAL(pdPASS, xSemaphoreTake(semaphore, timeout_ms * 2)); TEST_ASSERT_EQUAL(pdPASS, xSemaphoreTake(semaphore, timeout_ms * 2));
TEST_ASSERT_EQUAL(pdPASS, xSemaphoreTake(semaphore, timeout_ms * 2)); TEST_ASSERT_EQUAL(pdPASS, xSemaphoreTake(semaphore, timeout_ms * 2));
printf("\n"); printf("\n");
@@ -394,7 +390,7 @@ TEST_CASE("esp_timer_get_time call takes less than 1us", "[esp_timer]")
for (int i = 0; i < iter_count; ++i) { for (int i = 0; i < iter_count; ++i) {
end = esp_timer_get_time(); end = esp_timer_get_time();
} }
int ns_per_call = (int) ((end - begin) * 1000 / iter_count); int ns_per_call = (int)((end - begin) * 1000 / iter_count);
TEST_PERFORMANCE_LESS_THAN(ESP_TIMER_GET_TIME_PER_CALL, "%dns", ns_per_call); TEST_PERFORMANCE_LESS_THAN(ESP_TIMER_GET_TIME_PER_CALL, "%dns", ns_per_call);
} }
@@ -415,7 +411,8 @@ typedef struct {
int64_t dummy; int64_t dummy;
} test_monotonic_values_state_t; } test_monotonic_values_state_t;
static void timer_test_monotonic_values_task(void* arg) { static void timer_test_monotonic_values_task(void* arg)
{
test_monotonic_values_state_t* state = (test_monotonic_values_state_t*) arg; test_monotonic_values_state_t* state = (test_monotonic_values_state_t*) arg;
state->pass = true; state->pass = true;
@@ -455,7 +452,7 @@ static void timer_test_monotonic_values_task(void* arg) {
state->avg_diff /= state->test_cnt; state->avg_diff /= state->test_cnt;
xSemaphoreGive(state->done); xSemaphoreGive(state->done);
vTaskDelete(NULL); vTaskDelete(NULL);
} }
TEST_CASE("esp_timer_get_time returns monotonic values", "[esp_timer]") TEST_CASE("esp_timer_get_time returns monotonic values", "[esp_timer]")
{ {
@@ -469,7 +466,7 @@ TEST_CASE("esp_timer_get_time returns monotonic values", "[esp_timer]")
} }
for (int i = 0; i < portNUM_PROCESSORS; ++i) { for (int i = 0; i < portNUM_PROCESSORS; ++i) {
TEST_ASSERT_TRUE( xSemaphoreTake(done, portMAX_DELAY) ); TEST_ASSERT_TRUE(xSemaphoreTake(done, portMAX_DELAY));
printf("CPU%d: %s test_cnt=%d error_cnt=%d avg_diff=%d |max_error|=%d\n", printf("CPU%d: %s test_cnt=%d error_cnt=%d avg_diff=%d |max_error|=%d\n",
i, states[i].pass ? "PASS" : "FAIL", i, states[i].pass ? "PASS" : "FAIL",
states[i].test_cnt, states[i].error_cnt, states[i].test_cnt, states[i].error_cnt,
@@ -523,7 +520,6 @@ TEST_CASE("Can delete timer from callback", "[esp_timer]")
vSemaphoreDelete(args.notify_from_timer_cb); vSemaphoreDelete(args.notify_from_timer_cb);
} }
typedef struct { typedef struct {
SemaphoreHandle_t delete_start; SemaphoreHandle_t delete_start;
SemaphoreHandle_t delete_done; SemaphoreHandle_t delete_done;
@@ -593,7 +589,8 @@ typedef struct {
int64_t cb_time; int64_t cb_time;
} test_run_when_expected_state_t; } test_run_when_expected_state_t;
static void test_run_when_expected_timer_func(void* varg) { static void test_run_when_expected_timer_func(void* varg)
{
test_run_when_expected_state_t* arg = (test_run_when_expected_state_t*) varg; test_run_when_expected_state_t* arg = (test_run_when_expected_state_t*) varg;
arg->cb_time = ref_clock_get(); arg->cb_time = ref_clock_get();
} }
@@ -668,7 +665,7 @@ TEST_CASE("Can start/stop timer from ISR context", "[esp_timer]")
esp_register_freertos_tick_hook(test_tick_hook); esp_register_freertos_tick_hook(test_tick_hook);
TEST_ASSERT(xSemaphoreTake(sem, portMAX_DELAY)); TEST_ASSERT(xSemaphoreTake(sem, portMAX_DELAY));
esp_deregister_freertos_tick_hook(test_tick_hook); esp_deregister_freertos_tick_hook(test_tick_hook);
TEST_ESP_OK( esp_timer_delete(timer1) ); TEST_ESP_OK(esp_timer_delete(timer1));
vSemaphoreDelete(sem); vSemaphoreDelete(sem);
} }
@@ -750,7 +747,6 @@ TEST_CASE("esp_timer_impl_set_alarm does not set an alarm below the current time
TEST_ASSERT(time_jumped == false); TEST_ASSERT(time_jumped == false);
} }
static esp_timer_handle_t oneshot_timer; static esp_timer_handle_t oneshot_timer;
static void oneshot_timer_callback(void* arg) static void oneshot_timer_callback(void* arg)
@@ -820,7 +816,6 @@ TEST_CASE("Test case when esp_timer_impl_set_alarm needs set timer < now_time",
TEST_ASSERT(alarm_reg <= (count_reg + offset)); TEST_ASSERT(alarm_reg <= (count_reg + offset));
} }
static void timer_callback5(void* arg) static void timer_callback5(void* arg)
{ {
*(int64_t *)arg = esp_timer_get_time(); *(int64_t *)arg = esp_timer_get_time();
@@ -907,8 +902,8 @@ TEST_CASE("periodic esp_timer can be restarted", "[esp_timer]")
/* Check that the alarm was triggered twice */ /* Check that the alarm was triggered twice */
TEST_ASSERT_EQUAL(2, timer_trig); TEST_ASSERT_EQUAL(2, timer_trig);
TEST_ESP_OK( esp_timer_stop(timer1) ); TEST_ESP_OK(esp_timer_stop(timer1));
TEST_ESP_OK( esp_timer_delete(timer1) ); TEST_ESP_OK(esp_timer_delete(timer1));
} }
TEST_CASE("one-shot esp_timer can be restarted", "[esp_timer]") TEST_CASE("one-shot esp_timer can be restarted", "[esp_timer]")
@@ -942,10 +937,9 @@ TEST_CASE("one-shot esp_timer can be restarted", "[esp_timer]")
/* Make sure the timer was triggered */ /* Make sure the timer was triggered */
TEST_ASSERT_EQUAL(0, timer_trig); TEST_ASSERT_EQUAL(0, timer_trig);
TEST_ESP_OK( esp_timer_delete(timer1) ); TEST_ESP_OK(esp_timer_delete(timer1));
} }
#ifdef CONFIG_ESP_TIMER_SUPPORTS_ISR_DISPATCH_METHOD #ifdef CONFIG_ESP_TIMER_SUPPORTS_ISR_DISPATCH_METHOD
static int64_t old_time[2]; static int64_t old_time[2];
@@ -967,7 +961,7 @@ static void timer_isr_callback(void* arg)
TEST_CASE("Test ESP_TIMER_ISR dispatch method", "[esp_timer]") TEST_CASE("Test ESP_TIMER_ISR dispatch method", "[esp_timer]")
{ {
TEST_ESP_OK(esp_timer_dump(stdout)); TEST_ESP_OK(esp_timer_dump(stdout));
int timer[2]= {0, 1}; int timer[2] = {0, 1};
const esp_timer_create_args_t periodic_timer1_args = { const esp_timer_create_args_t periodic_timer1_args = {
.callback = &timer_isr_callback, .callback = &timer_isr_callback,
.dispatch_method = ESP_TIMER_ISR, .dispatch_method = ESP_TIMER_ISR,
@@ -1222,7 +1216,8 @@ volatile uint64_t isr_t1;
const uint64_t period_task_ms = 200; const uint64_t period_task_ms = 200;
const uint64_t period_isr_ms = 20; const uint64_t period_isr_ms = 20;
void task_timer_cb(void *arg) { void task_timer_cb(void *arg)
{
uint64_t t2 = esp_timer_get_time(); uint64_t t2 = esp_timer_get_time();
uint64_t dt_task_ms = (t2 - task_t1) / 1000; uint64_t dt_task_ms = (t2 - task_t1) / 1000;
task_t1 = t2; task_t1 = t2;
@@ -1236,7 +1231,8 @@ void task_timer_cb(void *arg) {
} }
} }
void IRAM_ATTR isr_timer_cb(void *arg) { void IRAM_ATTR isr_timer_cb(void *arg)
{
uint64_t t2 = esp_timer_get_time(); uint64_t t2 = esp_timer_get_time();
uint64_t dt_isr_ms = (t2 - isr_t1) / 1000; uint64_t dt_isr_ms = (t2 - isr_t1) / 1000;
isr_t1 = t2; isr_t1 = t2;

View File

@@ -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: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */

View File

@@ -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: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */

View File

@@ -10,7 +10,6 @@
#include <stdint.h> #include <stdint.h>
#include <unistd.h> #include <unistd.h>
// getrandom() is not available on macOS, so we read from /dev/urandom instead. // getrandom() is not available on macOS, so we read from /dev/urandom instead.
int getrandom(void *buf, size_t buflen, unsigned int flags) int getrandom(void *buf, size_t buflen, unsigned int flags)

View File

@@ -12,13 +12,11 @@
extern "C" { extern "C" {
#endif #endif
/* newlib locks implementation for CONFIG_IDF_TARGET_LINUX, single threaded. /* newlib locks implementation for CONFIG_IDF_TARGET_LINUX, single threaded.
* Note, currently this doesn't implement the functions required * Note, currently this doesn't implement the functions required
* when _RETARGETABLE_LOCKING is defined. They should be added. * when _RETARGETABLE_LOCKING is defined. They should be added.
*/ */
/* Compatibility definitions for legacy newlib locking functions */ /* Compatibility definitions for legacy newlib locking functions */
typedef int _lock_t; typedef int _lock_t;
@@ -39,7 +37,6 @@ static inline int _lock_try_acquire_recursive(_lock_t *plock)
static inline void _lock_release(_lock_t *plock) {} static inline void _lock_release(_lock_t *plock) {}
static inline void _lock_release_recursive(_lock_t *plock) {} static inline void _lock_release_recursive(_lock_t *plock) {}
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@@ -159,7 +159,7 @@ uint32_t esp_log_early_timestamp(void);
* *
* This function or these macros should not be used from an interrupt. * This function or these macros should not be used from an interrupt.
*/ */
void esp_log_write(esp_log_level_t level, const char* tag, const char* format, ...) __attribute__ ((format (printf, 3, 4))); void esp_log_write(esp_log_level_t level, const char* tag, const char* format, ...) __attribute__((format(printf, 3, 4)));
/** /**
* @brief Write message into the log, va_list variant * @brief Write message into the log, va_list variant
@@ -279,7 +279,6 @@ void esp_log_writev(esp_log_level_t level, const char* tag, const char* format,
#define esp_log_buffer_hex ESP_LOG_BUFFER_HEX #define esp_log_buffer_hex ESP_LOG_BUFFER_HEX
#define esp_log_buffer_char ESP_LOG_BUFFER_CHAR #define esp_log_buffer_char ESP_LOG_BUFFER_CHAR
#if CONFIG_LOG_COLORS #if CONFIG_LOG_COLORS
#define LOG_COLOR_BLACK "30" #define LOG_COLOR_BLACK "30"
#define LOG_COLOR_RED "31" #define LOG_COLOR_RED "31"
@@ -523,5 +522,4 @@ void esp_log_writev(esp_log_level_t level, const char* tag, const char* format,
} }
#endif #endif
#endif /* __ESP_LOG_H__ */ #endif /* __ESP_LOG_H__ */

View File

@@ -10,6 +10,6 @@
//these functions do not check level versus ESP_LOCAL_LEVEL, this should be done in esp_log.h //these functions do not check level versus ESP_LOCAL_LEVEL, this should be done in esp_log.h
void esp_log_buffer_hex_internal(const char *tag, const void *buffer, uint16_t buff_len, esp_log_level_t level); void esp_log_buffer_hex_internal(const char *tag, const void *buffer, uint16_t buff_len, esp_log_level_t level);
void esp_log_buffer_char_internal(const char *tag, const void *buffer, uint16_t buff_len, esp_log_level_t level); void esp_log_buffer_char_internal(const char *tag, const void *buffer, uint16_t buff_len, esp_log_level_t level);
void esp_log_buffer_hexdump_internal( const char *tag, const void *buffer, uint16_t buff_len, esp_log_level_t log_level); void esp_log_buffer_hexdump_internal(const char *tag, const void *buffer, uint16_t buff_len, esp_log_level_t log_level);
#endif #endif

View File

@@ -1,5 +1,5 @@
/* /*
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
@@ -76,7 +76,6 @@ static vprintf_like_t s_log_print_func = &vprintf;
static uint32_t s_log_cache_misses = 0; static uint32_t s_log_cache_misses = 0;
#endif #endif
static inline bool get_cached_log_level(const char *tag, esp_log_level_t *level); static inline bool get_cached_log_level(const char *tag, esp_log_level_t *level);
static inline bool get_uncached_log_level(const char *tag, esp_log_level_t *level); static inline bool get_uncached_log_level(const char *tag, esp_log_level_t *level);
static inline void add_to_cache(const char *tag, esp_log_level_t level); static inline void add_to_cache(const char *tag, esp_log_level_t level);
@@ -156,7 +155,6 @@ void esp_log_level_set(const char *tag, esp_log_level_t level)
esp_log_impl_unlock(); esp_log_impl_unlock();
} }
/* Common code for getting the log level from cache, esp_log_impl_lock() /* Common code for getting the log level from cache, esp_log_impl_lock()
should be called before calling this function. The function unlocks, should be called before calling this function. The function unlocks,
as indicated in the name. as indicated in the name.

View File

@@ -13,7 +13,8 @@
#ifndef CONFIG_IDF_TARGET_LINUX #ifndef CONFIG_IDF_TARGET_LINUX
#include "esp_memory_utils.h" // for esp_ptr_byte_accessible #include "esp_memory_utils.h" // for esp_ptr_byte_accessible
#else #else
static inline bool esp_ptr_byte_accessible(const void* ptr) { static inline bool esp_ptr_byte_accessible(const void* ptr)
{
(void) ptr; (void) ptr;
return true; return true;
} }

View File

@@ -15,7 +15,6 @@
#include "esp_log.h" #include "esp_log.h"
#include "esp_log_private.h" #include "esp_log_private.h"
// Maximum time to wait for the mutex in a logging statement. // Maximum time to wait for the mutex in a logging statement.
// //
// We don't expect this to happen in most cases, as contention is low. The most likely case is if a // We don't expect this to happen in most cases, as contention is low. The most likely case is if a

View File

@@ -13,7 +13,6 @@
#include "esp_timer.h" #include "esp_timer.h"
#include "sdkconfig.h" #include "sdkconfig.h"
static const char * TAG = "log_test"; static const char * TAG = "log_test";
static int calc_time_of_logging(int iterations) static int calc_time_of_logging(int iterations)

View File

@@ -68,7 +68,6 @@ components_not_formatted_temporary:
- "/components/esp_phy/" - "/components/esp_phy/"
- "/components/esp_pm/" - "/components/esp_pm/"
- "/components/esp_rom/" - "/components/esp_rom/"
- "/components/esp_timer/"
- "/components/esp_wifi/" - "/components/esp_wifi/"
- "/components/esp-tls/" - "/components/esp-tls/"
- "/components/espcoredump/" - "/components/espcoredump/"
@@ -80,8 +79,6 @@ components_not_formatted_temporary:
- "/components/idf_test/" - "/components/idf_test/"
- "/components/ieee802154/" - "/components/ieee802154/"
- "/components/json/" - "/components/json/"
- "/components/linux/"
- "/components/log/"
- "/components/lwip/" - "/components/lwip/"
- "/components/mbedtls/" - "/components/mbedtls/"
- "/components/mqtt/" - "/components/mqtt/"