Skip to content

Commit ceb9de4

Browse files
committed
Serial1 fixes.
Former-commit-id: bf45df7
1 parent 7b722ef commit ceb9de4

File tree

3 files changed

+18
-8
lines changed

3 files changed

+18
-8
lines changed

cores/nRF5/HardwareSerial.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,4 +81,6 @@ class HardwareSerial : public Stream
8181

8282
extern void serialEventRun(void) __attribute__((weak));
8383

84+
extern void serialEvent() __attribute__((weak));
85+
extern void serialEvent1() __attribute__((weak));
8486
#endif

cores/nRF5/Uart.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,16 @@
2121
#include "Arduino.h"
2222
#include "wiring_private.h"
2323

24+
25+
void serialEventRun(void)
26+
{
27+
if (serialEvent && Serial.available() ) serialEvent();
28+
29+
#if defined(PIN_SERIAL1_RX) && defined(PIN_SERIAL1_TX)
30+
if (serialEvent1 && Serial1.available() ) serialEvent1();
31+
#endif
32+
}
33+
2434
Uart::Uart(NRF_UART_Type *_nrfUart, IRQn_Type _IRQn, uint8_t _pinRX, uint8_t _pinTX)
2535
{
2636
nrfUart = _nrfUart;

cores/nRF5/Uart.h

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,21 +78,19 @@ class Uart : public HardwareSerial
7878
//
7979
// SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX
8080
// pins are NOT connected to anything by default.
81-
#if !defined(USB_CDC_DEFAULT_SERIAL)
82-
#define SERIAL_PORT_MONITOR Serial
83-
#define SERIAL_PORT_HARDWARE Serial
84-
85-
#else
81+
#if defined(USB_CDC_DEFAULT_SERIAL)
8682
#define SERIAL_PORT_MONITOR Serial
8783
#define SERIAL_PORT_USBVIRTUAL Serial
8884

8985
#define SERIAL_PORT_HARDWARE Serial1
9086
#define SERIAL_PORT_HARDWARE_OPEN Serial1
91-
87+
#else
88+
#define SERIAL_PORT_MONITOR Serial
89+
#define SERIAL_PORT_HARDWARE Serial
9290
#endif
9391

9492
extern Uart SERIAL_PORT_HARDWARE;
9593

96-
#if defined(PIN_SERIAL2_RX) && defined(PIN_SERIAL2_TX)
97-
extern Uart Serial2;
94+
#if defined(PIN_SERIAL1_RX) && defined(PIN_SERIAL1_TX)
95+
extern Uart Serial1;
9896
#endif

0 commit comments

Comments
 (0)