GPS Device
Loading...
Searching...
No Matches
stm32f401re_rtc.h File Reference

STM32F401RE RTC driver public API. More...

#include <stdint.h>
#include "err.h"
Include dependency graph for stm32f401re_rtc.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  TIME_ts
 Holds a time-of-day value (hours, minutes, seconds). More...
struct  CALENDAR_ts
 Holds a calendar date (year, month, day, weekday). More...

Enumerations

enum  WEEK_DAYS_te {
  WEEK_DAYS_MONDAY , WEEK_DAYS_TUESDAY , WEEK_DAYS_WEDNESDAY , WEEK_DAYS_THURSDAY ,
  WEEK_DAYS_FRIDAY , WEEK_DAYS_SATURDAY , WEEK_DAYS_SUNDAY
}
 Day of the week. More...
enum  MONTHS_te {
  MONTHS_JANUARY , MONTHS_FEBRUARY , MONTHS_MARCH , MONTHS_APRIL ,
  MONTHS_MAY , MONTHS_JUNE , MONTHS_JULE , MONTHS_AUGUST ,
  MONTHS_SEPTEMBER , MONTHS_OCTOBER , MONTHS_NOVEMBER , MONTHS_DECEMBER
}
 Month of the year. More...

Functions

ERR_te rtc_init (void)
 Initializes the RTC peripheral.
void rtc_set_calendar (CALENDAR_ts const *date)
 Sets the RTC calendar (date and weekday).
void rtc_set_time (TIME_ts const *time)
 Sets the RTC time (hours, minutes, seconds).
void rtc_get_time (TIME_ts *time)
 Reads the current time from the RTC.

Detailed Description

STM32F401RE RTC driver public API.

Author
github.com/Baksi675

This module provides a driver for the STM32F401RE Real-Time Clock (RTC) peripheral, supporting calendar and time configuration and readback.

The RTC is clocked by the LSE (Low-Speed External, 32.768 kHz) oscillator and is configured with the standard 24-hour format. Prescalers are set to produce a 1 Hz tick (PREDIV_A = 127, PREDIV_S = 255).

A backup register pattern (0xABCD in BKP0R) is used as an initialization sentinel. If the pattern is present on startup, the RTC is assumed to already be configured and rtc_init returns ERR_MODULE_ALREADY_INITIALIZED without overwriting the current time. To force re-initialization, call rcc_reset_bkpd first.

Typical usage:

Version
0.1
Date
2026-01-23

Definition in file stm32f401re_rtc.h.