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

libopencm3 STM32F4xx RTC More...

Collaboration diagram for RTC peripheral API:

Functions

static uint8_t _rtc_dec_to_bcd (uint8_t dec)
 
void rtc_set_prescaler (uint32_t sync, uint32_t async)
 Set RTC prescalars. More...
 
void rtc_wait_for_synchro (void)
 Wait for RTC registers to be synchronised with the APB1 bus. More...
 
void rtc_unlock (void)
 Unlock write access to the RTC registers. More...
 
void rtc_lock (void)
 Lock write access to the RTC registers. More...
 
void rtc_set_wakeup_time (uint16_t wkup_time, uint8_t rtc_cr_wucksel)
 Sets the wakeup time auto-reload value. More...
 
void rtc_clear_wakeup_flag (void)
 Clears the wakeup flag. More...
 
void rtc_set_init_flag (void)
 Sets the initialization flag. More...
 
void rtc_clear_init_flag (void)
 Clears (resets) the initialization flag. More...
 
bool rtc_init_flag_is_ready (void)
 Returns if the RTC_ISR init flag RTC_ISR_INITF is set. More...
 
void rtc_wait_for_init_ready (void)
 Waits infinitely for initialization flag to be set in RTC_ISR. More...
 
void rtc_enable_bypass_shadow_register (void)
 Sets the bypass shadow bit in RTC_CR. More...
 
void rtc_disable_bypass_shadow_register (void)
 Clears the bypass shadow bit in RTC_CR. More...
 
void rtc_set_am_format (void)
 Sets the RTC control register hour format to AM (24h) More...
 
void rtc_set_pm_format (void)
 Sets the RTC control register hour format to PM (12h) More...
 
void rtc_calendar_set_year (uint8_t year)
 Sets the RTC BCD calendar year value. More...
 
void rtc_calendar_set_weekday (enum rtc_weekday rtc_dr_wdu)
 Sets the RTC BCD calendar weekday. More...
 
void rtc_calendar_set_month (uint8_t month)
 Sets the RTC BCD calendar month value. More...
 
void rtc_calendar_set_day (uint8_t day)
 Sets the RTC BCD calendar day value. More...
 
void rtc_calendar_set_date (uint8_t year, uint8_t month, uint8_t day, enum rtc_weekday rtc_dr_wdu)
 Sets the RTC BCD calendar value. More...
 
void rtc_time_set_hour (uint8_t hour, bool use_am_notation)
 Sets the RTC BCD time hour value. More...
 
void rtc_time_set_minute (uint8_t minute)
 Sets the RTC BCD time minute value. More...
 
void rtc_time_set_second (uint8_t second)
 Sets the RTC BCD time second value. More...
 
void rtc_time_set_time (uint8_t hour, uint8_t minute, uint8_t second, bool use_am_notation)
 Sets the RTC BCD time. More...
 
void rtc_enable_wakeup_timer (void)
 Enable the wakeup timer. More...
 
void rtc_disable_wakeup_timer (void)
 Disable the wakeup timer. More...
 
void rtc_enable_wakeup_timer_interrupt (void)
 Enable the wakeup timer interrupt. More...
 
void rtc_disable_wakeup_timer_interrupt (void)
 Disable the wakeup timer interrupt. More...
 

Detailed Description

libopencm3 STM32F4xx RTC

Version
1.0.0
Date
4 March 2013

LGPL License Terms libopencm3 License

Author
© 2012 Karl Palsson karlp.nosp@m.@twe.nosp@m.ak.ne.nosp@m.t.au

Function Documentation

◆ _rtc_dec_to_bcd()

static uint8_t _rtc_dec_to_bcd ( uint8_t  dec)
static

Definition at line 31 of file rtc_common_l1f024.c.

Referenced by rtc_calendar_set_day(), rtc_calendar_set_month(), rtc_calendar_set_year(), rtc_time_set_hour(), rtc_time_set_minute(), and rtc_time_set_second().

