From 8a3e9036eb4cd6a4fb216d980f7c8c44a3e1cbce Mon Sep 17 00:00:00 2001 From: Damien George Date: Tue, 3 May 2016 13:13:56 +0100 Subject: [PATCH] esp8266/modpybpin: Use None instead of PULL_NONE for no-pull config. --- esp8266/modpybpin.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/esp8266/modpybpin.c b/esp8266/modpybpin.c index 23d1a93734..57d97295f8 100644 --- a/esp8266/modpybpin.c +++ b/esp8266/modpybpin.c @@ -180,12 +180,12 @@ STATIC void pyb_pin_print(const mp_print_t *print, mp_obj_t self_in, mp_print_ki mp_printf(print, "Pin(%u)", self->phys_port); } -// pin.init(mode, pull=Pin.PULL_NONE, af=-1) +// pin.init(mode, pull=None, *, value) STATIC mp_obj_t pyb_pin_obj_init_helper(pyb_pin_obj_t *self, mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_mode, ARG_pull, ARG_value }; static const mp_arg_t allowed_args[] = { { MP_QSTR_mode, MP_ARG_REQUIRED | MP_ARG_INT }, - { MP_QSTR_pull, MP_ARG_INT, {.u_int = GPIO_PULL_NONE}}, + { MP_QSTR_pull, MP_ARG_OBJ, {.u_obj = mp_const_none}}, { MP_QSTR_value, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL}}, }; @@ -197,7 +197,10 @@ STATIC mp_obj_t pyb_pin_obj_init_helper(pyb_pin_obj_t *self, mp_uint_t n_args, c uint mode = args[ARG_mode].u_int; // get pull mode - uint pull = args[ARG_pull].u_int; + uint pull = GPIO_PULL_NONE; + if (args[ARG_pull].u_obj != mp_const_none) { + pull = mp_obj_get_int(args[ARG_pull].u_obj); + } // get initial value int value; @@ -343,7 +346,6 @@ STATIC const mp_map_elem_t pyb_pin_locals_dict_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR_IN), MP_OBJ_NEW_SMALL_INT(GPIO_MODE_INPUT) }, { MP_OBJ_NEW_QSTR(MP_QSTR_OUT), MP_OBJ_NEW_SMALL_INT(GPIO_MODE_OUTPUT) }, { MP_OBJ_NEW_QSTR(MP_QSTR_OPEN_DRAIN), MP_OBJ_NEW_SMALL_INT(GPIO_MODE_OPEN_DRAIN) }, - { MP_OBJ_NEW_QSTR(MP_QSTR_PULL_NONE), MP_OBJ_NEW_SMALL_INT(GPIO_PULL_NONE) }, { MP_OBJ_NEW_QSTR(MP_QSTR_PULL_UP), MP_OBJ_NEW_SMALL_INT(GPIO_PULL_UP) }, //{ MP_OBJ_NEW_QSTR(MP_QSTR_PULL_DOWN), MP_OBJ_NEW_SMALL_INT(GPIO_PULL_DOWN) },