mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
refactor(system): reformated esp_timer, linux and log comp with astyle
This commit is contained in:
parent
d749575648
commit
77dcb6d46e
@ -52,7 +52,6 @@ typedef struct esp_timer* esp_timer_handle_t;
|
||||
*/
|
||||
typedef void (*esp_timer_cb_t)(void* arg);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Method for dispatching timer callback
|
||||
*/
|
||||
@ -75,7 +74,6 @@ typedef struct {
|
||||
bool skip_unhandled_events; //!< Skip unhandled events for periodic timers
|
||||
} esp_timer_create_args_t;
|
||||
|
||||
|
||||
/**
|
||||
* @brief Minimal initialization of esp_timer
|
||||
*
|
||||
|
@ -112,7 +112,6 @@ uint64_t esp_timer_impl_get_min_period_us(void);
|
||||
*/
|
||||
void esp_timer_impl_lock(void);
|
||||
|
||||
|
||||
/**
|
||||
* @brief counterpart of esp_timer_impl_lock
|
||||
*/
|
||||
|
@ -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
|
||||
*/
|
||||
@ -582,7 +582,6 @@ esp_err_t esp_timer_init(void)
|
||||
#define ESP_TIMER_INIT_MASK ESP_SYSTEM_INIT_ALL_CORES
|
||||
#endif // CONFIG_ESP_TIMER_ISR_AFFINITY_*
|
||||
|
||||
|
||||
ESP_SYSTEM_INIT_FN(esp_timer_startup_init, SECONDARY, ESP_TIMER_INIT_MASK, 100)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
esp_err_t esp_timer_dump(FILE* stream)
|
||||
{
|
||||
/* Since timer lock is a critical section, we don't want to print directly
|
||||
|
@ -38,7 +38,8 @@ void IRAM_ATTR esp_timer_impl_set_alarm(uint64_t timestamp)
|
||||
}
|
||||
|
||||
#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);
|
||||
unsigned now_alarm_idx; // ISR is called due to this current alarm
|
||||
unsigned next_alarm_idx; // The following alarm after now_alarm_idx
|
||||
|
@ -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
|
||||
*/
|
||||
|
@ -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
|
||||
*/
|
||||
|
@ -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
|
||||
*/
|
||||
@ -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)
|
||||
{
|
||||
assert(timer_initialized(ptimer));
|
||||
@ -115,7 +114,6 @@ void IRAM_ATTR ets_timer_disarm(ETSTimer *ptimer)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ets_timer_init(void)
|
||||
{
|
||||
|
||||
|
@ -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
|
||||
*/
|
||||
@ -23,12 +23,10 @@
|
||||
|
||||
#define SEC (1000000)
|
||||
|
||||
|
||||
#ifdef CONFIG_ESP_TIMER_PROFILING
|
||||
#define WITH_PROFILING 1
|
||||
#endif
|
||||
|
||||
|
||||
static void dummy_cb(void* arg)
|
||||
{
|
||||
}
|
||||
@ -221,7 +219,6 @@ TEST_CASE("periodic esp_timer produces correct delays", "[esp_timer]")
|
||||
}
|
||||
#undef NUM_INTERVALS
|
||||
|
||||
|
||||
#define N 5
|
||||
|
||||
typedef struct {
|
||||
@ -306,7 +303,6 @@ TEST_CASE("multiple timers are ordered correctly", "[esp_timer]")
|
||||
.t_start = now
|
||||
};
|
||||
|
||||
|
||||
esp_timer_create_args_t create_args = {
|
||||
.callback = &test_timers_ordered_correctly_timer_func,
|
||||
.arg = &args1,
|
||||
@ -345,8 +341,8 @@ TEST_CASE("multiple timers are ordered correctly", "[esp_timer]")
|
||||
}
|
||||
#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;
|
||||
xSemaphoreGive(done);
|
||||
printf(".");
|
||||
@ -415,7 +411,8 @@ typedef struct {
|
||||
int64_t dummy;
|
||||
} 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;
|
||||
state->pass = true;
|
||||
|
||||
@ -523,7 +520,6 @@ TEST_CASE("Can delete timer from callback", "[esp_timer]")
|
||||
vSemaphoreDelete(args.notify_from_timer_cb);
|
||||
}
|
||||
|
||||
|
||||
typedef struct {
|
||||
SemaphoreHandle_t delete_start;
|
||||
SemaphoreHandle_t delete_done;
|
||||
@ -593,7 +589,8 @@ typedef struct {
|
||||
int64_t cb_time;
|
||||
} 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;
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
static esp_timer_handle_t oneshot_timer;
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
|
||||
static void timer_callback5(void* arg)
|
||||
{
|
||||
*(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));
|
||||
}
|
||||
|
||||
|
||||
#ifdef CONFIG_ESP_TIMER_SUPPORTS_ISR_DISPATCH_METHOD
|
||||
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_isr_ms = 20;
|
||||
|
||||
void task_timer_cb(void *arg) {
|
||||
void task_timer_cb(void *arg)
|
||||
{
|
||||
uint64_t t2 = esp_timer_get_time();
|
||||
uint64_t dt_task_ms = (t2 - task_t1) / 1000;
|
||||
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 dt_isr_ms = (t2 - isr_t1) / 1000;
|
||||
isr_t1 = t2;
|
||||
|
@ -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
|
||||
*/
|
||||
|
@ -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
|
||||
*/
|
||||
|
@ -10,7 +10,6 @@
|
||||
#include <stdint.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
// getrandom() is not available on macOS, so we read from /dev/urandom instead.
|
||||
|
||||
int getrandom(void *buf, size_t buflen, unsigned int flags)
|
||||
|
@ -12,13 +12,11 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* newlib locks implementation for CONFIG_IDF_TARGET_LINUX, single threaded.
|
||||
* Note, currently this doesn't implement the functions required
|
||||
* when _RETARGETABLE_LOCKING is defined. They should be added.
|
||||
*/
|
||||
|
||||
|
||||
/* Compatibility definitions for legacy newlib locking functions */
|
||||
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_recursive(_lock_t *plock) {}
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -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_char ESP_LOG_BUFFER_CHAR
|
||||
|
||||
|
||||
#if CONFIG_LOG_COLORS
|
||||
#define LOG_COLOR_BLACK "30"
|
||||
#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 /* __ESP_LOG_H__ */
|
||||
|
@ -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
|
||||
*/
|
||||
@ -76,7 +76,6 @@ static vprintf_like_t s_log_print_func = &vprintf;
|
||||
static uint32_t s_log_cache_misses = 0;
|
||||
#endif
|
||||
|
||||
|
||||
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 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();
|
||||
}
|
||||
|
||||
|
||||
/* Common code for getting the log level from cache, esp_log_impl_lock()
|
||||
should be called before calling this function. The function unlocks,
|
||||
as indicated in the name.
|
||||
|
@ -13,7 +13,8 @@
|
||||
#ifndef CONFIG_IDF_TARGET_LINUX
|
||||
#include "esp_memory_utils.h" // for esp_ptr_byte_accessible
|
||||
#else
|
||||
static inline bool esp_ptr_byte_accessible(const void* ptr) {
|
||||
static inline bool esp_ptr_byte_accessible(const void* ptr)
|
||||
{
|
||||
(void) ptr;
|
||||
return true;
|
||||
}
|
||||
|
@ -15,7 +15,6 @@
|
||||
#include "esp_log.h"
|
||||
#include "esp_log_private.h"
|
||||
|
||||
|
||||
// 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
|
||||
|
@ -13,7 +13,6 @@
|
||||
#include "esp_timer.h"
|
||||
#include "sdkconfig.h"
|
||||
|
||||
|
||||
static const char * TAG = "log_test";
|
||||
|
||||
static int calc_time_of_logging(int iterations)
|
||||
|
@ -68,7 +68,6 @@ components_not_formatted_temporary:
|
||||
- "/components/esp_phy/"
|
||||
- "/components/esp_pm/"
|
||||
- "/components/esp_rom/"
|
||||
- "/components/esp_timer/"
|
||||
- "/components/esp_wifi/"
|
||||
- "/components/esp-tls/"
|
||||
- "/components/espcoredump/"
|
||||
@ -80,8 +79,6 @@ components_not_formatted_temporary:
|
||||
- "/components/idf_test/"
|
||||
- "/components/ieee802154/"
|
||||
- "/components/json/"
|
||||
- "/components/linux/"
|
||||
- "/components/log/"
|
||||
- "/components/lwip/"
|
||||
- "/components/mbedtls/"
|
||||
- "/components/mqtt/"
|
||||
|
Loading…
Reference in New Issue
Block a user