From 108faf4ead2643d6ebd0fd238914b09dc4949861 Mon Sep 17 00:00:00 2001 From: Tomasz Kramkowski Date: Sun, 26 Mar 2017 21:46:11 +0100 Subject: usb: uart debugging --- usb/endpt0.c | 16 +++++++++++++++- usb/endpt1.c | 4 ++++ usb/usb.c | 3 +++ 3 files changed, 22 insertions(+), 1 deletion(-) (limited to 'usb') diff --git a/usb/endpt0.c b/usb/endpt0.c index 7791d38..22d78df 100644 --- a/usb/endpt0.c +++ b/usb/endpt0.c @@ -7,6 +7,8 @@ #include +#include "../uart/uart.h" + #include "bdt.h" #include "endpt0.h" @@ -131,29 +133,37 @@ static void tok_setup(struct tok_setup *setup) { switch (setup->reqtyp << 8 | setup->req) { case 0x0005: /* SET ADDRESS */ + uart_printf(" SET ADDRESS (%u)\n", (unsigned)setup->value); nextaddr = setup->value; puttx(NULL, 0); break; case 0x0009: /* SET CONFIGURATION */ + uart_puts(" SET CONFIGURATION"); puttx(NULL, 0); break; case 0x8006: /* GET DESCRIPTOR */ + uart_printf(" GET DESCRIPTOR (0x%x)", (unsigned)setup->value); switch (setup->value) { case 0x0100: /* DEVICE */ + uart_puts(" DEVICE"); quetx(ds_dev, trunc(ARRLEN(ds_dev), setup->length)); return; case 0x0200: /* CONFIGURATION */ + uart_puts(" CONFIGURATION"); quetx(ds_conf, trunc(ARRLEN(ds_conf), setup->length)); return; case 0x0300: /* STRING 0 */ + uart_puts(" STRING 0"); quetx(ds_lang, trunc(ARRLEN(ds_lang), setup->length)); return; case 0x0301: /* STRING 1 */ + uart_puts(" STRING 1"); quetx(ds_str1, trunc(ARRLEN(ds_str1), setup->length)); return; } /* fall through */ default: + /* since this EP was called successfuly, we unstall it */ SET_BIT(USB0_ENDPT(0), ENDPT_EPSTALL); break; } @@ -169,16 +179,19 @@ void usb_endpt0_token(uint8_t state) switch (GET_BITS(bd->desc, BD_TOK_PID)) { case BD_TOK_PID_OUT: + uart_puts(" PID_OUT"); bd->desc = USB0_BD_INIT(sizeof buf[0], 1); break; case BD_TOK_PID_IN: - pushtx(); + uart_puts(" PID_IN"); + uart_printf(" pushtx: %d\n", (int)pushtx()); if (nextaddr) { USB0_ADDR = nextaddr; nextaddr = 0; } break; case BD_TOK_PID_SETUP: + uart_puts(" PID_SETUP"); read_setup(&setup, bd->addr); bd->desc = USB0_BD_INIT(sizeof buf[0], 1); @@ -193,5 +206,6 @@ void usb_endpt0_token(uint8_t state) break; } + /*SET_BIT(USB0_CTL, CTL_ODDRST);*/ USB0_CTL = BV(CTL_USBENSOFEN); } diff --git a/usb/endpt1.c b/usb/endpt1.c index b29c3bb..ca954fc 100644 --- a/usb/endpt1.c +++ b/usb/endpt1.c @@ -1,6 +1,8 @@ #include #include +#include "../uart/uart.h" + #include "bdt.h" #include "endpt1.h" @@ -20,6 +22,8 @@ void usb_endpt1_token(uint8_t state) { struct usb0_bd *bd; + uart_puts(" endpt1 token"); + bd = &BDT_ENDPT(1, GET_BIT(state, STAT_TX), GET_BIT(state, STAT_ODD)); switch (GET_BITS(bd->desc, BD_TOK_PID)) { diff --git a/usb/usb.c b/usb/usb.c index 8b78f3b..a8cbbf8 100644 --- a/usb/usb.c +++ b/usb/usb.c @@ -4,6 +4,7 @@ #include #include +#include "../uart/uart.h" #include "usb.h" #include "bdt.h" #include "endpt0.h" @@ -80,10 +81,12 @@ void usb_isr(void) uint8_t stat = USB0_ISTAT; if (IS_BIT_SET(stat, ISTAT_TOKDNE)) { + uart_puts("tokdne"); i_tokdne(); USB0_ISTAT = BV(ISTAT_TOKDNE); } if (IS_BIT_SET(stat, ISTAT_USBRST)) { + uart_puts("usbrst"); i_usbrst(); USB0_ISTAT = BV(ISTAT_USBRST); } -- cgit v1.2.3-54-g00ecf