diff options
author | lokher <lokher@gmail.com> | 2022-09-22 17:33:56 +0800 |
---|---|---|
committer | lokher <lokher@gmail.com> | 2022-09-22 17:33:56 +0800 |
commit | f67150f16cb0e5bc71dc3320750ff96ba99e96dc (patch) | |
tree | 559bf802f0737dac2e0d4892577818d10d7c9f39 /keyboards/keychron/bluetooth/lpm_stm32l432.c | |
parent | 9581289745736ce068a1040f44cec37a2ca8830d (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.c | 20 |
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 + } /* |