Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd87e242

Browse files
committed
ISR safety.
1 parent03713a7 commitd87e242

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

‎cores/esp8266/Schedule.cpp‎

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -119,15 +119,15 @@ bool schedule_recurrent_function_us(const std::function<bool(void)>& fn,
119119
item->mFunc = fn;
120120
item->alarm = alarm;
121121

122+
esp8266::InterruptLock lockAllInterruptsInThisScope;
123+
122124
// prevent new item overwriting an already expired rTarget.
123-
constint32_trRemaining = rTarget -micros();
124-
if (!rFirst || (rRemaining >0 &&static_cast<uint32_t>(rRemaining) > item->callNow.remaining()))
125+
constint32_tremaining = rTarget -micros();
126+
if (!rFirst || (remaining >0 &&static_cast<uint32_t>(remaining) > item->callNow.remaining()))
125127
{
126128
rTarget =micros() + item->callNow.remaining();
127129
}
128130

129-
esp8266::InterruptLock lockAllInterruptsInThisScope;
130-
131131
if (rLast)
132132
{
133133
rLast->mNext = item;
@@ -145,8 +145,8 @@ uint32_t get_scheduled_recurrent_delay_us()
145145
{
146146
if (!rFirst)return ~static_cast<uint32_t>(0);
147147
// handle already expired rTarget.
148-
constint32_trRemaining = rTarget -micros();
149-
return (rRemaining >0) ?static_cast<uint32_t>(rRemaining) :0;
148+
constint32_tremaining = rTarget -micros();
149+
return (remaining >0) ?static_cast<uint32_t>(remaining) :0;
150150
}
151151

152152
voidrun_scheduled_functions()
@@ -248,9 +248,12 @@ void run_scheduled_recurrent_functions()
248248
{
249249
prev = current;
250250
current = current->mNext;
251+
252+
esp8266::InterruptLock lockAllInterruptsInThisScope;
253+
251254
// prevent current item overwriting an already expired rTarget.
252-
constint32_trRemaining = rTarget -micros();
253-
if (rRemaining >0 &&static_cast<uint32_t>(rRemaining) > current->callNow.remaining())
255+
constint32_tremaining = rTarget -micros();
256+
if (remaining >0 &&static_cast<uint32_t>(remaining) > current->callNow.remaining())
254257
{
255258
rTarget =micros() + current->callNow.remaining();
256259
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp