summaryrefslogtreecommitdiffstats
path: root/keyboards/keychron/bluetooth/lpm_stm32l432.c
diff options
context:
space:
mode:
authorlokher <lokher@gmail.com>2022-09-22 17:33:56 +0800
committerlokher <lokher@gmail.com>2022-09-22 17:33:56 +0800
commitf67150f16cb0e5bc71dc3320750ff96ba99e96dc (patch)
tree559bf802f0737dac2e0d4892577818d10d7c9f39 /keyboards/keychron/bluetooth/lpm_stm32l432.c
parent9581289745736ce068a1040f44cec37a2ca8830d (diff)
refactor indicator.c; fix LED/RGB_MATRIX_BRIGHTNESS_TURN_OFF_VAL related issue
Diffstat (limited to 'keyboards/keychron/bluetooth/lpm_stm32l432.c')
-rw-r--r--keyboards/keychron/bluetooth/lpm_stm32l432.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/keyboards/keychron/bluetooth/lpm_stm32l432.c b/keyboards/keychron/bluetooth/lpm_stm32l432.c
index a871a1b53c..10fe9f5ceb 100644
--- a/keyboards/keychron/bluetooth/lpm_stm32l432.c
+++ b/keyboards/keychron/bluetooth/lpm_stm32l432.c
@@ -192,12 +192,6 @@ static inline void lpm_wakeup(void) {
PWR->SCR |= PWR_SCR_CWUF;
PWR->SCR |= PWR_SCR_CSBF;
-#if defined(KEEP_USB_CONNECTION_IN_BLUETOOTH_MODE)
- /* Remove USB isolation.*/
- PWR->CR2 |= PWR_CR2_USV; /* PWR_CR2_USV is available on STM32L4x2xx and STM32L4x3xx devices only. */
- usb_start(&USBD1);
-#endif
-
/* TIMx is disable during stop/standby/sleep mode, init after wakeup */
stInit();
timer_init();
@@ -211,8 +205,21 @@ static inline void lpm_wakeup(void) {
}
}
palDisableLineEvent(BLUETOOTH_INT_INPUT_PIN);
+
+#ifdef USB_POWER_SENSE_PIN
palDisableLineEvent(USB_POWER_SENSE_PIN);
+#if defined(KEEP_USB_CONNECTION_IN_BLUETOOTH_MODE)
+ if (usb_power_connected()) {
+ /* Remove USB isolation.*/
+ //PWR->CR2 |= PWR_CR2_USV; /* PWR_CR2_USV is available on STM32L4x2xx and STM32L4x3xx devices only. */
+ usb_power_connect();
+ usb_start(&USBD1);
+ }
+#endif
+
+#endif
+
#if defined(DIP_SWITCH_PINS)
dip_switch_init();
dip_switch_read(true);
@@ -222,6 +229,7 @@ static inline void lpm_wakeup(void) {
rtcSTM32SetPeriodicWakeup(&RTCD1, NULL);
nvicDisableVector(STM32_EXTI20_NUMBER);
#endif
+
}
/*