Przeglądaj źródła

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

teensy4-core
PaulStoffregen 7 lat temu
rodzic
commit
fb5b81d75f
1 zmienionych plików z 7 dodań i 1 usunięć
  1. +7
    -1
      teensy3/usb_serial.h

+ 7
- 1
teensy3/usb_serial.h Wyświetl plik

class usb_serial_class : public Stream class usb_serial_class : public Stream
{ {
public: 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 */ }; void end() { /* TODO: flush output and shut down USB port */ };
virtual int available() { return usb_serial_available(); } virtual int available() { return usb_serial_available(); }
virtual int read() { return usb_serial_getchar(); } virtual int read() { return usb_serial_getchar(); }

Ładowanie…
Anuluj
Zapisz