Skip to content

Commit 1b7d672

Browse files
committed
esp8266: Enable micropython.schedule() with locking in pin callback.
1 parent a5159ed commit 1b7d672

4 files changed

Lines changed: 6 additions & 5 deletions

File tree

esp8266/esp8266_common.ld

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ SECTIONS
100100
*py/qstr.o*(.literal* .text*)
101101
*py/repl.o*(.literal* .text*)
102102
*py/runtime.o*(.literal* .text*)
103+
*py/scheduler.o*(.literal* .text*)
103104
*py/scope.o*(.literal* .text*)
104105
*py/sequence.o*(.literal* .text*)
105106
*py/showbc.o*(.literal* .text*)

esp8266/esp_mphal.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include "ets_alt_task.h"
3434
#include "py/obj.h"
3535
#include "py/mpstate.h"
36+
#include "py/runtime.h"
3637
#include "extmod/misc.h"
3738
#include "lib/utils/pyexec.h"
3839

@@ -130,11 +131,7 @@ void mp_hal_delay_ms(uint32_t delay) {
130131

131132
void ets_event_poll(void) {
132133
ets_loop_iter();
133-
if (MP_STATE_VM(mp_pending_exception) != NULL) {
134-
mp_obj_t obj = MP_STATE_VM(mp_pending_exception);
135-
MP_STATE_VM(mp_pending_exception) = MP_OBJ_NULL;
136-
nlr_raise(obj);
137-
}
134+
mp_handle_pending();
138135
}
139136

140137
void __assert_func(const char *file, int line, const char *func, const char *expr) {

esp8266/machine_pin.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ void pin_init0(void) {
100100
}
101101

102102
void pin_intr_handler(uint32_t status) {
103+
mp_sched_lock();
103104
gc_lock();
104105
status &= 0xffff;
105106
for (int p = 0; status; ++p, status >>= 1) {
@@ -111,6 +112,7 @@ void pin_intr_handler(uint32_t status) {
111112
}
112113
}
113114
gc_unlock();
115+
mp_sched_unlock();
114116
}
115117

116118
pyb_pin_obj_t *mp_obj_get_pin_obj(mp_obj_t pin_in) {

esp8266/mpconfigport.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#define MICROPY_MODULE_WEAK_LINKS (1)
2929
#define MICROPY_CAN_OVERRIDE_BUILTINS (1)
3030
#define MICROPY_USE_INTERNAL_ERRNO (1)
31+
#define MICROPY_ENABLE_SCHEDULER (1)
3132
#define MICROPY_PY_ALL_SPECIAL_METHODS (1)
3233
#define MICROPY_PY_BUILTINS_COMPLEX (0)
3334
#define MICROPY_PY_BUILTINS_STR_UNICODE (1)

0 commit comments

Comments
 (0)