Loading...
Searching...
No Matches
furi_hal_rtc.h File Reference

Furi Hal RTC API. More...

#include <stdint.h>
#include <stdbool.h>
#include <datetime/datetime.h>
#include <core/common_defines.h>

Go to the source code of this file.

Typedefs

typedef void(* FuriHalRtcAlarmCallback) (void *context)
 Furi HAL RTC alarm callback signature.
 

Enumerations

enum  FuriHalRtcFlag {
  FuriHalRtcFlagDebug = (1 << 0) , FuriHalRtcFlagStorageFormatInternal = (1 << 1) , FuriHalRtcFlagLock = (1 << 2) , FuriHalRtcFlagC2Update = (1 << 3) ,
  FuriHalRtcFlagHandOrient = (1 << 4) , FuriHalRtcFlagLegacySleep = (1 << 5) , FuriHalRtcFlagStealthMode = (1 << 6) , FuriHalRtcFlagDetailedFilename = (1 << 7)
}
 
enum  FuriHalRtcBootMode {
  FuriHalRtcBootModeNormal = 0 , FuriHalRtcBootModeDfu , FuriHalRtcBootModePreUpdate , FuriHalRtcBootModeUpdate ,
  FuriHalRtcBootModePostUpdate
}
 
enum  FuriHalRtcHeapTrackMode { FuriHalRtcHeapTrackModeNone = 0 , FuriHalRtcHeapTrackModeMain , FuriHalRtcHeapTrackModeTree , FuriHalRtcHeapTrackModeAll }
 
enum  FuriHalRtcRegister {
  FuriHalRtcRegisterHeader , FuriHalRtcRegisterSystem , FuriHalRtcRegisterVersion , FURI_DEPRECATED ,
  FuriHalRtcRegisterFaultData , FuriHalRtcRegisterPinFails , FuriHalRtcRegisterUpdateFolderFSIndex , FuriHalRtcRegisterPinValue ,
  FuriHalRtcRegisterMAX
}
 
enum  FuriHalRtcLocaleUnits { FuriHalRtcLocaleUnitsMetric = 0x0 , FuriHalRtcLocaleUnitsImperial = 0x1 }
 
enum  FuriHalRtcLocaleTimeFormat { FuriHalRtcLocaleTimeFormat24h = 0x0 , FuriHalRtcLocaleTimeFormat12h = 0x1 }
 
enum  FuriHalRtcLocaleDateFormat { FuriHalRtcLocaleDateFormatDMY = 0x0 , FuriHalRtcLocaleDateFormatMDY = 0x1 , FuriHalRtcLocaleDateFormatYMD = 0x2 }
 
enum  FuriHalRtcLogDevice { FuriHalRtcLogDeviceUsart = 0x0 , FuriHalRtcLogDeviceLpuart = 0x1 , FuriHalRtcLogDeviceReserved = 0x2 , FuriHalRtcLogDeviceNone = 0x3 }
 
enum  FuriHalRtcLogBaudRate {
  FuriHalRtcLogBaudRate230400 = 0x0 , FuriHalRtcLogBaudRate9600 = 0x1 , FuriHalRtcLogBaudRate38400 = 0x2 , FuriHalRtcLogBaudRate57600 = 0x3 ,
  FuriHalRtcLogBaudRate115200 = 0x4 , FuriHalRtcLogBaudRate460800 = 0x5 , FuriHalRtcLogBaudRate921600 = 0x6 , FuriHalRtcLogBaudRate1843200 = 0x7
}
 

Functions

void furi_hal_rtc_init_early (void)
 Early initialization.
 
void furi_hal_rtc_deinit_early (void)
 Early de-initialization.
 
void furi_hal_rtc_init (void)
 Initialize RTC subsystem.
 
void furi_hal_rtc_prepare_for_shutdown (void)
 Prepare system for shutdown.
 
void furi_hal_rtc_sync_shadow (void)
 Force sync shadow registers.
 
void furi_hal_rtc_reset_registers (void)
 Reset ALL RTC registers content.
 
uint32_t furi_hal_rtc_get_register (FuriHalRtcRegister reg)
 Get RTC register content.
 
void furi_hal_rtc_set_register (FuriHalRtcRegister reg, uint32_t value)
 Set register content.
 
void furi_hal_rtc_set_log_level (uint8_t level)
 Set Log Level value.
 
uint8_t furi_hal_rtc_get_log_level (void)
 Get Log Level value.
 
void furi_hal_rtc_set_log_device (FuriHalRtcLogDevice device)
 Set logging device.
 
