RV1103外设I2C与FPGA通信调试
介绍RV1103与FPGA通过I2C通信调试过程。FPGA厂家为易灵思。
一、RV1103的DTS设置
本次使用RV1103的I2C4。在DTS中进行设置。地址位0x0a。
&i2c4 {
status = “okay”;
clock-frequency = ;
pinctrl-names = “default”;
pinctrl-0 = ;
elinx@0a {
status = “okay”;
compatible = “elinx,fpga_t13”;
reg = ;
};
};
二、RV1103编译
运行后,查询系统上存在的I2C总线。
# ls /sys/bus/i2c/devices/
4-0030 i2c-44-000a i2c-3
#
三、FPGA代码设计,FPGA的I2C作为Slave端
FPGA端I2C地址设置位0x0a。正常后下载FPGA进行联调。调用FPGA内部IP。
四、FPGA与RV1103联调
# i2cdetect -a -y 4
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: — — — — — — — — — — 0a — — — — —
10: — — — — — — — — — — — — — — — —
20: — — — — — — — — — — — — — — — —
30: — — — — — — — — — — — — — — — —
40: — — — — — — — — — — — — — — — —
50: — — — — — — — — — — — — — — — —
60: — — — — — — — — — — — — — — — —
70: — — — — — — — — — — — — — — — —
#
发现0X0a端的FPGA。
五、RV1103读FPGA操作
# i2cget -f -y 4 0x0a 0x00
0xff
读地址0x00,数据为0xff。
FPGA在线捕获I2C波形,如下图。
# i2cget -f -y 4 0x0a 0x01
0xff
读地址0x01,数据为0xff。
FPGA在线捕获I2C波形,如下图。
i2cget -f -y 4 0x0a 0x05
0xff
#
读地址0x05,数据为0xff。
FPGA在线捕获I2C波形,如下图。
# i2cdump -f -y 4 0x0a
0 1 2 3 4 5 6 7 8 9 a b c d e f0123456789abcdef
00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00…………….
10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00…………….
20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00…………….
30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00…………….
40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00…………….
50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00…………….
60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00…………….
70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00…………….
80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00…………….
90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00…………….
a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00…………….
b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00…………….
c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00…………….
d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00…………….
e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00…………….
f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00…………….
#
从地址0x00开始dump。
六、RV1103先通过I2C写进FPGA,之后再读
# i2cset -f -y 4 0x0a 0x00 0x55
#
地址0x00,写数据为0x55。
# i2cget -f -y 4 0x0a 0x00
0x55
之后读地址0x00,数据为0x55。
#
# i2cset -f -y 4 0x0a 0x01 0xAA
#
#
#
# i2cget -f -y 4 0x0a 0x01
0xaa
#
读写正常。
# i2cset -f -y 4 0x0a 0x02 0x5A
# i2cget -f -y 4 0x0a 0x02
0x5a
#
读写正常。
# i2cset -f -y 4 0x0a 0x03 0xA5
# i2cget -f -y 4 0x0a 0x03
0xa5
#
读写正常。
# i2cdump -f -y 4 0x0a
0 1 2 3 4 5 6 7 8 9 a b c d e f0123456789abcdef
00: 55 aa 5a a5 00 00 00 00 00 00 00 00 00 00 00 00U” />六、验证完成,读写功能正常
欢迎讨论交流,微:moning_hello