Skip to content

Commit

Permalink
refactor latest commit
Browse files Browse the repository at this point in the history
  • Loading branch information
TuxSH committed Apr 4, 2019
1 parent af822e5 commit 70757e5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 0 additions & 2 deletions arm9/source/i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
12 changes: 10 additions & 2 deletions arm9/source/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 70757e5

Please sign in to comment.