Skip to content

Commit d63f11d

Browse files
committed
clean up fsdev symbols
1 parent 7411329 commit d63f11d

File tree

3 files changed

+28
-61
lines changed

3 files changed

+28
-61
lines changed

src/common/tusb_mcu.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,9 +241,11 @@
241241

242242
#if defined(STM32F302xB) || defined(STM32F302xC) || defined(STM32F303xB) || defined(STM32F303xC) || \
243243
defined(STM32F373xC)
244+
// xB, and xC: 512
244245
#define CFG_TUSB_FSDEV_PMA_SIZE 512u
245246
#elif defined(STM32F302x6) || defined(STM32F302x8) || defined(STM32F302xD) || defined(STM32F302xE) || \
246247
defined(STM32F303xD) || defined(STM32F303xE)
248+
// x6, x8, xD, and xE: 1024 + LPM Support
247249
#define CFG_TUSB_FSDEV_PMA_SIZE 1024u
248250
#else
249251
#error "Unsupported STM32F3 mcu"

src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@
5959
* - Enable USB clock; Perhaps use __HAL_RCC_USB_CLK_ENABLE();
6060
* - (Optionally configure GPIO HAL to tell it the USB driver is using the USB pins)
6161
* - call tusb_init();
62-
* - periodically call tusb_task();
6362
*
6463
* Assumptions of the driver:
6564
* - You are not using CAN (it must share the packet buffer)
@@ -87,19 +86,6 @@
8786
* below functions could be adjusting the wrong interrupts (if they had been reconfigured)
8887
* - LPM is not used correctly, or at all?
8988
*
90-
* USB documentation and Reference implementations
91-
* - STM32 Reference manuals
92-
* - STM32 USB Hardware Guidelines AN4879
93-
*
94-
* - STM32 HAL (much of this driver is based on this)
95-
* - libopencm3/lib/stm32/common/st_usbfs_core.c
96-
* - Keil USB Device http://www.keil.com/pack/doc/mw/USB/html/group__usbd.html
97-
*
98-
* - YouTube OpenTechLab 011; https://www.youtube.com/watch?v=4FOkJLp_PUw
99-
*
100-
* Advantages over HAL driver:
101-
* - Tiny (saves RAM, assumes a single USB peripheral)
102-
*
10389
* Notes:
10490
* - The buffer table is allocated as endpoints are opened. The allocation is only
10591
* cleared when the device is reset. This may be bad if the USB device needs

src/portable/st/stm32_fsdev/fsdev_stm32.h

Lines changed: 26 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838

3939
#elif CFG_TUSB_MCU == OPT_MCU_STM32F0
4040
#include "stm32f0xx.h"
41-
#define FSDEV_REG_BASE USB_BASE
4241
#define FSDEV_HAS_SBUF_ISO 0
4342
// F0x2 models are crystal-less
4443
// All have internal D+ pull-up
@@ -51,21 +50,24 @@
5150
// NO internal Pull-ups
5251
// *B, and *C: 2 x 16 bits/word
5352

54-
#elif defined(STM32F302xB) || defined(STM32F302xC) || defined(STM32F303xB) || defined(STM32F303xC) || \
55-
defined(STM32F373xC)
53+
#elif CFG_TUSB_MCU == OPT_MCU_STM32F3
5654
#include "stm32f3xx.h"
5755
#define FSDEV_HAS_SBUF_ISO 0
58-
// NO internal Pull-ups
59-
// *B, and *C: 1 x 16 bits/word
60-
// PMA dedicated to USB (no sharing with CAN)
56+
// NO internal Pull-ups. PMA dedicated to USB (no sharing with CAN)
57+
// xB, and xC: 512 bytes
58+
// x6, x8, xD, and xE: 1024 bytes + LPM Support. When CAN clock is enabled, USB can use the first 768 bytes ONLY.
6159

62-
#elif defined(STM32F302x6) || defined(STM32F302x8) || defined(STM32F302xD) || defined(STM32F302xE) || \
63-
defined(STM32F303xD) || defined(STM32F303xE)
64-
#include "stm32f3xx.h"
60+
#elif CFG_TUSB_MCU == OPT_MCU_STM32G0
61+
#include "stm32g0xx.h"
62+
#define FSDEV_HAS_SBUF_ISO 1
63+
64+
#elif CFG_TUSB_MCU == OPT_MCU_STM32G4
65+
#include "stm32g4xx.h"
6566
#define FSDEV_HAS_SBUF_ISO 0
66-
// NO internal Pull-ups
67-
// *6, *8, *D, and *E: 2 x 16 bits/word LPM Support
68-
// When CAN clock is enabled, USB can use first 768 bytes ONLY.
67+
68+
#elif CFG_TUSB_MCU == OPT_MCU_STM32H5
69+
#include "stm32h5xx.h"
70+
#define FSDEV_HAS_SBUF_ISO 1
6971

