在Raspberry Pi Zero W中配置TFT LCD Framebuffer驱动

TFT LCD Framebuffer驱动配置

文章目录

  • TFT LCD Framebuffer驱动配置
    • 1、硬件准备
    • 2、软件配置
      • 2.1 启用SPI驱动
      • 2.2 TFT LCD设备驱动树配置

本文将以ILI9341 LCD为例,将详细介绍如何配置TFT LCD的Framebuffer驱动。

1、硬件准备

  • Raspberry Pi Zero W开发板一个(镜像Linux内核版本为5.18.84+)
  • TFT LCD 模块一个(ILI9341驱动IC)
  • 连接线
  • 数据线
  • 面包板

TFT LCD与Raspberry Pi Zero W接线如下:

序号TFT LCDRaspberry PI
1VCC3.3V或5V
2GNDGND
3SCKGPIO 11 SCLK (SPI0)
4SDAGPIO10 MOSI (SPI0)
5RSTGPIO 6
6DCGPIO 5
7CSGPIO8 Chip-Enable-CE0(SPI0)

Raspberry PI Zero W的引脚如下:

在这里插入图片描述

2、软件配置

2.1 启用SPI驱动

在命令行中输入:

sudo raspi-config

在这里插入图片描述

选择3 Interface Options进入接口驱动配置页面:

在这里插入图片描述

选择I4 SPI Enable/disable automatic loading of SPI kernel module开启或关闭SPI驱动。

另外,如果不想在命令中配置,也可以在图形界面中配置。还可以修改/boot/config.txt文件:

在这里插入图片描述

#符号删除即可启用spi。

2.2 TFT LCD设备驱动树配置

下面将创建自定义的DTS文件。下面将创建一个名称为ili9341.dts的文件。其内容如下:

/dts-v1/;
/plugin/;/ {compatible = "brcm,bcm2835";// Enable the SPI controllerfragment@0 {target = <&spi0>;__overlay__ {status = "okay";};};// Enabling the SPI controller also enables spidev on cs0, so we have disable itfragment@1 {target = <&spidev0>;__overlay__ {status = "disabled";};};fragment@2 {target = <&spi0>;__overlay__ {/* needed to avoid dtc warning */#address-cells = <1>;#size-cells = <0>;display: display@0{// MIPI DBI compatible driver// This driver is used because it can ignore an illegal rotate value// and doesn't have a set_gamma() function.compatible = "ilitek,ili9341";reg = <0>; // Chip Select 0spi-max-frequency = <32000000>; // 32MHzreset-gpios = <&gpio 6 1>; // reset is active low hence the 1dc-gpios = <&gpio 5 0>;width = <320>;height = <240>;buswidth = <8>; // Most controllers use this value// This is a hack to prevent fb_s6d02a1.c:set_var() from issuing// command 0x36 after the init sequence has been applied and thus// changing the config.rotate = <1>;// see drivers/staging/fbtft/fb_ili9341.c:init_display() for how this looks in the driver// Command 0x36 is taken from the fb_ili9341.c:set_var() function.init = <0x10000010x20000050x10000280x10000cf 0x00 0x83 0x300x10000ed 0x64 0x03 0x12 0x810x10000e8 0x85 0x01 0x790x10000cb 0x39 0x2c 0x00 0x34 0x020x10000f7 0x200x10000ea 0x00 0x000x10000c0 0x260x10000c1 0x110x10000c5 0x35 0x3e0x10000c7 0xbe0x100003a 0x550x1000036 0x280x10000b1 0x00 0x1b0x1000026 0x010x10000f2 0x080x1000026 0x010x10000e0 0x1f 0x1a 0x18 0x0a 0x0f 0x06 0x45 0x87 0x32 0x0a 0x07 0x02 0x07 0x05 0x000x10000e1 0x00 0x25 0x27 0x05 0x10 0x09 0x3a 0x78 0x4d 0x05 0x18 0x0d 0x38 0x3a 0x1f0x10000b7 0x070x10000b6 0x0a 0x82 0x27 0x000x10000110x20000640x10000290x2000064>;debug = <0x4000000>; // print init commands to the kernel log};};};
};

请根据自己的接线修改引脚:

  • reset-gpios:LCD 的RES引脚
  • dc-gpios:LCD的DC引脚

init为LCD的初始化指令。

编译DTS

在命令行中,执行如下命令:

dtc -o ili9341.dtbo ili9341.dts

将编译好的dtbo文件复制到/boot/overlays/

sudo cp ili9341.dtbo /boot/overlays/

