Skip to content

Commit c2b13eb

Browse files
committed
feat: nesso_n1: protect digital* calls from misuse
1 parent 0756741 commit c2b13eb

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

variants/arduino_nesso_n1/expander.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,18 @@ void pinMode(ExpanderPin pin, uint8_t mode) {
7070
}
7171

7272
void digitalWrite(ExpanderPin pin, uint8_t val) {
73+
if (!wireInitialized) {
74+
WireInternal.begin(SDA, SCL);
75+
wireInitialized = true;
76+
}
7377
writeBitRegister(pin.address, 0x5, pin.pin, val == HIGH);
7478
}
7579

7680
int digitalRead(ExpanderPin pin) {
81+
if (!wireInitialized) {
82+
WireInternal.begin(SDA, SCL);
83+
wireInitialized = true;
84+
}
7785
return readBitRegister(pin.address, 0xF, pin.pin);
7886
}
7987

0 commit comments

Comments
 (0)