Skip to content
Snippets Groups Projects
Commit f3a29a7d authored by Arturo Guadalupi's avatar Arturo Guadalupi
Browse files

Merge pull request #143 from sandeepmistry/cdc-write-return-value

Correct SerialUSB return value
parents 2df644e6 8d0c1674
No related branches found
No related tags found
No related merge requests found
...@@ -262,7 +262,7 @@ size_t Serial_::write(const uint8_t *buffer, size_t size) ...@@ -262,7 +262,7 @@ size_t Serial_::write(const uint8_t *buffer, size_t size)
{ {
uint32_t r = usb.send(CDC_ENDPOINT_IN, buffer, size); uint32_t r = usb.send(CDC_ENDPOINT_IN, buffer, size);
if (r == 0) { if (r > 0) {
return r; return r;
} else { } else {
setWriteError(); setWriteError();
......
...@@ -605,6 +605,7 @@ uint8_t USBDeviceClass::armRecv(uint32_t ep) ...@@ -605,6 +605,7 @@ uint8_t USBDeviceClass::armRecv(uint32_t ep)
// Blocking Send of data to an endpoint // Blocking Send of data to an endpoint
uint32_t USBDeviceClass::send(uint32_t ep, const void *data, uint32_t len) uint32_t USBDeviceClass::send(uint32_t ep, const void *data, uint32_t len)
{ {
uint32_t written = 0;
uint32_t length = 0; uint32_t length = 0;
if (!_usbConfiguration) if (!_usbConfiguration)
...@@ -675,10 +676,11 @@ uint32_t USBDeviceClass::send(uint32_t ep, const void *data, uint32_t len) ...@@ -675,10 +676,11 @@ uint32_t USBDeviceClass::send(uint32_t ep, const void *data, uint32_t len)
while (!usbd.epBank1IsTransferComplete(ep)) { while (!usbd.epBank1IsTransferComplete(ep)) {
; // need fire exit. ; // need fire exit.
} }
written += length;
len -= length; len -= length;
data = (char *)data + length; data = (char *)data + length;
} }
return len; return written;
} }
uint32_t USBDeviceClass::armSend(uint32_t ep, const void* data, uint32_t len) uint32_t USBDeviceClass::armSend(uint32_t ep, const void* data, uint32_t len)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment