Skip to content

Commit

Permalink
Put InterruptLock (from interrupts.h) into namespace esp8266 to fix n…
Browse files Browse the repository at this point in the history
…ow and future (#6225)

collisions with 3rd party Arduino libraries (currently Adafruit DHT has this issue)
  • Loading branch information
dok-net authored and d-a-v committed Jun 25, 2019
1 parent 2e3e1d5 commit f5a882d
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion cores/esp8266/Esp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ void EspClass::restart(void)

uint16_t EspClass::getVcc(void)
{
InterruptLock lock;
esp8266::InterruptLock lock;
(void)lock;
return system_get_vdd33();
}
Expand Down
6 changes: 3 additions & 3 deletions cores/esp8266/Schedule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)

InterruptLock lockAllInterruptsInThisScope;
esp8266::InterruptLock lockAllInterruptsInThisScope;

scheduled_fn_t* item = get_fn_unsafe();
if (!item)
Expand Down Expand Up @@ -104,7 +104,7 @@ void run_scheduled_functions(schedule_e policy)

static bool fence = false;
{
InterruptLock lockAllInterruptsInThisScope;
esp8266::InterruptLock lockAllInterruptsInThisScope;
if (fence)
// prevent recursive calls from yield()
return;
Expand Down Expand Up @@ -136,7 +136,7 @@ void run_scheduled_functions(schedule_e policy)
else
{
// function removed from list
InterruptLock lockAllInterruptsInThisScope;
esp8266::InterruptLock lockAllInterruptsInThisScope;

if (sFirst == toCall)
sFirst = sFirst->mNext;
Expand Down
1 change: 0 additions & 1 deletion cores/esp8266/Updater.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include "Updater.h"
#include "Arduino.h"
#include "eboot_command.h"
#include <interrupts.h>
#include <esp8266_peri.h>

//#define DEBUG_UPDATER Serial
Expand Down
5 changes: 5 additions & 0 deletions cores/esp8266/interrupts.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
//}
//

namespace esp8266
{

class InterruptLock {
public:
InterruptLock() {
Expand Down Expand Up @@ -54,4 +57,6 @@ private: \
}; \
_AutoDisableIntr _autoDisableIntr

} // esp8266

#endif //INTERRUPTS_H
2 changes: 1 addition & 1 deletion libraries/SoftwareSerial

0 comments on commit f5a882d

Please sign in to comment.