Skip to content

Commit

Permalink
Merge pull request #28 from wollewald/wollewald-patch-2
Browse files Browse the repository at this point in the history
Add files via upload - added I2C connection error detection
  • Loading branch information
wollewald authored Dec 24, 2023
2 parents 88fb6b8 + 892db5d commit da78495
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions keywords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ getPort KEYWORD2
getIntCap KEYWORD2
setSPIClockSpeed KEYWORD2
printAllRegisters KEYWORD2
i2cConnectionError KEYWORD2

#######################################
# Constants (LITERAL1)
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=MCP23017_WE
version=1.6.7
version=1.6.8
author=Wolfgang Ewald <wolfgang.ewald@wolles-elektronikkiste.de>
maintainer=Wolfgang Ewald <wolfgang.ewald@wolles-elektronikkiste.de>
sentence=A library for the MCP23017, MCP23S17, MCP23018 and MCP23S18 port expanders.
Expand Down
15 changes: 15 additions & 0 deletions src/MCP23017.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,21 @@ void MCP23017::printBin(uint8_t val){
}
#endif // DEBUG_MCP23017


uint8_t MCP23017::i2cConnectionError(){
uint8_t error = 0;
if(!useSPI){
#ifndef USE_TINY_WIRE_M_
_wire->beginTransmission(I2C_Address);
error = _wire->endTransmission();
#else
TinyWireM.beginTransmission(I2C_Address);
error = TinyWireM.endTransmission();
#endif
}
return error;
}

/* Private Functions */

void MCP23017::setResetPin(uint8_t rp){
Expand Down
1 change: 1 addition & 0 deletions src/MCP23017.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ class MCP23017{
uint8_t getIntCap(mcp_port);
void setSPIClockSpeed(unsigned long clock);
void softReset();
uint8_t i2cConnectionError();
#ifdef DEBUG_MCP23017 // see MCP23017_config.h
void printAllRegisters();
void printBin(uint8_t val);
Expand Down

0 comments on commit da78495

Please sign in to comment.