mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-12-25 05:31:24 +01:00
Add extra error checking
This commit is contained in:
parent
754639c7e3
commit
c870940dde
@ -116,8 +116,13 @@ private:
|
|||||||
_digitalOutBuffer[0] = EXIODPUP;
|
_digitalOutBuffer[0] = EXIODPUP;
|
||||||
_digitalOutBuffer[1] = pin;
|
_digitalOutBuffer[1] = pin;
|
||||||
_digitalOutBuffer[2] = pullup;
|
_digitalOutBuffer[2] = pullup;
|
||||||
I2CManager.write(_i2cAddress, _digitalOutBuffer, 3);
|
I2CManager.read(_i2cAddress, _command1Buffer, 1, _digitalOutBuffer, 3);
|
||||||
|
if (_command1Buffer[0] == EXIORDY) {
|
||||||
return true;
|
return true;
|
||||||
|
} else {
|
||||||
|
DIAG(F("Vpin %d cannot be used as a digital input pin"), (int)vpin);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -128,7 +133,13 @@ private:
|
|||||||
int pin = vpin - _firstVpin;
|
int pin = vpin - _firstVpin;
|
||||||
_command2Buffer[0] = EXIOENAN;
|
_command2Buffer[0] = EXIOENAN;
|
||||||
_command2Buffer[1] = pin;
|
_command2Buffer[1] = pin;
|
||||||
I2CManager.write(_i2cAddress, _command2Buffer, 2);
|
I2CManager.read(_i2cAddress, _command1Buffer, 1, _command2Buffer, 2);
|
||||||
|
if (_command1Buffer[0] == EXIORDY) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
DIAG(F("Vpin %d cannot be used as an analogue input pin"), (int)vpin);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -167,7 +178,10 @@ private:
|
|||||||
_digitalOutBuffer[0] = EXIOWRD;
|
_digitalOutBuffer[0] = EXIOWRD;
|
||||||
_digitalOutBuffer[1] = pin;
|
_digitalOutBuffer[1] = pin;
|
||||||
_digitalOutBuffer[2] = value;
|
_digitalOutBuffer[2] = value;
|
||||||
I2CManager.write(_i2cAddress, _digitalOutBuffer, 3);
|
I2CManager.read(_i2cAddress, _command1Buffer, 1, _digitalOutBuffer, 3);
|
||||||
|
if (_command1Buffer[0] != EXIORDY) {
|
||||||
|
DIAG(F("Vpin %d cannot be used as a digital output pin"), (int)vpin);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _writeAnalogue(VPIN vpin, int value, uint8_t param1, uint16_t param2) override {
|
void _writeAnalogue(VPIN vpin, int value, uint8_t param1, uint16_t param2) override {
|
||||||
|
Loading…
Reference in New Issue
Block a user