Skip to content

Commit 5dd2adc

Browse files
committed
USBD: Rewritten RX/TX LED conditions in a slighlty more clear way
1 parent 0605c11 commit 5dd2adc

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

cores/arduino/USB/USBCore.cpp

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,9 @@ uint32_t USBDeviceClass::send(uint32_t ep, const void *data, uint32_t len)
610610
return -1;
611611

612612
#ifdef PIN_LED_TXL
613-
digitalWrite(PIN_LED_TXL, LOW);
613+
if (txLEDPulse == 0)
614+
digitalWrite(PIN_LED_TXL, LOW);
615+
614616
txLEDPulse = TX_RX_LED_PULSE_MS;
615617
#endif
616618

@@ -824,13 +826,19 @@ void USBDeviceClass::ISRHandler()
824826

825827
// check whether the one-shot period has elapsed. if so, turn off the LED
826828
#ifdef PIN_LED_TXL
827-
if (txLEDPulse && !(--txLEDPulse))
828-
digitalWrite(PIN_LED_TXL, HIGH);
829+
if (txLEDPulse > 0) {
830+
txLEDPulse--;
831+
if (txLEDPulse == 0)
832+
digitalWrite(PIN_LED_TXL, HIGH);
833+
}
829834
#endif
830835

831836
#ifdef PIN_LED_RXL
832-
if (rxLEDPulse && !(--rxLEDPulse))
833-
digitalWrite(PIN_LED_RXL, HIGH);
837+
if (rxLEDPulse > 0) {
838+
rxLEDPulse--;
839+
if (rxLEDPulse == 0)
840+
digitalWrite(PIN_LED_RXL, HIGH);
841+
}
834842
#endif
835843
}
836844

0 commit comments

Comments
 (0)