Skip to content

cores(U5): support USB Type-C on U5 #1640

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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