mirror of
https://github.com/espressif/esp-idf.git
synced 2025-11-23 03:39:33 +00:00
gptimer: unify clock setting with clk_tree API
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -134,11 +134,15 @@ TEST_CASE("gptimer_wallclock_with_various_clock_sources", "[gptimer]")
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Delta of the timer count after the triggering of the alarm. Delta must be sufficient large to account for the latency
|
||||
between the alarm triggering and the execution of the callback that actually stops the gptimer.
|
||||
*/
|
||||
#define GPTIMER_STOP_ON_ALARM_COUNT_DELTA 50
|
||||
/**
|
||||
* @note Delta of the timer count after the triggering of the alarm. Delta must be sufficient large to account for the latency
|
||||
* between the alarm triggering and the execution of the callback that actually stops the gptimer.
|
||||
*/
|
||||
#if CONFIG_PM_ENABLE
|
||||
#define GPTIMER_STOP_ON_ALARM_COUNT_DELTA 100
|
||||
#else
|
||||
#define GPTIMER_STOP_ON_ALARM_COUNT_DELTA 50
|
||||
#endif // CONFIG_PM_ENABLE
|
||||
|
||||
TEST_ALARM_CALLBACK_ATTR static bool test_gptimer_alarm_stop_callback(gptimer_handle_t timer, const gptimer_alarm_event_data_t *edata, void *user_data)
|
||||
{
|
||||
@@ -215,11 +219,15 @@ TEST_CASE("gptimer_stop_on_alarm", "[gptimer]")
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Delta of the timer count after the triggering of the alarm. Delta must be sufficient large to account for the latency
|
||||
between the alarm triggering and the capturing of the counter's value in the subsequent ISR.
|
||||
*/
|
||||
#define GPTIMER_AUTO_RELOAD_ON_ALARM_COUNT_DELTA 30
|
||||
/**
|
||||
* @note Delta of the timer count after the triggering of the alarm. Delta must be sufficient large to account for the latency
|
||||
* between the alarm triggering and the capturing of the counter's value in the subsequent ISR.
|
||||
*/
|
||||
#if CONFIG_PM_ENABLE
|
||||
#define GPTIMER_AUTO_RELOAD_ON_ALARM_COUNT_DELTA 200
|
||||
#else
|
||||
#define GPTIMER_AUTO_RELOAD_ON_ALARM_COUNT_DELTA 30
|
||||
#endif // CONFIG_PM_ENABLE
|
||||
|
||||
TEST_ALARM_CALLBACK_ATTR static bool test_gptimer_alarm_reload_callback(gptimer_handle_t timer, const gptimer_alarm_event_data_t *edata, void *user_data)
|
||||
{
|
||||
@@ -275,6 +283,7 @@ TEST_CASE("gptimer_auto_reload_on_alarm", "[gptimer]")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
TEST_ALARM_CALLBACK_ATTR static bool test_gptimer_alarm_normal_callback(gptimer_handle_t timer, const gptimer_alarm_event_data_t *edata, void *user_data)
|
||||
{
|
||||
TaskHandle_t task_handle = (TaskHandle_t)user_data;
|
||||
@@ -285,6 +294,17 @@ TEST_ALARM_CALLBACK_ATTR static bool test_gptimer_alarm_normal_callback(gptimer_
|
||||
return high_task_wakeup == pdTRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @note Delta of the timer count after the triggering of the alarm. Delta must be sufficient large to account for the latency
|
||||
* between the alarm triggering and the capturing of the counter's value in the subsequent ISR.
|
||||
* Also should account for the inaccuracy of the systick during DFS.
|
||||
*/
|
||||
#if CONFIG_PM_ENABLE
|
||||
#define GPTIMER_ONE_SHOT_ALARM_COUNT_DELTA 15000
|
||||
#else
|
||||
#define GPTIMER_ONE_SHOT_ALARM_COUNT_DELTA 1000
|
||||
#endif // CONFIG_PM_ENABLE
|
||||
|
||||
TEST_CASE("gptimer_one_shot_alarm", "[gptimer]")
|
||||
{
|
||||
TaskHandle_t task_handle = xTaskGetCurrentTaskHandle();
|
||||
@@ -319,7 +339,7 @@ TEST_CASE("gptimer_one_shot_alarm", "[gptimer]")
|
||||
// the alarm is stopped, but the counter should still work
|
||||
uint64_t value = 0;
|
||||
TEST_ESP_OK(gptimer_get_raw_count(timers[i], &value));
|
||||
TEST_ASSERT_UINT_WITHIN(1000, 1100000, value); // 1100000 = 100ms alarm + 1s delay
|
||||
TEST_ASSERT_UINT_WITHIN(GPTIMER_ONE_SHOT_ALARM_COUNT_DELTA, 1100000, value); // 1100000 = 100ms alarm + 1s delay
|
||||
TEST_ESP_OK(gptimer_stop(timers[i]));
|
||||
}
|
||||
|
||||
@@ -403,11 +423,15 @@ TEST_CASE("gptimer_update_alarm_dynamically", "[gptimer]")
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Delta of the timer count after the triggering of the alarm. Delta must be sufficient large to account for the latency
|
||||
between the alarm triggering and the capturing of the counter's value in the subsequent ISR.
|
||||
*/
|
||||
#define GPTIMER_COUNT_DOWN_RELOAD_DELTA 30
|
||||
/**
|
||||
* @noteDelta of the timer count after the triggering of the alarm. Delta must be sufficient large to account for the latency
|
||||
* between the alarm triggering and the capturing of the counter's value in the subsequent ISR.
|
||||
*/
|
||||
#if CONFIG_PM_ENABLE
|
||||
#define GPTIMER_COUNT_DOWN_RELOAD_DELTA 200
|
||||
#else
|
||||
#define GPTIMER_COUNT_DOWN_RELOAD_DELTA 30
|
||||
#endif // CONFIG_PM_ENABLE
|
||||
|
||||
TEST_ALARM_CALLBACK_ATTR static bool test_gptimer_count_down_reload_alarm_callback(gptimer_handle_t timer, const gptimer_alarm_event_data_t *edata, void *user_data)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user