Skip to content

Commit

Permalink
Fix #132: Configure Sleep mode to 'StopWithLowPowerRegulator'.
Browse files Browse the repository at this point in the history
  • Loading branch information
dhineshkumarmcci committed Apr 8, 2019
1 parent 9378cb1 commit 0cef7ce
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 43 deletions.
44 changes: 7 additions & 37 deletions src/lib/stm32/stm32l0/CatenaStm32L0Rtc.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* CatenaStm32L0Rtc.cpp Fri Mar 08 2019 18:40:03 dhineshkumar */
/* CatenaStm32L0Rtc.cpp Wed Jan 03 2018 11:04:33 chwon */

/*
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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 */
}
}
Expand All @@ -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();
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand All @@ -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:
Expand Down
9 changes: 3 additions & 6 deletions src/lib/stm32/stm32l0/CatenaStm32L0_Sleep.cpp
Original file line number Diff line number Diff line change
@@ -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 */

/*
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 0cef7ce

Please sign in to comment.