FuriHalRtcLogDevice furi_hal_rtc_get_log_device (void)
 Get logging device.
 
void furi_hal_rtc_set_log_baud_rate (FuriHalRtcLogBaudRate baud_rate)
 Set logging baud rate.
 
FuriHalRtcLogBaudRate furi_hal_rtc_get_log_baud_rate (void)
 Get logging baud rate.
 
void furi_hal_rtc_set_flag (FuriHalRtcFlag flag)
 Set RTC Flag.
 
void furi_hal_rtc_reset_flag (FuriHalRtcFlag flag)
 Reset RTC Flag.
 
bool furi_hal_rtc_is_flag_set (FuriHalRtcFlag flag)
 Check if RTC Flag is set.
 
void furi_hal_rtc_set_boot_mode (FuriHalRtcBootMode mode)
 Set RTC boot mode.
 
FuriHalRtcBootMode furi_hal_rtc_get_boot_mode (void)
 Get RTC boot mode.
 
void furi_hal_rtc_set_heap_track_mode (FuriHalRtcHeapTrackMode mode)
 Set Heap Track mode.
 
FuriHalRtcHeapTrackMode furi_hal_rtc_get_heap_track_mode (void)
 Get RTC Heap Track mode.
 
void furi_hal_rtc_set_locale_units (FuriHalRtcLocaleUnits value)
 Set locale units.
 
FuriHalRtcLocaleUnits furi_hal_rtc_get_locale_units (void)
 Get RTC Locale Units.
 
void furi_hal_rtc_set_locale_timeformat (FuriHalRtcLocaleTimeFormat value)
 Set RTC Locale Time Format.
 
FuriHalRtcLocaleTimeFormat furi_hal_rtc_get_locale_timeformat (void)
 Get RTC Locale Time Format.
 
void furi_hal_rtc_set_locale_dateformat (FuriHalRtcLocaleDateFormat value)
 Set RTC Locale Date Format.
 
FuriHalRtcLocaleDateFormat furi_hal_rtc_get_locale_dateformat (void)
 Get RTC Locale Date Format.
 
void furi_hal_rtc_set_datetime (DateTime *datetime)
 Set RTC Date Time.
 
void furi_hal_rtc_get_datetime (DateTime *datetime)
 Get RTC Date Time.
 
void furi_hal_rtc_set_alarm (const DateTime *datetime, bool enabled)
 Set alarm.
 
bool furi_hal_rtc_get_alarm (DateTime *datetime)
 Get alarm.
 
void furi_hal_rtc_set_alarm_callback (FuriHalRtcAlarmCallback callback, void *context)
 Set alarm callback.
 
void furi_hal_rtc_set_fault_data (uint32_t value)
 Set RTC Fault Data.
 
uint32_t furi_hal_rtc_get_fault_data (void)
 Get RTC Fault Data.
 
void furi_hal_rtc_set_pin_fails (uint32_t value)
 Set PIN Fails count.
 
uint32_t furi_hal_rtc_get_pin_fails (void)
 Get PIN Fails count.
 
void furi_hal_rtc_set_pin_value (uint32_t value)
 Set encoded PIN value.
 
uint32_t furi_hal_rtc_get_pin_value (void)
 Get the current PIN encoded value.
 
uint32_t furi_hal_rtc_get_timestamp (void)
 Get UNIX Timestamp.
 

Detailed Description

Furi Hal RTC API.

Enumeration Type Documentation

◆ FuriHalRtcBootMode

Enumerator
FuriHalRtcBootModeNormal 

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.

◆ FuriHalRtcHeapTrackMode

Enumerator
FuriHalRtcHeapTrackModeNone 

Disable allocation tracking.

FuriHalRtcHeapTrackModeMain 

Enable allocation tracking for main application thread.

FuriHalRtcHeapTrackModeTree 

Enable allocation tracking for main and children application threads.

FuriHalRtcHeapTrackModeAll 

Enable allocation tracking for all threads.

◆ FuriHalRtcLocaleDateFormat

Enumerator
FuriHalRtcLocaleDateFormatDMY 

Day/Month/Year.

FuriHalRtcLocaleDateFormatMDY 

Month/Day/Year.

FuriHalRtcLocaleDateFormatYMD 

Year/Month/Day.

◆ FuriHalRtcLocaleTimeFormat

Enumerator
FuriHalRtcLocaleTimeFormat24h 

24-hour format

FuriHalRtcLocaleTimeFormat12h 

12-hour format

◆ FuriHalRtcLocaleUnits

Enumerator
FuriHalRtcLocaleUnitsMetric 

