Skip to content

Commit b822091

Browse files
embmicrocmaglie
authored andcommitted
improved USB write speeds
1 parent 44b5096 commit b822091

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

hardware/arduino/cores/arduino/CDC.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,11 @@ void Serial_::flush(void)
199199
}
200200

201201
size_t Serial_::write(uint8_t c)
202+
{
203+
return write(&c, 1);
204+
}
205+
206+
size_t Serial_::write(const uint8_t *buffer, size_t size)
202207
{
203208
/* only try to send bytes if the high-level CDC connection itself
204209
is open (not just the pipe) - the OS should set lineState when the port
@@ -210,7 +215,7 @@ size_t Serial_::write(uint8_t c)
210215
// open connection isn't broken cleanly (cable is yanked out, host dies
211216
// or locks up, or host virtual serial port hangs)
212217
if (_usbLineInfo.lineState > 0) {
213-
int r = USB_Send(CDC_TX,&c,1);
218+
int r = USB_Send(CDC_TX,buffer,size);
214219
if (r > 0) {
215220
return r;
216221
} else {

hardware/arduino/cores/arduino/USBAPI.h

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ class Serial_ : public Stream
4040
virtual int read(void);
4141
virtual void flush(void);
4242
virtual size_t write(uint8_t);
43+
virtual size_t write(const uint8_t*, size_t);
4344
using Print::write; // pull in write(str) and write(buf, size) from Print
4445
operator bool();
4546
};

0 commit comments

Comments
 (0)