Skip to content

Commit

Permalink
Add dummy Serial implementation when NO_USB defined (#1438)
Browse files Browse the repository at this point in the history
Fixes #1434
  • Loading branch information
git2212 authored May 11, 2023
1 parent 3dee0a2 commit ef4ec41
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions cores/rp2040/RP2040USB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,59 @@ usbd_class_driver_t const *usbd_app_driver_get_cb(uint8_t *driver_count) {
*driver_count = 1;
return &_resetd_driver;
}

#elif defined NO_USB

// will ensure backward compatibility with existing code when using pico-debug

#warning "NO_USB selected. No output to Serial will occur!"

#include <Arduino.h>

void SerialUSB::begin(unsigned long baud) {
}

void SerialUSB::end() {

}

int SerialUSB::peek() {
return 0;
}

int SerialUSB::read() {
return -1;
}

int SerialUSB::available() {
return 0;
}

int SerialUSB::availableForWrite() {
return 0;
}

void SerialUSB::flush() {

}

size_t SerialUSB::write(uint8_t c) {
(void) c;
return 0;
}

size_t SerialUSB::write(const uint8_t *buf, size_t length) {
(void) buf;
(void) length;
return 0;
}

SerialUSB::operator bool() {
return false;
}

SerialUSB Serial;

#endif


Expand Down

0 comments on commit ef4ec41

Please sign in to comment.