Metric measurement units.

FuriHalRtcLocaleUnitsImperial 

Imperial measurement units.

◆ FuriHalRtcLogBaudRate

Enumerator
FuriHalRtcLogBaudRate230400 

230400 baud

FuriHalRtcLogBaudRate9600 

9600 baud

FuriHalRtcLogBaudRate38400 

38400 baud

FuriHalRtcLogBaudRate57600 

57600 baud

FuriHalRtcLogBaudRate115200 

115200 baud

FuriHalRtcLogBaudRate460800 

460800 baud

FuriHalRtcLogBaudRate921600 

921600 baud

FuriHalRtcLogBaudRate1843200 

1843200 baud

◆ FuriHalRtcLogDevice

Enumerator
FuriHalRtcLogDeviceUsart 

Default: USART.

FuriHalRtcLogDeviceLpuart 

Default: LPUART.

FuriHalRtcLogDeviceReserved 

Reserved for future use.

FuriHalRtcLogDeviceNone 

None, disable serial logging.

◆ FuriHalRtcRegister

Enumerator
FuriHalRtcRegisterHeader 

RTC structure header.

FuriHalRtcRegisterSystem 

Various system bits.

FuriHalRtcRegisterVersion 

Pointer to Version.

FURI_DEPRECATED 

LFS geometry fingerprint.

FuriHalRtcRegisterFaultData 

Pointer to last fault message.

FuriHalRtcRegisterPinFails 

Failed PINs count.

FuriHalRtcRegisterPinValue 

Encoded value of the currently set PIN.

FuriHalRtcRegisterMAX 

Service value, do not use.

Function Documentation

◆ furi_hal_rtc_get_alarm()

bool furi_hal_rtc_get_alarm ( DateTime * datetime)

Get alarm.

Parameters
datetimePointer to DateTime object
Returns
true if alarm was set, false otherwise

◆ furi_hal_rtc_get_boot_mode()

FuriHalRtcBootMode furi_hal_rtc_get_boot_mode ( void )

Get RTC boot mode.

Returns
The RTC boot mode.

◆ furi_hal_rtc_get_datetime()

void furi_hal_rtc_get_datetime ( DateTime * datetime)

Get RTC Date Time.

Parameters
datetimeThe datetime

◆ furi_hal_rtc_get_fault_data()

uint32_t furi_hal_rtc_get_fault_data ( void )

Get RTC Fault Data.

Returns
RTC Fault Data value

◆ furi_hal_rtc_get_heap_track_mode()

FuriHalRtcHeapTrackMode furi_hal_rtc_get_heap_track_mode ( void )

Get RTC Heap Track mode.

Returns
The RTC heap track mode.

◆ furi_hal_rtc_get_locale_dateformat()

FuriHalRtcLocaleDateFormat furi_hal_rtc_get_locale_dateformat ( void )

Get RTC Locale Date Format.

Returns
The RTC Locale Date Format

◆ furi_hal_rtc_get_locale_timeformat()

FuriHalRtcLocaleTimeFormat furi_hal_rtc_get_locale_timeformat ( void )

Get RTC Locale Time Format.

Returns
The RTC Locale Time Format.

◆ furi_hal_rtc_get_locale_units()

FuriHalRtcLocaleUnits furi_hal_rtc_get_locale_units ( void )

Get RTC Locale Units.

Returns
The RTC Locale Units.

◆ furi_hal_rtc_get_log_baud_rate()

FuriHalRtcLogBaudRate furi_hal_rtc_get_log_baud_rate ( void )

Get logging baud rate.

Returns
The furi hal rtc log baud rate.

◆ furi_hal_rtc_get_log_device()

FuriHalRtcLogDevice furi_hal_rtc_get_log_device ( void )

Get logging device.

Returns
The furi hal rtc log device.

◆ furi_hal_rtc_get_log_level()

uint8_t furi_hal_rtc_get_log_level ( void )

Get Log Level value.

Returns
The Log Level value

◆ furi_hal_rtc_get_pin_fails()

uint32_t furi_hal_rtc_get_pin_fails ( void )

Get PIN Fails count.

Returns
PIN Fails Count

◆ furi_hal_rtc_get_register()

uint32_t furi_hal_rtc_get_register ( FuriHalRtcRegister reg)

Get RTC register content.

Parameters
[in]regThe register identifier
Returns
content of the register

◆ furi_hal_rtc_get_timestamp()

uint32_t furi_hal_rtc_get_timestamp ( void )

Get UNIX Timestamp.

Returns
Unix Timestamp in seconds from UNIX epoch start

