Files
esp-idf/tools/unit-test-app/components/test_utils/ref_clock_impl_timergroup.c
T

39 lines
920 B
C
Raw Normal View History

2021-09-27 12:46:51 +08:00
/*
* SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD
2021-09-27 12:46:51 +08:00
*
* SPDX-License-Identifier: Apache-2.0
*/
2020-11-06 15:00:07 +11:00
#include "test_utils.h"
#include "unity_config.h"
#include "driver/gptimer.h"
2020-11-06 15:00:07 +11:00
static gptimer_handle_t ts_gptimer;
2020-11-06 15:00:07 +11:00
void ref_clock_init(void)
{
gptimer_config_t timer_config = {
.clk_src = GPTIMER_CLK_SRC_XTAL,
.direction = GPTIMER_COUNT_UP,
.resolution_hz = 1000000, // Resolution is configured to 1MHz
};
TEST_ESP_OK(gptimer_new_timer(&timer_config, &ts_gptimer));
2022-04-23 18:59:38 +08:00
TEST_ESP_OK(gptimer_enable(ts_gptimer));
TEST_ESP_OK(gptimer_start(ts_gptimer));
2020-11-06 15:00:07 +11:00
}
void ref_clock_deinit(void)
{
TEST_ESP_OK(gptimer_stop(ts_gptimer));
2022-04-23 18:59:38 +08:00
TEST_ESP_OK(gptimer_disable(ts_gptimer));
TEST_ESP_OK(gptimer_del_timer(ts_gptimer));
ts_gptimer = NULL;
2020-11-06 15:00:07 +11:00
}
uint64_t ref_clock_get(void)
{
uint64_t ts;
gptimer_get_raw_count(ts_gptimer, &ts);
return ts;
2020-11-06 15:00:07 +11:00
}