Chapter 2. API Reference
Parameters
• speed_mode: Select the LEDC channel group with specified speed mode. Note that not all targets
support high speed mode.
• channel: LEDC channel (0 - LEDC_CHANNEL_MAX-1), select from ledc_channel_t
esp_err_t ledc_set_fade(ledc_mode_t
LEDC set gradient Set LEDC gradient, After the function calls the ledc_update_duty function, the function
can take effect.
Note If a fade operation is running in progress on that channel, the driver would not allow it to be stopped.
Other duty operations will have to wait until the fade operation has finished.
Return
• ESP_OK Success
• ESP_ERR_INVALID_ARG Parameter error
Parameters
• speed_mode: Select the LEDC channel group with specified speed mode. Note that not all targets
support high speed mode.
• channel: LEDC channel (0 - LEDC_CHANNEL_MAX-1), select from ledc_channel_t
• duty: Set the start of the gradient duty, the range of duty setting is [0, (2**duty_resolution) - 1]
• fade_direction: Set the direction of the gradient
• step_num: Set the number of the gradient
• duty_cycle_num: Set how many LEDC tick each time the gradient lasts
• duty_scale: Set gradient change amplitude
esp_err_t
ledc_isr_register(void (*fn))void *
, void *arg, int intr_alloc_flags,
ISR. The handler will be attached to the same CPU core that this function is running on.
Return
• ESP_OK Success
• ESP_ERR_INVALID_ARG Function pointer error.
Parameters
• fn: Interrupt handler function.
• arg: User-supplied argument passed to the 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.
esp_err_t ledc_timer_set(ledc_mode_t
Configure LEDC settings.
Return
• (-1) Parameter error
• Other Current LEDC duty
Parameters
• speed_mode: Select the LEDC channel group with specified speed mode. Note that not all targets
support high speed mode.
• timer_sel: Timer index (0-3), there are 4 timers in LEDC module
• clock_divider: Timer clock divide value, the timer clock is divided from the selected clock
source
• duty_resolution: Resolution of duty setting in number of bits. The range of duty values is
[0, (2**duty_resolution)]
• clk_src: Select LEDC source clock.
esp_err_t ledc_timer_rst(ledc_mode_t
Reset LEDC timer.
Return
• ESP_ERR_INVALID_ARG Parameter error
Espressif Systems
speed_mode,
ledc_duty_direction_t
fade_direction,
duty_cycle_num, uint32_t duty_scale)
ledc_isr_handle_t
*handleRegister LEDC interrupt handler, the handler is an
speed_mode,
uint32_t duty_resolution,
speed_mode,
321
Submit Document Feedback
ledc_channel_t
channel,
uint32_t
ledc_timer_t
timer_sel, uint32_t clock_divider,
ledc_clk_src_t
clk_src)
ledc_timer_t
timer_sel)
uint32_t
duty,
step_num,
uint32_t
One or multiple (ORred)
Release v4.4
Need help?
Do you have a question about the ESP32-S2 and is the answer not in the manual?