aboutsummaryrefslogtreecommitdiffstats
path: root/src/stm32/usbfs.c
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2019-08-22 08:48:10 -0400
committerKevin O'Connor <kevin@koconnor.net>2019-08-22 09:58:58 -0400
commita44bc950a393644b1af6b2e83bdcfc265a852583 (patch)
tree4206108a19775824342634b5297bad2416c75bb6 /src/stm32/usbfs.c
parent2a2cf1f536f985330054cf47f47ec7d2455e35fa (diff)
downloadkutter-a44bc950a393644b1af6b2e83bdcfc265a852583.tar.gz
kutter-a44bc950a393644b1af6b2e83bdcfc265a852583.tar.xz
kutter-a44bc950a393644b1af6b2e83bdcfc265a852583.zip
stm32: Move irq handler code above irq setup
Only code movement. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'src/stm32/usbfs.c')
-rw-r--r--src/stm32/usbfs.c56
1 files changed, 28 insertions, 28 deletions
diff --git a/src/stm32/usbfs.c b/src/stm32/usbfs.c
index 929ec01b..a2706d31 100644
--- a/src/stm32/usbfs.c
+++ b/src/stm32/usbfs.c
@@ -233,34 +233,6 @@ usb_request_bootloader(void)
* Setup and interrupts
****************************************************************/
-DECL_CONSTANT_STR("RESERVE_PINS_USB", "PA11,PA12");
-
-// Initialize the usb controller
-void
-usb_init(void)
-{
- // Pull the D+ pin low briefly to signal a new connection
- gpio_out_setup(GPIO('A', 12), 0);
- udelay(5000);
- gpio_in_setup(GPIO('A', 12), 0);
-
- // Setup USB packet memory
- btable_configure();
-
- // Enable USB clock
- enable_pclock(USB_BASE);
-
- // Reset usb controller and enable interrupts
- USB->CNTR = USB_CNTR_FRES;
- USB->BTABLE = 0;
- USB->DADDR = 0;
- USB->CNTR = USB_CNTR_RESETM;
- USB->ISTR = 0;
- NVIC_SetPriority(USB_LP_CAN1_RX0_IRQn, 1);
- NVIC_EnableIRQ(USB_LP_CAN1_RX0_IRQn);
-}
-DECL_INIT(usb_init);
-
// Configure interface after a USB reset event
static void
usb_reset(void)
@@ -305,3 +277,31 @@ USB_LP_CAN1_RX0_IRQHandler(void)
usb_reset();
}
}
+
+DECL_CONSTANT_STR("RESERVE_PINS_USB", "PA11,PA12");
+
+// Initialize the usb controller
+void
+usb_init(void)
+{
+ // Pull the D+ pin low briefly to signal a new connection
+ gpio_out_setup(GPIO('A', 12), 0);
+ udelay(5000);
+ gpio_in_setup(GPIO('A', 12), 0);
+
+ // Setup USB packet memory
+ btable_configure();
+
+ // Enable USB clock
+ enable_pclock(USB_BASE);
+
+ // Reset usb controller and enable interrupts
+ USB->CNTR = USB_CNTR_FRES;
+ USB->BTABLE = 0;
+ USB->DADDR = 0;
+ USB->CNTR = USB_CNTR_RESETM;
+ USB->ISTR = 0;
+ NVIC_SetPriority(USB_LP_CAN1_RX0_IRQn, 1);
+ NVIC_EnableIRQ(USB_LP_CAN1_RX0_IRQn);
+}
+DECL_INIT(usb_init);