From d69c3729864f7813c1afe9964e9d3fd3e924e6de Mon Sep 17 00:00:00 2001 From: Sandeep Mistry Date: Mon, 6 Jun 2016 10:13:18 -0400 Subject: [PATCH] Add Serial_::availableForWrite --- hardware/arduino/sam/cores/arduino/USB/CDC.cpp | 7 +++++++ hardware/arduino/sam/cores/arduino/USB/USBAPI.h | 1 + 2 files changed, 8 insertions(+) diff --git a/hardware/arduino/sam/cores/arduino/USB/CDC.cpp b/hardware/arduino/sam/cores/arduino/USB/CDC.cpp index 3192143fc..dea6bd2b9 100644 --- a/hardware/arduino/sam/cores/arduino/USB/CDC.cpp +++ b/hardware/arduino/sam/cores/arduino/USB/CDC.cpp @@ -214,6 +214,13 @@ int Serial_::available(void) return (unsigned int)(CDC_SERIAL_BUFFER_SIZE + buffer->head - buffer->tail) % CDC_SERIAL_BUFFER_SIZE; } +int Serial_::availableForWrite(void) +{ + // return the number of bytes left in the current bank, + // always EP size - 1, because bank is flushed on every write + return (EPX_SIZE - 1); +} + int Serial_::peek(void) { ring_buffer *buffer = &cdc_rx_buffer; diff --git a/hardware/arduino/sam/cores/arduino/USB/USBAPI.h b/hardware/arduino/sam/cores/arduino/USB/USBAPI.h index 2eeaca08e..0a7063423 100644 --- a/hardware/arduino/sam/cores/arduino/USB/USBAPI.h +++ b/hardware/arduino/sam/cores/arduino/USB/USBAPI.h @@ -54,6 +54,7 @@ public: void end(void); virtual int available(void); + virtual int availableForWrite(void); virtual void accept(void); virtual int peek(void); virtual int read(void);