1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-06-12 01:53:07 +03:00

emulation on host: minor updates (#8454)

* emulation on host: minor fixes
merge MockDigital.cpp and HostWiring.cpp

* emulation: share mockverbose between CI-on-host and emulation

* mock: add missing recently overridden method

* remove extern variable, use weak function
This commit is contained in:
david gauchard
2022-02-20 14:27:52 +01:00
committed by GitHub
parent 7356cd1ef1
commit 15e7d35d6e
7 changed files with 51 additions and 61 deletions

View File

@ -37,6 +37,11 @@
#define VERBOSE(x...) mockverbose(x)
#endif
#define GPIONUM 17
static uint8_t _mode[GPIONUM];
static uint8_t _gpio[GPIONUM];
void pinMode (uint8_t pin, uint8_t mode)
{
#define xxx(mode) case mode: m=STRHELPER(mode); break
@ -53,11 +58,19 @@ void pinMode (uint8_t pin, uint8_t mode)
default: m="(special)";
}
VERBOSE("gpio%d: mode='%s'\n", pin, m);
if (pin < GPIONUM)
{
_mode[pin] = mode;
}
}
void digitalWrite(uint8_t pin, uint8_t val)
{
VERBOSE("digitalWrite(pin=%d val=%d)\n", pin, val);
if (pin < GPIONUM) {
_gpio[pin] = val;
}
}
void analogWrite(uint8_t pin, int val)
@ -80,6 +93,9 @@ int digitalRead(uint8_t pin)
{
VERBOSE("digitalRead(%d)\n", pin);
// pin 0 is most likely a low active input
return pin ? 0 : 1;
if (pin < GPIONUM) {
return _gpio[pin] != 0;
} else {
return 0;
}
}