libopencm3
A free/libre/open-source firmware library for various ARM Cortex-M3 microcontrollers.

Defined Constants and Types for the STM32F1xx Real Time Clock More...

Collaboration diagram for RTC Defines:

Macros

#define RTC_CRH   MMIO32(RTC_BASE + 0x00)
 
#define RTC_CRL   MMIO32(RTC_BASE + 0x04)
 
#define RTC_PRLH   MMIO32(RTC_BASE + 0x08)
 
#define RTC_PRLL   MMIO32(RTC_BASE + 0x0c)
 
#define RTC_DIVH   MMIO32(RTC_BASE + 0x10)
 
#define RTC_DIVL   MMIO32(RTC_BASE + 0x14)
 
#define RTC_CNTH   MMIO32(RTC_BASE + 0x18)
 
#define RTC_CNTL   MMIO32(RTC_BASE + 0x1c)
 
#define RTC_ALRH   MMIO32(RTC_BASE + 0x20)
 
#define RTC_ALRL   MMIO32(RTC_BASE + 0x24)
 
#define RTC_CRH_OWIE   (1 << 2)
 
#define RTC_CRH_ALRIE   (1 << 1)
 
#define RTC_CRH_SECIE   (1 << 0)
 
#define RTC_CRL_RTOFF   (1 << 5)
 
#define RTC_CRL_CNF   (1 << 4)
 
#define RTC_CRL_RSF   (1 << 3)
 
#define RTC_CRL_OWF   (1 << 2)
 
#define RTC_CRL_ALRF   (1 << 1)
 
#define RTC_CRL_SECF   (1 << 0)
 

Enumerations

enum  rtcflag_t { RTC_SEC , RTC_ALR , RTC_OW }
 RTC Interrupt Flags. More...
 

Functions

void rtc_awake_from_off (enum rcc_osc clock_source)
 RTC Set Operational from the Off state. More...
 
void rtc_enter_config_mode (void)
 RTC Enter Configuration Mode. More...
 
void rtc_exit_config_mode (void)
 RTC Leave Configuration Mode. More...
 
void rtc_set_alarm_time (uint32_t alarm_time)
 RTC Set the Alarm Time. More...
 
void rtc_enable_alarm (void)
 RTC Enable the Alarm. More...
 
void rtc_disable_alarm (void)
 RTC Disable the Alarm. More...
 
void rtc_set_prescale_val (uint32_t prescale_val)
 RTC Set the prescaler Value. More...
 
uint32_t rtc_get_counter_val (void)
 RTC return the Counter Value. More...
 
uint32_t rtc_get_prescale_div_val (void)
 RTC return the prescaler Value. More...
 
uint32_t rtc_get_alarm_val (void)
 RTC return the Alarm Value. More...
 
void rtc_set_counter_val (uint32_t counter_val)
 RTC set the Counter. More...
 
void rtc_interrupt_enable (rtcflag_t flag_val)
 RTC Enable Interrupt. More...
 
void rtc_interrupt_disable (rtcflag_t flag_val)
 RTC Disable Interrupt. More...
 
void rtc_clear_flag (rtcflag_t flag_val)
 RTC Clear an Interrupt Flag. More...
 
uint32_t rtc_check_flag (rtcflag_t flag_val)
 RTC Return a Flag Setting. More...
 
void rtc_awake_from_standby (void)
 RTC Start RTC after Standby Mode. More...
 
void rtc_auto_awake (enum rcc_osc clock_source, uint32_t prescale_val)
 RTC Configuration on Wakeup. More...
 

Detailed Description

Defined Constants and Types for the STM32F1xx Real Time Clock

Author
© 2010 Uwe Hermann uwe@h.nosp@m.erma.nosp@m.nn-uw.nosp@m.e.de
Version
1.0.0
Date
4 March 2013

LGPL License Terms libopencm3 License

Macro Definition Documentation

◆ RTC_ALRH

#define RTC_ALRH   MMIO32(RTC_BASE + 0x20)

Definition at line 67 of file f1/rtc.h.

◆ RTC_ALRL

#define RTC_ALRL   MMIO32(RTC_BASE + 0x24)

Definition at line 68 of file f1/rtc.h.

◆ RTC_CNTH

#define RTC_CNTH   MMIO32(RTC_BASE + 0x18)

Definition at line 63 of file f1/rtc.h.

◆ RTC_CNTL

#define RTC_CNTL   MMIO32(RTC_BASE + 0x1c)

Definition at line 64 of file f1/rtc.h.

◆ RTC_CRH

#define RTC_CRH   MMIO32(RTC_BASE + 0x00)

Definition at line 49 of file f1/rtc.h.

◆ RTC_CRH_ALRIE

#define RTC_CRH_ALRIE   (1 << 1)

Definition at line 78 of file f1/rtc.h.

◆ RTC_CRH_OWIE

#define RTC_CRH_OWIE   (1 << 2)

Definition at line 75 of file f1/rtc.h.

◆ RTC_CRH_SECIE

#define RTC_CRH_SECIE   (1 << 0)

