libopencm3/lib/usb
Karl Palsson 26ab78a710 usb: fix race between setup complete and endpoint nak
See https://github.com/libopencm3/libopencm3/issues/873

Commentary describing this patch originally by zyp:

```
After looking further into it, I've concluded that my preliminary
analysis looks correct. The problem is that setting CNAK before
the SETUP complete event is received causes a race condition. The
SETUP callback is called when the SETUP packet event is received,
which means that setting CNAK from the callback is too early.

Originally the problem was that CNAK was set by ep_read() which is
called by the callback. #672 solved this by moving CNAK out of
ep_read() and calling it after the SETUP complete event is received
instead.

The regression by #785 is caused by the introduction of flow control
calls into the SETUP callback. They also set CNAK.

To solve this properly, I propose changing the event handling code
to only call the SETUP callback after the SETUP complete event is
received. Unfortunately, this implies that the callback can't call
ep_read() itself anymore, because the packet has to be read out of
the FIFO before the SETUP complete event arrives. This implies a
change of the API between the hardware drivers and _usbd_control_setup().
```

L1 (st_usbfs) works and passes tests as before change
F4 (dwc_otg_fs) works and now passes tests. (yay)
LM4f still compiles, and has had the same style of implementation as
st_usbfs, however has not been tested on any hardware.
2018-08-27 15:11:32 +00:00
..
usb.c usb: make usb_disconnect() weak 2018-08-27 15:11:32 +00:00
usb_control.c usb: fix race between setup complete and endpoint nak 2018-08-27 15:11:32 +00:00
usb_dwc_common.c usb: fix race between setup complete and endpoint nak 2018-08-27 15:11:32 +00:00
usb_dwc_common.h usb: stm32fx07 -> usb_dwc_common 2018-03-02 22:42:05 +00:00
usb_efm32.c efm32: Split efm32/lg into /lg and /common. 2018-04-27 21:36:42 +00:00
usb_efm32hg.c efm32hg: usb: add usb support 2018-03-02 22:42:05 +00:00
usb_f107.c usb: stm32fx07 -> usb_dwc_common 2018-03-02 22:42:05 +00:00
usb_f207.c usb: stm32fx07 -> usb_dwc_common 2018-03-02 22:42:05 +00:00
usb_lm4f.c usb: fix race between setup complete and endpoint nak 2018-08-27 15:11:32 +00:00
usb_msc.c usb: Use enumerated return codes 2018-03-02 22:42:05 +00:00
usb_private.h usb: make strings "const char * const *" 2018-08-27 13:34:52 +00:00
usb_standard.c usb: prevent registering duplicate config callbacks 2018-08-17 00:15:01 +00:00