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
*/ */
@@ -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
*/ */

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
*/ */
@@ -75,7 +75,6 @@ void ets_timer_setfn(ETSTimer *ptimer, ETSTimerFunc *pfunction, void *parg)
} }
} }
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));
@@ -115,7 +114,6 @@ void IRAM_ATTR ets_timer_disarm(ETSTimer *ptimer)
} }
} }
void ets_timer_init(void) void ets_timer_init(void)
{ {

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)
{ {
} }
@@ -221,7 +219,6 @@ TEST_CASE("periodic esp_timer produces correct delays", "[esp_timer]")
} }
#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,
@@ -345,8 +341,8 @@ TEST_CASE("multiple timers are ordered correctly", "[esp_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(".");
@@ -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;
@@ -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();
} }
@@ -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();
@@ -945,7 +940,6 @@ TEST_CASE("one-shot esp_timer can be restarted", "[esp_timer]")
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];
@@ -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

@@ -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

@@ -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/"