【全志T113-S3_100ask】15-2 linux系统gpio模拟spi驱动屏幕——ILI9341

【全志T113-S3_100ask】15-2 linux系统gpio模拟spi驱动屏幕——ILI9341

背景

  • 在上一小节里,我们使用了硬件spi以及内核程序对spi屏幕进行了控制,刷屏的速度还是非常快的。
  • 既然stm32和esp32等单片机都能模拟spi进行驱动,那么强大的arm理论上也能通过gpio模拟spi进行控制,本小节将实现如何配置模拟spi。

(一)查阅参考文档

文档路径 :Documentation/devicetree/bindings/spi/spi-gpio.yaml

# SPDX-License-Identifier: GPL-2.0
%YAML 1.2
---
$id: http://devicetree.org/schemas/spi/spi-gpio.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: SPI-GPIO devicetree bindings

maintainers:
  - Rob Herring <robh@kernel.org>

description:
  This represents a group of 3-n GPIO lines used for bit-banged SPI on
  dedicated GPIO lines.

allOf:
  - $ref: "/schemas/spi/spi-controller.yaml#"

properties:
  compatible:
    const: spi-gpio

  sck-gpios:
    description: GPIO spec for the SCK line to use
    maxItems: 1

  miso-gpios:
    description: GPIO spec for the MISO line to use
    maxItems: 1

  mosi-gpios:
    description: GPIO spec for the MOSI line to use
    maxItems: 1

  cs-gpios:
    description: GPIOs to use for chipselect lines.
      Not needed if num-chipselects = <0>.
    minItems: 1
    maxItems: 1024

  num-chipselects:
    description: Number of chipselect lines. Should be <0> if a single device
      with no chip select is connected.
    $ref: "/schemas/types.yaml#/definitions/uint32"

  # Deprecated properties
  gpio-sck: false
  gpio-miso: false
  gpio-mosi: false

required:
  - compatible
  - num-chipselects
  - sck-gpios

examples:
  - |
    spi {
      compatible = "spi-gpio";
      #address-cells = <0x1>;
      #size-cells = <0x0>;

      sck-gpios = <&gpio 95 0>;
      miso-gpios = <&gpio 98 0>;
      mosi-gpios = <&gpio 97 0>;
      cs-gpios = <&gpio 125 0>;
      num-chipselects = <1>;

      /* clients */
    };

看起来还是挺简单的,只需要配置 compatible 和对应的 gpio。
但是要在内核勾选相应的模块。

(二)使能内核模块

1、在linux内核目录下,输入 make menuconfig 即可进入菜单页面
2、左斜杠 / 进入搜素 ,输入 spi_gpio ,然后回车
在这里插入图片描述
在这里插入图片描述
3、输入 1 选中它,然后勾选这两项
在这里插入图片描述
4、然后退出

(三)修改设备树

此时工作已经完成一半了,下面直接修改设备树即可使用。
参照那个文档,进行设备树的配置

  • 在根节点下:
aspi{
	compatible = "spi-gpio";
	#address-cells = <0x1>;
	#size-cells = <0x0>;

	sck-gpios = <&pio PE 8 0>;
	miso-gpios = <&pio PE 9 0>;
	mosi-gpios = <&pio PE 10 0>;
	cs-gpios = <&pio PE 11 0>;
	num-chipselects = <1>;

	status = "okay";
	/* 下面添加具体的spi设备*/
	
};

如下所示:
在这里插入图片描述

  • 在pio添加对应的gpio
aspi_pin: aspi_pin{
			allwinner,pins = "PE8","PE9","PE10","PE11"; 
		};

如下所示:
在这里插入图片描述
然后编译内核、buildroot、烧录balabala。。。

(四)测试

参照上一个文档的程序 fb-test-rect
感受:慢。
明显感觉到一帧帧地刷过去。
在这里插入图片描述

(五)后语

其实实现模拟spi不是为了刷屏,而是这个屏幕使用的是电阻屏,使用的是XPT2046芯片,需要使用spi通信,对于读取触摸屏位置来说,对速度的要求其实不高。但是这个板子没有多余的spi了,cs只有一个,只能暂时模拟spi使用了(如果把核心板的spi nand拆掉呢)

  • 5
    点赞
  • 16
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

第四维度4

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值