Skip to content

Commit 6ead6b4

Browse files
committed
Fix stubs and tweak IOPin deinit
1 parent 21c9645 commit 6ead6b4

File tree

2 files changed

+9
-13
lines changed
  • shared-bindings/i2cioexpander
  • shared-module/i2cioexpander

2 files changed

+9
-13
lines changed

shared-bindings/i2cioexpander/IOPin.c

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,12 @@ static inline void check_for_deinit(i2cioexpander_iopin_obj_t *self) {
4242
raise_deinited_error();
4343
}
4444
}
45-
46-
//| def deinit(self) -> None:
47-
//| """Turn off the pin and release it for other use."""
48-
//| ...
49-
static mp_obj_t i2cioexpander_iopin_deinit(mp_obj_t self_in) {
50-
i2cioexpander_iopin_obj_t *self = MP_OBJ_TO_PTR(self_in);
51-
common_hal_i2cioexpander_iopin_deinit(self);
52-
return mp_const_none;
53-
}
54-
MP_DEFINE_CONST_FUN_OBJ_1(i2cioexpander_iopin_deinit_obj, i2cioexpander_iopin_deinit);
45+
//| class IOPin:
46+
//| """Control a single pin on an `IOExpander` in the same way as `DigitalInOut`.
47+
//|
48+
//| Not constructed directly. Get from `IOExpander.pins` instead.
49+
//| """
50+
//|
5551

5652
//| def switch_to_output(
5753
//| self, value: bool = False, drive_mode: digitalio.DriveMode = digitalio.DriveMode.PUSH_PULL
@@ -310,7 +306,6 @@ static const digitalinout_p_t iopin_digitalinout_p = {
310306

311307
static const mp_rom_map_elem_t i2cioexpander_iopin_locals_dict_table[] = {
312308
// Methods
313-
{ MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&i2cioexpander_iopin_deinit_obj) },
314309
{ MP_ROM_QSTR(MP_QSTR_switch_to_input), MP_ROM_PTR(&i2cioexpander_iopin_switch_to_input_obj) },
315310
{ MP_ROM_QSTR(MP_QSTR_switch_to_output), MP_ROM_PTR(&i2cioexpander_iopin_switch_to_output_obj) },
316311

shared-module/i2cioexpander/IOPin.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,12 @@ mp_errno_t i2cioexpander_iopin_construct(
2626
}
2727

2828
void common_hal_i2cioexpander_iopin_deinit(i2cioexpander_iopin_obj_t *self) {
29-
self->expander = NULL;
29+
// Switch to input on deinit.
30+
common_hal_i2cioexpander_iopin_switch_to_input(self, PULL_NONE);
3031
}
3132

3233
bool common_hal_i2cioexpander_iopin_deinited(i2cioexpander_iopin_obj_t *self) {
33-
return self->expander == NULL;
34+
return self->expander == NULL || common_hal_i2cioexpander_ioexpander_deinited(self->expander);
3435
}
3536

3637
digitalinout_result_t common_hal_i2cioexpander_iopin_switch_to_input(

0 commit comments

Comments
 (0)