File tree Expand file tree Collapse file tree 3 files changed +17
-0
lines changed Expand file tree Collapse file tree 3 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -204,6 +204,10 @@ void Serial_::flush(void)
204204 usb.flush (CDC_ENDPOINT_IN);
205205}
206206
207+ void Serial_::clear (void ) {
208+ usb.clear (CDC_ENDPOINT_IN);
209+ }
210+
207211size_t Serial_::write (const uint8_t *buffer, size_t size)
208212{
209213 uint32_t r = usb.send (CDC_ENDPOINT_IN, buffer, size);
Original file line number Diff line number Diff line change @@ -94,6 +94,7 @@ class USBDeviceClass {
9494 int recv (uint32_t ep);
9595 uint32_t available (uint32_t ep);
9696 void flush (uint32_t ep);
97+ void clear (uint32_t ep);
9798 void stall (uint32_t ep);
9899
99100 // private?
@@ -125,6 +126,7 @@ class Serial_ : public Stream
125126 virtual int peek (void );
126127 virtual int read (void );
127128 virtual void flush (void );
129+ virtual void clear (void );
128130 virtual size_t write (uint8_t );
129131 virtual size_t write (const uint8_t *buffer, size_t size);
130132 using Print::write; // pull in write(str) from Print
Original file line number Diff line number Diff line change @@ -508,6 +508,17 @@ void USBDeviceClass::flush(uint32_t ep)
508508 }
509509}
510510
511+ void USBDeviceClass::clear (uint32_t ep) {
512+ usbd.epBank1SetAddress (ep, &udd_ep_in_cache_buffer[ep]);
513+ usbd.epBank1SetByteCount (ep, 0 );
514+
515+ // Clear the transfer complete flag
516+ usbd.epBank1AckTransferComplete (ep);
517+
518+ // RAM buffer is full, we can send data (IN)
519+ usbd.epBank1SetReady (ep);
520+ }
521+
511522void USBDeviceClass::stall (uint32_t ep)
512523{
513524 // TODO: test
You can’t perform that action at this time.
0 commit comments