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
26
27#include <stdbool.h>
28#include <stdint.h>
29#include <time.h>
30
31#ifdef __cplusplus
32extern "C" {
33#endif
34
43typedef void (*walltime_change_cb_t)(void *ctx, int32_t diff_sec, int16_t diff_ms);
44
50typedef void(*walltime_alarm_cb_t)(void *arg);
51
56typedef struct {
57 void *next;
59 void *ctx;
61
62
72
82
91int walltime_set(struct tm *time);
92
103int walltime_get(struct tm *time, uint16_t *ms);
104
113uint32_t walltime_get_riot(uint16_t *ms);
114
123time_t walltime_get_unix(uint16_t *ms);
124
139int walltime_set_alarm(struct tm *time, walltime_alarm_cb_t cb, void *arg);
140
150int walltime_get_alarm(struct tm *time);
151
162uint32_t walltime_uptime(bool full);
163
168
176int walltime_impl_set(struct tm *time);
177
186int walltime_impl_get(struct tm *time, uint16_t *ms);
187
202int walltime_impl_alarm_set(struct tm *time, walltime_alarm_cb_t cb, void *arg);
203
213int walltime_impl_alarm_get(struct tm *time);
214
215#ifdef __cplusplus
216}
217#endif
218
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 This will be called whenever the system time changes.
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:50
void(* walltime_change_cb_t)(void *ctx, int32_t diff_sec, int16_t diff_ms)
Time change notification callback.
Definition walltime.h:43
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 when necessary.
int walltime_impl_alarm_get(struct tm *time)
Gets the current alarm setting.
Time change notification subscription.
Definition walltime.h:56
void * next
next pointer, internal use only
Definition walltime.h:57
void * ctx
callback function context
Definition walltime.h:59
walltime_change_cb_t cb
time change callback function
Definition walltime.h:58