9
9
10
10
See file LICENSE.txt for further informations on licensing terms.
11
11
12
- Last updated January 3rd , 2017
12
+ Last updated January 7th , 2017
13
13
*/
14
14
15
15
#include " SPIFirmata.h"
@@ -64,6 +64,8 @@ boolean SPIFirmata::handleSysex(byte command, byte argc, byte *argv)
64
64
mCsPin = argv[8 ];
65
65
pinMode (mCsPin , OUTPUT);
66
66
// 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.
67
69
Firmata.setPinMode (mCsPin , PIN_MODE_SPI);
68
70
}
69
71
SPISettings settings (clockSpeed, getBitOrder (bitOrder), getDataMode (dataMode));
@@ -78,7 +80,7 @@ boolean SPIFirmata::handleSysex(byte command, byte argc, byte *argv)
78
80
byte transferOptions = argv[2 ] & SPI_TRANSFER_OPTS_MASK;
79
81
byte numBytes = argv[3 ];
80
82
81
- boolean csIsActive = false ;
83
+ boolean csIsActive = true ;
82
84
byte csStartVal = LOW;
83
85
byte csEndVal = HIGH;
84
86
boolean csStartOnly = false ;
@@ -87,16 +89,17 @@ boolean SPIFirmata::handleSysex(byte command, byte argc, byte *argv)
87
89
// boolean csToggle = false;
88
90
89
91
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 {
92
95
if (argv[2 ] & SPI_CS_START_ONLY_MASK) csStartOnly = true ;
93
96
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) {
97
98
csStartVal = HIGH;
98
99
csStartVal = LOW;
99
100
}
101
+ // TODO - handle csToggle
102
+ // if (argv[2] & SPI_CS_TOGGLE_MASK) csToggle = true;
100
103
}
101
104
}
102
105
0 commit comments