您尚未登录。

楼主 # 2025-07-23 15:45:00

林34
会员
注册时间: 2025-06-06
已发帖子: 7
积分: 7

v3s怎么实现模拟i2c---荔枝派

v3s怎么实现模拟i2c,使用linux-5.2-y内核,勾选了 <*> GPIO-based bitbanging I2C           
设备树怎么写?

离线

楼主 #2 2025-07-29 12:50:19

林34
会员
注册时间: 2025-06-06
已发帖子: 7
积分: 7

Re: v3s怎么实现模拟i2c---荔枝派

海石生风 说:

源码目录的文档:Documentation/devicetree/bindings/i2c/i2c-gpio.yaml
或在线内核文档:https://www.kernel.org/doc/Documentation/devicetree/bindings/i2c/i2c-gpio.txt

sun8i-v3s.dtsi:516-523
        i2c3_gpio: i2c3_gpio{
            sda-gpios = <&pioC 2 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>;
            scl-gpios = <&pioC 3 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>;
            i2c-gpio,delay-us = <2>;  //100khz
            #address-cells = <1>;
            #size-cells = <0>;
            status = "okay";
        };

我这样配置设备树之后:make dtbs
DTC     arch/arm/boot/dts/sun8i-v3s-licheepi-zero.dtb
Error: arch/arm/boot/dts/sun8i-v3s.dtsi:517.26-27 syntax error
FATAL ERROR: Unable to parse input tree
make[2]: *** [arch/arm/boot/dts/sun8i-v3s-licheepi-zero.dtb] 错误 1
make[1]: *** [dtbs] 错误 2
编译显示sda-gpios = <&pioC 2 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>;这行配置有错

make: *** [sub-make] 错误 2

离线

楼主 #4 2025-07-30 11:25:52

林34
会员
注册时间: 2025-06-06
已发帖子: 7
积分: 7

Re: v3s怎么实现模拟i2c---荔枝派

@海石生风
修改后:
i2c_gpio0: i2c-gpio-0 {
            compatible = "i2c-gpio";
            sda-gpios = <&pio 2 2 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>;
            scl-gpios = <&pio 2 3 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>;
            i2c-gpio,delay-us = <5>;  //100khz
            #address-cells = <1>;
            #size-cells = <0>;
            status = "okay";
        };
在板子上运行查看日志:
root@licheepiw:/#: dmesg | grep i2c
[    0.036596] i2c-gpio soc:i2c-gpio-0: error trying to get descriptor: -2
[    1.110930] i2c /dev entries driver
[    1.274979] i2c-gpio soc:i2c-gpio-0: using lines 66 (SDA) and 67 (SCL)
设备下也出现了该i2c
root@licheepiw:/#: ls /dev/i
i2c-0   i2c-1   input/
使用i2cdetect -y 1命令查看总线上的设备,发现相较于硬件i2c读取的很慢,(不是设置了100khz了吗)
查看日志发现的错误:
    i2c-gpio soc:i2c-gpio-0: error trying to get descriptor: -2
是i2c-gpio-0没定义吗,要咋定义呀

离线

楼主 #8 2025-07-30 14:07:34

林34
会员
注册时间: 2025-06-06
已发帖子: 7
积分: 7

Re: v3s怎么实现模拟i2c---荔枝派

使用硬件的i2c,挂载设备后,偶尔会出现i2c i2c-0: mv64xxx: I2C bus locked, block: 1, time_left: 0导致控制设备失败,所以才想使用模拟i2c。

离线

楼主 #9 2025-07-30 14:07:50

林34
会员
注册时间: 2025-06-06
已发帖子: 7
积分: 7

Re: v3s怎么实现模拟i2c---荔枝派

qxxz 说:
林34 说:

v3s怎么实现模拟i2c,使用linux-5.2-y内核,勾选了 <*> GPIO-based bitbanging I2C           
设备树怎么写?

有没有大佬分享一下

上面有完整的了

离线

楼主 #11 2025-07-31 22:10:34

林34
会员
注册时间: 2025-06-06
已发帖子: 7
积分: 7

Re: v3s怎么实现模拟i2c---荔枝派

@海石生风
暂时告一段落 谢谢大佬

离线

页脚

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

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