mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-02-06 00:45:22 +08:00
Use time_t for RT_DEVICE_CTRL_RTC_GET_TIME RT_DEVICE_CTRL_RTC_SET_TIME
This commit is contained in:
@@ -47,11 +47,11 @@ static rt_err_t _rtc_control(rt_device_t dev, int cmd, void *args)
|
||||
switch (cmd)
|
||||
{
|
||||
case RT_DEVICE_CTRL_RTC_GET_TIME:
|
||||
*(rt_uint32_t *)args = rtc_time + BFLB_RTC_TIME2SEC(bflb_rtc_get_time(bflb_rtc));
|
||||
*(time_t *)args = rtc_time + BFLB_RTC_TIME2SEC(bflb_rtc_get_time(bflb_rtc));
|
||||
break;
|
||||
|
||||
case RT_DEVICE_CTRL_RTC_SET_TIME:
|
||||
rtc_time = *(rt_uint32_t *)args;
|
||||
rtc_time = *(time_t *)args;
|
||||
bflb_rtc_set_time(bflb_rtc, 0);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -85,13 +85,13 @@ static rt_err_t rt_rtc_control(rt_device_t dev, int cmd, void *args)
|
||||
switch (cmd)
|
||||
{
|
||||
case RT_DEVICE_CTRL_RTC_GET_TIME:
|
||||
*(rt_uint32_t *)args = rtc_time + RTC_CounterGet();
|
||||
*(time_t *)args = rtc_time + RTC_CounterGet();
|
||||
rtc_debug("RTC: get rtc_time %x + %x\n", rtc_time, RTC_CounterGet());
|
||||
break;
|
||||
|
||||
case RT_DEVICE_CTRL_RTC_SET_TIME:
|
||||
{
|
||||
rtc_time = *(rt_uint32_t *)args;
|
||||
rtc_time = *(time_t *)args;
|
||||
rtc_debug("RTC: set rtc_time %x\n", rtc_time);
|
||||
|
||||
/* Reset counter */
|
||||
|
||||
@@ -110,14 +110,14 @@ static rt_err_t rt_rtc_control(rt_device_t dev, int cmd, void *args)
|
||||
{
|
||||
case RT_DEVICE_CTRL_RTC_GET_TIME:
|
||||
|
||||
*(rt_uint32_t *)args = get_timestamp();
|
||||
rtc_debug("RTC: get rtc_time %x\n", *(rt_uint32_t *)args);
|
||||
*(time_t *)args = get_timestamp();
|
||||
rtc_debug("RTC: get rtc_time %x\n", *(time_t *)args);
|
||||
break;
|
||||
|
||||
case RT_DEVICE_CTRL_RTC_SET_TIME:
|
||||
{
|
||||
result = set_timestamp(*(rt_uint32_t *)args);
|
||||
rtc_debug("RTC: set rtc_time %x\n", *(rt_uint32_t *)args);
|
||||
result = set_timestamp(*(time_t *)args);
|
||||
rtc_debug("RTC: set rtc_time %x\n", *(time_t *)args);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -64,16 +64,16 @@ static rt_err_t rt_rtc_control(rt_device_t dev, int cmd, void *args)
|
||||
switch (cmd)
|
||||
{
|
||||
case RT_DEVICE_CTRL_RTC_GET_TIME:
|
||||
*(rt_uint32_t *)args = get_rtc_timestamp();
|
||||
LOG_D("RTC: get rtc_time %x\n", *(rt_uint32_t *)args);
|
||||
*(time_t *)args = get_rtc_timestamp();
|
||||
LOG_D("RTC: get rtc_time %x\n", *(time_t *)args);
|
||||
break;
|
||||
|
||||
case RT_DEVICE_CTRL_RTC_SET_TIME:
|
||||
if (set_rtc_time_stamp(*(rt_uint32_t *)args))
|
||||
if (set_rtc_time_stamp(*(time_t *)args))
|
||||
{
|
||||
result = -RT_ERROR;
|
||||
}
|
||||
LOG_D("RTC: set rtc_time %x\n", *(rt_uint32_t *)args);
|
||||
LOG_D("RTC: set rtc_time %x\n", *(time_t *)args);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -116,7 +116,7 @@ static rt_err_t gd32_rtc_control(rt_device_t dev, int cmd, void *args)
|
||||
{
|
||||
case RT_DEVICE_CTRL_RTC_GET_TIME:
|
||||
{
|
||||
*(uint32_t *)args = get_timestamp();
|
||||
*(time_t *)args = get_timestamp();
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
@@ -121,7 +121,7 @@ static rt_err_t imxrt_hp_rtc_control(rt_device_t dev, int cmd, void *args)
|
||||
{
|
||||
case RT_DEVICE_CTRL_RTC_GET_TIME:
|
||||
{
|
||||
*(uint32_t *)args = imxrt_hp_get_timestamp();
|
||||
*(time_t *)args = imxrt_hp_get_timestamp();
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ static rt_err_t pl031_rtc_control(rt_device_t dev, int cmd, void *args)
|
||||
switch (cmd)
|
||||
{
|
||||
case RT_DEVICE_CTRL_RTC_GET_TIME:
|
||||
*(rt_uint32_t *)args = pl031_read32(RTC_DR);
|
||||
*(time_t *)args = pl031_read32(RTC_DR);
|
||||
break;
|
||||
case RT_DEVICE_CTRL_RTC_SET_TIME:
|
||||
pl031_write32(RTC_LR, *(time_t *)args);
|
||||
|
||||
@@ -238,7 +238,7 @@ static rt_err_t raspi_rtc_control(rt_device_t dev, int cmd, void *args)
|
||||
switch (cmd)
|
||||
{
|
||||
case RT_DEVICE_CTRL_RTC_GET_TIME:
|
||||
*(rt_uint32_t *)args = raspi_get_timestamp();
|
||||
*(time_t *)args = raspi_get_timestamp();
|
||||
break;
|
||||
case RT_DEVICE_CTRL_RTC_SET_TIME:
|
||||
raspi_set_timestamp(*(time_t *)args);
|
||||
|
||||
@@ -82,7 +82,7 @@ static rt_err_t raspi_rtc_control(rt_device_t dev, int cmd, void *args)
|
||||
switch (cmd)
|
||||
{
|
||||
case RT_DEVICE_CTRL_RTC_GET_TIME:
|
||||
*(rt_uint32_t *)args = raspi_get_timestamp();
|
||||
*(time_t *)args = raspi_get_timestamp();
|
||||
break;
|
||||
case RT_DEVICE_CTRL_RTC_SET_TIME:
|
||||
raspi_set_timestamp(*(time_t *)args);
|
||||
|
||||
@@ -139,7 +139,7 @@ static rt_err_t wm_rtc_control(rt_device_t dev, int cmd, void *args)
|
||||
switch (cmd)
|
||||
{
|
||||
case RT_DEVICE_CTRL_RTC_GET_TIME:
|
||||
*(rt_uint32_t *)args = wm_get_timestamp();
|
||||
*(time_t *)args = wm_get_timestamp();
|
||||
break;
|
||||
case RT_DEVICE_CTRL_RTC_SET_TIME:
|
||||
wm_set_timestamp(*(time_t *)args);
|
||||
|
||||
Reference in New Issue
Block a user