You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
563 B
29 lines
563 B
#include <libopencm3/cm3/nvic.h>
|
|
#include <libopencm3/stm32/exti.h>
|
|
#include <libopencm3/stm32/rtc.h>
|
|
|
|
void rtc_alarm_isr(void)
|
|
{
|
|
exti_reset_request(EXTI17);
|
|
|
|
if (rtc_check_flag(RTC_ALR)) {
|
|
rtc_clear_flag(RTC_ALR);
|
|
|
|
rtc_set_alarm_time(rtc_get_counter_val() + 10);
|
|
|
|
EXTI_IMR |= EXTI17;
|
|
exti_set_trigger(EXTI17, EXTI_TRIGGER_RISING);
|
|
}
|
|
}
|
|
|
|
int alarm_init(void)
|
|
{
|
|
rtc_enable_alarm();
|
|
rtc_set_alarm_time(rtc_get_counter_val() + 10);
|
|
|
|
nvic_enable_irq(NVIC_RTC_ALARM_IRQ);
|
|
EXTI_IMR |= EXTI17;
|
|
exti_set_trigger(EXTI17, EXTI_TRIGGER_RISING);
|
|
|
|
return 0;
|
|
}
|
|
|