STM32duino RTC
Arduino library for managing the RTC peripheral on STM32 boards.
Loading...
Searching...
No Matches
STM32RTC Class Reference

Controls the RTC peripheral on an STM32 board. More...

#include <STM32RTC.h>

Public Types

enum  Hour_Format : uint8_t { HOUR_12 = HOUR_FORMAT_12 , HOUR_24 = HOUR_FORMAT_24 }
 Selects the RTC hour display format. More...
enum  AM_PM : uint8_t { AM = HOUR_AM , PM = HOUR_PM }
 Selects the AM or PM period in 12-hour format. More...
enum  Binary_Mode : uint8_t { MODE_BCD = MODE_BINARY_NONE , MODE_BIN = MODE_BINARY_ONLY , MODE_MIX = MODE_BINARY_MIX }
 Selects BCD, binary, or combined RTC mode. More...
enum  Alarm_Match : uint8_t {
  MATCH_OFF = OFF_MSK , MATCH_SUBSEC = SUBSEC_MSK , MATCH_SS = SS_MSK , MATCH_MMSS = SS_MSK | MM_MSK ,
  MATCH_HHMMSS = SS_MSK | MM_MSK | HH_MSK , MATCH_DHHMMSS = SS_MSK | MM_MSK | HH_MSK | D_MSK , MATCH_MMDDHHMMSS = SS_MSK | MM_MSK | HH_MSK | D_MSK | M_MSK , MATCH_YYMMDDHHMMSS = SS_MSK | MM_MSK | HH_MSK | D_MSK | M_MSK | Y_MSK
}
 Selects which RTC fields must match for an alarm. More...
enum  Source_Clock : uint8_t { LSI_CLOCK = ::LSI_CLOCK , LSE_CLOCK = ::LSE_CLOCK , HSE_CLOCK = ::HSE_CLOCK }
 Selects the input clock source for the RTC. More...
enum  Alarm : uint32_t { ALARM_A = ::ALARM_A }
 Identifies an RTC alarm. More...

Public Member Functions

 STM32RTC (STM32RTC const &)=delete
void operator= (STM32RTC const &)=delete
void begin (bool resetTime, Hour_Format format=HOUR_24)
 Initializes the RTC and optionally resets its time.
void begin (Hour_Format format=HOUR_24)
 Initializes the RTC without resetting its current time.
void end (void)
 Deinitializes the RTC and clears registered callbacks.
RTC_HandleTypeDef * getHandle (void)
 Returns the STM32 HAL RTC handle.
Source_Clock getClockSource (void)
 Returns the selected RTC input clock source.
void setClockSource (Source_Clock source, uint32_t predivA=(PREDIVA_MAX+1), uint32_t predivS=(PREDIVS_MAX+1))
 Selects the RTC clock source and its prescalers.
void getPrediv (uint32_t *predivA, uint32_t *predivS)
 Reads the configured or calculated RTC prescalers.
void setPrediv (uint32_t predivA, uint32_t predivS)
 Sets the RTC prescalers.
Binary_Mode getBinaryMode (void)
 Returns the current RTC operating mode.
void setBinaryMode (Binary_Mode mode)
 Selects BCD, binary, or mixed RTC operation.
void enableAlarm (Alarm_Match match, Alarm name=ALARM_A)
 Enables an RTC alarm with the requested match fields.
void disableAlarm (Alarm name=ALARM_A)
 Disables an RTC alarm.
void attachInterrupt (voidFuncPtrParam callback, Alarm name)
 Attaches a callback to an RTC alarm.
void attachInterrupt (voidFuncPtrParam callback, void *data=nullptr, Alarm name=ALARM_A)
 Attaches a callback and user data to an RTC alarm.
void detachInterrupt (Alarm name=ALARM_A)
 Detaches the callback from an RTC alarm.
void standbyMode ()
 Compatibility method; use the STM32LowPower library for standby mode.
uint32_t getSubSeconds (void)
 Returns the current subsecond value in milliseconds.
uint8_t getSeconds (void)
 Returns the current seconds value.
uint8_t getMinutes (void)
 Returns the current minutes value.
uint8_t getHours (AM_PM *period=nullptr)
 Returns the current hours value.
