From f67150f16cb0e5bc71dc3320750ff96ba99e96dc Mon Sep 17 00:00:00 2001 From: lokher Date: Thu, 22 Sep 2022 17:33:56 +0800 Subject: refactor indicator.c; fix LED/RGB_MATRIX_BRIGHTNESS_TURN_OFF_VAL related issue --- keyboards/keychron/bluetooth/lpm_stm32l432.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'keyboards/keychron/bluetooth/lpm_stm32l432.c') 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 + } /* -- cgit v1.2.3