libopencm3/lib
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
..
cm3 cm3: Only inline asm is allowed in naked functions 2018-07-29 20:31:17 +00:00
dispatch msp432/e4: new target 2018-08-27 13:34:29 +00:00
efm32 efm32: add USB mass storage class code 2018-06-27 22:13:40 +00:00
ethernet ethernet: ksz80x1: fix build/compile 2018-04-14 18:40:54 +00:00
lm3s ld scripts: drop duplication of standard sections 2018-04-28 21:12:27 +00:00
lm4f add USB mass storage class code where it was ommitted 2018-06-07 12:09:11 +00:00
lpc13xx ld scripts: drop duplication of standard sections 2018-04-28 21:12:27 +00:00
lpc17xx ld scripts: drop duplication of standard sections 2018-04-28 21:12:27 +00:00
lpc43xx make: use std=c99 everywhere by default. 2017-06-08 23:01:45 +00:00
msp432/e4 msp432/e4: new target 2018-08-27 13:34:29 +00:00
sam ld scripts: drop duplication of standard sections 2018-04-28 21:12:27 +00:00
stm32 usb: fix race between setup complete and endpoint nak 2018-08-27 15:11:32 +00:00
usb usb: fix race between setup complete and endpoint nak 2018-08-27 15:11:32 +00:00
vf6xx vector: fix externs 2017-10-18 20:51:33 +00:00
Makefile.include ld scripts: drop duplication of standard sections 2018-04-28 21:12:27 +00:00
cortex-m-generic.ld ld scripts: drop duplication of standard sections 2018-04-28 21:12:27 +00:00