10000 esp8266: Provide a dedicated variable to disable ets_loop_iter. · lapsule/micropython@927388e · GitHub
[go: up one dir, main page]

Skip to content

Commit 927388e

Browse files
committed
esp8266: Provide a dedicated variable to disable ets_loop_iter.
So ets_loop_iter is now only disabled when using machine.disable_irq.
1 parent 752e952 commit 927388e

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

esp8266/ets_alt_task.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
#include <stdio.h>
2-
#include "xtirq.h"
32
#include "osapi.h"
43
#include "os_type.h"
54
#include "ets_sys.h"
65
#include <esp_sdk_ver.h>
76
#include "etshal.h"
87
#include "user_interface.h"
8+
#include "ets_alt_task.h"
99

1010
// Use standard ets_task or alternative impl
1111
#define USE_ETS_TASK 0
@@ -108,8 +108,10 @@ bool ets_post(uint8 prio, os_signal_t sig, os_param_t param) {
108108
#endif
109109
}
110110

111+
int ets_loop_iter_disable = 0;
112+
111113
bool ets_loop_iter(void) {
112-
if (query_irq() != 0) {
114+
if (ets_loop_iter_disable) {
113115
return false;
114116
}
115117
//static unsigned cnt;

esp8266/ets_alt_task.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
extern int ets_loop_iter_disable;
12
bool ets_loop_iter(void);

esp8266/modmachine.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,13 +191,21 @@ const mp_obj_type_t esp_timer_type = {
191191
.locals_dict = (mp_obj_t)&esp_timer_locals_dict,
192192
};
193193

194+
// this bit is unused in the Xtensa PS register
195+
#define ETS_LOOP_ITER_BIT (12)
196+
194197
STATIC mp_obj_t machine_disable_irq(void) {
195-
return mp_obj_new_int(disable_irq());
198+
uint32_t state = disable_irq();
199+
state = (state & ~(1 << ETS_LOOP_ITER_BIT)) | (ets_loop_iter_disable << ETS_LOOP_ITER_BIT);
200+
ets_loop_iter_disable = 1;
201+
return mp_obj_new_int(state);
196202
}
197203
MP_DEFINE_CONST_FUN_OBJ_0(machine_disable_irq_obj, machine_disable_irq);
198204

199-
STATIC mp_obj_t machine_enable_irq(mp_obj_t state) {
200-
enable_irq(mp_obj_get_int(state));
205+
STATIC mp_obj_t machine_enable_irq(mp_obj_t state_in) {
206+
uint32_t state = mp_obj_get_int(state_in);
207+
ets_loop_iter_disable = (state >> ETS_LOOP_ITER_BIT) & 1;
208+
enable_irq(state & ~(1 << ETS_LOOP_ITER_BIT));
201209
return mp_const_none;
202210
}
203211
MP_DEFINE_CONST_FUN_OBJ_1(machine_enable_irq_obj, machine_enable_irq);

0 commit comments

Comments
 (0)
0