Skip to content

Commit aae0ce6

Browse files
committed
Fix autoreload and ticks on IMX RT
1 parent a8dfba2 commit aae0ce6

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

  • ports/mimxrt10xx/supervisor

ports/mimxrt10xx/supervisor/port.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
#include "shared-module/gamepadshift/__init__.h"
5454
#endif
5555
#include "shared-module/_pew/PewPew.h"
56+
#include "supervisor/shared/tick.h"
5657

5758
#include "clocks.h"
5859

@@ -243,6 +244,8 @@ __attribute__((used, naked)) void Reset_Handler(void) {
243244
}
244245

245246
safe_mode_t port_init(void) {
247+
CLOCK_SetMode(kCLOCK_ModeRun);
248+
246249
clocks_init();
247250

248251
#if CIRCUITPY_RTC
@@ -350,8 +353,19 @@ uint64_t port_get_raw_ticks(uint8_t* subticks) {
350353
return ticks / 32;
351354
}
352355

356+
void SNVS_HP_WRAPPER_IRQHandler(void) {
357+
if ((SNVS->HPSR & SNVS_HPSR_PI_MASK) != 0) {
358+
supervisor_tick();
359+
SNVS->HPSR = SNVS_HPSR_PI_MASK;
360+
}
361+
if ((SNVS->HPSR & SNVS_HPSR_HPTA_MASK) != 0) {
362+
SNVS->HPSR = SNVS_HPSR_HPTA_MASK;
363+
}
364+
}
365+
353366
// Enable 1/1024 second tick.
354367
void port_enable_tick(void) {
368+
NVIC_EnableIRQ(SNVS_HP_WRAPPER_IRQn);
355369
uint32_t hpcr = SNVS->HPCR;
356370
hpcr &= ~SNVS_HPCR_PI_FREQ_MASK;
357371
SNVS->HPCR = hpcr | SNVS_HPCR_PI_FREQ(5) | SNVS_HPCR_PI_EN_MASK;
@@ -360,6 +374,7 @@ void port_enable_tick(void) {
360374
// Disable 1/1024 second tick.
361375
void port_disable_tick(void) {
362376
SNVS->HPCR &= ~SNVS_HPCR_PI_EN_MASK;
377+
NVIC_DisableIRQ(SNVS_HP_WRAPPER_IRQn);
363378
}
364379

365380
void port_interrupt_after_ticks(uint32_t ticks) {

0 commit comments

Comments
 (0)