Skip to content

Commit 3c5b839

Browse files
author
James Foster
committed
Limit mock to AVR.
1 parent 3f38e9a commit 3c5b839

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

cpp/arduino/Godmode.h

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,6 @@ unsigned long micros();
3030
#define NUM_SERIAL_PORTS 0
3131
#endif
3232

33-
// These definitions allow the following to compile (see issue #193):
34-
// https://github.com/arduino-libraries/Ethernet/blob/master/src/utility/w5100.h:341
35-
// add padding because some boards (__MK20DX128__) offset from the given address
36-
#define MMAP_PORTS_SIZE (MOCK_PINS_COUNT + 256)
37-
#define digitalPinToBitMask(pin) (1)
38-
#define digitalPinToPort(pin) (pin)
39-
#define portOutputRegister(port) (GODMODE()->pMmapPort(port))
40-
4133
class GodmodeState {
4234
private:
4335
struct PortDef {
@@ -51,7 +43,7 @@ class GodmodeState {
5143
uint8_t mode;
5244
};
5345

54-
uint8_t mmapPorts[MMAP_PORTS_SIZE];
46+
uint8_t mmapPorts[MOCK_PINS_COUNT];
5547

5648
static GodmodeState* instance;
5749

@@ -98,7 +90,7 @@ class GodmodeState {
9890
}
9991

10092
void resetMmapPorts() {
101-
for (int i = 0; i < MMAP_PORTS_SIZE; ++i) {
93+
for (int i = 0; i < MOCK_PINS_COUNT; ++i) {
10294
mmapPorts[i] = 1;
10395
}
10496
}
@@ -159,5 +151,16 @@ void detachInterrupt(uint8_t interrupt);
159151
inline void tone(uint8_t _pin, unsigned int frequency, unsigned long duration = 0) {}
160152
inline void noTone(uint8_t _pin) {}
161153

154+
// These definitions allow the following to compile (see issue #193):
155+
// https://github.com/arduino-libraries/Ethernet/blob/master/src/utility/w5100.h:341
156+
// we allow one byte per port which "wastes" 224 bytes, but makes the code easier
157+
#if defined(__AVR__)
158+
#define digitalPinToBitMask(pin) (1)
159+
#define digitalPinToPort(pin) (pin)
160+
#define portOutputRegister(port) (GODMODE()->pMmapPort(port))
161+
#else
162+
// we don't (yet) support other boards
163+
#endif
164+
162165

163166
GodmodeState* GODMODE();

0 commit comments

Comments
 (0)