From 9c99fe9c032d3e9e4bb4d03f5431d6035f26b520 Mon Sep 17 00:00:00 2001 From: hathach Date: Fri, 28 Jul 2017 12:28:22 +0700 Subject: [PATCH] add Uart.setPins() to remap Serial rx, tx --- cores/nRF5/Uart.cpp | 8 ++++++-- cores/nRF5/Uart.h | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/cores/nRF5/Uart.cpp b/cores/nRF5/Uart.cpp index 5a1225f8..0b31d4be 100644 --- a/cores/nRF5/Uart.cpp +++ b/cores/nRF5/Uart.cpp @@ -30,7 +30,6 @@ Uart::Uart(NRF_UART_Type *_nrfUart, IRQn_Type _IRQn, uint8_t _pinRX, uint8_t _pi uc_hwFlow = 0; _mutex = NULL; - _begun = false; } @@ -45,10 +44,15 @@ Uart::Uart(NRF_UART_Type *_nrfUart, IRQn_Type _IRQn, uint8_t _pinRX, uint8_t _pi uc_hwFlow = 1; _mutex = NULL; - _begun = false; } +void Uart::setPins(uint8_t pin_rx, uint8_t pin_tx) +{ + uc_pinRX = pin_rx; + uc_pinTX = pin_tx; +} + void Uart::begin(unsigned long baudrate) { begin(baudrate, (uint8_t)SERIAL_8N1); diff --git a/cores/nRF5/Uart.h b/cores/nRF5/Uart.h index 93460687..d791aab9 100644 --- a/cores/nRF5/Uart.h +++ b/cores/nRF5/Uart.h @@ -32,6 +32,8 @@ class Uart : public HardwareSerial public: Uart(NRF_UART_Type *_nrfUart, IRQn_Type _IRQn, uint8_t _pinRX, uint8_t _pinTX); Uart(NRF_UART_Type *_nrfUart, IRQn_Type _IRQn, uint8_t _pinRX, uint8_t _pinTX, uint8_t _pinCTS, uint8_t _pinRTS ); + + void setPins(uint8_t pin_rx, uint8_t pin_tx); void begin(unsigned long baudRate); void begin(unsigned long baudrate, uint16_t config); void end();