Ubiquitous/RT_Thread: fix lcd drive for k210 ,before lcd drive can't work with spi.

This commit is contained in:
chunyexixiaoyu 2021-06-21 18:03:15 +08:00
parent fedd6affc9
commit 5b9cbad759
3 changed files with 21 additions and 14 deletions

View File

@ -37,7 +37,7 @@ static struct io_config
IOCONFIG(BSP_DVP_CMOS_HREF_PIN, FUNC_CMOS_HREF),
#endif
#ifdef BSP_USING_LCD
#if 0 //here is a drv lcd bug now don't know why
IOCONFIG(BSP_LCD_CS_PIN, FUNC_SPI0_SS3), /* LCD CS PIN */
IOCONFIG(BSP_LCD_WR_PIN, FUNC_SPI0_SCLK), /* LCD WR PIN */
IOCONFIG(BSP_LCD_DC_PIN, FUNC_GPIOHS2), /* LCD DC PIN */
@ -123,6 +123,9 @@ int io_config_init(void)
sysctl_set_power_mode(SYSCTL_POWER_BANK6, SYSCTL_POWER_V18);
sysctl_set_power_mode(SYSCTL_POWER_BANK7, SYSCTL_POWER_V18);
#endif
#ifdef FACE_DETECT
sysctl_clock_enable(SYSCTL_CLOCK_AI);
#endif
}
INIT_BOARD_EXPORT(io_config_init);

View File

@ -52,9 +52,9 @@ static void init_rst(void)
{
gpiohs_set_drive_mode(RST_GPIONUM, GPIO_DM_OUTPUT);
gpiohs_set_pin(RST_GPIONUM, GPIO_PV_LOW);
usleep(100000);
rt_thread_mdelay(10);
gpiohs_set_pin(RST_GPIONUM, GPIO_PV_HIGH);
usleep(100000);
rt_thread_mdelay(10);
}
@ -122,17 +122,26 @@ void lcd_interrupt_enable(void)
lcd_ctl.mode = 1;
}
void lcd_pre()
{
fpioa_set_function(37, FUNC_GPIOHS0 + RST_GPIONUM);
fpioa_set_function(38, FUNC_GPIOHS0 + DCX_GPIONUM);
fpioa_set_function(36, FUNC_SPI0_SS0 + LCD_SPI_SLAVE_SELECT);
fpioa_set_function(39, FUNC_SPI0_SCLK);
}
int lcd_init(void)
{
uint8_t data = 0;
lcd_pre();
tft_hard_init();
/*soft reset*/
tft_write_command(SOFTWARE_RESET);
usleep(100000);
rt_thread_mdelay(10);
/*exit sleep*/
tft_write_command(SLEEP_OFF);
usleep(100000);
rt_thread_mdelay(10);
/*pixel format*/
tft_write_command(PIXEL_FORMAT_SET);
data = 0x55;
@ -302,14 +311,8 @@ void lcd_draw_picture(uint16_t x1, uint16_t y1, uint16_t width, uint16_t height,
lcd_set_area(x1, y1, x1 + width - 1, y1 + height - 1);
tft_write_word(ptr, width * height / 2, lcd_ctl.mode ? 2 : 0);
}
void lcd_pre()
{
fpioa_set_function(38, FUNC_GPIOHS0 + DCX_GPIONUM);
fpioa_set_function(36, FUNC_SPI0_SS3);
fpioa_set_function(39, FUNC_SPI0_SCLK);
fpioa_set_function(37, FUNC_GPIOHS0 + RST_GPIONUM);
}
void lcd_test0()
{
char test[]={"xuos-intelligence framwork"};

View File

@ -96,8 +96,9 @@
#define DIGITAL_GAMMA_CTL2 0xE3
#define INTERFACE_CTL 0xF6
#define DCX_GPIONUM (2)
#define RST_GPIONUM (3)
#define DCX_GPIONUM (5)
#define RST_GPIONUM (4)
#define LCD_SPI_SLAVE_SELECT 3
#define SPI_CHANNEL 0
#define SPI_SLAVE_SELECT 3