Skip to content

Commit 78fc45d

Browse files
authored
Revert "Add SPI mocks"
This reverts commit 937f10a.
1 parent bc82674 commit 78fc45d

File tree

7 files changed

+8
-253
lines changed

7 files changed

+8
-253
lines changed

CHANGELOG.md

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
99
- Explicit checks that the requested test platforms are defined in YML
1010
- Arduino command wrapper can now guess whether a library is installed
1111
- CPP library class now reaches into included Arduino libraries for source files
12-
- SPI mocks
1312

1413
### Changed
1514
- Refactored documentation

REFERENCE.md

-40
Original file line numberDiff line numberDiff line change
@@ -366,43 +366,3 @@ unittest(interrupt_attachment) {
366366
detachInterrupt(7);
367367
assertFalse(state->interrupt[7].attached);
368368
}```
369-
370-
371-
### SPI
372-
373-
These basic mocks of SPI store the values in Strings.
374-
375-
```C++
376-
unittest(spi) {
377-
GodmodeState *state = GODMODE();
378-
379-
// 8-bit
380-
state->reset();
381-
state->spi.dataIn = "LMNO";
382-
uint8_t out8 = SPI.transfer('a');
383-
assertEqual("a", state->spi.dataOut);
384-
assertEqual('L', out8);
385-
assertEqual("MNO", state->spi.dataIn);
386-
387-
// 16-bit
388-
union { uint16_t val; struct { char lsb; char msb; }; } in16, out16;
389-
state->reset();
390-
state->spi.dataIn = "LMNO";
391-
in16.lsb = 'a';
392-
in16.msb = 'b';
393-
out16.val = SPI.transfer16(in16.val);
394-
assertEqual("NO", state->spi.dataIn);
395-
assertEqual('L', out16.lsb);
396-
assertEqual('M', out16.msb);
397-
assertEqual("ab", state->spi.dataOut);
398-
399-
// buffer
400-
state->reset();
401-
state->spi.dataIn = "LMNOP";
402-
char inBuf[6] = "abcde";
403-
SPI.transfer(inBuf, 4);
404-
405-
assertEqual("abcd", state->spi.dataOut);
406-
assertEqual("LMNOe", String(inBuf));
407-
}
408-
```

SampleProjects/TestSomething/test/godmode.cpp

-38
Original file line numberDiff line numberDiff line change
@@ -183,44 +183,6 @@ unittest(interrupt_attachment) {
183183
assertFalse(state->interrupt[0].attached);
184184
}
185185

186-
unittest(spi) {
187-
GodmodeState *state = GODMODE();
188-
state->reset();
189-
assertEqual("", state->spi.dataIn);
190-
assertEqual("", state->spi.dataOut);
191-
192-
// 8-bit
193-
state->reset();
194-
state->spi.dataIn = "LMNO";
195-
uint8_t out8 = SPI.transfer('a');
196-
assertEqual("a", state->spi.dataOut);
197-
assertEqual('L', out8);
198-
assertEqual("MNO", state->spi.dataIn);
199-
200-
// 16-bit
201-
union { uint16_t val; struct { char lsb; char msb; }; } in16, out16;
202-
state->reset();
203-
state->spi.dataIn = "LMNO";
204-
in16.lsb = 'a';
205-
in16.msb = 'b';
206-
out16.val = SPI.transfer16(in16.val);
207-
assertEqual("NO", state->spi.dataIn);
208-
assertEqual('L', out16.lsb);
209-
assertEqual('M', out16.msb);
210-
assertEqual("ab", state->spi.dataOut);
211-
212-
// buffer
213-
state->reset();
214-
state->spi.dataIn = "LMNOP";
215-
char inBuf[6] = "abcde";
216-
SPI.transfer(inBuf, 4);
217-
218-
assertEqual("abcd", state->spi.dataOut);
219-
assertEqual("LMNOe", String(inBuf));
220-
}
221-
222-
223-
224186
#ifdef HAVE_HWSERIAL0
225187

226188
void smartLightswitchSerialHandler(int pin) {

cpp/arduino/Arduino.h

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ Where possible, variable names from the Arduino library are used to avoid confli
1414
#include "Print.h"
1515
#include "Stream.h"
1616
#include "HardwareSerial.h"
17-
#include "SPI.h"
1817

1918
typedef bool boolean;
2019
typedef uint8_t byte;

cpp/arduino/Godmode.cpp

-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#include "Godmode.h"
22
#include "HardwareSerial.h"
3-
#include "SPI.h"
43

54
GodmodeState godmode = GodmodeState();
65

@@ -98,6 +97,3 @@ inline std::ostream& operator << ( std::ostream& out, const PinHistory<T>& ph )
9897
out << ph;
9998
return out;
10099
}
101-
102-
// defined in SPI.h
103-
SPIClass SPI = SPIClass(&godmode.spi.dataIn, &godmode.spi.dataOut);

cpp/arduino/Godmode.h

+8-19
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ class GodmodeState {
5151
PinHistory<int> analogPin[MOCK_PINS_COUNT];
5252
struct PortDef serialPort[NUM_SERIAL_PORTS];
5353
struct InterruptDef interrupt[MOCK_PINS_COUNT]; // not sure how to get actual number
54-
struct PortDef spi;
5554

5655
void resetPins() {
5756
for (int i = 0; i < MOCK_PINS_COUNT; ++i) {
@@ -70,27 +69,10 @@ class GodmodeState {
7069
}
7170
}
7271

73-
void resetPorts() {
74-
for (int i = 0; i < serialPorts(); ++i)
75-
{
76-
serialPort[i].dataIn = "";
77-
serialPort[i].dataOut = "";
78-
serialPort[i].readDelayMicros = 0;
79-
}
80-
}
81-
82-
void resetSPI() {
83-
spi.dataIn = "";
84-
spi.dataOut = "";
85-
spi.readDelayMicros = 0;
86-
}
87-
8872
void reset() {
8973
resetClock();
9074
resetPins();
9175
resetInterrupts();
92-
resetPorts();
93-
resetSPI();
9476
seed = 1;
9577
}
9678

@@ -101,7 +83,14 @@ class GodmodeState {
10183
GodmodeState()
10284
{
10385
reset();
104-
}
86+
for (int i = 0; i < serialPorts(); ++i)
87+
{
88+
serialPort[i].dataIn = "";
89+
serialPort[i].dataOut = "";
90+
serialPort[i].readDelayMicros = 0;
91+
}
92+
}
93+
10594
};
10695

10796
// io pins

cpp/arduino/SPI.h

-150
This file was deleted.

0 commit comments

Comments
 (0)