From 0cef7ce0ebc0ed8d6e9083bf115add8225bb4aff Mon Sep 17 00:00:00 2001 From: Dhinesh Kumar Pitchai Date: Tue, 9 Apr 2019 01:41:52 +0530 Subject: [PATCH] Fix #132: Configure Sleep mode to 'StopWithLowPowerRegulator'. --- src/lib/stm32/stm32l0/CatenaStm32L0Rtc.cpp | 44 +++---------------- src/lib/stm32/stm32l0/CatenaStm32L0_Sleep.cpp | 9 ++-- 2 files changed, 10 insertions(+), 43 deletions(-) diff --git a/src/lib/stm32/stm32l0/CatenaStm32L0Rtc.cpp b/src/lib/stm32/stm32l0/CatenaStm32L0Rtc.cpp index 122dbfe..bc492d0 100644 --- a/src/lib/stm32/stm32l0/CatenaStm32L0Rtc.cpp +++ b/src/lib/stm32/stm32l0/CatenaStm32L0Rtc.cpp @@ -1,4 +1,4 @@ -/* CatenaStm32L0Rtc.cpp Fri Mar 08 2019 18:40:03 dhineshkumar */ +/* CatenaStm32L0Rtc.cpp Wed Jan 03 2018 11:04:33 chwon */ /* @@ -8,10 +8,10 @@ Module: CatenaStm32L0Rtc.cpp Class CatenaStm32L0Rtc Version: - V0.8.0 Fri Mar 08 2019 18:40:03 dhineshkumar Edit level 5 + V0.7.0 Wed Jan 03 2018 11:04:33 chwon Edit level 4 Copyright notice: - This file copyright (C) 2017-2019 by + This file copyright (C) 2017 by MCCI Corporation 3520 Krums Corners Road @@ -38,9 +38,6 @@ Revision history: 0.7.0 Wed Jan 03 2018 11:04:33 chwon Need to call HAL_RTCEx_EnableBypassShadow() to support USB. - 0.8.0 Fri Mar 08 2019 18:40:03 dhineshkumar - Set and Clear Power interface clock enable bit in Stop mode. - */ #ifdef ARDUINO_ARCH_STM32 @@ -112,7 +109,7 @@ void HAL_RTC_MspInit( __HAL_RCC_RTC_ENABLE(); /* USER CODE BEGIN RTC_MspInit 1 */ HAL_NVIC_SetPriority(RTC_IRQn, TICK_INT_PRIORITY, 0U); - HAL_NVIC_EnableIRQ(RTC_IRQn); + HAL_NVIC_EnableIRQ(RTC_IRQn); /* USER CODE END RTC_MspInit 1 */ } } @@ -124,7 +121,7 @@ void HAL_RTC_MspDeInit( if (hRtc->Instance == RTC) { /* USER CODE BEGIN RTC_MspDeInit 0 */ - HAL_NVIC_DisableIRQ(RTC_IRQn); + HAL_NVIC_DisableIRQ(RTC_IRQn); /* USER CODE END RTC_MspDeInit 0 */ /* Peripheral clock disable */ __HAL_RCC_RTC_DISABLE(); @@ -213,13 +210,13 @@ bool CatenaStm32L0Rtc::begin(bool fResetTime) Serial.println("HAL_RTC_SetTime() failed"); return false; } - + /* Sunday 1st January 2017 */ Date.WeekDay = RTC_WEEKDAY_SUNDAY; Date.Month = RTC_MONTH_JANUARY; Date.Date = 0x1; Date.Year = 0x0; - + if (HAL_RTC_SetDate( &this->m_hRtc, &Date, @@ -411,10 +408,6 @@ void CatenaStm32L0Rtc::SleepForAlarm( break; case SleepMode::StopWithLowPowerRegulator: - { - /* Set Power interface clock enable bit */ - RCC->APB1ENR |= RCC_APB1ENR_PWREN; - while (! m_Alarm) { ++nWakes; @@ -424,29 +417,6 @@ void CatenaStm32L0Rtc::SleepForAlarm( PWR_SLEEPENTRY_WFI ); } - - /* Set Power interface clock enable bit */ - RCC->APB1ENR |= RCC_APB1ENR_PWREN; - - if (HAL_RCC_GetHCLKFreq() < 16000000) - { - /* MSI clock, enable and ready */ - LL_RCC_MSI_Enable(); - while (LL_RCC_MSI_IsReady() != 1U) - { - /* Wait for MSI ready */ - } - } - else - { - /* HSI clock, enable and ready */ - LL_RCC_HSI_Enable(); - while (LL_RCC_HSI_IsReady() != 1U) - { - /* Wait for HSI ready */ - } - } - } break; case SleepMode::Standby: diff --git a/src/lib/stm32/stm32l0/CatenaStm32L0_Sleep.cpp b/src/lib/stm32/stm32l0/CatenaStm32L0_Sleep.cpp index c97efe4..d0b392b 100644 --- a/src/lib/stm32/stm32l0/CatenaStm32L0_Sleep.cpp +++ b/src/lib/stm32/stm32l0/CatenaStm32L0_Sleep.cpp @@ -1,4 +1,4 @@ -/* CatenaStm32L0_Sleep.cpp Fri Mar 08 2019 18:05:26 dhineshkumar */ +/* CatenaStm32L0_Sleep.cpp Wed Oct 31 2018 10:57:42 chwon */ /* @@ -8,10 +8,10 @@ Module: CatenaStm32L0_Sleep.cpp Home for CatenaStm32L0::Sleep() Version: - V0.11.1 Fri Mar 08 2019 18:05:26 dhineshkumar Edit level 2 + V0.11.0 Wed Oct 31 2018 10:57:42 chwon Edit level 1 Copyright notice: - This file copyright (C) 2018-2019 by + This file copyright (C) 2018 by MCCI Corporation 3520 Krums Corners Road @@ -29,9 +29,6 @@ Revision history: 0.11.0 Wed Oct 31 2018 10:57:42 chwon Module created. - 0.11.1 Fri Mar 08 2019 18:05:26 dhineshkumar - Call SleepForAlarm with SleepMode StopWithLowPowerRegulator. - */ #ifdef ARDUINO_ARCH_STM32