配置overlays

打开/boot/config.txt文件,在文件末尾添加如下内容:

dtoverlay=ili9341

保存并重新启动系统。在系统启动完成后,在命令行执行命令:

dmesg

可以看到TFT的Framebuffer内核日志信息:

[   40.657276] fbtft: module is from the staging directory, the quality is unknown, you have been warned.
[   40.911475] fb_ili9341: module is from the staging directory, the quality is unknown, you have been warned.
[   41.314042] SPI driver fb_ili9341 has no spi_device_id for ilitek,ili9341
[   41.314487] fb_ili9341 spi0.0: fbtft_property_value: width = 320
[   41.314532] fb_ili9341 spi0.0: fbtft_property_value: height = 240
[   41.314562] fb_ili9341 spi0.0: fbtft_property_value: buswidth = 8
[   41.314594] fb_ili9341 spi0.0: fbtft_property_value: debug = 67108864
[   41.314620] fb_ili9341 spi0.0: fbtft_property_value: rotate = 1
[   41.457358] cfg80211: Loading compiled-in X.509 certificates for regulatory database
[   41.515507] fb_ili9341 spi0.0: init: write_register:
[   41.515554] fb_ili9341 spi0.0: buf[0] = 01
[   41.515705] fb_ili9341 spi0.0: init: msleep(5)
[   41.547050] fb_ili9341 spi0.0: init: write_register:
[   41.547097] fb_ili9341 spi0.0: buf[0] = 28
[   41.549533] fb_ili9341 spi0.0: init: write_register:
[   41.549576] fb_ili9341 spi0.0: buf[0] = CF
[   41.549607] fb_ili9341 spi0.0: buf[1] = 00
[   41.549628] fb_ili9341 spi0.0: buf[2] = 83
[   41.549649] fb_ili9341 spi0.0: buf[3] = 30
[   41.550784] fb_ili9341 spi0.0: init: write_register:
[   41.550821] fb_ili9341 spi0.0: buf[0] = ED
[   41.550848] fb_ili9341 spi0.0: buf[1] = 64
[   41.550868] fb_ili9341 spi0.0: buf[2] = 03
[   41.550888] fb_ili9341 spi0.0: buf[3] = 12
[   41.550907] fb_ili9341 spi0.0: buf[4] = 81
[   41.551978] fb_ili9341 spi0.0: init: write_register:
[   41.552019] fb_ili9341 spi0.0: buf[0] = E8
[   41.552045] fb_ili9341 spi0.0: buf[1] = 85
[   41.552067] fb_ili9341 spi0.0: buf[2] = 01
[   41.552088] fb_ili9341 spi0.0: buf[3] = 79
[   41.556254] fb_ili9341 spi0.0: init: write_register:
[   41.556350] fb_ili9341 spi0.0: buf[0] = CB
[   41.556382] fb_ili9341 spi0.0: buf[1] = 39
[   41.556404] fb_ili9341 spi0.0: buf[2] = 2C
[   41.556424] fb_ili9341 spi0.0: buf[3] = 00
[   41.556444] fb_ili9341 spi0.0: buf[4] = 34
[   41.556464] fb_ili9341 spi0.0: buf[5] = 02
[   41.558014] fb_ili9341 spi0.0: init: write_register:
[   41.558055] fb_ili9341 spi0.0: buf[0] = F7
[   41.558083] fb_ili9341 spi0.0: buf[1] = 20
[   41.559167] fb_ili9341 spi0.0: init: write_register:
[   41.559208] fb_ili9341 spi0.0: buf[0] = EA
[   41.559236] fb_ili9341 spi0.0: buf[1] = 00
[   41.559257] fb_ili9341 spi0.0: buf[2] = 00
[   41.561600] fb_ili9341 spi0.0: init: write_register:
[   41.561643] fb_ili9341 spi0.0: buf[0] = C0
[   41.561672] fb_ili9341 spi0.0: buf[1] = 26
[   41.561848] fb_ili9341 spi0.0: init: write_register:
[   41.561904] fb_ili9341 spi0.0: buf[0] = C1
[   41.561935] fb_ili9341 spi0.0: buf[1] = 11
[   41.566661] fb_ili9341 spi0.0: init: write_register:
[   41.566706] fb_ili9341 spi0.0: buf[0] = C5
[   41.566736] fb_ili9341 spi0.0: buf[1] = 35
[   41.566757] fb_ili9341 spi0.0: buf[2] = 3E
[   41.569197] fb_ili9341 spi0.0: init: write_register:
[   41.569236] fb_ili9341 spi0.0: buf[0] = C7
[   41.569267] fb_ili9341 spi0.0: buf[1] = BE
[   41.569440] fb_ili9341 spi0.0: init: write_register:
[   41.569465] fb_ili9341 spi0.0: buf[0] = 3A
[   41.569489] fb_ili9341 spi0.0: buf[1] = 55
[   41.571529] fb_ili9341 spi0.0: init: write_register:
[   41.571572] fb_ili9341 spi0.0: buf[0] = 36
[   41.571600] fb_ili9341 spi0.0: buf[1] = 28
[   41.580923] fb_ili9341 spi0.0: init: write_register:
[   41.580969] fb_ili9341 spi0.0: buf[0] = B1
[   41.580998] fb_ili9341 spi0.0: buf[1] = 00
[   41.581019] fb_ili9341 spi0.0: buf[2] = 1B
[   41.588734] fb_ili9341 spi0.0: init: write_register:
[   41.588781] fb_ili9341 spi0.0: buf[0] = 26
[   41.588811] fb_ili9341 spi0.0: buf[1] = 01
[   41.633770] fb_ili9341 spi0.0: init: write_register:
[   41.633816] fb_ili9341 spi0.0: buf[0] = F2
[   41.633847] fb_ili9341 spi0.0: buf[1] = 08
[   41.636043] fb_ili9341 spi0.0: init: write_register:
[   41.636086] fb_ili9341 spi0.0: buf[0] = 26
[   41.636116] fb_ili9341 spi0.0: buf[1] = 01
[   41.669646] fb_ili9341 spi0.0: init: write_register:
[   41.669691] fb_ili9341 spi0.0: buf[0] = E0
[   41.669720] fb_ili9341 spi0.0: buf[1] = 1F
[   41.669740] fb_ili9341 spi0.0: buf[2] = 1A
[   41.669759] fb_ili9341 spi0.0: buf[3] = 18
[   41.669779] fb_ili9341 spi0.0: buf[4] = 0A
[   41.669800] fb_ili9341 spi0.0: buf[5] = 0F
[   41.669819] fb_ili9341 spi0.0: buf[6] = 06
[   41.669838] fb_ili9341 spi0.0: buf[7] = 45
[   41.669857] fb_ili9341 spi0.0: buf[8] = 87
[   41.669877] fb_ili9341 spi0.0: buf[9] = 32
[   41.669897] fb_ili9341 spi0.0: buf[10] = 0A
[   41.669918] fb_ili9341 spi0.0: buf[11] = 07
[   41.669938] fb_ili9341 spi0.0: buf[12] = 02
[   41.669958] fb_ili9341 spi0.0: buf[13] = 07
[   41.669977] fb_ili9341 spi0.0: buf[14] = 05
[   41.669997] fb_ili9341 spi0.0: buf[15] = 00
[   41.683625] fb_ili9341 spi0.0: init: write_register:
[   41.683670] fb_ili9341 spi0.0: buf[0] = E1
[   41.683788] fb_ili9341 spi0.0: buf[1] = 00
[   41.683815] fb_ili9341 spi0.0: buf[2] = 25
[   41.683838] fb_ili9341 spi0.0: buf[3] = 27
[   41.683859] fb_ili9341 spi0.0: buf[4] = 05
[   41.683879] fb_ili9341 spi0.0: buf[5] = 10
[   41.683899] fb_ili9341 spi0.0: buf[6] = 09
[   41.683919] fb_ili9341 spi0.0: buf[7] = 3A
[   41.683939] fb_ili9341 spi0.0: buf[8] = 78
[   41.683958] fb_ili9341 spi0.0: buf[9] = 4D
[   41.683977] fb_ili9341 spi0.0: buf[10] = 05
[   41.683998] fb_ili9341 spi0.0: buf[11] = 18
[   41.684019] fb_ili9341 spi0.0: buf[12] = 0D
[   41.684038] fb_ili9341 spi0.0: buf[13] = 38
[   41.684059] fb_ili9341 spi0.0: buf[14] = 3A
[   41.684079] fb_ili9341 spi0.0: buf[15] = 1F
[   41.693430] fb_ili9341 spi0.0: init: write_register:
[   41.693474] fb_ili9341 spi0.0: buf[0] = B7
[   41.693504] fb_ili9341 spi0.0: buf[1] = 07
[   41.707164] fb_ili9341 spi0.0: init: write_register:
[   41.707209] fb_ili9341 spi0.0: buf[0] = B6
[   41.707240] fb_ili9341 spi0.0: buf[1] = 0A
[   41.707261] fb_ili9341 spi0.0: buf[2] = 82
[   41.707283] fb_ili9341 spi0.0: buf[3] = 27
[   41.707303] fb_ili9341 spi0.0: buf[4] = 00
[   41.719204] fb_ili9341 spi0.0: init: write_register:
[   41.719250] fb_ili9341 spi0.0: buf[0] = 11
[   41.721594] fb_ili9341 spi0.0: init: msleep(100)
[   41.833878] fb_ili9341 spi0.0: init: write_register:
[   41.833925] fb_ili9341 spi0.0: buf[0] = 29
[   41.834076] fb_ili9341 spi0.0: init: msleep(100)

