思澈SDKOf显示框架介绍

简介

思澈Of显示框架Is基于rt_device框架Of,具Have如Under特点:

  • The same screen driver, TP driver, and backlight driver can be reused among different development boards

  • The same development board can choose different screen modules through menuconfig

  • Supports simultaneous compatibility with multiple screen drivers and TP drivers, distinguished by ID



This design does indeed improve reuse, but it also brings dispersion problems to the screen module driver configuration:
  • The power on/off, reset interface, pinmux settings, and PWM used for backlight of the screen module are all associated with the development board(类似屏驱模组OfBIOS)

  • The writing of the screen driver, TP driver, and backlight driver needs to be implemented based on the provided macro definitions and IO interfaces above

  • Ultimately, the implemented screen driver, TP driver, and backlight driver are aggregated into a menuconfig menu for the development board to choose from。


目录结构

Here is an example with the eh-lb525 board, screen module (nv3051f screen drive + gt911 touch control drive), and aw9364 backlight drive chip:

SDK
├──customer
│   ├──boards
│   │   ├──eh-lb52xu            #eh-lb525板子Of板级目录
│   │   │   ├──bsp_lcd_tp.c     #Implementation of power on/off and reset interfaces for the screen and TP, pinmux configuration for communication interfaces, etc.
│   │   │   └──Kconfig.board    #Definition of power on/off and reset pins for the screen and TP, definition of PWM backlight pins
│   │   │
│   │   │
│   │   └──Kconfig_lcd     #Menuconfig menu definition for the screen module (gathering macro definitions for screen drive, TP drive, backlight type, and screen module resolution)
│   │
│   │
│   └──peripherals
│       ├──nv3051f1              #Directory for the nv3051f1 screen driver
│       │   ├──nv3051f1.c        #Implementation of the screen driver
│       │   └──SConscript        #Compilation link file
│       │
│       ├──gt911                #Directory for the gt911 touch driver
│       │   ├──gt911.c          #C file for the touch driver
│       │   ├──gt911.h          #Header file for the touch driver
│       │   └──SConscript        #Compilation link file
|       |
│       ├──aw9364                #Aw9364 backlight driver chip, backlight device "lcdlight"
│       │   ├──aw9364.c          #C file for the backlight driver chip
│       │   ├──aw9364.h          #Header file for the backlight driver chip
│       │   └──SConscript        #Compilation link file
│       │   
│       └──Kconfig              #Location of macro definitions for screen IC, touch IC, and backlight IC
├──rtos
│   └──rtthread
│       └──bsp
│           └──sifli
│               └──drivers
│                   ├──drv_touch.c  #TP driver management layer, providing the "touch" device to the application layer
│                   └──drv_lcd.c    #LCD driver management layer, providing the "lcd" device to the application layer
└──examples        #示例应用
    └──rt_driver   #Screen debugging project, calling the "lcd" and "touch" devices





屏幕Part

屏幕框架图

alt text

图内各项解释:

  • Driver layer (drv_lcd.c) - implements an rt_device named “lcd” for upper-layer screen operations。

  • The middle green part is the specific driver code (the main code for customers to add screen drivers)

  • 板级IO接口文件(bsp_lcd_tp.c, Or drv_io.c) — For屏幕驱动提供统一OfPower On、Power Off、ResetOf接口。

  • Backlight device “lcdlight” - provides a unified backlight control interface for the screen driver

  • HAL layer (bf0_hal_lcdc.c) - provides a basically unified parameter configuration, LCD register read/write, etc., interface for the screen driver





注册屏驱To系统

SiChu’s screen driver framework supports registering multiple screen drivers to the system simultaneously, generating a specially named variable via the LCD_DRIVER_EXPORT2 macro, linked together。

Innv3051f1.cMiddleThroughLCD_DRIVER_EXPORT2Will屏驱Of回调函数注册To系统,每个函数Of详细解析请参考屏驱回调函数

static const LCD_DrvOpsDef LCD_drv =
{
	LCD_Init,    			  //[Mandatory], screen driver initialization function (including reset, initialization program, etc.) 
	LCD_ReadID,    			  //[Mandatory], screen presence detection function 
	LCD_DisplayOn,   		  //[Mandatory], turn on the screen 
	LCD_DisplayOff,  		  //[Mandatory], turn off the screen 
	LCD_SetRegion,    		  //[Mandatory], set the area when the screen receives data (area 2A, 2B)
	LCD_WritePixel,   		  // Optional, write one pixel point to the screen
	LCD_WriteMultiplePixels,  //[Mandatory], write batch pixel points to the screen
	LCD_ReadPixel,    		  // Optional, read one pixel point data on the screen, return the RGB value of the pixel
	LCD_SetColorMode,    	  // Optional, switch the color format output to the screen
	LCD_SetBrightness,   	  // Optional, set the brightness of the screen 
	LCD_IdleModeOn,    		  // Optional, enter standby display mode (low power mode) 
	LCD_IdleModeOff,   		  // Optional, exit standby display mode (low power mode) 
	LCD_Rotate,  			  // Optional, rotate the screen by a certain angle 
	LCD_TimeoutDbg, 		  // Optional, after batch data transmission times out, perform screen self-check 
	LCD_TimeoutReset,  		  // Optional, after batch data transmission times out, reset the screen 
	LCD_ESDCheck,  		      // Optional, periodic ESD detection for the screen 
};

