利用i2c来控制gpio口
1、编译驱动或者安装驱动
# opkg update # opkg install kmod-i2c-gpio-custom kmod-i2c-core
# 加载驱动 # insmod i2c-dev # insmod i2c-gpio-custom bus0=0,18,22 # dmesg | grep gpio Mar 23 09:01:23 openwrt kern.info kernel: [ 52.910000] Custom GPIO-based I2C driver version 0.1.1 Mar 23 09:01:23 openwrt kern.info kernel: [ 52.910000] i2c-gpio i2c-gpio.0: using pins 7 (SDA) and 29 (SCL)
2、找到i2c文件
驱动安装完成,成功加载驱动之后,查看是否存在i2c文件,
文件路径为:
/sys/class/i2c-dev/i2c-0