void getTime (uint8_t *hours, uint8_t *minutes, uint8_t *seconds, uint32_t *subSeconds, AM_PM *period=nullptr)
 Reads the current time.
uint8_t getWeekDay (void)
 Returns the current weekday.
uint8_t getDay (void)
 Returns the current day of the month.
uint8_t getMonth (void)
 Returns the current month.
uint8_t getYear (void)
 Returns the current year value.
void getDate (uint8_t *weekDay, uint8_t *day, uint8_t *month, uint8_t *year)
 Reads the current date.
uint32_t getAlarmSubSeconds (Alarm name=ALARM_A)
 Returns the alarm subsecond value in milliseconds.
uint8_t getAlarmSeconds (Alarm name=ALARM_A)
 Returns the alarm seconds value.
uint8_t getAlarmMinutes (Alarm name=ALARM_A)
 Returns the alarm minutes value.
uint8_t getAlarmHours (Alarm name)
 Returns the alarm hours value.
uint8_t getAlarmHours (AM_PM *period=nullptr, Alarm name=ALARM_A)
 Returns the alarm hours value and optionally its AM/PM period.
uint8_t getAlarmDay (Alarm name=ALARM_A)
 Returns the alarm day of the month.
uint8_t getAlarmMonth (void)
 Returns zero; STM32 RTC alarms do not match a month.
uint8_t getAlarmYear (void)
 Returns zero; STM32 RTC alarms do not match a year.
void setSubSeconds (uint32_t subSeconds)
 Sets the current subsecond value in milliseconds.
void setSeconds (uint8_t seconds)
 Sets the current seconds value.
void setMinutes (uint8_t minutes)
 Sets the current minutes value.
void setHours (uint8_t hours, AM_PM period=AM)
 Sets the current hour value and optional AM/PM period.
void setTime (uint8_t hours, uint8_t minutes, uint8_t seconds, uint32_t subSeconds=1000, AM_PM period=AM)
 Sets the current time.
void setWeekDay (uint8_t weekDay)
 Sets the current weekday.
void setDay (uint8_t day)
 Sets the current day of the month.
void setMonth (uint8_t month)
 Sets the current month.
void setYear (uint8_t year)
 Sets the current year value.
void setDate (uint8_t day, uint8_t month, uint8_t year)
 Sets the current date without changing the weekday.
void setDate (uint8_t weekDay, uint8_t day, uint8_t month, uint8_t year)
 Sets the current weekday and date.
void setAlarmSubSeconds (uint32_t subSeconds, Alarm name=ALARM_A)
 Sets the alarm subsecond value in milliseconds.
void setAlarmSeconds (uint8_t seconds, Alarm name=ALARM_A)
 Sets the alarm seconds value.
void setAlarmMinutes (uint8_t minutes, Alarm name=ALARM_A)
 Sets the alarm minutes value.
void setAlarmHours (uint8_t hours, Alarm name)
 Sets the alarm hours value.
void setAlarmHours (uint8_t hours, AM_PM period=AM, Alarm name=ALARM_A)
 Sets the alarm hours value and optional AM/PM period.
void setAlarmTime (uint32_t subSeconds, Alarm name=ALARM_A)
 Sets an alarm using a subsecond value.
void setAlarmTime (uint8_t hours, uint8_t minutes, uint8_t seconds, Alarm name)
 Sets an alarm time without a subsecond value.
void setAlarmTime (uint8_t hours, uint8_t minutes, uint8_t seconds, uint32_t subSeconds, Alarm name)
 Sets an alarm time and subsecond value.
void setAlarmTime (uint8_t hours, uint8_t minutes, uint8_t seconds, uint32_t subSeconds=0, AM_PM period=AM, Alarm name=ALARM_A)
 Sets an alarm time.
void setAlarmDay (uint8_t day, Alarm name=ALARM_A)
 Sets the alarm day of the month.
void setAlarmMonth (uint8_t month)
 Compatibility method; the month is ignored by STM32 RTC alarms.
void setAlarmYear (uint8_t year)
 Compatibility method; the year is ignored by STM32 RTC alarms.
