简体   繁体   English

访问多个I2C设备

[英]Accessing multiple I2C devices

I have multiple I2C devices on my bus and want to access (read or write) them one by one. 我的总线上有多个I2C设备,并且想要一个一个地访问(读取或写入)它们。 What is the correct way? 正确的方法是什么?

  • open() -> set slave address -> write() -> close() -> open() -> set next slave address -> ... open()->设置从站地址-> write()-> close()-> open()->设置下一个从站地址-> ...
  • open() -> set slave address -> write -> set next slave address -> write ... open()->设置从站地址->写->设置下一个从站地址->写...

Open and close the bus for each device or keep the bus open and only change the device address for each device? 打开和关闭每个设备的总线,还是保持总线打开,仅更改每个设备的设备地址?

I believe, there is no point in closing and re-opening the bus driver node for each access. 我相信,为每次访问关闭和重新打开总线驱动程序节点没有任何意义。 Use the second strategy. 使用第二种策略。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM