Safe API Framework
Layered API framework for safety-related applications (ERTMS RBC reference targeting CENELEC EN 50128 SIL 4)
Loading...
Searching...
No Matches
sapi_timer.h
Go to the documentation of this file.
1
17#ifndef SAFEAPI_OS_TIMER_H
18#define SAFEAPI_OS_TIMER_H
19
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
28SAFEAPI_DECLARE_STORAGE(sapi_timer_storage_t, 64U);
29
31typedef struct sapi_timer_impl_s *sapi_timer_handle_t;
32
34typedef enum sapi_timer_mode_e
35{
39
49typedef void (*sapi_timer_callback_t)(sapi_timer_handle_t handle, void *user_ctx);
50
59
73sapi_status_t sapi_timer_create(sapi_timer_storage_t *storage,
74 const sapi_timer_config_t *config,
75 sapi_timer_handle_t *out_handle);
76
85
93
101
111
112/*
113 * The backend vtable (sapi_timer_backend_t) and sapi_timer_register_backend()
114 * live in safeapi_backend/timer/sapi_timer_backend.h, not here (ADR-021).
115 * This header is the consumer-facing surface only - a real application
116 * never needs to see the backend vtable shape; only the platform
117 * integrator wiring a concrete backend does.
118 */
119
120#ifdef __cplusplus
121}
122#endif
123
124#endif /* SAFEAPI_OS_TIMER_H */
125 /* TIMER */
sapi_status_t
Common result/status codes.
Definition sapi_status.h:27
sapi_status_t sapi_timer_start(sapi_timer_handle_t handle)
Starts (or restarts) a created timer.
Definition sapi_timer.c:79
sapi_status_t sapi_timer_stop(sapi_timer_handle_t handle)
Stops a running timer; safe to call on an already-stopped timer.
Definition sapi_timer.c:96
sapi_status_t sapi_timer_destroy(sapi_timer_handle_t handle)
Destroys a timer, releasing any backend resources bound to it.
Definition sapi_timer.c:113
struct sapi_timer_impl_s * sapi_timer_handle_t
Definition sapi_timer.h:31
sapi_status_t sapi_timer_now(sapi_timestamp_ms_t *out_now_ms)
Returns the current monotonic time base used by all timers.
Definition sapi_timer.c:130
sapi_status_t sapi_timer_create(sapi_timer_storage_t *storage, const sapi_timer_config_t *config, sapi_timer_handle_t *out_handle)
Creates a timer bound to caller-owned storage. Does not start it.
Definition sapi_timer.c:44
void(*) sapi_timer_callback_t(sapi_timer_handle_t handle, void *user_ctx)
Signature for a timer expiry callback.
Definition sapi_timer.h:49
sapi_timer_mode_t
Whether a timer fires once or repeatedly every period_ms.
Definition sapi_timer.h:35
@ SAPI_TIMER_MODE_PERIODIC
Definition sapi_timer.h:37
@ SAPI_TIMER_MODE_ONE_SHOT
Definition sapi_timer.h:36
uint32_t sapi_duration_ms_t
Definition sapi_types.h:27
uint64_t sapi_timestamp_ms_t
Definition sapi_types.h:30
#define SAFEAPI_DECLARE_STORAGE(type_name, byte_size)
Declares an opaque, fixed-size, aligned storage type for a service's handle. The real internal layout...
Definition sapi_types.h:69
Common status/error codes returned by every Safe API Framework function. Shared across all OS Abstrac...
Common fixed-width types and the caller-owned-storage handle pattern used by every OAL service (see A...
Configuration for sapi_timer_create().
Definition sapi_timer.h:53
sapi_timer_callback_t callback
Definition sapi_timer.h:56
sapi_timer_mode_t mode
Definition sapi_timer.h:54
sapi_duration_ms_t period_ms
Definition sapi_timer.h:55