void setAlarmDate (uint8_t day, uint8_t month, uint8_t year, Alarm name=ALARM_A)
 Sets the alarm day; the month and year are ignored.
time_t getEpoch (uint32_t *subSeconds=nullptr)
 Returns the current Unix epoch time.
time_t getY2kEpoch (void)
 Returns the current time as seconds since the Y2K epoch.
void setEpoch (time_t ts, uint32_t subSeconds=0)
 Sets the RTC from a Unix epoch timestamp.
void setY2kEpoch (time_t ts)
 Sets the RTC from seconds since the Y2K epoch.
time_t getAlarmEpoch (Alarm name)
 Returns the configured alarm's epoch timestamp.
time_t getAlarmEpoch (uint32_t *subSeconds=nullptr, Alarm name=ALARM_A)
 Returns the configured alarm's epoch timestamp.
void setAlarmEpoch (time_t ts, Alarm_Match match, Alarm name)
 Configures an alarm from an epoch timestamp.
void setAlarmEpoch (time_t ts, Alarm_Match match=MATCH_DHHMMSS, uint32_t subSeconds=0, Alarm name=ALARM_A)
 Configures an alarm from an epoch timestamp.
bool isConfigured (void)
 Reports whether the RTC peripheral is configured.
bool isFormat_24hour (void)
 Reports whether the current hour format is 24-hour.
bool isAlarmEnabled (Alarm name=ALARM_A)
 Reports whether the selected alarm is enabled.
bool isTimeSet (void)
 Reports whether the library has set the current time.

Static Public Member Functions

static STM32RTC & getInstance ()
 Returns the singleton RTC controller.

Friends

class STM32LowPower

Detailed Description

Controls the RTC peripheral on an STM32 board.

Use getInstance() to access the single library instance.

Member Enumeration Documentation

◆ Alarm

enum STM32RTC::Alarm : uint32_t

Identifies an RTC alarm.

Enumerator
ALARM_A 

◆ Alarm_Match

enum STM32RTC::Alarm_Match : uint8_t

Selects which RTC fields must match for an alarm.

Enumerator
MATCH_OFF 
MATCH_SUBSEC 
MATCH_SS 
MATCH_MMSS 
MATCH_HHMMSS 
MATCH_DHHMMSS 
MATCH_MMDDHHMMSS 
MATCH_YYMMDDHHMMSS 

◆ AM_PM

enum STM32RTC::AM_PM : uint8_t

Selects the AM or PM period in 12-hour format.

Enumerator
AM 
PM 

◆ Binary_Mode

enum STM32RTC::Binary_Mode : uint8_t

Selects BCD, binary, or combined RTC mode.

Enumerator
MODE_BCD 
MODE_BIN 
MODE_MIX 

◆ Hour_Format

enum STM32RTC::Hour_Format : uint8_t

Selects the RTC hour display format.

Enumerator
HOUR_12 
HOUR_24 

◆ Source_Clock

enum STM32RTC::Source_Clock : uint8_t

Selects the input clock source for the RTC.

Enumerator
LSI_CLOCK 
LSE_CLOCK 
HSE_CLOCK 

Constructor & Destructor Documentation

◆ STM32RTC()

STM32RTC::STM32RTC ( STM32RTC const & )
delete

Member Function Documentation

◆ attachInterrupt() [1/2]

void STM32RTC::attachInterrupt ( voidFuncPtrParam callback,
Alarm name )

Attaches a callback to an RTC alarm.

Parameters
callbackFunction called when the alarm fires.
nameAlarm that invokes the callback.

◆ attachInterrupt() [2/2]

void STM32RTC::attachInterrupt ( voidFuncPtrParam callback,
void * data = nullptr,
Alarm name = ALARM_A )

Attaches a callback and user data to an RTC alarm.

Parameters
callbackFunction called when the alarm fires.
dataUser data passed to the callback.
nameAlarm that invokes the callback.

◆ begin() [1/2]

void STM32RTC::begin ( bool resetTime,
Hour_Format format = HOUR_24 )

Initializes the RTC and optionally resets its time.

Parameters
resetTimeSet true to reset the RTC registers.
formatHour format to use.

◆ begin() [2/2]

void STM32RTC::begin ( Hour_Format format = HOUR_24)

