The tca9548a is an i2c multiplexer but currently needs to have i2c.enable/disable_port (and the other APIs) functions called directly to change the i2c ports available. Drivers that only accept i2c drivers to work cannot also take tca9548a driver to control their own i2c. Thus, the tca9548a should be capable of returning an i2c driver that automatically changes the mux's enabled ports before performing an i2c transaction.
auto tca = mem::make_strong_ptr<tca9548a>(allocator, /* ... */);
auto i2c_first_half = tca.acquire_i2c(allocator, 0b00001111);
auto i2c_second_half = tca.acquire_i2c(allocator, 0b11110000);
// ❌ Below would throw would fail as the 0th port is already in use
auto i2c_first_port = tca.acquire_i2c(allocator, 0b00000001);
// Now pass the i2c halves into whichever drivers need them.
The acquire_i2c would accept a bitset as its 2nd parameter.
The tca9548a is an i2c multiplexer but currently needs to have
i2c.enable/disable_port(and the other APIs) functions called directly to change the i2c ports available. Drivers that only accept i2c drivers to work cannot also taketca9548adriver to control their own i2c. Thus, the tca9548a should be capable of returning an i2c driver that automatically changes the mux's enabled ports before performing an i2c transaction.The
acquire_i2cwould accept a bitset as its 2nd parameter.