Skip to content

Commit 545dd35

Browse files
committed
fix emulation on host, use alternate interruopt locking method
1 parent b6564c2 commit 545dd35

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

cores/esp8266/Arduino.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,16 @@ void ets_intr_unlock();
146146
#define __STRINGIFY(a) #a
147147
#endif
148148

149+
#if CORE_MOCK
150+
151+
#define xt_rsil(level) (level)
152+
#define xt_wsr_ps(state) do { (void)(state); } while (0)
153+
154+
#define interrupts() do { (void)0; } while (0)
155+
#define noInterrupts() do { (void)0; } while (0)
156+
157+
#else // !CORE_MOCK
158+
149159
// these low level routines provide a replacement for SREG interrupt save that AVR uses
150160
// but are esp8266 specific. A normal use pattern is like
151161
//
@@ -165,6 +175,7 @@ void ets_intr_unlock();
165175
#define interrupts() xt_rsil(0)
166176
#define noInterrupts() xt_rsil(15)
167177

178+
#endif // !CORE_MOCK
168179

169180
#define clockCyclesPerMicrosecond() ( F_CPU / 1000000L )
170181
#define clockCyclesToMicroseconds(a) ( (a) / clockCyclesPerMicrosecond() )

cores/esp8266/Schedule.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ bool schedule_function_us(mFuncT fn, uint32_t repeat_us)
4747
}
4848
item->mFunc = fn;
4949

50-
noInterrupts();
50+
uint32_t savedPS = xt_rsil(0); // noInterrupts();
5151
item->mNext = sFirst;
5252
sFirst = item;
53-
interrupts();
53+
xt_wsr_ps(savedPS); // interrupts();
5454

5555
if (repeat_us)
5656
item->callNow.reset(repeat_us);
@@ -70,10 +70,10 @@ void run_scheduled_functions()
7070
toCall = item->mNext;
7171
if (item->callNow && !item->mFunc())
7272
{
73-
noInterrupts();
73+
uint32_t savedPS = xt_rsil(0); // noInterrupts();
7474
if (sFirst == item)
7575
sFirst = item->mNext;
76-
interrupts();
76+
xt_wsr_ps(savedPS); // interrupts();
7777

7878
item->mFunc = mFuncT();
7979
recycle_fn(item);

0 commit comments

Comments
 (0)