summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhathach <[email protected]>2026-03-16 22:59:24 +0700
committerhathach <[email protected]>2026-03-16 22:59:24 +0700
commitd63f11dbdae5da68338f78708af93ece20254d50 (patch)
tree5936ac013a3bc8b0ccde51cd9acea2d586ac9046
parent741132948b10d2410692b46b227da194fefb7238 (diff)
clean up fsdev symbols
-rw-r--r--src/common/tusb_mcu.h2
-rw-r--r--src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c14
-rw-r--r--src/portable/st/stm32_fsdev/fsdev_stm32.h73
3 files changed, 28 insertions, 61 deletions
diff --git a/src/common/tusb_mcu.h b/src/common/tusb_mcu.h
index edc7ecc3e..34dd6af8d 100644
--- a/src/common/tusb_mcu.h
+++ b/src/common/tusb_mcu.h
@@ -241,9 +241,11 @@
#if defined(STM32F302xB) || defined(STM32F302xC) || defined(STM32F303xB) || defined(STM32F303xC) || \
defined(STM32F373xC)
+ // xB, and xC: 512
#define CFG_TUSB_FSDEV_PMA_SIZE 512u
#elif defined(STM32F302x6) || defined(STM32F302x8) || defined(STM32F302xD) || defined(STM32F302xE) || \
defined(STM32F303xD) || defined(STM32F303xE)
+ // x6, x8, xD, and xE: 1024 + LPM Support
#define CFG_TUSB_FSDEV_PMA_SIZE 1024u
#else
#error "Unsupported STM32F3 mcu"
diff --git a/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c b/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c
index c06911177..13d1a6cb4 100644
--- a/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c
+++ b/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c
@@ -59,7 +59,6 @@
* - Enable USB clock; Perhaps use __HAL_RCC_USB_CLK_ENABLE();
* - (Optionally configure GPIO HAL to tell it the USB driver is using the USB pins)
* - call tusb_init();
- * - periodically call tusb_task();
*
* Assumptions of the driver:
* - You are not using CAN (it must share the packet buffer)
@@ -87,19 +86,6 @@
* below functions could be adjusting the wrong interrupts (if they had been reconfigured)
* - LPM is not used correctly, or at all?
*
- * USB documentation and Reference implementations
- * - STM32 Reference manuals
- * - STM32 USB Hardware Guidelines AN4879
- *
- * - STM32 HAL (much of this driver is based on this)
- * - libopencm3/lib/stm32/common/st_usbfs_core.c
- * - Keil USB Device http://www.keil.com/pack/doc/mw/USB/html/group__usbd.html
- *
- * - YouTube OpenTechLab 011; https://www.youtube.com/watch?v=4FOkJLp_PUw
- *
- * Advantages over HAL driver:
- * - Tiny (saves RAM, assumes a single USB peripheral)
- *
* Notes:
* - The buffer table is allocated as endpoints are opened. The allocation is only
* cleared when the device is reset. This may be bad if the USB device needs
diff --git a/src/portable/st/stm32_fsdev/fsdev_stm32.h b/src/portable/st/stm32_fsdev/fsdev_stm32.h
index 3bb137734..a63592c5d 100644
--- a/src/portable/st/stm32_fsdev/fsdev_stm32.h
+++ b/src/portable/st/stm32_fsdev/fsdev_stm32.h
@@ -38,7 +38,6 @@
#elif CFG_TUSB_MCU == OPT_MCU_STM32F0
#include "stm32f0xx.h"
- #define FSDEV_REG_BASE USB_BASE
#define FSDEV_HAS_SBUF_ISO 0
// F0x2 models are crystal-less
// All have internal D+ pull-up
@@ -51,21 +50,24 @@
// NO internal Pull-ups
// *B, and *C: 2 x 16 bits/word
-#elif defined(STM32F302xB) || defined(STM32F302xC) || defined(STM32F303xB) || defined(STM32F303xC) || \
- defined(STM32F373xC)
+#elif CFG_TUSB_MCU == OPT_MCU_STM32F3
#include "stm32f3xx.h"
#define FSDEV_HAS_SBUF_ISO 0
- // NO internal Pull-ups
- // *B, and *C: 1 x 16 bits/word
- // PMA dedicated to USB (no sharing with CAN)
+ // NO internal Pull-ups. PMA dedicated to USB (no sharing with CAN)
+ // xB, and xC: 512 bytes
+ // x6, x8, xD, and xE: 1024 bytes + LPM Support. When CAN clock is enabled, USB can use the first 768 bytes ONLY.
-#elif defined(STM32F302x6) || defined(STM32F302x8) || defined(STM32F302xD) || defined(STM32F302xE) || \
- defined(STM32F303xD) || defined(STM32F303xE)
- #include "stm32f3xx.h"
+#elif CFG_TUSB_MCU == OPT_MCU_STM32G0
+ #include "stm32g0xx.h"
+ #define FSDEV_HAS_SBUF_ISO 1
+
+#elif CFG_TUSB_MCU == OPT_MCU_STM32G4
+ #include "stm32g4xx.h"
#define FSDEV_HAS_SBUF_ISO 0
- // NO internal Pull-ups
- // *6, *8, *D, and *E: 2 x 16 bits/word LPM Support
- // When CAN clock is enabled, USB can use first 768 bytes ONLY.
+
+#elif CFG_TUSB_MCU == OPT_MCU_STM32H5
+ #include "stm32h5xx.h"
+ #define FSDEV_HAS_SBUF_ISO 1
#elif CFG_TUSB_MCU == OPT_MCU_STM32L0
#include "stm32l0xx.h"
@@ -87,25 +89,13 @@
#define USB_PMAADDR (USB_BASE + (USB_PMAADDR_NS - USB_BASE_NS))
#endif
-#elif CFG_TUSB_MCU == OPT_MCU_STM32G0
- #include "stm32g0xx.h"
- #define FSDEV_HAS_SBUF_ISO 1
-
-#elif CFG_TUSB_MCU == OPT_MCU_STM32G4
- #include "stm32g4xx.h"
- #define FSDEV_HAS_SBUF_ISO 0
-
-#elif CFG_TUSB_MCU == OPT_MCU_STM32H5
- #include "stm32h5xx.h"
- #define FSDEV_HAS_SBUF_ISO 1
-
#elif CFG_TUSB_MCU == OPT_MCU_STM32U0
#include "stm32u0xx.h"
#define FSDEV_HAS_SBUF_ISO 1
#elif CFG_TUSB_MCU == OPT_MCU_STM32U3
#include "stm32u3xx.h"
- #define FSDEV_HAS_SBUF_ISO 1 // This is assumed to work but has not been tested...
+ #define FSDEV_HAS_SBUF_ISO 1
#elif CFG_TUSB_MCU == OPT_MCU_STM32U5
#include "stm32u5xx.h"
@@ -114,8 +104,6 @@
#elif CFG_TUSB_MCU == OPT_MCU_STM32WB
#include "stm32wbxx.h"
#define FSDEV_HAS_SBUF_ISO 0
- /* ST provided header has incorrect value of USB_PMAADDR */
- #define FSDEV_PMA_BASE USB1_PMAADDR
#else
#error You are using an untested or unimplemented STM32 variant. Please update the driver.
@@ -185,42 +173,33 @@
#endif
static const IRQn_Type fsdev_irq[] = {
- #if TU_CHECK_MCU(OPT_MCU_STM32F0, OPT_MCU_STM32L0, OPT_MCU_STM32L4)
+ #if TU_CHECK_MCU(OPT_MCU_STM32F0, OPT_MCU_STM32L0, OPT_MCU_STM32L4, OPT_MCU_STM32U5)
+ USB_IRQn,
+ #elif TU_CHECK_MCU(OPT_MCU_STM32L5, OPT_MCU_STM32U3)
+ USB_FS_IRQn,
+ #elif TU_CHECK_MCU(OPT_MCU_STM32C0, OPT_MCU_STM32H5, OPT_MCU_STM32U0)
+ USB_DRD_FS_IRQn,
+ #elif CFG_TUSB_MCU == OPT_MCU_STM32G0
+ #ifdef STM32G0B0xx
USB_IRQn,
+ #else
+ USB_UCPD1_2_IRQn,
+ #endif
#elif CFG_TUSB_MCU == OPT_MCU_STM32F1
USB_HP_CAN1_TX_IRQn,
USB_LP_CAN1_RX0_IRQn,
USBWakeUp_IRQn,
#elif CFG_TUSB_MCU == OPT_MCU_STM32F3
- // USB remap handles dcd functions
USB_HP_CAN_TX_IRQn,
USB_LP_CAN_RX0_IRQn,
USBWakeUp_IRQn,
- #elif CFG_TUSB_MCU == OPT_MCU_STM32G0
- #ifdef STM32G0B0xx
- USB_IRQn,
- #else
- USB_UCPD1_2_IRQn,
- #endif
- #elif CFG_TUSB_MCU == OPT_MCU_STM32C0
- USB_DRD_FS_IRQn,
#elif TU_CHECK_MCU(OPT_MCU_STM32G4, OPT_MCU_STM32L1)
USB_HP_IRQn,
USB_LP_IRQn,
USBWakeUp_IRQn,
- #elif CFG_TUSB_MCU == OPT_MCU_STM32H5
- USB_DRD_FS_IRQn,
- #elif CFG_TUSB_MCU == OPT_MCU_STM32L5
- USB_FS_IRQn,
#elif CFG_TUSB_MCU == OPT_MCU_STM32WB
USB_HP_IRQn,
USB_LP_IRQn,
- #elif CFG_TUSB_MCU == OPT_MCU_STM32U5
- USB_IRQn,
- #elif CFG_TUSB_MCU == OPT_MCU_STM32U0
- USB_DRD_FS_IRQn,
- #elif CFG_TUSB_MCU == OPT_MCU_STM32U3
- USB_FS_IRQn,
#else
#error Unknown arch in USB driver
#endif