summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVegard Storheil Eriksen <zyp@jvnv.net>2012-01-21 19:22:56 +0100
committerVegard Storheil Eriksen <zyp@jvnv.net>2012-01-21 19:22:56 +0100
commit5f22ed065513388486c909d23dd48a4fee3e76ee (patch)
tree6eed3703677d0fb3fa00b739b561654c5ae37423
parent6a6342ac8b9919c116e10b5c4d315ecc88b1233f (diff)
Added USB register definitions.
-rw-r--r--hal/usb.h42
-rw-r--r--main.cpp4
2 files changed, 46 insertions, 0 deletions
diff --git a/hal/usb.h b/hal/usb.h
new file mode 100644
index 0000000..6fbd24f
--- /dev/null
+++ b/hal/usb.h
@@ -0,0 +1,42 @@
+#ifndef USB_H
+#define USB_H
+
+#include <stdint.h>
+
+struct USB_reg_t {
+ volatile uint32_t GOTGCTL;
+ volatile uint32_t GOTGINT;
+ volatile uint32_t GAHBCFG;
+ volatile uint32_t GUSBCFG;
+ volatile uint32_t GRSTCTL;
+ volatile uint32_t GINTSTS;
+ volatile uint32_t GINTMSK;
+ volatile uint32_t GRXSTSR;
+ volatile uint32_t GRXSTSP;
+ volatile uint32_t GRXFSIZ;
+ volatile uint32_t DIEPTXF0;
+ volatile uint32_t HNPTXSTS;
+ volatile uint32_t GCCFG;
+ volatile uint32_t CID;
+ uint32_t _reserved[49];
+ volatile uint32_t HPTXFSIZ;
+ volatile uint32_t DIEPTXF1;
+ volatile uint32_t DIEPTXF2;
+ volatile uint32_t DIEPTXF3;
+};
+
+class USB_t {
+ public:
+ USB_reg_t& reg;
+
+ USB_t(uint32_t reg_addr) : reg(*(USB_reg_t*)reg_addr) {}
+
+};
+
+#if defined(STM32F1)
+
+#elif defined(STM32F4)
+static USB_t OTG_FS(0x50000000);
+#endif
+
+#endif
diff --git a/main.cpp b/main.cpp
index 3b43d9d..807c0b0 100644
--- a/main.cpp
+++ b/main.cpp
@@ -6,6 +6,8 @@
#include "pin.h"
+#include "usb.h"
+
static Pin& led_green = PD12;
static Pin& led_yellow = PD13;
static Pin& led_red = PD14;
@@ -25,6 +27,8 @@ int main() {
led_red.set_mode(Pin::Output);
led_blue.set_mode(Pin::Output);
+ RCC.enable(RCC.OTGFS);
+
while(1) {
led_green.on();
Time::sleep(100);