drivers: counter: systimer: esp32c2: Fix clock parameters
Fix clock source frequency for systimer and GP timer. Signed-off-by: Raffael Rostagno <raffael.rostagno@espressif.com>
This commit is contained in:
parent
cf367686f6
commit
4be1897519
2 changed files with 18 additions and 7 deletions
|
@ -256,6 +256,13 @@ static void counter_esp32_isr(void *arg)
|
|||
timer_ll_clear_intr_status(data->hal_ctx.dev, TIMER_LL_EVENT_ALARM(data->hal_ctx.timer_id));
|
||||
}
|
||||
|
||||
#if defined(CONFIG_SOC_SERIES_ESP32C2)
|
||||
#define CLK_LL_PLL_40M_FREQ MHZ(40)
|
||||
#define CLOCK_SOURCE_FREQ CLK_LL_PLL_40M_FREQ
|
||||
#else
|
||||
#define CLOCK_SOURCE_FREQ APB_CLK_FREQ
|
||||
#endif
|
||||
|
||||
#define ESP32_COUNTER_GET_CLK_DIV(idx) \
|
||||
(((DT_INST_PROP(idx, prescaler) & UINT16_MAX) < 2) ? \
|
||||
2 : (DT_INST_PROP(idx, prescaler) & UINT16_MAX))
|
||||
|
@ -265,11 +272,11 @@ static void counter_esp32_isr(void *arg)
|
|||
static struct counter_esp32_data counter_data_##idx; \
|
||||
\
|
||||
static const struct counter_esp32_config counter_config_##idx = { \
|
||||
.counter_info = { \
|
||||
.max_top_value = UINT32_MAX, \
|
||||
.freq = (APB_CLK_FREQ / ESP32_COUNTER_GET_CLK_DIV(idx)), \
|
||||
.flags = COUNTER_CONFIG_INFO_COUNT_UP, \
|
||||
.channels = 1 \
|
||||
.counter_info = { \
|
||||
.max_top_value = UINT32_MAX, \
|
||||
.freq = (CLOCK_SOURCE_FREQ / ESP32_COUNTER_GET_CLK_DIV(idx)), \
|
||||
.flags = COUNTER_CONFIG_INFO_COUNT_UP, \
|
||||
.channels = 1 \
|
||||
}, \
|
||||
.config = { \
|
||||
.alarm_en = TIMER_ALARM_DIS, \
|
||||
|
|
|
@ -21,9 +21,13 @@ config ISR_STACK_SIZE
|
|||
config ATOMIC_OPERATIONS_C
|
||||
default y
|
||||
|
||||
config XTAL_FREQ_HZ
|
||||
int
|
||||
default $(dt_node_int_prop_int,/cpus/cpu@0,xtal-freq)
|
||||
|
||||
config SYS_CLOCK_HW_CYCLES_PER_SEC
|
||||
default 12000000 if SOC_SERIES_ESP32C2
|
||||
default 16000000 if SOC_SERIES_ESP32C3 || SOC_SERIES_ESP32C6
|
||||
default 10400000 if XTAL_FREQ_HZ = 26000000
|
||||
default 16000000 if XTAL_FREQ_HZ = 40000000
|
||||
|
||||
config SYS_CLOCK_TICKS_PER_SEC
|
||||
default 1000
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue