From 3c3fcb29f91f9ba3aecc3e78c25e4fc0267b49d9 Mon Sep 17 00:00:00 2001 From: CTCaer Date: Fri, 31 Mar 2023 09:15:56 +0300 Subject: [PATCH] hekate: clear rtc interrupt and stop alarm Stopping rtc alarm is now done in the function that actually checks it, in order to avoid power offs from HOS if it's fired and user wants to continue booting. Additionally, clear the interrupt which is the actual thing that is checked by HOS. --- bootloader/main.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/bootloader/main.c b/bootloader/main.c index 676e470..5c83fc8 100644 --- a/bootloader/main.c +++ b/bootloader/main.c @@ -87,6 +87,14 @@ void check_power_off_from_hos() { // Power off on alarm wakeup from HOS shutdown. For modchips/dongles. u8 hos_wakeup = i2c_recv_byte(I2C_5, MAX77620_I2C_ADDR, MAX77620_REG_IRQTOP); + + // Clear RTC interrupts. + (void)i2c_recv_byte(I2C_5, MAX77620_RTC_I2C_ADDR, MAX77620_RTC_RTCINT_REG); + + // Stop the alarm, in case we injected and powered off too fast. + max77620_rtc_stop_alarm(); + + // Handle RTC wake up. if (hos_wakeup & MAX77620_IRQ_TOP_RTC_MASK) { if (h_cfg.autohosoff == 1)