Code: Select all
static void timer_group0_isr(void* arg) {
printf("timer_group0_isr OK!\n");
TIMERG0.int_clr_timers.t0 = 1;
TIMERG0.hw_timer[0].config.alarm_en = 1;
}
void timer_tg0_initialise (int timer_idx) {
timer_config_t config = {
.alarm_en = true,
.counter_en = false,
.intr_type = TIMER_INTR_LEVEL,
.counter_dir = TIMER_COUNT_UP,
.auto_reload = true,
.divider = 80
};
timer_init(TIMER_GROUP_0, timer_idx, &config);
timer_set_counter_value(TIMER_GROUP_0, timer_idx, 0);
timer_set_alarm_value(TIMER_GROUP_0, timer_idx, 10000);
timer_enable_intr(TIMER_GROUP_0, timer_idx);
timer_isr_register(TIMER_GROUP_0, timer_idx, timer_group0_isr, (void *) timer_idx, ESP_INTR_FLAG_IRAM, NULL);
timer_start(TIMER_GROUP_0, timer_idx);
printf("timer initialzied!!!!\n");
}
Code: Select all
timer_tg0_initialise(TIMER_0);