一、硬件
1.1 TFT屏幕
型号:HP28030
显示芯片:ST7789V
电容触摸芯片:GT911
分辨率:240*320
数据格式:RGB565
触摸点数:5
接口类型:SPI4线串口
1.2 硬件飞线
1.2.1 背光
限流电阻接多大呢?
背光源由 6 颗 LED 灯并联,每颗 LED 灯典型电流值 15mA,6 颗 LED 灯总电流为:6*15mA=90mA;在设计产 品时,要采用限流电路(通常加 10 欧姆左右的限流电阻),把背光源的总电流限制在 90mA 以内,防止背 光源长时间工作时发热,造成显示屏和背光源不可逆的永久损坏。
1.2.2 触摸
序号 | 屏幕 | F1C200S |
---|---|---|
1 | GND | GND |
2 | RST | 外部上拉(低电平复位) |
3 | INT_3.3V | PA1(下降沿触发) |
4 | SDA | TWI0_SDA |
5 | SCL | TWI0_SCK |
6 | VCC_3.3V | 3.3V |
1.2.3 显示
使用SPI0,调试情况需要去掉SPI芯片,飞线接屏幕。
其他需要修改:R18和R19互换位置。去掉R44。去掉R43。
序号 | 屏幕 | F1C200S |
---|---|---|
1 | GND | GND |
2 | RESET | 外部上拉(低电平复位) |
3 | SCL | SPI0_CLK |
4 | D/C | PA0(1数据 0指令) |
5 | CSX | SPI0_CS |
6 | SDA | SPI0_MOSI |
7 | SDO | SPI0_MISO |
8 | GND | GND |
9 | VDD | 3.3V |
10 | LED-A | 3.3V |
11 | LED-K | 串接10R电阻接地(测试就GND) |
12 | LED-K | 串接10R电阻接地(测试就GND) |
13 | LED-K | 串接10R电阻接地(测试就GND) |
14 | LED-K | 串接10R电阻接地(测试就GND) |
使用转接板
序号 | 转接板 | F1C200S |
---|---|---|
1 | 3.3 | 3.3V |
2 | GND | GND |
3 | IO_BK 背光 | 3.3V |
4 | NC | |
5 | LCD_RST | 3.3V 外部上拉(低电平复位) |
6 | LCD_SCL | SPI0_CLK |
7 | LCD_DC | PA0(1数据 0指令) |
8 | LCD_CS | SPI0_CS |
9 | SPI_MOSI | SPI0_MOSI |
10 | SPI_MISO | SPI0_MISO |
11 | T_MISO | |
12 | T_MOSI | CP_SDA/TWI0_SDA |
13 | T_PEN | CP_INT/PE11 |
14 | NC | |
15 | T_CS | 3.3V 外部上拉(低电平复位) |
16 | T_CLK | CP_SCL/TWI0_SCK |
二、显示驱动
2.1 修改驱动文件
drivers/staging/fbtft/fb_st7789v.c
// SPDX-License-Identifier: GPL-2.0+
/*
* FB driver for the ST7789V LCD Controller
*
* Copyright (C) 2015 Dennis Menschel
*/
#include <linux/bitops.h>
#include <linux/delay.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <video/mipi_display.h>
#include "fbtft.h"
#define DRVNAME "fb_st7789v"
#define DEFAULT_GAMMA \
"70 2C 2E 15 10 09 48 33 53 0B 19 18 20 25\n" \
"70 2C 2E 15 10 09 48 33 53 0B 19 18 20 25"
/**
* enum st7789v_command - ST7789V display controller commands
*
* @PORCTRL: porch setting
* @GCTRL: gate control
* @VCOMS: VCOM setting
* @VDVVRHEN: VDV and VRH command enable
* @VRHS: VRH set
* @VDVS: VDV set
* @VCMOFSET: VCOM offset set
* @PWCTRL1: power control 1
* @PVGAMCTRL: positive voltage gamma control
* @NVGAMCTRL: negative voltage gamma control
*
* The command names are the same as those found in the datasheet to ease
* looking up their semantics and usage.
*
* Note that the ST7789V display controller offers quite a few more commands
* which have been omitted from this list as they are not used at the moment.
* Furthermore, commands that are compliant with the MIPI DCS have been left
* out as well to avoid duplicate entries.
*/
enum st7789v_command {
PORCTRL = 0xB2,
GCTRL = 0xB7,
VCOMS = 0xBB,
VDVVRHEN = 0xC2,
VRHS = 0xC3,
VDVS = 0xC4,
VCMOFSET = 0xC5,
PWCTRL1 = 0xD0,
PVGAMCTRL = 0xE0,
NVGAMCTRL = 0xE1,
};
#define MADCTL_BGR BIT(3) /* bitmask for RGB/BGR order */
#define MADCTL_MV BIT(5) /* bitmask for page/column order */
#define MADCTL_MX BIT(6) /* bitmask for column address order */
#define MADCTL_MY BIT(7) /* bitmask for page address order */
/**
* init_display() - initialize the display controller
*
* @par: FBTFT parameter object
*
* Most of the commands in this init function set their parameters to the
* same default values which are already in place after the display has been
* powered up. (The main exception to this rule is the pixel format which
* would default to 18 instead of 16 bit per pixel.)
* Nonetheless, this sequence can be used as a template for concrete
* displays which usually need some adjustments.
*
* Return: 0 on success, < 0 if error occurred.
*/
static int init_display(struct fbtft_par *par)
{
/* turn off sleep mode */
write_reg(par, 0x11);
mdelay(120);
write_reg(par, 0x36, 0); // 方向
write_reg(par, 0x3A, 0x05);
write_reg(par, 0xB2, 0x0C, 0x0C, 0x00, 0x33, 0x33);
write_reg(par, 0xB7, 0x71);
write_reg(par, 0xBB, 0x3B);
write_reg(par, 0xC0, 0x2C);
write_reg(par, 0xC2, 0x01);
write_reg(par, 0xC3, 0x13);
write_reg(par, 0xC4, 0x20);
write_reg(par, 0xC6, 0x0F);
write_reg(par, 0xD0, 0xA4, 0xA1);
write_reg(par, 0xD6, 0xA1);
//write_reg(par, 0x21);
write_reg(par, 0x29);
return 0;
}
/**
* set_var() - apply LCD properties like rotation and BGR mode
*
* @par: FBTFT parameter object
*
* Return: 0 on success, < 0 if error occurred.
*/
static int set_var(struct fbtft_par *par)
{
u8 madctl_par = 0;
if (par->bgr)
madctl_par |= MADCTL_BGR;
switch (par->info->var.rotate) {
case 0:
break;
case 90:
madctl_par |= (MADCTL_MV | MADCTL_MY); // BIT(5) | BIT(7) = 101
break;
case 180:
madctl_par |= (MADCTL_MX | MADCTL_MY); // BIT(6) | BIT(7) = 011
break;
case 270:
madctl_par |= (MADCTL_MV | MADCTL_MX); // BIT(5) | BIT(6) = 110
break;
default:
return -EINVAL;
}
write_reg(par, MIPI_DCS_SET_ADDRESS_MODE, madctl_par);
return 0;
}
/**
* set_gamma() - set gamma curves
*
* @par: FBTFT parameter object
* @curves: gamma curves
*
* Before the gamma curves are applied, they are preprocessed with a bitmask
* to ensure syntactically correct input for the display controller.
* This implies that the curves input parameter might be changed by this
* function and that illegal gamma values are auto-corrected and not
* reported as errors.
*
* Return: 0 on success, < 0 if error occurred.
*/
static int set_gamma(struct fbtft_par *par, u32 *curves)
{
write_reg(par, PVGAMCTRL, 0xD0, 0x08, 0x0A, 0x0D, 0x0B, 0x07, 0x21, 0x33, 0x39, 0x39, 0x16, 0x16, 0x1F, 0x3C);
write_reg(par, NVGAMCTRL, 0xD0, 0x00, 0x03, 0x01, 0x00, 0x10, 0x21, 0x32, 0x38, 0x16, 0x14, 0x14, 0x20, 0x3D);
return 0;
}
/**
* blank() - blank the display
*
* @par: FBTFT parameter object
* @on: whether to enable or disable blanking the display
*
* Return: 0 on success, < 0 if error occurred.
*/
static int blank(struct fbtft_par *par, bool on)
{
if (on)
write_reg(par, MIPI_DCS_SET_DISPLAY_OFF);
else
write_reg(par, MIPI_DCS_SET_DISPLAY_ON);
return 0;
}
static struct fbtft_display display = {
.regwidth = 8,
.width = 240,
.height = 320,
.gamma_num = 2,
.gamma_len = 14,
.gamma = DEFAULT_GAMMA,
.fbtftops = {
.init_display = init_display,
.set_var = set_var,
.set_gamma = set_gamma,
.blank = blank,
},
};
FBTFT_REGISTER_DRIVER(DRVNAME, "sitronix,st7789v", &display);
MODULE_ALIAS("spi:" DRVNAME);
MODULE_ALIAS("platform:" DRVNAME);
MODULE_ALIAS("spi:st7789v");
MODULE_ALIAS("platform:st7789v");
MODULE_DESCRIPTION("FB driver for the ST7789V LCD Controller");
MODULE_AUTHOR("Dennis Menschel");
MODULE_LICENSE("GPL");
方向的问题:
if(USE_HORIZONTAL==0)
Lcd_WriteData(0x08); // 000
else if(USE_HORIZONTAL==1)
Lcd_WriteData(0xC8); // 110
else if(USE_HORIZONTAL==2)
Lcd_WriteData(0x68); // 011
else
Lcd_WriteData(0xA8); // 101
2.2 修改设备树
链接:f1c200s_st7789v设备树。
需要注释掉RGB显示驱动部分。如果不注释会出现在/dev目录下出现2个fb设备。启动信息无法显示到屏幕。
suniv-f1c100s-licheepi-nano.dts
// SPDX-License-Identifier: (GPL-2.0+ OR X11)
/dts-v1/;
#include "suniv-f1c100s.dtsi"
/ {
model = "Widora MangoPi R3";
compatible = "allwinner,suniv-f1c200s",
"allwinner,suniv-f1c100s";
aliases {
//serial0 = &uart0;
serial1 = &uart1;
};
chosen {
stdout-path = "serial1:115200n8";
};
/*
panel: panel {
compatible = "bananapi,s070wv20-ct16", "simple-panel";
#address-cells = <1>;
#size-cells = <0>;
port@0 {
reg = <0>;
#address-cells = <1>;
#size-cells = <0>;
panel_input: endpoint@0 {
reg = <0>;
remote-endpoint = <&tcon0_out_lcd>;
};
};
};
*/
/*
backlight: backlight {
compatible = "pwm-backlight";
pwms = <&pwm 1 500000 0>;
pwm-names = "backlight";
brightness-levels = <0 4 8 16 32 64 128 255>;
default-brightness-level = <7>;
status = "okay";
};
*/
};
&spi0 {
status = "okay";
spi-nor@0 {
#address-cells = <1>;
#size-cells = <1>;
compatible = "winbond,w25q128", "jedec,spi-nor";
reg = <0>;
spi-max-frequency = <50000000>;
status = "disabled";
partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;
partition@0 {
label = "u-boot";
reg = <0x000000 0x70000>;
read-only;
};
partition@1 {
label = "kernel";
reg = <0x70000 0x590000>;
read-only;
};
partition@2 {
label = "rom";
reg = <0x600000 0x700000>;
read-only;
};
partition@3 {
label = "overlay";
reg = <0xd00000 0x300000>;
};
};
};
spi-nand@0 {
#address-cells = <1>;
#size-cells = <1>;
compatible = "spi-nand";
reg = <0>;
spi-max-frequency = <50000000>;
status = "disabled";
partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;
partition@0 {
label = "u-boot";
reg = <0x000000 0x100000>;
read-only;
};
partition@1 {
label = "kernel";
reg = <0x100000 0x500000>;
read-only;
};
partition@2 {
label = "rom";
reg = <0x600000 0x2a00000>;
read-only;
};
partition@3 {
label = "vendor";
reg = <0x3000000 0x1000000>;
};
partition@4 {
label = "overlay";
reg = <0x4000000 0x3000000>;
};
};
};
st7789v@0 {
status = "okay";
compatible = "sitronix,st7789v";
reg = <0>;
spi-max-frequency =<32000000>; //SPI时钟32M,先给50M试一下
rotate =<90>; //屏幕旋转90度
spi-cpol;
spi-cpha;
rgb; //颜色格式RGB
fps =<30>; //刷新30帧率,先给60试一下
buswidth =<8>; //总线宽度8
reset-gpios=<&pio 4 12 GPIO_ACTIVE_LOW>; //GPIOE12
dc-gpios =<&pio 0 0 GPIO_ACTIVE_HIGH>; //GPIOA0
debug =<1>; //不开启调试
};
};
/*
&pwm {
pinctrl-names = "default";
pinctrl-0 = <&pwm1_pe_pins>;
status = "okay";
};
*/
&uart1 {
pinctrl-names = "default";
pinctrl-0 = <&uart1_pa_pins>;
status = "okay";
};
&mmc0 {
status = "okay";
broken-cd;
};
&otg_sram {
status = "okay";
};
&usb_otg {
dr_mode = "otg"; /* otg host peripheral */
status = "okay";
};
&usbphy {
status = "okay";
};
&cedar_ve {
status = "okay";
};
&ion {
status = "okay";
};
/*
&de {
status = "okay";
};
&fe0 {
status = "okay";
};
&be0 {
status = "okay";
};
&tve0 {
status = "okay";
};
&tcon0 {
pinctrl-names = "default";
pinctrl-0 = <&lcd_rgb565_pins>;
status = "okay";
};
&tcon0_out {
tcon0_out_lcd: endpoint@0 {
reg = <0>;
remote-endpoint = <&panel_input>;
};
};
*/
&codec {
allwinner,audio-routing =
"Headphone", "HP",
"Headphone", "HPCOM",
"LINEIN", "Line In",
"FMINL", "Left FM In",
"FMINR", "Right FM In",
"MIC", "Mic";
status = "okay";
};
&i2c0 {
pinctrl-names = "default";
pinctrl-0 = <&i2c0_pd_pins>;
status = "okay";
/*
rtp@48 {
compatible = "ti,tsc2007";
reg = <0x48>;
interrupt-parent = <&pio>;
interrupts = <4 12 IRQ_TYPE_EDGE_FALLING>;
gpios = <&pio 4 12 GPIO_ACTIVE_LOW>;
pendown-gpio = <&pio 4 12 GPIO_ACTIVE_LOW>;
ti,x-plate-ohms = <660>;
wakeup-source;
status = "okay";
};
*/
ctp@5d {
compatible = "goodix,gt911";
reg = <0x5d>;
interrupt-parent = <&pio>;
interrupts = <4 12 IRQ_TYPE_EDGE_FALLING>; // PE12
irq-gpios = <&pio 4 12 GPIO_ACTIVE_HIGH>; // PE12
reset-gpios = <&pio 0 0 GPIO_ACTIVE_HIGH>; // PA0
status = "disabled";
};
ov2640: camera@30 {
compatible = "ovti,ov2640";
reg = <0x30>;
pinctrl-0 = <&clk_out_pins>;
pinctrl-names = "default";
clocks = <&clk_out>;
clock-names = "xvclk";
assigned-clocks = <&clk_out>;
assigned-clock-rates = <24000000>;
status = "okay";
port {
ov2640_ep: endpoint {
remote-endpoint = <&csi0_ep>;
bus-width = <8>;
hsync-active = <0>;
vsync-active = <0>;
pclk-sample = <1>;
};
};
};
/*
ov5640: camera@3c {
compatible = "ovti,ov5640";
reg = <0x3c>;
pinctrl-0 = <&clk_out_pins>;
pinctrl-names = "default";
clocks = <&clk_out>;
clock-names = "xclk";
assigned-clocks = <&clk_out>;
assigned-clock-rates = <24000000>;
status = "disabled";
port {
ov5640_ep: endpoint {
remote-endpoint = <&csi0_ep>;
bus-width = <8>;
hsync-active = <0>;
vsync-active = <0>;
pclk-sample = <1>;
};
};
};
*/
};
&csi0 {
pinctrl-names = "default";
pinctrl-0 = <&csi0_pins>;
packed-format;
status = "okay";
port {
csi0_ep: endpoint {
remote-endpoint = <&ov2640_ep>;
bus-width = <8>;
hsync-active = <0>;
vsync-active = <0>;
pclk-sample = <1>;
};
};
};
2.3 修改内核配置
开启SPI驱动的时候必须选择A31。
开启fb驱动支持。
选择编译ST7789V驱动。
将控制台映射到fb功能开启。
启动logo显示。
2.4 编译,测试
重新拷贝zImage、设备树。
屏幕出现启动信息。
测试cat /dev/urandom > /dev/fb0
测试cat /dev/zero> /dev/fb0
测试echo hello > /dev/tty1
设备树debug改为0,改为60帧,改为50Mhz。再继续测试,也没问题。
2.5 出现的问题
2.5.1 gpio申请失败
设备树中引脚配置冲突。
2.5.2 屏幕不受控制
使用cat /dev/urandom > /dev/fb0 又有时有反应。使用逻辑分析仪分析SPI4线和DC线的时序,发现DC线命令和数据的状态反。修改设备树。
2.5.3 启动信息不在屏幕上显示
使用cat /sys/class/graphics/fb*/name查看有2个设备。
在/dev目录下也有2个fb设备。
猜想,可能存在冲突。解决思路,注释掉RGB屏幕相关设备树内容。修改后,正常。
root@wangpi:~# cat /sys/class/graphics/fb*/name
fb_st7789v
root@wangpi:~# ls /dev/fb*
/dev/fb0
2.5.4 颜色反色
驱动文件中屏幕的初始化代码,不反转颜色。
2.5.6 fb与tty的映射
root@wangpi:~# echo hello > /dev/tty1
2.5.7 CS片选被拉高
在抓时序的过程中,CS在片选的时候,中间会有拉高信号。认为R43电阻拉高片选线应该没有问题,但是去掉就好了。不明所以,莫名其妙,去掉好用就行了。
三、触摸驱动
驱动IC:GT911
3.1 配置内核
3.2 修改设备树
suniv-f1c100s-licheepi-nano.dts
// SPDX-License-Identifier: (GPL-2.0+ OR X11)
/dts-v1/;
#include "suniv-f1c100s.dtsi"
/ {
model = "Widora MangoPi R3";
compatible = "allwinner,suniv-f1c200s",
"allwinner,suniv-f1c100s";
aliases {
//serial0 = &uart0;
serial1 = &uart1;
};
chosen {
stdout-path = "serial1:115200n8";
};
/*
panel: panel {
compatible = "bananapi,s070wv20-ct16", "simple-panel";
#address-cells = <1>;
#size-cells = <0>;
port@0 {
reg = <0>;
#address-cells = <1>;
#size-cells = <0>;
panel_input: endpoint@0 {
reg = <0>;
remote-endpoint = <&tcon0_out_lcd>;
};
};
};
*/
/*
backlight: backlight {
compatible = "pwm-backlight";
pwms = <&pwm 1 500000 0>;
pwm-names = "backlight";
brightness-levels = <0 4 8 16 32 64 128 255>;
default-brightness-level = <7>;
status = "okay";
};
*/
};
&spi0 {
status = "okay";
spi-nor@0 {
#address-cells = <1>;
#size-cells = <1>;
compatible = "winbond,w25q128", "jedec,spi-nor";
reg = <0>;
spi-max-frequency = <50000000>;
status = "disabled";
partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;
partition@0 {
label = "u-boot";
reg = <0x000000 0x70000>;
read-only;
};
partition@1 {
label = "kernel";
reg = <0x70000 0x590000>;
read-only;
};
partition@2 {
label = "rom";
reg = <0x600000 0x700000>;
read-only;
};
partition@3 {
label = "overlay";
reg = <0xd00000 0x300000>;
};
};
};
spi-nand@0 {
#address-cells = <1>;
#size-cells = <1>;
compatible = "spi-nand";
reg = <0>;
spi-max-frequency = <50000000>;
status = "disabled";
partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;
partition@0 {
label = "u-boot";
reg = <0x000000 0x100000>;
read-only;
};
partition@1 {
label = "kernel";
reg = <0x100000 0x500000>;
read-only;
};
partition@2 {
label = "rom";
reg = <0x600000 0x2a00000>;
read-only;
};
partition@3 {
label = "vendor";
reg = <0x3000000 0x1000000>;
};
partition@4 {
label = "overlay";
reg = <0x4000000 0x3000000>;
};
};
};
st7789v@0 {
status = "okay";
compatible = "sitronix,st7789v";
reg = <0>;
spi-max-frequency =<50000000>; //SPI时钟32M,先给50M试一下
rotate =<90>; //屏幕旋转90度
spi-cpol;
spi-cpha;
rgb; //颜色格式RGB
fps =<60>; //刷新30帧率,先给60试一下
buswidth =<8>; //总线宽度8
reset-gpios=<&pio 4 12 GPIO_ACTIVE_LOW>; //GPIOE12
dc-gpios =<&pio 0 0 GPIO_ACTIVE_HIGH>; //GPIOA0
debug =<0>; //不开启调试
};
};
/*
&pwm {
pinctrl-names = "default";
pinctrl-0 = <&pwm1_pe_pins>;
status = "okay";
};
*/
&uart1 {
pinctrl-names = "default";
pinctrl-0 = <&uart1_pa_pins>;
status = "okay";
};
&mmc0 {
status = "okay";
broken-cd;
};
&otg_sram {
status = "okay";
};
&usb_otg {
dr_mode = "otg"; /* otg host peripheral */
status = "okay";
};
&usbphy {
status = "okay";
};
&cedar_ve {
status = "okay";
};
&ion {
status = "okay";
};
/*
&de {
status = "okay";
};
&fe0 {
status = "okay";
};
&be0 {
status = "okay";
};
&tve0 {
status = "okay";
};
&tcon0 {
pinctrl-names = "default";
pinctrl-0 = <&lcd_rgb565_pins>;
status = "okay";
};
&tcon0_out {
tcon0_out_lcd: endpoint@0 {
reg = <0>;
remote-endpoint = <&panel_input>;
};
};
*/
&codec {
allwinner,audio-routing =
"Headphone", "HP",
"Headphone", "HPCOM",
"LINEIN", "Line In",
"FMINL", "Left FM In",
"FMINR", "Right FM In",
"MIC", "Mic";
status = "okay";
};
&i2c0 {
pinctrl-names = "default";
pinctrl-0 = <&i2c0_pd_pins>;
status = "okay";
/*
rtp@48 {
compatible = "ti,tsc2007";
reg = <0x48>;
interrupt-parent = <&pio>;
interrupts = <4 12 IRQ_TYPE_EDGE_FALLING>;
gpios = <&pio 4 12 GPIO_ACTIVE_LOW>;
pendown-gpio = <&pio 4 12 GPIO_ACTIVE_LOW>;
ti,x-plate-ohms = <660>;
wakeup-source;
status = "okay";
};
*/
ctp@14 {
compatible = "goodix,gt911";
reg = <0x14>; // 0x5d
interrupt-parent = <&pio>;
interrupts = <4 11 IRQ_TYPE_EDGE_FALLING>; // PE11
irq-gpios = <&pio 4 11 GPIO_ACTIVE_HIGH>; // PE11
reset-gpios = <&pio 4 10 GPIO_ACTIVE_HIGH>; // PE10
status = "okay";
touchscreen-size-x = <240>;
touchscreen-size-y = <320>;
touchscreen-swapped-x-y;
touchscreen-inverted-y;
};
/*
ov2640: camera@30 {
compatible = "ovti,ov2640";
reg = <0x30>;
pinctrl-0 = <&clk_out_pins>;
pinctrl-names = "default";
clocks = <&clk_out>;
clock-names = "xvclk";
assigned-clocks = <&clk_out>;
assigned-clock-rates = <24000000>;
status = "okay";
port {
ov2640_ep: endpoint {
remote-endpoint = <&csi0_ep>;
bus-width = <8>;
hsync-active = <0>;
vsync-active = <0>;
pclk-sample = <1>;
};
};
};
*/
/*
ov5640: camera@3c {
compatible = "ovti,ov5640";
reg = <0x3c>;
pinctrl-0 = <&clk_out_pins>;
pinctrl-names = "default";
clocks = <&clk_out>;
clock-names = "xclk";
assigned-clocks = <&clk_out>;
assigned-clock-rates = <24000000>;
status = "disabled";
port {
ov5640_ep: endpoint {
remote-endpoint = <&csi0_ep>;
bus-width = <8>;
hsync-active = <0>;
vsync-active = <0>;
pclk-sample = <1>;
};
};
};
*/
};
/*
&csi0 {
pinctrl-names = "default";
pinctrl-0 = <&csi0_pins>;
packed-format;
status = "okay";
port {
csi0_ep: endpoint {
remote-endpoint = <&ov2640_ep>;
bus-width = <8>;
hsync-active = <0>;
vsync-active = <0>;
pclk-sample = <1>;
};
};
};
*/
3.3 配置tslib
参考:https://blog.csdn.net/weixin_36117563/article/details/140269173
ts_calibrate
ts_print
ts_test
均可正常使用。
3.4 测试
evtest /dev/input/event0
3.5 问题
3.5.1 gpio申请错误
中断引脚需要选择的引脚不支持中断。从PA1改为PE11。
3.5.2 i2c总线没有0x5d
使用命令i2cdetect -y 0 查看是否发现设备,发现没有0x5d。
root@wangpi:~# i2cdetect -y 0
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- --
10: -- -- -- -- UU -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- 48 -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
查看GT911芯片手册,确认地址。发现地址有2个,由初始化时序确定。地址为0x14或0x5d。
3.5.3 测试的时候发现x,y坐标反
使用evtest时候获得的坐标值与期望不一致,修改设备树。
touchscreen-size-x = <240>;
touchscreen-size-y = <320>;
touchscreen-swapped-x-y;
touchscreen-inverted-y;
四、参考
显示驱动参考链接:
https://www.cnblogs.com/twzy/p/15160836.html
https://www.cnblogs.com/hfwz/p/16028968.html
https://www.bilibili.com/read/cv9947785/
https://blog.csdn.net/qq_33552551/article/details/133740350
触摸参考链接:
https://blog.csdn.net/weixin_45881223/article/details/126176885
https://blog.csdn.net/qq_50299271/article/details/131610509