* Set timestamp(UTC). * * @param time_t timestamp * * @return rt_err_t if set success, return RT_EOK. */
| 236 | * @return rt_err_t if set success, return RT_EOK. |
| 237 | */ |
| 238 | rt_err_t set_timestamp(time_t timestamp) |
| 239 | { |
| 240 | if (_rtc_device == RT_NULL) |
| 241 | { |
| 242 | _rtc_device = rt_device_find("rtc"); |
| 243 | if (_rtc_device == RT_NULL) |
| 244 | { |
| 245 | return -RT_ERROR; |
| 246 | } |
| 247 | } |
| 248 | |
| 249 | /* update to RTC device. */ |
| 250 | return rt_device_control(_rtc_device, RT_DEVICE_CTRL_RTC_SET_TIME, ×tamp); |
| 251 | } |
| 252 | |
| 253 | /** |
| 254 | * Get timestamp(UTC). |
no test coverage detected