time_machine.h 902 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*
  2. * Copyright (c) 2017 Oticon A/S
  3. * Copyright (c) 2021 Codecoup
  4. *
  5. * SPDX-License-Identifier: Apache-2.0
  6. */
  7. #ifndef _TIME_MACHINE_H
  8. #define _TIME_MACHINE_H
  9. #include "bs_types.h"
  10. #ifdef __cplusplus
  11. extern "C"{
  12. #endif
  13. extern bs_time_t now;
  14. bs_time_t tm_get_abs_time(void);
  15. bs_time_t tm_get_hw_time(void);
  16. bs_time_t tm_hw_time_to_abs_time(bs_time_t hwtime);
  17. bs_time_t tm_abs_time_to_hw_time(bs_time_t abstime);
  18. void tm_reset_hw_times(void);
  19. void tm_find_next_timer_to_trigger(void);
  20. bs_time_t tm_get_next_timer_abstime(void);
  21. void tm_update_last_phy_sync_time(bs_time_t abs_time);
  22. void tm_set_phy_max_resync_offset(bs_time_t offset_in_us);
  23. void tm_run_forever(void);
  24. void tm_sleep_until_hw_time(bs_time_t hw_time);
  25. void tm_sleep_until_abs_time(bs_time_t time);
  26. void tm_start(void);
  27. void tm_tick(void);
  28. void tm_tick_limited(bs_time_t max_time_diff);
  29. #ifdef __cplusplus
  30. }
  31. #endif
  32. #endif