LCD_DRIVER_EXPORT2(nv3051f1, LCD_ID, &lcdc_int_cfg, &LCD_drv,2);




屏幕In位检测

When the system registers multiple screen drivers, determining which screen driver to use to drive the current screen requires screen presence detection。方法Is先调用每个屏驱OfLCD_Init函数,让其初始化,然BackIn调用LCD_ReadID函数,IfLCD_ReadID函数返回Of值与LCD_ID值相同时,认For屏幕In位,则使用该屏驱。否则继续调用Under一个屏驱OfLCD_InitAndLCD_ReadID

  • LCD_InitAndLCD_ReadID Is每个屏驱注册Of回调函数

  • LCD_IDIsThroughLCD_DRIVER_EXPORT2传入Of参数

  • Can直接返回LCD_ID,If强制使用该屏幕驱动。 适用于只Have1个屏幕驱动Or者屏幕不支持读IDOf情况。

屏幕刷新Of像素对齐

Have些屏驱Of刷新区域Have像素对齐Want求,思澈Of屏驱框架Can支持设置像素对齐(IfHaveOf屏幕行列对齐Want求不一致,则用最大Of值。比如某屏幕行对齐Want求Is2,列对齐Want求Is4,则取4)。

屏驱ICOf更新区域像素对齐Want求一般In0x2A(起止列)And0x2B(起止行) This个2个寄存器Of描述Inside, 如Under图OfThis个IC行列都IsWant求2像素对齐:

../../_images/LCD_IC_pixel_alignment.png




Touch Part

Touch (TP) Framework Diagram

alt text





Interface for TP driver registration to the system

Register the initialization function rt_tp_device_init via INIT_COMPONENT_EXPORT in gt911.c,Then, inside rt_tp_device_init, register the TP driver to the system through the function rt_touch_drivers_register。

static struct touch_drivers driver;

static struct touch_ops ops =
{
    read_point, //TP数据读取回调函数
    init,       //TP初始化回调函数
    deinit      //TP去初始化回调函数
};



static int rt_tp_device_init(void)
{

    driver.probe = probe;  //TPIn位检测回调函数
    driver.ops = &ops;
    driver.user_data = RT_NULL;
    driver.isr_sem = rt_sem_create("gt911", 0, RT_IPC_FLAG_FIFO); //TP数据读取信号量

    rt_touch_drivers_register(&driver);  //注册To系统TP驱动框架
    return 0;

}
INIT_COMPONENT_EXPORT(rt_tp_device_init); //注册初始化函数

Backlight Section

Non-self-luminous screens generally require backlighting,The backlight drivers for current screens have implemented an “lcdlight” rt_device device through various methods,It is then uniformly used within the screen driver’s callback function LCD_SetBrightness

目Front支持2种模式:

  • PWM Direct Drive Backlight,芯片直接OutputPWM波形,直驱背光

  • External Backlight Driver, ThroughGPIO控制External Backlight Driver芯片OutputPWM波形,来驱动背光

PWM Direct Drive Backlight

This kind of device has already registered the “lcdlight” rt_device device in drv_lcd.c,见rt_hw_lcd_backlight_init函数。

The default PWM frequency used is 1KHz。

InsideWill用To2个宏LCD_PWM_BACKLIGHT_INTERFACE_NAMEAndLCD_PWM_BACKLIGHT_CHANEL_NUM,分别指定了PWMOf设备名称Andchannel号,These two macros are generally defined in Kconfig.board

Note: It is necessary to enable the pwm rt_device specified by LCD_PWM_BACKLIGHT_INTERFACE_NAME in menuconfig,例如指定”pwm2”时Need选择: alt text

ThroughInScreen moduleInside选择宏LCD_USING_PWM_AS_BACKLIGHT来使用This种类型Of背光。

External Backlight Driver

For example, aw9364.c registers the “lcdlight” rt_device device inside the sif_aw9364_init function。

The macro LCD_BACKLIGHT_CONTROL_PIN inside specifies which GPIO to use to control aw9364。This macro is also defined in Kconfig.board

ThroughInScreen moduleInside选择宏BL_USING_AW9364来使用This种类型Of背光。