diff options
Diffstat (limited to 'main.cpp')
-rw-r--r-- | main.cpp | 67 |
1 files changed, 34 insertions, 33 deletions
@@ -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); |