Skip to content

Commit

Permalink
Merge pull request #2 from kmpelectronics/examples-and-descriptions
Browse files Browse the repository at this point in the history
Add register reset() method
  • Loading branch information
kmpelectronics committed May 9, 2021
2 parents 751eec8 + 56074c1 commit 29d5361
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
15 changes: 8 additions & 7 deletions KMP_MCP23S08.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* please support KMP Electronics and open-source hardware by purchasing
* products from KMP Electronics!
*
* Written by Plamen Kovandzhiev for KMP Electronics Ltd.
* Written by Plamen Kovandzhiev for KMP Electronics Ltd. contact@kmpelectronics.eu
* It is licensed under the MIT License, see LICENSE.txt.
*/

Expand Down Expand Up @@ -48,12 +48,6 @@ void KMP_MCP23S08::begin() {

// Start SPI
SPI.begin();

// Reset all registers
writeRegister(IODIR, 0xFF);
for (byte i = IPOL; i <= OLAT; i++) {
writeRegister(i, 0x00);
}
}

bool KMP_MCP23S08::read(byte pin) {
Expand Down Expand Up @@ -151,4 +145,11 @@ void KMP_MCP23S08::beginTransaction() {
void KMP_MCP23S08::endTransaction() {
write(_csPin, HIGH);
SPI.endTransaction();
}

void KMP_MCP23S08::reset() {
writeRegister(IODIR, 0xFF);
for (byte i = IPOL; i <= OLAT; i++) {
writeRegister(i, 0x00);
}
}
5 changes: 5 additions & 0 deletions KMP_MCP23S08.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,11 @@ class KMP_MCP23S08 {
*/
byte getPullup();

/*!
* @brief Reset all registers
*/
void reset();

private:
byte _csPin;
byte _deviceOpcode = 0x40;
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=KMP_MCP23S08
version=1.0.0
version=1.0.1
author=Plamen Kovandzhiev
maintainer=KMP Electronics <contact@kmpelectronics.eu>
sentence=Unified driver for the the MCP23S08 SPI expander
Expand Down

0 comments on commit 29d5361

Please sign in to comment.