Chapter 2. API Reference
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
• evt_type: Watch point event type. All enabled events share the same interrupt (one interrupt per
pulse counter unit).
• value: Pointer to accept counter value for PCNT event
esp_err_t pcnt_get_event_status(pcnt_unit_t unit, uint32_t *status)
Get PCNT event status of PCNT 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
• status: Pointer to accept event status word
esp_err_t pcnt_isr_unregister(pcnt_isr_handle_t handle)
Unregister PCNT interrupt handler (registered by pcnt_isr_register), the handler is an ISR. The handler will
be attached to the same CPU core that this function is running on. If the interrupt service is registered by
pcnt_isr_service_install, please call pcnt_isr_service_uninstall instead.
Return
• ESP_OK Success
• ESP_ERR_NOT_FOUND Can not find the interrupt that matches the flags.
• ESP_ERR_INVALID_ARG Function pointer error.
Parameters
• handle: handle to unregister the ISR service.
esp_err_t pcnt_isr_register(void (*fn))void *
, void *arg, int intr_alloc_flags, pcnt_isr_handle_t *handleRegister PCNT interrupt handler, the handler is an
ISR. The handler will be attached to the same CPU core that this function is running on. Please do not use
pcnt_isr_service_install if this function was called.
Return
• ESP_OK Success
• ESP_ERR_NOT_FOUND Can not find the interrupt that matches the flags.
• ESP_ERR_INVALID_ARG Function pointer error.
Parameters
• fn: Interrupt handler function.
• arg: Parameter for handler function
• 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.
• handle: Pointer to return handle. If non-NULL, a handle for the interrupt will be returned here.
Calling pcnt_isr_unregister to unregister this ISR service if needed, but only if the handle is not
NULL.
esp_err_t pcnt_set_pin(pcnt_unit_t unit, pcnt_channel_t channel, int pulse_io, int ctrl_io)
Configure PCNT pulse signal input pin and control input pin.
Note Set the signal input to PCNT_PIN_NOT_USED if unused.
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
• channel: PCNT channel number
Espressif Systems 333
Submit Document Feedback
Release v4.4