mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-12-24 13:21:23 +01:00
Change to blocking I2CManager calls
This commit is contained in:
parent
5c120efa16
commit
e48a40fafb
@ -79,7 +79,8 @@ private:
|
|||||||
_digitalOutBuffer[1] = _numDigitalPins;
|
_digitalOutBuffer[1] = _numDigitalPins;
|
||||||
_digitalOutBuffer[2] = _numAnaloguePins;
|
_digitalOutBuffer[2] = _numAnaloguePins;
|
||||||
// Send config, if EXIORDY returned, we're good, otherwise go offline
|
// Send config, if EXIORDY returned, we're good, otherwise go offline
|
||||||
I2CManager.read(_i2cAddress, _digitalInBuffer, 1, _digitalOutBuffer, 3, &_i2crb);
|
// I2CManager.read(_i2cAddress, _digitalInBuffer, 1, _digitalOutBuffer, 3, &_i2crb);
|
||||||
|
I2CManager.read(_i2cAddress, _digitalInBuffer, 1, _digitalOutBuffer, 3);
|
||||||
if (_digitalInBuffer[0] != EXIORDY) {
|
if (_digitalInBuffer[0] != EXIORDY) {
|
||||||
DIAG(F("ERROR configuring EX-IOExpander device, I2C:x%x"), _i2cAddress);
|
DIAG(F("ERROR configuring EX-IOExpander device, I2C:x%x"), _i2cAddress);
|
||||||
_deviceState = DEVSTATE_FAILED;
|
_deviceState = DEVSTATE_FAILED;
|
||||||
@ -88,7 +89,8 @@ private:
|
|||||||
// Attempt to get version, if we don't get it, we don't care, don't go offline
|
// Attempt to get version, if we don't get it, we don't care, don't go offline
|
||||||
// Using digital in buffer in reverse to save RAM
|
// Using digital in buffer in reverse to save RAM
|
||||||
_digitalInBuffer[0] = EXIOVER;
|
_digitalInBuffer[0] = EXIOVER;
|
||||||
I2CManager.read(_i2cAddress, _versionBuffer, 3, _digitalInBuffer, 1, &_i2crb);
|
// I2CManager.read(_i2cAddress, _versionBuffer, 3, _digitalInBuffer, 1, &_i2crb);
|
||||||
|
I2CManager.read(_i2cAddress, _versionBuffer, 3, _digitalInBuffer, 1);
|
||||||
_majorVer = _versionBuffer[0];
|
_majorVer = _versionBuffer[0];
|
||||||
_minorVer = _versionBuffer[1];
|
_minorVer = _versionBuffer[1];
|
||||||
_patchVer = _versionBuffer[2];
|
_patchVer = _versionBuffer[2];
|
||||||
@ -110,7 +112,8 @@ private:
|
|||||||
_digitalOutBuffer[0] = EXIODPUP;
|
_digitalOutBuffer[0] = EXIODPUP;
|
||||||
_digitalOutBuffer[1] = pin;
|
_digitalOutBuffer[1] = pin;
|
||||||
_digitalOutBuffer[2] = pullup;
|
_digitalOutBuffer[2] = pullup;
|
||||||
I2CManager.write(_i2cAddress, _digitalOutBuffer, 3, &_i2crb);
|
// I2CManager.write(_i2cAddress, _digitalOutBuffer, 3, &_i2crb);
|
||||||
|
I2CManager.write(_i2cAddress, _digitalOutBuffer, 3);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -118,7 +121,8 @@ private:
|
|||||||
int pin = vpin - _firstVpin;
|
int pin = vpin - _firstVpin;
|
||||||
_analogueOutBuffer[0] = EXIORDAN;
|
_analogueOutBuffer[0] = EXIORDAN;
|
||||||
_analogueOutBuffer[1] = pin;
|
_analogueOutBuffer[1] = pin;
|
||||||
I2CManager.read(_i2cAddress, _analogueInBuffer, 2, _analogueOutBuffer, 2, &_i2crb);
|
// I2CManager.read(_i2cAddress, _analogueInBuffer, 2, _analogueOutBuffer, 2, &_i2crb);
|
||||||
|
I2CManager.read(_i2cAddress, _analogueInBuffer, 2, _analogueOutBuffer, 2);
|
||||||
return (_analogueInBuffer[1] << 8) + _analogueInBuffer[0];
|
return (_analogueInBuffer[1] << 8) + _analogueInBuffer[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -127,7 +131,8 @@ private:
|
|||||||
_digitalOutBuffer[0] = EXIORDD;
|
_digitalOutBuffer[0] = EXIORDD;
|
||||||
_digitalOutBuffer[1] = pin;
|
_digitalOutBuffer[1] = pin;
|
||||||
_digitalOutBuffer[2] = 0x00; // Don't need to use this for reading
|
_digitalOutBuffer[2] = 0x00; // Don't need to use this for reading
|
||||||
I2CManager.read(_i2cAddress, _digitalInBuffer, 1, _digitalOutBuffer, 3, &_i2crb);
|
// I2CManager.read(_i2cAddress, _digitalInBuffer, 1, _digitalOutBuffer, 3, &_i2crb);
|
||||||
|
I2CManager.read(_i2cAddress, _digitalInBuffer, 1, _digitalOutBuffer, 3);
|
||||||
return _digitalInBuffer[0];
|
return _digitalInBuffer[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -136,7 +141,8 @@ private:
|
|||||||
_digitalOutBuffer[0] = EXIOWRD;
|
_digitalOutBuffer[0] = EXIOWRD;
|
||||||
_digitalOutBuffer[1] = pin;
|
_digitalOutBuffer[1] = pin;
|
||||||
_digitalOutBuffer[2] = value;
|
_digitalOutBuffer[2] = value;
|
||||||
I2CManager.write(_i2cAddress, _digitalOutBuffer, 3, &_i2crb);
|
// I2CManager.write(_i2cAddress, _digitalOutBuffer, 3, &_i2crb);
|
||||||
|
I2CManager.write(_i2cAddress, _digitalOutBuffer, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _display() override {
|
void _display() override {
|
||||||
@ -168,7 +174,7 @@ private:
|
|||||||
uint8_t _majorVer = 0;
|
uint8_t _majorVer = 0;
|
||||||
uint8_t _minorVer = 0;
|
uint8_t _minorVer = 0;
|
||||||
uint8_t _patchVer = 0;
|
uint8_t _patchVer = 0;
|
||||||
I2CRB _i2crb;
|
// I2CRB _i2crb;
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
EXIOINIT = 0xE0, // Flag to initialise setup procedure
|
EXIOINIT = 0xE0, // Flag to initialise setup procedure
|
||||||
|
Loading…
Reference in New Issue
Block a user