adafruit / adafruit/Adafruit_nRF52_Arduino
Use Serial1 without including "Adafruit_TinyUSB.h"
- Dominant language
- C
- Stars
- 699
- Forks
- 570
- PR merge metrics
- No merged PRs in 30d
Description
**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.
https://github.com/adafruit/Adafruit_nRF52_Arduino/blob/d75bb2a8524e7f00f725eb2ab27a8996be65e7a3/cores/nRF5/Uart.cpp#L27
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();
}
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in cores/nRF5/Uart.cpp at the serialEventRun reference linked in the issue, then reproduce the sketch on an nRF52840 target without including Adafruit_TinyUSB.h. Compare the Serial1-only build with the proposed weak-symbol behavior; done means it builds without the undefined reference while preserving serialEvent handling.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- embedded-iot
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100