-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Serial as a #define #8798
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
Serial as a #define #8798
Changes from 4 commits
fa6fb2f
80f050f
cff748c
700ed96
b5beaf3
ecbc5ca
ee7cf12
6e4d4e5
4204144
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -113,11 +113,8 @@ void serialEvent2(void) {} | |
#endif /* SOC_UART_NUM > 2 */ | ||
|
||
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_SERIAL) | ||
#if ARDUINO_USB_CDC_ON_BOOT //Serial used for USB CDC | ||
// There is always Seria0 for UART0 | ||
HardwareSerial Serial0(0); | ||
#else | ||
HardwareSerial Serial(0); | ||
#endif | ||
#if SOC_UART_NUM > 1 | ||
HardwareSerial Serial1(1); | ||
#endif | ||
|
@@ -127,11 +124,8 @@ HardwareSerial Serial2(2); | |
|
||
void serialEventRun(void) | ||
{ | ||
#if ARDUINO_USB_CDC_ON_BOOT //Serial used for USB CDC | ||
if(Serial0.available()) serialEvent(); | ||
#else | ||
// Serial is always defined as something (UART0 or USBSerial) | ||
if(Serial.available()) serialEvent(); | ||
|
||
#endif | ||
#if SOC_UART_NUM > 1 | ||
if(Serial1.available()) serialEvent1(); | ||
#endif | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,6 +51,7 @@ | |
#include "esp32-hal.h" | ||
#include "soc/soc_caps.h" | ||
#include "HWCDC.h" | ||
#include "USBCDC.h" | ||
|
||
#include "freertos/FreeRTOS.h" | ||
#include "freertos/task.h" | ||
|
@@ -240,15 +241,14 @@ extern void serialEventRun(void) __attribute__((weak)); | |
#ifndef ARDUINO_USB_CDC_ON_BOOT | ||
#define ARDUINO_USB_CDC_ON_BOOT 0 | ||
#endif | ||
#if ARDUINO_USB_CDC_ON_BOOT //Serial used for USB CDC | ||
#if !ARDUINO_USB_MODE | ||
#include "USB.h" | ||
#include "USBCDC.h" | ||
#if !ARDUINO_USB_CDC_ON_BOOT //Serial used for USB CDC | ||
|
||
// if not using CDC on Boot, Arduino Serial is the UART0 device | ||
#define Serial Serial0 | ||
#endif | ||
|
||
// There is always Seria0 for UART0 | ||
extern HardwareSerial Serial0; | ||
#else | ||
extern HardwareSerial Serial; | ||
#endif | ||
|
||
#if SOC_UART_NUM > 1 | ||
extern HardwareSerial Serial1; | ||
#endif | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -141,8 +141,13 @@ class USBCDC: public Stream | |
|
||
}; | ||
|
||
#if ARDUINO_USB_CDC_ON_BOOT && !ARDUINO_USB_MODE //Serial used for USB CDC | ||
extern USBCDC Serial; | ||
#if !ARDUINO_USB_MODE // Native USB CDC selected | ||
#if ARDUINO_USB_CDC_ON_BOOT //Serial used for USB CDC | ||
// When using CDC on Boot, Arduino Serial is the USB device | ||
#define Serial USBSerial | ||
#endif | ||
// USBSerial is always available to be used | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the whole #if !ARDUINO_USB_MODE // Native USB CDC selected
extern USBCDC USBSerial;
#endif There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK. |
||
extern USBCDC USBSerial; | ||
#endif | ||
|
||
#endif /* CONFIG_TINYUSB_CDC_ENABLED */ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,13 +9,7 @@ void loop(){} | |
#if !ARDUINO_USB_MSC_ON_BOOT | ||
FirmwareMSC MSC_Update; | ||
#endif | ||
#if ARDUINO_USB_CDC_ON_BOOT | ||
#define HWSerial Serial0 | ||
|
||
#define USBSerial Serial | ||
#else | ||
#define HWSerial Serial | ||
USBCDC USBSerial; | ||
#endif | ||
|
||
static void usbEventCallback(void* arg, esp_event_base_t event_base, int32_t event_id, void* event_data){ | ||
if(event_base == ARDUINO_USB_EVENTS){ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See my comment about
USBCDC.h