Skip to content

Commit 7fc68de

Browse files
ABOSTMfpistm
authored andcommitted
cores(U5): support USB Type-C on U5
Only USB legacy on Type-C, no UCPD. Hardening of TCPP default legacy state, which applies to U5 as well as L5 series. Signed-off-by: Alexandre Bourdiol <[email protected]>
1 parent 29d4caa commit 7fc68de

File tree

5 files changed

+21
-2
lines changed

5 files changed

+21
-2
lines changed

cores/arduino/stm32/usb/usbd_conf.c

+7
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,13 @@ PCD_HandleTypeDef g_hpcd;
5151
void HAL_PCD_MspInit(PCD_HandleTypeDef *hpcd)
5252
{
5353
const PinMap *map = NULL;
54+
55+
#if defined(PIN_UCPD_TCPP)
56+
/* Set TCPP default state: Type-C legacy */
57+
pinMode(PIN_UCPD_TCPP, OUTPUT_OPEN_DRAIN);
58+
digitalWriteFast(digitalPinToPinName(PIN_UCPD_TCPP), LOW);
59+
#endif
60+
5461
#if defined(PWR_CR2_USV) || defined(PWR_SVMCR_USV)
5562
/* Enable VDDUSB on Pwrctrl CR2 register*/
5663
HAL_PWREx_EnableVddUSB();

cores/arduino/stm32/usb/usbd_conf.h

+3
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ extern "C" {
7070
#elif defined(STM32G0xx)
7171
#define USB_IRQn USB_UCPD1_2_IRQn
7272
#define USB_IRQHandler USB_UCPD1_2_IRQHandler
73+
#elif defined(STM32U5xx)
74+
#define USB_IRQn OTG_FS_IRQn
75+
#define USB_IRQHandler OTG_FS_IRQHandler
7376
#elif defined(STM32L5xx)
7477
#define USB_IRQn USB_FS_IRQn
7578
#define USB_IRQHandler USB_FS_IRQHandler

variants/STM32L5xx/L552Z(C-E)TxQ_L562ZETxQ/variant_NUCLEO_L552ZE_Q.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
#define PD12 19
4040
#define PA4 PIN_A9
4141
#define PB4 21
42-
#define PB5 22
42+
#define PB5 22 // UCPD TCPP
4343
#define PB3 23
4444
// 24 is PA4 (20)
4545
// 25 is PB4 (21)
@@ -233,6 +233,9 @@
233233
#define PIN_SERIAL_TX PG7
234234
#endif
235235

236+
// Pin UCPD to configure TCPP in default Type-C legacy state (UCPD_DBn for TCPP01)
237+
#define PIN_UCPD_TCPP PB5
238+
236239
// Extra HAL modules
237240
#if !defined(HAL_DAC_MODULE_DISABLED)
238241
#define HAL_DAC_MODULE_ENABLED

variants/STM32U5xx/U575A(G-I)IxQ_U585AIIxQ/variant_B_U585I_IOT02A.h

+3
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,9 @@
301301
#define PIN_SERIAL_TX PA9
302302
#endif
303303

304+
// Pin UCPD to configure TCPP in default Type-C legacy state (UCPD_PWR for TCPP03)
305+
#define PIN_UCPD_TCPP PB5
306+
304307
// Extra HAL modules
305308
#if !defined(HAL_DAC_MODULE_DISABLED)
306309
#define HAL_DAC_MODULE_ENABLED

variants/STM32U5xx/U575Z(G-I)TxQ_U585ZETxQ/variant_NUCLEO_U575ZI_Q.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
#define PD12 PIN_A15
3838
#define PA4 PIN_A16 // SB35 ON
3939
#define PB4 21 // SB36 ON
40-
#define PB5 22
40+
#define PB5 22 // UCPD TCPP
4141
#define PB3 23
4242
// 24 is PA4 (20) as default SB38 ON
4343
// 25 is PB4 (21) as default SB43 ON
@@ -236,6 +236,9 @@
236236
#define PIN_SERIAL_TX PA9
237237
#endif
238238

239+
// Pin UCPD to configure TCPP in default Type-C legacy state (UCPD_DBn for TCPP01)
240+
#define PIN_UCPD_TCPP PB5
241+
239242
// Extra HAL modules
240243
#if !defined(HAL_DAC_MODULE_DISABLED)
241244
#define HAL_DAC_MODULE_ENABLED

0 commit comments

Comments
 (0)