Skip to content

Commit 7fd5307

Browse files
make ets_intr_lock_stack uint16_t and behave like the original on over/underflow
The PS register is 15 bits, we should store the whole thing as xt_wsr_ps() writes the whole thing. Also if there is an underflow, we should make sure interrupts are enabled. Same goes for overflow making sure interrupts are disabled, although this is less important.
1 parent 5f9281f commit 7fd5307

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

cores/esp8266/core_esp8266_main.cpp

+6-2
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ static uint32_t s_micros_at_task_start;
6464
* Max nesting seen by SDK so far is 2.
6565
*/
6666
#define ETS_INTR_LOCK_NEST_MAX 7
67-
byte ets_intr_lock_stack[ETS_INTR_LOCK_NEST_MAX];
68-
byte ets_intr_lock_stack_ptr=0;
67+
uint16_t ets_intr_lock_stack[ETS_INTR_LOCK_NEST_MAX];
68+
byte ets_intr_lock_stack_ptr=0;
6969

7070

7171
extern "C" {
@@ -131,11 +131,15 @@ extern "C" void optimistic_yield(uint32_t interval_us) {
131131
extern "C" void ets_intr_lock_nest() {
132132
if (ets_intr_lock_stack_ptr < ETS_INTR_LOCK_NEST_MAX)
133133
ets_intr_lock_stack[ets_intr_lock_stack_ptr++] = xt_rsil(3);
134+
else
135+
xt_rsil(3);
134136
}
135137

136138
extern "C" void ets_intr_unlock_nest() {
137139
if (ets_intr_lock_stack_ptr > 0)
138140
xt_wsr_ps(ets_intr_lock_stack[--ets_intr_lock_stack_ptr]);
141+
else
142+
xt_rsil(0);
139143
}
140144

141145

0 commit comments

Comments
 (0)