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
• duty: Set the LEDC duty, the range of duty setting is [0, (2**duty_resolution) - 1]
• hpoint: Set the LEDC hpoint value(max: 0xfffff)
esp_err_t ledc_set_fade_time_and_start(ledc_mode_t speed_mode, ledc_channel_t channel,
uint32_t target_duty, uint32_t max_fade_time_ms,
ledc_fade_mode_t fade_mode)
A thread-safe API to set and start LEDC fade function, with a limited time.
Note Call ledc_fade_func_install() once, before calling this function.
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_ERR_INVALID_ARG Parameter error
• ESP_OK Success
• ESP_ERR_INVALID_STATE Fade function not installed.
• ESP_FAIL Fade function init 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 index (0 - LEDC_CHANNEL_MAX-1), select from ledc_channel_t
• target_duty: Target duty of fading [0, (2**duty_resolution) - 1]
• max_fade_time_ms: The maximum time of the fading ( ms ).
• fade_mode: choose blocking or non-blocking mode
esp_err_t ledc_set_fade_step_and_start(ledc_mode_t speed_mode, ledc_channel_t channel,
uint32_t target_duty, uint32_t scale, uint32_t cy-
cle_num, ledc_fade_mode_t fade_mode)
A thread-safe API to set and start LEDC fade function.
Note Call ledc_fade_func_install() once before calling this function.
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_ERR_INVALID_ARG Parameter error
• ESP_OK Success
• ESP_ERR_INVALID_STATE Fade function not installed.
• ESP_FAIL Fade function init 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 index (0 - LEDC_CHANNEL_MAX-1), select from ledc_channel_t
• target_duty: Target duty of fading [0, (2**duty_resolution) - 1]
• scale: Controls the increase or decrease step scale.
• cycle_num: increase or decrease the duty every cycle_num cycles
• fade_mode: choose blocking or non-blocking mode
esp_err_t ledc_cb_register(ledc_mode_t speed_mode, ledc_channel_t channel, ledc_cbs_t *cbs, void
*user_arg)
LEDC callback registration function.
Note The callback is called from an ISR, it must never attempt to block, and any FreeRTOS API called must
be ISR capable.
Return
• ESP_ERR_INVALID_ARG Parameter error
• ESP_OK Success
• ESP_ERR_INVALID_STATE Fade function not installed.
• ESP_FAIL Fade function init error
Parameters
Espressif Systems 324
Submit Document Feedback
Release v4.4