EasyManua.ls Logo

Espressif ESP32-S2 - Page 346

Espressif ESP32-S2
1695 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Chapter 2. API Reference
esp_err_t pcnt_isr_handler_add(pcnt_unit_t unit, void (*isr_handler))void *
, void *argsAdd ISR handler for specified unit.
Call this function after using pcnt_isr_service_install() to install the PCNT drivers 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. One or multiple (ORred)
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 unit)
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 335
Submit Document Feedback
Release v4.4

Table of Contents