STM32 RTC Scheduler
RTC-based scheduler for ultra-low power applications
rtc.h File Reference

This file contains the RTC-specific function prototypes. More...

#include "stm32l4xx_hal.h"

Go to the source code of this file.

Functions

void RtcInit (void)
 RTC initialization function. More...
 
uint32_t RtcGetEpoch (void)
 Get the current epoch. More...
 
void RtcConvertEpochToDatetime (uint32_t epoch, RTC_DateTypeDef *date, RTC_TimeTypeDef *time)
 Convert an epoch to human-readable date and time format. More...
 
uint8_t RtcSetAlarmFromEpoch (const uint32_t epoch)
 Set an RTC alarm at a given time specified by an epoch. More...
 
void RtcDeactivateAlarm (void)
 Deactivate a previously set RTC alarm.
 
void RtcWaitForClockSynchronization (void)
 This function waits until the RTC time and date registers are synchronized with RTC APB clock. This function needs to be called after resuming execution from a sleep mode.
 

Detailed Description

This file contains the RTC-specific function prototypes.

STM32 RTC Scheduler

Author
Akos Pasztor
See also
Please refer to README for detailed information.

Definition in file rtc.h.

Function Documentation

◆ RtcConvertEpochToDatetime()

void RtcConvertEpochToDatetime ( uint32_t  epoch,
RTC_DateTypeDef *  date,
RTC_TimeTypeDef *  time 
)

Convert an epoch to human-readable date and time format.

This function converts an Unix epoch into human-readable date and time format.

See also
https://www.epochconverter.com/programming/c
Parameters
epochThe epoch to be converted.
datePointer to a RTC date structure where the converted values are written.
timePointer to a RTC time structure where the converted values are written.

Definition at line 120 of file rtc.c.

◆ RtcGetEpoch()

uint32_t RtcGetEpoch ( void  )

Get the current epoch.

This function retrieves the date and time from the RTC registers and converts the values into Unix epoch.

See also
https://www.epochconverter.com/programming/c
Returns
The current epoch in [s].

Definition at line 84 of file rtc.c.

◆ RtcInit()

void RtcInit ( void  )

RTC initialization function.

This function initializes the RTC peripheral and sets the current date and time to a predefined value.

Definition at line 30 of file rtc.c.

◆ RtcSetAlarmFromEpoch()

uint8_t RtcSetAlarmFromEpoch ( const uint32_t  epoch)

Set an RTC alarm at a given time specified by an epoch.

Parameters
epochThe epoch when an alarm should be set.
Returns
A non-zero number if the alarm has been successfully set; otherwise 0.

Definition at line 149 of file rtc.c.