From 929ba5dddbbbf2aaee90047531533cdd2f48ff9d Mon Sep 17 00:00:00 2001 From: Vegard Storheil Eriksen Date: Sat, 8 Sep 2012 00:58:25 +0200 Subject: temp --- usb/dwc_otg.h | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'usb/dwc_otg.h') diff --git a/usb/dwc_otg.h b/usb/dwc_otg.h index b68ca0e..f206a44 100644 --- a/usb/dwc_otg.h +++ b/usb/dwc_otg.h @@ -24,8 +24,7 @@ class USB_otg : public USB_generic { // OUT packet. if(type == (0x2 << 17)) { - // TODO: Call endpoint callback. - (void)ep; + handle_out(ep, len); } // SETUP packet. @@ -97,6 +96,8 @@ class USB_otg : public USB_generic { void process() { // USB reset. if(otg.reg.GINTSTS & (1 << 12)) { + handle_reset(); + otg.dev_oep_reg[0].DOEPCTL = (1 << 27); otg.dev_reg.DAINTMSK = (1 << 16) | 1; otg.dev_reg.DOEPMSK = (1 << 3) | 1; @@ -136,6 +137,26 @@ class USB_otg : public USB_generic { otg.fifo[ep].reg = *bufp++; } } + + virtual uint32_t read(uint32_t ep, uint32_t* bufp, uint32_t len) { + if(ep != rxfifo_ep) { + return 0; + } + + if(len > rxfifo_bytes) { + len = rxfifo_bytes; + } + + // TODO: Handle non-mod4 length properly. + + for(uint32_t i = 0; i < len; i += 4) { + bufp[i >> 2] = otg.fifo[0].reg; + } + + rxfifo_bytes -= len; + + return len; + } }; #endif -- cgit v1.2.3