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 <a.gatti@frob.it>
This commit is contained in:
Alessandro Gatti
2024-12-04 12:30:25 +01:00
committed by Damien George
parent 9441ce6e3c
commit 82e382a399

View File

@@ -292,12 +292,17 @@ void *esp_native_code_commit(void *, size_t, void *);
MP_THREAD_GIL_ENTER(); \
} while (0);
#else
#if CONFIG_IDF_TARGET_ARCH_RISCV
#define MICROPY_PY_WAIT_FOR_INTERRUPT asm volatile ("wfi\n")
#else
#define MICROPY_PY_WAIT_FOR_INTERRUPT asm volatile ("waiti 0\n")
#endif
#define MICROPY_EVENT_POLL_HOOK \
do { \
extern void mp_handle_pending(bool); \
mp_handle_pending(true); \
MICROPY_PY_SOCKET_EVENTS_HANDLER \
asm ("waiti 0"); \
MICROPY_PY_WAIT_FOR_INTERRUPT; \
} while (0);
#endif