基于rk3568解决gpio阶梯波形(适用于i2c、uart、电平转换)

32 篇文章 4 订阅
13 篇文章 4 订阅

1、理解GPIO的开漏(OD)和开集(OC)

参考链接:GPIO口有关上拉电阻和下拉电阻&推挽输出&开漏(OD)和开集(OC)

实测中遇到的是i2c问题,但是uart或者电平转换芯片都会遇到,首先保证外部是否有1k电阻的上拉,当然具体的电阻可以自行进行调节,其次需要满足开漏模式的输出(OD)。

2、查询io寄存器地址定义

根据原理图的地址,查询rk3568的手册得到gpio的OD配置及地址,

主要是为了后续能够进行io操作指令对具体gpio的寄存器值进行改写测试

31:16位电平要求与150一致才能使能生效

GRF_GPIO4B_OPD

Address: Operational Base + offset (0x0134) 

根据当前参数章节隶属于3.7SYS_GRF 找到基地址

3.7 SYS_GRF Register Description

3.7.1 Registers Summary 

基地址SYS_GRF  0xFDC60000

0xFDC60000 + 0x0134 = 0xFDC60134 

3、配置可调寄存器接口dev/mem

makefile

kernel/drivers/char/Makefile

obj-$(CONFIG_DEVMEM)           += mem.o

config

kernel/arch/arm64/configs/rockchip_defconfig

CONFIG_DEVMEM=y

CONFIG_STRICT_DEVMEM=n

CONFIG_ARCH_HAS_DEVMEM_IS_ALLOWED=n

单独编译boot.img

  1. uboot编译

$ cd u-boot

$ ./make.sh rk3568

  1. kernel编译(单编 boot.img 同步骤)

$ cd ..

$ cd kernel 

$ make ARCH=arm64  rockchip_evb3568_v2b_defconfig

$ ./mk_kernel.sh ido-evb3568-v2b-dsi0-mipi.img

1|rk3568_r:/ # ls -l /dev/mem
crw------- 1 media media 1,   1 2023-12-01 21:13 /dev/mem
1|rk3568_r:/ # io
Raw memory i/o utility - $Revision: 1.5 $

io -v -1|2|4 -r|[-l <len>] [-f <file>] <addr> [<value>]

    -v         Verbose, asks for confirmation
    -1|2|4     Sets memory access size in bytes (default byte)
    -l <len>   Length in bytes of area to access (defaults to
               one access, or whole file length)
    -r|w       Read from or Write to memory (default read)
    -f <file>  File to write on memory read, or
               to read on memory write
    <addr>     The memory address to access
    <val>      The value to write (implies -w)

Examples:
    io 0x1000                  Reads one byte from 0x1000
    io 0x1000 0x12             Writes 0x12 to location 0x1000
    io -2 -l 8 0x1000          Reads 8 words from 0x1000
    io -r -f dmp -l 100 200    Reads 100 bytes from addr 200 to file
    io -w -f img 0x10000       Writes the whole of file to memory

Note access size (-1|2|4) does not apply to file based accesses.

1|rk3568_r:/ # io -4 -l 0x30 0xFDC60000
open /dev/mem: No such file or directory
rk3568_r:/ # io -4 -w 0xFDC60134 0x040004
rk3568_r:/ # io -4 -r 0xFDC60134
 #0x040004

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值