summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Bergli Heier <snakebite@jvnv.net>2012-01-22 15:01:57 +0100
committerJon Bergli Heier <snakebite@jvnv.net>2012-01-22 15:01:57 +0100
commite684c845fe3a76136af497f11daf4b666007f7f0 (patch)
treebffea325ea18d7ac86afc9d56fa2dc6836503b9c
parent5fd6f9224700bf960941c00cc07370b0bc1a0632 (diff)
Set some flags on USB reset.
-rw-r--r--hal/usb.h4
-rw-r--r--main.cpp12
2 files changed, 13 insertions, 3 deletions
diff --git a/hal/usb.h b/hal/usb.h
index 9dc327a..14a5440 100644
--- a/hal/usb.h
+++ b/hal/usb.h
@@ -65,8 +65,8 @@ class USB_t {
public:
USB_reg_t& reg;
USB_dev_reg_t& dev_reg;
- USB_dev_iep_reg_t const* dev_iep_reg;
- USB_dev_oep_reg_t const* dev_oep_reg;
+ USB_dev_iep_reg_t * const dev_iep_reg;
+ USB_dev_oep_reg_t * const dev_oep_reg;
USB_t(uint32_t reg_addr) :
reg(*(USB_reg_t*)reg_addr),
diff --git a/main.cpp b/main.cpp
index 2fafeb6..e56c435 100644
--- a/main.cpp
+++ b/main.cpp
@@ -21,6 +21,16 @@ template<>
void interrupt<(Interrupt::IRQ)67>() {
led_blue.toggle();
led_red.toggle();
+
+ if(OTG_FS.reg.GINTSTS & (1 << 12)) {
+ led_yellow.toggle();
+ OTG_FS.dev_oep_reg[0].DOEPCTL = (1 << 27);
+ OTG_FS.dev_reg.DAINTMSK = (1 << 16) | 1;
+ OTG_FS.dev_reg.DOEPMSK = (1 << 3) | 1;
+ OTG_FS.dev_reg.DIEPEMPMSK = (1 << 3) | 1;
+ OTG_FS.reg.GRXFSIZ = 256;
+ OTG_FS.dev_oep_reg[0].DOEPTSIZ = (3 << 29);
+ }
OTG_FS.reg.GINTSTS = 0xffffffff;
}
@@ -56,7 +66,7 @@ int main() {
OTG_FS.reg.GAHBCFG = 1;
// USB configuration
- OTG_FS.reg.GUSBCFG = (1 << 30) | (0xf << 10) | (1 << 9) | (1 << 8);
+ OTG_FS.reg.GUSBCFG = (1 << 30) | (0xf << 10) | (0 << 9) | (0 << 8);
// FDMOD TRDT HNPCAP SRPCAP
// interrupt mask