esp_lcd_backlight: Handle different versions of ESP-IDF
This commit is contained in:
parent
9b666658ea
commit
2f70856205
1 changed files with 17 additions and 0 deletions
|
@ -12,6 +12,11 @@
|
|||
#include "esp_log.h"
|
||||
#include "soc/ledc_periph.h" // to invert LEDC output on IDF version < v4.3
|
||||
|
||||
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 3, 0)
|
||||
#include "esp_rom_gpio.h"
|
||||
#include "soc/gpio_sig_map.h"
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
bool pwm_control; // true: LEDC is used, false: GPIO is used
|
||||
int index; // Either GPIO or LEDC channel
|
||||
|
@ -56,15 +61,27 @@ 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_channel_config(&LCD_backlight_channel));
|
||||
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 3, 0)
|
||||
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
|
||||
gpio_matrix_out(config->gpio_num, ledc_periph_signal[LEDC_LOW_SPEED_MODE].sig_out0_idx + config->channel_idx, config->output_invert, 0);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
// Configure GPIO for output
|
||||
bckl_dev->index = config->gpio_num;
|
||||
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 3, 0)
|
||||
esp_rom_gpio_pad_select_gpio(config->num);
|
||||
#else
|
||||
gpio_pad_select_gpio(config->gpio_num);
|
||||
#endif
|
||||
ESP_ERROR_CHECK(gpio_set_direction(config->gpio_num, GPIO_MODE_OUTPUT));
|
||||
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 3, 0)
|
||||
esp_rom_gpio_connect_out_signal(config->gpio_num, SIG_GPIO_OUT_IDX, config->output_invert, false);
|
||||
#else
|
||||
gpio_matrix_out(config->gpio_num, SIG_GPIO_OUT_IDX, config->output_invert, false);
|
||||
#endif
|
||||
}
|
||||
|
||||
return (disp_backlight_h)bckl_dev;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue