From 70757e564d3cf9c371a60ee9e4bdd605d12a4bb6 Mon Sep 17 00:00:00 2001 From: TuxSH Date: Fri, 5 Apr 2019 00:55:13 +0200 Subject: [PATCH] refactor latest commit --- arm9/source/i2c.c | 2 -- arm9/source/utils.c | 12 ++++++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/arm9/source/i2c.c b/arm9/source/i2c.c index 8bbf016..d2d37e8 100644 --- a/arm9/source/i2c.c +++ b/arm9/source/i2c.c @@ -214,10 +214,8 @@ bool I2C_writeRegBuf(I2cDevice devId, u8 regAddr, const u8 *in, u32 size) u8 I2C_readReg(I2cDevice devId, u8 regAddr) { - // note: don't use it in itcm code u8 data; if(!I2C_readRegBuf(devId, regAddr, &data, 1)) return 0xFF; - wait(3); return data; } diff --git a/arm9/source/utils.c b/arm9/source/utils.c index 21dc364..a048348 100644 --- a/arm9/source/utils.c +++ b/arm9/source/utils.c @@ -86,8 +86,16 @@ u32 waitInput(bool isMenu) if(!key) { - if((!(I2C_readReg(I2C_DEV_MCU, 0xF) & 2) && shouldShellShutdown) || - (I2C_readReg(I2C_DEV_MCU, 0x10) & 1) == 1) mcuPowerOff(); + if (shouldShellShutdown) { + u8 shellState = I2C_readReg(I2C_DEV_MCU, 0xF); + wait(3); + if (!(shellState & 2)) mcuPowerOff(); + } + + u8 intstatus = I2C_readReg(I2C_DEV_MCU, 0x10); + wait(3); + if (intstatus & 1) mcuPowerOff(); //Power button pressed + oldKey = 0; dPadDelay = 0; continue;