在设备目录中,我们将可以看到有两个framebuffer设备文件,fb0,fb1,其中fb1就是我们的TFT LCD的Framebuffer设备。

在这里插入图片描述

从内核日志输出可以知道,fb_ili9341已经启动。结果如下:

在这里插入图片描述

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/604299.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Linux系统常用的安全优化

环境&#xff1a;CentOS7.9 1、禁用SELinux SELinux是美国国家安全局对于强制访问控制的实现 1)永久禁用SELinux vim /etc/selinux/config SELINUXdisabled #必须重启系统才能生效2&#xff09;临时禁用SELInux getenforce #查看SELInux当前状态 setenforce 0 #数字…

[AutoSar]基础部分 RTE 06 对runnable的触发和SWC的影响

目录 关键词平台说明一、runnable二、RTE的event2.1Mode类型event2.2周期触发类型2.3 数据交互触发 三、internal runnable value四、专属运行区指定五、per_instance memory 关键词 嵌入式、C语言、autosar、Rte 平台说明 项目ValueOSautosar OSautosar厂商vector芯片厂商T…

UG装配-动画制作

制作装配动画用到的命令是序列 制作动画前&#xff0c;先将所有约束取消 当我们在装配导航器中装配好产品后&#xff0c;可以在序列中编辑生产动态装配或爆炸动画&#xff1b; 需要注意的是&#xff0c;如果是希望创建装配或爆炸动画&#xff0c;需要先将所有约束取消&#…

