2021-12-15 01:39:59 +03:00
|
|
|
/**
|
2022-01-05 19:10:18 +03:00
|
|
|
* @file furi_hal_rtc.h
|
2021-12-15 01:39:59 +03:00
|
|
|
* Furi Hal RTC API
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
// Time
|
2022-01-05 19:10:18 +03:00
|
|
|
uint8_t hour; /**< Hour in 24H format: 0-23 */
|
2021-12-15 01:39:59 +03:00
|
|
|
uint8_t minute; /**< Minute: 0-59 */
|
|
|
|
uint8_t second; /**< Second: 0-59 */
|
|
|
|
// Date
|
2022-01-05 19:10:18 +03:00
|
|
|
uint8_t day; /**< Current day: 1-31 */
|
|
|
|
uint8_t month; /**< Current month: 1-12 */
|
|
|
|
uint16_t year; /**< Current year: 2000-2099 */
|
|
|
|
uint8_t weekday; /**< Current weekday: 1-7 */
|
2021-12-15 01:39:59 +03:00
|
|
|
} FuriHalRtcDateTime;
|
|
|
|
|
|
|
|
typedef enum {
|
2022-01-05 19:10:18 +03:00
|
|
|
FuriHalRtcFlagDebug = (1 << 0),
|
|
|
|
FuriHalRtcFlagFactoryReset = (1 << 1),
|
|
|
|
FuriHalRtcFlagLock = (1 << 2),
|
2021-12-15 01:39:59 +03:00
|
|
|
} FuriHalRtcFlag;
|
|
|
|
|
2021-12-24 17:33:58 +03:00
|
|
|
typedef enum {
|
2022-04-13 23:50:25 +03:00
|
|
|
FuriHalRtcBootModeNormal = 0, /**< Normal boot mode, default value */
|
|
|
|
FuriHalRtcBootModeDfu, /**< Boot to DFU (MCU bootloader by ST) */
|
|
|
|
FuriHalRtcBootModePreUpdate, /**< Boot to Update, pre update */
|
|
|
|
FuriHalRtcBootModeUpdate, /**< Boot to Update, main */
|
|
|
|
FuriHalRtcBootModePostUpdate, /**< Boot to Update, post update */
|
|
|
|
} FuriHalRtcBootMode;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
FuriHalRtcRegisterHeader, /**< RTC structure header */
|
|
|
|
FuriHalRtcRegisterSystem, /**< Various system bits */
|
|
|
|
FuriHalRtcRegisterVersion, /**< Pointer to Version */
|
|
|
|
FuriHalRtcRegisterLfsFingerprint, /**< LFS geometry fingerprint */
|
|
|
|
FuriHalRtcRegisterFaultData, /**< Pointer to last fault message */
|
|
|
|
FuriHalRtcRegisterPinFails, /**< Failed pins count */
|
|
|
|
/* Index of FS directory entry corresponding to FW update to be applied */
|
|
|
|
FuriHalRtcRegisterUpdateFolderFSIndex,
|
|
|
|
|
|
|
|
FuriHalRtcRegisterMAX, /**< Service value, do not use */
|
2021-12-24 17:33:58 +03:00
|
|
|
} FuriHalRtcRegister;
|
|
|
|
|
2022-04-13 23:50:25 +03:00
|
|
|
/** Early initialization */
|
|
|
|
void furi_hal_rtc_init_early();
|
|
|
|
|
|
|
|
/** Early deinitialization */
|
|
|
|
void furi_hal_rtc_deinit_early();
|
|
|
|
|
2021-12-15 01:39:59 +03:00
|
|
|
/** Initialize RTC subsystem */
|
|
|
|
void furi_hal_rtc_init();
|
|
|
|
|
2021-12-24 17:33:58 +03:00
|
|
|
uint32_t furi_hal_rtc_get_register(FuriHalRtcRegister reg);
|
|
|
|
|
|
|
|
void furi_hal_rtc_set_register(FuriHalRtcRegister reg, uint32_t value);
|
|
|
|
|
2021-12-15 01:39:59 +03:00
|
|
|
void furi_hal_rtc_set_log_level(uint8_t level);
|
|
|
|
|
|
|
|
uint8_t furi_hal_rtc_get_log_level();
|
|
|
|
|
|
|
|
void furi_hal_rtc_set_flag(FuriHalRtcFlag flag);
|
|
|
|
|
|
|
|
void furi_hal_rtc_reset_flag(FuriHalRtcFlag flag);
|
|
|
|
|
|
|
|
bool furi_hal_rtc_is_flag_set(FuriHalRtcFlag flag);
|
|
|
|
|
2022-04-13 23:50:25 +03:00
|
|
|
void furi_hal_rtc_set_boot_mode(FuriHalRtcBootMode mode);
|
|
|
|
|
|
|
|
FuriHalRtcBootMode furi_hal_rtc_get_boot_mode();
|
|
|
|
|
2021-12-15 01:39:59 +03:00
|
|
|
void furi_hal_rtc_set_datetime(FuriHalRtcDateTime* datetime);
|
|
|
|
|
|
|
|
void furi_hal_rtc_get_datetime(FuriHalRtcDateTime* datetime);
|
|
|
|
|
2021-12-17 16:24:37 +03:00
|
|
|
bool furi_hal_rtc_validate_datetime(FuriHalRtcDateTime* datetime);
|
|
|
|
|
2021-12-31 20:32:49 +03:00
|
|
|
void furi_hal_rtc_set_fault_data(uint32_t value);
|
|
|
|
|
|
|
|
uint32_t furi_hal_rtc_get_fault_data();
|
|
|
|
|
2022-02-10 21:17:41 +03:00
|
|
|
void furi_hal_rtc_set_pin_fails(uint32_t value);
|
|
|
|
|
|
|
|
uint32_t furi_hal_rtc_get_pin_fails();
|
|
|
|
|
2021-12-15 01:39:59 +03:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|