mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
esp_system: test system time for rtc compensation
This commit is contained in:
parent
74de5a7c58
commit
131bbbd5c4
36
components/esp_system/test/test_system_time.c
Normal file
36
components/esp_system/test/test_system_time.c
Normal file
@ -0,0 +1,36 @@
|
||||
#include <stdio.h>
|
||||
#include "unity.h"
|
||||
|
||||
#include "esp_private/system_internal.h"
|
||||
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
#include "esp32/clk.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32S2
|
||||
#include "esp32s2/clk.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32S3
|
||||
#include "esp32s3/clk.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||
#include "esp32c3/clk.h"
|
||||
#endif
|
||||
|
||||
TEST_CASE("Test effect of rtc clk calibration compensation on system time", "[esp_system]")
|
||||
{
|
||||
uint32_t prev_cal = esp_clk_slowclk_cal_get();
|
||||
int64_t t1 = esp_system_get_time();
|
||||
|
||||
// Modify calibration value
|
||||
esp_clk_slowclk_cal_set(prev_cal/2);
|
||||
|
||||
// Internally, the origin point of rtc clk has been adjusted
|
||||
// so that t2 > t1 remains true
|
||||
int64_t t2 = esp_system_get_time();
|
||||
|
||||
TEST_ASSERT_GREATER_THAN(t1, t2);
|
||||
|
||||
// Restore calibration value
|
||||
esp_clk_slowclk_cal_set(prev_cal);
|
||||
|
||||
t2 = esp_system_get_time();
|
||||
|
||||
TEST_ASSERT_GREATER_THAN(t1, t2);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user