From 873fb3e35bf3a3eeff04b9b40a3aba1d93433f6f Mon Sep 17 00:00:00 2001 From: sumotoy Date: Tue, 3 Nov 2015 02:10:23 +0100 Subject: [PATCH] DUE compatibility fixed --- max6957.cpp | 6 ++++-- max7301.cpp | 6 ++++-- max7311.cpp | 6 ++++-- max7318.cpp | 6 ++++-- mcp23016.cpp | 6 ++++-- mcp23017.cpp | 6 ++++-- mcp23018.cpp | 6 ++++-- mcp23s17.cpp | 6 ++++-- mcp23s18.cpp | 6 ++++-- pca9555.cpp | 6 ++++-- pca9655.cpp | 6 ++++-- 11 files changed, 44 insertions(+), 22 deletions(-) diff --git a/max6957.cpp b/max6957.cpp index 69d5a38..28c0096 100644 --- a/max6957.cpp +++ b/max6957.cpp @@ -278,8 +278,10 @@ void max6957::writeWord(byte addr, uint16_t data){ #if !defined(__SAM3X8E__) && ((ARDUINO >= 160) || (TEENSYDUINO > 121)) SPI.transfer16(data); #else - SPI.transfer(word2lowByte(data)); - SPI.transfer(word2highByte(data)); + //SPI.transfer(word2lowByte(data)); + //SPI.transfer(word2highByte(data)); + SPI.transfer(data >> 8); + SPI.transfer(data & 0xFF); #endif endSend(); } diff --git a/max7301.cpp b/max7301.cpp index fd949b1..cd1defa 100644 --- a/max7301.cpp +++ b/max7301.cpp @@ -275,8 +275,10 @@ void max7301::writeWord(byte addr, uint16_t data){ #if !defined(__SAM3X8E__) && ((ARDUINO >= 160) || (TEENSYDUINO > 121)) SPI.transfer16(data); #else - SPI.transfer(word2lowByte(data)); - SPI.transfer(word2highByte(data)); + //SPI.transfer(word2lowByte(data)); + //SPI.transfer(word2highByte(data)); + SPI.transfer(data >> 8); + SPI.transfer(data & 0xFF); #endif endSend(); } diff --git a/max7311.cpp b/max7311.cpp index 0deff85..1ad6e8b 100644 --- a/max7311.cpp +++ b/max7311.cpp @@ -177,8 +177,10 @@ void max7311::writeWord(byte addr, uint16_t data){ if (!_error){ Wire.beginTransmission(_adrs); Wire.write(addr);//witch register? - Wire.write(word2lowByte(data)); - Wire.write(word2highByte(data)); + //Wire.write(word2lowByte(data)); + //Wire.write(word2highByte(data)); + Wire.write(data >> 8); + Wire.write(data & 0xFF); Wire.endTransmission(); } } \ No newline at end of file diff --git a/max7318.cpp b/max7318.cpp index 7fe5f66..33ad0e0 100644 --- a/max7318.cpp +++ b/max7318.cpp @@ -174,8 +174,10 @@ void max7318::writeWord(byte addr, uint16_t data){ if (!_error){ Wire.beginTransmission(_adrs); Wire.write(addr);//witch register? - Wire.write(word2lowByte(data)); - Wire.write(word2highByte(data)); + //Wire.write(word2lowByte(data)); + //Wire.write(word2highByte(data)); + Wire.write(data >> 8); + Wire.write(data & 0xFF); Wire.endTransmission(); } } diff --git a/mcp23016.cpp b/mcp23016.cpp index 3de9fc7..1e43f65 100644 --- a/mcp23016.cpp +++ b/mcp23016.cpp @@ -190,8 +190,10 @@ void mcp23016::writeWord(byte addr, uint16_t data){ if (!_error){ Wire.beginTransmission(_adrs); Wire.write(addr); - Wire.write(word2lowByte(data)); - Wire.write(word2highByte(data)); + //Wire.write(word2lowByte(data)); + //Wire.write(word2highByte(data)); + Wire.write(data >> 8); + Wire.write(data & 0xFF); Wire.endTransmission(); } } \ No newline at end of file diff --git a/mcp23017.cpp b/mcp23017.cpp index af1cfc9..fe01f7c 100644 --- a/mcp23017.cpp +++ b/mcp23017.cpp @@ -206,8 +206,10 @@ void mcp23017::writeWord(byte addr, uint16_t data){ if (!_error){ Wire.beginTransmission(_adrs); Wire.write(addr);//witch register? - Wire.write(word2lowByte(data)); - Wire.write(word2highByte(data)); + //Wire.write(word2lowByte(data)); + //Wire.write(word2highByte(data)); + Wire.write(data >> 8); + Wire.write(data & 0xFF); Wire.endTransmission(); } } diff --git a/mcp23018.cpp b/mcp23018.cpp index adf283e..4eeb723 100644 --- a/mcp23018.cpp +++ b/mcp23018.cpp @@ -204,8 +204,10 @@ void mcp23018::writeWord(byte addr, uint16_t data){ if (!_error){ Wire.beginTransmission(_adrs); Wire.write(addr); - Wire.write(word2lowByte(data)); - Wire.write(word2highByte(data)); + //Wire.write(word2lowByte(data)); + //Wire.write(word2highByte(data)); + Wire.write(data >> 8); + Wire.write(data & 0xFF); Wire.endTransmission(); } } \ No newline at end of file diff --git a/mcp23s17.cpp b/mcp23s17.cpp index 14a04f9..ca696c0 100644 --- a/mcp23s17.cpp +++ b/mcp23s17.cpp @@ -277,8 +277,10 @@ void mcp23s17::writeWord(byte addr, uint16_t data){ #if !defined(__SAM3X8E__) && ((ARDUINO >= 160) || (TEENSYDUINO > 121)) SPI.transfer16(data); #else - SPI.transfer(word2lowByte(data)); - SPI.transfer(word2highByte(data)); + //SPI.transfer(word2lowByte(data)); + //SPI.transfer(word2highByte(data)); + SPI.transfer(data >> 8); + SPI.transfer(data & 0xFF); #endif endSend(); } diff --git a/mcp23s18.cpp b/mcp23s18.cpp index 3df04f9..5c35ed7 100644 --- a/mcp23s18.cpp +++ b/mcp23s18.cpp @@ -281,8 +281,10 @@ void mcp23s18::writeByte(byte addr, byte data){ void mcp23s18::writeWord(byte addr, uint16_t data){ startSend(0); SPI.transfer(addr); - SPI.transfer(word2lowByte(data)); - SPI.transfer(word2highByte(data)); + //SPI.transfer(word2lowByte(data)); + //SPI.transfer(word2highByte(data)); + SPI.transfer(data >> 8); + SPI.transfer(data & 0xFF); endSend(); } diff --git a/pca9555.cpp b/pca9555.cpp index d6bb9b9..4b65231 100644 --- a/pca9555.cpp +++ b/pca9555.cpp @@ -176,8 +176,10 @@ void pca9555::writeWord(byte addr, uint16_t data){ if (!_error){ Wire.beginTransmission(_adrs); Wire.write(addr);//witch register? - Wire.write(word2lowByte(data)); - Wire.write(word2highByte(data)); + //Wire.write(word2lowByte(data)); + //Wire.write(word2highByte(data)); + Wire.write(data >> 8); + Wire.write(data & 0xFF); Wire.endTransmission(); } } diff --git a/pca9655.cpp b/pca9655.cpp index d0febb5..56edd1f 100644 --- a/pca9655.cpp +++ b/pca9655.cpp @@ -176,8 +176,10 @@ void pca9655::writeWord(byte addr, uint16_t data){ if (!_error){ Wire.beginTransmission(_adrs); Wire.write(addr);//witch register? - Wire.write(word2lowByte(data)); - Wire.write(word2highByte(data)); + //Wire.write(word2lowByte(data)); + //Wire.write(word2highByte(data)); + Wire.write(data >> 8); + Wire.write(data & 0xFF); Wire.endTransmission(); } }