From 9ad3c5b0d75784b5881d94b44b3b86f54a8a7f3b Mon Sep 17 00:00:00 2001 From: Harald Barth Date: Mon, 7 Feb 2022 00:14:43 +0100 Subject: [PATCH] ESP8266 specific adaptions --- MotorDriver.cpp | 4 +++- SerialManager.cpp | 7 ++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/MotorDriver.cpp b/MotorDriver.cpp index 2aa9639..3b76fa4 100644 --- a/MotorDriver.cpp +++ b/MotorDriver.cpp @@ -141,12 +141,14 @@ bool MotorDriver::canMeasureCurrent() { * a central value depending on direction. */ int MotorDriver::getCurrentRaw() { - if (currentPin==UNUSED_PIN) return 0; + if (currentPin==UNUSED_PIN) return 0; int current; #if defined(ARDUINO_TEENSY40) || defined(ARDUINO_TEENSY41) bool irq = disableInterrupts(); current = analogRead(currentPin)-senseOffset; enableInterrupts(irq); +#elif defined(ARDUINO_ARCH_ESP8266) + current = analogRead(currentPin)-senseOffset; #else // Uno, Mega and all the TEENSY3* but not TEENSY4* unsigned char sreg_backup; sreg_backup = SREG; /* save interrupt enable/disable state */ diff --git a/SerialManager.cpp b/SerialManager.cpp index 8717227..9cf559c 100644 --- a/SerialManager.cpp +++ b/SerialManager.cpp @@ -32,7 +32,12 @@ SerialManager::SerialManager(Stream * myserial) { } void SerialManager::init() { - while (!Serial && millis() < 5000); // wait max 5s for Serial to start + while (!Serial && millis() < 5000) // wait max 5s for Serial to start +#if defined(ARDUINO_ARCH_ESP8266) + yield(); // yield (otherwise chip resets) +#else + ; // do nothing +#endif Serial.begin(115200); new SerialManager(&Serial); #ifdef SERIAL3_COMMANDS