From 53d821332fa933a3b6272710dadc24bf140a3152 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Thu, 5 Jul 2018 17:35:20 -0400 Subject: [PATCH 1/3] update Crickit library to fix stepper Drive issues --- frozen/Adafruit_CircuitPython_Crickit | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frozen/Adafruit_CircuitPython_Crickit b/frozen/Adafruit_CircuitPython_Crickit index f948e09d38..44f52c5dac 160000 --- a/frozen/Adafruit_CircuitPython_Crickit +++ b/frozen/Adafruit_CircuitPython_Crickit @@ -1 +1 @@ -Subproject commit f948e09d38aaa8d3f59350372388cd5d603f95a6 +Subproject commit 44f52c5dacd9fc605565e5794e95c9a785aaf693 From 8bb363f7c4f537e90659bc98e1a1cd0097424d96 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Mon, 9 Jul 2018 17:18:06 -0400 Subject: [PATCH 2/3] must set pull after setting direction with gpio_set_pin routines --- ports/atmel-samd/common-hal/digitalio/DigitalInOut.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ports/atmel-samd/common-hal/digitalio/DigitalInOut.c b/ports/atmel-samd/common-hal/digitalio/DigitalInOut.c index 03bd225b14..c5c8f48e9f 100644 --- a/ports/atmel-samd/common-hal/digitalio/DigitalInOut.c +++ b/ports/atmel-samd/common-hal/digitalio/DigitalInOut.c @@ -40,8 +40,9 @@ digitalinout_result_t common_hal_digitalio_digitalinout_construct( claim_pin(pin); self->pin = pin; - gpio_set_pin_pull_mode(pin->pin, GPIO_PULL_OFF); + // Must set pull after setting direction. gpio_set_pin_direction(pin->pin, GPIO_DIRECTION_IN); + gpio_set_pin_pull_mode(pin->pin, GPIO_PULL_OFF); return DIGITALINOUT_OK; } @@ -154,9 +155,9 @@ void common_hal_digitalio_digitalinout_set_pull( default: break; } - // Set pull first to avoid glitches. - gpio_set_pin_pull_mode(self->pin->pin, asf_pull); + // Must set pull after setting direction. gpio_set_pin_direction(self->pin->pin, GPIO_DIRECTION_IN); + gpio_set_pin_pull_mode(self->pin->pin, asf_pull); } digitalio_pull_t common_hal_digitalio_digitalinout_get_pull( From be1d882a8b5d2878c9b4402ae641abf9a88cd682 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Thu, 19 Jul 2018 15:19:21 -0400 Subject: [PATCH 3/3] Prevent repetitive recursive scanning of dicts when making them long-lived --- py/gc_long_lived.c | 12 +++++++++++- py/obj.h | 4 +++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/py/gc_long_lived.c b/py/gc_long_lived.c index d34fde5d9b..dd5f0e8fd0 100644 --- a/py/gc_long_lived.c +++ b/py/gc_long_lived.c @@ -91,6 +91,13 @@ mp_obj_dict_t *make_dict_long_lived(mp_obj_dict_t *dict, uint8_t max_depth) { if (dict == NULL || max_depth == 0) { return dict; } + // Don't recurse unnecessarily. Return immediately if we've already seen this dict. + if (dict->map.scanning) { + return dict; + } + // Mark that we're processing this dict. + dict->map.scanning = 1; + // Update all of the references first so that we reduce the chance of references to the old // copies. dict->map.table = gc_make_long_lived(dict->map.table); @@ -100,7 +107,10 @@ mp_obj_dict_t *make_dict_long_lived(mp_obj_dict_t *dict, uint8_t max_depth) { dict->map.table[i].value = make_obj_long_lived(value, max_depth - 1); } } - return gc_make_long_lived(dict); + dict = gc_make_long_lived(dict); + // Done recursing through this dict. + dict->map.scanning = 0; + return dict; } mp_obj_str_t *make_str_long_lived(mp_obj_str_t *str) { diff --git a/py/obj.h b/py/obj.h index d086d3c149..8e95983f06 100644 --- a/py/obj.h +++ b/py/obj.h @@ -359,7 +359,9 @@ typedef struct _mp_map_t { size_t all_keys_are_qstrs : 1; size_t is_fixed : 1; // a fixed array that can't be modified; must also be ordered size_t is_ordered : 1; // an ordered array - size_t used : (8 * sizeof(size_t) - 3); + size_t scanning : 1; // true if we're in the middle of scanning linked dictionaries, + // e.g., make_dict_long_lived() + size_t used : (8 * sizeof(size_t) - 4); size_t alloc; mp_map_elem_t *table; } mp_map_t;