Skip to content

Commit 16e43c0

Browse files
authored
Revert "Mock attachInterrupt and detachInterrupt"
This reverts commit c22862c.
1 parent 78fc45d commit 16e43c0

File tree

6 files changed

+3
-52
lines changed

6 files changed

+3
-52
lines changed

CHANGELOG.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1313
### Changed
1414
- Refactored documentation
1515
- External libraries aren't forcibly installed via the Arduino binary (in `arduino_cmd_remote.rb`) if they appear to exist on disk already
16-
- `attachInterrupt` and `detachInterrupt` are now mocked instead of `_NOP`
1716

1817
### Deprecated
1918

REFERENCE.md

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -351,18 +351,3 @@ unittest(modem_hardware)
351351
Note that instead of setting `mLast = output` in the `onMatchInput()` function for test purposes, we could just as easily queue some bytes to state->serialPort[0].dataIn for the library under test to find on its next `peek()` or `read()`. Or we could execute some action on a digital or analog input pin; the possibilities are fairly endless in this regard, although you will have to define them yourself -- from scratch -- extending the `DataStreamObserver` class to emulate your physical device.
352352

353353

354-
### Interrupts
355-
356-
Although ISRs should be tested directly (as their asynchronous nature is not mocked), the act of attaching or detaching an interrupt can be measured.
357-
358-
```C++
359-
unittest(interrupt_attachment) {
360-
GodmodeState *state = GODMODE();
361-
state->reset();
362-
assertFalse(state->interrupt[7].attached);
363-
attachInterrupt(7, (void (*)(void))0, 3);
364-
assertTrue(state->interrupt[7].attached);
365-
assertEqual(state->interrupt[7].mode, 3);
366-
detachInterrupt(7);
367-
assertFalse(state->interrupt[7].attached);
368-
}```

SampleProjects/TestSomething/test/godmode.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -172,17 +172,6 @@ unittest(pin_write_history)
172172

173173
}
174174

175-
unittest(interrupt_attachment) {
176-
GodmodeState *state = GODMODE();
177-
state->reset();
178-
assertFalse(state->interrupt[0].attached);
179-
attachInterrupt(0, (void (*)(void))0, 3);
180-
assertTrue(state->interrupt[0].attached);
181-
assertEqual(state->interrupt[0].mode, 3);
182-
detachInterrupt(0);
183-
assertFalse(state->interrupt[0].attached);
184-
}
185-
186175
#ifdef HAVE_HWSERIAL0
187176

188177
void smartLightswitchSerialHandler(int pin) {

cpp/arduino/Arduino.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ typedef uint8_t byte;
4343
#define yield() _NOP()
4444
#define interrupts() _NOP()
4545
#define noInterrupts() _NOP()
46+
#define attachInterrupt(...) _NOP()
47+
#define detachInterrupt(...) _NOP()
48+
4649

4750
// TODO: correctly establish this per-board!
4851
#define F_CPU 1000000UL

cpp/arduino/Godmode.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,16 +67,6 @@ int analogRead(unsigned char pin) {
6767
return godmode->analogPin[pin].retrieve();
6868
}
6969

70-
void attachInterrupt(uint8_t interrupt, void ISR(void), uint8_t mode) {
71-
GodmodeState* godmode = GODMODE();
72-
godmode->interrupt[interrupt].attached = true;
73-
godmode->interrupt[interrupt].mode = mode;
74-
}
75-
76-
void detachInterrupt(uint8_t interrupt) {
77-
GodmodeState* godmode = GODMODE();
78-
godmode->interrupt[interrupt].attached = false;
79-
}
8070

8171
// Serial ports
8272
#if defined(HAVE_HWSERIAL0)

cpp/arduino/Godmode.h

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,13 @@ class GodmodeState {
3838
unsigned long readDelayMicros;
3939
};
4040

41-
struct InterruptDef {
42-
bool attached;
43-
uint8_t mode;
44-
};
45-
4641
public:
4742
unsigned long micros;
4843
unsigned long seed;
4944
// not going to put pinmode here unless its really needed. can't think of why it would be
5045
PinHistory<bool> digitalPin[MOCK_PINS_COUNT];
5146
PinHistory<int> analogPin[MOCK_PINS_COUNT];
5247
struct PortDef serialPort[NUM_SERIAL_PORTS];
53-
struct InterruptDef interrupt[MOCK_PINS_COUNT]; // not sure how to get actual number
5448

5549
void resetPins() {
5650
for (int i = 0; i < MOCK_PINS_COUNT; ++i) {
@@ -63,16 +57,9 @@ class GodmodeState {
6357
micros = 0;
6458
}
6559

66-
void resetInterrupts() {
67-
for (int i = 0; i < MOCK_PINS_COUNT; ++i) {
68-
interrupt[i].attached = false;
69-
}
70-
}
71-
7260
void reset() {
7361
resetClock();
7462
resetPins();
75-
resetInterrupts();
7663
seed = 1;
7764
}
7865

@@ -103,8 +90,6 @@ int analogRead(uint8_t);
10390
void analogWrite(uint8_t, int);
10491
#define analogReadResolution(...) _NOP()
10592
#define analogWriteResolution(...) _NOP()
106-
void attachInterrupt(uint8_t interrupt, void ISR(void), uint8_t mode);
107-
void detachInterrupt(uint8_t interrupt);
10893

10994
// TODO: issue #26 to track the commanded state here
11095
inline void tone(uint8_t _pin, unsigned int frequency, unsigned long duration = 0) {}

0 commit comments

Comments
 (0)