Loading...
Searching...
No Matches
walltime.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2025 ML!PA Consulting GmbH
3 * SPDX-License-Identifier: LGPL-2.1-only
4 */
5#pragma once
6
28
29#include <stdbool.h>
30#include <stdint.h>
31#include <time.h>
32
33#ifdef __cplusplus
34extern "C" {
35#endif
36
45typedef void (*walltime_change_cb_t)(void *ctx, int32_t diff_sec, int16_t diff_ms);
46
52typedef void(*walltime_alarm_cb_t)(void *arg);
53
58typedef struct {
59 void *next;
61 void *ctx;
63
64
74
84
93int walltime_set(struct tm *time);
94
106int walltime_get(struct tm *time, uint16_t *ms);
107
117uint32_t walltime_get_riot(uint16_t *ms);
118
128time_t walltime_get_unix(uint16_t *ms);
129
146int walltime_set_alarm(struct tm *time, walltime_alarm_cb_t cb, void *arg);
147
158int walltime_get_alarm(struct tm *time);
159
171uint32_t walltime_uptime(bool full);
172
178
186int walltime_impl_set(struct tm *time);
187
196int walltime_impl_get(struct tm *time, uint16_t *ms);
197
213int walltime_impl_alarm_set(struct tm *time, walltime_alarm_cb_t cb, void *arg);
214
225int walltime_impl_alarm_get(struct tm *time);
226
227#ifdef __cplusplus
228}
229#endif
230
int walltime_set_alarm(struct tm *time, walltime_alarm_cb_t cb, void *arg)
Set an alarm for RTC to the specified value.
bool walltime_change_unsubscribe(walltime_change_sub_t *sub)
Remove a time change notification subscription.
int walltime_impl_get(struct tm *time, uint16_t *ms)
Backend implementation to get the system time.
uint32_t walltime_uptime(bool full)
Get seconds elapsed since last reset.
void walltime_change_subscribe(walltime_change_sub_t *sub)
Add a time change notification subscription.
int walltime_impl_alarm_set(struct tm *time, walltime_alarm_cb_t cb, void *arg)
Backend implementation to set the alarm.
uint32_t walltime_get_riot(uint16_t *ms)
Get the current system time in seconds since RIOT_EPOCH.
int walltime_impl_set(struct tm *time)
Backend implementation to set the system time.
int walltime_set(struct tm *time)
Set the system date / time.
int walltime_get(struct tm *time, uint16_t *ms)
Get the system date / time.
int walltime_get_alarm(struct tm *time)
Gets the current alarm setting.
void(* walltime_alarm_cb_t)(void *arg)
Signature for Alarm Callback.
Definition walltime.h:52
void(* walltime_change_cb_t)(void *ctx, int32_t diff_sec, int16_t diff_ms)
Time change notification callback.
Definition walltime.h:45
time_t walltime_get_unix(uint16_t *ms)
Get the current system time in seconds since 01.01.1970.
void walltime_impl_init(void)
Backend implementation init, only implement this function when required.
int walltime_impl_alarm_get(struct tm *time)
Backend implementation to get the current alarm setting.
Time change notification subscription.
Definition walltime.h:58
void * next
Next pointer, internal use only.
Definition walltime.h:59
void * ctx
Callback function context.
Definition walltime.h:61
walltime_change_cb_t cb
Time change callback function.
Definition walltime.h:60