Initializes the RTC without resetting its current time.

Parameters
formatHour format to use.

◆ detachInterrupt()

void STM32RTC::detachInterrupt ( Alarm name = ALARM_A)

Detaches the callback from an RTC alarm.

Parameters
nameAlarm whose callback will be detached.

◆ disableAlarm()

void STM32RTC::disableAlarm ( Alarm name = ALARM_A)

Disables an RTC alarm.

Parameters
nameAlarm to disable; defaults to ALARM_A.

◆ enableAlarm()

void STM32RTC::enableAlarm ( Alarm_Match match,
Alarm name = ALARM_A )

Enables an RTC alarm with the requested match fields.

Parameters
matchFields that must match when the alarm fires.
nameAlarm to enable.

◆ end()

void STM32RTC::end ( void )

Deinitializes the RTC and clears registered callbacks.

◆ getAlarmDay()

uint8_t STM32RTC::getAlarmDay ( Alarm name = ALARM_A)

Returns the alarm day of the month.

Parameters
nameAlarm to read.
Returns
Alarm day value.

◆ getAlarmEpoch() [1/2]

time_t STM32RTC::getAlarmEpoch ( Alarm name)

Returns the configured alarm's epoch timestamp.

Parameters
nameAlarm to read.
Returns
Alarm time as an epoch timestamp.

◆ getAlarmEpoch() [2/2]

time_t STM32RTC::getAlarmEpoch ( uint32_t * subSeconds = nullptr,
Alarm name = ALARM_A )

Returns the configured alarm's epoch timestamp.

Parameters
subSecondsOptional pointer receiving the subsecond value in milliseconds.
nameAlarm to read.
Returns
Alarm epoch timestamp.

◆ getAlarmHours() [1/2]

uint8_t STM32RTC::getAlarmHours ( Alarm name)

Returns the alarm hours value.

Parameters
nameAlarm to read.
Returns
Alarm hours value.

◆ getAlarmHours() [2/2]

uint8_t STM32RTC::getAlarmHours ( AM_PM * period = nullptr,
Alarm name = ALARM_A )

Returns the alarm hours value and optionally its AM/PM period.

Parameters
periodOptional pointer receiving AM or PM in 12-hour mode.
nameAlarm to read.
Returns
Alarm hour value.

◆ getAlarmMinutes()

uint8_t STM32RTC::getAlarmMinutes ( Alarm name = ALARM_A)

Returns the alarm minutes value.

Parameters
nameAlarm to read.
Returns
Alarm minutes value.

◆ getAlarmMonth()

uint8_t STM32RTC::getAlarmMonth ( void )

Returns zero; STM32 RTC alarms do not match a month.

Returns
Always zero.

◆ getAlarmSeconds()

uint8_t STM32RTC::getAlarmSeconds ( Alarm name = ALARM_A)

Returns the alarm seconds value.

Parameters
nameAlarm to read.
Returns
Alarm seconds value.

◆ getAlarmSubSeconds()

uint32_t STM32RTC::getAlarmSubSeconds ( Alarm name = ALARM_A)

Returns the alarm subsecond value in milliseconds.

Parameters
nameAlarm to read.
Returns
Alarm subsecond value.

◆ getAlarmYear()

uint8_t STM32RTC::getAlarmYear ( void )

Returns zero; STM32 RTC alarms do not match a year.

Returns
Always zero.

◆ getBinaryMode()

Binary_Mode STM32RTC::getBinaryMode ( void )

Returns the current RTC operating mode.

Returns
The current binary mode.

◆ getClockSource()

Source_Clock STM32RTC::getClockSource ( void )

Returns the selected RTC input clock source.

Returns
The current RTC clock source.

◆ getDate()

void STM32RTC::getDate ( uint8_t * weekDay,
uint8_t * day,
uint8_t * month,
uint8_t * year )

Reads the current date.

Parameters
weekDayOptional pointer receiving the weekday.
dayOptional pointer receiving the day of the month.
monthOptional pointer receiving the month.
yearOptional pointer receiving the year value.

◆ getDay()

uint8_t STM32RTC::getDay ( void )

Returns the current day of the month.

