STM32L4 RTC: store RTC MAGIC to backup reg, not to address zero
This commit is contained in:
parent
f5e6afe9cd
commit
ad6515563b
@ -114,7 +114,7 @@ static inline void rcc_resetbkp(void)
|
||||
|
||||
/* Check if the RTC is already configured */
|
||||
|
||||
init_stat = rtc_is_inits();
|
||||
init_stat = stm32l4_rtc_is_initialized();
|
||||
if(!init_stat)
|
||||
{
|
||||
/* Enable write access to the backup domain (RTC registers, RTC
|
||||
|
@ -76,7 +76,7 @@ enum alm_id_e
|
||||
RTC_ALARM_LAST
|
||||
};
|
||||
|
||||
/* Structure used to pass parmaters to set an alarm */
|
||||
/* Structure used to pass parameters to set an alarm */
|
||||
|
||||
struct alm_setalarm_s
|
||||
{
|
||||
@ -106,7 +106,7 @@ extern "C"
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************************************
|
||||
* Name: rtc_is_inits
|
||||
* Name: stm32l4_rtc_is_initialized
|
||||
*
|
||||
* Description:
|
||||
* Returns 'true' if the RTC has been initialized (according to the RTC itself).
|
||||
@ -120,10 +120,10 @@ extern "C"
|
||||
* bool -- true if the INITS flag is set in the ISR.
|
||||
*
|
||||
************************************************************************************/
|
||||
#ifdef CONFIG_RTC_DRIVER
|
||||
bool rtc_is_inits(void);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_RTC_DRIVER
|
||||
bool stm32l4_rtc_is_initialized(void);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32l4_rtc_getdatetime_with_subseconds
|
||||
|
@ -176,7 +176,7 @@ static void stm32l4_alarm_callback(FAR void *arg, unsigned int alarmid)
|
||||
rtc_alarm_callback_t cb;
|
||||
FAR void *priv;
|
||||
|
||||
DEBUGASSERT(priv != NULL);
|
||||
DEBUGASSERT(arg != NULL);
|
||||
DEBUGASSERT(alarmid == RTC_ALARMA || alarmid == RTC_ALARMB);
|
||||
|
||||
lower = (struct stm32l4_lowerhalf_s *)arg;
|
||||
|
@ -95,6 +95,10 @@
|
||||
# define CONFIG_RTC_MAGIC_REG (0)
|
||||
#endif
|
||||
|
||||
#define RTC_MAGIC CONFIG_RTC_MAGIC
|
||||
#define RTC_MAGIC_TIME_SET CONFIG_RTC_MAGIC_TIME_SET
|
||||
#define RTC_MAGIC_REG STM32L4_RTC_BKR(CONFIG_RTC_MAGIC_REG)
|
||||
|
||||
/* Constants ************************************************************************/
|
||||
|
||||
#define SYNCHRO_TIMEOUT (0x00020000)
|
||||
@ -816,7 +820,7 @@ static inline void rtc_enable_alarm(void)
|
||||
************************************************************************************/
|
||||
|
||||
/************************************************************************************
|
||||
* Name: rtc_is_inits
|
||||
* Name: stm32l4_rtc_is_initialized
|
||||
*
|
||||
* Description:
|
||||
* Returns 'true' if the RTC has been initialized (according to the RTC itself).
|
||||
@ -831,7 +835,7 @@ static inline void rtc_enable_alarm(void)
|
||||
*
|
||||
************************************************************************************/
|
||||
|
||||
bool rtc_is_inits(void)
|
||||
bool stm32l4_rtc_is_initialized(void)
|
||||
{
|
||||
uint32_t regval;
|
||||
|
||||
@ -867,8 +871,7 @@ int up_rtc_initialize(void)
|
||||
* backed, we don't need or want to re-initialize on each reset.
|
||||
*/
|
||||
|
||||
init_stat = rtc_is_inits();
|
||||
|
||||
init_stat = stm32l4_rtc_is_initialized();
|
||||
if (!init_stat)
|
||||
{
|
||||
/* Enable write access to the backup domain (RTC registers, RTC
|
||||
@ -1164,7 +1167,7 @@ int stm32l4_rtc_setdatetime(FAR const struct tm *tp)
|
||||
|
||||
/* Then write the broken out values to the RTC */
|
||||
|
||||
/* Convert the struct tm format to RTC time register fields. All of the STM32
|
||||
/* Convert the struct tm format to RTC time register fields.
|
||||
* All of the ranges of values correspond between struct tm and the time
|
||||
* register.
|
||||
*/
|
||||
@ -1216,10 +1219,10 @@ int stm32l4_rtc_setdatetime(FAR const struct tm *tp)
|
||||
|
||||
/* Remember that the RTC is initialized and had its time set. */
|
||||
|
||||
if (getreg32(CONFIG_RTC_MAGIC_REG) != CONFIG_RTC_MAGIC_TIME_SET)
|
||||
if (getreg32(RTC_MAGIC_REG) != RTC_MAGIC_TIME_SET)
|
||||
{
|
||||
stm32l4_pwr_enablebkp(true);
|
||||
putreg32(CONFIG_RTC_MAGIC_TIME_SET, CONFIG_RTC_MAGIC_REG);
|
||||
putreg32(RTC_MAGIC_TIME_SET, RTC_MAGIC_REG);
|
||||
stm32l4_pwr_enablebkp(false);
|
||||
}
|
||||
|
||||
@ -1243,7 +1246,7 @@ int stm32l4_rtc_setdatetime(FAR const struct tm *tp)
|
||||
|
||||
bool stm32l4_rtc_havesettime(void)
|
||||
{
|
||||
return getreg32(CONFIG_RTC_MAGIC_REG) == CONFIG_RTC_MAGIC_TIME_SET;
|
||||
return getreg32(RTC_MAGIC_REG) == RTC_MAGIC_TIME_SET;
|
||||
}
|
||||
|
||||
/************************************************************************************
|
||||
|
Loading…
Reference in New Issue
Block a user