添加新的屏幕驱动¶
Adding a new screen driver is mainly divided into:
Add macro definitions for the driver IC in the Kconfig file¶
Open the SDK\customer\peripherals\Kconfig file which contains many configs like LCD_USING_XXX, and add a new config at the end:
config LCD_USING_NV3051F1
bool
default n
Note: If there is already a screen drive IC with the same name, it means that you only need to modify the initialization code of the existing driver。
Copy similar driver code and add it to the compilation¶
在SDK\customer\peripherals目录下找一个类似且已[适配过的Screen driver](./List of adapted screen modules.md),
Copy the entire directory and rename it to “nv3051f1”
里面的Screen driver.c文件也改成nv3051f1.c, 并修改里面的内容。
Change the depend macro in the SConscript file inside to ‘LCD_USING_NV3051F1’ added before, so that the newly added file will be compiled
Modify the copied screen driver file¶
Configure screen parameters¶
Depending on the interface, the parameters required for each type of screen will vary. The following several screen interfaces each have corresponding parameters for configuration:
修改屏驱回调函数¶
修改复制过来的屏驱里面的内容为自己的,屏驱里面的回调函数说明:
注:可选的回调函数可以注册为NULL,或者函数内部实现为空
回调函数 |
说明 |
---|---|
【必选】,屏驱初始函数(包括复位,初始化程序等) |
|
【必选】,屏幕在位检测函数 |
|
【必选】,屏幕打开 |
|
【必选】,屏幕关闭 |
|
【必选】,设置屏幕接受数据时的区域(2A,2B 的区域) |
|
可选,写一个像素点到屏幕上 |
|
【必选】,写批量像素点到屏幕上 |
|
可选,读屏幕上的一个像素点数据,返回像素的RGB值 |
|
可选,切换输出给屏幕的颜色格式 |
|
可选,设置屏幕的亮度 |
|
可选,进入待机显示模式(低功耗模式) |
|
可选,退出待机显示模式(低功耗模式) |
|
可选,旋转屏幕一定角度 |
|
可选,批量送数超时后,屏幕自检 |
|
可选,批量送数超时后,屏幕复位 |
|
可选,屏幕定时ESD检测 |
注册屏驱到系统¶
通过LCD_DRIVER_EXPORT2将屏驱IC的回调函数注册到系统:
LCD_DRIVER_EXPORT2(nv3051f1, LCD_ID, &lcdc_int_cfg,
&LCD_drv,2);
参数说明:
nv3051f1 - 屏驱IC的名字
LCD_ID - 屏幕在位时,屏幕在位检测函数LCD_ReadID应该返回的值。
&lcdc_int_cfg - 对外提供屏幕初始化参数(外部只读不写,只用于查询屏幕带宽、颜色格式等信息)
&LCD_drv - 屏驱IC的所有操作的回调函数集合
2 - 该屏驱IC更新屏幕区域要求2像素对齐