您尚未登录。

楼主 # 2021-09-05 19:14:40

tlxfif
会员
注册时间: 2021-07-23
已发帖子: 36
积分: 18

[求助]我好像进入了一个大坑,不会编写spi屏幕驱动

由于我看中了一款小屏幕
希望把他移植到我的nano上面来

其实目前我也只是自己刚编译好系统能进入linux而已
可是这款屏幕的芯片是gc9a01
fbtft里面没有提供对应的驱动
我也不知道如何编写
只是照着stm32代码写了init_display函数

我实在是不知道fbtft_display里面的set_var咋写了
准确的说,我其实啥都不知道,请问下我现在应该怎么用最简单的方式驱动这个屏幕呢?

离线

楼主 #1 2021-09-05 19:17:35

tlxfif
会员
注册时间: 2021-07-23
已发帖子: 36
积分: 18

Re: [求助]我好像进入了一个大坑,不会编写spi屏幕驱动

这是stm32的代码

	LCD_WR_REG(0xEF);
	LCD_WR_REG(0xEB);
	LCD_WR_DATA8(0x14); 

这是我弄成fbtft init_display 里面的代码

    write_reg(par,0xEF);
    write_reg(par,0xEB,0x14);

不知道对不对

离线

楼主 #3 2021-09-05 20:27:07

tlxfif
会员
注册时间: 2021-07-23
已发帖子: 36
积分: 18

Re: [求助]我好像进入了一个大坑,不会编写spi屏幕驱动

cube 说:

我现在已经改成这样了,然后怎么开始测试呢?

#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/delay.h>
#include <video/mipi_display.h>

#include "fbtft.h"

#define DRVNAME "fb_gc9a01"
#define WIDTH		240
#define HEIGHT		240

#define ORIENTATION 2   // Set the display orientation 0,1,2,3

// Command codes:
#define COL_ADDR_SET        0x2A
#define ROW_ADDR_SET        0x2B
#define MEM_WR              0x2C
#define COLOR_MODE          0x3A
#define COLOR_MODE__12_BIT  0x03
#define COLOR_MODE__16_BIT  0x05
#define COLOR_MODE__18_BIT  0x06
#define MEM_WR_CONT         0x3C




static int init_display(struct fbtft_par *par)
{
    par->fbtftops.reset(par);
    write_reg(par,0xEF);
    write_reg(par,0xEB,0x14);

    write_reg(par,0xEF);
    write_reg(par,0xEF);

    write_reg(par,0xEB,0x14);

    write_reg(par,0x84,0x40);

    write_reg(par,0x85,0xFF);

    write_reg(par,0x86,0xFF);

    write_reg(par,0x87,0xFF);

    write_reg(par,0x88,0x0A);

    write_reg(par,0x89,0x21);

    write_reg(par,0x8A,0x00);

    write_reg(par,0x8B,0x80);

    write_reg(par,0x8C,0x01);

    write_reg(par,0x8D,0x01);

    write_reg(par,0x8E,0xFF);

    write_reg(par,0x8F,0xFF);

    write_reg(par,0xB6,0x00,0x20); // used 0x00

    write_reg(par,0x36);
#if ORIENTATION == 0
    write_reg(par,0x18);
#elif ORIENTATION == 1
    write_reg(par,0x28);
#elif ORIENTATION == 2
    write_reg(par,0x08); //0x48
#else
    write_reg(par,0x88);
#endif

    write_reg(par,COLOR_MODE,COLOR_MODE__18_BIT);

    write_reg(par,0x90,0x08,0x08,0x08,0x08);

    write_reg(par,0xBD,0x06);

    write_reg(par,0xBC,0x00);

    write_reg(par,0xFF,0x60,0x01,0x04);

    write_reg(par,0xC3,0x13);

    write_reg(par,0xC4,0x13);

    write_reg(par,0xC9,0x22);

    write_reg(par,0xBE,0x11);

    write_reg(par,0xE1,0x10,0x0E);

    write_reg(par,0xDF,0x21,0x0c,0x02);

    write_reg(par,0xF0,0x45,0x09,0x08,0x08,0x26,0x2A);

    write_reg(par,0xF1,0x43,0x70,0x72,0x36,0x37,0x6F);

    write_reg(par,0xF2,0x45,0x09,0x08,0x08,0x26,0x2A);

    write_reg(par,0xF3,0x43,0x70,0x72,0x36,0x37,0x6F);

    write_reg(par,0xED,0x1B,0x0B);

    write_reg(par,0xAE,0x77);

    write_reg(par,0xCD,0x63);

    write_reg(par,0x70,0x07,0x07,0x04,0x0E,0x0F,0x09,0x07,0x08,0x03);

    write_reg(par,0xE8,0x34);

    write_reg(par,0x62,0x18,0x0D,0x71,0xED,0x70,0x70,0x18,0x0F,0x71,0xEF,0x70,0x70);

    write_reg(par,0x63,0x18,0x11,0x71,0xF1,0x70,0x70,0x18,0x13,0x71,0xF3,0x70,0x70);

    write_reg(par,0x64,0x28,0x29,0xF1,0x01,0xF1,0x00,0x07);

    write_reg(par,0x66,0x3C,0x00,0xCD,0x67,0x45,0x45,0x10,0x00,0x00,0x00);

    write_reg(par,0x67,0x00,0x3C,0x00,0x00,0x00,0x01,0x54,0x10,0x32,0x98);

    write_reg(par,0x74,0x10,0x85,0x80,0x00,0x00,0x4E,0x00);

    write_reg(par,0x98,0x3e,0x07);

    write_reg(par,0x35,0x21);

    write_reg(par,0x11);
    mdelay(120);
    write_reg(par,0x29);
    mdelay(20);
    return 0;
}


