Skip to content

Commit e275976

Browse files
author
Jan Kamidra
committed
initial USB modification
1 parent b5fbee4 commit e275976

File tree

4 files changed

+17
-12
lines changed

4 files changed

+17
-12
lines changed

targets/TARGET_STM/TARGET_STM32U0/PeripheralNames.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,7 @@ typedef enum {
124124
} PWMName;
125125

126126
typedef enum {
127-
#if defined USB_DRD_FS_BASE
128-
USB_FS = (int)USB_DRD_FS_BASE
129-
#else
130127
USB_FS = (int)USB_DRD_BASE
131-
#endif
132128
} USBName;
133129

134130

targets/TARGET_STM/USBPhyHw.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
#if !defined(MBED_CONF_TARGET_USB_SPEED)
3333

34-
#if defined (USB)
34+
#if defined (USB) || defined(USB_DRD_FS)
3535
#define MBED_CONF_TARGET_USB_SPEED USE_USB_NO_OTG
3636
#elif defined(USB_OTG_FS)
3737
#define MBED_CONF_TARGET_USB_SPEED USE_USB_OTG_FS
@@ -49,17 +49,17 @@
4949
#define USBHAL_IRQn USB_LP_CAN_RX0_IRQn
5050
#elif defined(TARGET_STM32L5)
5151
#define USBHAL_IRQn USB_FS_IRQn
52+
#elif defined(TARGET_STM32U0)
53+
#define USBHAL_IRQn USB_DRD_FS_IRQn
5254
#else
5355
#define USBHAL_IRQn USB_IRQn
54-
#endif
56+
#endif /* #if defined(TARGET_STM32F1) | */
5557

5658
#elif (MBED_CONF_TARGET_USB_SPEED == USE_USB_OTG_FS)
5759
#define USBHAL_IRQn OTG_FS_IRQn
58-
5960
#else
6061
#define USBHAL_IRQn OTG_HS_IRQn
61-
62-
#endif
62+
#endif /* #if MBED_CONF_TARGET_USB_SPEED == USE_USB_NO_OTG */
6363

6464
#define NB_ENDPOINT 8
6565

targets/TARGET_STM/USBPhy_STM32.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ void USBPhyHw::init(USBPhyEvents *events)
243243
#if (MBED_CONF_TARGET_USB_SPEED == USE_USB_OTG_HS)
244244
hpcd.Instance = USB_OTG_HS;
245245
hpcd.Init.phy_itface = PCD_PHY_ULPI;
246-
hpcd.Init.Sof_enable = 1;
246+
hpcd.Init.Sof_enable = ENABLE;
247247
hpcd.Init.dma_enable = DISABLE;
248248
hpcd.Init.vbus_sensing_enable = ENABLE;
249249
hpcd.Init.use_external_vbus = DISABLE;
@@ -287,7 +287,7 @@ void USBPhyHw::init(USBPhyEvents *events)
287287
#elif (MBED_CONF_TARGET_USB_SPEED == USE_USB_OTG_FS)
288288
hpcd.Instance = USB_OTG_FS;
289289
hpcd.Init.phy_itface = PCD_PHY_EMBEDDED;
290-
hpcd.Init.Sof_enable = 1;
290+
hpcd.Init.Sof_enable = ENABLE;
291291
hpcd.Init.speed = PCD_SPEED_FULL;
292292

293293
__HAL_RCC_USB_OTG_FS_CLK_ENABLE();
@@ -302,7 +302,12 @@ void USBPhyHw::init(USBPhyEvents *events)
302302
map = PinMap_USB_FS;
303303

304304
#elif (MBED_CONF_TARGET_USB_SPEED == USE_USB_NO_OTG)
305+
#if defined(USB_DRD_FS)
306+
hpcd.Instance = USB_DRD_FS;
307+
hpcd.Init.Sof_enable = ENABLE;
308+
#else
305309
hpcd.Instance = USB;
310+
#endif
306311
hpcd.Init.phy_itface = PCD_PHY_EMBEDDED;
307312
hpcd.Init.speed = PCD_SPEED_FULL;
308313

targets/targets.json5

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4786,6 +4786,10 @@ mode is recommended for target MCUs with small amounts of flash and RAM.",
47864786
"i2c_timing_value_algo": {
47874787
"help": "If value was set to true I2C timing algorithm is enabled. Enabling may leads to performance issue. Keeping this false and changing system clock will trigger assert.)",
47884788
"value": false
4789+
},
4790+
"usb_speed": {
4791+
"help": "USE_USB_OTG_FS or USE_USB_OTG_HS or USE_USB_HS_IN_FS",
4792+
"value": "USE_USB_NO_OTG"
47894793
}
47904794
},
47914795
"overrides": {
@@ -4798,7 +4802,7 @@ mode is recommended for target MCUs with small amounts of flash and RAM.",
47984802
"MPU",
47994803
"ANALOGOUT",
48004804
"TRNG",
4801-
"USB"
4805+
"USBDEVICE"
48024806
],
48034807
"is_mcu_family_target": true
48044808
},

0 commit comments

Comments
 (0)