Skip to content

Commit 4f87112

Browse files
Peter Van Hoyweghenmatthijskooijman
Peter Van Hoyweghen
authored andcommitted
Add Serial_::availableForWrite().
This makes the CDC "Serial" object on the Leonardo and similar boards support this recently introduced method as well. The CDC code in the sam core is not changed.
1 parent 9b7b23f commit 4f87112

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

Diff for: hardware/arduino/avr/cores/arduino/CDC.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,11 @@ int Serial_::read(void)
163163
return USB_Recv(CDC_RX);
164164
}
165165

166+
int Serial_::availableForWrite(void)
167+
{
168+
return USB_SendSpace(CDC_TX);
169+
}
170+
166171
void Serial_::flush(void)
167172
{
168173
USB_Flush(CDC_TX);

Diff for: hardware/arduino/avr/cores/arduino/USBAPI.h

+2
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ class Serial_ : public Stream
9292
virtual int available(void);
9393
virtual int peek(void);
9494
virtual int read(void);
95+
int availableForWrite(void);
9596
virtual void flush(void);
9697
virtual size_t write(uint8_t);
9798
virtual size_t write(const uint8_t*, size_t);
@@ -188,6 +189,7 @@ int USB_SendControl(uint8_t flags, const void* d, int len);
188189
int USB_RecvControl(void* d, int len);
189190

190191
uint8_t USB_Available(uint8_t ep);
192+
uint8_t USB_SendSpace(uint8_t ep);
191193
int USB_Send(uint8_t ep, const void* data, int len); // blocking
192194
int USB_Recv(uint8_t ep, void* data, int len); // non-blocking
193195
int USB_Recv(uint8_t ep); // non-blocking

0 commit comments

Comments
 (0)