diff --git a/Documentation/NuttxUserGuide.html b/Documentation/NuttxUserGuide.html index 67c5012073..5c063fefeb 100644 --- a/Documentation/NuttxUserGuide.html +++ b/Documentation/NuttxUserGuide.html @@ -4359,9 +4359,7 @@ FAR struct tm *localtime(FAR const time_t *timep);

Description: @@ -4388,9 +4386,7 @@ FAR char *asctime(FAR const struct tm *tp);

Description: @@ -4479,9 +4475,7 @@ FAR struct tm *localtime_r(FAR const time_t *timep, FAR struct tm *result);

Description: @@ -4511,9 +4505,7 @@ FAR char *asctime_r(FAR const struct tm *tp, FAR char *buf);

Description: diff --git a/arch/arm/src/lpc43xx/lpc43_rtc.c b/arch/arm/src/lpc43xx/lpc43_rtc.c index 7275dbb724..51a61e610f 100644 --- a/arch/arm/src/lpc43xx/lpc43_rtc.c +++ b/arch/arm/src/lpc43xx/lpc43_rtc.c @@ -65,6 +65,7 @@ ************************************************************************************/ /* Configuration ********************************************************************/ + /* This RTC implementation supports only date/time RTC hardware */ #ifndef CONFIG_RTC_DATETIME @@ -310,11 +311,8 @@ int up_rtc_getdatetime(FAR struct tm *tp) tp->tm_mday = ((getreg32(LPC43_RTC_DOM) & RTC_DOM_MASK)); tp->tm_mon = ((getreg32(LPC43_RTC_MONTH) & RTC_MONTH_MASK)) - 1; tp->tm_year = ((getreg32(LPC43_RTC_YEAR) & RTC_YEAR_MASK)-1900); - -#if defined(CONFIG_LIBC_LOCALTIME) || defined(CONFIG_TIME_EXTENDED) tp->tm_wday = ((getreg32(LPC43_RTC_DOW) & RTC_DOW_MASK)); tp->tm_yday = ((getreg32(LPC43_RTC_DOY) & RTC_DOY_MASK)); -#endif rtc_dumptime(tp, "Returning"); return OK; @@ -352,11 +350,8 @@ int up_rtc_settime(FAR const struct timespec *tp) putreg32(((newtime.tm_mday) & RTC_DOM_MASK), LPC43_RTC_DOM); putreg32((((newtime.tm_mon)+1) & RTC_MONTH_MASK), LPC43_RTC_MONTH); putreg32(((newtime.tm_year) & RTC_YEAR_MASK)+1900, LPC43_RTC_YEAR); - -#if defined(CONFIG_LIBC_LOCALTIME) || defined(CONFIG_TIME_EXTENDED) putreg32(((newtime.tm_wday) & RTC_DOW_MASK), LPC43_RTC_DOW); putreg32(((newtime.tm_yday) & RTC_DOY_MASK), LPC43_RTC_DOY); -#endif return OK; } @@ -390,13 +385,16 @@ int lpc43_rtc_setalarm(FAR const struct timespec *tp, alarmcb_t callback) g_alarmcb = callback; /* Break out the time values */ + #warning "Missing logic" /* The set the alarm */ + #warning "Missing logic" ret = OK; } + return ret; } #endif diff --git a/arch/arm/src/stm32/stm32_rtcc.c b/arch/arm/src/stm32/stm32_rtcc.c index 5b6db8db62..5ad90ebebf 100644 --- a/arch/arm/src/stm32/stm32_rtcc.c +++ b/arch/arm/src/stm32/stm32_rtcc.c @@ -61,7 +61,9 @@ /************************************************************************************ * Pre-processor Definitions ************************************************************************************/ + /* Configuration ********************************************************************/ + /* This RTC implementation supports only date/time RTC hardware */ #ifndef CONFIG_RTC_DATETIME @@ -102,6 +104,7 @@ volatile bool g_rtc_enabled = false; /************************************************************************************ * Private Functions ************************************************************************************/ + /************************************************************************************ * Name: rtc_dumpregs ************************************************************************************/ @@ -523,6 +526,7 @@ int up_rtc_initialize(void) rtc_dumpregs("On reset"); /* Select the clock source */ + /* Save the token before losing it when resetting */ regval = getreg32(RTC_MAGIC_REG); @@ -776,6 +780,7 @@ int up_rtc_getdatetime(FAR struct tm *tp) continue; } #endif + tmp = getreg32(STM32_RTC_DR); if (tmp == dr) { @@ -818,12 +823,12 @@ int up_rtc_getdatetime(FAR struct tm *tp) tmp = (dr & (RTC_DR_YU_MASK | RTC_DR_YT_MASK)) >> RTC_DR_YU_SHIFT; tp->tm_year = rtc_bcd2bin(tmp) + 100; -#if defined(CONFIG_LIBC_LOCALTIME) || defined(CONFIG_TIME_EXTENDED) tmp = (dr & RTC_DR_WDU_MASK) >> RTC_DR_WDU_SHIFT; tp->tm_wday = tmp % 7; - tp->tm_yday = tp->tm_mday + clock_daysbeforemonth(tp->tm_mon, clock_isleapyear(tp->tm_year + 1900)); + tp->tm_yday = tp->tm_mday + + clock_daysbeforemonth(tp->tm_mon, + clock_isleapyear(tp->tm_year + 1900)); tp->tm_isdst = 0; -#endif #ifdef CONFIG_STM32_HAVE_RTC_SUBSECONDS /* Return RTC sub-seconds if no configured and if a non-NULL value @@ -964,9 +969,7 @@ int stm32_rtc_setdatetime(FAR const struct tm *tp) dr = (rtc_bin2bcd(tp->tm_mday) << RTC_DR_DU_SHIFT) | ((rtc_bin2bcd(tp->tm_mon + 1)) << RTC_DR_MU_SHIFT) | -#if defined(CONFIG_LIBC_LOCALTIME) || defined(CONFIG_TIME_EXTENDED) ((tp->tm_wday == 0 ? 7 : (tp->tm_wday & 7)) << RTC_DR_WDU_SHIFT) | -#endif ((rtc_bin2bcd(tp->tm_year - 100)) << RTC_DR_YU_SHIFT); dr &= ~RTC_DR_RESERVED_BITS; @@ -1063,9 +1066,11 @@ int stm32_rtc_setalarm(FAR const struct timespec *tp, alarmcb_t callback) g_alarmcb = callback; /* Break out the time values */ + #warning "Missing logic" /* The set the alarm */ + #warning "Missing logic" ret = OK; diff --git a/arch/arm/src/stm32/stm32f40xxx_rtcc.c b/arch/arm/src/stm32/stm32f40xxx_rtcc.c index 8529924fc9..e9dc53e20a 100644 --- a/arch/arm/src/stm32/stm32f40xxx_rtcc.c +++ b/arch/arm/src/stm32/stm32f40xxx_rtcc.c @@ -65,6 +65,7 @@ ****************************************************************************/ /* Configuration ************************************************************/ + /* This RTC implementation supports * - date/time RTC hardware * - extended functions Alarm A and B for STM32F4xx and onwards @@ -198,7 +199,7 @@ static void rtc_dumpregs(FAR const char *msg) ((getreg32(STM32_EXTI_FTSR) & EXTI_RTC_ALARM) ? 0x0100 : 0) | ((getreg32(STM32_EXTI_IMR) & EXTI_RTC_ALARM) ? 0x0010 : 0) | ((getreg32(STM32_EXTI_EMR) & EXTI_RTC_ALARM) ? 0x0001 : 0); - rtcinfo("EXTI (RTSR FTSR ISR EVT): %01x\n",rtc_state); + rtcinfo("EXTI (RTSR FTSR ISR EVT): %01x\n", rtc_state); } #else # define rtc_dumpregs(msg) @@ -852,7 +853,8 @@ static inline void rtc_enable_alarm(void) #ifdef CONFIG_RTC_ALARM static int stm32_rtc_getalarmdatetime(rtc_alarmreg_t reg, FAR struct tm *tp) { - uint32_t data, tmp; + uint32_t data; + uint32_t tmp; DEBUGASSERT(tp != NULL); @@ -915,6 +917,7 @@ int up_rtc_initialize(void) */ /* Select the clock source */ + /* Save the token before losing it when resetting */ regval = getreg32(RTC_MAGIC_REG); @@ -1085,7 +1088,7 @@ int up_rtc_initialize(void) return OK; } -/************************************************************************************ +/**************************************************************************** * Name: stm32_rtc_irqinitialize * * Description: @@ -1098,7 +1101,7 @@ int up_rtc_initialize(void) * Returned Value: * Zero (OK) on success; a negated errno on failure * - ************************************************************************************/ + ****************************************************************************/ int stm32_rtc_irqinitialize(void) { @@ -1162,6 +1165,7 @@ int up_rtc_getdatetime(FAR struct tm *tp) continue; } #endif + tmp = getreg32(STM32_RTC_DR); if (tmp == dr) { @@ -1204,12 +1208,12 @@ int up_rtc_getdatetime(FAR struct tm *tp) tmp = (dr & (RTC_DR_YU_MASK | RTC_DR_YT_MASK)) >> RTC_DR_YU_SHIFT; tp->tm_year = rtc_bcd2bin(tmp) + 100; -#if defined(CONFIG_LIBC_LOCALTIME) || defined(CONFIG_TIME_EXTENDED) tmp = (dr & RTC_DR_WDU_MASK) >> RTC_DR_WDU_SHIFT; tp->tm_wday = tmp % 7; - tp->tm_yday = tp->tm_mday + clock_daysbeforemonth(tp->tm_mon, clock_isleapyear(tp->tm_year + 1900)); + tp->tm_yday = tp->tm_mday + + clock_daysbeforemonth(tp->tm_mon, + clock_isleapyear(tp->tm_year + 1900)); tp->tm_isdst = 0; -#endif #ifdef CONFIG_STM32_HAVE_RTC_SUBSECONDS /* Return RTC sub-seconds if no configured and if a non-NULL value @@ -1318,9 +1322,7 @@ int stm32_rtc_setdatetime(FAR const struct tm *tp) dr = (rtc_bin2bcd(tp->tm_mday) << RTC_DR_DU_SHIFT) | ((rtc_bin2bcd(tp->tm_mon + 1)) << RTC_DR_MU_SHIFT) | -#if defined(CONFIG_LIBC_LOCALTIME) || defined(CONFIG_TIME_EXTENDED) ((tp->tm_wday == 0 ? 7 : (tp->tm_wday & 7)) << RTC_DR_WDU_SHIFT) | -#endif ((rtc_bin2bcd(tp->tm_year - 100)) << RTC_DR_YU_SHIFT); dr &= ~RTC_DR_RESERVED_BITS; diff --git a/arch/arm/src/stm32/stm32l15xxx_rtcc.c b/arch/arm/src/stm32/stm32l15xxx_rtcc.c index b12346b7ec..60e9a0c1b9 100644 --- a/arch/arm/src/stm32/stm32l15xxx_rtcc.c +++ b/arch/arm/src/stm32/stm32l15xxx_rtcc.c @@ -66,6 +66,7 @@ ****************************************************************************/ /* Configuration ************************************************************/ + /* This RTC implementation supports * - date/time RTC hardware * - extended functions Alarm A and B @@ -216,7 +217,7 @@ static void rtc_dumptime(FAR const struct tm *tp, FAR const char *msg) rtcinfo(" tm_year: %08x\n", tp->tm_year); #else rtcinfo(" tm: %04d-%02d-%02d %02d:%02d:%02d\n", - tp->tm_year+1900, tp->tm_mon+1, tp->tm_mday, + tp->tm_year + 1900, tp->tm_mon + 1, tp->tm_mday, tp->tm_hour, tp->tm_min, tp->tm_sec); #endif } @@ -493,7 +494,8 @@ static void rtc_resume(void) ****************************************************************************/ #ifdef CONFIG_RTC_ALARM -static int stm32_rtc_alarm_handler(int irq, FAR void *context, FAR void *rtc_handler_arg) +static int stm32_rtc_alarm_handler(int irq, FAR void *context, + FAR void *rtc_handler_arg) { FAR struct alm_cbinfo_s *cbinfo; alm_callback_t cb; @@ -802,7 +804,8 @@ static inline void rtc_enable_alarm(void) #ifdef CONFIG_RTC_ALARM static int stm32_rtc_getalarmdatetime(rtc_alarmreg_t reg, FAR struct tm *tp) { - uint32_t data, tmp; + uint32_t data; + uint32_t tmp; DEBUGASSERT(tp != NULL); @@ -1017,7 +1020,7 @@ int up_rtc_initialize(void) return OK; } -/************************************************************************************ +/**************************************************************************** * Name: stm32_rtc_irqinitialize * * Description: @@ -1030,7 +1033,7 @@ int up_rtc_initialize(void) * Returned Value: * Zero (OK) on success; a negated errno on failure * - ************************************************************************************/ + ****************************************************************************/ int stm32_rtc_irqinitialize(void) { @@ -1089,6 +1092,7 @@ int stm32_rtc_getdatetime_with_subseconds(FAR struct tm *tp, FAR long *nsec) continue; } #endif + tmp = getreg32(STM32_RTC_DR); if (tmp == dr) { @@ -1131,12 +1135,12 @@ int stm32_rtc_getdatetime_with_subseconds(FAR struct tm *tp, FAR long *nsec) tmp = (dr & (RTC_DR_YU_MASK | RTC_DR_YT_MASK)) >> RTC_DR_YU_SHIFT; tp->tm_year = rtc_bcd2bin(tmp) + 100; -#if defined(CONFIG_LIBC_LOCALTIME) || defined(CONFIG_TIME_EXTENDED) tmp = (dr & RTC_DR_WDU_MASK) >> RTC_DR_WDU_SHIFT; tp->tm_wday = tmp % 7; - tp->tm_yday = tp->tm_mday + clock_daysbeforemonth(tp->tm_mon, clock_isleapyear(tp->tm_year + 1900)); + tp->tm_yday = tp->tm_mday + + clock_daysbeforemonth(tp->tm_mon, + clock_isleapyear(tp->tm_year + 1900)); tp->tm_isdst = 0; -#endif /* Return RTC sub-seconds if a non-NULL value * of nsec has been provided to receive the sub-second value. @@ -1202,14 +1206,15 @@ int up_rtc_getdatetime(FAR struct tm *tp) * Description: * Get the current date and time from the date/time RTC. This interface * is only supported by the date/time RTC hardware implementation. - * It is used to replace the system timer. It is only used by the RTOS during - * initialization to set up the system time when CONFIG_RTC and CONFIG_RTC_DATETIME - * are selected (and CONFIG_RTC_HIRES is not). + * It is used to replace the system timer. It is only used by the RTOS + * during initialization to set up the system time when CONFIG_RTC and + * CONFIG_RTC_DATETIME are selected (and CONFIG_RTC_HIRES is not). * - * NOTE: This interface exposes sub-second accuracy capability of RTC hardware. - * This interface allow maintaining timing accuracy when system time needs constant - * resynchronization with RTC, for example with board level power-save mode utilizing - * deep-sleep modes such as STOP on STM32 MCUs. + * NOTE: This interface exposes sub-second accuracy capability of RTC + * hardware. This interface allow maintaining timing accuracy when + * system time needs constant resynchronization with RTC, for example + * with board level power-save mode utilizing deep-sleep modes such as + * STOP on STM32 MCUs. * * Input Parameters: * tp - The location to return the high resolution time value. @@ -1277,9 +1282,7 @@ int stm32_rtc_setdatetime(FAR const struct tm *tp) dr = (rtc_bin2bcd(tp->tm_mday) << RTC_DR_DU_SHIFT) | ((rtc_bin2bcd(tp->tm_mon + 1)) << RTC_DR_MU_SHIFT) | -#if defined(CONFIG_LIBC_LOCALTIME) || defined(CONFIG_TIME_EXTENDED) ((tp->tm_wday == 0 ? 7 : (tp->tm_wday & 7)) << RTC_DR_WDU_SHIFT) | -#endif ((rtc_bin2bcd(tp->tm_year - 100)) << RTC_DR_YU_SHIFT); dr &= ~RTC_DR_RESERVED_BITS; @@ -1661,13 +1664,13 @@ static inline void rtc_enable_wakeup(void) } #endif -/************************************************************************************ +/**************************************************************************** * Name: rtc_set_wcksel * * Description: * Sets RTC wakeup clock selection value * - ************************************************************************************/ + ****************************************************************************/ #ifdef CONFIG_RTC_PERIODIC static inline void rtc_set_wcksel(unsigned int wucksel) @@ -1711,7 +1714,7 @@ int stm32_rtc_setperiodic(FAR const struct timespec *period, wakeupcb_t callback #elif defined(CONFIG_STM32_RTC_LSICLOCK) # error "Periodic wakeup not available for LSI (and it is too inaccurate!)" #elif defined(CONFIG_STM32_RTC_LSECLOCK) - const uint32_t rtc_div16_max_msecs = 16 * 1000 * 0xffffU / STM32_LSE_FREQUENCY; + const uint32_t rtc_div16_max_msecs = 16 * 1000 * 0xffffu / STM32_LSE_FREQUENCY; #else # error "No clock for RTC!" #endif @@ -1722,12 +1725,12 @@ int stm32_rtc_setperiodic(FAR const struct timespec *period, wakeupcb_t callback * We currently go for subseconds accuracy instead of maximum period. */ - if (period->tv_sec > 0xffffU || - (period->tv_sec == 0xffffU && period->tv_nsec > 0)) + if (period->tv_sec > 0xffffu || + (period->tv_sec == 0xffffu && period->tv_nsec > 0)) { /* More than max. */ - secs = 0xffffU; + secs = 0xffffu; millisecs = secs * 1000; } else @@ -1833,6 +1836,7 @@ int stm32_rtc_setperiodic(FAR const struct timespec *period, wakeupcb_t callback * Zero (OK) on success; a negated errno on failure * ****************************************************************************/ + #ifdef CONFIG_RTC_PERIODIC int stm32_rtc_cancelperiodic(void) { diff --git a/arch/arm/src/stm32f7/stm32_rtc.c b/arch/arm/src/stm32f7/stm32_rtc.c index 3ce5ffa650..efd615aa95 100644 --- a/arch/arm/src/stm32f7/stm32_rtc.c +++ b/arch/arm/src/stm32f7/stm32_rtc.c @@ -1147,6 +1147,7 @@ int up_rtc_getdatetime(FAR struct tm *tp) continue; } #endif + tmp = getreg32(STM32_RTC_DR); if (tmp == dr) { @@ -1189,13 +1190,11 @@ int up_rtc_getdatetime(FAR struct tm *tp) tmp = (dr & (RTC_DR_YU_MASK | RTC_DR_YT_MASK)) >> RTC_DR_YU_SHIFT; tp->tm_year = rtc_bcd2bin(tmp) + 100; -#if defined(CONFIG_LIBC_LOCALTIME) || defined(CONFIG_TIME_EXTENDED) tmp = (dr & RTC_DR_WDU_MASK) >> RTC_DR_WDU_SHIFT; tp->tm_wday = tmp % 7; tp->tm_yday = tp->tm_mday + clock_daysbeforemonth(tp->tm_mon, clock_isleapyear(tp->tm_year + 1900)); tp->tm_isdst = 0; -#endif #ifdef CONFIG_STM32F7_HAVE_RTC_SUBSECONDS /* Return RTC sub-seconds if a non-NULL value @@ -1340,9 +1339,7 @@ int stm32_rtc_setdatetime(FAR const struct tm *tp) dr = (rtc_bin2bcd(tp->tm_mday) << RTC_DR_DU_SHIFT) | ((rtc_bin2bcd(tp->tm_mon + 1)) << RTC_DR_MU_SHIFT) | -#if defined(CONFIG_LIBC_LOCALTIME) || defined(CONFIG_TIME_EXTENDED) ((tp->tm_wday == 0 ? 7 : (tp->tm_wday & 7)) << RTC_DR_WDU_SHIFT) | -#endif ((rtc_bin2bcd(tp->tm_year - 100)) << RTC_DR_YU_SHIFT); dr &= ~RTC_DR_RESERVED_BITS; @@ -1742,13 +1739,13 @@ static inline void rtc_enable_wakeup(void) } #endif -/************************************************************************************ +/**************************************************************************** * Name: rtc_set_wcksel * * Description: * Sets RTC wakeup clock selection value * - ************************************************************************************/ + ****************************************************************************/ #ifdef CONFIG_RTC_PERIODIC static inline void rtc_set_wcksel(unsigned int wucksel) diff --git a/arch/arm/src/stm32h7/stm32_rtc.c b/arch/arm/src/stm32h7/stm32_rtc.c index 6301c91895..3f34a066af 100644 --- a/arch/arm/src/stm32h7/stm32_rtc.c +++ b/arch/arm/src/stm32h7/stm32_rtc.c @@ -1147,6 +1147,7 @@ int up_rtc_getdatetime(FAR struct tm *tp) continue; } #endif + tmp = getreg32(STM32_RTC_DR); if (tmp == dr) { @@ -1189,13 +1190,11 @@ int up_rtc_getdatetime(FAR struct tm *tp) tmp = (dr & (RTC_DR_YU_MASK | RTC_DR_YT_MASK)) >> RTC_DR_YU_SHIFT; tp->tm_year = rtc_bcd2bin(tmp) + 100; -#if defined(CONFIG_LIBC_LOCALTIME) || defined(CONFIG_TIME_EXTENDED) tmp = (dr & RTC_DR_WDU_MASK) >> RTC_DR_WDU_SHIFT; tp->tm_wday = tmp % 7; tp->tm_yday = tp->tm_mday + clock_daysbeforemonth(tp->tm_mon, clock_isleapyear(tp->tm_year + 1900)); tp->tm_isdst = 0; -#endif #ifdef CONFIG_STM32H7_HAVE_RTC_SUBSECONDS /* Return RTC sub-seconds if a non-NULL value @@ -1340,9 +1339,7 @@ int stm32_rtc_setdatetime(FAR const struct tm *tp) dr = (rtc_bin2bcd(tp->tm_mday) << RTC_DR_DU_SHIFT) | ((rtc_bin2bcd(tp->tm_mon + 1)) << RTC_DR_MU_SHIFT) | -#if defined(CONFIG_LIBC_LOCALTIME) || defined(CONFIG_TIME_EXTENDED) ((tp->tm_wday == 0 ? 7 : (tp->tm_wday & 7)) << RTC_DR_WDU_SHIFT) | -#endif ((rtc_bin2bcd(tp->tm_year - 100)) << RTC_DR_YU_SHIFT); dr &= ~RTC_DR_RESERVED_BITS; @@ -1742,13 +1739,13 @@ static inline void rtc_enable_wakeup(void) } #endif -/************************************************************************************ +/**************************************************************************** * Name: rtc_set_wcksel * * Description: * Sets RTC wakeup clock selection value * - ************************************************************************************/ + ****************************************************************************/ #ifdef CONFIG_RTC_PERIODIC static inline void rtc_set_wcksel(unsigned int wucksel) diff --git a/arch/arm/src/stm32l4/stm32l4_rtc.c b/arch/arm/src/stm32l4/stm32l4_rtc.c index 0cdf628a4a..f99783dbca 100644 --- a/arch/arm/src/stm32l4/stm32l4_rtc.c +++ b/arch/arm/src/stm32l4/stm32l4_rtc.c @@ -67,6 +67,7 @@ ****************************************************************************/ /* Configuration ************************************************************/ + /* This RTC implementation supports * - date/time RTC hardware * - extended functions Alarm A and B @@ -195,7 +196,7 @@ static void rtc_dumptime(FAR const struct tm *tp, FAR const char *msg) rtcinfo(" tm_year: %08x\n", tp->tm_year); #else rtcinfo(" tm: %04d-%02d-%02d %02d:%02d:%02d\n", - tp->tm_year+1900, tp->tm_mon+1, tp->tm_mday, + tp->tm_year + 1900, tp->tm_mon + 1, tp->tm_mday, tp->tm_hour, tp->tm_min, tp->tm_sec); #endif } @@ -226,7 +227,7 @@ static void rtc_wprunlock(void) /* The following steps are required to unlock the write protection on all the * RTC registers (except for RTC_ISR[13:8], RTC_TAFCR, and RTC_BKPxR). * - * 1. Write 0xCA into the RTC_WPR register. + * 1. Write 0xca into the RTC_WPR register. * 2. Write 0x53 into the RTC_WPR register. * * Writing a wrong key re-activates the write protection. @@ -472,7 +473,8 @@ static void rtc_resume(void) ****************************************************************************/ #ifdef CONFIG_RTC_ALARM -static int stm32l4_rtc_alarm_handler(int irq, FAR void *context, FAR void *rtc_handler_arg) +static int stm32l4_rtc_alarm_handler(int irq, FAR void *context, + FAR void *rtc_handler_arg) { FAR struct alm_cbinfo_s *cbinfo; alm_callback_t cb; @@ -781,7 +783,8 @@ static inline void rtc_enable_alarm(void) #ifdef CONFIG_RTC_ALARM static int stm32l4_rtc_getalarmdatetime(rtc_alarmreg_t reg, FAR struct tm *tp) { - uint32_t data, tmp; + uint32_t data; + uint32_t tmp; DEBUGASSERT(tp != NULL); @@ -1046,6 +1049,7 @@ int stm32l4_rtc_getdatetime_with_subseconds(FAR struct tm *tp, FAR long *nsec) continue; } #endif + tmp = getreg32(STM32L4_RTC_DR); if (tmp == dr) { @@ -1088,12 +1092,12 @@ int stm32l4_rtc_getdatetime_with_subseconds(FAR struct tm *tp, FAR long *nsec) tmp = (dr & (RTC_DR_YU_MASK | RTC_DR_YT_MASK)) >> RTC_DR_YU_SHIFT; tp->tm_year = rtc_bcd2bin(tmp) + 100; -#if defined(CONFIG_LIBC_LOCALTIME) || defined(CONFIG_TIME_EXTENDED) tmp = (dr & RTC_DR_WDU_MASK) >> RTC_DR_WDU_SHIFT; tp->tm_wday = tmp % 7; - tp->tm_yday = tp->tm_mday + clock_daysbeforemonth(tp->tm_mon, clock_isleapyear(tp->tm_year + 1900)); + tp->tm_yday = tp->tm_mday + + clock_daysbeforemonth(tp->tm_mon, + clock_isleapyear(tp->tm_year + 1900)); tp->tm_isdst = 0; -#endif /* Return RTC sub-seconds if a non-NULL value * of nsec has been provided to receive the sub-second value. @@ -1159,14 +1163,15 @@ int up_rtc_getdatetime(FAR struct tm *tp) * Description: * Get the current date and time from the date/time RTC. This interface * is only supported by the date/time RTC hardware implementation. - * It is used to replace the system timer. It is only used by the RTOS during - * initialization to set up the system time when CONFIG_RTC and CONFIG_RTC_DATETIME - * are selected (and CONFIG_RTC_HIRES is not). + * It is used to replace the system timer. It is only used by the RTOS + * during initialization to set up the system time when CONFIG_RTC and + * CONFIG_RTC_DATETIME are selected (and CONFIG_RTC_HIRES is not). * - * NOTE: This interface exposes sub-second accuracy capability of RTC hardware. - * This interface allow maintaining timing accuracy when system time needs constant - * resynchronization with RTC, for example with board level power-save mode utilizing - * deep-sleep modes such as STOP on STM32 MCUs. + * NOTE: This interface exposes sub-second accuracy capability of RTC + * hardware. This interface allow maintaining timing accuracy when system + * time needs constant resynchronization with RTC, for example with board + * level power-save mode utilizing deep-sleep modes such as STOP on STM32 + * MCUs. * * Input Parameters: * tp - The location to return the high resolution time value. @@ -1234,9 +1239,7 @@ int stm32l4_rtc_setdatetime(FAR const struct tm *tp) dr = (rtc_bin2bcd(tp->tm_mday) << RTC_DR_DU_SHIFT) | ((rtc_bin2bcd(tp->tm_mon + 1)) << RTC_DR_MU_SHIFT) | -#if defined(CONFIG_LIBC_LOCALTIME) || defined(CONFIG_TIME_EXTENDED) ((tp->tm_wday == 0 ? 7 : (tp->tm_wday & 7)) << RTC_DR_WDU_SHIFT) | -#endif ((rtc_bin2bcd(tp->tm_year - 100)) << RTC_DR_YU_SHIFT); dr &= ~RTC_DR_RESERVED_BITS; @@ -1618,13 +1621,13 @@ static inline void rtc_enable_wakeup(void) } #endif -/************************************************************************************ +/**************************************************************************** * Name: rtc_set_wcksel * * Description: * Sets RTC wakeup clock selection value * - ************************************************************************************/ + ****************************************************************************/ #ifdef CONFIG_RTC_PERIODIC static inline void rtc_set_wcksel(unsigned int wucksel) @@ -1668,7 +1671,7 @@ int stm32l4_rtc_setperiodic(FAR const struct timespec *period, wakeupcb_t callba #elif defined(CONFIG_STM32L4_RTC_LSICLOCK) # error "Periodic wakeup not available for LSI (and it is too inaccurate!)" #elif defined(CONFIG_STM32L4_RTC_LSECLOCK) - const uint32_t rtc_div16_max_msecs = 16 * 1000 * 0xffffU / STM32L4_LSE_FREQUENCY; + const uint32_t rtc_div16_max_msecs = 16 * 1000 * 0xffffu / STM32L4_LSE_FREQUENCY; #else # error "No clock for RTC!" #endif @@ -1679,12 +1682,12 @@ int stm32l4_rtc_setperiodic(FAR const struct timespec *period, wakeupcb_t callba * We currently go for subseconds accuracy instead of maximum period. */ - if (period->tv_sec > 0xffffU || - (period->tv_sec == 0xffffU && period->tv_nsec > 0)) + if (period->tv_sec > 0xffffu || + (period->tv_sec == 0xffffu && period->tv_nsec > 0)) { /* More than max. */ - secs = 0xffffU; + secs = 0xffffu; millisecs = secs * 1000; } else @@ -1790,6 +1793,7 @@ int stm32l4_rtc_setperiodic(FAR const struct timespec *period, wakeupcb_t callba * Zero (OK) on success; a negated errno on failure * ****************************************************************************/ + #ifdef CONFIG_RTC_PERIODIC int stm32l4_rtc_cancelperiodic(void) { diff --git a/arch/z80/src/ez80/Kconfig b/arch/z80/src/ez80/Kconfig index fe99f5a7b9..ca8bb1486e 100644 --- a/arch/z80/src/ez80/Kconfig +++ b/arch/z80/src/ez80/Kconfig @@ -35,7 +35,6 @@ config EZ80_RTC default n select RTC select RTC_DATETIME - select TIME_EXTENDED config EZ80_EMAC bool "Ethernet MAC" diff --git a/arch/z80/src/ez80/ez80_rtc.c b/arch/z80/src/ez80/ez80_rtc.c index 40d1564f3e..0a42252bb6 100644 --- a/arch/z80/src/ez80/ez80_rtc.c +++ b/arch/z80/src/ez80/ez80_rtc.c @@ -72,7 +72,7 @@ /**************************************************************************** * Private Types - *****************************************************************************/ + ****************************************************************************/ /* Raw time from the RTC. All are binary. */ @@ -198,9 +198,7 @@ static void rtc_dumptime(FAR const struct tm *tp, FAR const char *msg) rtcinfo(" tm_sec: %08x\n", tp->tm_sec); rtcinfo(" tm_min: %08x\n", tp->tm_min); rtcinfo(" tm_hour: %08x\n", tp->tm_hour); -#if defined(CONFIG_LIBC_LOCALTIME) || defined(CONFIG_TIME_EXTENDED) rtcinfo(" tm_wday: %08x\n", tp->tm_wday); -#endif rtcinfo(" tm_mday: %08x\n", tp->tm_mday); rtcinfo(" tm_mon: %08x\n", tp->tm_mon); rtcinfo(" tm_year: %08x\n", tp->tm_year); @@ -229,7 +227,7 @@ static void rtc_unlock(void) regval = inp(EZ80_RTC_CTRL); regval |= EZ80_RTC_UNLOCK; - outp(EZ80_RTC_CTRL,regval); + outp(EZ80_RTC_CTRL, regval); } /**************************************************************************** @@ -252,7 +250,7 @@ static void rtc_lock(void) regval = inp(EZ80_RTC_CTRL); regval &= ~EZ80_RTC_UNLOCK; - outp(EZ80_RTC_CTRL,regval); + outp(EZ80_RTC_CTRL, regval); } /**************************************************************************** @@ -453,7 +451,7 @@ int up_rtc_initialize(void) return OK; } -/************************************************************************************ +/**************************************************************************** * Name: z80_rtc_irqinitialize * * Description: @@ -466,7 +464,7 @@ int up_rtc_initialize(void) * Returned Value: * Zero (OK) on success; a negated errno on failure * - ************************************************************************************/ + ****************************************************************************/ #ifdef CONFIG_RTC_ALARM int z80_rtc_irqinitialize(void) @@ -642,9 +640,7 @@ int ez80_rtc_setalarm(FAR struct alm_setalarm_s *alminfo) almregs.sec = alminfo->as_time.tm_sec; almregs.min = alminfo->as_time.tm_min; almregs.hrs = alminfo->as_time.tm_hour; -#if defined(CONFIG_LIBC_LOCALTIME) || defined(CONFIG_TIME_EXTENDED) almregs.dow = alminfo->as_time.tm_wday; -#endif set_raw_alarm(&almregs); @@ -747,9 +743,7 @@ int ez80_rtc_rdalarm(FAR struct tm *almtime) almtime->tm_sec = almregs.sec; almtime->tm_min = almregs.min; almtime->tm_hour = almregs.hrs; -#if defined(CONFIG_LIBC_LOCALTIME) || defined(CONFIG_TIME_EXTENDED) almtime->tm_wday = almregs.dow; -#endif rtc_dumptime((FAR const struct tm *)almtime, "Returning"); return OK; diff --git a/boards/sim/sim/sim/configs/bluetooth/defconfig b/boards/sim/sim/sim/configs/bluetooth/defconfig index e148c8d5de..54e5c9b10e 100644 --- a/boards/sim/sim/sim/configs/bluetooth/defconfig +++ b/boards/sim/sim/sim/configs/bluetooth/defconfig @@ -70,7 +70,6 @@ CONFIG_SIM_WALLTIME=y CONFIG_START_DAY=3 CONFIG_START_MONTH=4 CONFIG_SYSTEM_NSH=y -CONFIG_TIME_EXTENDED=y CONFIG_USERMAIN_STACKSIZE=4096 CONFIG_USER_ENTRYPOINT="nsh_main" CONFIG_WIRELESS=y diff --git a/boards/sim/sim/sim/configs/ipforward/defconfig b/boards/sim/sim/sim/configs/ipforward/defconfig index 408f231116..70b2ca964b 100644 --- a/boards/sim/sim/sim/configs/ipforward/defconfig +++ b/boards/sim/sim/sim/configs/ipforward/defconfig @@ -72,7 +72,6 @@ CONFIG_SIM_WALLTIME=y CONFIG_START_MONTH=6 CONFIG_START_YEAR=2008 CONFIG_SYSTEM_NSH=y -CONFIG_TIME_EXTENDED=y CONFIG_TUN_NINTERFACES=2 CONFIG_USERMAIN_STACKSIZE=4096 CONFIG_USER_ENTRYPOINT="nsh_main" diff --git a/boards/sim/sim/sim/configs/loadable/defconfig b/boards/sim/sim/sim/configs/loadable/defconfig index 17d59c2848..a5ff865965 100644 --- a/boards/sim/sim/sim/configs/loadable/defconfig +++ b/boards/sim/sim/sim/configs/loadable/defconfig @@ -51,6 +51,5 @@ CONFIG_SIM_WALLTIME=y CONFIG_START_MONTH=6 CONFIG_START_YEAR=2008 CONFIG_SYSTEM_NSH=m -CONFIG_TIME_EXTENDED=y CONFIG_USERMAIN_STACKSIZE=4096 CONFIG_USER_INITPATH="/system/bin/nsh" diff --git a/boards/sim/sim/sim/configs/minibasic/defconfig b/boards/sim/sim/sim/configs/minibasic/defconfig index bc8e3ce7fa..856e5bd820 100644 --- a/boards/sim/sim/sim/configs/minibasic/defconfig +++ b/boards/sim/sim/sim/configs/minibasic/defconfig @@ -56,6 +56,5 @@ CONFIG_SIM_WALLTIME=y CONFIG_START_MONTH=6 CONFIG_START_YEAR=2008 CONFIG_SYSTEM_NSH=y -CONFIG_TIME_EXTENDED=y CONFIG_USERMAIN_STACKSIZE=4096 CONFIG_USER_ENTRYPOINT="nsh_main" diff --git a/boards/sim/sim/sim/configs/nsh/defconfig b/boards/sim/sim/sim/configs/nsh/defconfig index 3f8e571c88..5cd75c8b16 100644 --- a/boards/sim/sim/sim/configs/nsh/defconfig +++ b/boards/sim/sim/sim/configs/nsh/defconfig @@ -58,6 +58,5 @@ CONFIG_SIM_WALLTIME=y CONFIG_START_MONTH=6 CONFIG_START_YEAR=2008 CONFIG_SYSTEM_NSH=y -CONFIG_TIME_EXTENDED=y CONFIG_USERMAIN_STACKSIZE=4096 CONFIG_USER_ENTRYPOINT="nsh_main" diff --git a/boards/sim/sim/sim/configs/userfs/defconfig b/boards/sim/sim/sim/configs/userfs/defconfig index 0e5f12cfad..41fc752350 100644 --- a/boards/sim/sim/sim/configs/userfs/defconfig +++ b/boards/sim/sim/sim/configs/userfs/defconfig @@ -61,6 +61,5 @@ CONFIG_SIM_WALLTIME=y CONFIG_START_MONTH=6 CONFIG_START_YEAR=2008 CONFIG_SYSTEM_NSH=y -CONFIG_TIME_EXTENDED=y CONFIG_USERMAIN_STACKSIZE=8192 CONFIG_USER_ENTRYPOINT="nsh_main" diff --git a/boards/z16/z16f/z16f2800100zcog/README.txt b/boards/z16/z16f/z16f2800100zcog/README.txt index cbe9a362da..22387c42c5 100644 --- a/boards/z16/z16f/z16f2800100zcog/README.txt +++ b/boards/z16/z16f/z16f2800100zcog/README.txt @@ -78,18 +78,16 @@ Version 5.2.1 This is the change to suppress building these files: diff --git a/libs/libc/time/Make.defs b/libs/libc/time/Make.defs - index 5c9b746778..8327e287f4 100644 + index 2a26d556ff..08fd0b7bcd 100644 --- a/libs/libc/time/Make.defs +++ b/libs/libc/time/Make.defs - @@ -44,7 +44,7 @@ ifdef CONFIG_LIBC_LOCALTIME - CSRCS += lib_localtime.c lib_asctime.c lib_asctimer.c lib_ctime.c - CSRCS += lib_ctimer.c + @@ -44,7 +44,7 @@ CSRCS += lib_asctime.c lib_asctimer.c lib_ctime.c lib_ctimer.c + ifdef CONFIG_LIBC_LOCALTIME + CSRCS += lib_localtime.c else -CSRCS += lib_mktime.c lib_gmtime.c lib_gmtimer.c - +CSRCS += lib_mktime.c # lib_gmtime.c lib_gmtimer.c - ifdef CONFIG_TIME_EXTENDED - CSRCS += lib_dayofweek.c lib_asctime.c lib_asctimer.c lib_ctime.c - CSRCS += lib_ctimer.c + +CSRCS += lib_mktime.c #lib_gmtime.c lib_gmtimer.c + endif The consequence is, of course, that these interfaces will not be available to applications. diff --git a/drivers/timers/ds3231.c b/drivers/timers/ds3231.c index a791bce16d..f7b38a3eab 100644 --- a/drivers/timers/ds3231.c +++ b/drivers/timers/ds3231.c @@ -136,11 +136,9 @@ static void rtc_dumptime(FAR struct tm *tp, FAR const char *msg) rtcinfo(" tm_mday: %08x\n", tp->tm_mday); rtcinfo(" tm_mon: %08x\n", tp->tm_mon); rtcinfo(" tm_year: %08x\n", tp->tm_year); -#if defined(CONFIG_LIBC_LOCALTIME) || defined(CONFIG_TIME_EXTENDED) rtcinfo(" tm_wday: %08x\n", tp->tm_wday); rtcinfo(" tm_yday: %08x\n", tp->tm_yday); rtcinfo(" tm_isdst: %08x\n", tp->tm_isdst); -#endif } #else # define rtc_dumptime(tp, msg) @@ -270,12 +268,9 @@ int up_rtc_getdatetime(FAR struct tm *tp) tp->tm_min = 0; tp->tm_hour = 0; -#if defined(CONFIG_LIBC_LOCALTIME) || defined(CONFIG_TIME_EXTENDED) /* Jan 1, 1970 was a Thursday */ tp->tm_wday = 4; -#endif - tp->tm_mday = 1; tp->tm_mon = 0; tp->tm_year = 70; @@ -346,11 +341,9 @@ int up_rtc_getdatetime(FAR struct tm *tp) tp->tm_hour = rtc_bcd2bin(buffer[2] & DSXXXX_TIME_HOUR24_BCDMASK); - #if defined(CONFIG_LIBC_LOCALTIME) || defined(CONFIG_TIME_EXTENDED) /* Return the day of the week (0-6) */ tp->tm_wday = (rtc_bcd2bin(buffer[3]) & DSXXXX_TIME_DAY_MASK) - 1; -#endif /* Return the day of the month (1-31) */ @@ -469,11 +462,7 @@ int up_rtc_settime(FAR const struct timespec *tp) /* Save the day of the week (1-7) */ -#if defined(CONFIG_LIBC_LOCALTIME) || defined(CONFIG_TIME_EXTENDED) buffer[4] = rtc_bin2bcd(newtm.tm_wday + 1); -#else - buffer[4] = 1; -#endif /* Save the day of the month (1-31) */ diff --git a/drivers/timers/mcp794xx.c b/drivers/timers/mcp794xx.c index 314e0ea392..87ecd4d133 100644 --- a/drivers/timers/mcp794xx.c +++ b/drivers/timers/mcp794xx.c @@ -142,11 +142,9 @@ static void rtc_dumptime(FAR struct tm *tp, FAR const char *msg) rtcinfo(" tm_mday: %08x\n", tp->tm_mday); rtcinfo(" tm_mon: %08x\n", tp->tm_mon); rtcinfo(" tm_year: %08x\n", tp->tm_year); -#if defined(CONFIG_LIBC_LOCALTIME) || defined(CONFIG_TIME_EXTENDED) rtcinfo(" tm_wday: %08x\n", tp->tm_wday); rtcinfo(" tm_yday: %08x\n", tp->tm_yday); rtcinfo(" tm_isdst: %08x\n", tp->tm_isdst); -#endif } #else # define rtc_dumptime(tp, msg) @@ -280,12 +278,9 @@ int up_rtc_getdatetime(FAR struct tm *tp) tp->tm_min = 0; tp->tm_hour = 0; -#if defined(CONFIG_LIBC_LOCALTIME) || defined(CONFIG_TIME_EXTENDED) /* Jan 1, 1970 was a Thursday */ tp->tm_wday = 4; -#endif - tp->tm_mday = 1; tp->tm_mon = 0; tp->tm_year = 70; @@ -358,11 +353,9 @@ int up_rtc_getdatetime(FAR struct tm *tp) tp->tm_hour = rtc_bcd2bin(buffer[2] & MCP794XX_RTCHOUR_BCDMASK); - #if defined(CONFIG_LIBC_LOCALTIME) || defined(CONFIG_TIME_EXTENDED) /* Return the day of the week (0-6) */ tp->tm_wday = (rtc_bcd2bin(buffer[3]) & MCP794XX_RTCWKDAY_BCDMASK) - 1; -#endif /* Return the day of the month (1-31) */ @@ -523,11 +516,7 @@ int up_rtc_settime(FAR const struct timespec *tp) /* Save the day of the week (1-7) and enable VBAT. */ -#if defined(CONFIG_LIBC_LOCALTIME) || defined(CONFIG_TIME_EXTENDED) buffer[4] = rtc_bin2bcd(newtm.tm_wday + 1) | MCP794XX_RTCWKDAY_VBATEN; -#else - buffer[4] = 1 | MCP794XX_RTCWKDAY_VBATEN; -#endif /* Save the day of the month (1-31) */ diff --git a/drivers/timers/pcf85263.c b/drivers/timers/pcf85263.c index b836aafc88..53454992f5 100644 --- a/drivers/timers/pcf85263.c +++ b/drivers/timers/pcf85263.c @@ -136,11 +136,9 @@ static void rtc_dumptime(FAR struct tm *tp, FAR const char *msg) rtcinfo(" tm_mday: %08x\n", tp->tm_mday); rtcinfo(" tm_mon: %08x\n", tp->tm_mon); rtcinfo(" tm_year: %08x\n", tp->tm_year); -#if defined(CONFIG_LIBC_LOCALTIME) || defined(CONFIG_TIME_EXTENDED) rtcinfo(" tm_wday: %08x\n", tp->tm_wday); rtcinfo(" tm_yday: %08x\n", tp->tm_yday); rtcinfo(" tm_isdst: %08x\n", tp->tm_isdst); -#endif } #else # define rtc_dumptime(tp, msg) @@ -269,12 +267,9 @@ int up_rtc_getdatetime(FAR struct tm *tp) tp->tm_min = 0; tp->tm_hour = 0; -#if defined(CONFIG_LIBC_LOCALTIME) || defined(CONFIG_TIME_EXTENDED) /* Jan 1, 1970 was a Thursday */ tp->tm_wday = 4; -#endif - tp->tm_mday = 1; tp->tm_mon = 0; tp->tm_year = 70; @@ -349,11 +344,9 @@ int up_rtc_getdatetime(FAR struct tm *tp) tp->tm_mday = rtc_bcd2bin(buffer[3] & PCF85263_RTC_DAYS_MASK); -#if defined(CONFIG_LIBC_LOCALTIME) || defined(CONFIG_TIME_EXTENDED) /* Return the day of the week (0-6) */ tp->tm_wday = (rtc_bcd2bin(buffer[4]) & PCF85263_RTC_WEEKDAYS_MASK); -#endif /* Return the month (0-11) */ @@ -460,11 +453,7 @@ int up_rtc_settime(FAR const struct timespec *tp) /* Save the day of the week (1-7) */ -#if defined(CONFIG_LIBC_LOCALTIME) || defined(CONFIG_TIME_EXTENDED) buffer[6] = rtc_bin2bcd(newtm.tm_wday); -#else - buffer[6] = 0; -#endif /* Save the month (1-12) */ diff --git a/include/nuttx/time.h b/include/nuttx/time.h index ee4705ba30..d368b017b3 100644 --- a/include/nuttx/time.h +++ b/include/nuttx/time.h @@ -116,9 +116,7 @@ int clock_daysbeforemonth(int month, bool leapyear); * ****************************************************************************/ -#if defined(CONFIG_TIME_EXTENDED) int clock_dayoftheweek(int mday, int month, int year); -#endif /**************************************************************************** * Name: clock_calendar2utc diff --git a/include/nuttx/timers/rtc.h b/include/nuttx/timers/rtc.h index 3d0399d560..f4cab252be 100644 --- a/include/nuttx/timers/rtc.h +++ b/include/nuttx/timers/rtc.h @@ -60,7 +60,9 @@ /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ + /* Configuration ************************************************************/ + /* CONFIG_RTC - Enables general support for a hardware RTC. Specific * architectures may require other specific settings. * @@ -125,6 +127,7 @@ #ifdef CONFIG_RTC_DRIVER /* IOCTL Commands ***********************************************************/ + /* RTC driver IOCTL commands. These are Linux compatible command names, not * all of these commands are supported by all RTC drivers, however. */ @@ -145,7 +148,6 @@ #define RTC_SET_TIME _RTCIOC(0x0002) - /* RTC_HAVE_SET_TIME checks if RTC's time had been set * * Argument: A writable reference to a bool to receive true/false return value @@ -212,6 +214,7 @@ /**************************************************************************** * Public Types ****************************************************************************/ + /* IOCTL data structures */ /* Broken-out time representation used with RTC IOCTL commands: @@ -229,11 +232,9 @@ struct rtc_time int tm_mday; /* Day of the month (1-31) */ int tm_mon; /* Month (0-11) */ int tm_year; /* Years since 1900 */ -#if defined(CONFIG_LIBC_LOCALTIME) || defined(CONFIG_TIME_EXTENDED) int tm_wday; /* Day of the week (0-6) (unused) */ int tm_yday; /* Day of the year (0-365) (unused) */ int tm_isdst; /* Non-0 if daylight savings time is in effect (unused) */ -#endif #if defined(CONFIG_RTC_HIRES) || defined(CONFIG_ARCH_HAVE_RTC_SUBSECONDS) long tm_nsec; /* Nanosecond (0-999999999) */ #endif @@ -246,29 +247,29 @@ struct rtc_time struct rtc_rdalarm_s { - uint8_t id; /* Indicates the alarm being queried */ - bool active; /* Alarm actively timing or disabled */ - struct rtc_time time; /* Current RTC time (if enabled) */ + uint8_t id; /* Indicates the alarm being queried */ + bool active; /* Alarm actively timing or disabled */ + struct rtc_time time; /* Current RTC time (if enabled) */ }; /* Structure used with the RTC_SET_ALARM IOCTL command. */ struct rtc_setalarm_s { - uint8_t id; /* Indicates the alarm to be set */ - pid_t pid; /* Identifies task to be notified (0=caller) */ - struct sigevent event; /* Describe the way a task is to be notified */ - struct rtc_time time; /* Alarm time */ + uint8_t id; /* Indicates the alarm to be set */ + pid_t pid; /* Identifies task to be notified (0=caller) */ + struct sigevent event; /* Describe the way a task is to be notified */ + struct rtc_time time; /* Alarm time */ }; /* Structure used with the RTC_SET_RELATIVE IOCTL command. */ struct rtc_setrelative_s { - uint8_t id; /* Indicates the alarm to be set */ - pid_t pid; /* Identifies task to be notified (0=caller) */ - struct sigevent event; /* Describe the way a task is to be notified */ - time_t reltime; /* Relative time in seconds */ + uint8_t id; /* Indicates the alarm to be set */ + pid_t pid; /* Identifies task to be notified (0=caller) */ + struct sigevent event; /* Describe the way a task is to be notified */ + time_t reltime; /* Relative time in seconds */ }; /* Callback type used by the RTC hardware to notify the RTC driver when the @@ -281,29 +282,29 @@ typedef CODE void (*rtc_alarm_callback_t)(FAR void *priv, int alarmid); struct lower_setalarm_s { - uint8_t id; /* Indicates the alarm to be set */ - rtc_alarm_callback_t cb; /* Callback when the alarm expires */ - FAR void *priv; /* Private argument to accompany callback */ - struct rtc_time time; /* Alarm time */ + uint8_t id; /* Indicates the alarm to be set */ + rtc_alarm_callback_t cb; /* Callback when the alarm expires */ + FAR void *priv; /* Private argument to accompany callback */ + struct rtc_time time; /* Alarm time */ }; /* Structure used with the setrelative method */ struct lower_setrelative_s { - uint8_t id; /* Indicates the alarm to be set */ - rtc_alarm_callback_t cb; /* Callback when the alarm expires */ - FAR void *priv; /* Private argument to accompany callback */ - time_t reltime; /* Relative time in seconds */ + uint8_t id; /* Indicates the alarm to be set */ + rtc_alarm_callback_t cb; /* Callback when the alarm expires */ + FAR void *priv; /* Private argument to accompany callback */ + time_t reltime; /* Relative time in seconds */ }; /* Structure used with the rdalarm method */ struct lower_rdalarm_s { - uint8_t id; /* Indicates the alarm to be set */ - FAR void *priv; /* Private argument to accompany callback */ - FAR struct rtc_time *time;/* Queried RTC time pointer */ + uint8_t id; /* Indicates the alarm to be set */ + FAR void *priv; /* Private argument to accompany callback */ + FAR struct rtc_time *time; /* Queried RTC time pointer */ }; #endif @@ -313,10 +314,10 @@ struct lower_rdalarm_s struct rtc_setperiodic_s { - uint8_t id; /* Indicates the alarm to be set */ - pid_t pid; /* Identifies task to be notified (0=caller) */ - struct sigevent event; /* Describe the way a task is to be notified */ - struct timespec period; /* Period between wakeups */ + uint8_t id; /* Indicates the alarm to be set */ + pid_t pid; /* Identifies task to be notified (0=caller) */ + struct sigevent event; /* Describe the way a task is to be notified */ + struct timespec period; /* Period between wakeups */ }; /* Callback type used by the RTC hardware to notify the RTC driver when the @@ -399,16 +400,16 @@ struct rtc_ops_s #endif #ifdef CONFIG_RTC_IOCTL - /* Support for architecture-specific RTC operations */ + /* Support for architecture-specific RTC operations */ CODE int (*ioctl)(FAR struct rtc_lowerhalf_s *lower, int cmd, unsigned long arg); #endif #ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS - /* The driver has been unlinked and there are no further open references - * to the driver. - */ + /* The driver has been unlinked and there are no further open references + * to the driver. + */ CODE int (*destroy)(FAR struct rtc_lowerhalf_s *lower); #endif @@ -447,7 +448,7 @@ extern "C" #endif /**************************************************************************** - * Public Functions + * Public Function Prototypes ****************************************************************************/ /**************************************************************************** diff --git a/include/time.h b/include/time.h index 8c92a3b191..12234432e1 100644 --- a/include/time.h +++ b/include/time.h @@ -140,11 +140,9 @@ struct tm int tm_mday; /* Day of the month (1-31) */ int tm_mon; /* Month (0-11) */ int tm_year; /* Years since 1900 */ -#if defined(CONFIG_LIBC_LOCALTIME) || defined(CONFIG_TIME_EXTENDED) int tm_wday; /* Day of the week (0-6) */ int tm_yday; /* Day of the year (0-365) */ int tm_isdst; /* Non-0 if daylight savings time is in effect */ -#endif }; /* Struct itimerspec is used to define settings for an interval timer */ @@ -175,9 +173,11 @@ extern "C" #ifdef CONFIG_LIBC_LOCALTIME /* daylight - Daylight savings time flag */ + /* EXTERN int daylight; not supported */ /* timezone - Difference from UTC and local standard time */ + /* EXTERN long int timezone; not supported */ /* tzname[] - Timezone strings @@ -209,12 +209,10 @@ FAR struct tm *localtime_r(FAR const time_t *timep, FAR struct tm *result); size_t strftime(FAR char *s, size_t max, FAR const char *format, FAR const struct tm *tm); -#if defined(CONFIG_LIBC_LOCALTIME) || defined(CONFIG_TIME_EXTENDED) FAR char *asctime(FAR const struct tm *tp); FAR char *asctime_r(FAR const struct tm *tp, FAR char *buf); FAR char *ctime(FAR const time_t *timep); FAR char *ctime_r(FAR const time_t *timep, FAR char *buf); -#endif time_t time(FAR time_t *timep); diff --git a/libs/libc/time/Kconfig b/libs/libc/time/Kconfig index a05fcf0ace..d3be629685 100644 --- a/libs/libc/time/Kconfig +++ b/libs/libc/time/Kconfig @@ -68,16 +68,4 @@ config LIB_ZONEINFO_ROMFS endif # LIB_ZONEINFO endif # LIBC_LOCALTIME - -config TIME_EXTENDED - bool "Add day of week, year support" - default "n" - depends on !LIBC_LOCALTIME - ---help--- - Selecting TIME_EXTENDED adds tm_wday, tm_yday and tm_isdst - to the tm struct. This allows integration with 3rd party libraries - that expect the tm struct to contain these members. - - Note: tm_isdst is always 0 - endmenu # Time/Time Zone Support diff --git a/libs/libc/time/Make.defs b/libs/libc/time/Make.defs index 5c9b746778..2a26d556ff 100644 --- a/libs/libc/time/Make.defs +++ b/libs/libc/time/Make.defs @@ -38,17 +38,13 @@ CSRCS += lib_strftime.c lib_calendar2utc.c lib_daysbeforemonth.c CSRCS += lib_gettimeofday.c lib_isleapyear.c lib_settimeofday.c lib_time.c -CSRCS += lib_nanosleep.c lib_difftime.c +CSRCS += lib_nanosleep.c lib_difftime.c lib_dayofweek.c +CSRCS += lib_asctime.c lib_asctimer.c lib_ctime.c lib_ctimer.c ifdef CONFIG_LIBC_LOCALTIME -CSRCS += lib_localtime.c lib_asctime.c lib_asctimer.c lib_ctime.c -CSRCS += lib_ctimer.c +CSRCS += lib_localtime.c else CSRCS += lib_mktime.c lib_gmtime.c lib_gmtimer.c -ifdef CONFIG_TIME_EXTENDED -CSRCS += lib_dayofweek.c lib_asctime.c lib_asctimer.c lib_ctime.c -CSRCS += lib_ctimer.c -endif endif # Add the time directory to the build diff --git a/libs/libc/time/lib_asctime.c b/libs/libc/time/lib_asctime.c index 1face37446..3baf38ac9e 100644 --- a/libs/libc/time/lib_asctime.c +++ b/libs/libc/time/lib_asctime.c @@ -41,8 +41,6 @@ #include -#if defined(CONFIG_LIBC_LOCALTIME) || defined(CONFIG_TIME_EXTENDED) - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -69,5 +67,3 @@ FAR char *asctime(FAR const struct tm *tp) static char buf[26]; return asctime_r(tp, buf); } - -#endif /* CONFIG_LIBC_LOCALTIME || CONFIG_TIME_EXTENDED */ diff --git a/libs/libc/time/lib_asctimer.c b/libs/libc/time/lib_asctimer.c index 6c2b3c0c39..df405b2a57 100644 --- a/libs/libc/time/lib_asctimer.c +++ b/libs/libc/time/lib_asctimer.c @@ -42,11 +42,10 @@ #include #include -#if defined(CONFIG_LIBC_LOCALTIME) || defined(CONFIG_TIME_EXTENDED) - /**************************************************************************** * Private Data ****************************************************************************/ + /* Note: These strings duplicate other definitions in other files. These * definitions could be combined to save a little FLASH space. */ @@ -93,5 +92,3 @@ FAR char *asctime_r(FAR const struct tm *tp, FAR char *buf) return buf; } - -#endif /* CONFIG_LIBC_LOCALTIME || CONFIG_TIME_EXTENDED */ diff --git a/libs/libc/time/lib_ctime.c b/libs/libc/time/lib_ctime.c index e0b15000a4..2f7819cdc3 100644 --- a/libs/libc/time/lib_ctime.c +++ b/libs/libc/time/lib_ctime.c @@ -41,8 +41,6 @@ #include -#if defined(CONFIG_LIBC_LOCALTIME) || defined(CONFIG_TIME_EXTENDED) - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -78,5 +76,3 @@ FAR char *ctime(FAR const time_t *timep) return asctime(gmtime(timep)); #endif } - -#endif /* CONFIG_LIBC_LOCALTIME || CONFIG_TIME_EXTENDED */ diff --git a/libs/libc/time/lib_ctimer.c b/libs/libc/time/lib_ctimer.c index e2ee7ea7bc..77a07d097a 100644 --- a/libs/libc/time/lib_ctimer.c +++ b/libs/libc/time/lib_ctimer.c @@ -41,8 +41,6 @@ #include -#if defined(CONFIG_LIBC_LOCALTIME) || defined(CONFIG_TIME_EXTENDED) - /**************************************************************************** * Private Data ****************************************************************************/ @@ -79,5 +77,3 @@ FAR char *ctime_r(FAR const time_t *timep, FAR char *buf) return asctime_r(gmtime_r(timep, &tm), buf); #endif } - -#endif /* CONFIG_LIBC_LOCALTIME || CONFIG_TIME_EXTENDED */ diff --git a/libs/libc/time/lib_dayofweek.c b/libs/libc/time/lib_dayofweek.c index ceeaffcb62..07b64a289f 100644 --- a/libs/libc/time/lib_dayofweek.c +++ b/libs/libc/time/lib_dayofweek.c @@ -45,8 +45,6 @@ #include -#if defined(CONFIG_TIME_EXTENDED) - /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ @@ -107,4 +105,3 @@ int clock_dayoftheweek(int mday, int month, int year) return (mday + year + year / 4 - year / 100 + year / 400 + (31 * month) / 12) % 7; } -#endif /* CONFIG_TIME_EXTENDED */ diff --git a/libs/libc/time/lib_gmtimer.c b/libs/libc/time/lib_gmtimer.c index 6281d21325..b2c17fc5e5 100644 --- a/libs/libc/time/lib_gmtimer.c +++ b/libs/libc/time/lib_gmtimer.c @@ -122,7 +122,7 @@ static void clock_utc2gregorian(time_t jd, FAR int *year, FAR int *month, l = jd + 68569; n = (4 * l) / 146097; - l = l - (146097 * n + 3)/4; + l = l - (146097 * n + 3) / 4; i = (4000 * (l + 1)) / 1461001; l = l - (1461 * i) / 4 + 31; j = (80 * l) / 2447; @@ -156,7 +156,7 @@ static void clock_utc2julian(time_t jd, FAR int *year, FAR int *month, n = (l - 1) / 365 - l / 1461; i = l - 365 * n + 30; j = (80 * i) / 2447; - d = i - (2447 * j)/80; + d = i - (2447 * j) / 80; i = j / 11; m = j + 2 - 12 * i; y = 4 * k + n + i - 4716; @@ -267,9 +267,9 @@ static void clock_utc2calendar(time_t days, FAR int *year, FAR int *month, } else { - /* No... The one we want is somwhere between value+1 and max */ + /* No... The one we want is somwhere between value+1 and max */ - min = value + 1; + min = value + 1; } /* If we break out of the loop because min == max, then we want value @@ -356,13 +356,11 @@ FAR struct tm *gmtime_r(FAR const time_t *timer, FAR struct tm *result) result->tm_min = (int)min; result->tm_sec = (int)sec; -#if defined(CONFIG_TIME_EXTENDED) result->tm_wday = clock_dayoftheweek(day, month, year); result->tm_yday = day + clock_daysbeforemonth(result->tm_mon, clock_isleapyear(year)); result->tm_isdst = 0; -#endif return result; } diff --git a/libs/libc/time/lib_strftime.c b/libs/libc/time/lib_strftime.c index 6fa5b5f2cf..46165a57c1 100644 --- a/libs/libc/time/lib_strftime.c +++ b/libs/libc/time/lib_strftime.c @@ -70,7 +70,6 @@ * Private Data ****************************************************************************/ -#if defined(CONFIG_LIBC_LOCALTIME) || defined(CONFIG_TIME_EXTENDED) static const char * const g_abbrev_wdayname[7] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" @@ -80,7 +79,6 @@ static const char * const g_wdayname[7] = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" }; -#endif static const char * const g_abbrev_monthname[12] = { @@ -181,7 +179,6 @@ size_t strftime(FAR char *s, size_t max, FAR const char *format, switch (*format++) { -#if defined(CONFIG_LIBC_LOCALTIME) || defined(CONFIG_TIME_EXTENDED) /* %a: A three-letter abbreviation for the day of the week. */ case 'a': @@ -205,17 +202,6 @@ size_t strftime(FAR char *s, size_t max, FAR const char *format, } } break; -#else - /* %a: A three-letter abbreviation for the day of the week. */ - /* %A: The full name for the day of the week. */ - - case 'a': - case 'A': - { - len = snprintf(dest, chleft, "Day"); /* Not supported */ - } - break; -#endif /* %h: Equivalent to %b */ @@ -301,7 +287,9 @@ size_t strftime(FAR char *s, size_t max, FAR const char *format, { if (tm->tm_mon < 12) { - value = clock_daysbeforemonth(tm->tm_mon, clock_isleapyear(tm->tm_year)) + tm->tm_mday; + value = clock_daysbeforemonth(tm->tm_mon, + clock_isleapyear(tm->tm_year)) + + tm->tm_mday; len = snprintf(dest, chleft, "%03d", value); } } @@ -364,6 +352,7 @@ size_t strftime(FAR char *s, size_t max, FAR const char *format, { str = "AM"; } + len = snprintf(dest, chleft, "%s", str); } break; @@ -380,6 +369,7 @@ size_t strftime(FAR char *s, size_t max, FAR const char *format, { str = "am"; } + len = snprintf(dest, chleft, "%s", str); } break; diff --git a/libs/libxx/Kconfig b/libs/libxx/Kconfig index c9858e9b4e..f342066aad 100644 --- a/libs/libxx/Kconfig +++ b/libs/libxx/Kconfig @@ -44,7 +44,6 @@ config LIBCXX select CLOCK_MONOTONIC select LIBC_WCHAR select LIBC_LOCALE - select TIME_EXTENDED ---help--- If you have installed libcxx into the NuttX source tree, then it can be built by selecting this option. See the README.txt file in the