Espressif ESP32-S2 Programming Manual page 346

Table of Contents

Advertisement

Chapter 2. API Reference
esp_err_t pcnt_isr_handler_add(pcnt_unit_t
, void *argsAdd ISR handler for specified unit.
Call this function after using pcnt_isr_service_install() to install the PCNT driver's ISR handler service.
The ISR handlers do not need to be declared with IRAM_ATTR, unless you pass the
ESP_INTR_FLAG_IRAM flag when allocating the ISR in pcnt_isr_service_install().
This ISR handler will be called from an ISR. So there is a stack size limit (configurable as "ISR stack size"
in menuconfig). This limit is smaller compared to a global PCNT interrupt handler due to the additional level
of indirection.
Return
• ESP_OK Success
• ESP_ERR_INVALID_STATE pcnt driver has not been initialized
• ESP_ERR_INVALID_ARG Parameter error
Parameters
• unit: PCNT unit number
• isr_handler: Interrupt handler function.
• args: Parameter for handler function
esp_err_t
pcnt_isr_service_install(int intr_alloc_flags)
Install PCNT ISR service.
Note We can manage different interrupt service for each unit. This function will use the default ISR handle
service, Calling pcnt_isr_service_uninstall to uninstall the default service if needed. Please do not use
pcnt_isr_register if this function was called.
Return
• ESP_OK Success
• ESP_ERR_INVALID_STATE pcnt driver has not been initialized
• ESP_ERR_NO_MEM No memory to install this service
• ESP_ERR_INVALID_STATE ISR service already installed
Parameters
• intr_alloc_flags: Flags used to allocate the interrupt.
ESP_INTR_FLAG_* values. See esp_intr_alloc.h for more info.
void pcnt_isr_service_uninstall(void)
Uninstall PCNT ISR service, freeing related resources.
esp_err_t pcnt_isr_handler_remove(pcnt_unit_t
Delete ISR handler for specified unit.
Return
• ESP_OK Success
• ESP_ERR_INVALID_STATE pcnt driver has not been initialized
• ESP_ERR_INVALID_ARG Parameter error
Parameters
• unit: PCNT unit number
Structures
struct pcnt_config_t
Pulse Counter configuration for a single channel.
Public Members
int pulse_gpio_num
Pulse input GPIO number, if you want to use GPIO16, enter pulse_gpio_num = 16, a negative value will
be ignored
int ctrl_gpio_num
Control signal input GPIO number, a negative value will be ignored
Espressif Systems
unit, void (*isr_handler))void *
unit)
335
Submit Document Feedback
One or multiple (ORred)
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?

Subscribe to Our Youtube Channel

Table of Contents

Save PDF