From eb3e6c7ba4ceef6adbf60abbd5d64ed7f7fade9b Mon Sep 17 00:00:00 2001 From: Stany MARCEL Date: Fri, 7 Dec 2012 02:15:00 +0100 Subject: [PATCH] Add rts dtr and baudrate public functions in CDC Serial_ class This permit to use the CDC serial link like a modem. For example configuration mode while DTR is low and data mode otherwise. Signed-off-by: Stany MARCEL --- hardware/arduino/cores/arduino/CDC.cpp | 17 +++++++++++++++++ hardware/arduino/cores/arduino/USBAPI.h | 3 +++ 2 files changed, 20 insertions(+) diff --git a/hardware/arduino/cores/arduino/CDC.cpp b/hardware/arduino/cores/arduino/CDC.cpp index e1e859d18c4..c490ef11be6 100644 --- a/hardware/arduino/cores/arduino/CDC.cpp +++ b/hardware/arduino/cores/arduino/CDC.cpp @@ -237,6 +237,23 @@ Serial_::operator bool() { return result; } + +unsigned long Serial_::baudrate(void) +{ + return _usbLineInfo.dwDTERate; +} + +bool Serial_::dtr(void) +{ + return (_usbLineInfo.lineState & 0x01) == 0x01; +} + +bool Serial_::rts(void) +{ + return (_usbLineInfo.lineState & 0x02) == 0x02; +} + + Serial_ Serial; #endif diff --git a/hardware/arduino/cores/arduino/USBAPI.h b/hardware/arduino/cores/arduino/USBAPI.h index 7a14285db05..b0e51282e17 100644 --- a/hardware/arduino/cores/arduino/USBAPI.h +++ b/hardware/arduino/cores/arduino/USBAPI.h @@ -40,6 +40,9 @@ class Serial_ : public Stream virtual int read(void); virtual void flush(void); virtual size_t write(uint8_t); + virtual unsigned long baudrate(void); + virtual bool dtr(void); + virtual bool rts(void); using Print::write; // pull in write(str) and write(buf, size) from Print operator bool(); };