unix/modmachine: Add machine.idle(), implemented using sched_yield.
Also add a definition of MICROPY_EVENT_POLL_HOOK so the unix port can build against modules that require this.
This commit is contained in:
parent
4fa6d939d6
commit
cb5994d96e
@ -77,6 +77,14 @@ uintptr_t mod_machine_mem_get_addr(mp_obj_t addr_o, uint align) {
|
||||
return addr;
|
||||
}
|
||||
|
||||
#ifdef MICROPY_UNIX_MACHINE_IDLE
|
||||
STATIC mp_obj_t machine_idle(void) {
|
||||
MICROPY_UNIX_MACHINE_IDLE
|
||||
return mp_const_none;
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_0(machine_idle_obj, machine_idle);
|
||||
#endif
|
||||
|
||||
STATIC const mp_rom_map_elem_t machine_module_globals_table[] = {
|
||||
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_umachine) },
|
||||
|
||||
@ -84,6 +92,10 @@ STATIC const mp_rom_map_elem_t machine_module_globals_table[] = {
|
||||
{ MP_ROM_QSTR(MP_QSTR_mem16), MP_ROM_PTR(&machine_mem16_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_mem32), MP_ROM_PTR(&machine_mem32_obj) },
|
||||
|
||||
#ifdef MICROPY_UNIX_MACHINE_IDLE
|
||||
{ MP_ROM_QSTR(MP_QSTR_idle), MP_ROM_PTR(&machine_idle_obj) },
|
||||
#endif
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_PinBase), MP_ROM_PTR(&machine_pinbase_type) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_Signal), MP_ROM_PTR(&machine_signal_type) },
|
||||
#if MICROPY_PY_MACHINE_PULSE
|
||||
|
@ -349,4 +349,9 @@ void mp_unix_mark_exec(void);
|
||||
#define MICROPY_END_ATOMIC_SECTION(x) (void)x; mp_thread_unix_end_atomic_section()
|
||||
#endif
|
||||
|
||||
#define MICROPY_EVENT_POLL_HOOK mp_hal_delay_us(500);
|
||||
|
||||
#include <sched.h>
|
||||
#define MICROPY_UNIX_MACHINE_IDLE sched_yield();
|
||||
|
||||
#endif // MICROPY_UNIX_MINIMAL
|
||||
|
Loading…
Reference in New Issue
Block a user