summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVegard Storheil Eriksen <zyp@jvnv.net>2012-04-02 20:24:07 +0200
committerVegard Storheil Eriksen <zyp@jvnv.net>2012-04-02 20:24:07 +0200
commitb1b3b431ac499d850a9f44b5ed104ebbcefc3c58 (patch)
tree9ea643cf20bdb1e50abd7ce6b20685d5df74f2f2
parentc7b62aa051bd942bf5148a386dc852de1943c0cc (diff)
Moved usb initialization to usb thread.
-rw-r--r--main.cpp67
1 files changed, 34 insertions, 33 deletions
diff --git a/main.cpp b/main.cpp
index ce799d9..591d99b 100644
--- a/main.cpp
+++ b/main.cpp
@@ -193,36 +193,6 @@ void interrupt<(Interrupt::IRQ)77>() {
}
void usb_main() {
- while(1) {
- usb_process();
- Thread::yield();
- }
-}
-
-uint32_t usb_stack[1024];
-
-Thread usb_thread(usb_stack, sizeof(usb_stack), usb_main);
-
-int main() {
- // Initialize system timer.
- STK.LOAD = 168000000 / 8 / 1000; // 1000 Hz.
- STK.CTRL = 0x03;
-
- RCC.enable(RCC.GPIOA);
- RCC.enable(RCC.GPIOB);
- RCC.enable(RCC.GPIOC);
- RCC.enable(RCC.GPIOD);
-
- led_status.set_mode(Pin::Output);
- led_status.off();
- led_error.set_mode(Pin::Output);
- led_error.off();
-
- jtag_tdi.set_mode(Pin::Output);
- jtag_tms.set_mode(Pin::Output);
- jtag_tck.set_mode(Pin::Output);
- jtag_tdo.set_mode(Pin::Input);
-
usb_vbus.set_mode(Pin::Input);
usb_dm.set_mode(Pin::AF);
usb_dm.set_pull(Pin::PullNone);
@@ -248,19 +218,50 @@ int main() {
// USB configuration
OTG_HS.reg.GUSBCFG = (1 << 30) | (0xf << 10) | (0 << 9) | (0 << 8) | (1 << 6);
// FDMOD TRDT HNPCAP SRPCAP PHYSEL
-
+
// interrupt mask
OTG_HS.reg.GINTMSK = (1 << 13) | (1 << 12) | (1 << 11) | (1 << 10) | (1 << 3) | (1 << 2) | (1 << 1) | (1 << 4);
// ENUMDNEM USBRST USBSUSPM ESUSPM SOFM OTGINT MMISM
-
+
// device configuration
OTG_HS.dev_reg.DCFG = (1 << 2) | 3;
// NZLSOHSK DSPD
-
+
// core configuration
OTG_HS.reg.GCCFG = (1 << 19) | (1 << 16);
// VBUSBSEN PWRDWN
+
+ while(1) {
+ usb_process();
+ Thread::yield();
+ }
+}
+
+uint32_t usb_stack[1024];
+
+Thread usb_thread(usb_stack, sizeof(usb_stack), usb_main);
+
+int main() {
+ // Initialize system timer.
+ STK.LOAD = 168000000 / 8 / 1000; // 1000 Hz.
+ STK.CTRL = 0x03;
+
+ RCC.enable(RCC.GPIOA);
+ RCC.enable(RCC.GPIOB);
+ RCC.enable(RCC.GPIOC);
+ RCC.enable(RCC.GPIOD);
+
+ led_status.set_mode(Pin::Output);
+ led_status.off();
+ led_error.set_mode(Pin::Output);
+ led_error.off();
+
+ jtag_tdi.set_mode(Pin::Output);
+ jtag_tms.set_mode(Pin::Output);
+ jtag_tck.set_mode(Pin::Output);
+ jtag_tdo.set_mode(Pin::Input);
+
RCC.enable(RCC.I2C2);
I2C2.enable(i2c_scl, i2c_sda);