summaryrefslogtreecommitdiff
path: root/usb/dwc_otg.h
diff options
context:
space:
mode:
authorVegard Storheil Eriksen <zyp@jvnv.net>2012-09-08 00:58:25 +0200
committerVegard Storheil Eriksen <zyp@jvnv.net>2012-09-08 17:07:23 +0200
commit929ba5dddbbbf2aaee90047531533cdd2f48ff9d (patch)
tree1f5c71e996b4ab5dfdc2ed95e12c7d5409229423 /usb/dwc_otg.h
parent9ae91599772ee81d352014a8ff293c5feec0439b (diff)
temp
Diffstat (limited to 'usb/dwc_otg.h')
-rw-r--r--usb/dwc_otg.h25
1 files changed, 23 insertions, 2 deletions
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