summaryrefslogtreecommitdiff
path: root/ucoo/hal/usb
diff options
context:
space:
mode:
authorNicolas Schodet2015-08-25 10:56:28 +0200
committerNicolas Schodet2019-10-07 00:44:50 +0200
commite936a9b325475c43796dc72d34e5c9fcce23f271 (patch)
tree59511dbf9a508babdf4200d24239386d5b5e4430 /ucoo/hal/usb
parent4f3801868f0ebcf80325a48a5a03b3ca082c20c6 (diff)
ucoo/hal/usb: lock IRQ while filling FIFO
This works around a problem with the USB IP which does not tolerate any other access while filling the FIFO.
Diffstat (limited to 'ucoo/hal/usb')
-rw-r--r--ucoo/hal/usb/usb.stm32.cc4
1 files changed, 4 insertions, 0 deletions
diff --git a/ucoo/hal/usb/usb.stm32.cc b/ucoo/hal/usb/usb.stm32.cc
index a45e121..dfc085e 100644
--- a/ucoo/hal/usb/usb.stm32.cc
+++ b/ucoo/hal/usb/usb.stm32.cc
@@ -173,8 +173,12 @@ UsbStream::write (const char *buf, int count)
{
if (control_.configured_)
{
+ // Do the FIFO write with IRQ locked, as the USB IP does not
+ // tolerate any interruption while the FIFO is being filled.
int len = std::min (left, UsbStreamControl::ep_size_);
+ irq_flags_t f = irq_lock ();
len = usbd_ep_write_packet (usbdev, num_ + 0x81, buf, len);
+ irq_restore (f);
buf += len;
left -= len;
}