Support IDF version < v4.3
This commit is contained in:
parent
3c4399d510
commit
11c240daca
|
@ -10,7 +10,8 @@
|
||||||
#include "driver/ledc.h"
|
#include "driver/ledc.h"
|
||||||
#include "driver/gpio.h"
|
#include "driver/gpio.h"
|
||||||
#include "esp_log.h"
|
#include "esp_log.h"
|
||||||
#include "esp_rom_gpio.h" // for output signal inversion
|
#include "esp_rom_gpio.h" // for output signal inversion
|
||||||
|
#include "soc/ledc_periph.h" // to invert LEDC output on IDF version < v4.3
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
bool pwm_control; // true: LEDC is used, false: GPIO is used
|
bool pwm_control; // true: LEDC is used, false: GPIO is used
|
||||||
|
@ -40,8 +41,7 @@ disp_backlight_h disp_backlight_new(const disp_backlight_config_t *config)
|
||||||
.intr_type = LEDC_INTR_DISABLE,
|
.intr_type = LEDC_INTR_DISABLE,
|
||||||
.timer_sel = config->timer_idx,
|
.timer_sel = config->timer_idx,
|
||||||
.duty = 0,
|
.duty = 0,
|
||||||
.hpoint = 0,
|
.hpoint = 0
|
||||||
.flags.output_invert = config->output_invert //@todo added only in recent IDF versions
|
|
||||||
};
|
};
|
||||||
const ledc_timer_config_t LCD_backlight_timer = {
|
const ledc_timer_config_t LCD_backlight_timer = {
|
||||||
.speed_mode = LEDC_LOW_SPEED_MODE,
|
.speed_mode = LEDC_LOW_SPEED_MODE,
|
||||||
|
@ -52,6 +52,7 @@ disp_backlight_h disp_backlight_new(const disp_backlight_config_t *config)
|
||||||
|
|
||||||
ESP_ERROR_CHECK(ledc_timer_config(&LCD_backlight_timer));
|
ESP_ERROR_CHECK(ledc_timer_config(&LCD_backlight_timer));
|
||||||
ESP_ERROR_CHECK(ledc_channel_config(&LCD_backlight_channel));
|
ESP_ERROR_CHECK(ledc_channel_config(&LCD_backlight_channel));
|
||||||
|
esp_rom_gpio_connect_out_signal(config->gpio_num, ledc_periph_signal[LEDC_LOW_SPEED_MODE].sig_out0_idx + config->channel_idx, config->output_invert, 0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue