Started to implement the lcd driver
This commit is contained in:
parent
9bf5c774cb
commit
2ca0d48258
@ -4,6 +4,7 @@ sinclude $(TOP_DIR)/tools/w800/conf.mk
|
||||
ifndef PDIR
|
||||
GEN_LIBS = libuser$(LIB_EXT)
|
||||
COMPONENTS_libuser = gfx/libusergfx$(LIB_EXT)
|
||||
#COMPONENTS_libuser = drivers/libdrivers$(LIB_EXT)
|
||||
endif
|
||||
|
||||
#DEFINES +=
|
||||
|
16
src/W800 SDK v1.00.08/app/drivers/Makefile
Normal file
16
src/W800 SDK v1.00.08/app/drivers/Makefile
Normal file
@ -0,0 +1,16 @@
|
||||
TOP_DIR = ../..
|
||||
sinclude $(TOP_DIR)/tools/w800/conf.mk
|
||||
|
||||
ifndef PDIR
|
||||
GEN_LIBS = libdrivers$(LIB_EXT)
|
||||
COMPONENTS_libdrivers = lcd/libdriverslcd$(LIB_EXT)
|
||||
endif
|
||||
|
||||
#DEFINES +=
|
||||
|
||||
sinclude $(TOP_DIR)/tools/w800/rules.mk
|
||||
|
||||
INCLUDES := $(INCLUDES) -I $(PDIR)include
|
||||
|
||||
PDIR := ../$(PDIR)
|
||||
sinclude $(PDIR)Makefile
|
15
src/W800 SDK v1.00.08/app/drivers/lcd/Makefile
Normal file
15
src/W800 SDK v1.00.08/app/drivers/lcd/Makefile
Normal file
@ -0,0 +1,15 @@
|
||||
TOP_DIR = ../../..
|
||||
sinclude $(TOP_DIR)/tools/w800/conf.mk
|
||||
|
||||
ifndef PDIR
|
||||
GEN_LIBS = libdriverslcd$(LIB_EXT)
|
||||
endif
|
||||
|
||||
#DEFINES +=
|
||||
|
||||
sinclude $(TOP_DIR)/tools/w800/rules.mk
|
||||
|
||||
INCLUDES := $(INCLUDES) -I $(PDIR)include
|
||||
|
||||
PDIR := ../$(PDIR)
|
||||
sinclude $(PDIR)Makefile
|
70
src/W800 SDK v1.00.08/app/drivers/lcd/lcd.c
Normal file
70
src/W800 SDK v1.00.08/app/drivers/lcd/lcd.c
Normal file
@ -0,0 +1,70 @@
|
||||
#include "FreeRTOS.h"
|
||||
#include "lcd.h"
|
||||
|
||||
void lcd_config_init(LCDConfig_t * const LCDConfig)
|
||||
{
|
||||
if(!LCDConfig) return;
|
||||
|
||||
LCDConfig->LCDPWMBacklightPin = -1;
|
||||
LCDConfig->LCDClockPin = -1;
|
||||
LCDConfig->LCDDataPin = -1;
|
||||
LCDConfig->LCDCSPin = -1;
|
||||
LCDConfig->LCDDataCommandPin = -1;
|
||||
LCDConfig->LCDResetPin = -1;
|
||||
|
||||
}
|
||||
|
||||
void lcd_init(LCDConfig_t * const LCDConfig)
|
||||
{
|
||||
if(!LCDConfig) return;
|
||||
|
||||
// Backlight is controlled using PWM
|
||||
tls_gpio_cfg(LCDConfig->LCDPWMBacklightPin, WM_GPIO_DIR_OUTPUT, WM_GPIO_ATTR_FLOATING);
|
||||
|
||||
tls_gpio_cfg(LCDConfig->LCDCSPin, WM_GPIO_DIR_OUTPUT, WM_GPIO_ATTR_FLOATING);
|
||||
tls_gpio_cfg(LCDConfig->LCDDataCommandPin, WM_GPIO_DIR_OUTPUT, WM_GPIO_ATTR_FLOATING);
|
||||
tls_gpio_cfg(LCDConfig->LCDResetPin, WM_GPIO_DIR_OUTPUT, WM_GPIO_ATTR_PULLHIGH);
|
||||
|
||||
// The clock and data line are driven using the MMC peripheral
|
||||
tls_io_cfg_set(LCDConfig->LCDClockPin, WM_IO_OPTION2);
|
||||
tls_io_cfg_set(LCDConfig->LCDDataPin, WM_IO_OPTION2);
|
||||
|
||||
// We set some of the pins default value
|
||||
lcd_set_backlight(LCDConfig, 0);
|
||||
lcd_set_cs(LCDConfig, false);
|
||||
lcd_set_data_command(LCDConfig, LCD_DATA);
|
||||
|
||||
lcd_hardware_reset(LCDConfig);
|
||||
|
||||
// Init MMC SDIO peripheral
|
||||
}
|
||||
|
||||
void lcd_set_window(u16 x_start, u16 y_start, u16 x_end, u16 y_end);
|
||||
|
||||
void lcd_write_frame(void);
|
||||
|
||||
void lcd_set_backlight(LCDConfig_t * const LCDConfig, u8 brightness)
|
||||
{
|
||||
if(brightness)
|
||||
tls_gpio_write(LCDConfig->LCDPWMBacklightPin, 1);
|
||||
else
|
||||
tls_gpio_write(LCDConfig->LCDPWMBacklightPin, 1);
|
||||
}
|
||||
|
||||
void lcd_set_cs(LCDConfig_t * const LCDConfig, bool selected)
|
||||
{
|
||||
// CS is active low...
|
||||
tls_gpio_write(LCDConfig->LCDCSPin, !selected);
|
||||
}
|
||||
|
||||
void lcd_set_data_command(LCDConfig_t * const LCDConfig, LCDDataCommand_e dataCommand)
|
||||
{
|
||||
tls_gpio_write(LCDConfig->LCDDataCommandPin, dataCommand);
|
||||
}
|
||||
|
||||
void lcd_hardware_reset(LCDConfig_t * const LCDConfig)
|
||||
{
|
||||
tls_gpio_write(LCDConfig->LCDResetPin, 0);
|
||||
tls_os_time_delay(pdMS_TO_TICKS(1));
|
||||
tls_gpio_write(LCDConfig->LCDResetPin, 1);
|
||||
}
|
52
src/W800 SDK v1.00.08/app/drivers/lcd/lcd.h
Normal file
52
src/W800 SDK v1.00.08/app/drivers/lcd/lcd.h
Normal file
@ -0,0 +1,52 @@
|
||||
#ifndef LCD_H
|
||||
#define LCD_H
|
||||
|
||||
#include "wm_include.h"
|
||||
#include "lv_conf.h"
|
||||
/* Used SOC : W800 or W801*/
|
||||
#define W800
|
||||
/* Display drive controller */
|
||||
#define DISPLAY_CONTROLLER ILI9341
|
||||
//#define DISPLAY_CONTROLLER ST7789V
|
||||
|
||||
typedef enum LCDDataCommand
|
||||
{
|
||||
LCD_COMMAND = 0,
|
||||
LCD_DATA = 1
|
||||
} LCDDataCommand_e;
|
||||
|
||||
typedef struct LCDConfig
|
||||
{
|
||||
enum tls_io_name LCDPWMBacklightPin;
|
||||
enum tls_io_name LCDClockPin;
|
||||
enum tls_io_name LCDDataPin;
|
||||
enum tls_io_name LCDCSPin;
|
||||
enum tls_io_name LCDDataCommandPin;
|
||||
enum tls_io_name LCDResetPin;
|
||||
} LCDConfig_t;
|
||||
|
||||
/* Initializes the LCDConfig object to known values */
|
||||
void lcd_config_init(LCDConfig_t * const LCDConfig);
|
||||
|
||||
/* Initializes IOs using the configured LCDConfig object and the LCD display */
|
||||
void lcd_init(LCDConfig_t * const LCDConfig);
|
||||
|
||||
/* Sets the LCD write window area */
|
||||
void lcd_set_window(u16 x_start, u16 y_start, u16 x_end, u16 y_end);
|
||||
|
||||
/* Writes the frame to display's internal RAM */
|
||||
void lcd_write_frame(void);
|
||||
|
||||
/* Sets the backlight to the specified brightness value */
|
||||
void lcd_set_backlight(LCDConfig_t * const LCDConfig, u8 brightness);
|
||||
|
||||
/* Sets the chip select pin */
|
||||
void lcd_set_cs(LCDConfig_t * const LCDConfig, bool selected);
|
||||
|
||||
/* Sets the data/command pin state */
|
||||
void lcd_set_data_command(LCDConfig_t * const LCDConfig, LCDDataCommand_e dataCommand);
|
||||
|
||||
/* Issues a reset of the lcd display */
|
||||
void lcd_hardware_reset(LCDConfig_t * const LCDConfig);
|
||||
|
||||
#endif //LCD_H
|
Loading…
Reference in New Issue
Block a user