mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-03 12:44:33 +02:00
refactor(ledc): deprecate ledc_isr_register and ledc_channel_config_t::intr_type
This commit is contained in:
@@ -36,7 +36,7 @@ typedef struct {
|
|||||||
int gpio_num; /*!< the LEDC output gpio_num, if you want to use gpio16, gpio_num = 16 */
|
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_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_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) */
|
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)] */
|
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] */
|
int hpoint; /*!< LEDC channel hpoint value, the range is [0, (2**duty_resolution)-1] */
|
||||||
@@ -331,7 +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_INVALID_ARG Parameter error
|
||||||
* - ESP_ERR_NOT_FOUND Failed to find available interrupt source
|
* - 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);
|
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
|
* @brief Reset LEDC timer
|
||||||
|
@@ -826,7 +826,6 @@ esp_err_t ledc_channel_config(const ledc_channel_config_t *ledc_conf)
|
|||||||
int gpio_num = ledc_conf->gpio_num;
|
int gpio_num = ledc_conf->gpio_num;
|
||||||
uint32_t ledc_channel = ledc_conf->channel;
|
uint32_t ledc_channel = ledc_conf->channel;
|
||||||
uint32_t timer_select = ledc_conf->timer_sel;
|
uint32_t timer_select = ledc_conf->timer_sel;
|
||||||
uint32_t intr_type = ledc_conf->intr_type;
|
|
||||||
uint32_t duty = ledc_conf->duty;
|
uint32_t duty = ledc_conf->duty;
|
||||||
uint32_t hpoint = ledc_conf->hpoint;
|
uint32_t hpoint = ledc_conf->hpoint;
|
||||||
bool output_invert = ledc_conf->flags.output_invert;
|
bool output_invert = ledc_conf->flags.output_invert;
|
||||||
@@ -834,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(speed_mode < LEDC_SPEED_MODE_MAX, "speed_mode");
|
||||||
LEDC_ARG_CHECK(GPIO_IS_VALID_OUTPUT_GPIO(gpio_num), "gpio_num");
|
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(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");
|
LEDC_ARG_CHECK(ledc_conf->sleep_mode < LEDC_SLEEP_MODE_INVALID, "sleep_mode");
|
||||||
#if !SOC_LEDC_SUPPORT_SLEEP_RETENTION
|
#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");
|
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");
|
||||||
@@ -875,10 +873,6 @@ esp_err_t ledc_channel_config(const ledc_channel_config_t *ledc_conf)
|
|||||||
ledc_update_duty(speed_mode, ledc_channel);
|
ledc_update_duty(speed_mode, ledc_channel);
|
||||||
/*bind the channel with the timer*/
|
/*bind the channel with the timer*/
|
||||||
ledc_bind_channel_timer(speed_mode, ledc_channel, timer_select);
|
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,
|
ESP_LOGD(LEDC_TAG, "LEDC_PWM CHANNEL %"PRIu32"|GPIO %02u|Duty %04"PRIu32"|Time %"PRIu32,
|
||||||
ledc_channel, gpio_num, duty, timer_select);
|
ledc_channel, gpio_num, duty, timer_select);
|
||||||
/*set LEDC signal in gpio matrix*/
|
/*set LEDC signal in gpio matrix*/
|
||||||
@@ -1527,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);
|
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
|
//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)
|
void ledc_fade_func_uninstall(void)
|
||||||
|
@@ -90,13 +90,6 @@ TEST_CASE("LEDC channel config wrong channel", "[ledc]")
|
|||||||
TEST_ASSERT(ledc_channel_config(&ledc_ch_config) == ESP_ERR_INVALID_ARG);
|
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]")
|
TEST_CASE("LEDC wrong timer", "[ledc]")
|
||||||
{
|
{
|
||||||
ledc_channel_config_t ledc_ch_config = initialize_channel_config();
|
ledc_channel_config_t ledc_ch_config = initialize_channel_config();
|
||||||
|
@@ -18,7 +18,6 @@ ledc_channel_config_t initialize_channel_config(void)
|
|||||||
config.gpio_num = PULSE_IO;
|
config.gpio_num = PULSE_IO;
|
||||||
config.speed_mode = TEST_SPEED_MODE;
|
config.speed_mode = TEST_SPEED_MODE;
|
||||||
config.channel = LEDC_CHANNEL_0;
|
config.channel = LEDC_CHANNEL_0;
|
||||||
config.intr_type = LEDC_INTR_DISABLE;
|
|
||||||
config.timer_sel = LEDC_TIMER_0;
|
config.timer_sel = LEDC_TIMER_0;
|
||||||
config.duty = 4000;
|
config.duty = 4000;
|
||||||
config.hpoint = 0;
|
config.hpoint = 0;
|
||||||
|
@@ -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.
|
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
|
Power Management
|
||||||
----------------
|
----------------
|
||||||
|
|
||||||
|
@@ -58,6 +58,10 @@ LEDC
|
|||||||
|
|
||||||
- Removed esp_driver_gpio as a public required component from esp_driver_ledc.
|
- 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
|
I2C
|
||||||
---
|
---
|
||||||
|
|
||||||
|
@@ -332,14 +332,6 @@ LED PWM 控制器 API 有多种方式即时改变 PWM 频率:
|
|||||||
第一个定时器复位函数在函数 :cpp:func:`ledc_timer_config` 内部完成所有定时器配置后会被调用一次。
|
第一个定时器复位函数在函数 :cpp:func:`ledc_timer_config` 内部完成所有定时器配置后会被调用一次。
|
||||||
|
|
||||||
|
|
||||||
使用中断
|
|
||||||
^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
配置 LED PWM 控制器通道时,可在 :cpp:type:`ledc_channel_config_t` 中选取参数 :cpp:type:`ledc_intr_type_t` ,在渐变完成时触发中断。
|
|
||||||
|
|
||||||
要注册处理程序来处理中断,可调用函数 :cpp:func:`ledc_isr_register`。
|
|
||||||
|
|
||||||
|
|
||||||
电源管理
|
电源管理
|
||||||
--------
|
--------
|
||||||
|
|
||||||
|
@@ -58,6 +58,10 @@ LEDC
|
|||||||
|
|
||||||
- esp_driver_gpio 不再作为 esp_driver_ledc 的公共依赖组件。
|
- 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
|
I2C
|
||||||
---
|
---
|
||||||
|
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
dependencies:
|
dependencies:
|
||||||
espressif/esp_cam_sensor: "^1.1.0"
|
espressif/esp_cam_sensor: "^1.2.1"
|
||||||
idf:
|
idf:
|
||||||
version: ">=5.3.0"
|
version: ">=5.3.0"
|
||||||
|
@@ -234,7 +234,6 @@ static void example_rgb_ledc_init(void)
|
|||||||
ledc_channel_config_t ledc_channel = {
|
ledc_channel_config_t ledc_channel = {
|
||||||
.speed_mode = LEDC_MODE,
|
.speed_mode = LEDC_MODE,
|
||||||
.timer_sel = LEDC_TIMER,
|
.timer_sel = LEDC_TIMER,
|
||||||
.intr_type = LEDC_INTR_DISABLE,
|
|
||||||
.duty = 0, // Set initial duty to 0%
|
.duty = 0, // Set initial duty to 0%
|
||||||
.hpoint = 0
|
.hpoint = 0
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user