static void set_addr_win(struct fbtft_par *par, int xs, int ys, int xe, int ye)
{
    write_reg(par, MIPI_DCS_SET_COLUMN_ADDRESS,
              xs >> 8, xs & 0xff, xe >> 8, xe & 0xff);

    write_reg(par, MIPI_DCS_SET_PAGE_ADDRESS,
              ys >> 8, ys & 0xff, ye >> 8, ye & 0xff);

    write_reg(par, MIPI_DCS_WRITE_MEMORY_START);
}

static int set_var(struct fbtft_par *par)
{
    switch (par->info->var.rotate) {
        case 0:
            write_reg(par, MIPI_DCS_SET_ADDRESS_MODE,
                      0x80 | (par->bgr << 3));
            break;
        case 90:
            write_reg(par, MIPI_DCS_SET_ADDRESS_MODE,
                      0x20 | (par->bgr << 3));
            break;
        case 180:
            write_reg(par, MIPI_DCS_SET_ADDRESS_MODE,
                      0x40 | (par->bgr << 3));
            break;
        case 270:
            write_reg(par, MIPI_DCS_SET_ADDRESS_MODE,
                      0xE0 | (par->bgr << 3));
            break;
        default:
            break;
    }

    return 0;
}

static struct fbtft_display display = {
        .regwidth = 8,
        .width = WIDTH,
        .height = HEIGHT,
        .fbtftops = {
                .init_display = init_display,
                .set_addr_win = set_addr_win,
                .set_var = set_var,
        },
};


FBTFT_REGISTER_DRIVER(DRVNAME, "gc9a01", &display);

MODULE_ALIAS("spi:" DRVNAME);
MODULE_ALIAS("platform:" DRVNAME);
MODULE_ALIAS("spi:gc9a01");
MODULE_ALIAS("platform:gc9a01");

MODULE_DESCRIPTION("FB driver for the GC9A01 LCD Controller");
MODULE_AUTHOR("tlxfif");
MODULE_LICENSE("GPL");

离线

楼主 #5 2021-09-05 20:43:15

tlxfif
会员
注册时间: 2021-07-23
已发帖子: 36
积分: 18

Re: [求助]我好像进入了一个大坑,不会编写spi屏幕驱动

哇酷小二 说:

荔枝派Zero V3s开发板驱动 ili9341 摆拍
https://whycan.com/t_576.html

linux5.2内核,配置SPI屏幕(ili9341)步骤
https://whycan.com/t_6412.html


https://cn.bing.com/search?q=ili9341%20site:whycan.com


多谢,请问下这里怎么填写呢?

 reset-gpios = <&pio 【1】 【2】 GPIO_ACTIVE_LOW>;

我不太清楚硬件上写的E3/E4/E5对应的数字是多少

离线

楼主 #7 2021-09-05 21:37:29

tlxfif
会员
注册时间: 2021-07-23
已发帖子: 36
积分: 18

Re: [求助]我好像进入了一个大坑,不会编写spi屏幕驱动

哇酷小二 说:

那个是复位脚定义,
前面那个数字代表 A B C ..
后面数字代表引脚号

PE3

那应该是

4 3


好滴,多谢多谢

离线

页脚

工信部备案:粤ICP备20025096号 Powered by FluxBB

感谢为中文互联网持续输出优质内容的各位老铁们。 QQ: 516333132, 微信(wechat): whycan_cn (哇酷网/挖坑网/填坑网) service@whycan.cn