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.pswp.cn/web/42251.shtml
繁體地址,請注明出處:http://hk.pswp.cn/web/42251.shtml
英文地址,請注明出處:http://en.pswp.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高可…

痙攣性斜頸對生活有哪些影響?

痙攣性斜頸&#xff0c;這個名字聽起來可能并不熟悉&#xff0c;但它實際上是一種神經系統疾病&#xff0c;影響著全球數百萬人的生活質量。它以一種無法控制的方式&#xff0c;使患者的頸部肌肉發生不自主的收縮&#xff0c;導致頭部姿勢異常。對于患者來說&#xff0c;痙攣性…

和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&…

k8s中使用cert-manager生成自簽名證書

一、安裝 cert-manager 注意查看cert-manager和K8S支持的對應版本 我的 k8sv1.28.2&#xff0c;cert-manager v1.12.11 下載 cert-manager.yaml 文件&#xff0c;執行 kubectl apply -f cert-manager.yaml二、生成自簽名證書 cert-selfsigned.yaml apiVersion: cert-manage…

【SpringBoot】隨機鹽值+雙重SHA256加密實戰

目錄&#xff1a; 1.SHA-256和隨機鹽值 2.前端實現 3.后端實現 1.SHA-256和Salt 1.1.什么是SHA-256 SHA-256是一種信息摘要算法&#xff0c;也是一種密碼散列函數。對于任意長度的消息&#xff0c;SHA256都會產生一個256bit長的散列值&#xff08;哈希值&#xff09;&…

插件更新了!

最近花了點時間&#xff0c;給網頁插件添加了新功能&#xff0c;下面簡單給大家介紹一下如何使用 我們安裝好插件后&#xff0c;進入網頁就可以看到一個帶logo的按鈕了&#xff0c;我們可以點一下就可以跳出快捷操作 不同頁面點擊會出現不同的功能&#xff0c;大家可以根據自己…

dy商品評論采集

摘要 本文將詳細介紹如何通過抖音商品評論采集來獲取精準的用戶反饋&#xff0c;從而優化產品和營銷策略。通過這個指南&#xff0c;您將學會如何設置評論采集系統&#xff0c;分析用戶評論數據&#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…

數據賦能(142)——開發:數據合并——技術方法、主要工具

技術方法 數據合并的技術方法主要包括以下幾種&#xff1a; 軸向連接&#xff08;Concatenation&#xff09;&#xff1a; 使用pd.concat()函數&#xff0c;沿一個軸&#xff08;通常是行或列&#xff09;將多個DataFrame對象連接在一起&#xff0c;形成一個新的DataFrame對…

html自學筆記與面試會問到問題

第一章 1.1什么是JavaScript&#xff1f; 一各跨平臺的腳本語言1.2ECMA特點&#xff1a; 由三大部分組成&#xff1a;核心語法(關鍵字、核心對象、語法)、DOM、BOM1.3 取余運算&#xff08;又叫取模運算&#xff09;&#xff1a; 取余&#xff1a;整除后&#xff0c;除不盡的…

發那科機床聯網串口配置

本文章僅針對無網口&#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;都會被記錄得清…