1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2024-11-22 15:46:14 +01:00

Update I2CManager_Wire.h

Add alternative multiplexer support for I2C Wire subsystem.
This commit is contained in:
Neil McKechnie 2023-02-25 11:43:36 +00:00
parent 8c8a913678
commit f56f5d9ebe

View File

@ -77,7 +77,15 @@ static uint8_t muxSelect(I2CAddress address) {
Wire.beginTransmission(I2C_MUX_BASE_ADDRESS+muxNo); Wire.beginTransmission(I2C_MUX_BASE_ADDRESS+muxNo);
uint8_t data = (subBus == SubBus_All) ? 0xff : uint8_t data = (subBus == SubBus_All) ? 0xff :
(subBus == SubBus_None) ? 0x00 : (subBus == SubBus_None) ? 0x00 :
(1 << subBus); #if defined(I2CMUX_PCA9547)
0x08 | subBus;
#elif defined(I2CMUX_PCA9542) || defined(I2CMUX_PCA9544)
0x04 | subBus; // NB Only 2 or 4 subbuses respectively
#else
// Default behaviour for most MUXs is to use a mask
// with a bit set for the subBus to be enabled
1 << subBus;
#endif
Wire.write(&data, 1); Wire.write(&data, 1);
return Wire.endTransmission(true); // have to release I2C bus for it to work return Wire.endTransmission(true); // have to release I2C bus for it to work
} }