/* wait for RTC registers synchronization */
rtc_register_sync_wait();
/* wait until last write operation on RTC registers has finished */
rtc_lwoff_wait();
/* enable the RTC second and alarm interrupt*/
rtc_interrupt_enable(RTC_INT_SECOND);
rtc_interrupt_enable(RTC_INT_ALARM);
/* wait until last write operation on RTC registers has finished */
rtc_lwoff_wait();
/* set RTC prescaler: set RTC period to 1s */
rtc_prescaler_set(32767);
/* wait until last write operation on RTC registers has finished */
rtc_lwoff_wait();
}
/* enable and set EXTI interrupt to the lowest priority */
nvic_irq_enable(RTC_ALARM_IRQn, 2U, 0U);
/* configure EXTI line */
exti_init(EXTI_17, EXTI_INTERRUPT, EXTI_TRIG_FALLING);
exti_interrupt_flag_clear(EXTI_17);