allow the Low Power library to not break the Serial connection
This commit is contained in:
parent
3645829901
commit
52e005278a
3 changed files with 17 additions and 0 deletions
|
|
@ -204,6 +204,10 @@ void Serial_::flush(void)
|
|||
usb.flush(CDC_ENDPOINT_IN);
|
||||
}
|
||||
|
||||
void Serial_::clear(void) {
|
||||
usb.clear(CDC_ENDPOINT_IN);
|
||||
}
|
||||
|
||||
size_t Serial_::write(const uint8_t *buffer, size_t size)
|
||||
{
|
||||
uint32_t r = usb.send(CDC_ENDPOINT_IN, buffer, size);
|
||||
|
|
|
|||
|
|
@ -94,6 +94,7 @@ public:
|
|||
int recv(uint32_t ep);
|
||||
uint32_t available(uint32_t ep);
|
||||
void flush(uint32_t ep);
|
||||
void clear(uint32_t ep);
|
||||
void stall(uint32_t ep);
|
||||
|
||||
// private?
|
||||
|
|
@ -125,6 +126,7 @@ public:
|
|||
virtual int peek(void);
|
||||
virtual int read(void);
|
||||
virtual void flush(void);
|
||||
virtual void clear(void);
|
||||
virtual size_t write(uint8_t);
|
||||
virtual size_t write(const uint8_t *buffer, size_t size);
|
||||
using Print::write; // pull in write(str) from Print
|
||||
|
|
|
|||
|
|
@ -508,6 +508,17 @@ void USBDeviceClass::flush(uint32_t ep)
|
|||
}
|
||||
}
|
||||
|
||||
void USBDeviceClass::clear(uint32_t ep) {
|
||||
usbd.epBank1SetAddress(ep, &udd_ep_in_cache_buffer[ep]);
|
||||
usbd.epBank1SetByteCount(ep, 0);
|
||||
|
||||
// Clear the transfer complete flag
|
||||
usbd.epBank1AckTransferComplete(ep);
|
||||
|
||||
// RAM buffer is full, we can send data (IN)
|
||||
usbd.epBank1SetReady(ep);
|
||||
}
|
||||
|
||||
void USBDeviceClass::stall(uint32_t ep)
|
||||
{
|
||||
// TODO: test
|
||||
|
|
|
|||
Loading…
Reference in a new issue