Returns
Day value.

◆ getEpoch()

time_t STM32RTC::getEpoch ( uint32_t * subSeconds = nullptr)

Returns the current Unix epoch time.

Parameters
subSecondsOptional pointer receiving the subsecond value in milliseconds.
Returns
Current epoch time.

◆ getHandle()

RTC_HandleTypeDef * STM32RTC::getHandle ( void )
inline

Returns the STM32 HAL RTC handle.

Returns
Pointer to the RTC handle.

◆ getHours()

uint8_t STM32RTC::getHours ( AM_PM * period = nullptr)

Returns the current hours value.

Parameters
periodOptional pointer receiving AM or PM in 12-hour mode.
Returns
Current hour value.

◆ getInstance()

STM32RTC & STM32RTC::getInstance ( )
inlinestatic

Returns the singleton RTC controller.

Returns
Reference to the library's sole STM32RTC instance.

◆ getMinutes()

uint8_t STM32RTC::getMinutes ( void )

Returns the current minutes value.

Returns
Minutes in the current hour.

◆ getMonth()

uint8_t STM32RTC::getMonth ( void )

Returns the current month.

Returns
Month value.

◆ getPrediv()

void STM32RTC::getPrediv ( uint32_t * predivA,
uint32_t * predivS )

Reads the configured or calculated RTC prescalers.

Parameters
predivAReceives the asynchronous prescaler.
predivSReceives the synchronous prescaler; unused on STM32F1.

◆ getSeconds()

uint8_t STM32RTC::getSeconds ( void )

Returns the current seconds value.

Returns
Seconds in the current minute.

◆ getSubSeconds()

uint32_t STM32RTC::getSubSeconds ( void )

Returns the current subsecond value in milliseconds.

Returns
Current subsecond value.

◆ getTime()

void STM32RTC::getTime ( uint8_t * hours,
uint8_t * minutes,
uint8_t * seconds,
uint32_t * subSeconds,
AM_PM * period = nullptr )

Reads the current time.

Parameters
hoursOptional pointer receiving the hour value.
minutesOptional pointer receiving the minute value.
secondsOptional pointer receiving the second value.
subSecondsOptional pointer receiving the subsecond value in milliseconds.
periodOptional pointer receiving AM or PM in 12-hour mode.

◆ getWeekDay()

uint8_t STM32RTC::getWeekDay ( void )

Returns the current weekday.

Returns
Weekday value.

◆ getY2kEpoch()

time_t STM32RTC::getY2kEpoch ( void )

Returns the current time as seconds since the Y2K epoch.

Returns
Seconds since 2000-01-01 00:00:00.

◆ getYear()

uint8_t STM32RTC::getYear ( void )

Returns the current year value.

Returns
Year value in the range 0-99.

◆ isAlarmEnabled()

bool STM32RTC::isAlarmEnabled ( Alarm name = ALARM_A)

Reports whether the selected alarm is enabled.

Parameters
nameAlarm to check.
Returns
True if the alarm is enabled; otherwise false.

◆ isConfigured()

bool STM32RTC::isConfigured ( void )
inline

Reports whether the RTC peripheral is configured.

Returns
True if the RTC is configured; otherwise false.

◆ isFormat_24hour()

bool STM32RTC::isFormat_24hour ( void )
inline

Reports whether the current hour format is 24-hour.

Returns
True for 24-hour format; otherwise false.

◆ isTimeSet()

bool STM32RTC::isTimeSet ( void )
inline

Reports whether the library has set the current time.

Returns
True if the library has set the time; otherwise false.

◆ operator=()

void STM32RTC::operator= ( STM32RTC const & )
delete

◆ setAlarmDate()

void STM32RTC::setAlarmDate ( uint8_t day,
uint8_t month,
uint8_t year,
Alarm name = ALARM_A )

Sets the alarm day; the month and year are ignored.

Parameters
dayDay value in the range 1-31.
monthIgnored.
yearIgnored.
nameAlarm to configure.

◆ setAlarmDay()

void STM32RTC::setAlarmDay ( uint8_t day,
Alarm name = ALARM_A )

Sets the alarm day of the month.

Parameters
dayDay value in the range 1-31.
nameAlarm to configure.

