Skip to content

Commit

Permalink
fix #10 incorrect mask (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
RobTillaart authored Jun 28, 2022
1 parent 4bd2030 commit 1b57ca4
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 11 deletions.
11 changes: 6 additions & 5 deletions MCP23S17.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//
// FILE: MCP23S17.cpp
// AUTHOR: Rob Tillaart
// VERSION: 0.1.3
// VERSION: 0.2.0
// PURPOSE: Arduino library for SPI MCP23S17 16 channel port expander
// DATE: 2021-12-30
// URL: https://github.com/RobTillaart/MCP23S17
Expand All @@ -12,6 +12,7 @@
// 0.1.1 2022-01-10 add 16 bit interface
// 0.1.2 2022-01-12 change the URL for library manager
// 0.1.3 2022-04-13 fix compiling for NANO33 BLE
// 0.2.0 2022-06-28 fix #10 incorrect mask


#include "Arduino.h"
Expand Down Expand Up @@ -499,7 +500,7 @@ bool MCP23S17::getPullup8(uint8_t port, uint8_t &mask)
bool MCP23S17::pinMode16(uint16_t value)
{
writeReg(MCP23S17_DDR_A, value >> 8);
writeReg(MCP23S17_DDR_B, value & 8);
writeReg(MCP23S17_DDR_B, value & 0xFF);
_error = MCP23S17_OK;
return true;
}
Expand All @@ -509,7 +510,7 @@ bool MCP23S17::pinMode16(uint16_t value)
bool MCP23S17::write16(uint16_t value)
{
writeReg(MCP23S17_GPIO_A, value >> 8);
writeReg(MCP23S17_GPIO_B, value & 8);
writeReg(MCP23S17_GPIO_B, value & 0xFF);
_error = MCP23S17_OK;
return true;
}
Expand All @@ -530,7 +531,7 @@ uint16_t MCP23S17::read16()
bool MCP23S17::setPolarity16(uint16_t mask)
{
writeReg(MCP23S17_POL_A, mask >> 8);
writeReg(MCP23S17_POL_B, mask & 8);
writeReg(MCP23S17_POL_B, mask & 0xFF);
if (_error != MCP23S17_OK)
{
return false;
Expand All @@ -557,7 +558,7 @@ bool MCP23S17::getPolarity16(uint16_t &mask)
bool MCP23S17::setPullup16(uint16_t mask)
{
writeReg(MCP23S17_PUR_A, mask >> 8);
writeReg(MCP23S17_PUR_B, mask & 8);
writeReg(MCP23S17_PUR_B, mask & 0xFF);
if (_error != MCP23S17_OK)
{
return false;
Expand Down
4 changes: 2 additions & 2 deletions MCP23S17.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// FILE: MCP23S17.h
// AUTHOR: Rob Tillaart
// VERSION: 0.1.3
// VERSION: 0.2.0
// PURPOSE: Arduino library for SPI MCP23S17 16 channel port expander
// DATE: 2021-12-30
// URL: https://github.com/RobTillaart/MCP23S17
Expand All @@ -12,7 +12,7 @@
#include "SPI.h"


#define MCP23S17_LIB_VERSION (F("0.1.3"))
#define MCP23S17_LIB_VERSION (F("0.2.0"))

#define MCP23S17_OK 0x00
#define MCP23S17_PIN_ERROR 0x81
Expand Down
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,4 @@ See examples.
- **isConnected()** is not really needed
- implement ESP32 specific support - see MCP_ADC.begin()
- replace magic numbers with a defined constant
- fix lint badge.


2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"type": "git",
"url": "https://github.com/RobTillaart/MCP23S17.git"
},
"version": "0.1.3",
"version": "0.2.0",
"license": "MIT",
"frameworks": "arduino",
"platforms": "*",
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=MCP23S17
version=0.1.3
version=0.2.0
author=Rob Tillaart <[email protected]>
maintainer=Rob Tillaart <[email protected]>
sentence=Arduino library for SPI MCP23S17 16 channel port expander 16 IO-lines
Expand Down

0 comments on commit 1b57ca4

Please sign in to comment.