NanoPi NEO Air使用十二:使用自带的fbtft驱动点亮SPI接口TFT屏幕,ST7789V

NanoPi NEO Air使用十二:使用自带的fbtft驱动点亮SPI接口TFT屏幕,ST7789V,第1张

NanoPi NEO Air使用十二:使用自带的fbtft驱动点亮SPI接口TFT屏幕,ST7789V

上节自己编写spi驱动来点亮spi接口的小屏幕,其实Linux内核里已经提供spi接口小屏的设备驱动,即内核中已经自带了此类驱动,名字为fbtft。本节就来使用它。

引脚


240x240分辨率,1.3寸,主控为ST7789VW。

与开发板的引脚连接确定如下:

功能IOGNDPin65VPin2LCD_RESETPin7-PG11LCD_DCPin22-PA1SPICLKPin23-PC2SPIMOSIPin19-PC0

从开发板的引脚图发现,开发板使用的SPI0。

修改设备树

打开/home/ql/linux/H3/linux/arch/arm/boot/dts/sun8i-h3-nanopi.dtsi,找到spi0节点,修改为如下:

&spi0 {
	
	#address-cells = <1>;
	#size-cells = <0>;

	status = "okay";
	pinctrl-names = "default";
	pinctrl-0 = <&spi0_pins &spi0_cs_pins>;
	cs-gpios = <&pio 2 3 GPIO_ACTIVE_HIGH>, <&pio 0 6 GPIO_ACTIVE_HIGH>; 

	pitft: pitft@0{
		compatible = "sitronix,st7789vw";
		reg = <0>;
		status = "okay";

		spi-max-frequency = <50000000>;
		rotate = <0>;
		fps = <33>;
		buswidth = <8>;
		dc-gpios = <&pio 0 1 GPIO_ACTIVE_HIGH>;	 
		reset-gpios = <&pio 6 11 GPIO_ACTIVE_HIGH>; 
		led-gpios = <&pio 0 0 GPIO_ACTIVE_LOW>;	 		
		debug = <0x0>;
	};
};
&pio {
	leds_npi: led_pins {
		pins = "PA10";
		function = "gpio_out";
	};

	pinctrl_testTFTRes: testTFTRes_pins {
		pins = "PG11";
		function = "gpio_out";
	};

	pinctrl_testTFTDc: testTFTDc_pins {
		pins = "PA1";
		function = "gpio_out";
	};

	pinctrl_testTFTBk: testTFTBk_pins {
		pins = "PA0";
		function = "gpio_out";
	};
	
	spi0_cs_pins: spi0_cs_pins {
		pins = "PC3", "PA6";
		function = "gpio_out";
	};
};

关闭HDMI,否则设备默认HDMI输出,tft黑屏

&hdmi {
	//status = "okay";
	status = "disable";
};

&hdmi_out {
	hdmi_out_con: endpoint {
		remote-endpoint = <&hdmi_con_in>;
	};
};

&sound_hdmi {
	//status = "okay";
	status = "disable";
};

修改驱动文件

打开/home/ql/linux/H3/linux/drivers/staging/fbtft/路径,看下有没有fb_st7789vw.c文件,如果有下面的步骤就可以忽略了。
如果没有,那么新建一个fb_st7789vw.c文件,把下面内容复制进去,保存。


#include 
#include 
#include 
#include 
#include 
#include 

在Makefile中添加obj-$(CONFIG_FB_TFT_ST7789VW) += fb_st7789vw.o

在Kconfig中添加

config FB_TFT_ST7789VW
	tristate "FB driver for the ST7789VW LCD Controller"
	depends on FB_TFT
	help
	  This enables generic framebuffer support for the Sitronix ST7789VW
	  display controller. The controller is intended for small color
	  displays with a resolution of up to 240x240 pixels.

	  Say Y if you have such a display that utilizes this controller.

编译

到menuconfig中使能此驱动
make menuconfig ARCH=arm CROSS_COMPILE=arm-linux-

Device Drivers  --->  
	[*] Staging drivers  --->  
		<*>   Support for small TFT LCD display modules  --->
			<*>   FB driver for the ST7789VW LCD Controller 

# 编译内核、设备树
make zImage dtbs ARCH=arm CROSS_COMPILE=arm-linux- 

# 网络更新内核
scp arch/arm/boot/zImage [email protected]:/boot

# 网络更新设备树
scp arch/arm/boot/dts/sun8i-h3-nanopi-neo-air.dtb [email protected]:/boot

实际效果 命令行

上面的步骤做完了,重启就会有如下画面

播放视频
sudo apt install mplayer        # 安装mplayer
mplayer 1.mp4 -vo fbdev      

运行QT

下面的指令都要切换root执行

apt-get update && apt-get install git
git clone https://github.com/friendlyarm/matrix.git
cd matrix/demo/nanopi-status
./build.sh
./run.sh /dev/fb_st7789vw

轻量级界面
sudo apt install xfce4
startx

欢迎分享,转载请注明来源:内存溢出

原文地址: http://www.outofmemory.cn/zaji/5693922.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-17
下一篇 2022-12-17

发表评论

登录后才能评论

评论列表(0条)

保存