summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2016-06-09 22:05:24 -0700
committerKeith Packard <keithp@keithp.com>2016-06-09 22:05:24 -0700
commit2970de9f92243b11d3beef56f3b1df3ef3579b95 (patch)
tree6464571a07d90db93736a2b0b40ad9a34fb91772 /src
parent55c8e5aff2cc7b941503a04970f7d368261af52a (diff)
stmf0: Clear all USB state when resetting chip. Wakeup all sleepers
When USB is reset, but the board is not power cycled, all of the internal USB state needs to be reset, and any tasks blocked on sending or receiving packets need to be awoken so they can go wait for USB to start running again. Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'src')
-rw-r--r--src/stmf0/ao_usb_stm.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/stmf0/ao_usb_stm.c b/src/stmf0/ao_usb_stm.c
index 253506d5..a67fc868 100644
--- a/src/stmf0/ao_usb_stm.c
+++ b/src/stmf0/ao_usb_stm.c
@@ -437,6 +437,17 @@ ao_usb_set_ep0(void)
ao_usb_set_address(0);
ao_usb_running = 0;
+
+ /* Reset our internal state
+ */
+
+ ao_usb_ep0_state = AO_USB_EP0_IDLE;
+
+ ao_usb_ep0_in_data = NULL;
+ ao_usb_ep0_in_len = 0;
+
+ ao_usb_ep0_out_data = 0;
+ ao_usb_ep0_out_len = 0;
}
static void
@@ -493,6 +504,20 @@ ao_usb_set_configuration(void)
STM_USB_EPR_STAT_TX_NAK);
#endif
+ ao_usb_in_flushed = 0;
+ ao_usb_in_pending = 0;
+ ao_wakeup(&ao_usb_in_pending);
+#if AO_USB_HAS_IN2
+ ao_usb_in2_flushed = 0;
+ ao_usb_in2_pending = 0;
+ ao_wakeup(&ao_usb_in2_pending);
+#endif
+
+ ao_usb_out_avail = 0;
+ ao_usb_configuration = 0;
+
+ ao_wakeup(AO_USB_OUT_SLEEP_ADDR);
+
ao_usb_running = 1;
#if AO_USB_DIRECTIO
ao_wakeup(&ao_usb_running);