diff --git a/components/esp_driver_ledc/CMakeLists.txt b/components/esp_driver_ledc/CMakeLists.txt index cab83e6222..e16690efab 100644 --- a/components/esp_driver_ledc/CMakeLists.txt +++ b/components/esp_driver_ledc/CMakeLists.txt @@ -10,13 +10,12 @@ endif() if(${target} STREQUAL "linux") set(priv_requires "") else() - set(priv_requires esp_pm) + set(priv_requires esp_pm esp_driver_gpio) endif() idf_component_register( SRCS ${srcs} INCLUDE_DIRS ${public_include} PRIV_REQUIRES "${priv_requires}" - REQUIRES esp_driver_gpio # IDF-11989: Remove this in IDF v6.0 LDFRAGMENTS "linker.lf" ) diff --git a/components/esp_driver_ledc/include/driver/ledc.h b/components/esp_driver_ledc/include/driver/ledc.h index 8aac882873..c5f9d5a737 100644 --- a/components/esp_driver_ledc/include/driver/ledc.h +++ b/components/esp_driver_ledc/include/driver/ledc.h @@ -9,27 +9,11 @@ #include "esp_err.h" #include "esp_intr_alloc.h" #include "hal/ledc_types.h" -#include "driver/gpio.h" #ifdef __cplusplus extern "C" { #endif -#if SOC_LEDC_SUPPORT_APB_CLOCK -/** - * @brief Frequency of one of the LEDC peripheral clock sources, APB_CLK - * @note This macro should have no use in your application, we keep it here only for backward compatible - */ -#define LEDC_APB_CLK_HZ _Pragma ("GCC warning \"'LEDC_APB_CLK_HZ' macro is deprecated\"") (APB_CLK_FREQ) -#endif -#if SOC_LEDC_SUPPORT_REF_TICK -/** - * @brief Frequency of one of the LEDC peripheral clock sources, REF_TICK - * @note This macro should have no use in your application, we keep it here only for backward compatible - */ -#define LEDC_REF_CLK_HZ _Pragma ("GCC warning \"'LEDC_REF_CLK_HZ' macro is deprecated\"") (REF_CLK_FREQ) -#endif - #define LEDC_ERR_DUTY (0xFFFFFFFF) #define LEDC_ERR_VAL (-1) @@ -52,7 +36,7 @@ typedef struct { int gpio_num; /*!< the LEDC output gpio_num, if you want to use gpio16, gpio_num = 16 */ ledc_mode_t speed_mode; /*!< LEDC speed speed_mode, high-speed mode (only exists on esp32) or low-speed mode */ ledc_channel_t channel; /*!< LEDC channel (0 - LEDC_CHANNEL_MAX-1) */ - ledc_intr_type_t intr_type; /*!< configure interrupt, Fade interrupt enable or Fade interrupt disable */ + ledc_intr_type_t intr_type __attribute__((deprecated)); /*!< @deprecated, no need to explicitly configure interrupt, handled in the driver */ ledc_timer_t timer_sel; /*!< Select the timer source of channel (0 - LEDC_TIMER_MAX-1) */ uint32_t duty; /*!< LEDC channel duty, the range of duty setting is [0, (2**duty_resolution)] */ int hpoint; /*!< LEDC channel hpoint value, the range is [0, (2**duty_resolution)-1] */ @@ -347,28 +331,7 @@ esp_err_t ledc_set_fade(ledc_mode_t speed_mode, ledc_channel_t channel, uint32_t * - ESP_ERR_INVALID_ARG Parameter error * - ESP_ERR_NOT_FOUND Failed to find available interrupt source */ -esp_err_t ledc_isr_register(void (*fn)(void *), void *arg, int intr_alloc_flags, ledc_isr_handle_t *handle); - -/** - * @brief Configure LEDC timer settings - * - * This function does not take care of whether the chosen clock source is enabled or not, also does not handle the clock source - * to meet channel sleep mode choice. - * - * If the chosen clock source is a new clock source to the LEDC timer, please use `ledc_timer_config`; - * If the clock source is kept to be the same, but frequency needs to be updated, please use `ledc_set_freq`. - * - * @param speed_mode Select the LEDC channel group with specified speed mode. Note that not all targets support high speed mode. - * @param timer_sel Timer index (0-3), there are 4 timers in LEDC module - * @param clock_divider Timer clock divide value, the timer clock is divided from the selected clock source - * @param duty_resolution Resolution of duty setting in number of bits. The range is [1, SOC_LEDC_TIMER_BIT_WIDTH] - * @param clk_src Select LEDC source clock. - * - * @return - * - (-1) Parameter error - * - Other Current LEDC duty - */ -esp_err_t ledc_timer_set(ledc_mode_t speed_mode, ledc_timer_t timer_sel, uint32_t clock_divider, uint32_t duty_resolution, ledc_clk_src_t clk_src) __attribute__((deprecated("Please use ledc_timer_config() or ledc_set_freq()"))); +esp_err_t ledc_isr_register(void (*fn)(void *), void *arg, int intr_alloc_flags, ledc_isr_handle_t *handle) __attribute__((deprecated("LEDC interrupt handling is implemented by driver itself, please only register event callbacks if necessary"))); /** * @brief Reset LEDC timer diff --git a/components/esp_driver_ledc/src/ledc.c b/components/esp_driver_ledc/src/ledc.c index 1db84af62c..3ab3483dcb 100644 --- a/components/esp_driver_ledc/src/ledc.c +++ b/components/esp_driver_ledc/src/ledc.c @@ -20,6 +20,7 @@ #include "clk_ctrl_os.h" #include "esp_private/esp_sleep_internal.h" #include "esp_private/periph_ctrl.h" +#include "driver/gpio.h" #include "esp_private/gpio.h" #include "esp_private/esp_clk_tree_common.h" #include "esp_private/esp_gpio_reserve.h" @@ -260,13 +261,6 @@ static esp_err_t ledc_set_timer_params(ledc_mode_t speed_mode, ledc_timer_t time return ESP_OK; } -// Deprecated public API -esp_err_t ledc_timer_set(ledc_mode_t speed_mode, ledc_timer_t timer_sel, uint32_t clock_divider, uint32_t duty_resolution, - ledc_clk_src_t clk_src) -{ - return ledc_set_timer_params(speed_mode, timer_sel, clock_divider, duty_resolution, clk_src); -} - static IRAM_ATTR esp_err_t ledc_duty_config(ledc_mode_t speed_mode, ledc_channel_t channel, int hpoint_val, int duty_val, ledc_duty_direction_t duty_direction, uint32_t duty_num, uint32_t duty_cycle, uint32_t duty_scale) { @@ -832,7 +826,6 @@ esp_err_t ledc_channel_config(const ledc_channel_config_t *ledc_conf) int gpio_num = ledc_conf->gpio_num; uint32_t ledc_channel = ledc_conf->channel; uint32_t timer_select = ledc_conf->timer_sel; - uint32_t intr_type = ledc_conf->intr_type; uint32_t duty = ledc_conf->duty; uint32_t hpoint = ledc_conf->hpoint; bool output_invert = ledc_conf->flags.output_invert; @@ -840,7 +833,6 @@ esp_err_t ledc_channel_config(const ledc_channel_config_t *ledc_conf) LEDC_ARG_CHECK(speed_mode < LEDC_SPEED_MODE_MAX, "speed_mode"); LEDC_ARG_CHECK(GPIO_IS_VALID_OUTPUT_GPIO(gpio_num), "gpio_num"); LEDC_ARG_CHECK(timer_select < LEDC_TIMER_MAX, "timer_select"); - LEDC_ARG_CHECK(intr_type < LEDC_INTR_MAX, "intr_type"); LEDC_ARG_CHECK(ledc_conf->sleep_mode < LEDC_SLEEP_MODE_INVALID, "sleep_mode"); #if !SOC_LEDC_SUPPORT_SLEEP_RETENTION ESP_RETURN_ON_FALSE(ledc_conf->sleep_mode != LEDC_SLEEP_MODE_NO_ALIVE_ALLOW_PD, ESP_ERR_NOT_SUPPORTED, LEDC_TAG, "register back up is not supported"); @@ -881,10 +873,6 @@ esp_err_t ledc_channel_config(const ledc_channel_config_t *ledc_conf) ledc_update_duty(speed_mode, ledc_channel); /*bind the channel with the timer*/ ledc_bind_channel_timer(speed_mode, ledc_channel, timer_select); - /*set interrupt type*/ - portENTER_CRITICAL(&ledc_spinlock); - ledc_enable_intr_type(speed_mode, ledc_channel, intr_type); - portEXIT_CRITICAL(&ledc_spinlock); ESP_LOGD(LEDC_TAG, "LEDC_PWM CHANNEL %"PRIu32"|GPIO %02u|Duty %04"PRIu32"|Time %"PRIu32, ledc_channel, gpio_num, duty, timer_select); /*set LEDC signal in gpio matrix*/ @@ -975,7 +963,7 @@ esp_err_t ledc_channel_config(const ledc_channel_config_t *ledc_conf) static void _ledc_update_duty(ledc_mode_t speed_mode, ledc_channel_t channel) { ledc_hal_set_sig_out_en(&(p_ledc_obj[speed_mode]->ledc_hal), channel, true); - ledc_hal_set_duty_start(&(p_ledc_obj[speed_mode]->ledc_hal), channel, true); + ledc_hal_set_duty_start(&(p_ledc_obj[speed_mode]->ledc_hal), channel); ledc_ls_channel_update(speed_mode, channel); } @@ -998,7 +986,6 @@ esp_err_t ledc_stop(ledc_mode_t speed_mode, ledc_channel_t channel, uint32_t idl portENTER_CRITICAL_SAFE(&ledc_spinlock); ledc_hal_set_idle_level(&(p_ledc_obj[speed_mode]->ledc_hal), channel, idle_level); ledc_hal_set_sig_out_en(&(p_ledc_obj[speed_mode]->ledc_hal), channel, false); - ledc_hal_set_duty_start(&(p_ledc_obj[speed_mode]->ledc_hal), channel, false); ledc_ls_channel_update(speed_mode, channel); portEXIT_CRITICAL_SAFE(&ledc_spinlock); return ESP_OK; @@ -1261,7 +1248,7 @@ static void IRAM_ATTR ledc_fade_isr(void *arg) cycle, scale); s_ledc_fade_rec[speed_mode][channel]->fsm = LEDC_FSM_HW_FADE; - ledc_hal_set_duty_start(&(p_ledc_obj[speed_mode]->ledc_hal), channel, true); + ledc_hal_set_duty_start(&(p_ledc_obj[speed_mode]->ledc_hal), channel); ledc_ls_channel_update(speed_mode, channel); } portEXIT_CRITICAL_ISR(&ledc_spinlock); @@ -1534,7 +1521,7 @@ esp_err_t ledc_fade_func_install(int intr_alloc_flags) { LEDC_CHECK(s_ledc_fade_isr_handle == NULL, "fade function already installed", ESP_ERR_INVALID_STATE); //OR intr_alloc_flags with ESP_INTR_FLAG_IRAM because the fade isr is in IRAM - return ledc_isr_register(ledc_fade_isr, NULL, intr_alloc_flags | ESP_INTR_FLAG_IRAM, &s_ledc_fade_isr_handle); + return esp_intr_alloc(ETS_LEDC_INTR_SOURCE, intr_alloc_flags | ESP_INTR_FLAG_IRAM, ledc_fade_isr, NULL, &s_ledc_fade_isr_handle); } void ledc_fade_func_uninstall(void) diff --git a/components/esp_driver_ledc/test_apps/ledc/main/test_ledc.c b/components/esp_driver_ledc/test_apps/ledc/main/test_ledc.c index c6a3a7483e..3d8f548f41 100644 --- a/components/esp_driver_ledc/test_apps/ledc/main/test_ledc.c +++ b/components/esp_driver_ledc/test_apps/ledc/main/test_ledc.c @@ -14,14 +14,13 @@ #include "freertos/FreeRTOS.h" #include "freertos/task.h" #include "unity.h" -#include "soc/gpio_periph.h" -#include "soc/io_mux_reg.h" #include "esp_system.h" #include "esp_timer.h" #include "driver/ledc.h" #include "soc/ledc_struct.h" #include "esp_clk_tree.h" #include "test_ledc_utils.h" +#include "driver/gpio.h" static void fade_setup(void) { @@ -91,13 +90,6 @@ TEST_CASE("LEDC channel config wrong channel", "[ledc]") TEST_ASSERT(ledc_channel_config(&ledc_ch_config) == ESP_ERR_INVALID_ARG); } -TEST_CASE("LEDC channel config wrong interrupt type", "[ledc]") -{ - ledc_channel_config_t ledc_ch_config = initialize_channel_config(); - ledc_ch_config.intr_type = 2; - TEST_ASSERT_EQUAL(ESP_ERR_INVALID_ARG, ledc_channel_config(&ledc_ch_config)); -} - TEST_CASE("LEDC wrong timer", "[ledc]") { ledc_channel_config_t ledc_ch_config = initialize_channel_config(); @@ -150,6 +142,12 @@ TEST_CASE("LEDC output idle level test", "[ledc]") TEST_ESP_OK(ledc_stop(test_speed_mode, LEDC_CHANNEL_0, !current_level)); vTaskDelay(1000 / portTICK_PERIOD_MS); TEST_ASSERT_EQUAL_INT32(!current_level, LEDC.channel_group[test_speed_mode].channel[LEDC_CHANNEL_0].conf0.idle_lv); + // check real output level over some period + gpio_input_enable(PULSE_IO); + for (int i = 0; i < 40; i++) { + TEST_ASSERT_EQUAL_INT32(!current_level, gpio_get_level(PULSE_IO)); + esp_rom_delay_us(50); + } } TEST_CASE("LEDC iterate over all channel and timer configs", "[ledc]") diff --git a/components/esp_driver_ledc/test_apps/ledc/main/test_ledc_utils.c b/components/esp_driver_ledc/test_apps/ledc/main/test_ledc_utils.c index a7b0c844b6..8dece59874 100644 --- a/components/esp_driver_ledc/test_apps/ledc/main/test_ledc_utils.c +++ b/components/esp_driver_ledc/test_apps/ledc/main/test_ledc_utils.c @@ -18,7 +18,6 @@ ledc_channel_config_t initialize_channel_config(void) config.gpio_num = PULSE_IO; config.speed_mode = TEST_SPEED_MODE; config.channel = LEDC_CHANNEL_0; - config.intr_type = LEDC_INTR_DISABLE; config.timer_sel = LEDC_TIMER_0; config.duty = 4000; config.hpoint = 0; diff --git a/components/hal/esp32/include/hal/ledc_ll.h b/components/hal/esp32/include/hal/ledc_ll.h index 9f98ecc72a..198c56bd5d 100644 --- a/components/hal/esp32/include/hal/ledc_ll.h +++ b/components/hal/esp32/include/hal/ledc_ll.h @@ -481,13 +481,15 @@ static inline void ledc_ll_set_sig_out_en(ledc_dev_t *hw, ledc_mode_t speed_mode * @param hw Beginning address of the peripheral registers * @param speed_mode LEDC speed_mode, high-speed mode or low-speed mode * @param channel_num LEDC channel index (0-7), select from ledc_channel_t - * @param duty_start The duty start * * @return None */ -static inline void ledc_ll_set_duty_start(ledc_dev_t *hw, ledc_mode_t speed_mode, ledc_channel_t channel_num, bool duty_start) +static inline void ledc_ll_set_duty_start(ledc_dev_t *hw, ledc_mode_t speed_mode, ledc_channel_t channel_num) { - hw->channel_group[speed_mode].channel[channel_num].conf1.duty_start = duty_start; + // wait until the last duty change took effect (duty_start bit will be self-cleared when duty update or fade is done) + // this is necessary on ESP32 only, otherwise, internal logic might mess up (later targets with SOC_LEDC_SUPPORT_FADE_STOP allow to re-configure parameters while last update is still in progress) + while (hw->channel_group[speed_mode].channel[channel_num].conf1.duty_start); + hw->channel_group[speed_mode].channel[channel_num].conf1.duty_start = 1; } /** diff --git a/components/hal/esp32c2/include/hal/ledc_ll.h b/components/hal/esp32c2/include/hal/ledc_ll.h index 0470664986..04d2517f77 100644 --- a/components/hal/esp32c2/include/hal/ledc_ll.h +++ b/components/hal/esp32c2/include/hal/ledc_ll.h @@ -458,13 +458,12 @@ static inline void ledc_ll_set_sig_out_en(ledc_dev_t *hw, ledc_mode_t speed_mode * @param hw Beginning address of the peripheral registers * @param speed_mode LEDC speed_mode, high-speed mode or low-speed mode * @param channel_num LEDC channel index (0-7), select from ledc_channel_t - * @param duty_start The duty start * * @return None */ -static inline void ledc_ll_set_duty_start(ledc_dev_t *hw, ledc_mode_t speed_mode, ledc_channel_t channel_num, bool duty_start) +static inline void ledc_ll_set_duty_start(ledc_dev_t *hw, ledc_mode_t speed_mode, ledc_channel_t channel_num) { - hw->channel_group[speed_mode].channel[channel_num].conf1.duty_start = duty_start; + hw->channel_group[speed_mode].channel[channel_num].conf1.duty_start = 1; } /** diff --git a/components/hal/esp32c3/include/hal/ledc_ll.h b/components/hal/esp32c3/include/hal/ledc_ll.h index f96582f614..ae7dfcc94e 100644 --- a/components/hal/esp32c3/include/hal/ledc_ll.h +++ b/components/hal/esp32c3/include/hal/ledc_ll.h @@ -459,13 +459,12 @@ static inline void ledc_ll_set_sig_out_en(ledc_dev_t *hw, ledc_mode_t speed_mode * @param hw Beginning address of the peripheral registers * @param speed_mode LEDC speed_mode, high-speed mode or low-speed mode * @param channel_num LEDC channel index (0-7), select from ledc_channel_t - * @param duty_start The duty start * * @return None */ -static inline void ledc_ll_set_duty_start(ledc_dev_t *hw, ledc_mode_t speed_mode, ledc_channel_t channel_num, bool duty_start) +static inline void ledc_ll_set_duty_start(ledc_dev_t *hw, ledc_mode_t speed_mode, ledc_channel_t channel_num) { - hw->channel_group[speed_mode].channel[channel_num].conf1.duty_start = duty_start; + hw->channel_group[speed_mode].channel[channel_num].conf1.duty_start = 1; } /** diff --git a/components/hal/esp32c5/include/hal/ledc_ll.h b/components/hal/esp32c5/include/hal/ledc_ll.h index 184ba2355d..3e237c6801 100644 --- a/components/hal/esp32c5/include/hal/ledc_ll.h +++ b/components/hal/esp32c5/include/hal/ledc_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -458,13 +458,12 @@ static inline void ledc_ll_set_sig_out_en(ledc_dev_t *hw, ledc_mode_t speed_mode * @param hw Beginning address of the peripheral registers * @param speed_mode LEDC speed_mode, low-speed mode only * @param channel_num LEDC channel index (0-5), select from ledc_channel_t - * @param duty_start The duty start * * @return None */ -static inline void ledc_ll_set_duty_start(ledc_dev_t *hw, ledc_mode_t speed_mode, ledc_channel_t channel_num, bool duty_start) +static inline void ledc_ll_set_duty_start(ledc_dev_t *hw, ledc_mode_t speed_mode, ledc_channel_t channel_num) { - hw->channel_group[speed_mode].channel[channel_num].conf1.duty_start = duty_start; + hw->channel_group[speed_mode].channel[channel_num].conf1.duty_start = 1; } /** diff --git a/components/hal/esp32c6/include/hal/ledc_ll.h b/components/hal/esp32c6/include/hal/ledc_ll.h index a7f1374c4b..e6a0c73e3f 100644 --- a/components/hal/esp32c6/include/hal/ledc_ll.h +++ b/components/hal/esp32c6/include/hal/ledc_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -579,13 +579,12 @@ static inline void ledc_ll_set_sig_out_en(ledc_dev_t *hw, ledc_mode_t speed_mode * @param hw Beginning address of the peripheral registers * @param speed_mode LEDC speed_mode, low-speed mode only * @param channel_num LEDC channel index (0-5), select from ledc_channel_t - * @param duty_start The duty start * * @return None */ -static inline void ledc_ll_set_duty_start(ledc_dev_t *hw, ledc_mode_t speed_mode, ledc_channel_t channel_num, bool duty_start) +static inline void ledc_ll_set_duty_start(ledc_dev_t *hw, ledc_mode_t speed_mode, ledc_channel_t channel_num) { - hw->channel_group[speed_mode].channel[channel_num].conf1.duty_start = duty_start; + hw->channel_group[speed_mode].channel[channel_num].conf1.duty_start = 1; } /** diff --git a/components/hal/esp32c61/include/hal/ledc_ll.h b/components/hal/esp32c61/include/hal/ledc_ll.h index 38da76b0f5..4cd0f760ae 100644 --- a/components/hal/esp32c61/include/hal/ledc_ll.h +++ b/components/hal/esp32c61/include/hal/ledc_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -458,13 +458,12 @@ static inline void ledc_ll_set_sig_out_en(ledc_dev_t *hw, ledc_mode_t speed_mode * @param hw Beginning address of the peripheral registers * @param speed_mode LEDC speed_mode, low-speed mode only * @param channel_num LEDC channel index (0-5), select from ledc_channel_t - * @param duty_start The duty start * * @return None */ -static inline void ledc_ll_set_duty_start(ledc_dev_t *hw, ledc_mode_t speed_mode, ledc_channel_t channel_num, bool duty_start) +static inline void ledc_ll_set_duty_start(ledc_dev_t *hw, ledc_mode_t speed_mode, ledc_channel_t channel_num) { - hw->channel_group[speed_mode].channel[channel_num].conf1.duty_start = duty_start; + hw->channel_group[speed_mode].channel[channel_num].conf1.duty_start = 1; } /** diff --git a/components/hal/esp32h2/include/hal/ledc_ll.h b/components/hal/esp32h2/include/hal/ledc_ll.h index 56ae897e13..8351003001 100644 --- a/components/hal/esp32h2/include/hal/ledc_ll.h +++ b/components/hal/esp32h2/include/hal/ledc_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -577,13 +577,12 @@ static inline void ledc_ll_set_sig_out_en(ledc_dev_t *hw, ledc_mode_t speed_mode * @param hw Beginning address of the peripheral registers * @param speed_mode LEDC speed_mode, low-speed mode only * @param channel_num LEDC channel index (0-5), select from ledc_channel_t - * @param duty_start The duty start * * @return None */ -static inline void ledc_ll_set_duty_start(ledc_dev_t *hw, ledc_mode_t speed_mode, ledc_channel_t channel_num, bool duty_start) +static inline void ledc_ll_set_duty_start(ledc_dev_t *hw, ledc_mode_t speed_mode, ledc_channel_t channel_num) { - hw->channel_group[speed_mode].channel[channel_num].conf1.duty_start = duty_start; + hw->channel_group[speed_mode].channel[channel_num].conf1.duty_start = 1; } /** diff --git a/components/hal/esp32p4/include/hal/ledc_ll.h b/components/hal/esp32p4/include/hal/ledc_ll.h index 38c3d5358d..76ce621674 100644 --- a/components/hal/esp32p4/include/hal/ledc_ll.h +++ b/components/hal/esp32p4/include/hal/ledc_ll.h @@ -484,13 +484,12 @@ static inline void ledc_ll_set_sig_out_en(ledc_dev_t *hw, ledc_mode_t speed_mode * @param hw Beginning address of the peripheral registers * @param speed_mode LEDC speed_mode, low-speed mode only * @param channel_num LEDC channel index (0-5), select from ledc_channel_t - * @param duty_start The duty start * * @return None */ -static inline void ledc_ll_set_duty_start(ledc_dev_t *hw, ledc_mode_t speed_mode, ledc_channel_t channel_num, bool duty_start) +static inline void ledc_ll_set_duty_start(ledc_dev_t *hw, ledc_mode_t speed_mode, ledc_channel_t channel_num) { - hw->channel_group[speed_mode].channel[channel_num].conf1.duty_start = duty_start; + hw->channel_group[speed_mode].channel[channel_num].conf1.duty_start = 1; } /** diff --git a/components/hal/esp32s2/include/hal/ledc_ll.h b/components/hal/esp32s2/include/hal/ledc_ll.h index 2bc2627125..266d18b72a 100644 --- a/components/hal/esp32s2/include/hal/ledc_ll.h +++ b/components/hal/esp32s2/include/hal/ledc_ll.h @@ -498,13 +498,12 @@ static inline void ledc_ll_set_sig_out_en(ledc_dev_t *hw, ledc_mode_t speed_mode * @param hw Beginning address of the peripheral registers * @param speed_mode LEDC speed_mode, high-speed mode or low-speed mode * @param channel_num LEDC channel index (0-7), select from ledc_channel_t - * @param duty_start The duty start * * @return None */ -static inline void ledc_ll_set_duty_start(ledc_dev_t *hw, ledc_mode_t speed_mode, ledc_channel_t channel_num, bool duty_start) +static inline void ledc_ll_set_duty_start(ledc_dev_t *hw, ledc_mode_t speed_mode, ledc_channel_t channel_num) { - hw->channel_group[speed_mode].channel[channel_num].conf1.duty_start = duty_start; + hw->channel_group[speed_mode].channel[channel_num].conf1.duty_start = 1; } /** diff --git a/components/hal/esp32s3/include/hal/ledc_ll.h b/components/hal/esp32s3/include/hal/ledc_ll.h index e9a8ad17fd..e012868178 100644 --- a/components/hal/esp32s3/include/hal/ledc_ll.h +++ b/components/hal/esp32s3/include/hal/ledc_ll.h @@ -459,13 +459,12 @@ static inline void ledc_ll_set_sig_out_en(ledc_dev_t *hw, ledc_mode_t speed_mode * @param hw Beginning address of the peripheral registers * @param speed_mode LEDC speed_mode, high-speed mode or low-speed mode * @param channel_num LEDC channel index (0-7), select from ledc_channel_t - * @param duty_start The duty start * * @return None */ -static inline void ledc_ll_set_duty_start(ledc_dev_t *hw, ledc_mode_t speed_mode, ledc_channel_t channel_num, bool duty_start) +static inline void ledc_ll_set_duty_start(ledc_dev_t *hw, ledc_mode_t speed_mode, ledc_channel_t channel_num) { - hw->channel_group[speed_mode].channel[channel_num].conf1.duty_start = duty_start; + hw->channel_group[speed_mode].channel[channel_num].conf1.duty_start = 1; } /** diff --git a/components/hal/include/hal/ledc_hal.h b/components/hal/include/hal/ledc_hal.h index fe9275ee9b..18ac920a2d 100644 --- a/components/hal/include/hal/ledc_hal.h +++ b/components/hal/include/hal/ledc_hal.h @@ -263,11 +263,10 @@ void ledc_hal_ls_channel_update(ledc_hal_context_t *hal, ledc_channel_t channel_ * * @param hal Context of the HAL layer * @param channel_num LEDC channel index (0-7), select from ledc_channel_t - * @param duty_start The duty start * * @return None */ -void ledc_hal_set_duty_start(ledc_hal_context_t *hal, ledc_channel_t channel_num, bool duty_start); +void ledc_hal_set_duty_start(ledc_hal_context_t *hal, ledc_channel_t channel_num); /** * @brief Set LEDC the integer part of duty value diff --git a/components/hal/ledc_hal_iram.c b/components/hal/ledc_hal_iram.c index ac3112caa8..34884c78e7 100644 --- a/components/hal/ledc_hal_iram.c +++ b/components/hal/ledc_hal_iram.c @@ -16,9 +16,9 @@ void ledc_hal_ls_channel_update(ledc_hal_context_t *hal, ledc_channel_t channel_ ledc_ll_ls_channel_update(hal->dev, hal->speed_mode, channel_num); } -void ledc_hal_set_duty_start(ledc_hal_context_t *hal, ledc_channel_t channel_num, bool duty_start) +void ledc_hal_set_duty_start(ledc_hal_context_t *hal, ledc_channel_t channel_num) { - ledc_ll_set_duty_start(hal->dev, hal->speed_mode, channel_num, duty_start); + ledc_ll_set_duty_start(hal->dev, hal->speed_mode, channel_num); } void ledc_hal_set_duty_int_part(ledc_hal_context_t *hal, ledc_channel_t channel_num, uint32_t duty_val) diff --git a/docs/en/api-reference/peripherals/ledc.rst b/docs/en/api-reference/peripherals/ledc.rst index 733caf8361..e0a7fab376 100644 --- a/docs/en/api-reference/peripherals/ledc.rst +++ b/docs/en/api-reference/peripherals/ledc.rst @@ -332,14 +332,6 @@ There are several individual timer-specific functions that can be used to change The first function is called "behind the scenes" by :cpp:func:`ledc_timer_config` to provide a startup of a timer after it is configured. -Use Interrupts -^^^^^^^^^^^^^^ - -When configuring an LEDC channel, one of the parameters selected within :cpp:type:`ledc_channel_config_t` is :cpp:type:`ledc_intr_type_t` which triggers an interrupt on fade completion. - -For registration of a handler to address this interrupt, call :cpp:func:`ledc_isr_register`. - - Power Management ---------------- diff --git a/docs/en/migration-guides/release-6.x/6.0/peripherals.rst b/docs/en/migration-guides/release-6.x/6.0/peripherals.rst index aec17194ce..dfa18ccf42 100644 --- a/docs/en/migration-guides/release-6.x/6.0/peripherals.rst +++ b/docs/en/migration-guides/release-6.x/6.0/peripherals.rst @@ -49,6 +49,19 @@ GPIO :func:`gpio_iomux_in` and :func:`gpio_iomux_out` have been replaced by :func:`gpio_iomux_input` and :func:`gpio_iomux_output`, and have been moved to ``esp_private/gpio.h`` header file as private APIs for internal use only. +LEDC +---- + +- :func:`ledc_timer_set` has been removed. Use :func:`ledc_timer_config` or :func:`ledc_set_freq` instead. + +- ``LEDC_APB_CLK_HZ`` and ``LEDC_REF_CLK_HZ`` have been removed. + +- Removed esp_driver_gpio as a public required component from esp_driver_ledc. + +- :func:`ledc_isr_register` has been deprecated. LEDC interrupt handling is implemented by driver itself, please only register event callbacks if necessary. + +- :cpp:member:`ledc_channel_config_t::intr_type` has been deprecated. `LEDC_INTR_FADE_END` interrupt enable / disable control is handled by the driver internally. Users can still register a callback for this interrupt by :cpp:func:`ledc_cb_register`. + I2C --- diff --git a/docs/zh_CN/api-reference/peripherals/ledc.rst b/docs/zh_CN/api-reference/peripherals/ledc.rst index 35bc239bc8..0c3f9a0ab0 100644 --- a/docs/zh_CN/api-reference/peripherals/ledc.rst +++ b/docs/zh_CN/api-reference/peripherals/ledc.rst @@ -332,14 +332,6 @@ LED PWM 控制器 API 有多种方式即时改变 PWM 频率: 第一个定时器复位函数在函数 :cpp:func:`ledc_timer_config` 内部完成所有定时器配置后会被调用一次。 -使用中断 -^^^^^^^^^^^^^^ - -配置 LED PWM 控制器通道时,可在 :cpp:type:`ledc_channel_config_t` 中选取参数 :cpp:type:`ledc_intr_type_t` ,在渐变完成时触发中断。 - -要注册处理程序来处理中断,可调用函数 :cpp:func:`ledc_isr_register`。 - - 电源管理 -------- diff --git a/docs/zh_CN/migration-guides/release-6.x/6.0/peripherals.rst b/docs/zh_CN/migration-guides/release-6.x/6.0/peripherals.rst index a2f65540d4..5074835520 100644 --- a/docs/zh_CN/migration-guides/release-6.x/6.0/peripherals.rst +++ b/docs/zh_CN/migration-guides/release-6.x/6.0/peripherals.rst @@ -49,6 +49,19 @@ GPIO :func:`gpio_iomux_in` 和 :func:`gpio_iomux_out` 已被 :func:`gpio_iomux_input` 和 :func:`gpio_iomux_output` 函数取代, 并移至 ``esp_private/gpio.h`` 头文件中作为仅供内部使用的私有 API。 +LEDC +---- + +- :func:`ledc_timer_set` 已被移除。请使用 :func:`ledc_timer_config` 或 :func:`ledc_set_freq` 代替。 + +- ``LEDC_APB_CLK_HZ`` 和 ``LEDC_REF_CLK_HZ`` 已被移除。 + +- esp_driver_gpio 不再作为 esp_driver_ledc 的公共依赖组件。 + +- :func:`ledc_isr_register` 已被弃用。LEDC 中断处理由驱动内部实现,如果需要注册中断回调,仅需要注册事件回调即可。 + +- :cpp:member:`ledc_channel_config_t::intr_type` 已被弃用。`LEDC_INTR_FADE_END` 中断使能/禁用控制由驱动内部处理。用户仍可以通过 :cpp:func:`ledc_cb_register` 注册该中断的回调。 + I2C --- diff --git a/examples/bluetooth/esp_ble_mesh/aligenie_demo/main/aligenie_demo.c b/examples/bluetooth/esp_ble_mesh/aligenie_demo/main/aligenie_demo.c index 58cf187713..2bfd9397ab 100644 --- a/examples/bluetooth/esp_ble_mesh/aligenie_demo/main/aligenie_demo.c +++ b/examples/bluetooth/esp_ble_mesh/aligenie_demo/main/aligenie_demo.c @@ -1,7 +1,7 @@ /* * AliGenie - Example * - * SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Unlicense OR CC0-1.0 */ @@ -419,11 +419,10 @@ void user_genie_event_handle(genie_event_t event, void *p_arg) ESP_LOGI(TAG, "GENIE_EVT_RESET_BY_REPEAT_NOTIFY"); lightbulb_set_switch(false); lightbulb_effect_config_t effect1 = { - .red = 0, - .green = 255, - .blue = 0, - .max_brightness = 100, - .min_brightness = 0, + .hue = 120, + .saturation = 100, + .max_value_brightness = 100, + .min_value_brightness = 0, .effect_cycle_ms = CONFIG_LIGHT_BLINK_PERIOD_MS, .effect_type = EFFECT_BLINK, .mode = WORK_COLOR, @@ -435,11 +434,10 @@ void user_genie_event_handle(genie_event_t event, void *p_arg) ESP_LOGI(TAG, "GENIE_EVT_HW_RESET_START"); lightbulb_set_switch(false); lightbulb_effect_config_t effect2 = { - .red = 0, - .green = 255, - .blue = 0, - .max_brightness = 100, - .min_brightness = 0, + .hue = 120, + .saturation = 100, + .max_value_brightness = 100, + .min_value_brightness = 0, .effect_cycle_ms = CONFIG_LIGHT_BLINK_PERIOD_MS, .effect_type = EFFECT_BLINK, .mode = WORK_COLOR, @@ -1009,7 +1007,7 @@ static void example_ble_mesh_config_server_cb(esp_ble_mesh_cfg_server_cb_event_t #if GENIE_VENDOR_MODEL_VERSION == 0 #elif GENIE_VENDOR_MODEL_VERSION == 1 - // local bind AppKEY and Subcribe Group Address + // local bind AppKEY and Subscribe Group Address local_operation(param->value.state_change.appkey_add.app_idx); // genie mesh init genie_mesh_init(); @@ -1315,11 +1313,10 @@ static esp_err_t ble_mesh_init(void) ESP_LOGW(TAG, "node not provisioned"); lightbulb_set_switch(false); lightbulb_effect_config_t effect3 = { - .red = 0, - .green = 255, - .blue = 0, - .max_brightness = 100, - .min_brightness = 0, + .hue = 120, + .saturation = 100, + .max_value_brightness = 100, + .min_value_brightness = 0, .effect_cycle_ms = CONFIG_LIGHT_BLINK_PERIOD_MS, .effect_type = EFFECT_BLINK, .mode = WORK_COLOR, diff --git a/examples/bluetooth/esp_ble_mesh/aligenie_demo/main/board.c b/examples/bluetooth/esp_ble_mesh/aligenie_demo/main/board.c index dd7170ddba..d572e3cdb1 100644 --- a/examples/bluetooth/esp_ble_mesh/aligenie_demo/main/board.c +++ b/examples/bluetooth/esp_ble_mesh/aligenie_demo/main/board.c @@ -1,7 +1,7 @@ /* * AliGenie - Example * - * SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Unlicense OR CC0-1.0 */ @@ -45,12 +45,12 @@ static void board_led_init(void) lightbulb_config_t config = { .type = DRIVER_ESP_PWM, .driver_conf.pwm.freq_hz = 4000, - .capability.enable_fades = true, - .capability.fades_ms = CONFIG_LIGHT_FADE_PERIOD_MS, + .capability.enable_fade = true, + .capability.fade_time_ms = CONFIG_LIGHT_FADE_PERIOD_MS, .capability.enable_lowpower = false, - .capability.enable_mix_cct = false, + .capability.enable_hardware_cct = false, .capability.enable_status_storage = false, - .capability.mode_mask = COLOR_MODE, + .capability.led_beads = LED_BEADS_3CH_RGB, .capability.storage_cb = NULL, .capability.sync_change_brightness_value = true, .io_conf.pwm_io.red = CONFIG_LIGHT_GPIO_RED, diff --git a/examples/bluetooth/esp_ble_mesh/common_components/light_driver/idf_component.yml b/examples/bluetooth/esp_ble_mesh/common_components/light_driver/idf_component.yml index a70e0dba82..eb0bd538a8 100644 --- a/examples/bluetooth/esp_ble_mesh/common_components/light_driver/idf_component.yml +++ b/examples/bluetooth/esp_ble_mesh/common_components/light_driver/idf_component.yml @@ -1,3 +1,3 @@ ## IDF Component Manager Manifest File dependencies: - espressif/lightbulb_driver: "==0.5.5" + espressif/lightbulb_driver: ">=1.8.3" diff --git a/examples/bluetooth/esp_ble_mesh/directed_forwarding/df_client/main/board.c b/examples/bluetooth/esp_ble_mesh/directed_forwarding/df_client/main/board.c index 30f7b6be5a..affd75c9d4 100644 --- a/examples/bluetooth/esp_ble_mesh/directed_forwarding/df_client/main/board.c +++ b/examples/bluetooth/esp_ble_mesh/directed_forwarding/df_client/main/board.c @@ -2,7 +2,7 @@ /* * SPDX-FileCopyrightText: 2017 Intel Corporation - * SPDX-FileContributor: 2018-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileContributor: 2018-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -61,10 +61,10 @@ static void board_led_init(void) .type = DRIVER_WS2812, .driver_conf.ws2812.led_num = 3, .driver_conf.ws2812.ctrl_io = 8, - .capability.enable_fades = true, - .capability.fades_ms = 800, + .capability.enable_fade = true, + .capability.fade_time_ms = 800, .capability.enable_status_storage = false, - .capability.mode_mask = COLOR_MODE, + .capability.led_beads = LED_BEADS_3CH_RGB, .capability.storage_cb = NULL, .external_limit = NULL, .gamma_conf = NULL, diff --git a/examples/bluetooth/esp_ble_mesh/directed_forwarding/df_server/main/board.c b/examples/bluetooth/esp_ble_mesh/directed_forwarding/df_server/main/board.c index 6134c50f90..c170cb4f50 100644 --- a/examples/bluetooth/esp_ble_mesh/directed_forwarding/df_server/main/board.c +++ b/examples/bluetooth/esp_ble_mesh/directed_forwarding/df_server/main/board.c @@ -2,7 +2,7 @@ /* * SPDX-FileCopyrightText: 2017 Intel Corporation - * SPDX-FileContributor: 2018-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileContributor: 2018-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -58,10 +58,10 @@ static void board_led_init(void) .type = DRIVER_WS2812, .driver_conf.ws2812.led_num = 3, .driver_conf.ws2812.ctrl_io = 8, - .capability.enable_fades = true, - .capability.fades_ms = 800, + .capability.enable_fade = true, + .capability.fade_time_ms = 800, .capability.enable_status_storage = false, - .capability.mode_mask = COLOR_MODE, + .capability.led_beads = LED_BEADS_3CH_RGB, .capability.storage_cb = NULL, .external_limit = NULL, .gamma_conf = NULL, diff --git a/examples/bluetooth/esp_ble_mesh/remote_provisioning/rpr_client/main/board.c b/examples/bluetooth/esp_ble_mesh/remote_provisioning/rpr_client/main/board.c index db6da9b7ce..f86b37d0c8 100644 --- a/examples/bluetooth/esp_ble_mesh/remote_provisioning/rpr_client/main/board.c +++ b/examples/bluetooth/esp_ble_mesh/remote_provisioning/rpr_client/main/board.c @@ -2,7 +2,7 @@ /* * SPDX-FileCopyrightText: 2017 Intel Corporation - * SPDX-FileContributor: 2018-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileContributor: 2018-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -41,10 +41,10 @@ static void board_led_init(void) .type = DRIVER_WS2812, .driver_conf.ws2812.led_num = 3, .driver_conf.ws2812.ctrl_io = 8, - .capability.enable_fades = true, - .capability.fades_ms = 800, + .capability.enable_fade = true, + .capability.fade_time_ms = 800, .capability.enable_status_storage = false, - .capability.mode_mask = COLOR_MODE, + .capability.led_beads = LED_BEADS_3CH_RGB, .capability.storage_cb = NULL, .external_limit = NULL, .gamma_conf = NULL, diff --git a/examples/bluetooth/esp_ble_mesh/remote_provisioning/rpr_server/main/board.c b/examples/bluetooth/esp_ble_mesh/remote_provisioning/rpr_server/main/board.c index d2f8a4d295..bcb3b30886 100644 --- a/examples/bluetooth/esp_ble_mesh/remote_provisioning/rpr_server/main/board.c +++ b/examples/bluetooth/esp_ble_mesh/remote_provisioning/rpr_server/main/board.c @@ -2,7 +2,7 @@ /* * SPDX-FileCopyrightText: 2017 Intel Corporation - * SPDX-FileContributor: 2018-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileContributor: 2018-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -34,10 +34,10 @@ static void board_led_init(void) .type = DRIVER_WS2812, .driver_conf.ws2812.led_num = 3, .driver_conf.ws2812.ctrl_io = 8, - .capability.enable_fades = true, - .capability.fades_ms = 800, + .capability.enable_fade = true, + .capability.fade_time_ms = 800, .capability.enable_status_storage = false, - .capability.mode_mask = COLOR_MODE, + .capability.led_beads = LED_BEADS_3CH_RGB, .capability.storage_cb = NULL, .external_limit = NULL, .gamma_conf = NULL, diff --git a/examples/bluetooth/esp_ble_mesh/remote_provisioning/unprov_dev/main/board.c b/examples/bluetooth/esp_ble_mesh/remote_provisioning/unprov_dev/main/board.c index d2f8a4d295..bcb3b30886 100644 --- a/examples/bluetooth/esp_ble_mesh/remote_provisioning/unprov_dev/main/board.c +++ b/examples/bluetooth/esp_ble_mesh/remote_provisioning/unprov_dev/main/board.c @@ -2,7 +2,7 @@ /* * SPDX-FileCopyrightText: 2017 Intel Corporation - * SPDX-FileContributor: 2018-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileContributor: 2018-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -34,10 +34,10 @@ static void board_led_init(void) .type = DRIVER_WS2812, .driver_conf.ws2812.led_num = 3, .driver_conf.ws2812.ctrl_io = 8, - .capability.enable_fades = true, - .capability.fades_ms = 800, + .capability.enable_fade = true, + .capability.fade_time_ms = 800, .capability.enable_status_storage = false, - .capability.mode_mask = COLOR_MODE, + .capability.led_beads = LED_BEADS_3CH_RGB, .capability.storage_cb = NULL, .external_limit = NULL, .gamma_conf = NULL, diff --git a/examples/peripherals/camera/common_components/sensor_init/idf_component.yml b/examples/peripherals/camera/common_components/sensor_init/idf_component.yml index a5d6718e18..59b5f0ae18 100644 --- a/examples/peripherals/camera/common_components/sensor_init/idf_component.yml +++ b/examples/peripherals/camera/common_components/sensor_init/idf_component.yml @@ -1,4 +1,4 @@ dependencies: - espressif/esp_cam_sensor: "^1.1.0" + espressif/esp_cam_sensor: "^1.2.1" idf: version: ">=5.3.0" diff --git a/examples/peripherals/ledc/ledc_gamma_curve_fade/main/ledc_gamma_curve_fade_example_main.c b/examples/peripherals/ledc/ledc_gamma_curve_fade/main/ledc_gamma_curve_fade_example_main.c index b47e82bc64..29829c1a02 100644 --- a/examples/peripherals/ledc/ledc_gamma_curve_fade/main/ledc_gamma_curve_fade_example_main.c +++ b/examples/peripherals/ledc/ledc_gamma_curve_fade/main/ledc_gamma_curve_fade_example_main.c @@ -234,7 +234,6 @@ static void example_rgb_ledc_init(void) ledc_channel_config_t ledc_channel = { .speed_mode = LEDC_MODE, .timer_sel = LEDC_TIMER, - .intr_type = LEDC_INTR_DISABLE, .duty = 0, // Set initial duty to 0% .hpoint = 0 };