diff --git a/cores/esp8266/Arduino.h b/cores/esp8266/Arduino.h index c27259c4a9..ec0d460d8b 100644 --- a/cores/esp8266/Arduino.h +++ b/cores/esp8266/Arduino.h @@ -37,6 +37,7 @@ extern "C" { #include "binary.h" #include "esp8266_peri.h" #include "twi.h" + #include "core_esp8266_features.h" #include "core_esp8266_version.h" @@ -125,15 +126,11 @@ void timer0_isr_init(void); void timer0_attachInterrupt(timercallback userFunc); void timer0_detachInterrupt(void); -// Use stdlib abs() and round() to avoid issues with the C++ libraries #define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt))) #define radians(deg) ((deg)*DEG_TO_RAD) #define degrees(rad) ((rad)*RAD_TO_DEG) #define sq(x) ((x)*(x)) -void ets_intr_lock(); -void ets_intr_unlock(); - #define interrupts() xt_rsil(0) #define noInterrupts() xt_rsil(15) @@ -162,11 +159,12 @@ typedef uint16_t word; typedef bool boolean; typedef uint8_t byte; +void ets_intr_lock(); +void ets_intr_unlock(); + void init(void); void initVariant(void); -int atexit(void (*func)()) __attribute__((weak)); - void pinMode(uint8_t pin, uint8_t mode); void digitalWrite(uint8_t pin, uint8_t val); int digitalRead(uint8_t pin); @@ -212,21 +210,20 @@ void optimistic_yield(uint32_t interval_us); } // extern "C" #endif +// undefine stdlib's definitions when encountered, provide abs that supports floating point for C code +#ifndef __cplusplus +#undef abs +#define abs(x) ({ __typeof__(x) _x = (x); _x > 0 ? _x : -_x; }) +#undef round +#define round(x) ({ __typeof__(x) _x = (x); _x >= 0 ? (long)(_x + 0.5) : (long)(_x - 0.5); }) +#endif // ifndef __cplusplus - +// from this point onward, we need to configure the c++ environment #ifdef __cplusplus #include +#include #include -#include - -#include "WCharacter.h" -#include "WString.h" - -#include "HardwareSerial.h" -#include "Esp.h" -#include "Updater.h" -#include "debug.h" using std::min; using std::max; @@ -234,6 +231,10 @@ using std::round; using std::isinf; using std::isnan; +// Use float-compatible stl abs() and round(), we don't use Arduino macros to avoid issues with the C++ libraries +using std::abs; +using std::round; + #define _min(a,b) ({ decltype(a) _a = (a); decltype(b) _b = (b); _a < _b? _a : _b; }) #define _max(a,b) ({ decltype(a) _a = (a); decltype(b) _b = (b); _a > _b? _a : _b; }) @@ -273,8 +274,19 @@ inline void configTzTime(const char* tz, const char* server1, configTime(tz, server1, server2, server3); } +// Everything we expect to be implicitly loaded for the sketch +#include + +#include "WCharacter.h" +#include "WString.h" + +#include "HardwareSerial.h" +#include "Esp.h" +#include "Updater.h" + #endif // __cplusplus +#include "debug.h" #include "pins_arduino.h" #endif diff --git a/cores/esp8266/Esp.cpp b/cores/esp8266/Esp.cpp index e3dae810aa..60c52e513a 100644 --- a/cores/esp8266/Esp.cpp +++ b/cores/esp8266/Esp.cpp @@ -26,7 +26,9 @@ #include "MD5Builder.h" #include "umm_malloc/umm_malloc.h" #include "cont.h" + #include "coredecls.h" +#include extern "C" { #include "user_interface.h" diff --git a/cores/esp8266/Esp.h b/cores/esp8266/Esp.h index c321db3823..2327cf20dc 100644 --- a/cores/esp8266/Esp.h +++ b/cores/esp8266/Esp.h @@ -22,6 +22,7 @@ #define ESP_H #include +#include "core_esp8266_features.h" #include "spi_vendors.h" /** diff --git a/cores/esp8266/abi.cpp b/cores/esp8266/abi.cpp index aa031e6406..72f3fb0a06 100644 --- a/cores/esp8266/abi.cpp +++ b/cores/esp8266/abi.cpp @@ -18,7 +18,6 @@ #include #include -#include #include #include diff --git a/cores/esp8266/core_esp8266_features.h b/cores/esp8266/core_esp8266_features.h index cc4cd39777..5dea897bc0 100644 --- a/cores/esp8266/core_esp8266_features.h +++ b/cores/esp8266/core_esp8266_features.h @@ -54,6 +54,7 @@ // level 0 will enable ALL interrupts, // #ifndef CORE_MOCK + #define xt_rsil(level) (__extension__({uint32_t state; __asm__ __volatile__("rsil %0," __STRINGIFY(level) : "=a" (state) :: "memory"); state;})) #define xt_wsr_ps(state) __asm__ __volatile__("wsr %0,ps; isync" :: "a" (state) : "memory") @@ -73,6 +74,9 @@ inline uint32_t esp_get_program_counter() { #else // CORE_MOCK +#define xt_rsil(level) (level) +#define xt_wsr_ps(state) do { (void)(state); } while (0) + inline uint32_t esp_get_program_counter() { return 0; } #endif // CORE_MOCK diff --git a/cores/esp8266/esp8266_peri.h b/cores/esp8266/esp8266_peri.h index 1445b22dba..6ed20dfffd 100644 --- a/cores/esp8266/esp8266_peri.h +++ b/cores/esp8266/esp8266_peri.h @@ -21,6 +21,9 @@ #ifndef ESP8266_PERI_H_INCLUDED #define ESP8266_PERI_H_INCLUDED +// we expect mocking framework to provide these +#ifndef CORE_MOCK + #include "c_types.h" #include "esp8266_undocumented.h" @@ -847,4 +850,6 @@ extern volatile uint32_t* const esp8266_gpioToFn[16]; **/ #define RANDOM_REG32 ESP8266_DREG(0x20E44) +#endif // ifndef CORE_MOCK + #endif diff --git a/cores/esp8266/libc_replacements.cpp b/cores/esp8266/libc_replacements.cpp index 0ccf5e04b2..f9aa13d550 100644 --- a/cores/esp8266/libc_replacements.cpp +++ b/cores/esp8266/libc_replacements.cpp @@ -127,6 +127,7 @@ void _exit(int status) { abort(); } +int atexit(void (*func)()) __attribute__((weak)); int atexit(void (*func)()) { (void) func; return 0; diff --git a/cores/esp8266/umm_malloc/umm_malloc_cfg.h b/cores/esp8266/umm_malloc/umm_malloc_cfg.h index d6b7c5987b..2db2444753 100644 --- a/cores/esp8266/umm_malloc/umm_malloc_cfg.h +++ b/cores/esp8266/umm_malloc/umm_malloc_cfg.h @@ -17,9 +17,10 @@ #include #include #include -#include + #include -#include +#include "../debug.h" +#include "../esp8266_undocumented.h" #ifdef __cplusplus extern "C" { diff --git a/tests/device/test_sw_arduino_math_overrides/test_sw_arduino_math_overrides.ino b/tests/device/test_sw_arduino_math_overrides/test_sw_arduino_math_overrides.ino new file mode 100644 index 0000000000..49496ab7a0 --- /dev/null +++ b/tests/device/test_sw_arduino_math_overrides/test_sw_arduino_math_overrides.ino @@ -0,0 +1,86 @@ +/* + Small math example, checking whether we properly integrate with c++ math + + ref: + - https://github.com/esp8266/Arduino/issues/5530 + - https://github.com/espressif/arduino-esp32/pull/2738 + + Released to public domain +*/ + +#include +#include + +BS_ENV_DECLARE(); + +void setup() +{ + Serial.begin(115200); + BS_RUN(Serial); +} + +bool pretest() +{ + return true; +} + +#define TEST_MATH_IS_SAME(OP1, OP2) \ + std::is_same::value + +TEST_CASE("std::abs and abs result is the same", "[arduino-math]") +{ + CHECK(TEST_MATH_IS_SAME(abs(-5), std::abs(-5))); + CHECK(TEST_MATH_IS_SAME(abs(-25.0), std::abs(-25.0))); + CHECK(TEST_MATH_IS_SAME(abs(10.0), std::abs(10.0))); + CHECK(! TEST_MATH_IS_SAME(abs(10.0), std::abs(10))); + CHECK(! TEST_MATH_IS_SAME(abs(-5), std::abs(10.0))); +} + +TEST_CASE("abs works with ints", "[arduino-math]") +{ + int a = -3; + int b = 3; + CHECK(TEST_MATH_IS_SAME(abs(a), a)); + CHECK(TEST_MATH_IS_SAME(abs(b), b)); + CHECK(abs(a) == b); + CHECK(abs(b) == b); +} + +template +bool compare_floats(T a, T b) { + static_assert(std::is_floating_point::value, ""); + return std::fabs(a - b) < std::numeric_limits::epsilon(); +} + +TEST_CASE("abs works with floats", "[arduino-math]") +{ + float a = -3.5; + float b = 3.5; + CHECK(TEST_MATH_IS_SAME(abs(a), a)); + CHECK(TEST_MATH_IS_SAME(abs(b), b)); + CHECK(compare_floats(abs(a), b)); + CHECK(compare_floats(abs(b), b)); +} + +TEST_CASE("round works with ints", "[arduino-math]") +{ + int a = 5; + int b = 10; + CHECK(TEST_MATH_IS_SAME(round(a), std::round(a))); + CHECK(TEST_MATH_IS_SAME(round(b), std::round(b))); + CHECK(compare_floats(round(a), std::round(a))); + CHECK(compare_floats(round(b), std::round(b))); +} + +TEST_CASE("round works with floats", "[arduino-math]") +{ + float a = 2.9; + float b = 3.0; + CHECK(TEST_MATH_IS_SAME(round(a), a)); + CHECK(TEST_MATH_IS_SAME(round(b), b)); + CHECK(compare_floats(round(a), b)); + CHECK(compare_floats(round(b), b)); +} + +void loop(){} + diff --git a/tests/host/Makefile b/tests/host/Makefile index dabab58e7e..5799613a53 100644 --- a/tests/host/Makefile +++ b/tests/host/Makefile @@ -174,6 +174,7 @@ FLAGS += -DHTTPCLIENT_1_1_COMPATIBLE=0 FLAGS += -DLWIP_IPV6=0 FLAGS += -DHOST_MOCK=1 FLAGS += -DNONOSDK221=1 +FLAGS += -DF_CPU=80000000 FLAGS += $(MKFLAGS) FLAGS += -Wimplicit-fallthrough=2 # allow "// fall through" comments to stop spurious warnings FLAGS += $(USERCFLAGS) diff --git a/tests/host/common/Arduino.h b/tests/host/common/Arduino.h deleted file mode 100644 index 8735ecba6c..0000000000 --- a/tests/host/common/Arduino.h +++ /dev/null @@ -1,279 +0,0 @@ -/* - Arduino.h - Main include file for the Arduino SDK - Copyright (c) 2005-2013 Arduino Team. All right reserved. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef Arduino_h -#define Arduino_h - -#define MOCK "(mock) " - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "binary.h" -#include "twi.h" -#include "core_esp8266_features.h" - -#define HIGH 0x1 -#define LOW 0x0 - -#define PWMRANGE 1023 - - //GPIO FUNCTIONS -#define INPUT 0x00 -#define INPUT_PULLUP 0x02 -#define INPUT_PULLDOWN_16 0x04 // PULLDOWN only possible for pin16 -#define OUTPUT 0x01 -#define OUTPUT_OPEN_DRAIN 0x03 -#define WAKEUP_PULLUP 0x05 -#define WAKEUP_PULLDOWN 0x07 -#define SPECIAL 0xF8 //defaults to the usable BUSes uart0rx/tx uart1tx and hspi -#define FUNCTION_0 0x08 -#define FUNCTION_1 0x18 -#define FUNCTION_2 0x28 -#define FUNCTION_3 0x38 -#define FUNCTION_4 0x48 - -#define PI 3.1415926535897932384626433832795 -#define HALF_PI 1.5707963267948966192313216916398 -#define TWO_PI 6.283185307179586476925286766559 -#define DEG_TO_RAD 0.017453292519943295769236907684886 -#define RAD_TO_DEG 57.295779513082320876798154814105 -#define EULER 2.718281828459045235360287471352 - -#define SERIAL 0x0 -#define DISPLAY 0x1 - -#define LSBFIRST 0 -#define MSBFIRST 1 - - //Interrupt Modes -#define DISABLED 0x00 -#define RISING 0x01 -#define FALLING 0x02 -#define CHANGE 0x03 -#define ONLOW 0x04 -#define ONHIGH 0x05 -#define ONLOW_WE 0x0C -#define ONHIGH_WE 0x0D - -#define DEFAULT 1 -#define EXTERNAL 0 - - //timer dividers -#define TIM_DIV1 0 //80MHz (80 ticks/us - 104857.588 us max) -#define TIM_DIV16 1 //5MHz (5 ticks/us - 1677721.4 us max) -#define TIM_DIV265 3 //312.5Khz (1 tick = 3.2us - 26843542.4 us max) - //timer int_types -#define TIM_EDGE 0 -#define TIM_LEVEL 1 - //timer reload values -#define TIM_SINGLE 0 //on interrupt routine you need to write a new value to start the timer again -#define TIM_LOOP 1 //on interrupt the counter will start with the same value again - -#define timer1_read() (T1V) -#define timer1_enabled() ((T1C & (1 << TCTE)) != 0) -#define timer1_interrupted() ((T1C & (1 << TCIS)) != 0) - - typedef void(*timercallback)(void); - - void timer1_isr_init(void); - void timer1_enable(uint8_t divider, uint8_t int_type, uint8_t reload); - void timer1_disable(void); - void timer1_attachInterrupt(timercallback userFunc); - void timer1_detachInterrupt(void); - void timer1_write(uint32_t ticks); //maximum ticks 8388607 - - // timer0 is a special CPU timer that has very high resolution but with - // limited control. - // it uses CCOUNT (ESP.GetCycleCount()) as the non-resetable timer counter - // it does not support divide, type, or reload flags - // it is auto-disabled when the compare value matches CCOUNT - // it is auto-enabled when the compare value changes -#define timer0_interrupted() (ETS_INTR_PENDING() & (_BV(ETS_COMPARE0_INUM))) -#define timer0_read() ((__extension__({uint32_t count;__asm__ __volatile__("esync; rsr %0,ccompare0":"=a" (count));count;}))) -#define timer0_write(count) __asm__ __volatile__("wsr %0,ccompare0; esync"::"a" (count) : "memory") - - void timer0_isr_init(void); - void timer0_attachInterrupt(timercallback userFunc); - void timer0_detachInterrupt(void); - - // undefine stdlib's abs if encountered -#ifdef abs -#undef abs -#endif - -#define abs(x) ((x)>0?(x):-(x)) -#define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt))) -#define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5)) -#define radians(deg) ((deg)*DEG_TO_RAD) -#define degrees(rad) ((rad)*RAD_TO_DEG) -#define sq(x) ((x)*(x)) - - void ets_intr_lock(); - void ets_intr_unlock(); - -#ifndef __STRINGIFY -#define __STRINGIFY(a) #a -#endif - -#define xt_rsil(level) (level) -#define xt_wsr_ps(state) do { (void)(state); } while (0) - -#define interrupts() xt_rsil(0) -#define noInterrupts() xt_rsil(15) - -#define clockCyclesPerMicrosecond() ( F_CPU / 1000000L ) -#define clockCyclesToMicroseconds(a) ( (a) / clockCyclesPerMicrosecond() ) -#define microsecondsToClockCycles(a) ( (a) * clockCyclesPerMicrosecond() ) - -#define lowByte(w) ((uint8_t) ((w) & 0xff)) -#define highByte(w) ((uint8_t) ((w) >> 8)) - -#define bitRead(value, bit) (((value) >> (bit)) & 0x01) -#define bitSet(value, bit) ((value) |= (1UL << (bit))) -#define bitClear(value, bit) ((value) &= ~(1UL << (bit))) -#define bitWrite(value, bit, bitvalue) (bitvalue ? bitSet(value, bit) : bitClear(value, bit)) - - // avr-libc defines _NOP() since 1.6.2 -#ifndef _NOP -#define _NOP() do { __asm__ volatile ("nop"); } while (0) -#endif - - typedef unsigned int word; - -#define bit(b) (1UL << (b)) -#define _BV(b) (1UL << (b)) - - typedef uint8_t boolean; - typedef uint8_t byte; - - void init(void); - void initVariant(void); - - void pinMode(uint8_t pin, uint8_t mode); - void digitalWrite(uint8_t pin, uint8_t val); - int digitalRead(uint8_t pin); - int analogRead(uint8_t pin); - void analogReference(uint8_t mode); - void analogWrite(uint8_t pin, int val); - void analogWriteFreq(uint32_t freq); - void analogWriteRange(uint32_t range); - - unsigned long millis(void); - unsigned long micros(void); - void delay(unsigned long); - void delayMicroseconds(unsigned int us); - unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout); - unsigned long pulseInLong(uint8_t pin, uint8_t state, unsigned long timeout); - - void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t val); - uint8_t shiftIn(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder); - - void attachInterrupt(uint8_t pin, void (*)(void), int mode); - void detachInterrupt(uint8_t pin); - - void setup(void); - void loop(void); - - void yield(void); - void esp_yield(void); - void optimistic_yield(uint32_t interval_us); - -#define digitalPinToPort(pin) (0) -#define digitalPinToBitMask(pin) (1UL << (pin)) -#define digitalPinToTimer(pin) (0) -#define portOutputRegister(port) ((volatile uint32_t*) &GPO) -#define portInputRegister(port) ((volatile uint32_t*) &GPI) -#define portModeRegister(port) ((volatile uint32_t*) &GPE) - -#define NOT_A_PIN -1 -#define NOT_A_PORT -1 -#define NOT_AN_INTERRUPT -1 -#define NOT_ON_TIMER 0 - -#ifdef __cplusplus -} // extern "C" -#endif - -#ifdef __cplusplus - -#include - -#include "WCharacter.h" -#include "WString.h" - -#include "HardwareSerial.h" -#include "Esp.h" -#include "Updater.h" -#include "debug.h" - -#if 0 -#ifndef _GLIBCXX_VECTOR -// arduino is not compatible with std::vector -#define min(a,b) ((a)<(b)?(a):(b)) -#define max(a,b) ((a)>(b)?(a):(b)) -#endif -#endif - -#define _min(a,b) ((a)<(b)?(a):(b)) -#define _max(a,b) ((a)>(b)?(a):(b)) - -uint16_t makeWord(uint16_t w); -uint16_t makeWord(byte h, byte l); - -#define word(...) makeWord(__VA_ARGS__) - -unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout = 1000000L); -unsigned long pulseInLong(uint8_t pin, uint8_t state, unsigned long timeout = 1000000L); - -void tone(uint8_t _pin, unsigned int frequency, unsigned long duration = 0); -void noTone(uint8_t _pin); - -// WMath prototypes -long random(long); -long random(long, long); -void randomSeed(unsigned long); -long map(long, long, long, long, long); - -extern "C" void configTime(long timezone, int daylightOffset_sec, - const char* server1, const char* server2 = nullptr, const char* server3 = nullptr); - -#endif - -#include "pins_arduino.h" - -#endif /* Arduino_h */ - -#if __cplusplus -#include -#include -#define MOCKARGS 1 -extern std::map mockArgs; -#endif diff --git a/tests/host/common/ArduinoMain.cpp b/tests/host/common/ArduinoMain.cpp index 6372359681..a9d8d696f6 100644 --- a/tests/host/common/ArduinoMain.cpp +++ b/tests/host/common/ArduinoMain.cpp @@ -56,8 +56,6 @@ const char* fspath = nullptr; static struct termios initial_settings; -std::map mockArgs; - int mockverbose (const char* fmt, ...) { va_list ap; @@ -137,8 +135,6 @@ void help (const char* argv0, int exitcode) "\t-S - spiffs size in KBytes (default: %zd)\n" "\t-L - littlefs size in KBytes (default: %zd)\n" "\t (spiffs, littlefs: negative value will force mismatched size)\n" - "\t-K - key\n" - "\t-V - value\n" "\tgeneral:\n" "\t-c - ignore CTRL-C (send it via Serial)\n" "\t-f - no throttle (possibly 100%%CPU)\n" @@ -162,8 +158,6 @@ static struct option options[] = { "spiffskb", required_argument, NULL, 'S' }, { "littlefskb", required_argument, NULL, 'L' }, { "portshifter", required_argument, NULL, 's' }, - { "key", required_argument, NULL, 'K' }, - { "value", required_argument, NULL, 'V' }, { "once", no_argument, NULL, '1' }, }; @@ -215,11 +209,10 @@ int main (int argc, char* const argv []) mock_port_shifter = 0; else mock_port_shifter = MOCK_PORT_SHIFTER; - String key; for (;;) { - int n = getopt_long(argc, argv, "hlcfbvTi:S:s:L:P:1K:V:", options, NULL); + int n = getopt_long(argc, argv, "hlcfbvTi:S:s:L:P:1", options, NULL); if (n < 0) break; switch (n) @@ -260,12 +253,6 @@ int main (int argc, char* const argv []) case 'T': serial_timestamp = true; break; - case 'K': - key = optarg; - break; - case 'V': - mockArgs[key] = optarg; - break; case '1': run_once = true; break; diff --git a/tests/host/common/MockTools.cpp b/tests/host/common/MockTools.cpp index a2d72081de..5eb7969de7 100644 --- a/tests/host/common/MockTools.cpp +++ b/tests/host/common/MockTools.cpp @@ -53,16 +53,6 @@ int ets_printf (const char* fmt, ...) return len; } -extern "C" void configTime(long timezone, int daylightOffset_sec, - const char* server1, const char* server2, const char* server3) -{ - (void)server1; - (void)server2; - (void)server3; - - mockverbose("configTime: TODO (tz=%ldH offset=%dS) (time will be host's)\n", timezone, daylightOffset_sec); -} - void stack_thunk_add_ref() { } void stack_thunk_del_ref() { } void stack_thunk_repaint() { } @@ -78,3 +68,13 @@ void stack_thunk_dump_stack() { } #define make_stack_thunk(fcnToThunk) }; + +void configTime(int timezone, int daylightOffset_sec, + const char* server1, const char* server2, const char* server3) +{ + (void)server1; + (void)server2; + (void)server3; + + mockverbose("configTime: TODO (tz=%dH offset=%dS) (time will be host's)\n", timezone, daylightOffset_sec); +} diff --git a/tests/host/common/esp8266_peri.h b/tests/host/common/esp8266_peri.h index d9dfd50ed4..4a1a3cd031 100644 --- a/tests/host/common/esp8266_peri.h +++ b/tests/host/common/esp8266_peri.h @@ -6,4 +6,4 @@ const int GPI = 0; const int GPO = 0; const int GP16I = 0; -#endif \ No newline at end of file +#endif diff --git a/tests/host/common/littlefs_mock.cpp b/tests/host/common/littlefs_mock.cpp index 73629787a2..0d99e82b1e 100644 --- a/tests/host/common/littlefs_mock.cpp +++ b/tests/host/common/littlefs_mock.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include "flash_hal_mock.h" #define LITTLEFS_FILE_NAME "littlefs.bin" diff --git a/tests/host/common/mock.h b/tests/host/common/mock.h index eff32dd46a..8ab2a057e1 100644 --- a/tests/host/common/mock.h +++ b/tests/host/common/mock.h @@ -30,6 +30,7 @@ */ #define CORE_MOCK 1 +#define MOCK "(mock) " // TODO: provide common logging API instead of adding this string everywhere? // @@ -37,7 +38,6 @@ #define ESP8266 1 #define A0 0 #define LED_BUILTIN 0 -#define F_CPU 80000000 #define LWIP_OPEN_SRC #define TCP_MSS 536 #define LWIP_FEATURES 1 @@ -54,19 +54,12 @@ #define D7 7 #define D8 8 -// include host's STL before any other include file -// because core definition like max() is in the way - -#ifdef __cplusplus -#include -#endif #include - #ifdef __cplusplus extern "C" { #endif -//#include +// TODO: #include ? char* itoa (int val, char *s, int radix); char* ltoa (long val, char *s, int radix); #ifdef __cplusplus @@ -91,9 +84,6 @@ uint32_t esp_get_cycle_count(); #include -// - -#include #define RANDOM_REG32 ((uint32_t)random()) // net tweak diff --git a/tests/host/common/spiffs_mock.cpp b/tests/host/common/spiffs_mock.cpp index d32c56d9d0..c7f9f53aba 100644 --- a/tests/host/common/spiffs_mock.cpp +++ b/tests/host/common/spiffs_mock.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include "flash_hal_mock.h"