From beeed6ab2b651f9f4d2e488448809f15f68168b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Thu, 4 May 2017 16:19:37 +0200 Subject: [PATCH] [ion] No led when charging in sleep mode Change-Id: I8cdea4d435226fbc877e398909926c83642e0e55 --- apps/usb_timer.cpp | 2 ++ ion/src/device/power.cpp | 12 ++++++++++-- ion/src/device/wakeup.cpp | 2 ++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/apps/usb_timer.cpp b/apps/usb_timer.cpp index b83cb86ba..3b50f43f2 100644 --- a/apps/usb_timer.cpp +++ b/apps/usb_timer.cpp @@ -14,6 +14,7 @@ void USBTimer::fire() { if (!m_previousPluggedState && GlobalPreferences::sharedGlobalPreferences()->examMode() == GlobalPreferences::ExamMode::Activate) { m_container->displayExamModePopUp(false, true); } +#if LED_WHILE_CHARGING KDColor LEDColor = Ion::Battery::isCharging() ? KDColorYellow : KDColorGreen; Ion::LED::setColor(LEDColor); m_previousPluggedState = true; @@ -22,5 +23,6 @@ void USBTimer::fire() { Ion::LED::setColor(KDColorBlack); m_previousPluggedState = false; } +#endif } } diff --git a/ion/src/device/power.cpp b/ion/src/device/power.cpp index 5110ac7f5..c78befa4b 100644 --- a/ion/src/device/power.cpp +++ b/ion/src/device/power.cpp @@ -15,8 +15,9 @@ void Ion::Power::suspend() { PWR.CR()->setFPDS(true); // Put the flash to sleep. Takes longer to wake up. CM4.SCR()->setSLEEPDEEP(true); - WakeUp::Device::onChargingEvent(); WakeUp::Device::onUSBPlugging(); +#if LED_WHILE_CHARGING + WakeUp::Device::onChargingEvent(); while (1) { /* Update LEDS @@ -24,9 +25,15 @@ void Ion::Power::suspend() { * a while to be sure that the plug state of the USB is up-to-date. */ msleep(200); LED::Device::enforceState(Battery::isCharging(), USB::isPlugged(), false); +#endif WakeUp::Device::onPowerKeyDown(); +#if LED_WHILE_CHARGING +#else + msleep(200); +#endif + Device::shutdownClocks(); /* To enter sleep, we need to issue a WFE instruction, which waits for the @@ -39,6 +46,7 @@ void Ion::Power::suspend() { msleep(1); asm("wfe"); +#if LED_WHILE_CHARGING Device::initClocks(); Keyboard::Device::init(); @@ -51,7 +59,7 @@ void Ion::Power::suspend() { break; } } - +#endif Device::initClocks(); Device::initPeripherals(); diff --git a/ion/src/device/wakeup.cpp b/ion/src/device/wakeup.cpp index 1cedec801..d54ea0f83 100644 --- a/ion/src/device/wakeup.cpp +++ b/ion/src/device/wakeup.cpp @@ -31,7 +31,9 @@ void onUSBPlugging() { SYSCFG.EXTICR3()->setEXTI(USB::Device::VbusPin.pin(), USB::Device::VbusPin.group()); EXTI.EMR()->set(USB::Device::VbusPin.pin(), true); +#if LED_WHILE_CHARGING EXTI.FTSR()->set(USB::Device::VbusPin.pin(), true); +#endif EXTI.RTSR()->set(USB::Device::VbusPin.pin(), true); }