diff --git a/cores/esp32/Arduino.h b/cores/esp32/Arduino.h index d60d3fe0828..0fd238b9eb6 100644 --- a/cores/esp32/Arduino.h +++ b/cores/esp32/Arduino.h @@ -80,8 +80,6 @@ #define degrees(rad) ((rad)*RAD_TO_DEG) #define sq(x) ((x)*(x)) -#define sei() -#define cli() #define interrupts() sei() #define noInterrupts() cli() diff --git a/cores/esp32/esp32-hal-misc.c b/cores/esp32/esp32-hal-misc.c index bf4ee06ebea..5f3051931e6 100644 --- a/cores/esp32/esp32-hal-misc.c +++ b/cores/esp32/esp32-hal-misc.c @@ -23,6 +23,24 @@ #include "esp_log.h" #include +static portMUX_TYPE interrupt_mux = portMUX_INITIALIZER_UNLOCKED; +static uint8_t interrupts_disabled = 0; +void sei() +{ + if (interrupts_disabled) { + portEXIT_CRITICAL(&interrupt_mux); + interrupts_disabled = 0; + } +} + +void cli() +{ + if (!interrupts_disabled) { + portENTER_CRITICAL(&interrupt_mux); + interrupts_disabled = 1; + } +} + //Undocumented!!! Get chip temperature in Farenheit //Source: https://github.com/pcbreflux/espressif/blob/master/esp32/arduino/sketchbook/ESP32_int_temp_sensor/ESP32_int_temp_sensor.ino uint8_t temprature_sens_read(); diff --git a/cores/esp32/esp32-hal.h b/cores/esp32/esp32-hal.h index d6e5ca8ca65..556f500b5b6 100644 --- a/cores/esp32/esp32-hal.h +++ b/cores/esp32/esp32-hal.h @@ -61,6 +61,11 @@ void yield(void); #include "esp32-hal-bt.h" #include "esp_system.h" +#include + +void sei(); +void cli(); + //returns chip temperature in Celsius float temperatureRead();