From 6f8c546595556424568ee7b53e3ee5320cf092bd Mon Sep 17 00:00:00 2001 From: hathach Date: Sat, 1 Sep 2018 13:40:04 +0700 Subject: [PATCH] serial port clean up --- cores/nRF5/Uart.cpp | 11 ++--------- cores/nRF5/Uart.h | 30 +++++++++++++++++++----------- 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/cores/nRF5/Uart.cpp b/cores/nRF5/Uart.cpp index dd982b4d..b44d00c3 100644 --- a/cores/nRF5/Uart.cpp +++ b/cores/nRF5/Uart.cpp @@ -202,19 +202,12 @@ size_t Uart::write(const uint8_t data) #define NRF_UART0_IRQn UARTE0_UART0_IRQn - -#ifdef NRF52840_XXAA - #define SERIAL_HW Serial1 -#else - #define SERIAL_HW Serial -#endif - -Uart SERIAL_HW( NRF_UART0, NRF_UART0_IRQn, PIN_SERIAL_RX, PIN_SERIAL_TX ); +Uart SERIAL_PORT_HARDWARE( NRF_UART0, NRF_UART0_IRQn, PIN_SERIAL_RX, PIN_SERIAL_TX ); extern "C" { void UARTE0_UART0_IRQHandler() { - SERIAL_HW.IrqHandler(); + SERIAL_PORT_HARDWARE.IrqHandler(); } } diff --git a/cores/nRF5/Uart.h b/cores/nRF5/Uart.h index 1ba79f2f..7b3be224 100644 --- a/cores/nRF5/Uart.h +++ b/cores/nRF5/Uart.h @@ -68,15 +68,6 @@ class Uart : public HardwareSerial SemaphoreHandle_t _mutex; }; -#ifdef __cplusplus - -#ifdef NRF52840_XXAA - extern Uart Serial1; -#else - extern Uart Serial; -#endif - -#endif // These serial port names are intended to allow libraries and architecture-neutral // sketches to automatically default to the correct port name for a particular type @@ -93,5 +84,22 @@ class Uart : public HardwareSerial // // SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX // pins are NOT connected to anything by default. -#define SERIAL_PORT_MONITOR Serial -#define SERIAL_PORT_HARDWARE Serial +#ifdef NRF52840_XXAA + +#define SERIAL_PORT_MONITOR Serial +#define SERIAL_PORT_USBVIRTUAL Serial + +#define SERIAL_PORT_HARDWARE Serial1 +#define SERIAL_PORT_HARDWARE_OPEN Serial1 + +#else + +#define SERIAL_PORT_MONITOR Serial +#define SERIAL_PORT_HARDWARE Serial + +#endif + + +#ifdef __cplusplus +extern Uart SERIAL_PORT_HARDWARE; +#endif