summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--usb/usb.c32
1 files changed, 27 insertions, 5 deletions
diff --git a/usb/usb.c b/usb/usb.c
index c37fc5f..977e7a5 100644
--- a/usb/usb.c
+++ b/usb/usb.c
@@ -41,7 +41,8 @@ void usb_setup(void)
/* Initial Configuration */
SET_MASKED(USB0_USBCTRL, BV(USBCTRL_SUSP) | BV(USBCTRL_PDE), 0);
SET_BIT(USB0_CONTROL, CONTROL_DPPULLUPNONOTG);
- SET_BIT(USB0_INTEN, INTEN_USBRSTEN);
+ USB0_INTEN = BV(INTEN_STALLEN) | BV(INTEN_RESUMEEN) |
+ BV(INTEN_SLEEPEN) | BV(INTEN_ERROREN) | BV(INTEN_USBRSTEN);
/* NVIC Enable interrupt */
ISR_CLRPEND(73);
@@ -81,13 +82,34 @@ void usb_isr(void)
{
uint8_t stat = USB0_ISTAT;
- if (IS_BIT_SET(stat, ISTAT_TOKDNE)) {
- uart_puts("tokdne");
+ if (GET_BIT(stat, ISTAT_STALL)) {
+ uart_puts("INT: stall");
+ USB0_ISTAT = BV(ISTAT_STALL);
+ }
+ if (GET_BIT(stat, ISTAT_RESUME)) {
+ uart_puts("INT: resume");
+ USB0_ISTAT = BV(ISTAT_RESUME);
+ }
+ if (GET_BIT(stat, ISTAT_SLEEP)) {
+ uart_puts("INT: sleep");
+ USB0_ISTAT = BV(ISTAT_SLEEP);
+ }
+ if (GET_BIT(stat, ISTAT_TOKDNE)) {
+ uart_puts("INT: tokdne");
i_tokdne();
USB0_ISTAT = BV(ISTAT_TOKDNE);
}
- if (IS_BIT_SET(stat, ISTAT_USBRST)) {
- uart_puts("usbrst");
+ if (GET_BIT(stat, ISTAT_SOFTOK)) {
+ /*uart_puts("INT: softok");*/
+ USB0_ISTAT = BV(ISTAT_SOFTOK);
+ }
+ if (GET_BIT(stat, ISTAT_ERROR)) {
+ uart_printf("INT: error (0x%x)\n", (unsigned)USB0_ERRSTAT);
+ USB0_ERRSTAT = USB0_ERRSTAT;
+ USB0_ISTAT = BV(ISTAT_ERROR);
+ }
+ if (GET_BIT(stat, ISTAT_USBRST)) {
+ uart_puts("INT: usbrst");
i_usbrst();
USB0_ISTAT = BV(ISTAT_USBRST);
}