![]() In the interrupt handler, you need to call timer_spinlock_take(.) before your handling, and call timer_spinlock_give(…) after your handling. If use this function to reigster ISR, you need to write the whole ISR. Use direct register access to configure timers from inside the ISR in this case. If the intr_alloc_flags value ESP_INTR_FLAG_IRAM is set, the handler function must be declared with IRAM_ATTR attribute and can only call functions in IRAM or ROM. The handler will be attached to the same CPU core that this function is running on. Register Timer interrupt handler, the handler is an ISR. Remove ISR handle callback for the corresponding timer.Įsp_err_t timer_isr_register ( timer_group_t group_num, timer_idx_t timer_num, void (* fn) (void * ), void * arg, int intr_alloc_flags, timer_isr_handle_t * handle, ) ¶ It cannot call other timer APIs.Įsp_err_t timer_isr_callback_remove ( timer_group_t group_num, timer_idx_t timer_num ) ¶ One or multiple (ORred) ESP_INTR_FLAG_* values. Intr_alloc_flags: Flags used to allocate the interrupt. Isr_handler: Interrupt handler function, it is a callback function. If you want to realize some specific applications or write the whole ISR, you can call timer_isr_register(…) to register ISR. This ISR handler do not need to handle interrupt status, and should be kept short. ![]() This ISR handler will be called from an ISR. The callback should return a bool value to determine whether need to do YIELD at the end of the ISR. The divider’s range is from from 2 to 65536.Įsp_err_t timer_set_alarm_value ( timer_group_t group_num, timer_idx_t timer_num, uint64_t alarm_value ) ¶Īlarm_value: A 64-bit value to set the alarm value.Įsp_err_t timer_get_alarm_value ( timer_group_t group_num, timer_idx_t timer_num, uint64_t * alarm_value ) ¶Īlarm_value: Pointer of A 64-bit value to accept the alarm value.Įsp_err_t timer_set_alarm ( timer_group_t group_num, timer_idx_t timer_num, timer_alarm_t alarm_en ) ¶Įnable or disable generation of timer alarm events.Īlarm_en: To enable or disable timer alarm function.Įsp_err_t timer_isr_callback_add ( timer_group_t group_num, timer_idx_t timer_num, timer_isr_t isr_handler, void * arg, int intr_alloc_flags ) ¶Īdd ISR handle callback for the corresponding timer. Timer groups clock are divider from APB clock.ĭivider: Timer clock divider value. Group_num: Timer group number, 0 for TIMERG0 or 1 for TIMERG1Įsp_err_t timer_pause ( timer_group_t group_num, timer_idx_t timer_num ) ¶Įsp_err_t timer_set_counter_mode ( timer_group_t group_num, timer_idx_t timer_num, timer_count_dir_t counter_dir ) ¶Ĭounter_dir: Counting direction of timer, count-up or count-downĮsp_err_t timer_set_auto_reload ( timer_group_t group_num, timer_idx_t timer_num, timer_autoreload_t reload ) ¶Įnable or disable counter reload function when alarm event occurs.Įsp_err_t timer_set_divider ( timer_group_t group_num, timer_idx_t timer_num, uint32_t divider ) ¶ Load_val: Counter value to write to the hardware timer.Įsp_err_t timer_start ( timer_group_t group_num, timer_idx_t timer_num ) ¶ Time: Pointer, type of double*, to accept timer counter value, in seconds.Įsp_err_t timer_set_counter_value ( timer_group_t group_num, timer_idx_t timer_num, uint64_t load_val ) ¶ Read the counter value of hardware timer, in unit of a given scale. Timer_val: Pointer to accept timer counter value.Įsp_err_t timer_get_counter_time_sec ( timer_group_t group_num, timer_idx_t timer_num, double * time ) ¶ Timer_num: Timer index, 0 for hw_timer & 1 for hw_timer Group_num: Timer group, 0 for TIMERG0 or 1 for TIMERG1 ![]() Read the counter value of hardware timer. Set if the initial counter value should be reloaded on the timer’s alarmįunctions ¶ esp_err_t timer_get_counter_value ( timer_group_t group_num, timer_idx_t timer_num, uint64_t * timer_val ) ¶ Set if the counter should be incrementing or decrementing If the timer is running, timer_set_divider() pauses it, change the setting, and start the timer again. To avoid unpredictable results, the timer should be paused when changing the divider. You can also reconfigure the timer by using dedicated functions to change individual settings:Ĭhange the rate of ticking. This function is described in Section Timer Initialization. ![]() To reconfigure the timer, you can call timer_init(). To pause the timer at any time, call timer_pause(). To check the timer’s current value, call timer_get_counter_value() or timer_get_counter_time_sec(). You can specify the timer’s initial counter value by calling timer_set_counter_value(). To enable the timer, call the function timer_init() with counter_en set to true, or call timer_start(). Once the timer is enabled, its counter starts running. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |