Skip to content

Commit

Permalink
Merge branch 'doc/explain_ledc_callback_return_value_v5.0' into 'rele…
Browse files Browse the repository at this point in the history
…ase/v5.0'

ledc: explain the callback return value (v5.0)

See merge request espressif/esp-idf!20966
  • Loading branch information
suda-morris committed Dec 6, 2022
2 parents ffdec34 + 2dd67ec commit e843281
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
12 changes: 7 additions & 5 deletions components/driver/include/driver/ledc.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,9 @@ typedef struct {
* @brief Type of LEDC event callback
* @param param LEDC callback parameter
* @param user_arg User registered data
* @return Whether a high priority task has been waken up by this function
*/
typedef bool (* ledc_cb_t)(const ledc_cb_param_t *param, void *user_arg);
typedef bool (*ledc_cb_t)(const ledc_cb_param_t *param, void *user_arg);

/**
* @brief Group of supported LEDC callbacks
Expand All @@ -111,7 +112,7 @@ typedef struct {
* - ESP_OK Success
* - ESP_ERR_INVALID_ARG Parameter error
*/
esp_err_t ledc_channel_config(const ledc_channel_config_t* ledc_conf);
esp_err_t ledc_channel_config(const ledc_channel_config_t *ledc_conf);

/**
* @brief LEDC timer configuration
Expand All @@ -124,7 +125,7 @@ esp_err_t ledc_channel_config(const ledc_channel_config_t* ledc_conf);
* - ESP_ERR_INVALID_ARG Parameter error
* - ESP_FAIL Can not find a proper pre-divider number base on the given frequency and the current duty_resolution.
*/
esp_err_t ledc_timer_config(const ledc_timer_config_t* timer_conf);
esp_err_t ledc_timer_config(const ledc_timer_config_t *timer_conf);

/**
* @brief LEDC update channel parameters
Expand Down Expand Up @@ -299,7 +300,7 @@ esp_err_t ledc_set_fade(ledc_mode_t speed_mode, ledc_channel_t channel, uint32_t
* - ESP_OK Success
* - ESP_ERR_INVALID_ARG Function pointer error.
*/
esp_err_t ledc_isr_register(void (*fn)(void*), void * arg, int intr_alloc_flags, ledc_isr_handle_t *handle);
esp_err_t ledc_isr_register(void (*fn)(void *), void *arg, int intr_alloc_flags, ledc_isr_handle_t *handle);

/**
* @brief Configure LEDC settings
Expand Down Expand Up @@ -462,7 +463,7 @@ esp_err_t ledc_fade_start(ledc_mode_t speed_mode, ledc_channel_t channel, ledc_f
* - ESP_ERR_INVALID_ARG Parameter error.
*/
esp_err_t ledc_fade_stop(ledc_mode_t speed_mode, ledc_channel_t channel);
#endif
#endif //SOC_LEDC_SUPPORT_FADE_STOP

/**
* @brief A thread-safe API to set duty for LEDC channel and return when duty updated.
Expand Down Expand Up @@ -528,6 +529,7 @@ esp_err_t ledc_set_fade_step_and_start(ledc_mode_t speed_mode, ledc_channel_t ch
* - ESP_FAIL Fade function init error
*/
esp_err_t ledc_cb_register(ledc_mode_t speed_mode, ledc_channel_t channel, ledc_cbs_t *cbs, void *user_arg);

#ifdef __cplusplus
}
#endif
2 changes: 1 addition & 1 deletion docs/en/api-reference/peripherals/ledc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ The LEDC hardware provides the means to gradually transition from one duty cycle

Start fading with :cpp:func:`ledc_fade_start`. A fade can be operated in blocking or non-blocking mode, please check :cpp:enum:`ledc_fade_mode_t` for the difference between the two available fade modes. Note that with either fade mode, the next fade or fixed-duty update will not take effect until the last fade finishes or is stopped. :cpp:func:`ledc_fade_stop` has to be called to stop a fade that is in progress.

To get a notification about the completion of a fade operation, a fade end callback function can be registered for each channel by calling :cpp:func:`ledc_cb_register` after the fade service being installed.
To get a notification about the completion of a fade operation, a fade end callback function can be registered for each channel by calling :cpp:func:`ledc_cb_register` after the fade service being installed. The fade end callback prototype is defined in :cpp:type:`ledc_cb_t`, where you should return a boolean value from the callback function, indicating whether a high priority task is woken up by this callback function.

If not required anymore, fading and an associated interrupt can be disabled with :cpp:func:`ledc_fade_func_uninstall`.

Expand Down

0 comments on commit e843281

Please sign in to comment.