◆ furi_hal_rtc_is_flag_set()

bool furi_hal_rtc_is_flag_set ( FuriHalRtcFlag flag)

Check if RTC Flag is set.

Parameters
[in]flagThe flag to check
Returns
true if set

◆ furi_hal_rtc_prepare_for_shutdown()

void furi_hal_rtc_prepare_for_shutdown ( void )

Prepare system for shutdown.

This function must be called before system sent to transport mode(power off). FlipperZero implementation configures and enables ALARM output on pin PC13 (Back button). This allows the system to wake-up charger from transport mode.

◆ furi_hal_rtc_reset_flag()

void furi_hal_rtc_reset_flag ( FuriHalRtcFlag flag)

Reset RTC Flag.

Parameters
[in]flagThe flag to reset

◆ furi_hal_rtc_set_alarm()

void furi_hal_rtc_set_alarm ( const DateTime * datetime,
bool enabled )

Set alarm.

Parameters
[in]datetimeThe date time to set or NULL if time change is not needed
[in]enabledIndicates if alarm must be enabled or disabled

◆ furi_hal_rtc_set_alarm_callback()

void furi_hal_rtc_set_alarm_callback ( FuriHalRtcAlarmCallback callback,
void * context )

Set alarm callback.

Use it to subscribe to alarm trigger event. Setting alarm callback is independent from setting alarm.

Warning
Normally this callback will be delivered from the ISR, however we may deliver it while this function is called. This happens when the alarm has already triggered, but there was no ISR set.
Parameters
[in]callbackThe callback
contextThe context

◆ furi_hal_rtc_set_boot_mode()

void furi_hal_rtc_set_boot_mode ( FuriHalRtcBootMode mode)

Set RTC boot mode.

Parameters
[in]modeThe mode to set

◆ furi_hal_rtc_set_datetime()

void furi_hal_rtc_set_datetime ( DateTime * datetime)

Set RTC Date Time.

Parameters
datetimeThe date time to set

◆ furi_hal_rtc_set_fault_data()

void furi_hal_rtc_set_fault_data ( uint32_t value)

Set RTC Fault Data.

Parameters
[in]valueThe value

◆ furi_hal_rtc_set_flag()

void furi_hal_rtc_set_flag ( FuriHalRtcFlag flag)

Set RTC Flag.

Parameters
[in]flagThe flag to set

◆ furi_hal_rtc_set_heap_track_mode()

void furi_hal_rtc_set_heap_track_mode ( FuriHalRtcHeapTrackMode mode)

Set Heap Track mode.

Parameters
[in]modeThe mode to set

◆ furi_hal_rtc_set_locale_dateformat()

void furi_hal_rtc_set_locale_dateformat ( FuriHalRtcLocaleDateFormat value)

Set RTC Locale Date Format.

Parameters
[in]valueThe RTC Locale Date Format

◆ furi_hal_rtc_set_locale_timeformat()

void furi_hal_rtc_set_locale_timeformat ( FuriHalRtcLocaleTimeFormat value)

Set RTC Locale Time Format.

Parameters
[in]valueThe RTC Locale Time Format

◆ furi_hal_rtc_set_locale_units()

void furi_hal_rtc_set_locale_units ( FuriHalRtcLocaleUnits value)

Set locale units.

Parameters
[in]valueThe RTC Locale Units

◆ furi_hal_rtc_set_log_baud_rate()

void furi_hal_rtc_set_log_baud_rate ( FuriHalRtcLogBaudRate baud_rate)

Set logging baud rate.

Parameters
[in]baud_rateThe baud rate

◆ furi_hal_rtc_set_log_device()

void furi_hal_rtc_set_log_device ( FuriHalRtcLogDevice device)

Set logging device.

Parameters
[in]deviceThe device

◆ furi_hal_rtc_set_log_level()

void furi_hal_rtc_set_log_level ( uint8_t level)

Set Log Level value.

Parameters
[in]levelThe level to store

◆ furi_hal_rtc_set_pin_fails()

void furi_hal_rtc_set_pin_fails ( uint32_t value)

Set PIN Fails count.

Parameters
[in]valueThe PIN Fails count

◆ furi_hal_rtc_set_pin_value()

void furi_hal_rtc_set_pin_value ( uint32_t value)

Set encoded PIN value.

Parameters
[in]valuenew PIN code value to be set

◆ furi_hal_rtc_set_register()

void furi_hal_rtc_set_register ( FuriHalRtcRegister reg,
uint32_t value )

Set register content.

Parameters
[in]regThe register identifier
[in]valueThe value to store into register