Fix building for BOARD=watch (Fixes #8), enable in CI
This commit is contained in:
@@ -169,6 +169,12 @@ ReturnCode RtcDriver::init_hw()
|
||||
SET(RTC->CR, RTC_CR_WUTIE);
|
||||
NVIC_EnableIRQ(RTC_IRQn);
|
||||
NVIC_SetPriority(RTC_IRQn, 1);
|
||||
|
||||
enable_periodic_alarm();
|
||||
|
||||
// Clear the interrupt in the RTC
|
||||
CLR(RTC->ISR, RTC_ISR_WUTF);
|
||||
|
||||
#elif defined(STM32L4XX)
|
||||
CLR(RTC->ICSR, RTC_ICSR_INIT);
|
||||
|
||||
@@ -179,20 +185,17 @@ ReturnCode RtcDriver::init_hw()
|
||||
SET(RTC->CR, RTC_CR_WUTIE);
|
||||
NVIC_EnableIRQ(RTC_WKUP_IRQn);
|
||||
NVIC_SetPriority(RTC_WKUP_IRQn, 0);
|
||||
#else
|
||||
#error "Unsupported device type"
|
||||
#endif
|
||||
enable_periodic_alarm();
|
||||
|
||||
// Disable the wakeup timer. This can be leftover from an old firmware/reset
|
||||
enable_periodic_alarm();
|
||||
|
||||
// Clear the interrupt in the RTC
|
||||
SET(RTC->SCR, RTC_SCR_CWUTF);
|
||||
// Disable the Wakeup timer (its periodic, but we use it as a
|
||||
// one-shot timer
|
||||
#else
|
||||
#error "Unsupported device type"
|
||||
#endif
|
||||
// Disable the wakeup timer. This can be leftover from an old firmware/reset
|
||||
CLR(RTC->CR, RTC_CR_WUTE);
|
||||
|
||||
|
||||
disable_rtc_write();
|
||||
|
||||
return ReturnCode::OK;
|
||||
@@ -313,7 +316,16 @@ ReturnCode RtcDriver::set_wakeup_in(BSP::time_t wakeup_delay)
|
||||
SET_TO(RTC->WUTR, RTC_WUTR_WUT, delay_cycles - 1);
|
||||
SET_TO(RTC->CR, RTC_CR_WUCKSEL, wucksel << RTC_CR_WUCKSEL_Pos);
|
||||
|
||||
// Clear any pending wakeup flags
|
||||
#if defined(STM32L0XX)
|
||||
CLR(RTC->ISR, RTC_ISR_WUTF);
|
||||
#elif defined(STM32L4XX)
|
||||
SET(RTC->SCR, RTC_SCR_CWUTF);
|
||||
#else
|
||||
#error "Unsupported family"
|
||||
#endif
|
||||
|
||||
// Finally, enable the timer
|
||||
SET(RTC->CR, RTC_CR_WUTE);
|
||||
|
||||
disable_rtc_write();
|
||||
@@ -327,9 +339,18 @@ BSP::time_t RtcDriver::RtcSystemTimer::get_time()
|
||||
uint64_t new_timer_ticks, new_millis;
|
||||
|
||||
enable_rtc_write();
|
||||
RTC->ICSR = ~(RTC_ICSR_INIT | RTC_ICSR_RSF);
|
||||
#if defined(STM32L0XX)
|
||||
CLR(RTC->ISR, RTC_ISR_RSF);
|
||||
disable_rtc_write();
|
||||
while (!(RTC->ISR & RTC_ISR_RSF)) {}
|
||||
#elif defined(STM32L4XX)
|
||||
CLR(RTC->ICSR, RTC_ICSR_RSF);
|
||||
disable_rtc_write();
|
||||
while (!(RTC->ICSR & RTC_ICSR_RSF)) {}
|
||||
#else
|
||||
#error "Unsupported family"
|
||||
#endif
|
||||
|
||||
|
||||
do {
|
||||
__disable_irq();
|
||||
|
||||
Reference in New Issue
Block a user