From 0673be772475671c34a88f4fc2c16d2055dcc682 Mon Sep 17 00:00:00 2001 From: hathach Date: Wed, 2 Oct 2019 12:01:34 +0700 Subject: ported stm32f1, tested with f103 blue pill --- src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c | 17 +++++++++++++++-- src/portable/st/stm32_fsdev/dcd_stm32_fsdev_pvt_st.h | 4 +++- 2 files changed, 18 insertions(+), 3 deletions(-) (limited to 'src/portable') diff --git a/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c b/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c index 9debef2ae..a705694b6 100644 --- a/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c +++ b/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c @@ -259,6 +259,12 @@ void dcd_int_enable (uint8_t rhport) NVIC_EnableIRQ(USB_HP_CAN_TX_IRQn); NVIC_EnableIRQ(USB_LP_CAN_RX0_IRQn); NVIC_EnableIRQ(USBWakeUp_IRQn); +#elif CFG_TUSB_MCU == OPT_MCU_STM32F1 + NVIC_EnableIRQ(USB_HP_CAN1_TX_IRQn); + NVIC_EnableIRQ(USB_LP_CAN1_RX0_IRQn); + NVIC_EnableIRQ(USBWakeUp_IRQn); +#else + #error Unknown arch in USB driver #endif } @@ -273,9 +279,14 @@ void dcd_int_disable(uint8_t rhport) NVIC_DisableIRQ(USB_HP_CAN_TX_IRQn); NVIC_DisableIRQ(USB_LP_CAN_RX0_IRQn); NVIC_DisableIRQ(USBWakeUp_IRQn); +#elif CFG_TUSB_MCU == OPT_MCU_STM32F1 + NVIC_DisableIRQ(USB_HP_CAN1_TX_IRQn); + NVIC_DisableIRQ(USB_LP_CAN1_RX0_IRQn); + NVIC_DisableIRQ(USBWakeUp_IRQn); #else #error Unknown arch in USB driver #endif + // I'm not convinced that memory synchronization is completely necessary, but // it isn't a bad idea. __DSB(); @@ -821,7 +832,7 @@ void USB_IRQHandler(void) dcd_fs_irqHandler(); } -#elif (CFG_TUSB_MCU) == (OPT_MCU_STM32F1) +#elif CFG_TUSB_MCU == OPT_MCU_STM32F1 void USB_HP_IRQHandler(void) { dcd_fs_irqHandler(); @@ -853,14 +864,16 @@ 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(); } + #else -#error Which IRQ handler do you need? + #error Which IRQ handler do you need? #endif #endif diff --git a/src/portable/st/stm32_fsdev/dcd_stm32_fsdev_pvt_st.h b/src/portable/st/stm32_fsdev/dcd_stm32_fsdev_pvt_st.h index bbaa52eae..36dca8cd8 100644 --- a/src/portable/st/stm32_fsdev/dcd_stm32_fsdev_pvt_st.h +++ b/src/portable/st/stm32_fsdev/dcd_stm32_fsdev_pvt_st.h @@ -57,7 +57,9 @@ #define PMA_LENGTH (512u) // NO internal Pull-ups // *B, and *C: 2 x 16 bits/word - #error The F102/F103 driver is expected not to work, but it might? Try it? + + // F1 names this differently from the rest + #define USB_CNTR_LPMODE USB_CNTR_LP_MODE #elif defined(STM32F302xB) || defined(STM32F302xC) || \ defined(STM32F303xB) || defined(STM32F303xC) || \ -- cgit v1.3.1