refactor latest commit

This commit is contained in:
TuxSH 2019-04-05 00:55:13 +02:00
parent af822e5af5
commit 70757e564d
2 changed files with 10 additions and 4 deletions

View File

@ -214,10 +214,8 @@ bool I2C_writeRegBuf(I2cDevice devId, u8 regAddr, const u8 *in, u32 size)
u8 I2C_readReg(I2cDevice devId, u8 regAddr) u8 I2C_readReg(I2cDevice devId, u8 regAddr)
{ {
// note: don't use it in itcm code
u8 data; u8 data;
if(!I2C_readRegBuf(devId, regAddr, &data, 1)) return 0xFF; if(!I2C_readRegBuf(devId, regAddr, &data, 1)) return 0xFF;
wait(3);
return data; return data;
} }

View File

@ -86,8 +86,16 @@ u32 waitInput(bool isMenu)
if(!key) if(!key)
{ {
if((!(I2C_readReg(I2C_DEV_MCU, 0xF) & 2) && shouldShellShutdown) || if (shouldShellShutdown) {
(I2C_readReg(I2C_DEV_MCU, 0x10) & 1) == 1) mcuPowerOff(); 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; oldKey = 0;
dPadDelay = 0; dPadDelay = 0;
continue; continue;