99
1010 See file LICENSE.txt for further informations on licensing terms.
1111
12- Last updated January 3rd , 2017
12+ Last updated January 7th , 2017
1313*/
1414
1515#include " SPIFirmata.h"
@@ -64,6 +64,8 @@ boolean SPIFirmata::handleSysex(byte command, byte argc, byte *argv)
6464 mCsPin = argv[8 ];
6565 pinMode (mCsPin , OUTPUT);
6666 // protect the CS pin
67+ // TODO - decide if this is the best approach. If PIN_MODE_SPI is set, the user cannot
68+ // manually control the CS pin using DIGITAL_MESSAGE.
6769 Firmata.setPinMode (mCsPin , PIN_MODE_SPI);
6870 }
6971 SPISettings settings (clockSpeed, getBitOrder (bitOrder), getDataMode (dataMode));
@@ -78,7 +80,7 @@ boolean SPIFirmata::handleSysex(byte command, byte argc, byte *argv)
7880 byte transferOptions = argv[2 ] & SPI_TRANSFER_OPTS_MASK;
7981 byte numBytes = argv[3 ];
8082
81- boolean csIsActive = false ;
83+ boolean csIsActive = true ;
8284 byte csStartVal = LOW;
8385 byte csEndVal = HIGH;
8486 boolean csStartOnly = false ;
@@ -87,16 +89,17 @@ boolean SPIFirmata::handleSysex(byte command, byte argc, byte *argv)
8789 // boolean csToggle = false;
8890
8991 if (mCsPin >= 0 ) {
90- if (argv[2 ] & SPI_CS_ACTIVE_MASK) {
91- csIsActive = true ;
92+ if (argv[2 ] & SPI_CS_DISABLE_MASK) {
93+ csIsActive = false ;
94+ } else {
9295 if (argv[2 ] & SPI_CS_START_ONLY_MASK) csStartOnly = true ;
9396 if (argv[2 ] & SPI_CS_END_ONLY_MASK) csEndOnly = true ;
94- // TODO - handle csToggle
95- // if (argv[2] & SPI_CS_TOGGLE_MASK) csToggle = true;
96- if (argv[2 ] & SPI_CS_INVERT_VAL_MASK) {
97+ if (argv[2 ] & SPI_CS_ACTIVE_EDGE_MASK) {
9798 csStartVal = HIGH;
9899 csStartVal = LOW;
99100 }
101+ // TODO - handle csToggle
102+ // if (argv[2] & SPI_CS_TOGGLE_MASK) csToggle = true;
100103 }
101104 }
102105
0 commit comments