Loading...
Searching...
No Matches
furi_hal_rtc.h
Go to the documentation of this file.
1
6#pragma once
7
8#include <stdint.h>
9#include <stdbool.h>
10
11#include <datetime/datetime.h>
12#include <core/common_defines.h>
13
14#ifdef __cplusplus
15extern "C" {
16#endif
17
18typedef enum {
19 FuriHalRtcFlagDebug = (1 << 0),
20 FuriHalRtcFlagStorageFormatInternal = (1 << 1),
21 FuriHalRtcFlagLock = (1 << 2),
22 FuriHalRtcFlagC2Update = (1 << 3),
23 FuriHalRtcFlagHandOrient = (1 << 4),
24 FuriHalRtcFlagLegacySleep = (1 << 5),
25 FuriHalRtcFlagStealthMode = (1 << 6),
26 FuriHalRtcFlagDetailedFilename = (1 << 7),
27} FuriHalRtcFlag;
28
36
43
44typedef enum {
48 FuriHalRtcRegisterLfsFingerprint FURI_DEPRECATED,
51 /* Index of FS directory entry corresponding to FW update to be applied */
52 FuriHalRtcRegisterUpdateFolderFSIndex,
57
62
67
73
80
91
94
97
99void furi_hal_rtc_init(void);
100
108
110void furi_hal_rtc_sync_shadow(void);
111
114
122
128void furi_hal_rtc_set_register(FuriHalRtcRegister reg, uint32_t value);
129
134void furi_hal_rtc_set_log_level(uint8_t level);
135
140uint8_t furi_hal_rtc_get_log_level(void);
141
147
153
159
165
170void furi_hal_rtc_set_flag(FuriHalRtcFlag flag);
171
176void furi_hal_rtc_reset_flag(FuriHalRtcFlag flag);
177
184bool furi_hal_rtc_is_flag_set(FuriHalRtcFlag flag);
185
191
197
203
209
215
221
227
233
239
245
250void furi_hal_rtc_set_datetime(DateTime* datetime);
251
256void furi_hal_rtc_get_datetime(DateTime* datetime);
257
263void furi_hal_rtc_set_alarm(const DateTime* datetime, bool enabled);
264
271bool furi_hal_rtc_get_alarm(DateTime* datetime);
272
274typedef void (*FuriHalRtcAlarmCallback)(void* context);
275
288void furi_hal_rtc_set_alarm_callback(FuriHalRtcAlarmCallback callback, void* context);
289
294void furi_hal_rtc_set_fault_data(uint32_t value);
295
300uint32_t furi_hal_rtc_get_fault_data(void);
301
306void furi_hal_rtc_set_pin_fails(uint32_t value);
307
312uint32_t furi_hal_rtc_get_pin_fails(void);
313
318void furi_hal_rtc_set_pin_value(uint32_t value);
319
323uint32_t furi_hal_rtc_get_pin_value(void);
324
329uint32_t furi_hal_rtc_get_timestamp(void);
330
331#ifdef __cplusplus
332}
333#endif
void furi_hal_rtc_set_log_baud_rate(FuriHalRtcLogBaudRate baud_rate)
Set logging baud rate.
Definition furi_hal_rtc.c:285
void furi_hal_rtc_set_alarm(const DateTime *datetime, bool enabled)
Set alarm.
Definition furi_hal_rtc.c:448
void furi_hal_rtc_set_pin_value(uint32_t value)
Set encoded PIN value.
Definition furi_hal_rtc.c:540
void furi_hal_rtc_set_locale_units(FuriHalRtcLocaleUnits value)
Set locale units.
Definition furi_hal_rtc.c:356
void furi_hal_rtc_reset_flag(FuriHalRtcFlag flag)
Reset RTC Flag.
Definition furi_hal_rtc.c:313
FuriHalRtcLocaleDateFormat
Definition furi_hal_rtc.h:68
@ FuriHalRtcLocaleDateFormatMDY
Month/Day/Year.
Definition furi_hal_rtc.h:70
@ FuriHalRtcLocaleDateFormatDMY
Day/Month/Year.
Definition furi_hal_rtc.h:69
@ FuriHalRtcLocaleDateFormatYMD
Year/Month/Day.
Definition furi_hal_rtc.h:71
FuriHalRtcHeapTrackMode furi_hal_rtc_get_heap_track_mode(void)
Get RTC Heap Track mode.
Definition furi_hal_rtc.c:350
void furi_hal_rtc_sync_shadow(void)
Force sync shadow registers.
Definition furi_hal_rtc.c:226
FuriHalRtcLocaleUnits
Definition furi_hal_rtc.h:58
@ FuriHalRtcLocaleUnitsMetric
Metric measurement units.
Definition furi_hal_rtc.h:59
@ FuriHalRtcLocaleUnitsImperial
Imperial measurement units.
Definition furi_hal_rtc.h:60
void furi_hal_rtc_set_pin_fails(uint32_t value)
Set PIN Fails count.
Definition furi_hal_rtc.c:532
void(* FuriHalRtcAlarmCallback)(void *context)
Furi HAL RTC alarm callback signature.
Definition furi_hal_rtc.h:274
FuriHalRtcLocaleTimeFormat
Definition furi_hal_rtc.h:63
@ FuriHalRtcLocaleTimeFormat24h
24-hour format
Definition furi_hal_rtc.h:64
@ FuriHalRtcLocaleTimeFormat12h
12-hour format
Definition furi_hal_rtc.h:65
void furi_hal_rtc_set_register(FuriHalRtcRegister reg, uint32_t value)
Set register content.
Definition furi_hal_rtc.c:250
uint32_t furi_hal_rtc_get_pin_value(void)
Get the current PIN encoded value.
Definition furi_hal_rtc.c:544
FuriHalRtcHeapTrackMode
Definition furi_hal_rtc.h:37
@ FuriHalRtcHeapTrackModeAll
Enable allocation tracking for all threads.
Definition furi_hal_rtc.h:41
@ FuriHalRtcHeapTrackModeTree
Enable allocation tracking for main and children application threads.
Definition furi_hal_rtc.h:40
@ FuriHalRtcHeapTrackModeMain
Enable allocation tracking for main application thread.
Definition furi_hal_rtc.h:39
@ FuriHalRtcHeapTrackModeNone
Disable allocation tracking.
Definition furi_hal_rtc.h:38
FuriHalRtcLocaleDateFormat furi_hal_rtc_get_locale_dateformat(void)
Get RTC Locale Date Format.
Definition furi_hal_rtc.c:389
void furi_hal_rtc_set_alarm_callback(FuriHalRtcAlarmCallback callback, void *context)
Set alarm callback.
Definition furi_hal_rtc.c:488
uint32_t furi_hal_rtc_get_register(FuriHalRtcRegister reg)
Get RTC register content.
Definition furi_hal_rtc.c:246
FuriHalRtcLogBaudRate
Definition furi_hal_rtc.h:81
@ FuriHalRtcLogBaudRate115200
115200 baud
Definition furi_hal_rtc.h:86
@ FuriHalRtcLogBaudRate460800
460800 baud
Definition furi_hal_rtc.h:87
@ FuriHalRtcLogBaudRate921600
921600 baud
Definition furi_hal_rtc.h:88
@ FuriHalRtcLogBaudRate38400
38400 baud
Definition furi_hal_rtc.h:84
@ FuriHalRtcLogBaudRate1843200
1843200 baud
Definition furi_hal_rtc.h:89
@ FuriHalRtcLogBaudRate230400
230400 baud
Definition furi_hal_rtc.h:82
@ FuriHalRtcLogBaudRate57600
57600 baud
Definition furi_hal_rtc.h:85
@ FuriHalRtcLogBaudRate9600
9600 baud
Definition furi_hal_rtc.h:83
uint32_t furi_hal_rtc_get_timestamp(void)
Get UNIX Timestamp.
Definition furi_hal_rtc.c:548
FuriHalRtcLocaleTimeFormat furi_hal_rtc_get_locale_timeformat(void)
Get RTC Locale Time Format.
Definition furi_hal_rtc.c:376
void furi_hal_rtc_prepare_for_shutdown(void)
Prepare system for shutdown.
Definition furi_hal_rtc.c:222
void furi_hal_rtc_set_boot_mode(FuriHalRtcBootMode mode)
Set RTC boot mode.
Definition furi_hal_rtc.c:330
void furi_hal_rtc_deinit_early(void)
Early de-initialization.
Definition furi_hal_rtc.c:203
FuriHalRtcRegister
Definition furi_hal_rtc.h:44
@ FuriHalRtcRegisterPinFails
Failed PINs count.
Definition furi_hal_rtc.h:50
@ FuriHalRtcRegisterPinValue
Encoded value of the currently set PIN.
Definition furi_hal_rtc.h:53
@ FuriHalRtcRegisterSystem
Various system bits.
Definition furi_hal_rtc.h:46
@ FURI_DEPRECATED
LFS geometry fingerprint.
Definition furi_hal_rtc.h:48
@ FuriHalRtcRegisterFaultData
Pointer to last fault message.
Definition furi_hal_rtc.h:49
@ FuriHalRtcRegisterVersion
Pointer to Version.
Definition furi_hal_rtc.h:47
@ FuriHalRtcRegisterHeader
RTC structure header.
Definition furi_hal_rtc.h:45
@ FuriHalRtcRegisterMAX
Service value, do not use.
Definition furi_hal_rtc.h:55
bool furi_hal_rtc_get_alarm(DateTime *datetime)
Get alarm.
Definition furi_hal_rtc.c:476
uint8_t furi_hal_rtc_get_log_level(void)
Get Log Level value.
Definition furi_hal_rtc.c:262
void furi_hal_rtc_init(void)
Initialize RTC subsystem.
Definition furi_hal_rtc.c:206
FuriHalRtcBootMode furi_hal_rtc_get_boot_mode(void)
Get RTC boot mode.
Definition furi_hal_rtc.c:337
void furi_hal_rtc_set_flag(FuriHalRtcFlag flag)
Set RTC Flag.
Definition furi_hal_rtc.c:302
void furi_hal_rtc_set_heap_track_mode(FuriHalRtcHeapTrackMode mode)
Set Heap Track mode.
Definition furi_hal_rtc.c:343
void furi_hal_rtc_set_fault_data(uint32_t value)
Set RTC Fault Data.
Definition furi_hal_rtc.c:524
void furi_hal_rtc_reset_registers(void)
Reset ALL RTC registers content.
Definition furi_hal_rtc.c:234
FuriHalRtcBootMode
Definition furi_hal_rtc.h:29
@ FuriHalRtcBootModeUpdate
Boot to Update, main.
Definition furi_hal_rtc.h:33
@ FuriHalRtcBootModePreUpdate
Boot to Update, pre update.
Definition furi_hal_rtc.h:32
@ FuriHalRtcBootModeDfu
Boot to DFU (MCU bootloader by ST)
Definition furi_hal_rtc.h:31
@ FuriHalRtcBootModeNormal
Normal boot mode, default value.
Definition furi_hal_rtc.h:30
@ FuriHalRtcBootModePostUpdate
Boot to Update, post update.
Definition furi_hal_rtc.h:34
FuriHalRtcLocaleUnits furi_hal_rtc_get_locale_units(void)
Get RTC Locale Units.
Definition furi_hal_rtc.c:363
void furi_hal_rtc_set_locale_dateformat(FuriHalRtcLocaleDateFormat value)
Set RTC Locale Date Format.
Definition furi_hal_rtc.c:382
void furi_hal_rtc_set_log_device(FuriHalRtcLogDevice device)
Set logging device.
Definition furi_hal_rtc.c:268
uint32_t furi_hal_rtc_get_pin_fails(void)
Get PIN Fails count.
Definition furi_hal_rtc.c:536
FuriHalRtcLogBaudRate furi_hal_rtc_get_log_baud_rate(void)
Get logging baud rate.
Definition furi_hal_rtc.c:296
void furi_hal_rtc_init_early(void)
Early initialization.
Definition furi_hal_rtc.c:179
void furi_hal_rtc_set_log_level(uint8_t level)
Set Log Level value.
Definition furi_hal_rtc.c:254
void furi_hal_rtc_get_datetime(DateTime *datetime)
Get RTC Date Time.
Definition furi_hal_rtc.c:430
void furi_hal_rtc_set_locale_timeformat(FuriHalRtcLocaleTimeFormat value)
Set RTC Locale Time Format.
Definition furi_hal_rtc.c:369
uint32_t furi_hal_rtc_get_fault_data(void)
Get RTC Fault Data.
Definition furi_hal_rtc.c:528
void furi_hal_rtc_set_datetime(DateTime *datetime)
Set RTC Date Time.
Definition furi_hal_rtc.c:395
bool furi_hal_rtc_is_flag_set(FuriHalRtcFlag flag)
Check if RTC Flag is set.
Definition furi_hal_rtc.c:324
FuriHalRtcLogDevice
Definition furi_hal_rtc.h:74
@ FuriHalRtcLogDeviceReserved
Reserved for future use.
Definition furi_hal_rtc.h:77
@ FuriHalRtcLogDeviceLpuart
Default: LPUART.
Definition furi_hal_rtc.h:76
@ FuriHalRtcLogDeviceNone
None, disable serial logging.
Definition furi_hal_rtc.h:78
@ FuriHalRtcLogDeviceUsart
Default: USART.
Definition furi_hal_rtc.h:75
FuriHalRtcLogDevice furi_hal_rtc_get_log_device(void)
Get logging device.
Definition furi_hal_rtc.c:279
Definition datetime.h:10