ST7789 linux4.x驱动

文章目录

  • ST7789 linux4.x驱动
    • 设备树配置
    • 驱动程序
    • 编译驱动
    • 测试驱动

ST7789 linux4.x驱动

设备树配置

pinctrl_ecspi2_cs_1: ecspi2_cs_grp-1 {fsl,pins = <MX6UL_PAD_CSI_DATA01__GPIO4_IO22	0x40017059>;
};pinctrl_ecspi2_1: escpi2grp {fsl,pins = <MX6UL_PAD_CSI_DATA00__ECSPI2_SCLK	0x100b1MX6UL_PAD_CSI_DATA02__ECSPI2_MOSI	0x100b1MX6UL_PAD_CSI_DATA03__ECSPI2_MISO	0x100b1>;
};
&ecspi2 {fsl,spi-num-chipselects = <1>;cs-gpios = <&gpio4 22 0>;pinctrl-names = "default";pinctrl-0 = <&pinctrl_ecspi2_1 &pinctrl_ecspi2_cs_1>;status = "okay";fbftf: st7789v@0 {compatible = "sitronix,st7789v";spi-max-frequency = <8000000>;dc-gpios = <&gpio3 23 GPIO_ACTIVE_HIGH>;rst-gpio = <&gpio2 22 GPIO_ACTIVE_HIGH>;led-gpios = <&gpio2 19 GPIO_ACTIVE_LOW>;reg = <0>;//bgr = <1>;//rotate = <0>;buswidth = <8>;//width = <240>;//height= <320>;//debug = <0>;fps = <60>;};
};

驱动程序

drivers/staging/fbtft/fb_st7789v.c

/** FB driver for the ST7789V LCD Controller** Copyright (C) 2015 Dennis Menschel** This program is free software; you can redistribute it and/or modify* it under the terms of the GNU General Public License as published by* the Free Software Foundation; either version 2 of the License, or* (at your option) any later version.** This program is distributed in the hope that it will be useful,* but WITHOUT ANY WARRANTY; without even the implied warranty of* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the* GNU General Public License for more details.*/#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"*/#define DEFAULT_GAMMA \"f0 00 0a 10 12 1b 39 44 47 28 12 10 16 1b\n" \"f0 00 0a 10 11 1a 3b 34 4e 3a 17 16 21 22"/*** 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, MIPI_DCS_EXIT_SLEEP_MODE);mdelay(120);write_reg(par, 0xb2, 0x0c, 0x0c, 0x00, 0x33, 0x33);write_reg(par, 0xb7, 0x35);write_reg(par, 0xbb, 0x33);write_reg(par, 0xc3, 0x1a);write_reg(par, 0xc4, 0x18);write_reg(par, 0xc6, 0x01);write_reg(par, 0xd0, 0xa4, 0xb3);write_reg(par, 0xe0, 0xf0, 0x00, 0x0a, 0x10, 0x12, 0x1b, 0x39, 0x44, 0x47, 0x28, 0x12, 0x10, 0x16, 0x1b);write_reg(par, 0xe1, 0xf0, 0x00, 0x0a, 0x10, 0x11, 0x1a, 0x3b, 0x34, 0x4e, 0x3a, 0x17, 0x16, 0x21, 0x22);write_reg(par, 0x3a, 0x55);write_reg(par, 0x2a, 0x00, 0x00, 0x00, 0xef);write_reg(par, 0x2b, 0x00, 0x00, 0x01, 0x3f);write_reg(par, 0x21);write_reg(par, 0x29);write_reg(par, 0x2c);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);break;case 180:madctl_par |= (MADCTL_MX | MADCTL_MY);break;case 270:madctl_par |= (MADCTL_MV | MADCTL_MX);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, unsigned long *curves)
{int i;int j;int c; /* curve index offset *//** Bitmasks for gamma curve command parameters.* The masks are the same for both positive and negative voltage* gamma curves.*/const u8 gamma_par_mask[] = {0xFF, /* V63[3:0], V0[3:0]*/0x3F, /* V1[5:0] */0x3F, /* V2[5:0] */0x1F, /* V4[4:0] */0x1F, /* V6[4:0] */0x3F, /* J0[1:0], V13[3:0] */0x7F, /* V20[6:0] */0x77, /* V36[2:0], V27[2:0] */0x7F, /* V43[6:0] */0x3F, /* J1[1:0], V50[3:0] */0x1F, /* V57[4:0] */0x1F, /* V59[4:0] */0x3F, /* V61[5:0] */0x3F, /* V62[5:0] */};for (i = 0; i < par->gamma.num_curves; i++) {c = i * par->gamma.num_values;for (j = 0; j < par->gamma.num_values; j++)curves[c + j] &= gamma_par_mask[j];write_reg(par, PVGAMCTRL + i,curves[c + 0], curves[c + 1], curves[c + 2],curves[c + 3], curves[c + 4], curves[c + 5],curves[c + 6], curves[c + 7], curves[c + 8],curves[c + 9], curves[c + 10], curves[c + 11],curves[c + 12], curves[c + 13]);}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);elsewrite_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");

drivers/staging/fbtft/Makefile

obj-$(CONFIG_FB_TFT_ST7789V)     += fb_st7789v.o

drivers/staging/fbtft/Kconfig

config FB_TFT_ST7789Vtristate "FB driver for the ST7789V LCD Controller"depends on FB_TFThelpThis enables generic framebuffer support for the Sitronix ST7789Vdisplay controller. The controller is intended for small colordisplays with a resolution of up to 320x240 pixels.Say Y if you have such a display that utilizes this controller.

编译驱动

make ARCH=arm menuconfig
make ARCH=arm -j8

image-20240709094652481

测试驱动

fb-test
fb-test 1.1.1 (rosetta)
fb res 240x320 virtual 240x320, line_len 480, bpp 16

image-20240709095113733

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

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

相关文章

RocketMQ快速入门:主从、集群模式原理及搭建实操(十一)

目录 0. 引言1. 前备知识1.1 namesrv集群模式1.2 broker集群模式1.2 broker主从复制原理 2. 集群部署2.1 环境准备2.2 配置讲解2.3 一主多从模式部署2.4 多主无从模式部署2.5 多主多从模式部署 3. 总结 0. 引言 在学习完rocketmq的基础知识后&#xff0c;我们进入rocketmq高可…

和Bug较劲的第n天:[Error: Unable to open snapshot file: No such file or directory]

问题描述 最近做了一个小demo&#xff0c;基于parcel的&#xff0c;在迁移仓库的时候发生了一个报错 [Error: Unable to open snapshot file: No such file or directory] 原因分析&#xff1a; 在迁移仓库的时候&#xff0c;我将项目放入了一个以中文命名的文件夹里&#xf…

模电基础 - 信号的运算和处理

目录 一. 简介 二. 加法 三. 减法 四. 乘法 五. 除法 六. 总结 一. 简介 在模电基础中&#xff0c;信号的运算和处理是非常重要的内容。 信号的运算包括加法、减法、乘法、除法等。通过使用集成运放&#xff0c;可以很容易地实现这些运算。例如&#xff0c;利用反相输入…

算法的几种常见形式

算法&#xff08;Algorithm&#xff09; 算法&#xff08;Algorithm&#xff09;是指解决问题或完成任务的一系列明确的步骤或规则。在计算机科学中&#xff0c;算法是程序的核心部分&#xff0c;它定义了如何执行特定的任务或解决特定的问题。算法可以用多种方式来表示和实现…

宜春旅游集散中心展厅OLED透明屏方案设计

一、项目概述 为提升宜春旅游集散中心展厅的现代化展示水平&#xff0c;增强游客的参观体验&#xff0c;我们计划在展厅的核心区域引入OLED透明屏技术。该方案旨在通过高科技的视觉呈现方式&#xff0c;将展品信息以虚拟与现实相结合的方式展现&#xff0c;打造出一个既具科技感…

谷粒商城学习笔记-22-分布式组件-SpringCloud-OpenFeign测试远程调用

文章目录 一&#xff0c;OpenFeign的简介二&#xff0c;OpenFeign的使用步骤1&#xff0c;场景说明2&#xff0c;引入依赖2&#xff0c;开启OpenFeign3&#xff0c;编写Feign接口4&#xff0c;使用feign调用远程接口5&#xff0c;验证 错误记录 上一节学习了注册中心&#xff0…

鼠标录制工具|键鼠轨迹录制,实现自动办公

利用键鼠录制工具录制固定的鼠标点击、键盘输入等操作&#xff0c;实现自动化执行固定操作&#xff0c;节省时间。鼠标录制功能可以录制多步骤的操作&#xff0c;将录制的动作保存并命名&#xff0c;甚至可以编辑操作速度。下面将演示几种生活中常见的案例&#xff0c;详细讲解…

企业微信hook接口协议,移除群成员通知

移除群成员通知 返回示例 {"flag": 0, "receiver": 0, "sender_name": "", "is_room": 1, "server_id": 15318083, "send_time": 1687688952, "sender": 1688855749266556, "referid&…

插件更新了!

最近花了点时间&#xff0c;给网页插件添加了新功能&#xff0c;下面简单给大家介绍一下如何使用 我们安装好插件后&#xff0c;进入网页就可以看到一个带logo的按钮了&#xff0c;我们可以点一下就可以跳出快捷操作 不同页面点击会出现不同的功能&#xff0c;大家可以根据自己…

跨境传输需要遵守哪些准则,如何做到有效管控?

在全球化的商业环境中&#xff0c;跨国企业面临着数据跨境传输的挑战。随着业务的扩展&#xff0c;企业需要在不同国家和地区之间高效、安全地传输大量数据。选择合适的跨境传输方案对于保障数据安全、提高业务效率、遵守法律法规至关重要。 跨境传输数据需要遵守的准则和规定主…

Nginx:关于实现跨域代理

运维专题 Nginx&#xff1a;关于实现跨域代理 - 文章信息 - Author: 李俊才 (jcLee95) Visit me at CSDN: https://jclee95.blog.csdn.netMy WebSite&#xff1a;http://thispage.tech/Email: 291148484163.com. Shenzhen ChinaAddress of this article:https://blog.csdn.ne…

发那科机床联网串口配置

本文章仅针对无网口&#xff0c;需要通过串口输出采集数据情况。跟这篇文章互为参考&#xff0c;一个理论&#xff0c;一个实战。 Fanuc DPRNT宏程序串口采集-CSDN博客 一、禁用机器串口监控 选择System、monit 二、设置参数可写 在MDI模式中字符面板上按OFS/SET键,连按致屏…

终于搞定了通过两路蓝牙接收数据

一直想做无线传感器&#xff0c;通过蓝牙来接收数据&#xff0c;无奈因为arduino接收串口数据的一些问题&#xff0c;一直搁到现在。因为学校里给学生开了选修课&#xff0c;所以手边有一些nano和mega可以使用&#xff0c;所以就做了用两个nano加上两个蓝牙模块来发射数据&…

经常用借呗和花呗对征信有影响吗?

说起支付宝里的花呗和借呗&#xff0c;大伙儿肯定都不陌生&#xff0c;它们俩就像是支付宝里的信用贷款双胞胎&#xff0c;名字相近&#xff0c;性格却大相径庭。现在&#xff0c;这俩兄弟都乖乖地接入了央行的征信大家庭&#xff0c;你的每一次使用&#xff0c;都会被记录得清…

DDD架构

1.DDD架构的概念&#xff1a; 领域驱动设计&#xff08;Domain-Driven Design, DDD&#xff09;是一种软件设计方法&#xff0c;旨在将软件系统的设计和开发焦点集中在领域模型上&#xff0c;以解决复杂业务问题 2.DDD架构解决了什么问题: 在以前的mvc架构种&#xff0c;三层结…

产品经理-交互设计动手实践(11)

业内有很多画交互的工具&#xff0c;这里不过多介绍&#xff0c;互联网公司最常用的工具是Axure,墨刀,蓝湖,小瀑 它是一个专业的快速原型设计工具&#xff0c;使用它能够快速创建线框图、流程图、原型和规格说明文档。 它能快速、高效地创建原型&#xff0c;同时支持多人协作设…

华为HCIP Datacom H12-821 卷30

1.单选题 以下关于OSPF协议报文说法错误的是? A、OSPF报文采用UDP报文封装并且端口号是89 B、OSPF所有报文的头部格式相同 C、OSPF协议使用五种报文完成路由信息的传递 D、OSPF所有报文头部都携带了Router-ID字段 正确答案&#xff1a;A 解析&#xff1a; OSPF用IP报…

【人工智能】-- 法律与伦理

个人主页&#xff1a;欢迎来到 Papicatch的博客 课设专栏 &#xff1a;学生成绩管理系统 专业知识专栏&#xff1a; 专业知识 文章目录 &#x1f349;引言 &#x1f349;伦理问题 &#x1f348;隐私泄露问题 &#x1f34d;人工智能与隐私泄露的紧密关联 &#x1f34d;数…

上海慕尼黑电子展开展,启明智显携物联网前沿方案亮相

随着科技创新的浪潮不断涌来&#xff0c;上海慕尼黑电子展在万众瞩目中盛大开幕。本次展会汇聚了全球顶尖的电子产品与技术解决方案&#xff0c;成为业界瞩目的焦点。启明智显作为物联网彩屏显示领域的佼佼者携产品亮相展会&#xff0c;为参展者带来了RTOS、LINUX全系列方案及A…

鸿蒙 arkts 实现手机号中间四位隐藏, 可以使用 substring [ 简单适用新手 ]

1, 看效果 2, 直接cv代码就可以 Preview Entry Component struct Setting {Statephone:string 15555555555maskPhoneNumber(phone:string){const start phone.substring(0,3)const end phone.substring(7)return ${start}****${end}}build() {Column(){Text(this.maskPhon…