summaryrefslogtreecommitdiffstats
path: root/platforms/chibios
diff options
context:
space:
mode:
authorQMK Bot <hello@qmk.fm>2023-07-02 22:54:27 +0000
committerQMK Bot <hello@qmk.fm>2023-07-02 22:54:27 +0000
commited6528b3e3f6f306b1ddd6155b0bad07d088898d (patch)
tree1adc1761573773854a51c3d6178a2c1a9b62c812 /platforms/chibios
parent80d0cacd2be68a3737645bc219b75049d4aea19f (diff)
parentb708658e2ea184402f6fad152c7596cbb40df508 (diff)
Merge remote-tracking branch 'origin/master' into develop
Diffstat (limited to 'platforms/chibios')
-rw-r--r--platforms/chibios/drivers/usbpd_stm32g4.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/platforms/chibios/drivers/usbpd_stm32g4.c b/platforms/chibios/drivers/usbpd_stm32g4.c
index 0096f22f07..21b8f6db95 100644
--- a/platforms/chibios/drivers/usbpd_stm32g4.c
+++ b/platforms/chibios/drivers/usbpd_stm32g4.c
@@ -22,8 +22,6 @@
// Initialises the USBPD subsystem
__attribute__((weak)) void usbpd_init(void) {
- // Disable dead-battery signals
- PWR->CR3 |= PWR_CR3_UCPD_DBDIS;
// Enable the clock for the UCPD1 peripheral
RCC->APB1ENR2 |= RCC_APB1ENR2_UCPD1EN;
@@ -46,6 +44,11 @@ __attribute__((weak)) void usbpd_init(void) {
CR |= UCPD_CR_ANAMODE | UCPD_CR_CCENABLE_Msk;
// Apply the changes
UCPD1->CR = CR;
+
+ // Disable dead-battery signals only after UCPD1 is configured to ensure
+ // that the transition does not go through any intermediate state without
+ // any pull-down resistance.
+ PWR->CR3 |= PWR_CR3_UCPD_DBDIS;
}
// Gets the current state of the USBPD allowance