Bladeren bron

Serial.begin() to wait up to 1 second for Arduino Serial Monitor

teensy4-core
PaulStoffregen 7 jaren geleden
bovenliggende
commit
fb5b81d75f
1 gewijzigde bestanden met toevoegingen van 7 en 1 verwijderingen
  1. +7
    -1
      teensy3/usb_serial.h

+ 7
- 1
teensy3/usb_serial.h Bestand weergeven

@@ -71,7 +71,13 @@ extern volatile uint8_t usb_configuration;
class usb_serial_class : public Stream
{
public:
void begin(long) { /* TODO: call a function that tries to wait for enumeration */ };
void begin(long) {
uint32_t millis_begin = systick_millis_count;
while (!(*this)) {
// wait up to 1 second for Arduino Serial Monitor
if ((uint32_t)(systick_millis_count - millis_begin) > 1000) break;
}
}
void end() { /* TODO: flush output and shut down USB port */ };
virtual int available() { return usb_serial_available(); }
virtual int read() { return usb_serial_getchar(); }

Laden…
Annuleren
Opslaan