summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVegard Storheil Eriksen <zyp@jvnv.net>2012-04-22 23:11:16 +0200
committerVegard Storheil Eriksen <zyp@jvnv.net>2012-04-22 23:11:16 +0200
commit79d7eb698ca00ca433f4a3cbea94475ce84e8a4e (patch)
treec8aefc87faf075e141bdff504f5feeeb5c8246a7
parenta75f2ed11d49f6db8da08fd01d66bcb2ca2f7fcf (diff)
Enabling IN endpoint on SET_CONFIGURATION.
-rw-r--r--main.cpp25
1 files changed, 23 insertions, 2 deletions
diff --git a/main.cpp b/main.cpp
index ca9237f..656e82d 100644
--- a/main.cpp
+++ b/main.cpp
@@ -52,6 +52,10 @@ void usb_write(uint32_t ep, uint32_t* bufp, uint32_t len) {
}
}
+bool usb_ep_ready(uint32_t ep) {
+ return (OTG_HS.dev_iep_reg[1].DIEPCTL & 0x80008000) == 0x8000;
+}
+
uint8_t dev_desc[] = {
0x12, 0x01, 0x00, 0x02, 0xff, 0x00, 0x00, 0x40, 0x34, 0x12, 0x78, 0x56, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
};
@@ -82,8 +86,17 @@ bool set_address(uint16_t wValue, uint16_t wIndex, uint16_t wLength) {
}
bool set_configuration(uint16_t wValue, uint16_t wIndex, uint16_t wLength) {
- if(wValue > 1) {
- return false;
+ switch(wValue) {
+ case 0:
+ OTG_HS.dev_iep_reg[1].DIEPCTL = 0;
+ break;
+
+ case 1:
+ OTG_HS.dev_iep_reg[1].DIEPCTL = (2 << 18) | (1 << 15) | 64;
+ break;
+
+ default:
+ return false;
}
usb_write(0, 0, 0);
@@ -192,6 +205,7 @@ void usb_process() {
OTG_HS.dev_reg.DIEPEMPMSK = (1 << 3) | 1;
OTG_HS.reg.GRXFSIZ = 256;
OTG_HS.reg.DIEPTXF0 = (64 << 16) | 256;
+ OTG_HS.reg.DIEPTXF1 = (64 << 16) | 320;
OTG_HS.dev_oep_reg[0].DOEPTSIZ = (3 << 29);
}
@@ -293,5 +307,12 @@ int main() {
while(1) {
led_error.toggle();
Time::sleep(100);
+
+ int16_t buf[] = {
+ };
+
+ if(usb_ep_ready(1)) {
+ usb_write(1, (uint32_t*)buf, sizeof(buf));
+ }
}
}