Definition at line 81 of file f1/rtc.h.

◆ RTC_CRL

#define RTC_CRL   MMIO32(RTC_BASE + 0x04)

Definition at line 52 of file f1/rtc.h.

◆ RTC_CRL_ALRF

#define RTC_CRL_ALRF   (1 << 1)

Definition at line 100 of file f1/rtc.h.

◆ RTC_CRL_CNF

#define RTC_CRL_CNF   (1 << 4)

Definition at line 91 of file f1/rtc.h.

◆ RTC_CRL_OWF

#define RTC_CRL_OWF   (1 << 2)

Definition at line 97 of file f1/rtc.h.

◆ RTC_CRL_RSF

#define RTC_CRL_RSF   (1 << 3)

Definition at line 94 of file f1/rtc.h.

◆ RTC_CRL_RTOFF

#define RTC_CRL_RTOFF   (1 << 5)

Definition at line 88 of file f1/rtc.h.

◆ RTC_CRL_SECF

#define RTC_CRL_SECF   (1 << 0)

Definition at line 103 of file f1/rtc.h.

◆ RTC_DIVH

#define RTC_DIVH   MMIO32(RTC_BASE + 0x10)

Definition at line 59 of file f1/rtc.h.

◆ RTC_DIVL

#define RTC_DIVL   MMIO32(RTC_BASE + 0x14)

Definition at line 60 of file f1/rtc.h.

◆ RTC_PRLH

#define RTC_PRLH   MMIO32(RTC_BASE + 0x08)

Definition at line 55 of file f1/rtc.h.

◆ RTC_PRLL

#define RTC_PRLL   MMIO32(RTC_BASE + 0x0c)

Definition at line 56 of file f1/rtc.h.

Enumeration Type Documentation

◆ rtcflag_t

enum rtcflag_t

RTC Interrupt Flags.

Enumerator
RTC_SEC 

Counter Second Flag.

RTC_ALR 

Alarm Event Flag.

RTC_OW 

Counter Overflow Flag.

Definition at line 142 of file f1/rtc.h.

Function Documentation

◆ rtc_auto_awake()

void rtc_auto_awake ( enum rcc_osc  clock_source,
uint32_t  prescale_val 
)

RTC Configuration on Wakeup.

Enable the backup domain clocks and write access to the backup domain. If the RTC has not been enabled, set the clock source and prescaler value. The parameters are not used if the RTC has already been enabled.

Parameters
[in]clock_sourcercc_osc. RTC clock source. Only HSE, LSE and LSI are permitted.
[in]prescale_valuint32_t. 20 bit prescale divider.

Definition at line 400 of file rtc.c.

References RCC_BKP, rcc_periph_clock_enable(), RCC_PWR, rcc_rtc_clock_enabled_flag(), rtc_awake_from_off(), rtc_awake_from_standby(), and rtc_set_prescale_val().

Here is the call graph for this function:

◆ rtc_awake_from_off()

void rtc_awake_from_off ( enum rcc_osc  clock_source)

RTC Set Operational from the Off state.

Power up the backup domain clocks, enable write access to the backup domain, select the clock source, clear the RTC registers and enable the RTC.

Parameters
[in]clock_sourcercc_osc. RTC clock source. Only the values HSE, LSE and LSI are permitted.

Definition at line 85 of file rtc.c.

References pwr_disable_backup_domain_write_protect(), RCC_BKP, rcc_enable_rtc_clock(), rcc_periph_clock_enable(), RCC_PWR, rcc_set_rtc_clock_source(), RTC_ALRH, RTC_ALRL, RTC_CNTH, RTC_CNTL, RTC_CRH, RTC_CRL, RTC_CRL_RSF, rtc_enter_config_mode(), rtc_exit_config_mode(), RTC_PRLH, and RTC_PRLL.

Referenced by rtc_auto_awake().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rtc_awake_from_standby()

void rtc_awake_from_standby ( void  )

RTC Start RTC after Standby Mode.

Enable the backup domain clocks, enable write access to the backup domain and the RTC, and synchronise the RTC register access.

Definition at line 368 of file rtc.c.

References pwr_disable_backup_domain_write_protect(), RCC_BKP, rcc_periph_clock_enable(), RCC_PWR, RTC_CRL, RTC_CRL_RSF, and RTC_CRL_RTOFF.

Referenced by rtc_auto_awake().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rtc_check_flag()

uint32_t rtc_check_flag ( rtcflag_t  flag_val)

RTC Return a Flag Setting.

Parameters
[in]flag_valrtcflag_t: The flag to check.
Returns
uint32_t: a nonzero value if the flag is set, zero otherwise.

Definition at line 338 of file rtc.c.

References RTC_ALR, RTC_CRL, RTC_CRL_ALRF, RTC_CRL_OWF, RTC_CRL_SECF, RTC_OW, and RTC_SEC.

◆ rtc_clear_flag()

void rtc_clear_flag ( rtcflag_t  flag_val)

RTC Clear an Interrupt Flag.

Parameters
[in]flag_valrtcflag_t: The flag to clear.

