Skip to content

Commit e20bb98

Browse files
robert-hhdpgeorge
authored andcommitted
mimxrt/machine_pin: Add the Pin.toggle() method.
For consistency with other ports, even if this method is undocumented at the moment.
1 parent c138e10 commit e20bb98

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

ports/mimxrt/machine_pin.c

+9
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,14 @@ STATIC mp_obj_t machine_pin_on(mp_obj_t self_in) {
285285
}
286286
STATIC MP_DEFINE_CONST_FUN_OBJ_1(machine_pin_on_obj, machine_pin_on);
287287

288+
// pin.toggle()
289+
STATIC mp_obj_t machine_pin_toggle(mp_obj_t self_in) {
290+
machine_pin_obj_t *self = self_in;
291+
mp_hal_pin_toggle(self);
292+
return mp_const_none;
293+
}
294+
STATIC MP_DEFINE_CONST_FUN_OBJ_1(machine_pin_toggle_obj, machine_pin_toggle);
295+
288296
// pin.value([value])
289297
STATIC mp_obj_t machine_pin_value(size_t n_args, const mp_obj_t *args) {
290298
return machine_pin_obj_call(args[0], (n_args - 1), 0, args + 1);
@@ -366,6 +374,7 @@ STATIC const mp_rom_map_elem_t machine_pin_locals_dict_table[] = {
366374
{ MP_ROM_QSTR(MP_QSTR_on), MP_ROM_PTR(&machine_pin_on_obj) },
367375
{ MP_ROM_QSTR(MP_QSTR_low), MP_ROM_PTR(&machine_pin_off_obj) },
368376
{ MP_ROM_QSTR(MP_QSTR_high), MP_ROM_PTR(&machine_pin_on_obj) },
377+
{ MP_ROM_QSTR(MP_QSTR_toggle), MP_ROM_PTR(&machine_pin_toggle_obj) },
369378
{ MP_ROM_QSTR(MP_QSTR_value), MP_ROM_PTR(&machine_pin_value_obj) },
370379
{ MP_ROM_QSTR(MP_QSTR_init), MP_ROM_PTR(&machine_pin_init_obj) },
371380
{ MP_ROM_QSTR(MP_QSTR_irq), MP_ROM_PTR(&machine_pin_irq_obj) },

0 commit comments

Comments
 (0)