Skip to content

Commit

Permalink
Improve comment and use gLog.printf
Browse files Browse the repository at this point in the history
  • Loading branch information
chwon64 committed Jul 19, 2019
1 parent abbb9e0 commit 407dd81
Showing 1 changed file with 37 additions and 9 deletions.
46 changes: 37 additions & 9 deletions src/lib/stm32/stm32l0/CatenaStm32L0Rtc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ Copyright notice:
#ifdef ARDUINO_ARCH_STM32

#include "CatenaStm32L0Rtc.h"
#include "Catena_Log.h"

using namespace McciCatena;

/****************************************************************************\
Expand Down Expand Up @@ -147,10 +149,16 @@ bool CatenaStm32L0Rtc::begin(bool fResetTime)
}
else
{
/* use HSE clock -- not defined HSE input clock value */
// this->m_hRtc.Init.AsynchPrediv = 64 - 1; /* 40kHz / 64 = 625Hz */
// this->m_hRtc.Init.SynchPrediv = 625 - 1; /* 625Hz / 625 = 1Hz */
Serial.println("RTC clock use HSE and not supported yet!");
/*
|| use HSE clock --
|| we don't support use of HSE as RTC because it's connected to
|| TCXO_OUT, and that's controlled by the LoRaWAN software.
*/
gLog.printf(
gLog.kError,
"?CatenaStm32L0Rtc::begin:"
" HSE can not be used for RTC clock!\n"
);
return false;
}

Expand All @@ -164,7 +172,11 @@ bool CatenaStm32L0Rtc::begin(bool fResetTime)

if (HAL_RTC_Init(&this->m_hRtc) != HAL_OK)
{
Serial.println("HAL_RTC_Init() failed");
gLog.printf(
gLog.kError,
"?CatenaStm32L0Rtc::begin:"
" HAL_RTC_Init() failed\n"
);
return false;
}

Expand All @@ -186,7 +198,11 @@ bool CatenaStm32L0Rtc::begin(bool fResetTime)
RTC_FORMAT_BIN
) != HAL_OK)
{
Serial.println("HAL_RTC_SetTime() failed");
gLog.printf(
gLog.kError,
"?CatenaStm32L0Rtc::begin:"
" HAL_RTC_SetTime() failed\n"
);
return false;
}

Expand All @@ -202,7 +218,11 @@ bool CatenaStm32L0Rtc::begin(bool fResetTime)
RTC_FORMAT_BIN
) != HAL_OK)
{
Serial.println("HAL_RTC_SetDate() failed");
gLog.printf(
gLog.kError,
"?CatenaStm32L0Rtc::begin:"
" HAL_RTC_SetDate() failed\n"
);
return false;
}

Expand Down Expand Up @@ -261,7 +281,11 @@ bool CatenaStm32L0Rtc::SetTime(const CalendarTime *pNow)

if (HAL_RTC_SetTime(&this->m_hRtc, &Time, RTC_FORMAT_BIN) != HAL_OK)
{
Serial.println("HAL_RTC_SetTime() failed");
gLog.printf(
gLog.kError,
"?CatenaStm32L0Rtc::begin:"
" HAL_RTC_SetTime() failed\n"
);
return false;
}

Expand All @@ -272,7 +296,11 @@ bool CatenaStm32L0Rtc::SetTime(const CalendarTime *pNow)

if (HAL_RTC_SetDate(&this->m_hRtc, &Date, RTC_FORMAT_BIN) != HAL_OK)
{
Serial.println("HAL_RTC_SetDate() failed");
gLog.printf(
gLog.kError,
"?CatenaStm32L0Rtc::begin:"
" HAL_RTC_SetDate() failed\n"
);
return false;
}

Expand Down

0 comments on commit 407dd81

Please sign in to comment.