| 91 | |
| 92 | #ifdef RT_USING_RTC |
| 93 | static rt_err_t _control_rtc(int cmd, void *arg) |
| 94 | { |
| 95 | static rt_device_t device = RT_NULL; |
| 96 | rt_err_t rst = -RT_ERROR; |
| 97 | |
| 98 | if (device == RT_NULL) |
| 99 | { |
| 100 | device = rt_device_find("rtc"); |
| 101 | } |
| 102 | |
| 103 | /* read timestamp from RTC device */ |
| 104 | if (device != RT_NULL) |
| 105 | { |
| 106 | if (rt_device_open(device, 0) == RT_EOK) |
| 107 | { |
| 108 | rst = rt_device_control(device, cmd, arg); |
| 109 | rt_device_close(device); |
| 110 | } |
| 111 | } |
| 112 | else |
| 113 | { |
| 114 | LOG_W(_WARNING_NO_RTC); |
| 115 | return -RT_ENOSYS; |
| 116 | } |
| 117 | return rst; |
| 118 | } |
| 119 | #endif /* RT_USING_RTC */ |
| 120 | |
| 121 | /* lightweight timezone and daylight saving time */ |
no test coverage detected