1 /*
2  * Copyright (c) 2018 Oticon A/S
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 /**
7  * Interface the HW models expect from the overall scheduler (this overall
8  * scheduler is the time machine in the nrf52_bsim target board)
9  */
10 #ifndef _TIME_MACHINE_IF_H
11 #define _TIME_MACHINE_IF_H
12 
13 #include "bs_types.h"
14 
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
18 
19 /**
20  * Get the absolute simulated time (microseconds since start)
21  * (as know by this device)
22  */
23 bs_time_t tm_get_abs_time(void);
24 /**
25  * Get the simulated time as presented to the HW models
26  *
27  * Note: In principle HW models should only rely on this time, but they
28  * may access the absolute time for logging/tracing, or other purposes
29  */
30 bs_time_t tm_get_hw_time();
31 
32 /*
33  * Convert an absolute time into HW time
34  * (Absolute and HW time may be the same, but needs not be)
35  */
36 bs_time_t tm_abs_time_to_hw_time(bs_time_t abstime);
37 
38 /*
39  * Convert a HW time into absolute time
40  */
41 bs_time_t tm_hw_time_to_abs_time(bs_time_t hwtime);
42 
43 /*
44  * Notify the overall scheduler that an event time (timer) has been updated
45  */
46 void tm_find_next_timer_to_trigger();
47 
48 /*
49  * Return the next time of the next event the overall scheduler knows about
50  */
51 bs_time_t tm_get_next_timer_abstime();
52 
53 /*
54  * Note the time of the last interaction with the Babblesim Phy
55  */
56 void tm_update_last_phy_sync_time(bs_time_t abs_time);
57 
58 /*
59  * Set the maximum amount of time we are willing to be without communicating
60  * with the BabbleSim Phy. If at some point we would spend longer than that
61  * without any Phy activity a "wait" command would be sent.
62  */
63 void tm_set_phy_max_resync_offset(bs_time_t offset_in_us);
64 
65 #ifdef __cplusplus
66 }
67 #endif
68 
69 #endif
70