Definition at line 313 of file rtc.c.

References RTC_ALR, RTC_CRL, RTC_OW, and RTC_SEC.

◆ rtc_disable_alarm()

void rtc_disable_alarm ( void  )

RTC Disable the Alarm.

Definition at line 187 of file rtc.c.

References RTC_CRH, rtc_enter_config_mode(), and rtc_exit_config_mode().

Here is the call graph for this function:

◆ rtc_enable_alarm()

void rtc_enable_alarm ( void  )

RTC Enable the Alarm.

Definition at line 175 of file rtc.c.

References RTC_CRH, RTC_CRH_ALRIE, rtc_enter_config_mode(), and rtc_exit_config_mode().

Here is the call graph for this function:

◆ rtc_enter_config_mode()

void rtc_enter_config_mode ( void  )

RTC Enter Configuration Mode.

Prime the RTC for configuration changes by giving access to the prescaler, and counter and alarm registers.

Definition at line 128 of file rtc.c.

References RTC_CRL, RTC_CRL_CNF, and RTC_CRL_RTOFF.

Referenced by rtc_awake_from_off(), rtc_disable_alarm(), rtc_enable_alarm(), rtc_interrupt_disable(), rtc_interrupt_enable(), rtc_set_alarm_time(), rtc_set_counter_val(), and rtc_set_prescale_val().

Here is the caller graph for this function:

◆ rtc_exit_config_mode()

void rtc_exit_config_mode ( void  )

RTC Leave Configuration Mode.

Revert the RTC to operational state.

Definition at line 145 of file rtc.c.

References RTC_CRL, and RTC_CRL_RTOFF.

Referenced by rtc_awake_from_off(), rtc_disable_alarm(), rtc_enable_alarm(), rtc_interrupt_disable(), rtc_interrupt_enable(), rtc_set_alarm_time(), rtc_set_counter_val(), and rtc_set_prescale_val().

Here is the caller graph for this function:

◆ rtc_get_alarm_val()

uint32_t rtc_get_alarm_val ( void  )

RTC return the Alarm Value.

Returns
uint32_t: the 32 bit alarm value.

Definition at line 236 of file rtc.c.

References RTC_ALRH, and RTC_ALRL.

◆ rtc_get_counter_val()

uint32_t rtc_get_counter_val ( void  )

RTC return the Counter Value.

Returns
uint32_t: the 32 bit counter value.

Definition at line 214 of file rtc.c.

References RTC_CNTH, and RTC_CNTL.

◆ rtc_get_prescale_div_val()

uint32_t rtc_get_prescale_div_val ( void  )

RTC return the prescaler Value.

Returns
uint32_t: the 20 bit prescale divider.

Definition at line 225 of file rtc.c.

References RTC_DIVH, and RTC_DIVL.

◆ rtc_interrupt_disable()

void rtc_interrupt_disable ( rtcflag_t  flag_val)

RTC Disable Interrupt.

Parameters
[in]flag_valrtcflag_t: The flag to disable.

Definition at line 287 of file rtc.c.

References RTC_ALR, RTC_CRH, rtc_enter_config_mode(), rtc_exit_config_mode(), RTC_OW, and RTC_SEC.

Here is the call graph for this function:

◆ rtc_interrupt_enable()

void rtc_interrupt_enable ( rtcflag_t  flag_val)

RTC Enable Interrupt.

Parameters
[in]flag_valrtcflag_t: The flag to enable.

Definition at line 261 of file rtc.c.

References RTC_ALR, RTC_CRH, RTC_CRH_ALRIE, RTC_CRH_OWIE, RTC_CRH_SECIE, rtc_enter_config_mode(), rtc_exit_config_mode(), RTC_OW, and RTC_SEC.

Here is the call graph for this function:

◆ rtc_set_alarm_time()

void rtc_set_alarm_time ( uint32_t  alarm_time)

RTC Set the Alarm Time.

Parameters
[in]alarm_timeuint32_t. time at which the alarm event is triggered.

Definition at line 162 of file rtc.c.

References RTC_ALRH, RTC_ALRL, rtc_enter_config_mode(), and rtc_exit_config_mode().

Here is the call graph for this function:

◆ rtc_set_counter_val()

void rtc_set_counter_val ( uint32_t  counter_val)

RTC set the Counter.

Parameters
[in]counter_val32 bit time setting for the counter.

Definition at line 247 of file rtc.c.

References RTC_CNTH, RTC_CNTL, rtc_enter_config_mode(), and rtc_exit_config_mode().

Here is the call graph for this function:

◆ rtc_set_prescale_val()

void rtc_set_prescale_val ( uint32_t  prescale_val)

RTC Set the prescaler Value.

Parameters
[in]prescale_valuint32_t. 20 bit prescale divider.

Definition at line 200 of file rtc.c.

References rtc_enter_config_mode(), rtc_exit_config_mode(), RTC_PRLH, and RTC_PRLL.

Referenced by rtc_auto_awake().

Here is the call graph for this function:
Here is the caller graph for this function: