stm32: Discard usbotg tx data until usb is ready

If the usb interface is not ready, just discard messages.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2019-08-29 23:23:58 -04:00
parent 5e3acff8c7
commit 917fd51057
1 changed files with 2 additions and 2 deletions

View File

@ -160,8 +160,8 @@ usb_send_bulk_in(void *data, uint_fast8_t len)
{ {
uint32_t ctl = EPIN(USB_CDC_EP_BULK_IN)->DIEPCTL; uint32_t ctl = EPIN(USB_CDC_EP_BULK_IN)->DIEPCTL;
if (!(ctl & USB_OTG_DIEPCTL_USBAEP)) if (!(ctl & USB_OTG_DIEPCTL_USBAEP))
// Controller not enabled // Controller not enabled - discard data
return -2; return len;
if (ctl & USB_OTG_DIEPCTL_EPENA) { if (ctl & USB_OTG_DIEPCTL_EPENA) {
// Wait for space to transmit // Wait for space to transmit
OTGD->DIEPEMPMSK |= (1 << USB_CDC_EP_BULK_IN); OTGD->DIEPEMPMSK |= (1 << USB_CDC_EP_BULK_IN);