openwrt 控制gpio口的方法

时间:2023-03-08 18:09:29

  利用i2c来控制gpio口

1、编译驱动或者安装驱动

# opkg update
# opkg install kmod-i2c-gpio-custom kmod-i2c-core
# 加载驱动
# insmod i2c-dev
# insmod i2c-gpio-custom bus0=,,
# dmesg | grep gpio
Mar :: openwrt kern.info kernel: [ 52.910000] Custom GPIO-based I2C driver version 0.1.
Mar :: openwrt kern.info kernel: [ 52.910000] i2c-gpio i2c-gpio.: using pins (SDA) and (SCL)

2、找到i2c文件

  驱动安装完成,成功加载驱动之后,查看是否存在i2c文件,

文件路径为:

/sys/class/i2c-dev/i2c-