◆ setAlarmEpoch() [1/2]

void STM32RTC::setAlarmEpoch ( time_t ts,
Alarm_Match match,
Alarm name )

Configures an alarm from an epoch timestamp.

Parameters
tsEpoch timestamp.
matchFields that must match when the alarm fires.
nameAlarm to configure.

◆ setAlarmEpoch() [2/2]

void STM32RTC::setAlarmEpoch ( time_t ts,
Alarm_Match match = MATCH_DHHMMSS,
uint32_t subSeconds = 0,
Alarm name = ALARM_A )

Configures an alarm from an epoch timestamp.

Parameters
tsEpoch timestamp.
matchFields that must match when the alarm fires.
subSecondsSubsecond value in milliseconds.
nameAlarm to configure.

◆ setAlarmHours() [1/2]

void STM32RTC::setAlarmHours ( uint8_t hours,
Alarm name )

Sets the alarm hours value.

Parameters
hoursHour value.
nameAlarm to configure.

◆ setAlarmHours() [2/2]

void STM32RTC::setAlarmHours ( uint8_t hours,
AM_PM period = AM,
Alarm name = ALARM_A )

Sets the alarm hours value and optional AM/PM period.

Parameters
hoursHour value.
periodAM or PM when using 12-hour format.
nameAlarm to configure.

◆ setAlarmMinutes()

void STM32RTC::setAlarmMinutes ( uint8_t minutes,
Alarm name = ALARM_A )

Sets the alarm minutes value.

Parameters
minutesMinutes value in the range 0-59.
nameAlarm to configure.

◆ setAlarmMonth()

void STM32RTC::setAlarmMonth ( uint8_t month)

Compatibility method; the month is ignored by STM32 RTC alarms.

Parameters
monthIgnored.

◆ setAlarmSeconds()

void STM32RTC::setAlarmSeconds ( uint8_t seconds,
Alarm name = ALARM_A )

Sets the alarm seconds value.

Parameters
secondsSeconds value in the range 0-59.
nameAlarm to configure.

◆ setAlarmSubSeconds()

void STM32RTC::setAlarmSubSeconds ( uint32_t subSeconds,
Alarm name = ALARM_A )

Sets the alarm subsecond value in milliseconds.

Parameters
subSecondsSubsecond value; 0-999 in BCD/MIX mode.
nameAlarm to configure.

◆ setAlarmTime() [1/4]

void STM32RTC::setAlarmTime ( uint32_t subSeconds,
Alarm name = ALARM_A )

Sets an alarm using a subsecond value.

Parameters
subSecondsSubsecond value in milliseconds.
nameAlarm to configure.

◆ setAlarmTime() [2/4]

void STM32RTC::setAlarmTime ( uint8_t hours,
uint8_t minutes,
uint8_t seconds,
Alarm name )

Sets an alarm time without a subsecond value.

Parameters
hoursHour value.
minutesMinute value.
secondsSecond value.
nameAlarm to configure.

◆ setAlarmTime() [3/4]

void STM32RTC::setAlarmTime ( uint8_t hours,
uint8_t minutes,
uint8_t seconds,
uint32_t subSeconds,
Alarm name )

Sets an alarm time and subsecond value.

Parameters
hoursHour value.
minutesMinute value.
secondsSecond value.
subSecondsSubsecond value in milliseconds.
nameAlarm to configure.

◆ setAlarmTime() [4/4]

void STM32RTC::setAlarmTime ( uint8_t hours,
uint8_t minutes,
uint8_t seconds,
uint32_t subSeconds = 0,
AM_PM period = AM,
Alarm name = ALARM_A )

Sets an alarm time.

Parameters
hoursHour value.
minutesMinute value.
secondsSecond value.
subSecondsSubsecond value in milliseconds.
periodAM or PM when using 12-hour format.
nameAlarm to configure.

◆ setAlarmYear()

void STM32RTC::setAlarmYear ( uint8_t year)

Compatibility method; the year is ignored by STM32 RTC alarms.

Parameters
yearIgnored.

◆ setBinaryMode()

void STM32RTC::setBinaryMode ( Binary_Mode mode)