Here is the caller graph for this function:

◆ rtc_calendar_set_date()

void rtc_calendar_set_date ( uint8_t  year,
uint8_t  month,
uint8_t  day,
enum rtc_weekday  rtc_dr_wdu 
)

Sets the RTC BCD calendar value.

Requires unlocking the RTC write-protection (RTC_WPR)

The year value should only be the abbreviated year tens, meaning if 2021 is desired pass in only 21.

Definition at line 271 of file rtc_common_l1f024.c.

References rtc_calendar_set_day(), rtc_calendar_set_month(), rtc_calendar_set_weekday(), and rtc_calendar_set_year().

Here is the call graph for this function:

◆ rtc_calendar_set_day()

void rtc_calendar_set_day ( uint8_t  day)

Sets the RTC BCD calendar day value.

Requires unlocking the RTC write-protection (RTC_WPR)

Definition at line 255 of file rtc_common_l1f024.c.

References _rtc_dec_to_bcd(), RTC_DR, RTC_DR_DT_MASK, RTC_DR_DT_SHIFT, RTC_DR_DU_MASK, and RTC_DR_DU_SHIFT.

Referenced by rtc_calendar_set_date().

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

◆ rtc_calendar_set_month()

void rtc_calendar_set_month ( uint8_t  month)

Sets the RTC BCD calendar month value.

Requires unlocking the RTC write-protection (RTC_WPR)

Definition at line 242 of file rtc_common_l1f024.c.

References _rtc_dec_to_bcd(), RTC_DR, RTC_DR_MT_MASK, RTC_DR_MT_SHIFT, RTC_DR_MU_MASK, and RTC_DR_MU_SHIFT.

Referenced by rtc_calendar_set_date().

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

◆ rtc_calendar_set_weekday()

void rtc_calendar_set_weekday ( enum rtc_weekday  rtc_dr_wdu)

Sets the RTC BCD calendar weekday.

Requires unlocking the RTC write-protection (RTC_WPR)

Definition at line 231 of file rtc_common_l1f024.c.

References RTC_DR, RTC_DR_WDU_MASK, and RTC_DR_WDU_SHIFT.

Referenced by rtc_calendar_set_date().

Here is the caller graph for this function:

◆ rtc_calendar_set_year()

void rtc_calendar_set_year ( uint8_t  year)

Sets the RTC BCD calendar year value.

Requires unlocking the RTC write-protection (RTC_WPR)

The year value should only be the abbreviated year tens, meaning if 2021 is desired pass in only 21.

Definition at line 218 of file rtc_common_l1f024.c.

References _rtc_dec_to_bcd(), RTC_DR, RTC_DR_YT_MASK, RTC_DR_YT_SHIFT, RTC_DR_YU_MASK, and RTC_DR_YU_SHIFT.

Referenced by rtc_calendar_set_date().

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

◆ rtc_clear_init_flag()

void rtc_clear_init_flag ( void  )

Clears (resets) the initialization flag.

Requires unlocking backup domain write protection (PWR_CR_DBP)

Definition at line 145 of file rtc_common_l1f024.c.

References RTC_ISR, and RTC_ISR_INIT.

◆ rtc_clear_wakeup_flag()

void rtc_clear_wakeup_flag ( void  )

Clears the wakeup flag.

This function should be called first in the rtc_wkup_isr()

Definition at line 125 of file rtc_common_l1f024.c.

References RTC_ISR, and RTC_ISR_WUTF.

◆ rtc_disable_bypass_shadow_register()

void rtc_disable_bypass_shadow_register ( void  )

Clears the bypass shadow bit in RTC_CR.

Requires unlocking backup domain write protection (PWR_CR_DBP)

Definition at line 185 of file rtc_common_l1f024.c.

References RTC_CR, and RTC_CR_BYPSHAD.

