Lines Matching refs:timer_num

49 esp_err_t timer_get_counter_value(timer_group_t group_num, timer_idx_t timer_num, uint64_t *timer_v…  in timer_get_counter_value()  argument
52 ESP_RETURN_ON_FALSE(timer_num < TIMER_MAX, ESP_ERR_INVALID_ARG, TIMER_TAG, TIMER_NUM_ERROR); in timer_get_counter_value()
54 …ESP_RETURN_ON_FALSE(p_timer_obj[group_num][timer_num] != NULL, ESP_ERR_INVALID_ARG, TIMER_TAG, TI… in timer_get_counter_value()
56 timer_hal_get_counter_value(&(p_timer_obj[group_num][timer_num]->hal), timer_val); in timer_get_counter_value()
61 esp_err_t timer_get_counter_time_sec(timer_group_t group_num, timer_idx_t timer_num, double *time) in timer_get_counter_time_sec() argument
64 ESP_RETURN_ON_FALSE(timer_num < TIMER_MAX, ESP_ERR_INVALID_ARG, TIMER_TAG, TIMER_NUM_ERROR); in timer_get_counter_time_sec()
66 …ESP_RETURN_ON_FALSE(p_timer_obj[group_num][timer_num] != NULL, ESP_ERR_INVALID_ARG, TIMER_TAG, TI… in timer_get_counter_time_sec()
68 esp_err_t err = timer_get_counter_value(group_num, timer_num, &timer_val); in timer_get_counter_time_sec()
71 timer_hal_get_divider(&(p_timer_obj[group_num][timer_num]->hal), &div); in timer_get_counter_time_sec()
74 if (timer_hal_get_use_xtal(&(p_timer_obj[group_num][timer_num]->hal))) { in timer_get_counter_time_sec()
82 esp_err_t timer_set_counter_value(timer_group_t group_num, timer_idx_t timer_num, uint64_t load_val) in timer_set_counter_value() argument
85 ESP_RETURN_ON_FALSE(timer_num < TIMER_MAX, ESP_ERR_INVALID_ARG, TIMER_TAG, TIMER_NUM_ERROR); in timer_set_counter_value()
86 …ESP_RETURN_ON_FALSE(p_timer_obj[group_num][timer_num] != NULL, ESP_ERR_INVALID_ARG, TIMER_TAG, TI… in timer_set_counter_value()
88 timer_hal_set_counter_value(&(p_timer_obj[group_num][timer_num]->hal), load_val); in timer_set_counter_value()
93 esp_err_t timer_start(timer_group_t group_num, timer_idx_t timer_num) in timer_start() argument
96 ESP_RETURN_ON_FALSE(timer_num < TIMER_MAX, ESP_ERR_INVALID_ARG, TIMER_TAG, TIMER_NUM_ERROR); in timer_start()
97 …ESP_RETURN_ON_FALSE(p_timer_obj[group_num][timer_num] != NULL, ESP_ERR_INVALID_ARG, TIMER_TAG, TI… in timer_start()
99 timer_hal_set_counter_enable(&(p_timer_obj[group_num][timer_num]->hal), TIMER_START); in timer_start()
104 esp_err_t timer_pause(timer_group_t group_num, timer_idx_t timer_num) in timer_pause() argument
107 ESP_RETURN_ON_FALSE(timer_num < TIMER_MAX, ESP_ERR_INVALID_ARG, TIMER_TAG, TIMER_NUM_ERROR); in timer_pause()
108 …ESP_RETURN_ON_FALSE(p_timer_obj[group_num][timer_num] != NULL, ESP_ERR_INVALID_ARG, TIMER_TAG, TI… in timer_pause()
110 timer_hal_set_counter_enable(&(p_timer_obj[group_num][timer_num]->hal), TIMER_PAUSE); in timer_pause()
115 esp_err_t timer_set_counter_mode(timer_group_t group_num, timer_idx_t timer_num, timer_count_dir_t … in timer_set_counter_mode() argument
118 ESP_RETURN_ON_FALSE(timer_num < TIMER_MAX, ESP_ERR_INVALID_ARG, TIMER_TAG, TIMER_NUM_ERROR); in timer_set_counter_mode()
120 …ESP_RETURN_ON_FALSE(p_timer_obj[group_num][timer_num] != NULL, ESP_ERR_INVALID_ARG, TIMER_TAG, TI… in timer_set_counter_mode()
122 timer_hal_set_counter_increase(&(p_timer_obj[group_num][timer_num]->hal), counter_dir); in timer_set_counter_mode()
127 esp_err_t timer_set_auto_reload(timer_group_t group_num, timer_idx_t timer_num, timer_autoreload_t … in timer_set_auto_reload() argument
130 ESP_RETURN_ON_FALSE(timer_num < TIMER_MAX, ESP_ERR_INVALID_ARG, TIMER_TAG, TIMER_NUM_ERROR); in timer_set_auto_reload()
132 …ESP_RETURN_ON_FALSE(p_timer_obj[group_num][timer_num] != NULL, ESP_ERR_INVALID_ARG, TIMER_TAG, TI… in timer_set_auto_reload()
134 timer_hal_set_auto_reload(&(p_timer_obj[group_num][timer_num]->hal), reload); in timer_set_auto_reload()
139 esp_err_t timer_set_divider(timer_group_t group_num, timer_idx_t timer_num, uint32_t divider) in timer_set_divider() argument
142 ESP_RETURN_ON_FALSE(timer_num < TIMER_MAX, ESP_ERR_INVALID_ARG, TIMER_TAG, TIMER_NUM_ERROR); in timer_set_divider()
144 …ESP_RETURN_ON_FALSE(p_timer_obj[group_num][timer_num] != NULL, ESP_ERR_INVALID_ARG, TIMER_TAG, TI… in timer_set_divider()
146 timer_hal_set_divider(&(p_timer_obj[group_num][timer_num]->hal), divider); in timer_set_divider()
151 esp_err_t timer_set_alarm_value(timer_group_t group_num, timer_idx_t timer_num, uint64_t alarm_valu… in timer_set_alarm_value() argument
154 ESP_RETURN_ON_FALSE(timer_num < TIMER_MAX, ESP_ERR_INVALID_ARG, TIMER_TAG, TIMER_NUM_ERROR); in timer_set_alarm_value()
155 …ESP_RETURN_ON_FALSE(p_timer_obj[group_num][timer_num] != NULL, ESP_ERR_INVALID_ARG, TIMER_TAG, TI… in timer_set_alarm_value()
157 timer_hal_set_alarm_value(&(p_timer_obj[group_num][timer_num]->hal), alarm_value); in timer_set_alarm_value()
162 esp_err_t timer_get_alarm_value(timer_group_t group_num, timer_idx_t timer_num, uint64_t *alarm_val… in timer_get_alarm_value() argument
165 ESP_RETURN_ON_FALSE(timer_num < TIMER_MAX, ESP_ERR_INVALID_ARG, TIMER_TAG, TIMER_NUM_ERROR); in timer_get_alarm_value()
167 …ESP_RETURN_ON_FALSE(p_timer_obj[group_num][timer_num] != NULL, ESP_ERR_INVALID_ARG, TIMER_TAG, TI… in timer_get_alarm_value()
169 timer_hal_get_alarm_value(&(p_timer_obj[group_num][timer_num]->hal), alarm_value); in timer_get_alarm_value()
174 esp_err_t timer_set_alarm(timer_group_t group_num, timer_idx_t timer_num, timer_alarm_t alarm_en) in timer_set_alarm() argument
177 ESP_RETURN_ON_FALSE(timer_num < TIMER_MAX, ESP_ERR_INVALID_ARG, TIMER_TAG, TIMER_NUM_ERROR); in timer_set_alarm()
179 …ESP_RETURN_ON_FALSE(p_timer_obj[group_num][timer_num] != NULL, ESP_ERR_INVALID_ARG, TIMER_TAG, TI… in timer_set_alarm()
181 timer_hal_set_alarm_enable(&(p_timer_obj[group_num][timer_num]->hal), alarm_en); in timer_set_alarm()
223 esp_err_t timer_isr_callback_add(timer_group_t group_num, timer_idx_t timer_num, timer_isr_t isr_ha… in timer_isr_callback_add() argument
226 ESP_RETURN_ON_FALSE(timer_num < TIMER_MAX, ESP_ERR_INVALID_ARG, TIMER_TAG, TIMER_NUM_ERROR); in timer_isr_callback_add()
227 …ESP_RETURN_ON_FALSE(p_timer_obj[group_num][timer_num] != NULL, ESP_ERR_INVALID_ARG, TIMER_TAG, TI… in timer_isr_callback_add()
229 timer_disable_intr(group_num, timer_num); in timer_isr_callback_add()
230 p_timer_obj[group_num][timer_num]->timer_isr_fun.fn = isr_handler; in timer_isr_callback_add()
231 p_timer_obj[group_num][timer_num]->timer_isr_fun.args = args; in timer_isr_callback_add()
232 p_timer_obj[group_num][timer_num]->timer_isr_fun.isr_timer_group = group_num; in timer_isr_callback_add()
233 …timer_isr_register(group_num, timer_num, timer_isr_default, (void *)p_timer_obj[group_num][timer_n… in timer_isr_callback_add()
234 … intr_alloc_flags, &(p_timer_obj[group_num][timer_num]->timer_isr_fun.timer_isr_handle)); in timer_isr_callback_add()
235 timer_enable_intr(group_num, timer_num); in timer_isr_callback_add()
240 esp_err_t timer_isr_callback_remove(timer_group_t group_num, timer_idx_t timer_num) in timer_isr_callback_remove() argument
243 ESP_RETURN_ON_FALSE(timer_num < TIMER_MAX, ESP_ERR_INVALID_ARG, TIMER_TAG, TIMER_NUM_ERROR); in timer_isr_callback_remove()
244 …ESP_RETURN_ON_FALSE(p_timer_obj[group_num][timer_num] != NULL, ESP_ERR_INVALID_ARG, TIMER_TAG, TI… in timer_isr_callback_remove()
246 timer_disable_intr(group_num, timer_num); in timer_isr_callback_remove()
247 p_timer_obj[group_num][timer_num]->timer_isr_fun.fn = NULL; in timer_isr_callback_remove()
248 p_timer_obj[group_num][timer_num]->timer_isr_fun.args = NULL; in timer_isr_callback_remove()
249 esp_intr_free(p_timer_obj[group_num][timer_num]->timer_isr_fun.timer_isr_handle); in timer_isr_callback_remove()
254 esp_err_t timer_isr_register(timer_group_t group_num, timer_idx_t timer_num, in timer_isr_register() argument
258 ESP_RETURN_ON_FALSE(timer_num < TIMER_MAX, ESP_ERR_INVALID_ARG, TIMER_TAG, TIMER_NUM_ERROR); in timer_isr_register()
260 …ESP_RETURN_ON_FALSE(p_timer_obj[group_num][timer_num] != NULL, ESP_ERR_INVALID_ARG, TIMER_TAG, TI… in timer_isr_register()
264 … timer_hal_get_status_reg_mask_bit(&(p_timer_obj[group_num][timer_num]->hal), &status_reg, &mask); in timer_isr_register()
265 …loc_intrstatus(timer_group_periph_signals.groups[group_num].t0_irq_id + timer_num, intr_alloc_flag… in timer_isr_register()
268 esp_err_t timer_init(timer_group_t group_num, timer_idx_t timer_num, const timer_config_t *config) in timer_init() argument
271 ESP_RETURN_ON_FALSE(timer_num < TIMER_MAX, ESP_ERR_INVALID_ARG, TIMER_TAG, TIMER_NUM_ERROR); in timer_init()
277 if (p_timer_obj[group_num][timer_num] == NULL) { in timer_init()
278 …p_timer_obj[group_num][timer_num] = (timer_obj_t *) heap_caps_calloc(1, sizeof(timer_obj_t), MALLO… in timer_init()
279 if (p_timer_obj[group_num][timer_num] == NULL) { in timer_init()
286 timer_hal_init(&(p_timer_obj[group_num][timer_num]->hal), group_num, timer_num); in timer_init()
287 timer_hal_reset_periph(&(p_timer_obj[group_num][timer_num]->hal)); in timer_init()
288 timer_hal_clear_intr_status(&(p_timer_obj[group_num][timer_num]->hal)); in timer_init()
289 timer_hal_set_auto_reload(&(p_timer_obj[group_num][timer_num]->hal), config->auto_reload); in timer_init()
290 timer_hal_set_divider(&(p_timer_obj[group_num][timer_num]->hal), config->divider); in timer_init()
291 timer_hal_set_counter_increase(&(p_timer_obj[group_num][timer_num]->hal), config->counter_dir); in timer_init()
292 timer_hal_set_alarm_enable(&(p_timer_obj[group_num][timer_num]->hal), config->alarm_en); in timer_init()
293 …timer_hal_set_level_int_enable(&(p_timer_obj[group_num][timer_num]->hal), config->intr_type == TIM… in timer_init()
297 timer_hal_set_counter_enable(&(p_timer_obj[group_num][timer_num]->hal), config->counter_en); in timer_init()
299 timer_hal_set_use_xtal(&(p_timer_obj[group_num][timer_num]->hal), config->clk_src); in timer_init()
306 esp_err_t timer_deinit(timer_group_t group_num, timer_idx_t timer_num) in timer_deinit() argument
309 ESP_RETURN_ON_FALSE(timer_num < TIMER_MAX, ESP_ERR_INVALID_ARG, TIMER_TAG, TIMER_NUM_ERROR); in timer_deinit()
310 …ESP_RETURN_ON_FALSE(p_timer_obj[group_num][timer_num] != NULL, ESP_ERR_INVALID_ARG, TIMER_TAG, TI… in timer_deinit()
313 timer_hal_set_counter_enable(&(p_timer_obj[group_num][timer_num]->hal), TIMER_PAUSE); in timer_deinit()
314 timer_hal_intr_disable(&(p_timer_obj[group_num][timer_num]->hal)); in timer_deinit()
315 timer_hal_clear_intr_status(&(p_timer_obj[group_num][timer_num]->hal)); in timer_deinit()
318 heap_caps_free(p_timer_obj[group_num][timer_num]); in timer_deinit()
319 p_timer_obj[group_num][timer_num] = NULL; in timer_deinit()
324 esp_err_t timer_get_config(timer_group_t group_num, timer_idx_t timer_num, timer_config_t *config) in timer_get_config() argument
327 ESP_RETURN_ON_FALSE(timer_num < TIMER_MAX, ESP_ERR_INVALID_ARG, TIMER_TAG, TIMER_NUM_ERROR); in timer_get_config()
329 …ESP_RETURN_ON_FALSE(p_timer_obj[group_num][timer_num] != NULL, ESP_ERR_INVALID_ARG, TIMER_TAG, TI… in timer_get_config()
332 config->alarm_en = timer_hal_get_alarm_enable(&(p_timer_obj[group_num][timer_num]->hal)); in timer_get_config()
333 config->auto_reload = timer_hal_get_auto_reload(&(p_timer_obj[group_num][timer_num]->hal)); in timer_get_config()
334 config->counter_dir = timer_hal_get_counter_increase(&(p_timer_obj[group_num][timer_num]->hal)); in timer_get_config()
335 config->counter_en = timer_hal_get_counter_enable(&(p_timer_obj[group_num][timer_num]->hal)); in timer_get_config()
338 timer_hal_get_divider(&(p_timer_obj[group_num][timer_num]->hal), &div); in timer_get_config()
341 if (timer_hal_get_level_int_enable(&(p_timer_obj[group_num][timer_num]->hal))) { in timer_get_config()
378 esp_err_t timer_enable_intr(timer_group_t group_num, timer_idx_t timer_num) in timer_enable_intr() argument
381 ESP_RETURN_ON_FALSE(timer_num < TIMER_MAX, ESP_ERR_INVALID_ARG, TIMER_TAG, TIMER_NUM_ERROR); in timer_enable_intr()
382 …ESP_RETURN_ON_FALSE(p_timer_obj[group_num][timer_num] != NULL, ESP_ERR_INVALID_ARG, TIMER_TAG, TI… in timer_enable_intr()
384 timer_hal_intr_enable(&(p_timer_obj[group_num][timer_num]->hal)); in timer_enable_intr()
389 esp_err_t timer_disable_intr(timer_group_t group_num, timer_idx_t timer_num) in timer_disable_intr() argument
392 ESP_RETURN_ON_FALSE(timer_num < TIMER_MAX, ESP_ERR_INVALID_ARG, TIMER_TAG, TIMER_NUM_ERROR); in timer_disable_intr()
393 …ESP_RETURN_ON_FALSE(p_timer_obj[group_num][timer_num] != NULL, ESP_ERR_INVALID_ARG, TIMER_TAG, TI… in timer_disable_intr()
395 timer_hal_intr_disable(&(p_timer_obj[group_num][timer_num]->hal)); in timer_disable_intr()
423 void IRAM_ATTR timer_group_intr_clr_in_isr(timer_group_t group_num, timer_idx_t timer_num) in timer_group_intr_clr_in_isr() argument
425 timer_group_clr_intr_status_in_isr(group_num, timer_num); in timer_group_intr_clr_in_isr()
428 void IRAM_ATTR timer_group_clr_intr_status_in_isr(timer_group_t group_num, timer_idx_t timer_num) in timer_group_clr_intr_status_in_isr() argument
430 timer_hal_clear_intr_status(&(p_timer_obj[group_num][timer_num]->hal)); in timer_group_clr_intr_status_in_isr()
433 void IRAM_ATTR timer_group_enable_alarm_in_isr(timer_group_t group_num, timer_idx_t timer_num) in timer_group_enable_alarm_in_isr() argument
435 timer_hal_set_alarm_enable(&(p_timer_obj[group_num][timer_num]->hal), true); in timer_group_enable_alarm_in_isr()
438 …64_t IRAM_ATTR timer_group_get_counter_value_in_isr(timer_group_t group_num, timer_idx_t timer_num) in timer_group_get_counter_value_in_isr() argument
441 timer_hal_get_counter_value(&(p_timer_obj[group_num][timer_num]->hal), &val); in timer_group_get_counter_value_in_isr()
445 void IRAM_ATTR timer_group_set_alarm_value_in_isr(timer_group_t group_num, timer_idx_t timer_num, u… in timer_group_set_alarm_value_in_isr() argument
447 timer_hal_set_alarm_value(&(p_timer_obj[group_num][timer_num]->hal), alarm_val); in timer_group_set_alarm_value_in_isr()
450 void IRAM_ATTR timer_group_set_counter_enable_in_isr(timer_group_t group_num, timer_idx_t timer_num in timer_group_set_counter_enable_in_isr() argument
452 timer_hal_set_counter_enable(&(p_timer_obj[group_num][timer_num]->hal), counter_en); in timer_group_set_counter_enable_in_isr()
465 bool IRAM_ATTR timer_group_get_auto_reload_in_isr(timer_group_t group_num, timer_idx_t timer_num) in timer_group_get_auto_reload_in_isr() argument
467 return timer_hal_get_auto_reload(&(p_timer_obj[group_num][timer_num]->hal)); in timer_group_get_auto_reload_in_isr()