Skip to content

Commit 6010af1

Browse files
committed
Wire: fix mux on SCI9
Channel indexes are 0 based, so channel number is bigger than max channel index
1 parent 41dd16d commit 6010af1

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

libraries/Wire/Wire.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ bool TwoWire::cfg_pins(int max_index) {
230230
ioport_peripheral_t ioport_scl;
231231

232232
if(IS_SCI(cfg_sda)) {
233-
if(channel >= TWOWIRE_MAX_SCI_CHANNELS) {
233+
if(channel >= TWOWIRE_MAX_SCI_CHANNELS) { // channels are 0 index based
234234
return false;
235235
}
236236
is_sci = true;
@@ -242,7 +242,7 @@ bool TwoWire::cfg_pins(int max_index) {
242242

243243
}
244244
else {
245-
if(channel >= TWOWIRE_MAX_I2C_CHANNELS) {
245+
if(channel >= TWOWIRE_MAX_I2C_CHANNELS) { // channels are 0 index based
246246
return false;
247247
}
248248
is_sci = false;

libraries/Wire/Wire.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ using I2C_onTxCallback_f = void (*)(void);
5858

5959
#define I2C_BUFFER_LENGTH 256
6060

61-
#define TWOWIRE_MAX_I2C_CHANNELS 2
62-
#define TWOWIRE_MAX_SCI_CHANNELS 9
61+
#define TWOWIRE_MAX_I2C_CHANNELS (3) // IIC0 to IIC2
62+
#define TWOWIRE_MAX_SCI_CHANNELS (10) // SCI0 to SCI9
6363

6464
#ifdef __cplusplus
6565

0 commit comments

Comments
 (0)