Skip to content

Commit

Permalink
cores(U5): support USB Type-C on U5
Browse files Browse the repository at this point in the history
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 <alexandre.bourdiol@st.com>
  • Loading branch information
ABOSTM authored and fpistm committed Feb 2, 2022
1 parent 29d4caa commit 7fc68de
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 2 deletions.
7 changes: 7 additions & 0 deletions cores/arduino/stm32/usb/usbd_conf.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ PCD_HandleTypeDef g_hpcd;
void HAL_PCD_MspInit(PCD_HandleTypeDef *hpcd)
{
const PinMap *map = NULL;

#if defined(PIN_UCPD_TCPP)
/* Set TCPP default state: Type-C legacy */
pinMode(PIN_UCPD_TCPP, OUTPUT_OPEN_DRAIN);
digitalWriteFast(digitalPinToPinName(PIN_UCPD_TCPP), LOW);
#endif

#if defined(PWR_CR2_USV) || defined(PWR_SVMCR_USV)
/* Enable VDDUSB on Pwrctrl CR2 register*/
HAL_PWREx_EnableVddUSB();
Expand Down
3 changes: 3 additions & 0 deletions cores/arduino/stm32/usb/usbd_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ extern "C" {
#elif defined(STM32G0xx)
#define USB_IRQn USB_UCPD1_2_IRQn
#define USB_IRQHandler USB_UCPD1_2_IRQHandler
#elif defined(STM32U5xx)
#define USB_IRQn OTG_FS_IRQn
#define USB_IRQHandler OTG_FS_IRQHandler
#elif defined(STM32L5xx)
#define USB_IRQn USB_FS_IRQn
#define USB_IRQHandler USB_FS_IRQHandler
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
#define PD12 19
#define PA4 PIN_A9
#define PB4 21
#define PB5 22
#define PB5 22 // UCPD TCPP
#define PB3 23
// 24 is PA4 (20)
// 25 is PB4 (21)
Expand Down Expand Up @@ -233,6 +233,9 @@
#define PIN_SERIAL_TX PG7
#endif

// Pin UCPD to configure TCPP in default Type-C legacy state (UCPD_DBn for TCPP01)
#define PIN_UCPD_TCPP PB5

// Extra HAL modules
#if !defined(HAL_DAC_MODULE_DISABLED)
#define HAL_DAC_MODULE_ENABLED
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,9 @@
#define PIN_SERIAL_TX PA9
#endif

// Pin UCPD to configure TCPP in default Type-C legacy state (UCPD_PWR for TCPP03)
#define PIN_UCPD_TCPP PB5

// Extra HAL modules
#if !defined(HAL_DAC_MODULE_DISABLED)
#define HAL_DAC_MODULE_ENABLED
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
#define PD12 PIN_A15
#define PA4 PIN_A16 // SB35 ON
#define PB4 21 // SB36 ON
#define PB5 22
#define PB5 22 // UCPD TCPP
#define PB3 23
// 24 is PA4 (20) as default SB38 ON
// 25 is PB4 (21) as default SB43 ON
Expand Down Expand Up @@ -236,6 +236,9 @@
#define PIN_SERIAL_TX PA9
#endif

// Pin UCPD to configure TCPP in default Type-C legacy state (UCPD_DBn for TCPP01)
#define PIN_UCPD_TCPP PB5

// Extra HAL modules
#if !defined(HAL_DAC_MODULE_DISABLED)
#define HAL_DAC_MODULE_ENABLED
Expand Down

0 comments on commit 7fc68de

Please sign in to comment.