DevKitBoard.c配置

配置显示器:st7789, 分配哪些引脚,分配SPI接口
配置触摸屏: iic, 配置iic引脚
按键: 配置按键

触摸屏配置

显示部分

SPI配置
  1. SPI1_PLATFORM_DATA_BEGIN(spi1_data)
  2. .clk = 96000000,
  3. .mode = SPI_1WIRE_MODE,
  4. .port = 'B',
  5. .attr = SPI_SCLK_L_UPL_SMPH | SPI_UNIDIR_MODE,//主机,CLK低 更新数据低,单向模式
  6. SPI1_PLATFORM_DATA_END()

接口定义
  1. static const struct ui_lcd_platform_data pdata = {
  2. .spi_id = "spi1",
  3. .bl_pin = IO_PORTH_02,
  4. .cs_pin = IO_PORTH_03,
  5. .rs_pin = IO_PORTH_04,
  6. .rst_pin = IO_PORTH_05,
  7. .touch_reset_pin = IO_PORTH_06,
  8. .touch_int_pin = IO_PORTH_07,
  9. .te_pin = -1,
  10. .lcd_if = LCD_SPI,//屏幕接口类型还有 PAP , SPI
  11. };

配置完成之后,记得要检查REGISTER_DEVICES(device_table)中有没有配置,app_config.h中有没有启用

在lcd_drive.c的第343行添加如下代码

  1. #if TCFG_LCD_ST7789V_ENABLE//客户屏放最后
  2. lcd_w = 240;
  3. lcd_h = 280;
  4. lcd_bk_on = 1;
  5. lcd_bk_off = 0;
  6. lcd_choice = CONFIG_ST7789V_ID;
  7. printf("\n [lcd_drive] %s -[find_check_ST7789] %d\n", __FUNCTION__, __LINE__);
  8. #endif

触摸部分

iic配置
  1. #ifdef CONFIG_IIC_ENABLE
  2. HW_IIC0_PLATFORM_DATA_BEGIN(hw_iic1_data)//硬件IIC
  3. .clk_pin = IO_PORTH_00,
  4. .dat_pin = IO_PORTH_01,
  5. .baudrate = 0x3f,
  6. HW_IIC0_PLATFORM_DATA_END()
  7. SW_IIC_PLATFORM_DATA_BEGIN(sw_iic0_data)//软件iic
  8. .clk_pin = IO_PORTH_00,
  9. .dat_pin = IO_PORTH_01,
  10. .sw_iic_delay = 50,
  11. SW_IIC_PLATFORM_DATA_END()
  12. #endif

配置完成之后,记得要检查REGISTER_DEVICES(device_table)中有没有配置,app_config.h中有没有启用

替换驱动文件

lcd_st7789v.c
cst816t.c
lcd_drive.h
lcd_drive.c

需要修改ui/include/lcd_config.h

  1. #define LCD_W 240
  2. #define LCD_H 280

app_config.h配置

里面有非常多的宏定义,根据这些宏定义,开关相应的功能

  1. #define TCFG_LCD_ST7789V_ENABLE 1
  2. #define TCFG_TOUCH_CST816T_ENABLE 1
  3. #define USE_LVGL_UI_DEMO 1
  4. #define CONFIG_UI_ENABLE 1
  5. #define CONFIG_BT_ENABLE 1

注意将没有用到的UI配置全都禁用掉

  1. #define USE_LCD_240X320 0
  2. #define USE_LCD_320X480 0
  3. #if USE_LCD_240X320
  4. #define TCFG_TOUCH_GT911_ENABLE 0
  5. #define TCFG_LCD_ILI9341_ENABLE 0
  6. #endif //USE_LCD_240X320_ILI9341
  7. #if USE_LCD_320X480
  8. #define TCFG_TOUCH_FT6236_ENABLE 0
  9. #define TCFG_LCD_ILI9488_ENABLE 0
  10. #define TCFG_LCD_ILI9481_ENABLE 0
  11. #endif //USE_LCD_320X480_ILI9481

其它配置

  1. 禁用ui_main.c
  2. wifi_demo_task.c 文件注释掉568行的 //stats_display();