16 #include <esp_idf_version.h>
18 #pragma GCC diagnostic push
19 #pragma GCC diagnostic ignored "-Wunused-parameter"
20 #if CONFIG_ESP_TIMER_IMPL_TG0_LAC
21 #include <soc/timer_group_reg.h>
23 #include <hal/systimer_ll.h>
25 #pragma GCC diagnostic pop
31 #define HW_TIMER_BASE_CLK APB_CLK_FREQ
48 #define HW_TIMER1_GROUP 0
49 #define HW_TIMER1_INDEX 0
62 #define MAX_HW_TIMER1_INTERVAL 0x7fffffff
70 #define MIN_HW_TIMER1_INTERVAL_US 50U
134 #if CONFIG_ESP_TIMER_IMPL_TG0_LAC
135 #define HW_TIMER2_CLK 2000000U
136 #elif defined(CONFIG_IDF_TARGET_ESP32S2)
137 #define HW_TIMER2_CLK 80000000U
138 #elif defined(CONFIG_IDF_TARGET_ESP32C3)
139 #define HW_TIMER2_CLK 16000000U
140 #elif defined(CONFIG_IDF_TARGET_ESP32S3)
141 #define HW_TIMER2_CLK 16000000U
142 #elif defined(CONFIG_IDF_TARGET_ESP32C2)
143 #define HW_TIMER2_CLK 40000000U
152 #if CONFIG_ESP_TIMER_IMPL_TG0_LAC
153 REG_WRITE(TIMG_LACTUPDATE_REG(0), 1);
154 return REG_READ(TIMG_LACTLO_REG(0));
155 #elif ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 4, 0)
156 systimer_ll_counter_snapshot(&SYSTIMER, 0);
157 return systimer_ll_get_counter_value_low(&SYSTIMER, 0);
158 #elif defined(CONFIG_IDF_TARGET_ESP32S2)
159 systimer_ll_counter_snapshot();
160 return systimer_ll_get_counter_value_low();
162 systimer_ll_counter_snapshot(0);
163 return systimer_ll_get_counter_value_low(0);
167 #define NOW() hw_timer2_read()
void hw_timer1_attach_interrupt(hw_timer_source_type_t source_type, hw_timer_callback_t callback, void *arg)
Attach an interrupt for the timer.
static uint32_t hw_timer2_read(void)
Read current timer2 value.
Definition: Esp32/Components/driver/include/driver/hw_timer.h:150
void hw_timer1_detach_interrupt(void)
Detach interrupt from the timer.
hw_timer_intr_type_t
Definition: Esp32/Components/driver/include/driver/hw_timer.h:80
void hw_timer1_disable(void)
Disable the timer.
Definition: Esp8266/Components/driver/include/driver/hw_timer.h:117
void hw_timer1_enable(hw_timer_clkdiv_t div, hw_timer_intr_type_t intr_type, bool auto_load)
Enable the timer.
Definition: Esp8266/Components/driver/include/driver/hw_timer.h:90
hw_timer_source_type_t
Definition: Esp32/Components/driver/include/driver/hw_timer.h:85
hw_timer_clkdiv_t
Definition: Esp32/Components/driver/include/driver/hw_timer.h:74
void hw_timer1_write(uint32_t ticks)
Set the timer interval.
Definition: Esp8266/Components/driver/include/driver/hw_timer.h:109
void(* hw_timer_callback_t)(void *arg)
Definition: Esp32/Components/driver/include/driver/hw_timer.h:72
void hw_timer_init(void)
Initialise hardware timers.
uint32_t hw_timer1_read(void)
Get timer1 count.
Definition: Esp8266/Components/driver/include/driver/hw_timer.h:132
@ TIMER_LEVEL_INT
Definition: Esp32/Components/driver/include/driver/hw_timer.h:82
@ TIMER_EDGE_INT
Definition: Esp32/Components/driver/include/driver/hw_timer.h:81
@ TIMER_FRC1_SOURCE
Definition: Esp32/Components/driver/include/driver/hw_timer.h:86
@ TIMER_NMI_SOURCE
Definition: Esp32/Components/driver/include/driver/hw_timer.h:87
@ TIMER_CLKDIV_1
Definition: Esp32/Components/driver/include/driver/hw_timer.h:75
@ TIMER_CLKDIV_16
Definition: Esp32/Components/driver/include/driver/hw_timer.h:76
@ TIMER_CLKDIV_256
Definition: Esp32/Components/driver/include/driver/hw_timer.h:77