Skip to content

Commit 023d64f

Browse files
committed
Merge branch 'pixelbuf-subscr-change' into new-pixelbuf-api
2 parents 09d4fe0 + f1a9039 commit 023d64f

File tree

34 files changed

+95
-50
lines changed

34 files changed

+95
-50
lines changed

extmod/machine_mem.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ STATIC void machine_mem_print(const mp_print_t *print, mp_obj_t self_in, mp_prin
6161
}
6262

6363
#pragma GCC diagnostic ignored "-Wunused-parameter"
64-
STATIC mp_obj_t machine_mem_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value, mp_obj_t instance) {
64+
STATIC mp_obj_t machine_mem_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
6565
// TODO support slice index to read/write multiple values at once
6666
machine_mem_obj_t *self = MP_OBJ_TO_PTR(self_in);
6767
if (value == MP_OBJ_NULL) {

extmod/modbtree.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,9 @@ STATIC mp_obj_t btree_iternext(mp_obj_t self_in) {
247247
}
248248

249249
#pragma GCC diagnostic ignored "-Wunused-parameter"
250-
STATIC mp_obj_t btree_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value, mp_obj_t instance) {
251-
mp_obj_btree_t *self = MP_OBJ_TO_PTR(self_in);
250+
STATIC mp_obj_t btree_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
251+
//mp_obj_btree_t *self = MP_OBJ_TO_PTR(self_in);
252+
mp_obj_btree_t *self = mp_instance_cast_to_native_base(self_in, &btree_type);
252253
if (value == MP_OBJ_NULL) {
253254
// delete
254255
DBT key;

extmod/moductypes.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -519,8 +519,8 @@ STATIC void uctypes_struct_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
519519
}
520520

521521
#pragma GCC diagnostic ignored "-Wunused-parameter"
522-
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) {
523-
mp_obj_uctypes_struct_t *self = MP_OBJ_TO_PTR(self_in);
522+
STATIC mp_obj_t uctypes_struct_subscr(mp_obj_t base_in, mp_obj_t index_in, mp_obj_t value) {
523+
mp_obj_uctypes_struct_t *self = mp_instance_cast_to_native_base(base_in, &uctypes_struct_type);
524524

525525
if (value == MP_OBJ_NULL) {
526526
// delete

extmod/modurandom.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_urandom_randint_obj, mod_urandom_randint);
150150
STATIC mp_obj_t mod_urandom_choice(mp_obj_t seq) {
151151
mp_int_t len = mp_obj_get_int(mp_obj_len(seq));
152152
if (len > 0) {
153-
return mp_obj_subscr(seq, mp_obj_new_int(yasmarang_randbelow(len)), MP_OBJ_SENTINEL, seq);
153+
return mp_obj_subscr(seq, mp_obj_new_int(yasmarang_randbelow(len)), MP_OBJ_SENTINEL);
154154
} else {
155155
nlr_raise(mp_obj_new_exception(&mp_type_IndexError));
156156
}

extmod/vfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ mp_obj_t mp_vfs_listdir(size_t n_args, const mp_obj_t *args) {
373373
mp_obj_t dir_list = mp_obj_new_list(0, NULL);
374374
mp_obj_t next;
375375
while ((next = mp_iternext(iter)) != MP_OBJ_STOP_ITERATION) {
376-
mp_obj_list_append(dir_list, mp_obj_subscr(next, MP_OBJ_NEW_SMALL_INT(0), MP_OBJ_SENTINEL, next));
376+
mp_obj_list_append(dir_list, mp_obj_subscr(next, MP_OBJ_NEW_SMALL_INT(0), MP_OBJ_SENTINEL));
377377
}
378378
return dir_list;
379379
}

ports/stm32f4/boards/feather_stm32f405_express/pins.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = {
77
{ MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_PA07) },
88
{ MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_PC04) },
99
{ MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_PC05) },
10+
{ MP_ROM_QSTR(MP_QSTR_VOLTAGE_MONITOR), MP_ROM_PTR(&pin_PA03) },
1011

1112
{ MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_PC07) },
1213
{ MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_PC06) },

ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#define FLASH_PAGE_SIZE (0x4000)
3434

3535
#define BOARD_OSC_DIV 25
36+
#define BOARD_NO_VBUS_SENSE
3637

3738
// On-board flash
3839
// #define SPI_FLASH_MOSI_PIN (&pin_PA07)

ports/stm32f4/supervisor/usb.c

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,33 @@
3232
#include "lib/mp-readline/readline.h"
3333
#include "stm32f4xx_hal.h"
3434

35+
#include "py/mpconfig.h"
36+
3537
#include "common-hal/microcontroller/Pin.h"
3638

