Skip to content

Commit ef4ec41

Browse files
authored
Add dummy Serial implementation when NO_USB defined (#1438)
Fixes #1434
1 parent 3dee0a2 commit ef4ec41

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

cores/rp2040/RP2040USB.cpp

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,59 @@ usbd_class_driver_t const *usbd_app_driver_get_cb(uint8_t *driver_count) {
550550
*driver_count = 1;
551551
return &_resetd_driver;
552552
}
553+
554+
#elif defined NO_USB
555+
556+
// will ensure backward compatibility with existing code when using pico-debug
557+
558+
#warning "NO_USB selected. No output to Serial will occur!"
559+
560+
#include <Arduino.h>
561+
562+
void SerialUSB::begin(unsigned long baud) {
563+
}
564+
565+
void SerialUSB::end() {
566+
567+
}
568+
569+
int SerialUSB::peek() {
570+
return 0;
571+
}
572+
573+
int SerialUSB::read() {
574+
return -1;
575+
}
576+
577+
int SerialUSB::available() {
578+
return 0;
579+
}
580+
581+
int SerialUSB::availableForWrite() {
582+
return 0;
583+
}
584+
585+
void SerialUSB::flush() {
586+
587+
}
588+
589+
size_t SerialUSB::write(uint8_t c) {
590+
(void) c;
591+
return 0;
592+
}
593+
594+
size_t SerialUSB::write(const uint8_t *buf, size_t length) {
595+
(void) buf;
596+
(void) length;
597+
return 0;
598+
}
599+
600+
SerialUSB::operator bool() {
601+
return false;
602+
}
603+
604+
SerialUSB Serial;
605+
553606
#endif
554607

555608

0 commit comments

Comments
 (0)