micropython: fix bug

This commit is contained in:
KY-zhang-X
2022-10-12 13:58:50 +08:00
parent 3e4ceb8afe
commit ed310f51bf
3 changed files with 8 additions and 6 deletions

View File

@@ -155,14 +155,14 @@ STATIC mp_obj_t machine_pin_obj_init_helper(machine_pin_obj_t *self, size_t n_ar
mp_raise_msg_varg(&mp_type_ValueError, MP_ERROR_TEXT("invalid pin mode: %d"), mode);
}
// if given, set the pin value before initialising to prevent glitches
// configure the GPIO as requested
mp_hal_pin_config(self, mode);
// set the pin value
if (args[ARG_value].u_obj != MP_OBJ_NULL) {
mp_hal_pin_write(self, mp_obj_is_true(args[ARG_value].u_obj));
}
// configure the GPIO as requested
mp_hal_pin_config(self, mode);
return mp_const_none;
}

View File

@@ -246,10 +246,10 @@ STATIC mp_obj_t esp8266_make_new(const mp_obj_type_t *type, size_t n_args, size_
esp8266_obj.uart = uart;
esp8266_obj.init = 1;
mod_network_register_nic(MP_OBJ_FROM_PTR(&esp8266_obj));
}
mod_network_register_nic(MP_OBJ_FROM_PTR(&esp8266_obj));
return MP_OBJ_FROM_PTR(&esp8266_obj);
}

View File

@@ -61,6 +61,8 @@
// #define MICROPY_STREAMS_POSIX_API (1)
#define MICROPY_MODULE_FROZEN_STR (0)
#define MICROPY_MODULE_FROZEN_MPY (0)
#define MICROPY_MODULE_WEAK_LINKS (1)
#define MICROPY_CAN_OVERRIDE_BUILTINS (1)
#define MICROPY_USE_INTERNAL_ERRNO (1)
#define MICROPY_USE_INTERNAL_PRINTF (0)
#define MICROPY_SCHEDULER_DEPTH (8)