* Returns the current time. * * @param time_t * t the timestamp pointer, if not used, keep NULL. * * @return The value ((time_t)-1) is returned if the calendar time is not available. * If timer is not a NULL pointer, the return value is also stored in timer. * */
| 338 | * |
| 339 | */ |
| 340 | rt_weak time_t time(time_t *t) |
| 341 | { |
| 342 | #ifdef RT_USING_RTC |
| 343 | time_t _t; |
| 344 | |
| 345 | if (_control_rtc(RT_DEVICE_CTRL_RTC_GET_TIME, &_t) != RT_EOK) |
| 346 | { |
| 347 | rt_set_errno(EFAULT); |
| 348 | return (time_t)-1; |
| 349 | } |
| 350 | |
| 351 | if (t) |
| 352 | *t = _t; |
| 353 | |
| 354 | return _t; |
| 355 | #else |
| 356 | rt_set_errno(EFAULT); |
| 357 | return (time_t)-1; |
| 358 | #endif |
| 359 | } |
| 360 | RTM_EXPORT(time); |
| 361 | |
| 362 | rt_weak clock_t clock(void) |