You can open as many I2C bus references as you’d like. There won’t be any issues. It’s common to call Circuits.I2C.open/2
for each I2C device that you’re using from Elixir. What you’re describing with two GenServers is the normal way, and that’s how most Elixir libraries that use I2C are written.
Trying to pass around I2C bus references to reduce calls to Circuits.I2C.open/2
is unnecessary. I probably would only do that if it were really convenient.
The Linux kernel ensures that each read and write completes before the next transfer starts. The low level I2C hardware controller can only issue one at a time anyway.
Yes, there’s a file handle behind each I2C bus reference.