• Recent
    • Docs
    • Github
    • 百度网盘
    • Onedrive
    • Official
    • Shop
    • Register
    • Login

    CoolPi 4B硬件扩展三:I2C

    Scheduled Pinned Locked Moved Hardware
    1 Posts 1 Posters 366 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • G
      george
      last edited by george

      如下表所示,coolpi 4b的40PIN连接器可以引出4组I2C总线出来,其中I2C1 I2C3 I2C5是独立I2C接口,机器内部没有和其它设备复用,I2C6板子内部有接RTC时钟芯片HYM8563,地址为51H,所以外设使用I2C6端口的时候注意地址不要冲突。

      I2C位置

      序号 端口定义 描述 IO状态
      3 I2C1_SDA_M2 I2C1数据 Internal 2.2K Pull up 3.3V
      5 I2C1_SCL_M2 I2C1时钟 Internal 2.2K Pull up 3.3V
      27 I2C6_SDA_M3 I2C6数据 Internal 2.2K Pull up 3.3V
      28 I2C6_SCL_M3 I2C6时钟 Internal 2.2K Pull up 3.3V
      31 I2C3_SCL_M2 I2C3时钟 Internal 2.2K Pull up 3.3V
      33 I2C3_SDA_M2 I2C3数据 Internal 2.2K Pull up 3.3V
      35 I2C5_SCL_M2 I2C5时钟 Internal 2.2K Pull up 3.3V
      37 I2C5_SDA_M2 I2C5数据 Internal 2.2K Pull up 3.3V

      DTS配置

      设备驱动的配置方式参考I2C6节点,注意不使用I2C功能确保节点的status为disabled,否则可能会导致其它功能异常。

      &i2c1 {
      	status = "okay";
      	pinctrl-names = "default";
      	pinctrl-0 = <&i2c1m2_xfer>;
      };
      
      &i2c3 {
      	status = "okay";
      	pinctrl-names = "default";
      	pinctrl-0 = <&i2c3m2_xfer>;
      };
      
      &i2c5 {
      	status = "okay";
      	pinctrl-names = "default";
      	pinctrl-0 = <&i2c5m2_xfer>;
      };
      
      &i2c6 {
      	status = "okay";
      	pinctrl-names = "default";
      	pinctrl-0 = <&i2c6m3_xfer>;
      
      	hym8563: hym8563@51 {
      		compatible = "haoyu,hym8563";
      		reg = <0x51>;
      		#clock-cells = <0>;
      		clock-frequency = <32768>;
      		clock-output-names = "hym8563";
      		pinctrl-names = "default";
      		pinctrl-0 = <&hym8563_int>;
      		interrupt-parent = <&gpio0>;
      		interrupts = <RK_PB0 IRQ_TYPE_LEVEL_LOW>;
      		status = "okay";
      	};
      
      };
      

      测试工具及方法

      git clone git://git.kernel.org/pub/scm/utils/i2c-tools/i2c-tools.git
      cd i2c-tools
      make -j8
      sudo make install
      root@ubuntu:/# i2cdetect -y 6
           0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
      00:                         -- -- -- -- -- -- -- -- 
      10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
      20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
      30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
      40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
      50: -- UU -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
      60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
      70: -- -- -- -- -- -- -- --
      I2C6节点上可以扫描到地址为51H的设备,即HYM8563。工具也支持其他读写操作。可以自行研究。
      
      1 Reply Last reply Reply Quote 1
      • 1 / 1
      • First post
        Last post