@@ -43,6 +43,8 @@ class GodmodeState {
4343 uint8_t mode;
4444 };
4545
46+ uint8_t mmapPorts[MOCK_PINS_COUNT];
47+
4648 static GodmodeState* instance;
4749
4850 public:
@@ -87,12 +89,19 @@ class GodmodeState {
8789 spi.readDelayMicros = 0 ;
8890 }
8991
92+ void resetMmapPorts () {
93+ for (int i = 0 ; i < MOCK_PINS_COUNT; ++i) {
94+ mmapPorts[i] = 1 ;
95+ }
96+ }
97+
9098 void reset () {
9199 resetClock ();
92100 resetPins ();
93101 resetInterrupts ();
94102 resetPorts ();
95103 resetSPI ();
104+ resetMmapPorts ();
96105 seed = 1 ;
97106 }
98107
@@ -112,6 +121,9 @@ class GodmodeState {
112121 return instance->micros ;
113122 }
114123
124+ uint8_t * pMmapPort (uint8_t port) { return &mmapPorts[port]; }
125+ uint8_t mmapPortValue (uint8_t port) { return mmapPorts[port]; }
126+
115127 // C++ 11, declare as public for better compiler error messages
116128 GodmodeState (GodmodeState const &) = delete;
117129 void operator =(GodmodeState const &) = delete;
@@ -139,5 +151,16 @@ void detachInterrupt(uint8_t interrupt);
139151inline void tone (uint8_t _pin, unsigned int frequency, unsigned long duration = 0 ) {}
140152inline void noTone (uint8_t _pin) {}
141153
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+
142165
143166GodmodeState* GODMODE ();
0 commit comments