◆ rtc_disable_wakeup_timer()

void rtc_disable_wakeup_timer ( void  )

Disable the wakeup timer.

Warning
You must unlock the registers before using this function

Definition at line 53 of file rtc.c.

References RTC_CR, RTC_CR_WUTE, and rtc_disable_wakeup_timer_interrupt().

Here is the call graph for this function:

◆ rtc_disable_wakeup_timer_interrupt()

void rtc_disable_wakeup_timer_interrupt ( void  )

Disable the wakeup timer interrupt.

Warning
You must unlock the registers before using this function

Definition at line 88 of file rtc.c.

References EXTI22, exti_disable_request(), nvic_disable_irq(), NVIC_RTC_WKUP_IRQ, RTC_CR, and RTC_CR_WUTIE.

Referenced by rtc_disable_wakeup_timer().

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

◆ rtc_enable_bypass_shadow_register()

void rtc_enable_bypass_shadow_register ( void  )

Sets the bypass shadow bit in RTC_CR.

Requires unlocking backup domain write protection (PWR_CR_DBP)

Definition at line 175 of file rtc_common_l1f024.c.

References RTC_CR, and RTC_CR_BYPSHAD.

◆ rtc_enable_wakeup_timer()

void rtc_enable_wakeup_timer ( void  )

Enable the wakeup timer.

Warning
You must unlock the registers before using this function

Definition at line 42 of file rtc.c.

References RTC_CR, RTC_CR_OSEL_SHIFT, RTC_CR_OSEL_WAKEUP, RTC_CR_WUTE, and rtc_enable_wakeup_timer_interrupt().

Here is the call graph for this function:

◆ rtc_enable_wakeup_timer_interrupt()

void rtc_enable_wakeup_timer_interrupt ( void  )

Enable the wakeup timer interrupt.

Warning
You must unlock the registers before using this function

Definition at line 64 of file rtc.c.

References EXTI22, exti_enable_request(), exti_set_trigger(), EXTI_TRIGGER_RISING, nvic_enable_irq(), NVIC_RTC_WKUP_IRQ, nvic_set_priority(), RTC_CR, and RTC_CR_WUTIE.

Referenced by rtc_enable_wakeup_timer().

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

◆ rtc_init_flag_is_ready()

bool rtc_init_flag_is_ready ( void  )

Returns if the RTC_ISR init flag RTC_ISR_INITF is set.

Requires unlocking backup domain write protection (PWR_CR_DBP)

Definition at line 155 of file rtc_common_l1f024.c.

References RTC_ISR, and RTC_ISR_INITF.

Referenced by rtc_wait_for_init_ready().

Here is the caller graph for this function:

◆ rtc_lock()

void rtc_lock ( void  )

Lock write access to the RTC registers.

Definition at line 86 of file rtc_common_l1f024.c.

References RTC_WPR.

◆ rtc_set_am_format()

void rtc_set_am_format ( void  )

Sets the RTC control register hour format to AM (24h)

Requires unlocking backup domain write protection (PWR_CR_DBP)

Definition at line 195 of file rtc_common_l1f024.c.

References RTC_CR, and RTC_CR_FMT.

◆ rtc_set_init_flag()

void rtc_set_init_flag ( void  )

Sets the initialization flag.

Requires unlocking backup domain write protection (PWR_CR_DBP)

Definition at line 135 of file rtc_common_l1f024.c.

References RTC_ISR, and RTC_ISR_INIT.

◆ rtc_set_pm_format()

void rtc_set_pm_format ( void  )

Sets the RTC control register hour format to PM (12h)

Requires unlocking backup domain write protection (PWR_CR_DBP)

Definition at line 205 of file rtc_common_l1f024.c.

References RTC_CR, and RTC_CR_FMT.

◆ rtc_set_prescaler()

void rtc_set_prescaler ( uint32_t  sync,
uint32_t  async 
)

