From 1244125bdcf6500a01b24773cf798fe01eee4c63 Mon Sep 17 00:00:00 2001 From: Hierophect Date: Thu, 12 Dec 2019 12:21:00 -0500 Subject: [PATCH 01/10] update tinyusb --- lib/tinyusb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tinyusb b/lib/tinyusb index e413c9efa3..7a05b177a4 160000 --- a/lib/tinyusb +++ b/lib/tinyusb @@ -1 +1 @@ -Subproject commit e413c9efa303d70de019a91aa415384fe80ca78f +Subproject commit 7a05b177a43b368fea1d60ca344fe4ae9902a432 From 885a1415d0b9b223ce8f77ea4e4d773c2eb28a5c Mon Sep 17 00:00:00 2001 From: Hierophect Date: Thu, 12 Dec 2019 12:47:40 -0500 Subject: [PATCH 02/10] Update stm32 usb.c --- ports/stm32f4/supervisor/usb.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/ports/stm32f4/supervisor/usb.c b/ports/stm32f4/supervisor/usb.c index f327050f58..6e9b233a47 100644 --- a/ports/stm32f4/supervisor/usb.c +++ b/ports/stm32f4/supervisor/usb.c @@ -32,6 +32,8 @@ #include "lib/mp-readline/readline.h" #include "stm32f4xx_hal.h" +#include "py/mpconfig.h" + #include "common-hal/microcontroller/Pin.h" void init_usb_hardware(void) { @@ -79,7 +81,21 @@ void init_usb_hardware(void) { HAL_GPIO_Init(GPIOG, &GPIO_InitStruct); never_reset_pin_number(0, 8); #endif + +#ifdef BOARD_NO_VBUS + disable_usb_vbus(); +#endif /* Peripheral clock enable */ __HAL_RCC_USB_OTG_FS_CLK_ENABLE(); } + +STATIC void disable_usb_vbus(void) { +#ifdef USB_OTG_GCCFG_VBDEN + USB_OTG_FS->GCCFG &= ~USB_OTG_GCCFG_VBDEN; +#else + USB_OTG_FS->GCCFG |= USB_OTG_GCCFG_NOVBUSSENS; + USB_OTG_FS->GCCFG &= ~USB_OTG_GCCFG_VBUSBSEN; + USB_OTG_FS->GCCFG &= ~USB_OTG_GCCFG_VBUSASEN; +#endif +} From d44a758a2d9066dfb369ccdf1f6ed82e0b6e3c13 Mon Sep 17 00:00:00 2001 From: Hierophect Date: Thu, 12 Dec 2019 12:48:37 -0500 Subject: [PATCH 03/10] Add no VBUS option to blackpill --- ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.h | 1 + 1 file changed, 1 insertion(+) diff --git a/ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.h b/ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.h index a438b5baa6..b8e374f05b 100644 --- a/ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.h +++ b/ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.h @@ -33,6 +33,7 @@ #define FLASH_PAGE_SIZE (0x4000) #define BOARD_OSC_DIV 25 +#define BOARD_NO_VBUS // On-board flash // #define SPI_FLASH_MOSI_PIN (&pin_PA07) From 15072c69c9e940fa5cb0239fc821d2c0353f918e Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Fri, 13 Dec 2019 13:32:58 -0500 Subject: [PATCH 04/10] push changes --- extmod/modbtree.c | 3 ++- extmod/moductypes.c | 4 ++-- py/objlist.c | 8 +++----- py/objtype.c | 10 ++++++++-- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/extmod/modbtree.c b/extmod/modbtree.c index 97a4de3d5b..939ab813e4 100644 --- a/extmod/modbtree.c +++ b/extmod/modbtree.c @@ -248,7 +248,8 @@ STATIC mp_obj_t btree_iternext(mp_obj_t self_in) { #pragma GCC diagnostic ignored "-Wunused-parameter" STATIC mp_obj_t btree_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value, mp_obj_t instance) { - mp_obj_btree_t *self = MP_OBJ_TO_PTR(self_in); + //mp_obj_btree_t *self = MP_OBJ_TO_PTR(self_in); + mp_obj_btree_t *self = mp_instance_cast_to_native_base(self_in, &btree_type); if (value == MP_OBJ_NULL) { // delete DBT key; diff --git a/extmod/moductypes.c b/extmod/moductypes.c index 722f4bb872..145b348874 100644 --- a/extmod/moductypes.c +++ b/extmod/moductypes.c @@ -519,8 +519,8 @@ STATIC void uctypes_struct_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { } #pragma GCC diagnostic ignored "-Wunused-parameter" -STATIC mp_obj_t uctypes_struct_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value, mp_obj_t instance) { - mp_obj_uctypes_struct_t *self = MP_OBJ_TO_PTR(self_in); +STATIC mp_obj_t uctypes_struct_subscr(mp_obj_t base_in, mp_obj_t index_in, mp_obj_t value, mp_obj_t instance) { + mp_obj_uctypes_struct_t *self = mp_instance_cast_to_native_base(base_in, &uctypes_struct_type); if (value == MP_OBJ_NULL) { // delete diff --git a/py/objlist.c b/py/objlist.c index c544c27f05..0c0d60aa83 100644 --- a/py/objlist.c +++ b/py/objlist.c @@ -160,11 +160,11 @@ STATIC mp_obj_t list_binary_op(mp_binary_op_t op, mp_obj_t lhs, mp_obj_t rhs) { #pragma GCC diagnostic ignored "-Wunused-parameter" STATIC mp_obj_t list_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value, mp_obj_t instance) { + mp_obj_list_t *self = mp_instance_cast_to_native_base(self_in, &mp_type_list); if (value == MP_OBJ_NULL) { // delete #if MICROPY_PY_BUILTINS_SLICE if (MP_OBJ_IS_TYPE(index, &mp_type_slice)) { - mp_obj_list_t *self = MP_OBJ_TO_PTR(self_in); mp_bound_slice_t slice; if (!mp_seq_get_fast_slice_indexes(self->len, index, &slice)) { mp_raise_NotImplementedError(NULL); @@ -180,12 +180,11 @@ STATIC mp_obj_t list_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value, mp return mp_const_none; } #endif - mp_obj_t args[2] = {self_in, index}; + mp_obj_t args[2] = {self, index}; list_pop(2, args); return mp_const_none; } else if (value == MP_OBJ_SENTINEL) { // load - mp_obj_list_t *self = MP_OBJ_TO_PTR(self_in); #if MICROPY_PY_BUILTINS_SLICE if (MP_OBJ_IS_TYPE(index, &mp_type_slice)) { mp_bound_slice_t slice; @@ -202,7 +201,6 @@ STATIC mp_obj_t list_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value, mp } else { #if MICROPY_PY_BUILTINS_SLICE if (MP_OBJ_IS_TYPE(index, &mp_type_slice)) { - mp_obj_list_t *self = MP_OBJ_TO_PTR(self_in); size_t value_len; mp_obj_t *value_items; mp_obj_get_array(value, &value_len, &value_items); mp_bound_slice_t slice_out; @@ -231,7 +229,7 @@ STATIC mp_obj_t list_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value, mp return mp_const_none; } #endif - mp_obj_list_store(self_in, index, value); + mp_obj_list_store(self, index, value); return mp_const_none; } } diff --git a/py/objtype.c b/py/objtype.c index 9608a9242d..c7dc2ae78f 100644 --- a/py/objtype.c +++ b/py/objtype.c @@ -34,6 +34,7 @@ #include "py/objtype.h" #include "py/runtime.h" +#include "supervisor/shared/stack.h" #include "supervisor/shared/translate.h" #if MICROPY_DEBUG_VERBOSE // print debugging info @@ -851,8 +852,13 @@ STATIC mp_obj_t instance_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value mp_obj_class_lookup(&lookup, self->base.type); meth_args = 3; } - if (member[0] == MP_OBJ_SENTINEL) { - return mp_obj_subscr(self->subobj[0], index, value, instance); + if (member[0] == MP_OBJ_SENTINEL) { // native base subscr exists + mp_obj_type_t *subobj_type = mp_obj_get_type(self->subobj[0]); + // return mp_obj_subscr(self->subobj[0], index, value, instance); + mp_obj_t ret = subobj_type->subscr(self_in, index, value, instance); + // May have called port specific C code. Make sure it didn't mess up the heap. + assert_heap_ok(); + return ret; } else if (member[0] != MP_OBJ_NULL) { mp_obj_t args[3] = {self_in, index, value}; // TODO probably need to call mp_convert_member_lookup, and use mp_call_method_n_kw From dc8dd6df20f4904917169f4ec1172c8f3827e822 Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Fri, 13 Dec 2019 14:29:15 -0500 Subject: [PATCH 05/10] Revert subscr signature change --- extmod/machine_mem.c | 2 +- extmod/modbtree.c | 2 +- extmod/moductypes.c | 2 +- extmod/modurandom.c | 2 +- extmod/vfs.c | 2 +- ports/unix/modjni.c | 4 ++-- py/obj.c | 6 +++--- py/obj.h | 4 ++-- py/objarray.c | 3 +-- py/objdict.c | 2 +- py/objlist.c | 2 +- py/objrange.c | 2 +- py/objreversed.c | 2 +- py/objstr.c | 2 +- py/objstrunicode.c | 2 +- py/objtuple.c | 2 +- py/objtuple.h | 2 +- py/objtype.c | 4 ++-- py/opmethods.c | 6 +++--- py/vm.c | 4 ++-- shared-bindings/_pixelbuf/PixelBuf.c | 6 +++--- shared-bindings/displayio/Bitmap.c | 2 +- shared-bindings/displayio/Group.c | 2 +- shared-bindings/displayio/Palette.c | 2 +- shared-bindings/displayio/TileGrid.c | 2 +- shared-bindings/nvm/ByteArray.c | 2 +- shared-bindings/pulseio/PulseIn.c | 2 +- shared-bindings/random/__init__.c | 2 +- shared-module/os/__init__.c | 2 +- 29 files changed, 39 insertions(+), 40 deletions(-) diff --git a/extmod/machine_mem.c b/extmod/machine_mem.c index 826c59d0f0..75496c6b5f 100644 --- a/extmod/machine_mem.c +++ b/extmod/machine_mem.c @@ -61,7 +61,7 @@ STATIC void machine_mem_print(const mp_print_t *print, mp_obj_t self_in, mp_prin } #pragma GCC diagnostic ignored "-Wunused-parameter" -STATIC mp_obj_t machine_mem_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value, mp_obj_t instance) { +STATIC mp_obj_t machine_mem_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { // TODO support slice index to read/write multiple values at once machine_mem_obj_t *self = MP_OBJ_TO_PTR(self_in); if (value == MP_OBJ_NULL) { diff --git a/extmod/modbtree.c b/extmod/modbtree.c index 939ab813e4..ad845163d6 100644 --- a/extmod/modbtree.c +++ b/extmod/modbtree.c @@ -247,7 +247,7 @@ STATIC mp_obj_t btree_iternext(mp_obj_t self_in) { } #pragma GCC diagnostic ignored "-Wunused-parameter" -STATIC mp_obj_t btree_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value, mp_obj_t instance) { +STATIC mp_obj_t btree_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { //mp_obj_btree_t *self = MP_OBJ_TO_PTR(self_in); mp_obj_btree_t *self = mp_instance_cast_to_native_base(self_in, &btree_type); if (value == MP_OBJ_NULL) { diff --git a/extmod/moductypes.c b/extmod/moductypes.c index 145b348874..bf5f1cef73 100644 --- a/extmod/moductypes.c +++ b/extmod/moductypes.c @@ -519,7 +519,7 @@ STATIC void uctypes_struct_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { } #pragma GCC diagnostic ignored "-Wunused-parameter" -STATIC mp_obj_t uctypes_struct_subscr(mp_obj_t base_in, mp_obj_t index_in, mp_obj_t value, mp_obj_t instance) { +STATIC mp_obj_t uctypes_struct_subscr(mp_obj_t base_in, mp_obj_t index_in, mp_obj_t value) { mp_obj_uctypes_struct_t *self = mp_instance_cast_to_native_base(base_in, &uctypes_struct_type); if (value == MP_OBJ_NULL) { diff --git a/extmod/modurandom.c b/extmod/modurandom.c index 101c80cf8a..1512a3fd4a 100644 --- a/extmod/modurandom.c +++ b/extmod/modurandom.c @@ -150,7 +150,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_urandom_randint_obj, mod_urandom_randint); STATIC mp_obj_t mod_urandom_choice(mp_obj_t seq) { mp_int_t len = mp_obj_get_int(mp_obj_len(seq)); if (len > 0) { - return mp_obj_subscr(seq, mp_obj_new_int(yasmarang_randbelow(len)), MP_OBJ_SENTINEL, seq); + return mp_obj_subscr(seq, mp_obj_new_int(yasmarang_randbelow(len)), MP_OBJ_SENTINEL); } else { nlr_raise(mp_obj_new_exception(&mp_type_IndexError)); } diff --git a/extmod/vfs.c b/extmod/vfs.c index 4d344095a6..2bb4057e7e 100644 --- a/extmod/vfs.c +++ b/extmod/vfs.c @@ -373,7 +373,7 @@ mp_obj_t mp_vfs_listdir(size_t n_args, const mp_obj_t *args) { mp_obj_t dir_list = mp_obj_new_list(0, NULL); mp_obj_t next; while ((next = mp_iternext(iter)) != MP_OBJ_STOP_ITERATION) { - mp_obj_list_append(dir_list, mp_obj_subscr(next, MP_OBJ_NEW_SMALL_INT(0), MP_OBJ_SENTINEL, next)); + mp_obj_list_append(dir_list, mp_obj_subscr(next, MP_OBJ_NEW_SMALL_INT(0), MP_OBJ_SENTINEL)); } return dir_list; } diff --git a/ports/unix/modjni.c b/ports/unix/modjni.c index 8f0eac5a9d..e18a26f3c6 100644 --- a/ports/unix/modjni.c +++ b/ports/unix/modjni.c @@ -242,7 +242,7 @@ STATIC void get_jclass_name(jobject obj, char *buf) { } #pragma GCC diagnostic ignored "-Wunused-parameter" -STATIC mp_obj_t jobject_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value, mp_obj_t instance) { +STATIC mp_obj_t jobject_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { mp_obj_jobject_t *self = self_in; mp_uint_t idx = mp_obj_get_int(index); char class_name[64]; @@ -311,7 +311,7 @@ STATIC mp_obj_t jobject_unary_op(mp_unary_op_t op, mp_obj_t self_in) { // TODO: subscr_load_adaptor & subscr_getiter convenience functions // should be moved to common location for reuse. STATIC mp_obj_t subscr_load_adaptor(mp_obj_t self_in, mp_obj_t index_in) { - return mp_obj_subscr(self_in, index_in, MP_OBJ_SENTINEL, self_in); + return mp_obj_subscr(self_in, index_in, MP_OBJ_SENTINEL); } MP_DEFINE_CONST_FUN_OBJ_2(subscr_load_adaptor_obj, subscr_load_adaptor); diff --git a/py/obj.c b/py/obj.c index 47aa1aebfc..09e71be4d6 100644 --- a/py/obj.c +++ b/py/obj.c @@ -487,11 +487,11 @@ mp_obj_t mp_obj_len_maybe(mp_obj_t o_in) { } } -mp_obj_t mp_obj_subscr(mp_obj_t base, mp_obj_t index, mp_obj_t value, mp_obj_t instance) { +mp_obj_t mp_obj_subscr(mp_obj_t base, mp_obj_t index, mp_obj_t value) { mp_obj_type_t *type = mp_obj_get_type(base); if (type->subscr != NULL) { - mp_obj_t ret = type->subscr(base, index, value, instance); + mp_obj_t ret = type->subscr(base, index, value); // May have called port specific C code. Make sure it didn't mess up the heap. assert_heap_ok(); if (ret != MP_OBJ_NULL) { @@ -546,7 +546,7 @@ STATIC mp_obj_t generic_it_iternext(mp_obj_t self_in) { mp_obj_type_t *type = mp_obj_get_type(self->obj); mp_obj_t current_length = type->unary_op(MP_UNARY_OP_LEN, self->obj); if (self->cur < MP_OBJ_SMALL_INT_VALUE(current_length)) { - mp_obj_t o_out = type->subscr(self->obj, MP_OBJ_NEW_SMALL_INT(self->cur), MP_OBJ_SENTINEL, self->obj); + mp_obj_t o_out = type->subscr(self->obj, MP_OBJ_NEW_SMALL_INT(self->cur), MP_OBJ_SENTINEL); self->cur += 1; return o_out; } else { diff --git a/py/obj.h b/py/obj.h index ff97b34d83..cf4216d02f 100644 --- a/py/obj.h +++ b/py/obj.h @@ -444,7 +444,7 @@ typedef mp_obj_t (*mp_call_fun_t)(mp_obj_t fun, size_t n_args, size_t n_kw, cons typedef mp_obj_t (*mp_unary_op_fun_t)(mp_unary_op_t op, mp_obj_t); typedef mp_obj_t (*mp_binary_op_fun_t)(mp_binary_op_t op, mp_obj_t, mp_obj_t); typedef void (*mp_attr_fun_t)(mp_obj_t self_in, qstr attr, mp_obj_t *dest); -typedef mp_obj_t (*mp_subscr_fun_t)(mp_obj_t self_in, mp_obj_t index, mp_obj_t value, mp_obj_t instance); +typedef mp_obj_t (*mp_subscr_fun_t)(mp_obj_t self_in, mp_obj_t index, mp_obj_t value); typedef mp_obj_t (*mp_getiter_fun_t)(mp_obj_t self_in, mp_obj_iter_buf_t *iter_buf); // Buffer protocol @@ -707,7 +707,7 @@ size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, bool mp_obj_t mp_obj_id(mp_obj_t o_in); mp_obj_t mp_obj_len(mp_obj_t o_in); mp_obj_t mp_obj_len_maybe(mp_obj_t o_in); // may return MP_OBJ_NULL -mp_obj_t mp_obj_subscr(mp_obj_t base, mp_obj_t index, mp_obj_t val, mp_obj_t instance); +mp_obj_t mp_obj_subscr(mp_obj_t base, mp_obj_t index, mp_obj_t val); mp_obj_t mp_generic_unary_op(mp_unary_op_t op, mp_obj_t o_in); // cell diff --git a/py/objarray.c b/py/objarray.c index 6fffa84125..9114a63c5a 100644 --- a/py/objarray.c +++ b/py/objarray.c @@ -396,8 +396,7 @@ STATIC mp_obj_t array_extend(mp_obj_t self_in, mp_obj_t arg_in) { STATIC MP_DEFINE_CONST_FUN_OBJ_2(array_extend_obj, array_extend); #endif -#pragma GCC diagnostic ignored "-Wunused-parameter" -STATIC mp_obj_t array_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value, mp_obj_t instance) { +STATIC mp_obj_t array_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value) { if (value == MP_OBJ_NULL) { // delete item // TODO implement diff --git a/py/objdict.c b/py/objdict.c index 2c07331e7c..5bbe939b1d 100644 --- a/py/objdict.c +++ b/py/objdict.c @@ -175,7 +175,7 @@ mp_obj_t mp_obj_dict_get(mp_obj_t self_in, mp_obj_t index) { } #pragma GCC diagnostic ignored "-Wunused-parameter" -STATIC mp_obj_t dict_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value, mp_obj_t instance) { +STATIC mp_obj_t dict_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { if (value == MP_OBJ_NULL) { // delete mp_obj_dict_delete(self_in, index); diff --git a/py/objlist.c b/py/objlist.c index 0c0d60aa83..64381bc706 100644 --- a/py/objlist.c +++ b/py/objlist.c @@ -159,7 +159,7 @@ STATIC mp_obj_t list_binary_op(mp_binary_op_t op, mp_obj_t lhs, mp_obj_t rhs) { } #pragma GCC diagnostic ignored "-Wunused-parameter" -STATIC mp_obj_t list_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value, mp_obj_t instance) { +STATIC mp_obj_t list_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { mp_obj_list_t *self = mp_instance_cast_to_native_base(self_in, &mp_type_list); if (value == MP_OBJ_NULL) { // delete diff --git a/py/objrange.c b/py/objrange.c index 328416303d..6f14bcc9f9 100644 --- a/py/objrange.c +++ b/py/objrange.c @@ -159,7 +159,7 @@ STATIC mp_obj_t range_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs #endif #pragma GCC diagnostic ignored "-Wunused-parameter" -STATIC mp_obj_t range_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value, mp_obj_t instance) { +STATIC mp_obj_t range_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { if (value == MP_OBJ_SENTINEL) { // load mp_obj_range_t *self = MP_OBJ_TO_PTR(self_in); diff --git a/py/objreversed.c b/py/objreversed.c index 0b21e69380..4937d08189 100644 --- a/py/objreversed.c +++ b/py/objreversed.c @@ -66,7 +66,7 @@ STATIC mp_obj_t reversed_iternext(mp_obj_t self_in) { // pre-decrement and index sequence self->cur_index -= 1; - return mp_obj_subscr(self->seq, MP_OBJ_NEW_SMALL_INT(self->cur_index), MP_OBJ_SENTINEL, self->seq); + return mp_obj_subscr(self->seq, MP_OBJ_NEW_SMALL_INT(self->cur_index), MP_OBJ_SENTINEL); } const mp_obj_type_t mp_type_reversed = { diff --git a/py/objstr.c b/py/objstr.c index fd802fe852..567e734442 100644 --- a/py/objstr.c +++ b/py/objstr.c @@ -440,7 +440,7 @@ const byte *str_index_to_ptr(const mp_obj_type_t *type, const byte *self_data, s // This is used for both bytes and 8-bit strings. This is not used for unicode strings. #pragma GCC diagnostic ignored "-Wunused-parameter" -STATIC mp_obj_t bytes_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value, mp_obj_t instance) { +STATIC mp_obj_t bytes_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { mp_obj_type_t *type = mp_obj_get_type(self_in); GET_STR_DATA_LEN(self_in, self_data, self_len); if (value == MP_OBJ_SENTINEL) { diff --git a/py/objstrunicode.c b/py/objstrunicode.c index dc8c0743d3..2540a1d7b6 100644 --- a/py/objstrunicode.c +++ b/py/objstrunicode.c @@ -198,7 +198,7 @@ const byte *str_index_to_ptr(const mp_obj_type_t *type, const byte *self_data, s } #pragma GCC diagnostic ignored "-Wunused-parameter" -STATIC mp_obj_t str_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value, mp_obj_t instance) { +STATIC mp_obj_t str_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { mp_obj_type_t *type = mp_obj_get_type(self_in); assert(type == &mp_type_str); GET_STR_DATA_LEN(self_in, self_data, self_len); diff --git a/py/objtuple.c b/py/objtuple.c index b6640def51..7a4c09ab70 100644 --- a/py/objtuple.c +++ b/py/objtuple.c @@ -178,7 +178,7 @@ mp_obj_t mp_obj_tuple_binary_op(mp_binary_op_t op, mp_obj_t lhs, mp_obj_t rhs) { } #pragma GCC diagnostic ignored "-Wunused-parameter" -mp_obj_t mp_obj_tuple_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value, mp_obj_t instance) { +mp_obj_t mp_obj_tuple_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { if (value == MP_OBJ_SENTINEL) { // load mp_obj_tuple_t *self = MP_OBJ_TO_PTR(self_in); diff --git a/py/objtuple.h b/py/objtuple.h index 4df3aeded9..7f20ab7b6f 100644 --- a/py/objtuple.h +++ b/py/objtuple.h @@ -45,7 +45,7 @@ extern const mp_obj_type_t mp_type_tuple; void mp_obj_tuple_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind); mp_obj_t mp_obj_tuple_unary_op(mp_unary_op_t op, mp_obj_t self_in); mp_obj_t mp_obj_tuple_binary_op(mp_binary_op_t op, mp_obj_t lhs, mp_obj_t rhs); -mp_obj_t mp_obj_tuple_subscr(mp_obj_t base, mp_obj_t index, mp_obj_t value, mp_obj_t instance); +mp_obj_t mp_obj_tuple_subscr(mp_obj_t base, mp_obj_t index, mp_obj_t value); mp_obj_t mp_obj_tuple_getiter(mp_obj_t o_in, mp_obj_iter_buf_t *iter_buf); extern const mp_obj_type_t mp_type_attrtuple; diff --git a/py/objtype.c b/py/objtype.c index c7dc2ae78f..a5e733208c 100644 --- a/py/objtype.c +++ b/py/objtype.c @@ -826,7 +826,7 @@ STATIC void mp_obj_instance_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { } } -STATIC mp_obj_t instance_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value, mp_obj_t instance) { +STATIC mp_obj_t instance_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { mp_obj_instance_t *self = MP_OBJ_TO_PTR(self_in); mp_obj_t member[2] = {MP_OBJ_NULL}; struct class_lookup_data lookup = { @@ -855,7 +855,7 @@ STATIC mp_obj_t instance_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value if (member[0] == MP_OBJ_SENTINEL) { // native base subscr exists mp_obj_type_t *subobj_type = mp_obj_get_type(self->subobj[0]); // return mp_obj_subscr(self->subobj[0], index, value, instance); - mp_obj_t ret = subobj_type->subscr(self_in, index, value, instance); + mp_obj_t ret = subobj_type->subscr(self_in, index, value); // May have called port specific C code. Make sure it didn't mess up the heap. assert_heap_ok(); return ret; diff --git a/py/opmethods.c b/py/opmethods.c index d906ddb6a3..247fa5bbc8 100644 --- a/py/opmethods.c +++ b/py/opmethods.c @@ -29,19 +29,19 @@ STATIC mp_obj_t op_getitem(mp_obj_t self_in, mp_obj_t key_in) { mp_obj_type_t *type = mp_obj_get_type(self_in); - return type->subscr(self_in, key_in, MP_OBJ_SENTINEL, self_in); + return type->subscr(self_in, key_in, MP_OBJ_SENTINEL); } MP_DEFINE_CONST_FUN_OBJ_2(mp_op_getitem_obj, op_getitem); STATIC mp_obj_t op_setitem(mp_obj_t self_in, mp_obj_t key_in, mp_obj_t value_in) { mp_obj_type_t *type = mp_obj_get_type(self_in); - return type->subscr(self_in, key_in, value_in, self_in); + return type->subscr(self_in, key_in, value_in); } MP_DEFINE_CONST_FUN_OBJ_3(mp_op_setitem_obj, op_setitem); STATIC mp_obj_t op_delitem(mp_obj_t self_in, mp_obj_t key_in) { mp_obj_type_t *type = mp_obj_get_type(self_in); - return type->subscr(self_in, key_in, MP_OBJ_NULL, self_in); + return type->subscr(self_in, key_in, MP_OBJ_NULL); } MP_DEFINE_CONST_FUN_OBJ_2(mp_op_delitem_obj, op_delitem); diff --git a/py/vm.c b/py/vm.c index 2fe8d32370..353fc88100 100644 --- a/py/vm.c +++ b/py/vm.c @@ -386,7 +386,7 @@ dispatch_loop: ENTRY(MP_BC_LOAD_SUBSCR): { MARK_EXC_IP_SELECTIVE(); mp_obj_t index = POP(); - SET_TOP(mp_obj_subscr(TOP(), index, MP_OBJ_SENTINEL, TOP())); + SET_TOP(mp_obj_subscr(TOP(), index, MP_OBJ_SENTINEL)); DISPATCH(); } @@ -464,7 +464,7 @@ dispatch_loop: ENTRY(MP_BC_STORE_SUBSCR): MARK_EXC_IP_SELECTIVE(); - mp_obj_subscr(sp[-1], sp[0], sp[-2], sp[-1]); + mp_obj_subscr(sp[-1], sp[0], sp[-2]); sp -= 3; DISPATCH(); diff --git a/shared-bindings/_pixelbuf/PixelBuf.c b/shared-bindings/_pixelbuf/PixelBuf.c index feda2c573a..a3579c92c0 100644 --- a/shared-bindings/_pixelbuf/PixelBuf.c +++ b/shared-bindings/_pixelbuf/PixelBuf.c @@ -368,7 +368,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(pixelbuf_pixelbuf_fill_obj, pixelbuf_pixelbuf_f //| //| Sets the pixel value at the given index. //| -STATIC mp_obj_t pixelbuf_pixelbuf_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value, mp_obj_t instance) { +STATIC mp_obj_t pixelbuf_pixelbuf_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value) { if (value == MP_OBJ_NULL) { // delete item // slice deletion @@ -431,7 +431,7 @@ STATIC mp_obj_t pixelbuf_pixelbuf_subscr(mp_obj_t self_in, mp_obj_t index_in, mp } } if (self->auto_write) - call_show(instance); + call_show(self_in); return mp_const_none; #else return MP_OBJ_NULL; // op not supported @@ -451,7 +451,7 @@ STATIC mp_obj_t pixelbuf_pixelbuf_subscr(mp_obj_t self_in, mp_obj_t index_in, mp pixelbuf_set_pixel(self->buf + offset, self->two_buffers ? self->rawbuf + offset : NULL, self->brightness, value, &self->byteorder, self->byteorder.is_dotstar); if (self->auto_write) - call_show(instance); + call_show(self_in); return mp_const_none; } } diff --git a/shared-bindings/displayio/Bitmap.c b/shared-bindings/displayio/Bitmap.c index 7c77d05eda..ca9484a408 100644 --- a/shared-bindings/displayio/Bitmap.c +++ b/shared-bindings/displayio/Bitmap.c @@ -134,7 +134,7 @@ const mp_obj_property_t displayio_bitmap_height_obj = { //| bitmap[0,1] = 3 //| #pragma GCC diagnostic ignored "-Wunused-parameter" -STATIC mp_obj_t bitmap_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t value_obj, mp_obj_t instance) { +STATIC mp_obj_t bitmap_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t value_obj) { if (value_obj == mp_const_none) { // delete item mp_raise_AttributeError(translate("Cannot delete values")); diff --git a/shared-bindings/displayio/Group.c b/shared-bindings/displayio/Group.c index 40f2704c05..f5e3c22634 100644 --- a/shared-bindings/displayio/Group.c +++ b/shared-bindings/displayio/Group.c @@ -311,7 +311,7 @@ STATIC mp_obj_t group_unary_op(mp_unary_op_t op, mp_obj_t self_in) { //| del group[0] //| #pragma GCC diagnostic ignored "-Wunused-parameter" -STATIC mp_obj_t group_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t value, mp_obj_t instance) { +STATIC mp_obj_t group_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t value) { displayio_group_t *self = native_group(self_in); if (MP_OBJ_IS_TYPE(index_obj, &mp_type_slice)) { diff --git a/shared-bindings/displayio/Palette.c b/shared-bindings/displayio/Palette.c index 2fa65867aa..903338abb2 100644 --- a/shared-bindings/displayio/Palette.c +++ b/shared-bindings/displayio/Palette.c @@ -96,7 +96,7 @@ STATIC mp_obj_t group_unary_op(mp_unary_op_t op, mp_obj_t self_in) { //| palette[3] = bytearray(b'\x00\x00\xFF') # set using a bytearay of 3 or 4 bytes //| #pragma GCC diagnostic ignored "-Wunused-parameter" -STATIC mp_obj_t palette_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value, mp_obj_t instance) { +STATIC mp_obj_t palette_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value) { if (value == MP_OBJ_NULL) { // delete item return MP_OBJ_NULL; // op not supported diff --git a/shared-bindings/displayio/TileGrid.c b/shared-bindings/displayio/TileGrid.c index 5acf8496f8..288eb4b236 100644 --- a/shared-bindings/displayio/TileGrid.c +++ b/shared-bindings/displayio/TileGrid.c @@ -349,7 +349,7 @@ const mp_obj_property_t displayio_tilegrid_pixel_shader_obj = { //| //| grid[0,0] = 10 //| -STATIC mp_obj_t tilegrid_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t value_obj, mp_obj_t instance) { +STATIC mp_obj_t tilegrid_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t value_obj) { displayio_tilegrid_t *self = native_tilegrid(self_in); diff --git a/shared-bindings/nvm/ByteArray.c b/shared-bindings/nvm/ByteArray.c index 5ac46b260c..31bedeacc0 100644 --- a/shared-bindings/nvm/ByteArray.c +++ b/shared-bindings/nvm/ByteArray.c @@ -70,7 +70,7 @@ STATIC const mp_rom_map_elem_t nvm_bytearray_locals_dict_table[] = { STATIC MP_DEFINE_CONST_DICT(nvm_bytearray_locals_dict, nvm_bytearray_locals_dict_table); -STATIC mp_obj_t nvm_bytearray_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value, mp_obj_t instance) { +STATIC mp_obj_t nvm_bytearray_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value) { if (value == MP_OBJ_NULL) { // delete item // slice deletion diff --git a/shared-bindings/pulseio/PulseIn.c b/shared-bindings/pulseio/PulseIn.c index 5947329a54..8b69109f04 100644 --- a/shared-bindings/pulseio/PulseIn.c +++ b/shared-bindings/pulseio/PulseIn.c @@ -272,7 +272,7 @@ STATIC mp_obj_t pulsein_unary_op(mp_unary_op_t op, mp_obj_t self_in) { //| pulses = pulseio.PulseIn(pin) //| print(pulses[0]) //| -STATIC mp_obj_t pulsein_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t value, mp_obj_t instance) { +STATIC mp_obj_t pulsein_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t value) { if (value == mp_const_none) { // delete item mp_raise_AttributeError(translate("Cannot delete values")); diff --git a/shared-bindings/random/__init__.c b/shared-bindings/random/__init__.c index fdef914438..83698eac57 100644 --- a/shared-bindings/random/__init__.c +++ b/shared-bindings/random/__init__.c @@ -145,7 +145,7 @@ STATIC mp_obj_t random_choice(mp_obj_t seq) { if (len == 0) { mp_raise_IndexError(translate("empty sequence")); } - return mp_obj_subscr(seq, mp_obj_new_int(shared_modules_random_randrange(0, len, 1)), MP_OBJ_SENTINEL, seq); + return mp_obj_subscr(seq, mp_obj_new_int(shared_modules_random_randrange(0, len, 1)), MP_OBJ_SENTINEL); } STATIC MP_DEFINE_CONST_FUN_OBJ_1(random_choice_obj, random_choice); diff --git a/shared-module/os/__init__.c b/shared-module/os/__init__.c index ad76251c81..8060eec4f3 100644 --- a/shared-module/os/__init__.c +++ b/shared-module/os/__init__.c @@ -127,7 +127,7 @@ mp_obj_t common_hal_os_listdir(const char* path) { mp_obj_t next; while ((next = mp_iternext(iter_obj)) != MP_OBJ_STOP_ITERATION) { // next[0] is the filename. - mp_obj_list_append(dir_list, mp_obj_subscr(next, MP_OBJ_NEW_SMALL_INT(0), MP_OBJ_SENTINEL, dir_list)); + mp_obj_list_append(dir_list, mp_obj_subscr(next, MP_OBJ_NEW_SMALL_INT(0), MP_OBJ_SENTINEL)); RUN_BACKGROUND_TASKS; } return dir_list; From 7f7105d36d5775e6b7842a24f06604a229b2aae3 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Fri, 13 Dec 2019 14:52:04 -0800 Subject: [PATCH 06/10] Fix tuple test --- py/objtuple.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py/objtuple.c b/py/objtuple.c index 7a4c09ab70..cc69f5469c 100644 --- a/py/objtuple.c +++ b/py/objtuple.c @@ -181,7 +181,7 @@ mp_obj_t mp_obj_tuple_binary_op(mp_binary_op_t op, mp_obj_t lhs, mp_obj_t rhs) { mp_obj_t mp_obj_tuple_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { if (value == MP_OBJ_SENTINEL) { // load - mp_obj_tuple_t *self = MP_OBJ_TO_PTR(self_in); + mp_obj_tuple_t *self = mp_instance_cast_to_native_base(self_in, MP_OBJ_FROM_PTR(&mp_type_tuple)); #if MICROPY_PY_BUILTINS_SLICE if (MP_OBJ_IS_TYPE(index, &mp_type_slice)) { mp_bound_slice_t slice; From d8e66a5f32749f29f5274432c616b2bd001dc7b3 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Fri, 13 Dec 2019 16:00:04 -0800 Subject: [PATCH 07/10] try 2. make namedtuple types handle subclasses --- py/objnamedtuple.c | 12 +++++++++++- py/objnamedtuple.h | 1 + py/objtuple.c | 3 ++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/py/objnamedtuple.c b/py/objnamedtuple.c index a044fe3ff8..a0a64f9b25 100644 --- a/py/objnamedtuple.c +++ b/py/objnamedtuple.c @@ -31,6 +31,7 @@ #include "py/runtime.h" #include "py/objstr.h" #include "py/objnamedtuple.h" +#include "py/objtype.h" #include "supervisor/shared/translate.h" @@ -70,6 +71,15 @@ void namedtuple_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t ki mp_obj_attrtuple_print_helper(print, fields, &o->tuple); } +mp_obj_t namedtuple_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { + mp_obj_type_t *type = mp_obj_get_type(self_in); + // Check for subclasses of namedtuple and unpack if needed. + if (type->parent != &mp_type_tuple) { + self_in = ((mp_obj_instance_t*) self_in)->subobj[0]; + } + return mp_obj_tuple_subscr(self_in, index, value); +} + void namedtuple_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { if (dest[0] == MP_OBJ_NULL) { // load attribute @@ -167,7 +177,7 @@ STATIC mp_obj_t mp_obj_new_namedtuple_type(qstr name, size_t n_fields, mp_obj_t o->base.unary_op = mp_obj_tuple_unary_op; o->base.binary_op = mp_obj_tuple_binary_op; o->base.attr = namedtuple_attr; - o->base.subscr = mp_obj_tuple_subscr; + o->base.subscr = namedtuple_subscr; o->base.getiter = mp_obj_tuple_getiter; o->base.parent = &mp_type_tuple; return MP_OBJ_FROM_PTR(o); diff --git a/py/objnamedtuple.h b/py/objnamedtuple.h index 0ea0d28622..5a7512e3a6 100644 --- a/py/objnamedtuple.h +++ b/py/objnamedtuple.h @@ -49,6 +49,7 @@ typedef struct _mp_obj_namedtuple_t { void namedtuple_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind); size_t mp_obj_namedtuple_find_field(const mp_obj_namedtuple_type_t *type, qstr name); +mp_obj_t namedtuple_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value); void namedtuple_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest); mp_obj_namedtuple_type_t *mp_obj_new_namedtuple_base(size_t n_fields, mp_obj_t *fields); mp_obj_t namedtuple_make_new(const mp_obj_type_t *type_in, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args); diff --git a/py/objtuple.c b/py/objtuple.c index cc69f5469c..b7f50d3b2c 100644 --- a/py/objtuple.c +++ b/py/objtuple.c @@ -179,9 +179,10 @@ mp_obj_t mp_obj_tuple_binary_op(mp_binary_op_t op, mp_obj_t lhs, mp_obj_t rhs) { #pragma GCC diagnostic ignored "-Wunused-parameter" mp_obj_t mp_obj_tuple_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { + if (value == MP_OBJ_SENTINEL) { // load - mp_obj_tuple_t *self = mp_instance_cast_to_native_base(self_in, MP_OBJ_FROM_PTR(&mp_type_tuple)); + mp_obj_tuple_t *self = MP_OBJ_TO_PTR(self_in); #if MICROPY_PY_BUILTINS_SLICE if (MP_OBJ_IS_TYPE(index, &mp_type_slice)) { mp_bound_slice_t slice; From ebc21144b8dc98dde7daf3f3832bdb33a5d8fc7d Mon Sep 17 00:00:00 2001 From: hathach Date: Tue, 17 Dec 2019 10:55:19 +0700 Subject: [PATCH 08/10] stm32 explicitily enable/disable vbus sense, fix warning --- ports/stm32f4/supervisor/usb.c | 37 ++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/ports/stm32f4/supervisor/usb.c b/ports/stm32f4/supervisor/usb.c index 6e9b233a47..23fff1a36b 100644 --- a/ports/stm32f4/supervisor/usb.c +++ b/ports/stm32f4/supervisor/usb.c @@ -36,6 +36,29 @@ #include "common-hal/microcontroller/Pin.h" +STATIC void init_usb_vbus_sense(void) { + +#ifdef BOARD_NO_VBUS + // Disable VBUS sensing + #ifdef USB_OTG_GCCFG_VBDEN + USB_OTG_FS->GCCFG &= ~USB_OTG_GCCFG_VBDEN; + #else + USB_OTG_FS->GCCFG |= USB_OTG_GCCFG_NOVBUSSENS; + USB_OTG_FS->GCCFG &= ~USB_OTG_GCCFG_VBUSBSEN; + USB_OTG_FS->GCCFG &= ~USB_OTG_GCCFG_VBUSASEN; + #endif +#else + // Enable VBUS hardware sensing + #ifdef USB_OTG_GCCFG_VBDEN + USB_OTG_FS->GCCFG |= USB_OTG_GCCFG_VBDEN; + #else + USB_OTG_FS->GCCFG &= ~USB_OTG_GCCFG_NOVBUSSENS; + USB_OTG_FS->GCCFG |= USB_OTG_GCCFG_VBUSBSEN; // B Device sense + #endif +#endif +} + + void init_usb_hardware(void) { //TODO: if future chips overload this with options, move to peripherals management. @@ -82,20 +105,8 @@ void init_usb_hardware(void) { never_reset_pin_number(0, 8); #endif -#ifdef BOARD_NO_VBUS - disable_usb_vbus(); -#endif - /* Peripheral clock enable */ __HAL_RCC_USB_OTG_FS_CLK_ENABLE(); -} -STATIC void disable_usb_vbus(void) { -#ifdef USB_OTG_GCCFG_VBDEN - USB_OTG_FS->GCCFG &= ~USB_OTG_GCCFG_VBDEN; -#else - USB_OTG_FS->GCCFG |= USB_OTG_GCCFG_NOVBUSSENS; - USB_OTG_FS->GCCFG &= ~USB_OTG_GCCFG_VBUSBSEN; - USB_OTG_FS->GCCFG &= ~USB_OTG_GCCFG_VBUSASEN; -#endif + init_usb_vbus_sense(); } From b49ecc52b9e41cbcc6943649217d8abea29b30a6 Mon Sep 17 00:00:00 2001 From: Hierophect Date: Mon, 23 Dec 2019 14:55:26 -0500 Subject: [PATCH 09/10] text fixes --- ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.h | 2 +- ports/stm32f4/supervisor/usb.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.h b/ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.h index b8e374f05b..05e2a384a1 100644 --- a/ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.h +++ b/ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.h @@ -33,7 +33,7 @@ #define FLASH_PAGE_SIZE (0x4000) #define BOARD_OSC_DIV 25 -#define BOARD_NO_VBUS +#define BOARD_NO_VBUS_SENSE // On-board flash // #define SPI_FLASH_MOSI_PIN (&pin_PA07) diff --git a/ports/stm32f4/supervisor/usb.c b/ports/stm32f4/supervisor/usb.c index 23fff1a36b..0d2d5cce9d 100644 --- a/ports/stm32f4/supervisor/usb.c +++ b/ports/stm32f4/supervisor/usb.c @@ -38,7 +38,7 @@ STATIC void init_usb_vbus_sense(void) { -#ifdef BOARD_NO_VBUS +#ifdef BOARD_NO_VBUS_SENSE // Disable VBUS sensing #ifdef USB_OTG_GCCFG_VBDEN USB_OTG_FS->GCCFG &= ~USB_OTG_GCCFG_VBDEN; From d38a0007f199b3e497a18f4aa52f9d5927f790e1 Mon Sep 17 00:00:00 2001 From: Jerry Needell Date: Thu, 26 Dec 2019 08:46:27 -0500 Subject: [PATCH 10/10] define board.VOLTAGE_MONITOR for feather_stm32f405_express --- ports/stm32f4/boards/feather_stm32f405_express/pins.c | 1 + 1 file changed, 1 insertion(+) diff --git a/ports/stm32f4/boards/feather_stm32f405_express/pins.c b/ports/stm32f4/boards/feather_stm32f405_express/pins.c index 180fdd0937..ebc8fa337e 100644 --- a/ports/stm32f4/boards/feather_stm32f405_express/pins.c +++ b/ports/stm32f4/boards/feather_stm32f405_express/pins.c @@ -7,6 +7,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_PA07) }, { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_PC04) }, { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_PC05) }, + { MP_ROM_QSTR(MP_QSTR_VOLTAGE_MONITOR), MP_ROM_PTR(&pin_PA03) }, { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_PC07) }, { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_PC06) },