16 #include <esp_idf_version.h>
18 #if CONFIG_ESP_TIMER_IMPL_TG0_LAC
19 #include <soc/timer_group_reg.h>
21 #include <hal/systimer_ll.h>
28 #define HW_TIMER_BASE_CLK APB_CLK_FREQ
45 #define HW_TIMER1_GROUP 0
46 #define HW_TIMER1_INDEX 0
59 #define MAX_HW_TIMER1_INTERVAL 0x7fffffff
67 #define MIN_HW_TIMER1_INTERVAL_US 50U
131 #if CONFIG_ESP_TIMER_IMPL_TG0_LAC
132 #define HW_TIMER2_CLK 2000000U
133 #elif defined(CONFIG_IDF_TARGET_ESP32S2)
134 #define HW_TIMER2_CLK 80000000U
135 #elif defined(CONFIG_IDF_TARGET_ESP32C3)
136 #define HW_TIMER2_CLK 16000000U
137 #elif defined(CONFIG_IDF_TARGET_ESP32S3)
138 #define HW_TIMER2_CLK 16000000U
139 #elif defined(CONFIG_IDF_TARGET_ESP32C2)
140 #define HW_TIMER2_CLK 40000000U
149 #if CONFIG_ESP_TIMER_IMPL_TG0_LAC
150 REG_WRITE(TIMG_LACTUPDATE_REG(0), 1);
151 return REG_READ(TIMG_LACTLO_REG(0));
152 #elif ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 4, 0)
153 systimer_ll_counter_snapshot(&SYSTIMER, 0);
154 return systimer_ll_get_counter_value_low(&SYSTIMER, 0);
155 #elif defined(CONFIG_IDF_TARGET_ESP32S2)
156 systimer_ll_counter_snapshot();
157 return systimer_ll_get_counter_value_low();
159 systimer_ll_counter_snapshot(0);
160 return systimer_ll_get_counter_value_low(0);
164 #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:147
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:77
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:82
hw_timer_clkdiv_t
Definition: Esp32/Components/driver/include/driver/hw_timer.h:71
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:69
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:79
@ TIMER_EDGE_INT
Definition: Esp32/Components/driver/include/driver/hw_timer.h:78
@ TIMER_FRC1_SOURCE
Definition: Esp32/Components/driver/include/driver/hw_timer.h:83
@ TIMER_NMI_SOURCE
Definition: Esp32/Components/driver/include/driver/hw_timer.h:84
@ TIMER_CLKDIV_1
Definition: Esp32/Components/driver/include/driver/hw_timer.h:72
@ TIMER_CLKDIV_16
Definition: Esp32/Components/driver/include/driver/hw_timer.h:73
@ TIMER_CLKDIV_256
Definition: Esp32/Components/driver/include/driver/hw_timer.h:74