File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -72,5 +72,6 @@ int common_hal_rtc_get_calibration(void) {
7272}
7373
7474void common_hal_rtc_set_calibration (int calibration ) {
75+ // SNVS has HPCALB_VAL bits for calibration.
7576 mp_raise_NotImplementedError (translate ("RTC calibration is not supported on this board" ));
7677}
Original file line number Diff line number Diff line change @@ -328,7 +328,7 @@ uint32_t *port_heap_get_top(void) {
328328 return & _ld_heap_end ;
329329}
330330
331- // Place the word to save just after our BSS section that gets blanked .
331+ // Place the word into the low power section of the SNVS .
332332void port_set_saved_word (uint32_t value ) {
333333 SNVS -> LPGPR [1 ] = value ;
334334}
@@ -366,8 +366,11 @@ void port_interrupt_after_ticks(uint32_t ticks) {
366366 uint8_t subticks ;
367367 uint64_t current_ticks = port_get_raw_ticks (& subticks );
368368 current_ticks += ticks ;
369- SNVS -> HPTALR = current_ticks << 5 | subticks ;
369+ SNVS -> HPCR &= ~SNVS_HPCR_HPTA_EN_MASK ;
370+ // Wait for the alarm to be disabled.
371+ while ((SNVS -> HPCR & SNVS_HPCR_HPTA_EN_MASK ) != 0 ) {}
370372 SNVS -> HPTAMR = current_ticks >> (32 - 5 );
373+ SNVS -> HPTALR = current_ticks << 5 | subticks ;
371374 SNVS -> HPCR |= SNVS_HPCR_HPTA_EN_MASK ;
372375}
373376
@@ -379,8 +382,10 @@ void port_sleep_until_interrupt(void) {
379382 __set_FPSCR (__get_FPSCR () & ~(0x9f ));
380383 (void ) __get_FPSCR ();
381384 }
382- // Call wait for interrupt ourselves if the SD isn't enabled.
385+ NVIC_ClearPendingIRQ (SNVS_HP_WRAPPER_IRQn );
386+ CLOCK_SetMode (kCLOCK_ModeWait );
383387 __WFI ();
388+ CLOCK_SetMode (kCLOCK_ModeRun );
384389}
385390
386391/**
You can’t perform that action at this time.
0 commit comments