RT-Thread RTOS
An open source embedded real-time operating system
|
Data Structures | |
struct | rt_rtc_wkalarm |
struct | rt_rtc_ops |
struct | rt_rtc_device |
Macros | |
#define | RT_DEVICE_CTRL_RTC_GET_TIME (RT_DEVICE_CTRL_BASE(RTC) + 0x01) |
#define | RT_DEVICE_CTRL_RTC_SET_TIME (RT_DEVICE_CTRL_BASE(RTC) + 0x02) |
#define | RT_DEVICE_CTRL_RTC_GET_TIMEVAL (RT_DEVICE_CTRL_BASE(RTC) + 0x03) |
#define | RT_DEVICE_CTRL_RTC_SET_TIMEVAL (RT_DEVICE_CTRL_BASE(RTC) + 0x04) |
#define | RT_DEVICE_CTRL_RTC_GET_ALARM (RT_DEVICE_CTRL_BASE(RTC) + 0x05) |
#define | RT_DEVICE_CTRL_RTC_SET_ALARM (RT_DEVICE_CTRL_BASE(RTC) + 0x06) |
#define | RT_DEVICE_CTRL_RTC_GET_TIMESPEC (RT_DEVICE_CTRL_BASE(RTC) + 0x07) |
#define | RT_DEVICE_CTRL_RTC_SET_TIMESPEC (RT_DEVICE_CTRL_BASE(RTC) + 0x08) |
#define | RT_DEVICE_CTRL_RTC_GET_TIMERES (RT_DEVICE_CTRL_BASE(RTC) + 0x09) |
Typedefs | |
typedef struct rt_rtc_device | rt_rtc_dev_t |
Functions | |
rt_err_t | rt_hw_rtc_register (rt_rtc_dev_t *rtc, const char *name, rt_uint32_t flag, void *data) |
rt_err_t | set_date (rt_uint32_t year, rt_uint32_t month, rt_uint32_t day) |
rt_err_t | set_time (rt_uint32_t hour, rt_uint32_t minute, rt_uint32_t second) |
rt_err_t | set_timestamp (time_t timestamp) |
rt_err_t | get_timestamp (time_t *timestamp) |
RTC driver api.
Example
#define RT_DEVICE_CTRL_RTC_GET_TIME (RT_DEVICE_CTRL_BASE(RTC) + 0x01) |
get second time
#define RT_DEVICE_CTRL_RTC_SET_TIME (RT_DEVICE_CTRL_BASE(RTC) + 0x02) |
set second time
#define RT_DEVICE_CTRL_RTC_GET_TIMEVAL (RT_DEVICE_CTRL_BASE(RTC) + 0x03) |
get timeval for gettimeofday
#define RT_DEVICE_CTRL_RTC_SET_TIMEVAL (RT_DEVICE_CTRL_BASE(RTC) + 0x04) |
set timeval for gettimeofday
#define RT_DEVICE_CTRL_RTC_GET_ALARM (RT_DEVICE_CTRL_BASE(RTC) + 0x05) |
get alarm
#define RT_DEVICE_CTRL_RTC_SET_ALARM (RT_DEVICE_CTRL_BASE(RTC) + 0x06) |
set alarm
#define RT_DEVICE_CTRL_RTC_GET_TIMESPEC (RT_DEVICE_CTRL_BASE(RTC) + 0x07) |
get timespec for clock_gettime
#define RT_DEVICE_CTRL_RTC_SET_TIMESPEC (RT_DEVICE_CTRL_BASE(RTC) + 0x08) |
set timespec for clock_settime
#define RT_DEVICE_CTRL_RTC_GET_TIMERES (RT_DEVICE_CTRL_BASE(RTC) + 0x09) |
get resolution for clock_getres
typedef struct rt_rtc_device rt_rtc_dev_t |
RTC device structure.
rt_err_t rt_hw_rtc_register | ( | rt_rtc_dev_t * | rtc, |
const char * | name, | ||
rt_uint32_t | flag, | ||
void * | data | ||
) |
Register a RTC device.
rtc | RTC device |
name | RTC device name |
flag | RTC device flag |
data | RTC device data |
rt_err_t set_date | ( | rt_uint32_t | year, |
rt_uint32_t | month, | ||
rt_uint32_t | day | ||
) |
set date
year | year |
month | month |
day | day |
rt_err_t set_time | ( | rt_uint32_t | hour, |
rt_uint32_t | minute, | ||
rt_uint32_t | second | ||
) |
set time
hour | hour |
minute | minute |
second | second |
rt_err_t set_timestamp | ( | time_t | timestamp | ) |
set timestamp
timestamp | A pointer to time |
rt_err_t get_timestamp | ( | time_t * | timestamp | ) |
get timestamp
timestamp | A secondary pointer to time |