mac版viso软件 流程图软件omnigraffile

OmniGraffle 是一款由 The Omni Group 开发的绘图工具&#xff0c;主要用于创建各种类型的图表、流程图、组织结构图、网站地图等。它提供了丰富的绘图工具和功能&#xff0c;包括形状、线条、文本、颜色、样式等&#xff0c;可以帮助用户轻松地创建出精美的图表和图形。 OmniG…

Micro-app 微前端框架demo介绍

Micro-app 框架 1、框架安装 npm i micro-zoe/micro-app --save2、子应用对应的view页面 <template><div><!-- name(必传)&#xff1a;应用名称url(必传)&#xff1a;应用地址&#xff0c;会被自动补全为http://localhost:3000/index.htmlbaseroute(可选)&…

react+AntDesign 之 pc端项目案例

1.环境搭建以及初始化目录 CRA是一个底层基于webpack快速创建React项目的脚手架工具 # 使用npx创建项目 npx create-react-app react-jike# 进入到项 cd react-jike# 启动项目 npm start2.安装SCSS SASS 是一种预编译的 CSS&#xff0c;支持一些比较高级的语法&#xff0c;…

3D点云上的深度学习综述

1 Title Deep Learning for 3D Point Clouds: A Survey&#xff08;Yulan Guo; Hanyun Wang; Qingyong Hu; Hao Liu; Li Liu; Mohammed Bennamoun&#xff09;【IEEE Transactions on Pattern Analysis and Machine Intelligence 2020】 2 Conclusion Deep learning on point…

Android开发编程从入门到精通,安卓技术从初级到高级全套教学

一、教程描述 本套教程基于JDK1.8版本&#xff0c;教学内容主要有&#xff0c;1、环境搭建&#xff0c;UI布局&#xff0c;基础UI组件&#xff0c;高级UI组件&#xff0c;通知&#xff0c;自定义组件&#xff0c;样式主题&#xff1b;2、四大组件&#xff0c;Intent&#xff0…

(九)One-Wire总线-DS18B20

文章目录 One-Wire总线篇复位和应答读/写0&#xff0c;1 DS18B20篇原理图概述最主要特性几个重要的寄存器&#xff08;部分要掌握&#xff09;存储有数字温度结果的2个字节宽度的温度寄存器寄存器描述&#xff1a;寄存器说明&#xff1a; 一个字节的过温和一个字节的低温&#…