39+
STATIC void init_usb_vbus_sense(void) {
40+
41+
#ifdef BOARD_NO_VBUS_SENSE
42+
// Disable VBUS sensing
43+
#ifdef USB_OTG_GCCFG_VBDEN
44+
USB_OTG_FS->GCCFG &= ~USB_OTG_GCCFG_VBDEN;
45+
#else
46+
USB_OTG_FS->GCCFG |= USB_OTG_GCCFG_NOVBUSSENS;
47+
USB_OTG_FS->GCCFG &= ~USB_OTG_GCCFG_VBUSBSEN;
48+
USB_OTG_FS->GCCFG &= ~USB_OTG_GCCFG_VBUSASEN;
49+
#endif
50+
#else
51+
// Enable VBUS hardware sensing
52+
#ifdef USB_OTG_GCCFG_VBDEN
53+
USB_OTG_FS->GCCFG |= USB_OTG_GCCFG_VBDEN;
54+
#else
55+
USB_OTG_FS->GCCFG &= ~USB_OTG_GCCFG_NOVBUSSENS;
56+
USB_OTG_FS->GCCFG |= USB_OTG_GCCFG_VBUSBSEN; // B Device sense
57+
#endif
58+
#endif
59+
}
60+
61+
3762
void init_usb_hardware(void) {
3863
//TODO: if future chips overload this with options, move to peripherals management.
3964

@@ -79,7 +104,9 @@ void init_usb_hardware(void) {
79104
HAL_GPIO_Init(GPIOG, &GPIO_InitStruct);
80105
never_reset_pin_number(0, 8);
81106
#endif
82-
107+
83108
/* Peripheral clock enable */
84109
__HAL_RCC_USB_OTG_FS_CLK_ENABLE();
110+
111+
init_usb_vbus_sense();
85112
}

ports/unix/modjni.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ STATIC void get_jclass_name(jobject obj, char *buf) {
242242
}
243243

244244
#pragma GCC diagnostic ignored "-Wunused-parameter"
245-
STATIC mp_obj_t jobject_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value, mp_obj_t instance) {
245+
STATIC mp_obj_t jobject_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
246246
mp_obj_jobject_t *self = self_in;
247247
mp_uint_t idx = mp_obj_get_int(index);
248248
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) {
311311
// TODO: subscr_load_adaptor & subscr_getiter convenience functions
312312
// should be moved to common location for reuse.
313313
STATIC mp_obj_t subscr_load_adaptor(mp_obj_t self_in, mp_obj_t index_in) {
314-
return mp_obj_subscr(self_in, index_in, MP_OBJ_SENTINEL, self_in);
314+
return mp_obj_subscr(self_in, index_in, MP_OBJ_SENTINEL);
315315
}
316316
MP_DEFINE_CONST_FUN_OBJ_2(subscr_load_adaptor_obj, subscr_load_adaptor);
317317

py/obj.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -487,11 +487,11 @@ mp_obj_t mp_obj_len_maybe(mp_obj_t o_in) {
487487
}
488488
}
489489

490-
mp_obj_t mp_obj_subscr(mp_obj_t base, mp_obj_t index, mp_obj_t value, mp_obj_t instance) {
490+
mp_obj_t mp_obj_subscr(mp_obj_t base, mp_obj_t index, mp_obj_t value) {
491491
mp_obj_type_t *type = mp_obj_get_type(base);
492492

493493
if (type->subscr != NULL) {
494-
mp_obj_t ret = type->subscr(base, index, value, instance);
494+
mp_obj_t ret = type->subscr(base, index, value);
495495
// May have called port specific C code. Make sure it didn't mess up the heap.
496496
assert_heap_ok();
497497
if (ret != MP_OBJ_NULL) {
@@ -546,7 +546,7 @@ STATIC mp_obj_t generic_it_iternext(mp_obj_t self_in) {
546546
mp_obj_type_t *type = mp_obj_get_type(self->obj);
547547
mp_obj_t current_length = type->unary_op(MP_UNARY_OP_LEN, self->obj);
548548
if (self->cur < MP_OBJ_SMALL_INT_VALUE(current_length)) {
549-
mp_obj_t o_out = type->subscr(self->obj, MP_OBJ_NEW_SMALL_INT(self->cur), MP_OBJ_SENTINEL, self->obj);
549+
mp_obj_t o_out = type->subscr(self->obj, MP_OBJ_NEW_SMALL_INT(self->cur), MP_OBJ_SENTINEL);
550550
self->cur += 1;
551551
return o_out;
552552
} else {

0 commit comments

Comments
 (0)