Ultibo API
C/C++ API for Ultibo Core
Loading...
Searching...
No Matches
rtc.h
Go to the documentation of this file.
1/*
2 * This file is part of the Ultibo project, https://ultibo.org/
3 *
4 * The MIT License (MIT)
5 *
6 * Copyright (c) 2026 Garry Wood <garry@softoz.com.au>
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a copy
9 * of this software and associated documentation files (the "Software"), to deal
10 * in the Software without restriction, including without limitation the rights
11 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 * copies of the Software, and to permit persons to whom the Software is
13 * furnished to do so, subject to the following conditions:
14 *
15 * The above copyright notice and this permission notice shall be included in
16 * all copies or substantial portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 * THE SOFTWARE.
25 */
26#ifndef _ULTIBO_RTC_H
27#define _ULTIBO_RTC_H
28
29#ifdef __cplusplus
30extern "C" {
31#endif
32
33#include "ultibo/globaltypes.h"
34#include "ultibo/globalconst.h"
35#include "ultibo/devices.h"
36#include "ultibo/sysutils.h"
37
39#define RTC_NAME_PREFIX "RTC"
40
42#define RTC_TYPE_NONE 0
43
44#define RTC_TYPE_MAX 0
45
47#define RTC_STATE_DISABLED 0
48#define RTC_STATE_ENABLED 1
49
50#define RTC_STATE_MAX 1
51
53#define RTC_FLAG_NONE 0x00000000
54#define RTC_FLAG_ALARM 0x00000001
55#define RTC_FLAG_WATCHDOG 0x00000002
56
58
62{
63 uint32_t flags;
64 int64_t mintime;
65 int64_t maxtime;
66 uint32_t alarmcount;
67};
68
70typedef struct _RTC_DEVICE RTC_DEVICE;
71
73typedef uint32_t STDCALL (*rtc_enumerate_cb)(RTC_DEVICE *rtc, void *data);
75typedef uint32_t STDCALL (*rtc_notification_cb)(DEVICE *device, void *data, uint32_t notification);
76
78typedef uint32_t STDCALL (*rtc_device_start_proc)(RTC_DEVICE *rtc);
79typedef uint32_t STDCALL (*rtc_device_stop_proc)(RTC_DEVICE *rtc);
81typedef int64_t STDCALL (*rtc_device_set_time_proc)(RTC_DEVICE *rtc, int64_t time);
83
106
110
112int64_t STDCALL rtc_device_set_time(RTC_DEVICE *rtc, int64_t time);
113
122
130
136
143
148
153
158
162uint32_t STDCALL rtc_device_enumerate(rtc_enumerate_cb callback, void *data);
163
164uint32_t STDCALL rtc_device_notification(RTC_DEVICE *rtc, rtc_notification_cb callback, void *data, uint32_t notification, uint32_t flags);
165
167
171uint32_t STDCALL rtc_get_count(void);
172
177
182
187
188uint32_t STDCALL rtc_device_type_to_string(uint32_t rtctype, char *string, uint32_t len);
189uint32_t STDCALL rtc_device_state_to_string(uint32_t rtcstate, char *string, uint32_t len);
190
192
196BOOL STDCALL rtc_systemtime_to_filetime(SYSTEMTIME *systemtime, int64_t *filetime);
197
201BOOL STDCALL rtc_filetime_to_systemtime(int64_t filetime, SYSTEMTIME *systemtime);
202
203#endif // _ULTIBO_RTC_H
struct _DEVICE DEVICE
Definition devices.h:373
#define STDCALL
Definition globaltypes.h:45
_Bool BOOL
Built in Boolean type (1 byte) (Redeclared here for flexibility).
Definition globaltypes.h:55
HANDLE MUTEX_HANDLE
Definition globaltypes.h:105
RTC_DEVICE *STDCALL rtc_device_check(RTC_DEVICE *rtc)
Check if the supplied RTC is in the RTC table.
uint32_t STDCALL rtc_device_type_to_string(uint32_t rtctype, char *string, uint32_t len)
BOOL STDCALL rtc_time_is_valid(SYSTEMTIME *time)
uint32_t STDCALL rtc_device_destroy(RTC_DEVICE *rtc)
Destroy an existing RTC entry.
uint32_t STDCALL(* rtc_device_get_properties_proc)(RTC_DEVICE *rtc, RTC_PROPERTIES *properties)
Definition rtc.h:82
RTC_DEVICE *STDCALL rtc_device_find_by_description(const char *description)
uint32_t STDCALL(* rtc_device_stop_proc)(RTC_DEVICE *rtc)
Definition rtc.h:79
int64_t STDCALL rtc_device_set_time(RTC_DEVICE *rtc, int64_t time)
uint32_t STDCALL rtc_device_stop(RTC_DEVICE *rtc)
uint32_t STDCALL(* rtc_device_start_proc)(RTC_DEVICE *rtc)
Definition rtc.h:78
uint32_t STDCALL(* rtc_enumerate_cb)(RTC_DEVICE *rtc, void *data)
Definition rtc.h:73
RTC_DEVICE *STDCALL rtc_device_create(void)
Create a new RTC entry.
int64_t STDCALL rtc_device_get_time(RTC_DEVICE *rtc)
struct _RTC_DEVICE RTC_DEVICE
Definition rtc.h:70
uint32_t STDCALL rtc_device_set_default(RTC_DEVICE *rtc)
Set the current default RTC device.
struct _RTC_PROPERTIES RTC_PROPERTIES
Definition rtc.h:60
int64_t STDCALL(* rtc_device_get_time_proc)(RTC_DEVICE *rtc)
Definition rtc.h:80
uint32_t STDCALL rtc_device_start(RTC_DEVICE *rtc)
RTC_DEVICE *STDCALL rtc_device_find_by_name(const char *name)
uint32_t STDCALL rtc_device_properties(RTC_DEVICE *rtc, RTC_PROPERTIES *properties)
Get the properties for the specified RTC device.
RTC_DEVICE *STDCALL rtc_device_get_default(void)
Get the current default RTC device.
uint32_t STDCALL rtc_device_register(RTC_DEVICE *rtc)
Register a new RTC in the RTC table.
BOOL STDCALL rtc_filetime_to_systemtime(int64_t filetime, SYSTEMTIME *systemtime)
uint32_t STDCALL rtc_device_enumerate(rtc_enumerate_cb callback, void *data)
uint32_t STDCALL rtc_get_count(void)
Get the current RTC count.
uint32_t STDCALL(* rtc_notification_cb)(DEVICE *device, void *data, uint32_t notification)
Definition rtc.h:75
uint32_t STDCALL rtc_device_state_to_string(uint32_t rtcstate, char *string, uint32_t len)
uint32_t STDCALL rtc_device_deregister(RTC_DEVICE *rtc)
Deregister a RTC from the RTC table.
RTC_DEVICE *STDCALL rtc_device_create_ex(uint32_t size)
Create a new RTC entry.
uint32_t STDCALL rtc_device_notification(RTC_DEVICE *rtc, rtc_notification_cb callback, void *data, uint32_t notification, uint32_t flags)
uint32_t STDCALL rtc_device_get_properties(RTC_DEVICE *rtc, RTC_PROPERTIES *properties)
Get the properties for the specified RTC device.
RTC_DEVICE *STDCALL rtc_device_find(uint32_t rtcid)
int64_t STDCALL(* rtc_device_set_time_proc)(RTC_DEVICE *rtc, int64_t time)
Definition rtc.h:81
BOOL STDCALL rtc_systemtime_to_filetime(SYSTEMTIME *systemtime, int64_t *filetime)
Definition rtc.h:85
MUTEX_HANDLE lock
Device lock.
Definition rtc.h:100
rtc_device_get_time_proc devicegettime
A Device specific DeviceGetTime method implementing the standard RTC device interface.
Definition rtc.h:93
RTC_PROPERTIES properties
Device properties.
Definition rtc.h:101
DEVICE device
The Device entry for this RTC.
Definition rtc.h:87
RTC_DEVICE * prev
Previous entry in RTC table.
Definition rtc.h:103
rtc_device_start_proc devicestart
A Device specific DeviceStart method implementing the standard RTC device interface.
Definition rtc.h:91
uint32_t getcount
Definition rtc.h:97
rtc_device_get_properties_proc devicegetproperties
A Device specific DeviceGetProperties method implementing the standard RTC device interface.
Definition rtc.h:95
uint32_t setcount
Definition rtc.h:98
uint32_t rtcid
Unique Id of this RTC in the RTC table.
Definition rtc.h:89
rtc_device_set_time_proc devicesettime
A Device specific DeviceSetTime method implementing the standard RTC device interface.
Definition rtc.h:94
RTC_DEVICE * next
Next entry in RTC table.
Definition rtc.h:104
uint32_t rtcstate
RTC state (eg RTC_STATE_ENABLED).
Definition rtc.h:90
rtc_device_stop_proc devicestop
A Device specific DeviceStop method implementing the standard RTC device interface.
Definition rtc.h:92
Definition rtc.h:62
int64_t mintime
Minimum time value represented by the device (Normally the power on reset value).
Definition rtc.h:64
uint32_t flags
Device flags (eg RTC_FLAG_ALARM).
Definition rtc.h:63
int64_t maxtime
Maximum time value represented by the device (Time when a rollover will occur).
Definition rtc.h:65
uint32_t alarmcount
Number of alarms supported by the device (0 if not supported).
Definition rtc.h:66
struct _SYSTEMTIME SYSTEMTIME