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

Use Serial1 without including "Adafruit_TinyUSB.h" #734

Open
arms22 opened this issue Jun 13, 2022 · 2 comments
Open

Use Serial1 without including "Adafruit_TinyUSB.h" #734

arms22 opened this issue Jun 13, 2022 · 2 comments
Labels

Comments

@arms22
Copy link

arms22 commented Jun 13, 2022

Is your feature request related to a problem? Please describe.

the following code causes undefined reference to 'Adafruit_USBD_CDC::available()' when targeting the nRF52840 boards.
I understand that the header "Adafruit_TinyUSB.h" needs to be included, but I don't want to include it for power saving.

void setup() {
  Serial1.begin(115200);
}

void loop() {
}

This is because serialEventRun refers to Serial.

if (serialEvent && Serial.available() ) serialEvent();

How about changing the call to Serial.available to a call to the weak symbol?

int Serial_available() __attribute__((weak));

void serialEventRun(void)
{
  if (serialEvent && Serial_available() ) serialEvent();
}
@arms22 arms22 added the Feature label Jun 13, 2022
@hathach
Copy link
Member

hathach commented Jun 14, 2022

I think it is better to add the #if defined(USE_TINYUSB) && defined(NRF52840) for the Serial, if you make an PR. I will be happy to review/merge.

Update: USE_TINYUSB seems to always defined for nrf52840, i will check this out later. If you could, please make an PR for your suggestion that will make it quicker to adopt the changes.

@arms22
Copy link
Author

arms22 commented Jun 17, 2022

I just compiled it.
I will make PR after the test.
arms22@1f4f503

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants