Skip to content

Commit 82e382a

Browse files
agattidpgeorge
authored andcommitted
esp32/mpconfigport: Use the appropriate wait-for-interrupt opcode.
When threading is disabled, the pending events handling code would wait for an incoming interrupt once there's no more work to do. This bit of code was Xtensa-specific and wouldn't compile on a RISC-V based MCU. This commit provides the RISC-V equivalent to that part of the code, allowing to make threadless MicroPython builds on RISC-V based MCUs. Signed-off-by: Alessandro Gatti <[email protected]>
1 parent 9441ce6 commit 82e382a

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Diff for: ports/esp32/mpconfigport.h

+6-1
Original file line numberDiff line numberDiff line change
@@ -292,12 +292,17 @@ void *esp_native_code_commit(void *, size_t, void *);
292292
MP_THREAD_GIL_ENTER(); \
293293
} while (0);
294294
#else
295+
#if CONFIG_IDF_TARGET_ARCH_RISCV
296+
#define MICROPY_PY_WAIT_FOR_INTERRUPT asm volatile ("wfi\n")
297+
#else
298+
#define MICROPY_PY_WAIT_FOR_INTERRUPT asm volatile ("waiti 0\n")
299+
#endif
295300
#define MICROPY_EVENT_POLL_HOOK \
296301
do { \
297302
extern void mp_handle_pending(bool); \
298303
mp_handle_pending(true); \
299304
MICROPY_PY_SOCKET_EVENTS_HANDLER \
300-
asm ("waiti 0"); \
305+
MICROPY_PY_WAIT_FOR_INTERRUPT; \
301306
} while (0);
302307
#endif
303308

0 commit comments

Comments
 (0)