Safe API Framework 0.1.0 build 384e6ae
Layered API framework for safety-related applications (ERTMS RBC reference targeting CENELEC EN 50128 SIL 4)
Loading...
Searching...
No Matches
rte_timer.c
Go to the documentation of this file.
1
10
12
14
18
20
22
23
26{
27 rte_status_t lifecycle_status;
28
29 if (osadapter == NULL)
30 {
32 }
33 /* REQ-LIFECYCLE-001 (ADR-026): registering an OSAdapter is a setup-only
34 * action - refuse once the application's setup phase has been locked. */
35 lifecycle_status = rte_lifecycle_check_setup_allowed();
36 if (lifecycle_status != RTE_STATUS_OK)
37 {
38 return lifecycle_status;
39 }
40 s_osadapter = osadapter;
41 return RTE_STATUS_OK;
42}
43
44rte_status_t rte_timer_create(rte_timer_storage_t *storage,
45 const rte_timer_config_t *config,
46 rte_timer_handle_t *out_handle)
47{
48 if ((storage == NULL) || (config == NULL) || (out_handle == NULL))
49 {
51 }
52 if ((config->callback == NULL) || (config->period_ms == 0U))
53 {
55 }
56 *out_handle = NULL;
57 /* REQ-LIFECYCLE-001 (ADR-026): a timer is a setup-only resource - refuse once the
58 * application's setup phase has been locked (rte_appmanager_run(),
59 * after ops->init() succeeds). */
60 {
62
63 if (lifecycle_status != RTE_STATUS_OK)
64 {
65 return lifecycle_status;
66 }
67 }
68 if (s_osadapter == NULL)
69 {
71 }
72 if (s_osadapter->create == NULL)
73 {
75 }
76 return s_osadapter->create(storage, config, out_handle);
77}
78
80{
81 if (handle == NULL)
82 {
84 }
85 /* REQ-LIFECYCLE-001/003 (ADR-026, OSA rules): setup-only - refused and reported once the setup phase is locked. */
86 {
88
89 if (lifecycle_status != RTE_STATUS_OK)
90 {
91 return lifecycle_status;
92 }
93 }
94 if (s_osadapter == NULL)
95 {
97 }
98 if (s_osadapter->start == NULL)
99 {
101 }
102 return s_osadapter->start(handle);
103}
104
106{
107 if (handle == NULL)
108 {
110 }
111 if (s_osadapter == NULL)
112 {
114 }
115 if (s_osadapter->stop == NULL)
116 {
118 }
119 return s_osadapter->stop(handle);
120}
121
123{
124 if (handle == NULL)
125 {
127 }
128 if (s_osadapter == NULL)
129 {
131 }
132 if (s_osadapter->destroy == NULL)
133 {
135 }
136 return s_osadapter->destroy(handle);
137}
138
140{
141 if (out_now_ms == NULL)
142 {
144 }
145 *out_now_ms = 0U;
146 if (s_osadapter == NULL)
147 {
149 }
150 if (s_osadapter->now == NULL)
151 {
153 }
154 return s_osadapter->now(out_now_ms);
155}
rte_status_t rte_lifecycle_check_setup_allowed(void)
Convenience check for a setup-only constructor: call this as one of the first checks in any function ...
rte_status_t
Common result/status codes.
Definition rte_status.h:27
@ RTE_STATUS_OK
Definition rte_status.h:28
@ RTE_STATUS_INVALID_PARAM
Definition rte_status.h:29
@ RTE_STATUS_NOT_SUPPORTED
Definition rte_status.h:34
@ RTE_STATUS_NOT_INITIALIZED
Definition rte_status.h:30
rte_status_t rte_timer_now(rte_timestamp_ms_t *out_now_ms)
Returns the current monotonic time base used by all timers.
Definition rte_timer.c:139
rte_status_t rte_timer_stop(rte_timer_handle_t handle)
Stops a running timer; safe to call on an already-stopped timer.
Definition rte_timer.c:105
rte_status_t rte_timer_start(rte_timer_handle_t handle)
Starts (or restarts) a created timer.
Definition rte_timer.c:79
struct rte_timer_impl_s * rte_timer_handle_t
Definition rte_timer.h:31
rte_status_t rte_timer_create(rte_timer_storage_t *storage, const rte_timer_config_t *config, rte_timer_handle_t *out_handle)
Creates a timer bound to caller-owned storage. Does not start it.
Definition rte_timer.c:44
rte_status_t rte_timer_destroy(rte_timer_handle_t handle)
Destroys a timer, releasing any OSAdapter resources bound to it.
Definition rte_timer.c:122
uint64_t rte_timestamp_ms_t
Definition rte_types.h:30
static const rte_osadapter_clocksync_t * s_osadapter
Process-wide application setup-phase lock (ADR-026).
OSAdapter interface for monotonic timers and timestamps.
rte_status_t rte_osadapter_timer_register(const rte_osadapter_timer_t *adapter)
Registers the OSAdapter timer implementation.
Definition rte_timer.c:25
OS Abstraction Layer - Timer service.
OSAdapter timer operations vtable.
Configuration for rte_timer_create().
Definition rte_timer.h:53
rte_timer_callback_t callback
Definition rte_timer.h:56
rte_duration_ms_t period_ms
Definition rte_timer.h:55