Rename display_bsp to display_hal

The implementation of display hal is MCU dependant, in this example we implement it using the ESP-IDF framework
This commit is contained in:
C47D 2021-08-25 14:43:24 -05:00
parent 2629b6d86a
commit 7cebfdd671
4 changed files with 21 additions and 21 deletions

View file

@ -1,10 +0,0 @@
#ifndef DISPLAY_BSP_H_
#define DISPLAY_BSP_H_
void display_bsp_init_io(void);
void display_bsp_delay(uint32_t delay_ms);
void display_bsp_backlight(uint8_t state);
void display_bsp_gpio_dc(uint8_t state);
void display_bsp_gpio_rst(uint8_t state);
#endif

10
lvgl_tft/display_hal.h Normal file
View file

@ -0,0 +1,10 @@
#ifndef DISPLAY_HAL_H_
#define DISPLAY_HAL_H_
void display_hal_init_io(void);
void display_hal_delay(uint32_t delay_ms);
void display_hal_backlight(uint8_t state);
void display_hal_gpio_dc(uint8_t state);
void display_hal_gpio_rst(uint8_t state);
#endif

View file

@ -10,7 +10,7 @@
#include "st7789.h" #include "st7789.h"
#include "disp_spi.h" #include "disp_spi.h"
#include "display_bsp.h" #include "display_hal.h"
/********************* /*********************
* DEFINES * DEFINES
@ -49,7 +49,7 @@ static void st7789_reset(void);
**********************/ **********************/
void st7789_init(void) void st7789_init(void)
{ {
display_bsp_init_io(); display_hal_init_io();
lcd_init_cmd_t st7789_init_cmds[] = { lcd_init_cmd_t st7789_init_cmds[] = {
{0xCF, {0x00, 0x83, 0X30}, 3}, {0xCF, {0x00, 0x83, 0X30}, 3},
@ -96,7 +96,7 @@ void st7789_init(void)
st7789_send_cmd(st7789_init_cmds[cmd].cmd); st7789_send_cmd(st7789_init_cmds[cmd].cmd);
st7789_send_data(st7789_init_cmds[cmd].data, st7789_init_cmds[cmd].databytes&0x1F); st7789_send_data(st7789_init_cmds[cmd].data, st7789_init_cmds[cmd].databytes&0x1F);
if (st7789_init_cmds[cmd].databytes & 0x80) { if (st7789_init_cmds[cmd].databytes & 0x80) {
display_bsp_delay(100); display_hal_delay(100);
} }
cmd++; cmd++;
} }
@ -116,7 +116,7 @@ void st7789_enable_backlight(bool backlight)
tmp = backlight ? 0 : 1; tmp = backlight ? 0 : 1;
#endif #endif
display_bsp_backlight(tmp); display_hal_backlight(tmp);
#endif #endif
} }
@ -179,21 +179,21 @@ void st7789_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * colo
void st7789_send_cmd(uint8_t cmd) void st7789_send_cmd(uint8_t cmd)
{ {
disp_wait_for_pending_transactions(); disp_wait_for_pending_transactions();
display_bsp_gpio_dc(0); display_hal_gpio_dc(0);
disp_spi_send_data(&cmd, 1); disp_spi_send_data(&cmd, 1);
} }
void st7789_send_data(void * data, uint16_t length) void st7789_send_data(void * data, uint16_t length)
{ {
disp_wait_for_pending_transactions(); disp_wait_for_pending_transactions();
display_bsp_gpio_dc(1); display_hal_gpio_dc(1);
disp_spi_send_data(data, length); disp_spi_send_data(data, length);
} }
static void st7789_send_color(void * data, size_t length) static void st7789_send_color(void * data, size_t length)
{ {
disp_wait_for_pending_transactions(); disp_wait_for_pending_transactions();
display_bsp_gpio_dc(1); display_hal_gpio_dc(1);
disp_spi_send_colors(data, length); disp_spi_send_colors(data, length);
} }
@ -201,10 +201,10 @@ static void st7789_send_color(void * data, size_t length)
static void st7789_reset(void) static void st7789_reset(void)
{ {
#if !defined(CONFIG_LV_DISP_ST7789_SOFT_RESET) #if !defined(CONFIG_LV_DISP_ST7789_SOFT_RESET)
display_bsp_gpio_rst(0); display_hal_gpio_rst(0);
display_bsp_delay(100); display_hal_delay(100);
display_bsp_gpio_rst(1); display_hal_gpio_rst(1);
display_bsp_delay(100); display_hal_delay(100);
#else #else
st7789_send_cmd(ST7789_SWRESET); st7789_send_cmd(ST7789_SWRESET);
#endif #endif