Fix alarm so that it is correctly set.
This commit is contained in:
parent
c49d2ea278
commit
a8dfba235c
@ -72,5 +72,6 @@ int common_hal_rtc_get_calibration(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void common_hal_rtc_set_calibration(int calibration) {
|
void common_hal_rtc_set_calibration(int calibration) {
|
||||||
|
// SNVS has HPCALB_VAL bits for calibration.
|
||||||
mp_raise_NotImplementedError(translate("RTC calibration is not supported on this board"));
|
mp_raise_NotImplementedError(translate("RTC calibration is not supported on this board"));
|
||||||
}
|
}
|
||||||
|
@ -328,7 +328,7 @@ uint32_t *port_heap_get_top(void) {
|
|||||||
return &_ld_heap_end;
|
return &_ld_heap_end;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Place the word to save just after our BSS section that gets blanked.
|
// Place the word into the low power section of the SNVS.
|
||||||
void port_set_saved_word(uint32_t value) {
|
void port_set_saved_word(uint32_t value) {
|
||||||
SNVS->LPGPR[1] = value;
|
SNVS->LPGPR[1] = value;
|
||||||
}
|
}
|
||||||
@ -366,8 +366,11 @@ void port_interrupt_after_ticks(uint32_t ticks) {
|
|||||||
uint8_t subticks;
|
uint8_t subticks;
|
||||||
uint64_t current_ticks = port_get_raw_ticks(&subticks);
|
uint64_t current_ticks = port_get_raw_ticks(&subticks);
|
||||||
current_ticks += ticks;
|
current_ticks += ticks;
|
||||||
SNVS->HPTALR = current_ticks << 5 | subticks;
|
SNVS->HPCR &= ~SNVS_HPCR_HPTA_EN_MASK;
|
||||||
|
// Wait for the alarm to be disabled.
|
||||||
|
while ((SNVS->HPCR & SNVS_HPCR_HPTA_EN_MASK) != 0) {}
|
||||||
SNVS->HPTAMR = current_ticks >> (32 - 5);
|
SNVS->HPTAMR = current_ticks >> (32 - 5);
|
||||||
|
SNVS->HPTALR = current_ticks << 5 | subticks;
|
||||||
SNVS->HPCR |= SNVS_HPCR_HPTA_EN_MASK;
|
SNVS->HPCR |= SNVS_HPCR_HPTA_EN_MASK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -379,8 +382,10 @@ void port_sleep_until_interrupt(void) {
|
|||||||
__set_FPSCR(__get_FPSCR() & ~(0x9f));
|
__set_FPSCR(__get_FPSCR() & ~(0x9f));
|
||||||
(void) __get_FPSCR();
|
(void) __get_FPSCR();
|
||||||
}
|
}
|
||||||
// Call wait for interrupt ourselves if the SD isn't enabled.
|
NVIC_ClearPendingIRQ(SNVS_HP_WRAPPER_IRQn);
|
||||||
|
CLOCK_SetMode(kCLOCK_ModeWait);
|
||||||
__WFI();
|
__WFI();
|
||||||
|
CLOCK_SetMode(kCLOCK_ModeRun);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user