mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-12-23 21:01:25 +01:00
Update I2CManager.cpp
Rearrange I2C short-circuit check to before I2C is initialised.
This commit is contained in:
parent
3ae1859ec7
commit
471b8ac8e1
@ -72,18 +72,23 @@ static const FSH * guessI2CDeviceType(uint8_t address) {
|
|||||||
void I2CManagerClass::begin(void) {
|
void I2CManagerClass::begin(void) {
|
||||||
if (!_beginCompleted) {
|
if (!_beginCompleted) {
|
||||||
_beginCompleted = true;
|
_beginCompleted = true;
|
||||||
|
|
||||||
|
// Check for short-circuit or floating lines (no pull-up) on I2C before enabling I2C
|
||||||
|
const FSH *message = F("WARNING: Possible short-circuit or inadequate pullup on I2C %S line");
|
||||||
|
pinMode(SDA, INPUT);
|
||||||
|
if (!digitalRead(SDA))
|
||||||
|
DIAG(message, F("SDA"));
|
||||||
|
pinMode(SCL, INPUT);
|
||||||
|
if (!digitalRead(SCL))
|
||||||
|
DIAG(message, F("SCL"));
|
||||||
|
|
||||||
|
// Now initialise I2C
|
||||||
_initialise();
|
_initialise();
|
||||||
|
|
||||||
#if defined(I2C_USE_WIRE)
|
#if defined(I2C_USE_WIRE)
|
||||||
DIAG(F("I2CManager: Using Wire library"));
|
DIAG(F("I2CManager: Using Wire library"));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Check for short-circuits on I2C
|
|
||||||
if (!digitalRead(SDA))
|
|
||||||
DIAG(F("WARNING: Possible short-circuit on I2C SDA line"));
|
|
||||||
if (!digitalRead(SCL))
|
|
||||||
DIAG(F("WARNING: Possible short-circuit on I2C SCL line"));
|
|
||||||
|
|
||||||
// Probe and list devices. Use standard mode
|
// Probe and list devices. Use standard mode
|
||||||
// (clock speed 100kHz) for best device compatibility.
|
// (clock speed 100kHz) for best device compatibility.
|
||||||
_setClock(100000);
|
_setClock(100000);
|
||||||
|
Loading…
Reference in New Issue
Block a user