diff --git a/components/hal/esp32/include/hal/timer_ll.h b/components/hal/esp32/include/hal/timer_ll.h index 447f3fded9..8705005ca1 100644 --- a/components/hal/esp32/include/hal/timer_ll.h +++ b/components/hal/esp32/include/hal/timer_ll.h @@ -43,11 +43,9 @@ _Static_assert(TIMER_INTR_WDT == TIMG_WDT_INT_CLR, "Add mapping to LL interrupt */ static inline void timer_ll_set_divider(timg_dev_t *hw, timer_idx_t timer_num, uint32_t divider) { - // refer to TRM 18.2.1 - if (divider == 65536) { + assert(divider >= 2 && divider <= 65536); + if (divider >= 65536) { divider = 0; - } else if (divider == 1) { - divider = 2; } int timer_en = hw->hw_timer[timer_num].config.enable; hw->hw_timer[timer_num].config.enable = 0; diff --git a/components/hal/esp32c3/include/hal/timer_ll.h b/components/hal/esp32c3/include/hal/timer_ll.h index edadee14e3..f3880b9a59 100644 --- a/components/hal/esp32c3/include/hal/timer_ll.h +++ b/components/hal/esp32c3/include/hal/timer_ll.h @@ -45,10 +45,15 @@ typedef struct { * * @return None */ -static inline void timer_ll_set_divider(timg_dev_t *hw, timer_idx_t timer_num, uint16_t divider) +static inline void timer_ll_set_divider(timg_dev_t *hw, timer_idx_t timer_num, uint32_t divider) { + assert(divider >= 2 && divider <= 65536); + if (divider >= 65536) { + divider = 0; + } int timer_en = hw->hw_timer[timer_num].config.enable; hw->hw_timer[timer_num].config.enable = 0; + hw->hw_timer[timer_num].config.divcnt_rst = 1; hw->hw_timer[timer_num].config.divider = divider; hw->hw_timer[timer_num].config.enable = timer_en; } @@ -67,6 +72,8 @@ static inline void timer_ll_get_divider(timg_dev_t *hw, timer_idx_t timer_num, u uint32_t d = hw->hw_timer[timer_num].config.divider; if (d == 0) { d = 65536; + } else if (d == 1) { + d = 2; } *divider = d; } diff --git a/components/hal/esp32s2/include/hal/timer_ll.h b/components/hal/esp32s2/include/hal/timer_ll.h index 3e8bc1930f..ceaa76a3b5 100644 --- a/components/hal/esp32s2/include/hal/timer_ll.h +++ b/components/hal/esp32s2/include/hal/timer_ll.h @@ -43,8 +43,8 @@ _Static_assert(TIMER_INTR_WDT == TIMG_WDT_INT_CLR, "Add mapping to LL interrupt */ static inline void timer_ll_set_divider(timg_dev_t *hw, timer_idx_t timer_num, uint32_t divider) { - // refer to TRM 12.2.1 - if (divider == 65536) { + assert(divider >= 2 && divider <= 65536); + if (divider >= 65536) { divider = 0; } int timer_en = hw->hw_timer[timer_num].config.enable; @@ -67,6 +67,8 @@ static inline void timer_ll_get_divider(timg_dev_t *hw, timer_idx_t timer_num, u uint32_t d = hw->hw_timer[timer_num].config.divider; if (d == 0) { d = 65536; + } else if (d == 1) { + d = 2; } *divider = d; } diff --git a/components/hal/esp32s3/include/hal/timer_ll.h b/components/hal/esp32s3/include/hal/timer_ll.h index 994cb48faf..ad002683c3 100644 --- a/components/hal/esp32s3/include/hal/timer_ll.h +++ b/components/hal/esp32s3/include/hal/timer_ll.h @@ -46,8 +46,12 @@ typedef struct { * * @return None */ -static inline void timer_ll_set_divider(timg_dev_t *hw, timer_idx_t timer_num, uint16_t divider) +static inline void timer_ll_set_divider(timg_dev_t *hw, timer_idx_t timer_num, uint32_t divider) { + assert(divider >= 2 && divider <= 65536); + if (divider >= 65536) { + divider = 0; + } int timer_en = hw->hw_timer[timer_num].config.enable; hw->hw_timer[timer_num].config.enable = 0; hw->hw_timer[timer_num].config.divider = divider; @@ -68,6 +72,8 @@ static inline void timer_ll_get_divider(timg_dev_t *hw, timer_idx_t timer_num, u uint32_t d = hw->hw_timer[timer_num].config.divider; if (d == 0) { d = 65536; + } else if (d == 1) { + d = 2; } *divider = d; } @@ -326,16 +332,7 @@ FORCE_INLINE_ATTR void timer_ll_get_intr_raw_status(timer_group_t group_num, uin */ static inline void timer_ll_set_level_int_enable(timg_dev_t *hw, timer_idx_t timer_num, bool level_int_en) { - switch (timer_num) { - case 0: - hw->int_ena.t0 = level_int_en; - break; - case 1: - hw->int_ena.t1 = level_int_en; - break; - default: - break; - } + // Only "level" interrupts are supported on this target } /** @@ -350,18 +347,7 @@ static inline void timer_ll_set_level_int_enable(timg_dev_t *hw, timer_idx_t tim */ static inline bool timer_ll_get_level_int_enable(timg_dev_t *hw, timer_idx_t timer_num) { - bool enable = false; - switch (timer_num) { - case 0: - enable = hw->int_ena.t0; - break; - case 1: - enable = hw->int_ena.t1; - break; - default: - break; - } - return enable; + return true; } /** diff --git a/components/soc/esp32/include/soc/soc_caps.h b/components/soc/esp32/include/soc/soc_caps.h index 51ecd22ce3..64425c570e 100644 --- a/components/soc/esp32/include/soc/soc_caps.h +++ b/components/soc/esp32/include/soc/soc_caps.h @@ -205,12 +205,10 @@ #define SOC_SPI_PERIPH_SUPPORT_MULTILINE_MODE(spi_host) ({(void)spi_host; 1;}) /*-------------------------- TIMER GROUP CAPS --------------------------------*/ -#define SOC_TIMER_GROUP_COUNTER_BIT_WIDTH (64) -#define SOC_TIMER_GROUP_PRESCALE_BIT_WIDTH (16) -#define SOC_TIMER_GROUPS (2) -#define SOC_TIMER_GROUP_TIMERS_PER_GROUP (2) +#define SOC_TIMER_GROUPS (2) +#define SOC_TIMER_GROUP_TIMERS_PER_GROUP (2) +#define SOC_TIMER_GROUP_COUNTER_BIT_WIDTH (64) #define SOC_TIMER_GROUP_TOTAL_TIMERS (SOC_TIMER_GROUPS * SOC_TIMER_GROUP_TIMERS_PER_GROUP) -#define SOC_TIMER_GROUP_LAYOUT {2,2} /*-------------------------- TOUCH SENSOR CAPS -------------------------------*/ #define SOC_TOUCH_SENSOR_NUM (10) diff --git a/components/soc/esp32c3/include/soc/soc_caps.h b/components/soc/esp32c3/include/soc/soc_caps.h index 0f271bf36f..fe908b89c1 100644 --- a/components/soc/esp32c3/include/soc/soc_caps.h +++ b/components/soc/esp32c3/include/soc/soc_caps.h @@ -26,7 +26,6 @@ #include "i2s_caps.h" #include "rtc_io_caps.h" #include "soc_caps.h" -#include "timer_group_caps.h" #include "cpu_caps.h" #include "gpio_caps.h" #include "ledc_caps.h" @@ -76,6 +75,12 @@ #define SOC_SHA_SUPPORT_SHA224 (1) #define SOC_SHA_SUPPORT_SHA256 (1) +/*--------------------------- TIMER GROUP CAPS ---------------------------------------*/ +#define SOC_TIMER_GROUPS (2) +#define SOC_TIMER_GROUP_TIMERS_PER_GROUP (1) +#define SOC_TIMER_GROUP_COUNTER_BIT_WIDTH (54) +#define SOC_TIMER_GROUP_SUPPORT_XTAL (1) +#define SOC_TIMER_GROUP_TOTAL_TIMERS (SOC_TIMER_GROUPS * SOC_TIMER_GROUP_TIMERS_PER_GROUP) /*--------------------------- RMT CAPS ---------------------------------------*/ #define SOC_RMT_GROUPS (1) /*!< One RMT group */ diff --git a/components/soc/esp32c3/include/soc/timer_group_caps.h b/components/soc/esp32c3/include/soc/timer_group_caps.h deleted file mode 100644 index b827b0005e..0000000000 --- a/components/soc/esp32c3/include/soc/timer_group_caps.h +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2020 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#pragma once - -#define SOC_TIMER_GROUP_SUPPORT_XTAL (1) -#define SOC_TIMER_GROUP_XTAL_MHZ (40) -#define SOC_TIMER_GROUP_COUNTER_BIT_WIDTH (54) -#define SOC_TIMER_GROUP_PRESCALE_BIT_WIDTH (16) -#define SOC_TIMER_GROUPS (2) -#define SOC_TIMER_GROUP_TIMERS_PER_GROUP (1) -#define SOC_TIMER_GROUP_TOTAL_TIMERS (SOC_TIMER_GROUPS * SOC_TIMER_GROUP_TIMERS_PER_GROUP) -#define SOC_TIMER_GROUP_LAYOUT {1,1} diff --git a/components/soc/esp32c3/include/soc/timer_group_struct.h b/components/soc/esp32c3/include/soc/timer_group_struct.h index e69f1fe777..6bae30720c 100644 --- a/components/soc/esp32c3/include/soc/timer_group_struct.h +++ b/components/soc/esp32c3/include/soc/timer_group_struct.h @@ -206,7 +206,7 @@ typedef volatile struct { union { struct { uint32_t reserved0: 29; - uint32_t clk_is_active: 1; + uint32_t wdt_clk_is_active: 1; uint32_t timer_clk_is_active: 1; uint32_t en: 1; }; diff --git a/components/soc/esp32s2/include/soc/soc_caps.h b/components/soc/esp32s2/include/soc/soc_caps.h index 5287aeea2c..0927167942 100644 --- a/components/soc/esp32s2/include/soc/soc_caps.h +++ b/components/soc/esp32s2/include/soc/soc_caps.h @@ -217,14 +217,11 @@ #define SOC_SYSTIMER_BIT_WIDTH_HI (32) // Bit width of systimer high part /*-------------------------- TIMER GROUP CAPS --------------------------------*/ -#define SOC_TIMER_GROUP_SUPPORT_XTAL (1) -#define SOC_TIMER_GROUP_XTAL_MHZ (40) -#define SOC_TIMER_GROUP_COUNTER_BIT_WIDTH (64) -#define SOC_TIMER_GROUP_PRESCALE_BIT_WIDTH (16) -#define SOC_TIMER_GROUPS (2) -#define SOC_TIMER_GROUP_TIMERS_PER_GROUP (2) +#define SOC_TIMER_GROUP_COUNTER_BIT_WIDTH (64) +#define SOC_TIMER_GROUPS (2) +#define SOC_TIMER_GROUP_TIMERS_PER_GROUP (2) +#define SOC_TIMER_GROUP_SUPPORT_XTAL (1) #define SOC_TIMER_GROUP_TOTAL_TIMERS (SOC_TIMER_GROUPS * SOC_TIMER_GROUP_TIMERS_PER_GROUP) -#define SOC_TIMER_GROUP_LAYOUT {2,2} /*-------------------------- TOUCH SENSOR CAPS -------------------------------*/ #define SOC_TOUCH_SENSOR_NUM (15) /*! 15 Touch channels */ diff --git a/components/soc/esp32s3/include/soc/soc_caps.h b/components/soc/esp32s3/include/soc/soc_caps.h index f6ceceb8b7..c4690b01e1 100644 --- a/components/soc/esp32s3/include/soc/soc_caps.h +++ b/components/soc/esp32s3/include/soc/soc_caps.h @@ -95,13 +95,11 @@ #include "systimer_caps.h" /*-------------------------- TIMER GROUP CAPS --------------------------------*/ -#define SOC_TIMER_GROUP_SUPPORT_XTAL (1) -#define SOC_TIMER_GROUP_COUNTER_BIT_WIDTH (54) -#define SOC_TIMER_GROUP_PRESCALE_BIT_WIDTH (16) -#define SOC_TIMER_GROUPS (2) -#define SOC_TIMER_GROUP_TIMERS_PER_GROUP (2) +#define SOC_TIMER_GROUPS (2) +#define SOC_TIMER_GROUP_TIMERS_PER_GROUP (2) +#define SOC_TIMER_GROUP_COUNTER_BIT_WIDTH (54) +#define SOC_TIMER_GROUP_SUPPORT_XTAL (1) #define SOC_TIMER_GROUP_TOTAL_TIMERS (SOC_TIMER_GROUPS * SOC_TIMER_GROUP_TIMERS_PER_GROUP) -#define SOC_TIMER_GROUP_LAYOUT {2,2} /*-------------------------- TOUCH SENSOR CAPS -------------------------------*/ #include "touch_sensor_caps.h"