summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomasz Kramkowski <tk@kyriasis.com>2017-03-28 16:13:02 +0100
committerTomasz Kramkowski <tk@kyriasis.com>2017-03-28 16:13:02 +0100
commit9ceb7ca646a8a0b8ae7885a93ee2ad7f89cd88c6 (patch)
tree911b9741955e9bddceb4b2c846ea6bff720b8145
parent1463b0b521a6df505d7d1799f33670b871c2caab (diff)
downloadfmk-9ceb7ca646a8a0b8ae7885a93ee2ad7f89cd88c6.tar.gz
fmk-9ceb7ca646a8a0b8ae7885a93ee2ad7f89cd88c6.tar.xz
fmk-9ceb7ca646a8a0b8ae7885a93ee2ad7f89cd88c6.zip
usb: Extra debug / error handling.
-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);
}