RTC driver api
Example
#include <rtdevice.h>
#define RTC_NAME "rtc"
static int rtc_sample(int argc, char *argv[])
{
time_t now;
if (!device)
{
LOG_E(
"find %s failed!", RTC_NAME);
return RT_ERROR;
}
{
LOG_E(
"open %s failed!", RTC_NAME);
return RT_ERROR;
}
if (ret != RT_EOK)
{
return ret;
}
if (ret != RT_EOK)
{
return ret;
}
return ret;
}
rt_device_t rt_device_find(const char *name)
struct rt_device * rt_device_t
rt_err_t rt_device_open(rt_device_t dev, rt_uint16_t oflag)
rt_err_t set_date(rt_uint32_t year, rt_uint32_t month, rt_uint32_t day)
set date
rt_err_t set_time(rt_uint32_t hour, rt_uint32_t minute, rt_uint32_t second)
set time
rt_err_t rt_thread_mdelay(rt_int32_t ms)
This function will let current thread delay for some milliseconds.
#define MSH_CMD_EXPORT(...)
◆ RT_DEVICE_CTRL_RTC_GET_TIME
◆ RT_DEVICE_CTRL_RTC_SET_TIME
◆ RT_DEVICE_CTRL_RTC_GET_TIMEVAL
◆ RT_DEVICE_CTRL_RTC_SET_TIMEVAL
◆ RT_DEVICE_CTRL_RTC_GET_ALARM
◆ RT_DEVICE_CTRL_RTC_SET_ALARM
◆ RT_DEVICE_CTRL_RTC_GET_TIMESPEC
◆ RT_DEVICE_CTRL_RTC_SET_TIMESPEC
◆ RT_DEVICE_CTRL_RTC_GET_TIMERES
get resolution for clock_getres
在文件 dev_rtc.h 第 95 行定义.
◆ rt_rtc_dev_t
◆ rt_hw_rtc_register()
Register a RTC device
- 参数
-
rtc | RTC device |
name | RTC device name |
flag | RTC device flag |
data | RTC device data |
- 返回
- rt_err_t error code
◆ set_date()
set date
- 参数
-
year | year |
month | month |
day | day |
- 返回
- rt_err_t error code
◆ set_time()
set time
- 参数
-
hour | hour |
minute | minute |
second | second |
- 返回
- rt_err_t error code
◆ set_timestamp()
rt_err_t set_timestamp |
( |
time_t | timestamp | ) |
|
set timestamp
- 参数
-
timestamp | A pointer to time |
- 返回
- rt_err_t error code
◆ get_timestamp()
rt_err_t get_timestamp |
( |
time_t * | timestamp | ) |
|
get timestamp
- 参数
-
timestamp | A secondary pointer to time |
- 返回
- rt_err_t error code