msckf_vio在ubuntu20.04中的编译

1.新建catkin workspace文件夹&#xff0c;并在其中新建src文件夹&#xff0c;并将源码clone至src内。 源码地址&#xff1a;https://github.com/KumarRobotics/msckf_vio 目录层级示意如下&#xff0c;build和devel不必新建&#xff0c;后续指令会自动新建。 2. 在编译之前…

Python 面向对象之反射

Python 面向对象之反射 【一】概念 反射是指通过对象的属性名或者方法名来获取对象的属性或调用方法的能力反射还指的是在程序额运行过程中可以动态获取对象的信息(属性和方法) 【二】四个内置函数 又叫做反射函数 万物皆对象&#xff08;整数、字符串、函数、模块、类等等…

第02章_变量与进制

第02章_变量与进制 讲师&#xff1a;尚硅谷-宋红康&#xff08;江湖人称&#xff1a;康师傅&#xff09; 官网&#xff1a;http://www.atguigu.com 本章专题脉络 1、关键字(keyword) 定义&#xff1a;被C语言赋予了特殊含义&#xff0c;用做专门用途的字符串&#xff08;或单…

力扣:438. 找到字符串中所有字母异位词 题解

Problem: 438. 找到字符串中所有字母异位词 438. 找到字符串中所有字母异位词 预备知识解题思路复杂度Code其它细节推荐博客或题目博客题目滑动窗口哈希表 预备知识 此题用到了双指针算法中的滑动窗口思想&#xff0c;以及哈希表的运用。c中是unordered_map。如果对此不了解的u…

Android 车联网——PowerHalService介绍(九)

在前面文章介绍 CarPowerManagementService 时候,我们了解到 VehicleHAL 接收到电源变化的信号后,通过 PowerHalService 分发给 CarPowerManagementService 的。而且 CarPowerManagementService 的很多方法也都是调用到 PowerHalService 中。这一节我们来看一下 PowerHalServ…

二、UI文件设计与运行机制

一、UI文件设计与运行机制 1、创建工程 2、添加控件&#xff0c;实现按钮点击 &#xff08;1&#xff09;添加控件 &#xff08;2&#xff09;添加信号和槽 2、分析项目结构 test_02test_02.pro Qt工程文件Headerswidget.h 设计的窗体类的头文件Sourcesmain.cpp 主程序入…

metartc5_jz源码阅读-yang_push_h264_encodeVideo

//编码rtp的视频buffer&#xff0c;发送给p2p对端。 int32_t yang_push_h264_encodeVideo(YangRtcSession *session, YangPushH264Rtp *rtp,YangRtpPacket *pkt) {int err 0;//用videoRtpBuffer中的数据填充rtp->buf.yang_init_buffer(&rtp->buf, yang_get_rtpBuffe…

如何在CMakeLists.txt设置多线程编译加速

在windows cmake-gui 编译时候&#xff0c;没有像linux 一样有make -j 实现多线程编译 但是没有多线程编译速度会很慢&#xff0c;为了windows 编译程序时候实现多线程加速可以在 cmakelists.txt 添加下面两句就可以实现多线程编译 set( CMAKE_C_FLAGS "${CMAKE_C_FLA…

RabbitMQ消息可靠性保证机制3--消费端ACK机制

消费端ACK机制 ​ 在这之前已经完成了发送端的确认机制。可以保证数据成功的发送到RabbitMQ&#xff0c;以及持久化机制&#xff0c;然尔这依然无法完全保证整个过程的可靠性&#xff0c;因为如果消息被消费过程中业务处理失败了&#xff0c;但是消息却已经被标记为消费了&…

3.2.6 使用ROPES软件开发模型做设计、实现、测试

3.2.6 使用ROPES软件开发模型做设计 使用ROPES软件开发模型进行设计涉及将系统开发过程分为分析、设计和优化的不同阶段。 分析模型与设计模型 分析模型&#xff1a;定义系统所需的属性集合&#xff0c;它是理解和表述系统需求的第一步。它更注重于"应该做什么"而…

cygwin安装make工具

1. 下载安装包。 2. 运行setup-x86_64.exe 3. 选择安装源&#xff08;Mirror&#xff09;&#xff1a;在 Cygwin 安装程序的窗口中&#xff0c;选择 "Install from Internet" 选项&#xff0c;然后点击 "Next" 继续。 4. 选择安装目录&#xff1a;在 &q…