Selects BCD, binary, or mixed RTC operation.

Parameters
modeRequested RTC mode; unsupported modes fall back to BCD.

◆ setClockSource()

void STM32RTC::setClockSource ( Source_Clock source,
uint32_t predivA = (PREDIVA_MAX+1),
uint32_t predivS = (PREDIVS_MAX+1) )

Selects the RTC clock source and its prescalers.

Parameters
sourceRTC input clock source.
predivAAsynchronous prescaler; use PREDIVA_MAX + 1 for automatic calculation.
predivSSynchronous prescaler; use PREDIVS_MAX + 1 for automatic calculation.

Call before begin(). For a 1 Hz calendar clock, the source frequency divided by ((predivA + 1) * (predivS + 1)) must equal 1 Hz.

◆ setDate() [1/2]

void STM32RTC::setDate ( uint8_t day,
uint8_t month,
uint8_t year )

Sets the current date without changing the weekday.

Parameters
dayDay value in the range 1-31.
monthMonth value in the range 1-12.
yearYear value in the range 0-99.

◆ setDate() [2/2]

void STM32RTC::setDate ( uint8_t weekDay,
uint8_t day,
uint8_t month,
uint8_t year )

Sets the current weekday and date.

Parameters
weekDayWeekday value in the range 1-7 (Monday is 1).
dayDay value in the range 1-31.
monthMonth value in the range 1-12.
yearYear value in the range 0-99.

◆ setDay()

void STM32RTC::setDay ( uint8_t day)

Sets the current day of the month.

Parameters
dayDay value in the range 1-31.

◆ setEpoch()

void STM32RTC::setEpoch ( time_t ts,
uint32_t subSeconds = 0 )

Sets the RTC from a Unix epoch timestamp.

Parameters
tsEpoch timestamp.
subSecondsSubsecond value in milliseconds.

◆ setHours()

void STM32RTC::setHours ( uint8_t hours,
AM_PM period = AM )

Sets the current hour value and optional AM/PM period.

Parameters
hoursHour value.
periodAM or PM when using 12-hour format.

◆ setMinutes()

void STM32RTC::setMinutes ( uint8_t minutes)

Sets the current minutes value.

Parameters
minutesMinutes value in the range 0-59.

◆ setMonth()

void STM32RTC::setMonth ( uint8_t month)

Sets the current month.

Parameters
monthMonth value in the range 1-12.

◆ setPrediv()

void STM32RTC::setPrediv ( uint32_t predivA,
uint32_t predivS )

Sets the RTC prescalers.

Parameters
predivAAsynchronous prescaler.
predivSSynchronous prescaler.

Call before begin().

◆ setSeconds()

void STM32RTC::setSeconds ( uint8_t seconds)

Sets the current seconds value.

Parameters
secondsSeconds value in the range 0-59.

◆ setSubSeconds()

void STM32RTC::setSubSeconds ( uint32_t subSeconds)

Sets the current subsecond value in milliseconds.

Parameters
subSecondsSubsecond value in the range 0-999.

◆ setTime()

void STM32RTC::setTime ( uint8_t hours,
uint8_t minutes,
uint8_t seconds,
uint32_t subSeconds = 1000,
AM_PM period = AM )

Sets the current time.

Parameters
hoursHour value.
minutesMinute value.
secondsSecond value.
subSecondsSubsecond value in milliseconds.
periodAM or PM when using 12-hour format.

◆ setWeekDay()

void STM32RTC::setWeekDay ( uint8_t weekDay)

Sets the current weekday.

Parameters
weekDayWeekday value in the range 1-7 (Monday is 1).

◆ setY2kEpoch()

void STM32RTC::setY2kEpoch ( time_t ts)

Sets the RTC from seconds since the Y2K epoch.

Parameters
tsSeconds since 2000-01-01 00:00:00.

◆ setYear()

void STM32RTC::setYear ( uint8_t year)

Sets the current year value.

Parameters
yearYear value in the range 0-99.

◆ standbyMode()

void STM32RTC::standbyMode ( )

Compatibility method; use the STM32LowPower library for standby mode.

◆ STM32LowPower

friend class STM32LowPower
friend

The documentation for this class was generated from the following file: