libopencm3 STM32F1xx RTC
More...
libopencm3 STM32F1xx RTC
- Author
- © 2010 Uwe Hermann uwe@h.nosp@m.erma.nosp@m.nn-uw.nosp@m.e.de
-
© 2010 Lord James lordj.nosp@m.ames.nosp@m.@y7ma.nosp@m.il.c.nosp@m.om
- Version
- 1.0.0
- Date
- 4 March 2013
The Real Time Clock peripheral consists of a set of 16 bit control, status, prescaler, counter and alarm registers. Before the latter three can be written the RTC must be placed in configuration mode by a call to rtc_enter_config_mode(). The functions below handle this implictly.
The RTC is completely reset by performing a Backup Domain reset. Note that this can affect unrelated user data contained in the Backup Domain registers. Other forms of reset will not affect the RTC registers as they are contained within the backup domain.
The RTC clock source to be used is selected by calling rcc_set_rtc_clock_source().
The LSE clock source normally comes from a 32.768kHz external crystal This clock is in the backup domain and so continues to run when only the V_BAT supply is present. A prescaler value of 7FFF will give a 1 second count quantum.
The LSI clock source is a low accuracy internal clock of about 40kHz frequency, and the HSE clock source is the external high speed clock divided by 128.
Initial configuration of the RTC consists of:
- perform a Backup Domain reset if appropriate;
- select the clock to be used;
- set the prescaler, counter and configuration values;
- enable the RTC.
- Note
- reading the RTC registers may result in a corrupted value being returned in certain cases. Refer to the STM32F1xx Reference Manual.
LGPL License Terms libopencm3 License
◆ rtc_auto_awake()
void rtc_auto_awake |
( |
enum rcc_osc |
clock_source, |
|
|
uint32_t |
prescale_val |
|
) |
| |
◆ 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_source | rcc_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().
◆ rtc_awake_from_standby()
void rtc_awake_from_standby |
( |
void |
| ) |
|
◆ rtc_check_flag()
uint32_t rtc_check_flag |
( |
rtcflag_t |
flag_val | ) |
|
◆ rtc_clear_flag()
◆ rtc_disable_alarm()
void rtc_disable_alarm |
( |
void |
| ) |
|
◆ rtc_enable_alarm()
void rtc_enable_alarm |
( |
void |
| ) |
|
◆ 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().
◆ rtc_exit_config_mode()
void rtc_exit_config_mode |
( |
void |
| ) |
|
◆ 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_interrupt_enable()
void rtc_interrupt_enable |
( |
rtcflag_t |
flag_val | ) |
|
◆ rtc_set_alarm_time()
void rtc_set_alarm_time |
( |
uint32_t |
alarm_time | ) |
|
◆ rtc_set_counter_val()
void rtc_set_counter_val |
( |
uint32_t |
counter_val | ) |
|
◆ rtc_set_prescale_val()
void rtc_set_prescale_val |
( |
uint32_t |
prescale_val | ) |
|