Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update RP2040USB.cpp included hollow Serial for backward compatibility #1438

Merged
merged 1 commit into from
May 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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