From e6c4b0ff7e54f15d51a4c0f0389951f41df9c14d Mon Sep 17 00:00:00 2001 From: hathach Date: Thu, 12 Jul 2018 16:51:28 +0700 Subject: [PATCH] support serialEvent() --- cores/nRF5/HardwareSerial.h | 1 + cores/nRF5/Uart.cpp | 6 ++++++ cores/nRF5/main.cpp | 2 ++ 3 files changed, 9 insertions(+) diff --git a/cores/nRF5/HardwareSerial.h b/cores/nRF5/HardwareSerial.h index 62508e78..bd5eb84a 100644 --- a/cores/nRF5/HardwareSerial.h +++ b/cores/nRF5/HardwareSerial.h @@ -80,5 +80,6 @@ class HardwareSerial : public Stream }; extern void serialEventRun(void) __attribute__((weak)); +extern void serialEvent() __attribute__((weak)); #endif diff --git a/cores/nRF5/Uart.cpp b/cores/nRF5/Uart.cpp index f478f21a..0fa1dcca 100644 --- a/cores/nRF5/Uart.cpp +++ b/cores/nRF5/Uart.cpp @@ -21,6 +21,12 @@ #include "Arduino.h" #include "wiring_private.h" + +void serialEventRun(void) +{ + if (serialEvent && Serial.available() ) serialEvent(); +} + Uart::Uart(NRF_UART_Type *_nrfUart, IRQn_Type _IRQn, uint8_t _pinRX, uint8_t _pinTX) { nrfUart = _nrfUart; diff --git a/cores/nRF5/main.cpp b/cores/nRF5/main.cpp index ce7c7ad3..d7d38ebc 100644 --- a/cores/nRF5/main.cpp +++ b/cores/nRF5/main.cpp @@ -61,6 +61,8 @@ static void loop_task(void* arg) { loop(); + if (serialEvent && serialEventRun) serialEventRun(); + #if CFG_DEBUG >= 2 && DBG_MEM_INFO static uint32_t meminfo_ms = 0; if (meminfo_ms + DBG_MEM_INFO_INTERVAL < millis())