diff --git a/arch/arm/src/stm32/stm32f40xxx_rtcc.c b/arch/arm/src/stm32/stm32f40xxx_rtcc.c index db2e7e232b..89098bbd13 100644 --- a/arch/arm/src/stm32/stm32f40xxx_rtcc.c +++ b/arch/arm/src/stm32/stm32f40xxx_rtcc.c @@ -860,6 +860,50 @@ static inline void rtc_enable_alarm(void) } #endif +/************************************************************************************ + * Name: stm32_rtc_getalarmdatetime + * + * Description: + * Get the current date and time for a RTC alarm. + * + * Input Parameters: + * reg - RTC alarm register + * tp - The location to return the high resolution time value. + * + * Returned Value: + * Zero (OK) on success; a negated errno on failure + * + ************************************************************************************/ + +#ifdef CONFIG_RTC_ALARM +static int stm32_rtc_getalarmdatetime(rtc_alarmreg_t reg, FAR struct tm *tp) +{ + uint32_t data, tmp; + + ASSERT(tp != NULL); + + /* Sample the data time register. */ + + data = getreg32(reg); + + /* Convert the RTC time to fields in struct tm format. All of the STM32 + * All of the ranges of values correspond between struct tm and the time + * register. + */ + + tmp = (data & (RTC_ALRMR_SU_MASK | RTC_ALRMR_ST_MASK)) >> RTC_ALRMR_SU_SHIFT; + tp->tm_sec = rtc_bcd2bin(tmp); + + tmp = (data & (RTC_ALRMR_MNU_MASK | RTC_ALRMR_MNT_MASK)) >> RTC_ALRMR_MNU_SHIFT; + tp->tm_min = rtc_bcd2bin(tmp); + + tmp = (data & (RTC_ALRMR_HU_MASK | RTC_ALRMR_HT_MASK)) >> RTC_ALRMR_HU_SHIFT; + tp->tm_hour = rtc_bcd2bin(tmp); + + return OK; +} +#endif + /**************************************************************************** * Public Functions ****************************************************************************/ @@ -1552,50 +1596,6 @@ errout_with_wprunlock: } #endif -#ifdef CONFIG_RTC_ALARM -/************************************************************************************ - * Name: stm32_rtc_getalarmdatetime - * - * Description: - * Get the current date and time for a RTC alarm. - * - * Input Parameters: - * reg - RTC alarm register - * tp - The location to return the high resolution time value. - * - * Returned Value: - * Zero (OK) on success; a negated errno on failure - * - ************************************************************************************/ - -int stm32_rtc_getalarmdatetime(rtc_alarmreg_t reg, FAR struct tm *tp) -{ - uint32_t data, tmp; - - ASSERT(tp != NULL); - - /* Sample the data time register. */ - - data = getreg32(reg); - - /* Convert the RTC time to fields in struct tm format. All of the STM32 - * All of the ranges of values correspond between struct tm and the time - * register. - */ - - tmp = (data & (RTC_ALRMR_SU_MASK | RTC_ALRMR_ST_MASK)) >> RTC_ALRMR_SU_SHIFT; - tp->tm_sec = rtc_bcd2bin(tmp); - - tmp = (data & (RTC_ALRMR_MNU_MASK | RTC_ALRMR_MNT_MASK)) >> RTC_ALRMR_MNU_SHIFT; - tp->tm_min = rtc_bcd2bin(tmp); - - tmp = (data & (RTC_ALRMR_HU_MASK | RTC_ALRMR_HT_MASK)) >> RTC_ALRMR_HU_SHIFT; - tp->tm_hour = rtc_bcd2bin(tmp); - - return OK; -} -#endif - /************************************************************************************ * Name: stm32_rtc_rdalarm * diff --git a/arch/arm/src/stm32f7/stm32_rtc.c b/arch/arm/src/stm32f7/stm32_rtc.c index 42e4d0af8a..05844c4378 100644 --- a/arch/arm/src/stm32f7/stm32_rtc.c +++ b/arch/arm/src/stm32f7/stm32_rtc.c @@ -817,6 +817,50 @@ rtchw_set_alrmbr_exit: } #endif +/************************************************************************************ + * Name: stm32_rtc_getalarmdatetime + * + * Description: + * Get the current date and time for a RTC alarm. + * + * Input Parameters: + * reg - RTC alarm register + * tp - The location to return the high resolution time value. + * + * Returned Value: + * Zero (OK) on success; a negated errno on failure + * + ************************************************************************************/ + +#ifdef CONFIG_RTC_ALARM +static int stm32_rtc_getalarmdatetime(rtc_alarmreg_t reg, FAR struct tm *tp) +{ + uint32_t data, tmp; + + ASSERT(tp != NULL); + + /* Sample the data time register. */ + + data = getreg32(reg); + + /* Convert the RTC time to fields in struct tm format. All of the STM32 + * All of the ranges of values correspond between struct tm and the time + * register. + */ + + tmp = (data & (RTC_ALRMR_SU_MASK | RTC_ALRMR_ST_MASK)) >> RTC_ALRMR_SU_SHIFT; + tp->tm_sec = rtc_bcd2bin(tmp); + + tmp = (data & (RTC_ALRMR_MNU_MASK | RTC_ALRMR_MNT_MASK)) >> RTC_ALRMR_MNU_SHIFT; + tp->tm_min = rtc_bcd2bin(tmp); + + tmp = (data & (RTC_ALRMR_HU_MASK | RTC_ALRMR_HT_MASK)) >> RTC_ALRMR_HU_SHIFT; + tp->tm_hour = rtc_bcd2bin(tmp); + + return OK; +} +#endif + /**************************************************************************** * Public Functions ****************************************************************************/ @@ -1559,50 +1603,6 @@ errout_with_wprunlock: } #endif -#ifdef CONFIG_RTC_ALARM -/************************************************************************************ - * Name: stm32_rtc_getalarmdatetime - * - * Description: - * Get the current date and time for a RTC alarm. - * - * Input Parameters: - * reg - RTC alarm register - * tp - The location to return the high resolution time value. - * - * Returned Value: - * Zero (OK) on success; a negated errno on failure - * - ************************************************************************************/ - -int stm32_rtc_getalarmdatetime(rtc_alarmreg_t reg, FAR struct tm *tp) -{ - uint32_t data, tmp; - - ASSERT(tp != NULL); - - /* Sample the data time register. */ - - data = getreg32(reg); - - /* Convert the RTC time to fields in struct tm format. All of the STM32 - * All of the ranges of values correspond between struct tm and the time - * register. - */ - - tmp = (data & (RTC_ALRMR_SU_MASK | RTC_ALRMR_ST_MASK)) >> RTC_ALRMR_SU_SHIFT; - tp->tm_sec = rtc_bcd2bin(tmp); - - tmp = (data & (RTC_ALRMR_MNU_MASK | RTC_ALRMR_MNT_MASK)) >> RTC_ALRMR_MNU_SHIFT; - tp->tm_min = rtc_bcd2bin(tmp); - - tmp = (data & (RTC_ALRMR_HU_MASK | RTC_ALRMR_HT_MASK)) >> RTC_ALRMR_HU_SHIFT; - tp->tm_hour = rtc_bcd2bin(tmp); - - return OK; -} -#endif - /************************************************************************************ * Name: stm32_rtc_rdalarm * diff --git a/arch/arm/src/stm32l4/stm32l4_rtcc.c b/arch/arm/src/stm32l4/stm32l4_rtcc.c index 7cdfc186f7..b7b4239dc7 100644 --- a/arch/arm/src/stm32l4/stm32l4_rtcc.c +++ b/arch/arm/src/stm32l4/stm32l4_rtcc.c @@ -815,6 +815,50 @@ static inline void rtc_enable_alarm(void) } #endif +/************************************************************************************ + * Name: stm32l4_rtc_getalarmdatetime + * + * Description: + * Get the current date and time for a RTC alarm. + * + * Input Parameters: + * reg - RTC alarm register + * tp - The location to return the high resolution time value. + * + * Returned Value: + * Zero (OK) on success; a negated errno on failure + * + ************************************************************************************/ + +#ifdef CONFIG_RTC_ALARM +static int stm32l4_rtc_getalarmdatetime(rtc_alarmreg_t reg, FAR struct tm *tp) +{ + uint32_t data, tmp; + + ASSERT(tp != NULL); + + /* Sample the data time register. */ + + data = getreg32(reg); + + /* Convert the RTC time to fields in struct tm format. All of the STM32 + * All of the ranges of values correspond between struct tm and the time + * register. + */ + + tmp = (data & (RTC_ALRMR_SU_MASK | RTC_ALRMR_ST_MASK)) >> RTC_ALRMR_SU_SHIFT; + tp->tm_sec = rtc_bcd2bin(tmp); + + tmp = (data & (RTC_ALRMR_MNU_MASK | RTC_ALRMR_MNT_MASK)) >> RTC_ALRMR_MNU_SHIFT; + tp->tm_min = rtc_bcd2bin(tmp); + + tmp = (data & (RTC_ALRMR_HU_MASK | RTC_ALRMR_HT_MASK)) >> RTC_ALRMR_HU_SHIFT; + tp->tm_hour = rtc_bcd2bin(tmp); + + return OK; +} +#endif + /************************************************************************************ * Public Functions ************************************************************************************/ @@ -1479,50 +1523,6 @@ errout_with_wprunlock: } #endif -#ifdef CONFIG_RTC_ALARM -/************************************************************************************ - * Name: stm32l4_rtc_getalarmdatetime - * - * Description: - * Get the current date and time for a RTC alarm. - * - * Input Parameters: - * reg - RTC alarm register - * tp - The location to return the high resolution time value. - * - * Returned Value: - * Zero (OK) on success; a negated errno on failure - * - ************************************************************************************/ - -int stm32l4_rtc_getalarmdatetime(rtc_alarmreg_t reg, FAR struct tm *tp) -{ - uint32_t data, tmp; - - ASSERT(tp != NULL); - - /* Sample the data time register. */ - - data = getreg32(reg); - - /* Convert the RTC time to fields in struct tm format. All of the STM32 - * All of the ranges of values correspond between struct tm and the time - * register. - */ - - tmp = (data & (RTC_ALRMR_SU_MASK | RTC_ALRMR_ST_MASK)) >> RTC_ALRMR_SU_SHIFT; - tp->tm_sec = rtc_bcd2bin(tmp); - - tmp = (data & (RTC_ALRMR_MNU_MASK | RTC_ALRMR_MNT_MASK)) >> RTC_ALRMR_MNU_SHIFT; - tp->tm_min = rtc_bcd2bin(tmp); - - tmp = (data & (RTC_ALRMR_HU_MASK | RTC_ALRMR_HT_MASK)) >> RTC_ALRMR_HU_SHIFT; - tp->tm_hour = rtc_bcd2bin(tmp); - - return OK; -} -#endif - /************************************************************************************ * Name: stm32l4_rtc_rdalarm *