Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f4641b2

Browse files
committed
esp32/uart: Use core-provided mp_keyboard_interrupt, placed in IRAM.
1 parent 8d0421c commit f4641b2

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

ports/esp32/mpconfigport.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,9 @@ void *esp_native_code_commit(void*, size_t, void*);
260260
} while (0);
261261
#endif
262262

263+
// Functions that should go in IRAM
264+
#define MICROPY_WRAP_MP_KEYBOARD_INTERRUPT(f) IRAM_ATTR f
265+
263266
#define UINT_FMT "%u"
264267
#define INT_FMT "%d"
265268

ports/esp32/uart.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
#include "driver/uart.h"
3232

33-
#include "py/mpstate.h"
33+
#include "py/runtime.h"
3434
#include "py/mphal.h"
3535

3636
STATIC void uart_irq_handler(void *arg);
@@ -50,13 +50,7 @@ STATIC void IRAM_ATTR uart_irq_handler(void *arg) {
5050
while (uart->status.rxfifo_cnt) {
5151
uint8_t c = uart->fifo.rw_byte;
5252
if (c == mp_interrupt_char) {
53-
// inline version of mp_keyboard_interrupt();
54-
MP_STATE_VM(mp_pending_exception) = MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_kbd_exception));
55-
#if MICROPY_ENABLE_SCHEDULER
56-
if (MP_STATE_VM(sched_state) == MP_SCHED_IDLE) {
57-
MP_STATE_VM(sched_state) = MP_SCHED_PENDING;
58-
}
59-
#endif
53+
mp_keyboard_interrupt();
6054
} else {
6155
// this is an inline function so will be in IRAM
6256
ringbuf_put(&stdin_ringbuf, c);

0 commit comments

Comments
 (0)