Skip to content

Commit e4f6ac8

Browse files
update pinOptions
1 parent 17cf555 commit e4f6ac8

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

utility/SPIFirmata.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
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

utility/SPIFirmata.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
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
#ifndef SPIFirmata_h
@@ -41,10 +41,10 @@
4141
#define SPI_WRITE_ONLY 0x02
4242

4343
// pinOptions
44-
#define SPI_CS_ACTIVE_MASK 0x04
45-
#define SPI_CS_INVERT_VAL_MASK 0x08
46-
#define SPI_CS_START_ONLY_MASK 0x10
47-
#define SPI_CS_END_ONLY_MASK 0x20
44+
#define SPI_CS_DISABLE_MASK 0x04
45+
#define SPI_CS_START_ONLY_MASK 0x08
46+
#define SPI_CS_END_ONLY_MASK 0x10
47+
#define SPI_CS_ACTIVE_EDGE_MASK 0x20
4848
#define SPI_CS_TOGGLE_MASK 0x40
4949

5050
#define SPI_CHANNEL_MASK 0x03

0 commit comments

Comments
 (0)