diff --git a/cores/arduino/Serial.cpp b/cores/arduino/Serial.cpp index 6b601907c..0a4239a45 100644 --- a/cores/arduino/Serial.cpp +++ b/cores/arduino/Serial.cpp @@ -38,6 +38,21 @@ struct _mbed_serial { mbed::UnbufferedSerial* obj; }; +UART::UART(int tx, int rx, int rts, int cts) { + _tx = digitalPinToPinName(tx); + _rx = digitalPinToPinName(rx); + if (rts >= 0) { + _rts = digitalPinToPinName(rts); + } else { + _rts = NC; + } + if (cts >= 0) { + _cts = digitalPinToPinName(cts); + } else { + _cts = NC; + } +} + void UART::begin(unsigned long baudrate, uint16_t config) { #if defined(SERIAL_CDC) diff --git a/cores/arduino/Serial.h b/cores/arduino/Serial.h index 173c9663d..f20e14060 100644 --- a/cores/arduino/Serial.h +++ b/cores/arduino/Serial.h @@ -38,7 +38,8 @@ namespace arduino { class UART : public HardwareSerial { public: - UART(int tx, int rx, int rts, int cts) : _tx((PinName)tx), _rx((PinName)rx), _rts((PinName)rts), _cts((PinName)cts) {} + UART(int tx, int rx, int rts = -1, int cts = -1); + UART(PinName tx, PinName rx, PinName rts = NC, PinName cts = NC) : _tx(tx), _rx(rx), _rts(rts), _cts(cts) {} UART() { is_usb = true; }