Skip to content

SAM: Add Serial_::availableForWrite #5018

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 7, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions hardware/arduino/sam/cores/arduino/USB/CDC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions hardware/arduino/sam/cores/arduino/USB/USBAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class Serial_ : public Stream
void end(void);

virtual int available(void);
virtual int availableForWrite(void);
virtual void accept(void);
virtual int peek(void);
virtual int read(void);
Expand Down