Skip to content

Commit 596ed3b

Browse files
committed
fix #50, reverse byte order in 16 bit API
1 parent f850dc5 commit 596ed3b

File tree

6 files changed

+22
-12
lines changed

6 files changed

+22
-12
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
66
and this project adheres to [Semantic Versioning](http://semver.org/).
77

88

9+
## [0.7.0] - 2025-02-18
10+
- fix #50, breaking change 16 bit API byte order to be intuitive / logic.
11+
- update readme.md
12+
13+
----
14+
915
## [0.6.1] - 2025-01-20
1016
- Sync MCP23017 PR #41 interrupt functions.
1117
- add link to keypad library

MCP23S17.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// FILE: MCP23S17.cpp
33
// AUTHOR: Rob Tillaart
4-
// VERSION: 0.6.1
4+
// VERSION: 0.7.0
55
// PURPOSE: Arduino library for SPI MCP23S17 16 channel port expander
66
// DATE: 2021-12-30
77
// URL: https://github.com/RobTillaart/MCP23S17
@@ -954,17 +954,17 @@ bool MCP23S17::writeReg16(uint8_t reg, uint16_t value)
954954
// _address already shifted
955955
_mySPI->transfer(MCP23S17_WRITE_REG | _address );
956956
_mySPI->transfer(reg);
957-
_mySPI->transfer(value >> 8);
958957
_mySPI->transfer(value & 0xFF);
958+
_mySPI->transfer(value >> 8);
959959
_mySPI->endTransaction();
960960
}
961961
else
962962
{
963963
// _address already shifted
964964
swSPI_transfer(MCP23S17_WRITE_REG | _address );
965965
swSPI_transfer(reg);
966-
swSPI_transfer(value >> 8);
967966
swSPI_transfer(value & 0xFF);
967+
swSPI_transfer(value >> 8);
968968
}
969969
::digitalWrite(_select, HIGH);
970970
return true;
@@ -991,17 +991,17 @@ uint16_t MCP23S17::readReg16(uint8_t reg)
991991
// _address already shifted
992992
_mySPI->transfer(MCP23S17_READ_REG | _address );
993993
_mySPI->transfer(reg);
994-
rv = _mySPI->transfer(0xFF) << 8;
995-
rv += _mySPI->transfer(0xFF);
994+
rv = _mySPI->transfer(0xFF);
995+
rv += _mySPI->transfer(0xFF) << 8;
996996
_mySPI->endTransaction();
997997
}
998998
else
999999
{
10001000
// _address already shifted
10011001
swSPI_transfer(MCP23S17_READ_REG | _address );
10021002
swSPI_transfer(reg);
1003-
rv = swSPI_transfer(0xFF) << 8;
1004-
rv += swSPI_transfer(0xFF);
1003+
rv = swSPI_transfer(0xFF);
1004+
rv += swSPI_transfer(0xFF) << 8;
10051005
}
10061006
::digitalWrite(_select, HIGH);
10071007
return rv;

MCP23S17.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// FILE: MCP23S17.h
44
// AUTHOR: Rob Tillaart
5-
// VERSION: 0.6.1
5+
// VERSION: 0.7.0
66
// PURPOSE: Arduino library for SPI MCP23S17 16 channel port expander
77
// DATE: 2021-12-30
88
// URL: https://github.com/RobTillaart/MCP23S17
@@ -13,7 +13,7 @@
1313
#include "MCP23x17_registers.h"
1414

1515

16-
#define MCP23S17_LIB_VERSION (F("0.6.1"))
16+
#define MCP23S17_LIB_VERSION (F("0.7.0"))
1717

1818
// ERROR CODES
1919
#define MCP23S17_OK 0x00

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,13 @@ Programming Interface is kept the same as much as possible.
2424
The **write1(pin, value)** is optimized.
2525
If a pin is not changed it will not be written again to save time.
2626

27+
### 0.7.0 Breaking change
28+
29+
Fix #50, reverse byte order in 16 bit interface to be intuitive / logic.
30+
2731
### 0.6.0 Breaking change
2832

29-
Fix for #47, bug in enable interrupt handling.
33+
Fix #47, bug in enable interrupt handling.
3034
Pre 0.6.0 versions are obsolete.
3135

3236
### 0.5.0 Breaking change

library.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"type": "git",
1616
"url": "https://github.com/RobTillaart/MCP23S17.git"
1717
},
18-
"version": "0.6.1",
18+
"version": "0.7.0",
1919
"license": "MIT",
2020
"frameworks": "*",
2121
"platforms": "*",

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=MCP23S17
2-
version=0.6.1
2+
version=0.7.0
33
author=Rob Tillaart <[email protected]>
44
maintainer=Rob Tillaart <[email protected]>
55
sentence=Arduino library for SPI MCP23S17 16 channel port expander 16 IO-lines

0 commit comments

Comments
 (0)