diff options
| author | Philipp Ebensberger <philipp.ebensberger@3bricks-software.de> | 2021-08-13 20:47:00 +0200 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2021-08-16 15:03:50 +1000 |
| commit | a1dc7277d950ddc493ee81a6c3ef736446b70352 (patch) | |
| tree | 86b0c49824410c8564b127d281ff1b0240558b7c | |
| parent | c70930fb24f3e10dfde6ca7c89421eb94136d3be (diff) | |
mimxrt/machine_pin: Implement ioctl for Pin.
To make machine.Signal work correctly (among other things). The solution
is taken over from the rp2 port.
Signed-off-by: Philipp Ebensberger
| -rw-r--r-- | ports/mimxrt/machine_pin.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/ports/mimxrt/machine_pin.c b/ports/mimxrt/machine_pin.c index 3a1151ba8..12975806d 100644 --- a/ports/mimxrt/machine_pin.c +++ b/ports/mimxrt/machine_pin.c @@ -32,6 +32,7 @@ #include "py/runtime.h" #include "py/mphal.h" #include "shared/runtime/mpirq.h" +#include "extmod/virtpin.h" #include "pin.h" // Local functions @@ -425,12 +426,34 @@ STATIC const mp_rom_map_elem_t machine_pin_locals_dict_table[] = { }; STATIC MP_DEFINE_CONST_DICT(machine_pin_locals_dict, machine_pin_locals_dict_table); + +STATIC mp_uint_t machine_pin_ioctl(mp_obj_t self_in, mp_uint_t request, uintptr_t arg, int *errcode) { + (void)errcode; + machine_pin_obj_t *self = self_in; + + switch (request) { + case MP_PIN_READ: { + return mp_hal_pin_read(self); + } + case MP_PIN_WRITE: { + mp_hal_pin_write(self, arg); + return 0; + } + } + return -1; +} + +STATIC const mp_pin_p_t machine_pin_obj_protocol = { + .ioctl = machine_pin_ioctl, +}; + const mp_obj_type_t machine_pin_type = { {&mp_type_type}, .name = MP_QSTR_Pin, .print = machine_pin_obj_print, .call = machine_pin_obj_call, .make_new = mp_pin_make_new, + .protocol = &machine_pin_obj_protocol, .locals_dict = (mp_obj_dict_t *)&machine_pin_locals_dict, }; |
