1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-19 23:22:16 +03:00

Put InterruptLock (from interrupts.h) into namespace esp8266 to fix now and future (#6225)

collisions with 3rd party Arduino libraries (currently Adafruit DHT has this issue)
This commit is contained in:
Dirk O. Kaar 2019-06-25 11:14:45 +02:00 committed by david gauchard
parent 2e3e1d5e98
commit f5a882d03d
5 changed files with 10 additions and 6 deletions

View File

@ -200,7 +200,7 @@ void EspClass::restart(void)
uint16_t EspClass::getVcc(void) uint16_t EspClass::getVcc(void)
{ {
InterruptLock lock; esp8266::InterruptLock lock;
(void)lock; (void)lock;
return system_get_vdd33(); return system_get_vdd33();
} }

View File

@ -56,7 +56,7 @@ bool schedule_function_us(std::function<bool(void)>&& fn, uint32_t repeat_us, sc
{ {
assert(repeat_us < decltype(scheduled_fn_t::callNow)::neverExpires); //~26800000us (26.8s) assert(repeat_us < decltype(scheduled_fn_t::callNow)::neverExpires); //~26800000us (26.8s)
InterruptLock lockAllInterruptsInThisScope; esp8266::InterruptLock lockAllInterruptsInThisScope;
scheduled_fn_t* item = get_fn_unsafe(); scheduled_fn_t* item = get_fn_unsafe();
if (!item) if (!item)
@ -104,7 +104,7 @@ void run_scheduled_functions(schedule_e policy)
static bool fence = false; static bool fence = false;
{ {
InterruptLock lockAllInterruptsInThisScope; esp8266::InterruptLock lockAllInterruptsInThisScope;
if (fence) if (fence)
// prevent recursive calls from yield() // prevent recursive calls from yield()
return; return;
@ -136,7 +136,7 @@ void run_scheduled_functions(schedule_e policy)
else else
{ {
// function removed from list // function removed from list
InterruptLock lockAllInterruptsInThisScope; esp8266::InterruptLock lockAllInterruptsInThisScope;
if (sFirst == toCall) if (sFirst == toCall)
sFirst = sFirst->mNext; sFirst = sFirst->mNext;

View File

@ -1,7 +1,6 @@
#include "Updater.h" #include "Updater.h"
#include "Arduino.h" #include "Arduino.h"
#include "eboot_command.h" #include "eboot_command.h"
#include <interrupts.h>
#include <esp8266_peri.h> #include <esp8266_peri.h>
//#define DEBUG_UPDATER Serial //#define DEBUG_UPDATER Serial

View File

@ -16,6 +16,9 @@
//} //}
// //
namespace esp8266
{
class InterruptLock { class InterruptLock {
public: public:
InterruptLock() { InterruptLock() {
@ -54,4 +57,6 @@ private: \
}; \ }; \
_AutoDisableIntr _autoDisableIntr _AutoDisableIntr _autoDisableIntr
} // esp8266
#endif //INTERRUPTS_H #endif //INTERRUPTS_H

@ -1 +1 @@
Subproject commit 8e45d18d5a1c9d9f6a9a6a9b4923690117117d45 Subproject commit c06b923bfea3641b537c1131f2b5612e48ffe1be