summaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorNathan Conrad <[email protected]>2019-09-09 19:20:26 -0400
committerNathan Conrad <[email protected]>2019-09-09 19:20:26 -0400
commitf7b0aeec523577d2ab5b3d486124979e093f5a45 (patch)
tree381eaa41e1c23566c772f75ffc75f947a7a883a3 /hw
parentd1976a30b3929911a99667625ebc332ea0745c16 (diff)
Start clock on F0 and F0, and handle USB interrupts.
Diffstat (limited to 'hw')
-rw-r--r--hw/bsp/stm32f070rbnucleo/board.mk2
-rw-r--r--hw/bsp/stm32f070rbnucleo/stm32f070rbnucleo.c8
-rw-r--r--hw/bsp/stm32f303disco/stm32f303disco.c29
3 files changed, 38 insertions, 1 deletions
diff --git a/hw/bsp/stm32f070rbnucleo/board.mk b/hw/bsp/stm32f070rbnucleo/board.mk
index 5206a6f91..a278b7b91 100644
--- a/hw/bsp/stm32f070rbnucleo/board.mk
+++ b/hw/bsp/stm32f070rbnucleo/board.mk
@@ -3,7 +3,7 @@ CFLAGS += \
-DSTM32F070xB \
-mthumb \
-mabi=aapcs-linux \
- -mcpu=cortex-m4 \
+ -mcpu=cortex-m0 \
-mfloat-abi=soft \
-nostdlib -nostartfiles \
-DCFG_TUSB_MCU=OPT_MCU_STM32_FSDEV
diff --git a/hw/bsp/stm32f070rbnucleo/stm32f070rbnucleo.c b/hw/bsp/stm32f070rbnucleo/stm32f070rbnucleo.c
index 8f864f739..9f3dd30dc 100644
--- a/hw/bsp/stm32f070rbnucleo/stm32f070rbnucleo.c
+++ b/hw/bsp/stm32f070rbnucleo/stm32f070rbnucleo.c
@@ -91,6 +91,14 @@ void board_init(void)
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
HAL_GPIO_Init(BUTTON_PORT, &GPIO_InitStruct);
+ // Start USB clock
+ __HAL_RCC_USB_CLK_ENABLE();
+}
+
+void dcd_fs_irqHandler(void);
+void USB_IRQHandler(void)
+{
+ dcd_fs_irqHandler();
}
//--------------------------------------------------------------------+
diff --git a/hw/bsp/stm32f303disco/stm32f303disco.c b/hw/bsp/stm32f303disco/stm32f303disco.c
index 45ba7a4f9..e8a647a99 100644
--- a/hw/bsp/stm32f303disco/stm32f303disco.c
+++ b/hw/bsp/stm32f303disco/stm32f303disco.c
@@ -86,6 +86,10 @@ void board_init(void)
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
HAL_GPIO_Init(BUTTON_PORT, &GPIO_InitStruct);
+
+ // Start USB clock
+ __HAL_RCC_USB_CLK_ENABLE();
+
#if 0
RCC->AHB2ENR |= RCC_AHB2ENR_OTGFSEN;
@@ -105,6 +109,31 @@ void board_init(void)
#endif
}
+// USB defaults to using interrupts 19, 20, and 42 (based on SYSCFG_CFGR1.USB_IT_RMP)
+// FIXME: Do all three need to be handled, or just the LP one?
+void dcd_fs_irqHandler(void);
+// USB high-priority interrupt (Channel 19): Triggered only by a correct
+// transfer event for isochronous and double-buffer bulk transfer to reach
+// the highest possible transfer rate.
+void USB_HP_CAN_TX_IRQHandler(void)
+{
+ dcd_fs_irqHandler();
+}
+
+// USB low-priority interrupt (Channel 20): Triggered by all USB events
+// (Correct transfer, USB reset, etc.). The firmware has to check the
+// interrupt source before serving the interrupt.
+void USB_LP_CAN_RX0_IRQHandler(void)
+{
+ dcd_fs_irqHandler();
+}
+// USB wakeup interrupt (Channel 42): Triggered by the wakeup event from the USB
+// Suspend mode.
+void USBWakeUp_IRQHandler(void)
+{
+ dcd_fs_irqHandler();
+}
+
//--------------------------------------------------------------------+
// Board porting API
//--------------------------------------------------------------------+