mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-12-17 18:43:50 +01:00
Merge pull request #8857 from ZetaR60/RIOT_atmega_time_dot_h
cpu/atmega_common: Use updated time.h
This commit is contained in:
commit
23d176f46b
@ -18,7 +18,7 @@ export USEMODULE += periph_common
|
||||
export USEMODULE += uart_stdio
|
||||
|
||||
# include module specific includes
|
||||
export INCLUDES += -I$(RIOTCPU)/atmega_common/include -isystem$(RIOTCPU)/atmega_common/avr-libc-extra
|
||||
export INCLUDES += -I$(RIOTCPU)/atmega_common/include -isystem$(RIOTCPU)/atmega_common/include/vendor
|
||||
|
||||
ifeq ($(LTO),1)
|
||||
# avr-gcc <4.8.3 has a bug when using LTO which causes a warning to be printed always:
|
||||
|
||||
@ -35,7 +35,7 @@ typedef int pid_t; /**< Used for process IDs and process group ID
|
||||
typedef unsigned int size_t; /**< Used for sizes of objects */
|
||||
typedef signed int ssize_t; /**< Used for a count of bytes or an error indication */
|
||||
typedef int32_t suseconds_t; /**< Used for time in microseconds */
|
||||
typedef int32_t time_t; /**< Used for time in seconds */
|
||||
typedef uint32_t time_t; /**< Used for time in seconds */
|
||||
typedef uint32_t timer_t; /**< Used for timer ID returned by timer_create() */
|
||||
typedef uint16_t uid_t; /**< Used for user IDs */
|
||||
typedef uint32_t useconds_t; /**< Used for time in microseconds */
|
||||
|
||||
@ -26,9 +26,7 @@
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/* \cond DOXYGEN_BLACKLIST */
|
||||
|
||||
/* $Id$ */
|
||||
/* $Id: time.h 2503 2016-02-07 22:59:47Z joerg_wunsch $ */
|
||||
|
||||
/** \file */
|
||||
|
||||
@ -101,16 +99,22 @@
|
||||
#ifndef TIME_H
|
||||
#define TIME_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/** \ingroup avr_time */
|
||||
/* @{ */
|
||||
|
||||
/**
|
||||
time_t represents seconds elapsed from Midnight, Jan 1 2000 UTC (the Y2K 'epoch').
|
||||
Its range allows this implementation to represent time up to Tue Feb 7 06:28:15 2136 UTC.
|
||||
*/
|
||||
typedef uint32_t time_t;
|
||||
|
||||
/**
|
||||
The time function returns the systems current time stamp.
|
||||
If timer is not a null pointer, the return value is also assigned to the object it points to.
|
||||
@ -128,22 +132,7 @@ extern "C" {
|
||||
The tm structure contains a representation of time 'broken down' into components of the
|
||||
Gregorian calendar.
|
||||
|
||||
The normal ranges of the elements are..
|
||||
|
||||
\code
|
||||
tm_sec seconds after the minute - [ 0 to 59 ]
|
||||
tm_min minutes after the hour - [ 0 to 59 ]
|
||||
tm_hour hours since midnight - [ 0 to 23 ]
|
||||
tm_mday day of the month - [ 1 to 31 ]
|
||||
tm_wday days since Sunday - [ 0 to 6 ]
|
||||
tm_mon months since January - [ 0 to 11 ]
|
||||
tm_year years since 1900
|
||||
tm_yday days since January 1 - [ 0 to 365 ]
|
||||
tm_isdst Daylight Saving Time flag *
|
||||
|
||||
\endcode
|
||||
|
||||
*The value of tm_isdst is zero if Daylight Saving Time is not in effect, and is negative if
|
||||
The value of tm_isdst is zero if Daylight Saving Time is not in effect, and is negative if
|
||||
the information is not available.
|
||||
|
||||
When Daylight Saving Time is in effect, the value represents the number of
|
||||
@ -153,18 +142,24 @@ extern "C" {
|
||||
|
||||
*/
|
||||
struct tm {
|
||||
int tm_sec;
|
||||
int tm_min;
|
||||
int tm_hour;
|
||||
int tm_mday;
|
||||
int tm_wday;
|
||||
int tm_mon;
|
||||
int tm_year;
|
||||
int tm_yday;
|
||||
int tm_isdst;
|
||||
int8_t tm_sec; /**< seconds after the minute - [ 0 to 59 ] */
|
||||
int8_t tm_min; /**< minutes after the hour - [ 0 to 59 ] */
|
||||
int8_t tm_hour; /**< hours since midnight - [ 0 to 23 ] */
|
||||
int8_t tm_mday; /**< day of the month - [ 1 to 31 ] */
|
||||
int8_t tm_wday; /**< days since Sunday - [ 0 to 6 ] */
|
||||
int8_t tm_mon; /**< months since January - [ 0 to 11 ] */
|
||||
int16_t tm_year; /**< years since 1900 */
|
||||
int16_t tm_yday; /**< days since January 1 - [ 0 to 365 ] */
|
||||
int16_t tm_isdst; /**< Daylight Saving Time flag */
|
||||
};
|
||||
|
||||
/**
|
||||
ATmega compatibility problem define
|
||||
NOTE: Added for RIOT compatibility
|
||||
*/
|
||||
#define ATMEGA_INCOMPATIBLE_TIME_H
|
||||
|
||||
#ifndef __DOXYGEN__
|
||||
/* We have to provide clock_t / CLOCKS_PER_SEC so that libstdc++-v3 can
|
||||
be built. We define CLOCKS_PER_SEC via a symbol _CLOCKS_PER_SEC_
|
||||
so that the user can provide the value on the link line, which should
|
||||
@ -173,6 +168,7 @@ extern "C" {
|
||||
extern char *_CLOCKS_PER_SEC_;
|
||||
#define CLOCKS_PER_SEC ((clock_t) _CLOCKS_PER_SEC_)
|
||||
extern clock_t clock(void);
|
||||
#endif /* !__DOXYGEN__ */
|
||||
|
||||
/**
|
||||
This function 'compiles' the elements of a broken-down time structure, returning a binary time stamp.
|
||||
@ -388,9 +384,9 @@ extern "C" {
|
||||
See http://en.wikipedia.org/wiki/ISO_week_date for more information.
|
||||
*/
|
||||
struct week_date {
|
||||
int year;
|
||||
int week;
|
||||
int day;
|
||||
int year; /**< year number (Gregorian calendar) */
|
||||
int week; /**< week number (#1 is where first Thursday is in) */
|
||||
int day; /**< day within week */
|
||||
};
|
||||
|
||||
/**
|
||||
@ -511,21 +507,18 @@ extern "C" {
|
||||
*/
|
||||
unsigned long lm_sidereal(const time_t * timer);
|
||||
|
||||
/**
|
||||
Definition of struct timespec for the atmega
|
||||
NOTE: Added for RIOT compatibility and standard compliance
|
||||
*/
|
||||
struct timespec {
|
||||
time_t tv_sec;
|
||||
long tv_nsec;
|
||||
};
|
||||
|
||||
/* @} */
|
||||
|
||||
/* /endcond */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* TIME_H */
|
||||
|
||||
/**
|
||||
\endcond
|
||||
*/
|
||||
@ -84,7 +84,11 @@ int tm_doomsday(int year) CONST;
|
||||
* @param[out] wday Returns the day of the week.
|
||||
* @param[out] yday Returns the day of the year (Jan 1st is 0).
|
||||
*/
|
||||
#ifndef ATMEGA_INCOMPATIBLE_TIME_H
|
||||
void tm_get_wyday(int year, int mon, int mday, int *wday, int *yday);
|
||||
#else
|
||||
void tm_get_wyday(int year, int mon, int mday, int8_t *wday, int16_t *yday);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Fills in `struct tm::tm_wday` and `struct tm::tm_yday` given a date.
|
||||
|
||||
@ -49,7 +49,11 @@ int tm_doomsday(int year)
|
||||
return result;
|
||||
}
|
||||
|
||||
#ifndef ATMEGA_INCOMPATIBLE_TIME_H
|
||||
void tm_get_wyday(int year, int mon, int mday, int *wday, int *yday)
|
||||
#else
|
||||
void tm_get_wyday(int year, int mon, int mday, int8_t *wday, int16_t *yday)
|
||||
#endif
|
||||
{
|
||||
int is_leap_year = tm_is_leap_year(year);
|
||||
*yday = TM_MON_DAYS_ACCU[mon] + mday + (mon <= TM_MON_FEB ? 0 : is_leap_year) - 1;
|
||||
|
||||
@ -5,6 +5,14 @@ USEPKG += minmea
|
||||
# The MSP-430 toolchain lacks mktime and NAN
|
||||
BOARD_BLACKLIST := chronos msb-430 msb-430h telosb wsn430-v1_3b wsn430-v1_4 z1
|
||||
|
||||
# Incompatible due to non-standard ATmega time.h
|
||||
BOARD_BLACKLIST += arduino-duemilanove \
|
||||
arduino-mega2560 \
|
||||
arduino-uno \
|
||||
jiminy-mega256rfr2 \
|
||||
mega-xplained \
|
||||
waspmote-pro
|
||||
|
||||
TEST_ON_CI_WHITELIST += all
|
||||
|
||||
include $(RIOTBASE)/Makefile.include
|
||||
|
||||
@ -113,7 +113,13 @@ static int cmd_day(int argc, char **argv)
|
||||
puts("The supplied date is invalid, but no error should occur.");
|
||||
}
|
||||
|
||||
#ifndef ATMEGA_INCOMPATIBLE_TIME_H
|
||||
int wday, yday;
|
||||
#else
|
||||
int8_t wday;
|
||||
int16_t yday;
|
||||
#endif
|
||||
|
||||
tm_get_wyday(year, mon - 1, day, &wday, &yday);
|
||||
printf("What weekday was %04d-%02d-%02d? The %d(th) day of the year was a %.3s.\n",
|
||||
year, mon, day, yday + 1, DAY_NAMES[wday]);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user