Set pinMode at start of setup to avert race condition, fixes #37

This commit is contained in:
Laura Hausmann 2023-02-14 02:24:57 +01:00
parent e5e8b5e215
commit ff400c18c9
Signed by: zotan
GPG key ID: D044E84C5BE01605

View file

@ -82,6 +82,13 @@ bool cooldownCheck(long timeout) {
void setup() {
Serial.begin(115200);
Serial2.begin(115200, SERIAL_8N1, PIN_HWSERIAL_RX, PIN_HWSERIAL_TX);
ledcSetup(0, 5000, 12);
pinMode(PIN_INTERRUPT_TRANSACT, INPUT_PULLUP);
pinMode(PIN_INTERRUPT_BALANCE, INPUT_PULLUP);
pinMode(PIN_INTERRUPT_CANCEL, INPUT_PULLUP);
pinMode(PIN_INTERRUPT_LINK, INPUT_PULLUP);
u8g2.begin();
drawLogo(u8g2, LOGO_MATECARD);
u8g2.sendBuffer();
@ -97,11 +104,6 @@ void setup() {
DateTime.begin();
updateOLED(u8g2, state);
ledcSetup(0, 5000, 12);
pinMode(PIN_INTERRUPT_TRANSACT, INPUT_PULLUP);
pinMode(PIN_INTERRUPT_BALANCE, INPUT_PULLUP);
pinMode(PIN_INTERRUPT_CANCEL, INPUT_PULLUP);
pinMode(PIN_INTERRUPT_LINK, INPUT_PULLUP);
attachInterrupt(PIN_INTERRUPT_TRANSACT, TransactInterruptHandler, FALLING);
attachInterrupt(PIN_INTERRUPT_BALANCE, BalanceInterruptHandler, FALLING);
attachInterrupt(PIN_INTERRUPT_CANCEL, CancelInterruptHandler, FALLING);