From 88455b696cebb9c5365818d2281df5863784057a Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Thu, 2 Aug 2018 17:45:09 +0200 Subject: [PATCH] Prepare for next core version Prepare for next core version using updated PWM library --- sonoff/core_esp8266_timer.c | 6 ++++++ sonoff/core_esp8266_wiring_digital.c | 13 +++++++++---- sonoff/core_esp8266_wiring_pwm.c | 6 ++++++ 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/sonoff/core_esp8266_timer.c b/sonoff/core_esp8266_timer.c index 1b18861ae..b0eb2e245 100644 --- a/sonoff/core_esp8266_timer.c +++ b/sonoff/core_esp8266_timer.c @@ -18,6 +18,10 @@ License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include +#ifdef ARDUINO_ESP8266_RELEASE_2_3_0 +#warning **** Tasmota is using v2.4.0 timer.c as planned **** + #include "wiring_private.h" #include "pins_arduino.h" @@ -101,3 +105,5 @@ void ICACHE_RAM_ATTR timer0_detachInterrupt() { timer0_user_cb = NULL; ETS_CCOMPARE0_DISABLE(); } + +#endif // ARDUINO_ESP8266_RELEASE_2_3_0 diff --git a/sonoff/core_esp8266_wiring_digital.c b/sonoff/core_esp8266_wiring_digital.c index 9d88ba847..cbed5cae6 100644 --- a/sonoff/core_esp8266_wiring_digital.c +++ b/sonoff/core_esp8266_wiring_digital.c @@ -18,6 +18,10 @@ License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include +#ifdef ARDUINO_ESP8266_RELEASE_2_3_0 +#warning **** Tasmota is using v2.4.0 wiring_digital.c as planned **** + #define ARDUINO_MAIN #include "wiring_private.h" #include "pins_arduino.h" @@ -130,12 +134,12 @@ void ICACHE_RAM_ATTR interrupt_handler(void *arg) { while(!(changedbits & (1 << i))) i++; changedbits &= ~(1 << i); interrupt_handler_t *handler = &interrupt_handlers[i]; - if (handler->fn && - (handler->mode == CHANGE || + if (handler->fn && + (handler->mode == CHANGE || (handler->mode & 1) == !!(levels & (1 << i)))) { // to make ISR compatible to Arduino AVR model where interrupts are disabled // we disable them before we call the client ISR - uint32_t savedPS = xt_rsil(15); // stop other interrupts + uint32_t savedPS = xt_rsil(15); // stop other interrupts if (handler->arg) { ((voidFuncPtrArg)handler->fn)(handler->arg); @@ -197,7 +201,7 @@ void initPins() { for (int i = 12; i <= 16; ++i) { pinMode(i, INPUT); } - + ETS_GPIO_INTR_ATTACH(interrupt_handler, &interrupt_reg); ETS_GPIO_INTR_ENABLE(); } @@ -208,3 +212,4 @@ extern int digitalRead(uint8_t pin) __attribute__ ((weak, alias("__digitalRead") extern void attachInterrupt(uint8_t pin, voidFuncPtr handler, int mode) __attribute__ ((weak, alias("__attachInterrupt"))); extern void detachInterrupt(uint8_t pin) __attribute__ ((weak, alias("__detachInterrupt"))); +#endif // ARDUINO_ESP8266_RELEASE_2_3_0 diff --git a/sonoff/core_esp8266_wiring_pwm.c b/sonoff/core_esp8266_wiring_pwm.c index 671eaa414..029cbf89c 100644 --- a/sonoff/core_esp8266_wiring_pwm.c +++ b/sonoff/core_esp8266_wiring_pwm.c @@ -18,6 +18,10 @@ License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include +#ifdef ARDUINO_ESP8266_RELEASE_2_3_0 +#warning **** Tasmota is using v2.4.0 wiring_pwm.c as planned **** + #include "wiring_private.h" #include "pins_arduino.h" #include "c_types.h" @@ -219,3 +223,5 @@ extern void __analogWriteRange(uint32_t range) extern void analogWrite(uint8_t pin, int val) __attribute__ ((weak, alias("__analogWrite"))); extern void analogWriteFreq(uint32_t freq) __attribute__ ((weak, alias("__analogWriteFreq"))); extern void analogWriteRange(uint32_t range) __attribute__ ((weak, alias("__analogWriteRange"))); + +#endif // ARDUINO_ESP8266_RELEASE_2_3_0