7072
#elif CFG_TUSB_MCU == OPT_MCU_STM32L0
7173
#include "stm32l0xx.h"
@@ -87,25 +89,13 @@
8789
#define USB_PMAADDR (USB_BASE + (USB_PMAADDR_NS - USB_BASE_NS))
8890
#endif
8991

90-
#elif CFG_TUSB_MCU == OPT_MCU_STM32G0
91-
#include "stm32g0xx.h"
92-
#define FSDEV_HAS_SBUF_ISO 1
93-
94-
#elif CFG_TUSB_MCU == OPT_MCU_STM32G4
95-
#include "stm32g4xx.h"
96-
#define FSDEV_HAS_SBUF_ISO 0
97-
98-
#elif CFG_TUSB_MCU == OPT_MCU_STM32H5
99-
#include "stm32h5xx.h"
100-
#define FSDEV_HAS_SBUF_ISO 1
101-
10292
#elif CFG_TUSB_MCU == OPT_MCU_STM32U0
10393
#include "stm32u0xx.h"
10494
#define FSDEV_HAS_SBUF_ISO 1
10595

10696
#elif CFG_TUSB_MCU == OPT_MCU_STM32U3
10797
#include "stm32u3xx.h"
108-
#define FSDEV_HAS_SBUF_ISO 1 // This is assumed to work but has not been tested...
98+
#define FSDEV_HAS_SBUF_ISO 1
10999

110100
#elif CFG_TUSB_MCU == OPT_MCU_STM32U5
111101
#include "stm32u5xx.h"
@@ -114,8 +104,6 @@
114104
#elif CFG_TUSB_MCU == OPT_MCU_STM32WB
115105
#include "stm32wbxx.h"
116106
#define FSDEV_HAS_SBUF_ISO 0
117-
/* ST provided header has incorrect value of USB_PMAADDR */
118-
#define FSDEV_PMA_BASE USB1_PMAADDR
119107

120108
#else
121109
#error You are using an untested or unimplemented STM32 variant. Please update the driver.
@@ -185,42 +173,33 @@
185173
#endif
186174

187175
static const IRQn_Type fsdev_irq[] = {
188-
#if TU_CHECK_MCU(OPT_MCU_STM32F0, OPT_MCU_STM32L0, OPT_MCU_STM32L4)
176+
#if TU_CHECK_MCU(OPT_MCU_STM32F0, OPT_MCU_STM32L0, OPT_MCU_STM32L4, OPT_MCU_STM32U5)
177+
USB_IRQn,
178+
#elif TU_CHECK_MCU(OPT_MCU_STM32L5, OPT_MCU_STM32U3)
179+
USB_FS_IRQn,
180+
#elif TU_CHECK_MCU(OPT_MCU_STM32C0, OPT_MCU_STM32H5, OPT_MCU_STM32U0)
181+
USB_DRD_FS_IRQn,
182+
#elif CFG_TUSB_MCU == OPT_MCU_STM32G0
183+
#ifdef STM32G0B0xx
189184
USB_IRQn,
185+
#else
186+
USB_UCPD1_2_IRQn,
187+
#endif
190188
#elif CFG_TUSB_MCU == OPT_MCU_STM32F1
191189
USB_HP_CAN1_TX_IRQn,
192190
USB_LP_CAN1_RX0_IRQn,
193191
USBWakeUp_IRQn,
194192
#elif CFG_TUSB_MCU == OPT_MCU_STM32F3
195-
// USB remap handles dcd functions
196193
USB_HP_CAN_TX_IRQn,
197194
USB_LP_CAN_RX0_IRQn,
198195
USBWakeUp_IRQn,
199-
#elif CFG_TUSB_MCU == OPT_MCU_STM32G0
200-
#ifdef STM32G0B0xx
201-
USB_IRQn,
202-
#else
203-
USB_UCPD1_2_IRQn,
204-
#endif
205-
#elif CFG_TUSB_MCU == OPT_MCU_STM32C0
206-
USB_DRD_FS_IRQn,
207196
#elif TU_CHECK_MCU(OPT_MCU_STM32G4, OPT_MCU_STM32L1)
208197
USB_HP_IRQn,
209198
USB_LP_IRQn,
210199
USBWakeUp_IRQn,
211-
#elif CFG_TUSB_MCU == OPT_MCU_STM32H5
212-
USB_DRD_FS_IRQn,
213-
#elif CFG_TUSB_MCU == OPT_MCU_STM32L5
214-
USB_FS_IRQn,
215200
#elif CFG_TUSB_MCU == OPT_MCU_STM32WB
216201
USB_HP_IRQn,
217202
USB_LP_IRQn,
218-
#elif CFG_TUSB_MCU == OPT_MCU_STM32U5
219-
USB_IRQn,
220-
#elif CFG_TUSB_MCU == OPT_MCU_STM32U0
221-
USB_DRD_FS_IRQn,
222-
#elif CFG_TUSB_MCU == OPT_MCU_STM32U3
223-
USB_FS_IRQn,
224203
#else
225204
#error Unknown arch in USB driver
226205
#endif

0 commit comments

Comments
 (0)