Espressif ESP32-S2 Programming Manual page 254

Table of Contents

Advertisement

Chapter 2. API Reference
esp_err_t timer_isr_callback_add(timer_group_t
Add ISR handle callback for the corresponding timer.
The callback should return a bool value to determine whether need to do YIELD at the end of the ISR.
Note This ISR handler will be called from an ISR. This ISR handler do not need to handle interrupt status,
and should be kept short. If you want to realize some specific applications or write the whole ISR, you
can call timer_isr_register(...) to register ISR.
Parameters
• group_num: Timer group number
• timer_num: Timer index of timer group
• isr_handler: Interrupt handler function, it is a callback function.
• arg: Parameter for handler function
• intr_alloc_flags: Flags used to allocate the interrupt.
ESP_INTR_FLAG_* values. See esp_intr_alloc.h for more info.
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. It cannot call other timer APIs.
Return
• ESP_OK Success
• ESP_ERR_INVALID_ARG Parameter error
esp_err_t timer_isr_callback_remove(timer_group_t
Remove ISR handle callback for the corresponding timer.
Return
• ESP_OK Success
• ESP_ERR_INVALID_ARG Parameter error
Parameters
• group_num: Timer group number
• timer_num: Timer index of timer group
esp_err_t timer_isr_register(timer_group_t
, void *arg, int intr_alloc_flags,
ISR. The handler will be attached to the same CPU core that this function is running on.
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. It cannot call other timer APIs. Use
direct register access to configure timers from inside the ISR in this case.
Note If use this function to reigster ISR, you need to write the whole ISR. In the interrupt handler, you need to
call timer_spinlock_take(..) before your handling, and call timer_spinlock_give(...) after your handling.
Parameters
• group_num: Timer group number
• timer_num: Timer index of timer group
• fn: Interrupt handler function.
• arg: Parameter for handler function
• intr_alloc_flags: Flags used to allocate the interrupt.
ESP_INTR_FLAG_* values. See esp_intr_alloc.h for more info.
• handle: Pointer to return handle. If non-NULL, a handle for the interrupt will be returned here.
Return
• ESP_OK Success
• ESP_ERR_INVALID_ARG Parameter error
esp_err_t timer_init(timer_group_t
Initializes and configure the timer.
Return
• ESP_OK Success
• ESP_ERR_INVALID_ARG Parameter error
Parameters
Espressif Systems
group_num,
isr_handler, void *arg, int intr_alloc_flags)
group_num,
group_num,
timer_isr_handle_t
*handleRegister Timer interrupt handler, the handler is an
group_num,
timer_idx_t
243
Submit Document Feedback
timer_idx_t
timer_num,
One or multiple (ORred)
timer_idx_t
timer_num)
timer_idx_t
timer_num, void (*fn))void *
One or multiple (ORred)
timer_num, const
timer_config_t
timer_isr_t
*config)
Release v4.4

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the ESP32-S2 and is the answer not in the manual?

Table of Contents

Save PDF