diff options
author | Justin Rajewski <justin@embeddedmicro.com> | 2014-03-18 14:15:41 -0700 |
---|---|---|
committer | Cristian Maglie <c.maglie@bug.st> | 2014-05-24 00:34:56 +0200 |
commit | 872c88bb5f643702edcc8d0ebfc1f6cd13bcf414 (patch) | |
tree | b97deeadaf9b67085cc2eca85ebbe090d65e4f73 | |
parent | f3e78a4a2920665b45b964049db3ebed9b8f1dc7 (diff) |
improved USB write speeds
-rw-r--r-- | cores/arduino/CDC.cpp | 7 | ||||
-rw-r--r-- | cores/arduino/USBAPI.h | 1 |
2 files changed, 7 insertions, 1 deletions
diff --git a/cores/arduino/CDC.cpp b/cores/arduino/CDC.cpp index e1e859d..fb0c0e0 100644 --- a/cores/arduino/CDC.cpp +++ b/cores/arduino/CDC.cpp @@ -200,6 +200,11 @@ void Serial_::flush(void) size_t Serial_::write(uint8_t c) { + return write(&c, 1); +} + +size_t Serial_::write(const uint8_t *buffer, size_t size) +{ /* only try to send bytes if the high-level CDC connection itself is open (not just the pipe) - the OS should set lineState when the port is opened and clear lineState when the port is closed. @@ -210,7 +215,7 @@ size_t Serial_::write(uint8_t c) // open connection isn't broken cleanly (cable is yanked out, host dies // or locks up, or host virtual serial port hangs) if (_usbLineInfo.lineState > 0) { - int r = USB_Send(CDC_TX,&c,1); + int r = USB_Send(CDC_TX,buffer,size); if (r > 0) { return r; } else { diff --git a/cores/arduino/USBAPI.h b/cores/arduino/USBAPI.h index 7a14285..1c5ecf0 100644 --- a/cores/arduino/USBAPI.h +++ b/cores/arduino/USBAPI.h @@ -40,6 +40,7 @@ public: virtual int read(void); virtual void flush(void); virtual size_t write(uint8_t); + virtual size_t write(const uint8_t*, size_t); using Print::write; // pull in write(str) and write(buf, size) from Print operator bool(); }; |