clock_time_boottime.c 921 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*
  2. * Copyright (c) 2006-2024, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2024-12-04 RT-Thread Boottime implementation using clock_time
  9. */
  10. #include <rtdevice.h>
  11. #include <sys/time.h>
  12. /**
  13. * @brief Get boottime in microsecond precision
  14. *
  15. * @param tv Output timeval structure
  16. * @return RT_EOK on success
  17. */
  18. rt_err_t rt_boottime_get_us(struct timeval *tv)
  19. {
  20. return rt_clock_time_boottime_us(tv);
  21. }
  22. /**
  23. * @brief Get boottime in second precision
  24. *
  25. * @param t Output time_t value
  26. * @return RT_EOK on success
  27. */
  28. rt_err_t rt_boottime_get_s(time_t *t)
  29. {
  30. return rt_clock_time_boottime_s(t);
  31. }
  32. /**
  33. * @brief Get boottime in nanosecond precision
  34. *
  35. * @param ts Output timespec structure
  36. * @return RT_EOK on success
  37. */
  38. rt_err_t rt_boottime_get_ns(struct timespec *ts)
  39. {
  40. return rt_clock_time_boottime_ns(ts);
  41. }