riot_time.c 782 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /*
  2. * Copyright (C) 2019 Intel Corporation. All rights reserved.
  3. * Copyright (C) 2020 TU Bergakademie Freiberg Karl Fessel
  4. * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  5. */
  6. #include "platform_api_vmcore.h"
  7. #include <ztimer64.h>
  8. #include <kernel_defines.h>
  9. #if IS_USED(MODULE_ZTIMER64_USEC)
  10. uint64
  11. os_time_get_boot_us()
  12. {
  13. return ztimer64_now(ZTIMER64_USEC);
  14. }
  15. #elif IS_USED(MODULE_ZTIMER64_MSEC)
  16. uint64
  17. os_time_get_boot_us()
  18. {
  19. return ztimer64_now(ZTIMER64_MSEC) * 1000;
  20. }
  21. #else
  22. #ifdef __GNUC__
  23. __attribute__((weak)) uint64
  24. os_time_get_boot_us();
  25. #endif
  26. uint64
  27. os_time_get_boot_us()
  28. {
  29. static uint64_t times;
  30. return ++times;
  31. }
  32. #endif
  33. uint64
  34. os_time_thread_cputime_us(void)
  35. {
  36. /* FIXME if u know the right api */
  37. return os_time_get_boot_us();
  38. }