Set RTC prescalars.

This sets the RTC synchronous and asynchronous prescalars.

Definition at line 42 of file rtc_common_l1f024.c.

References RTC_PRER, RTC_PRER_PREDIV_A_SHIFT, and RTC_PRER_PREDIV_S_MASK.

◆ rtc_set_wakeup_time()

void rtc_set_wakeup_time ( uint16_t  wkup_time,
uint8_t  rtc_cr_wucksel 
)

Sets the wakeup time auto-reload value.

Definition at line 95 of file rtc_common_l1f024.c.

References RTC_CR, RTC_CR_WUCLKSEL_MASK, RTC_CR_WUCLKSEL_SHIFT, RTC_CR_WUTE, RTC_ISR, RTC_ISR_WUTWF, and RTC_WUTR.

◆ rtc_time_set_hour()

void rtc_time_set_hour ( uint8_t  hour,
bool  use_am_notation 
)

Sets the RTC BCD time hour value.

Requires unlocking the RTC write-protection (RTC_WPR)

Pass true to use_am_notation to use 24-hour input time; pass false to use_am_notation to use 12-hour (AM/PM) input time

Definition at line 287 of file rtc_common_l1f024.c.

References _rtc_dec_to_bcd(), RTC_TR, RTC_TR_HT_MASK, RTC_TR_HT_SHIFT, RTC_TR_HU_MASK, RTC_TR_HU_SHIFT, and RTC_TR_PM.

Referenced by rtc_time_set_time().

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

◆ rtc_time_set_minute()

void rtc_time_set_minute ( uint8_t  minute)

Sets the RTC BCD time minute value.

Requires unlocking the RTC write-protection (RTC_WPR)

Definition at line 306 of file rtc_common_l1f024.c.

References _rtc_dec_to_bcd(), RTC_TR, RTC_TR_MNT_MASK, RTC_TR_MNT_SHIFT, RTC_TR_MNU_MASK, and RTC_TR_MNU_SHIFT.

Referenced by rtc_time_set_time().

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

◆ rtc_time_set_second()

void rtc_time_set_second ( uint8_t  second)

Sets the RTC BCD time second value.

Requires unlocking the RTC write-protection (RTC_WPR)

Definition at line 319 of file rtc_common_l1f024.c.

References _rtc_dec_to_bcd(), RTC_TR, RTC_TR_ST_MASK, RTC_TR_ST_SHIFT, RTC_TR_SU_MASK, and RTC_TR_SU_SHIFT.

Referenced by rtc_time_set_time().

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

◆ rtc_time_set_time()

void rtc_time_set_time ( uint8_t  hour,
uint8_t  minute,
uint8_t  second,
bool  use_am_notation 
)

Sets the RTC BCD time.

Requires unlocking the RTC write-protection (RTC_WPR)

Definition at line 332 of file rtc_common_l1f024.c.

References rtc_time_set_hour(), rtc_time_set_minute(), and rtc_time_set_second().

Here is the call graph for this function:

◆ rtc_unlock()

void rtc_unlock ( void  )

Unlock write access to the RTC registers.

Definition at line 76 of file rtc_common_l1f024.c.

References RTC_WPR.

◆ rtc_wait_for_init_ready()

void rtc_wait_for_init_ready ( void  )

Waits infinitely for initialization flag to be set in RTC_ISR.

Requires unlocking backup domain write protection (PWR_CR_DBP)

Definition at line 165 of file rtc_common_l1f024.c.

References rtc_init_flag_is_ready().

Here is the call graph for this function:

◆ rtc_wait_for_synchro()

void rtc_wait_for_synchro ( void  )

Wait for RTC registers to be synchronised with the APB1 bus.

Time and Date are accessed through shadow registers which must be synchronized

Definition at line 58 of file rtc_common_l1f024.c.

References RTC_ISR, RTC_ISR_RSF, and RTC_WPR.