summaryrefslogtreecommitdiff
path: root/py
diff options
context:
space:
mode:
authorScott Shawcroft <scott@tannewt.org>2020-09-03 16:34:56 -0700
committerScott Shawcroft <scott@tannewt.org>2020-09-03 16:34:56 -0700
commit96cf60fbbdc26d5ed3274a43ebbaab7feca797e1 (patch)
tree855371ca80ea386e004387ddbd69f372670e9109 /py
parent0b94638aeb667f2a417d859487083241a5749128 (diff)
parent5d17d6402d57a74e20ea332da6a31be65ec0e2ca (diff)
Merge remote-tracking branch 'adafruit/main' into native_wifi
Diffstat (limited to 'py')
-rw-r--r--py/builtinimport.c2
-rw-r--r--py/circuitpy_defns.mk24
-rw-r--r--py/circuitpy_mpconfig.mk4
-rw-r--r--py/misc.h2
-rw-r--r--py/mkrules.mk5
-rw-r--r--py/obj.h25
-rw-r--r--py/py.mk2
7 files changed, 57 insertions, 7 deletions
diff --git a/py/builtinimport.c b/py/builtinimport.c
index 597819f55..47ffab519 100644
--- a/py/builtinimport.c
+++ b/py/builtinimport.c
@@ -488,7 +488,7 @@ mp_obj_t mp_builtin___import__(size_t n_args, const mp_obj_t *args) {
// afterwards.
gc_collect();
}
- if (outer_module_obj != MP_OBJ_NULL) {
+ if (outer_module_obj != MP_OBJ_NULL && VERIFY_PTR(outer_module_obj) ) {
qstr s = qstr_from_strn(mod_str + last, i - last);
mp_store_attr(outer_module_obj, s, module_obj);
// The above store can cause a dictionary rehash and new allocation. So,
diff --git a/py/circuitpy_defns.mk b/py/circuitpy_defns.mk
index 07fad3272..04e38d81e 100644
--- a/py/circuitpy_defns.mk
+++ b/py/circuitpy_defns.mk
@@ -359,6 +359,15 @@ SRC_COMMON_HAL_ALL = \
wifi/ScannedNetworks.c \
wifi/__init__.c \
+ifeq ($(CIRCUITPY_BLEIO_HCI),1)
+# Helper code for _bleio HCI.
+SRC_C += \
+ common-hal/_bleio/att.c \
+ common-hal/_bleio/hci.c \
+
+endif
+
+
SRC_COMMON_HAL = $(filter $(SRC_PATTERNS), $(SRC_COMMON_HAL_ALL))
# These don't have corresponding files in each port but are still located in
@@ -462,7 +471,7 @@ SRC_SHARED_MODULE_ALL = \
SRC_SHARED_MODULE = $(filter $(SRC_PATTERNS), $(SRC_SHARED_MODULE_ALL))
# Use the native touchio if requested. This flag is set conditionally in, say, mpconfigport.h.
-# The presence of common-hal/touchio/* # does not imply it's available for all chips in a port,
+# The presence of common-hal/touchio/* does not imply it's available for all chips in a port,
# so there is an explicit flag. For example, SAMD21 touchio is native, but SAMD51 is not.
ifeq ($(CIRCUITPY_TOUCHIO_USE_NATIVE),1)
SRC_COMMON_HAL_ALL += \
@@ -473,6 +482,14 @@ SRC_SHARED_MODULE_ALL += \
touchio/TouchIn.c \
touchio/__init__.c
endif
+
+# If supporting _bleio via HCI, make devices/ble_hci/common-hal/_bleio be includable,
+# and use C source files in devices/ble_hci/common-hal.
+ifeq ($(CIRCUITPY_BLEIO_HCI),1)
+INC += -I$(TOP)/devices/ble_hci
+DEVICES_MODULES += $(TOP)/devices/ble_hci
+endif
+
ifeq ($(CIRCUITPY_AUDIOMP3),1)
SRC_MOD += $(addprefix lib/mp3/src/, \
bitstream.c \
@@ -506,6 +523,11 @@ $(filter $(SRC_PATTERNS), \
displayio/display_core.c \
)
+SRC_COMMON_HAL_INTERNAL = \
+$(filter $(SRC_PATTERNS), \
+ _bleio/ \
+)
+
ifeq ($(INTERNAL_LIBM),1)
SRC_LIBM = \
$(addprefix lib/,\
diff --git a/py/circuitpy_mpconfig.mk b/py/circuitpy_mpconfig.mk
index ca2f60508..a2da9c42f 100644
--- a/py/circuitpy_mpconfig.mk
+++ b/py/circuitpy_mpconfig.mk
@@ -80,6 +80,10 @@ CFLAGS += -DCIRCUITPY_BITBANGIO=$(CIRCUITPY_BITBANGIO)
CIRCUITPY_BLEIO ?= 0
CFLAGS += -DCIRCUITPY_BLEIO=$(CIRCUITPY_BLEIO)
+# _bleio can be supported on most any board via HCI
+CIRCUITPY_BLEIO_HCI ?= 0
+CFLAGS += -DCIRCUITPY_BLEIO_HCI=$(CIRCUITPY_BLEIO_HCI)
+
CIRCUITPY_BOARD ?= 1
CFLAGS += -DCIRCUITPY_BOARD=$(CIRCUITPY_BOARD)
diff --git a/py/misc.h b/py/misc.h
index 944c0a716..6ed256e70 100644
--- a/py/misc.h
+++ b/py/misc.h
@@ -120,6 +120,8 @@ size_t m_get_peak_bytes_allocated(void);
// align ptr to the nearest multiple of "alignment"
#define MP_ALIGN(ptr, alignment) (void*)(((uintptr_t)(ptr) + ((alignment) - 1)) & ~((alignment) - 1))
+#define sizeof_field(TYPE, MEMBER) sizeof((((TYPE *)0)->MEMBER))
+
/** unichar / UTF-8 *********************************************/
#if MICROPY_PY_BUILTINS_STR_UNICODE
diff --git a/py/mkrules.mk b/py/mkrules.mk
index 13a73b90e..0b3ecc0e1 100644
--- a/py/mkrules.mk
+++ b/py/mkrules.mk
@@ -42,7 +42,7 @@ $(Q)$(CC) $(CFLAGS) -c -MD -o $@ $<
$(RM) -f $(@:.o=.d)
endef
-vpath %.c . $(TOP) $(USER_C_MODULES)
+vpath %.c . $(TOP) $(USER_C_MODULES) $(DEVICES_MODULES)
$(BUILD)/%.o: %.c
$(call compile_c)
@@ -56,8 +56,7 @@ $(BUILD)/%.o: %.c
QSTR_GEN_EXTRA_CFLAGS += -I$(BUILD)/tmp
-vpath %.c . $(TOP) $(USER_C_MODULES)
-
+vpath %.c . $(TOP) $(USER_C_MODULES) $(DEVICES_MODULES)
$(BUILD)/%.pp: %.c
$(STEPECHO) "PreProcess $<"
$(Q)$(CC) $(CFLAGS) -E -Wp,-C,-dD,-dI -o $@ $<
diff --git a/py/obj.h b/py/obj.h
index c5ef74ef3..805b26e48 100644
--- a/py/obj.h
+++ b/py/obj.h
@@ -303,7 +303,7 @@ typedef struct _mp_rom_obj_t { mp_const_obj_t o; } mp_rom_obj_t;
(mp_obj_t)&mp_const_none_obj, \
(mp_obj_t)&mp_const_none_obj}, }
-// These macros are used to define constant map/dict objects
+// These macros are used to define constant or mutable map/dict objects
// You can put "static" in front of the definition to make it local
#define MP_DEFINE_CONST_MAP(map_name, table_name) \
@@ -329,6 +329,29 @@ typedef struct _mp_rom_obj_t { mp_const_obj_t o; } mp_rom_obj_t;
}, \
}
+#define MP_DEFINE_MUTABLE_MAP(map_name, table_name) \
+ mp_map_t map_name = { \
+ .all_keys_are_qstrs = 1, \
+ .is_fixed = 1, \
+ .is_ordered = 1, \
+ .used = MP_ARRAY_SIZE(table_name), \
+ .alloc = MP_ARRAY_SIZE(table_name), \
+ .table = table_name, \
+ }
+
+#define MP_DEFINE_MUTABLE_DICT(dict_name, table_name) \
+ mp_obj_dict_t dict_name = { \
+ .base = {&mp_type_dict}, \
+ .map = { \
+ .all_keys_are_qstrs = 1, \
+ .is_fixed = 1, \
+ .is_ordered = 1, \
+ .used = MP_ARRAY_SIZE(table_name), \
+ .alloc = MP_ARRAY_SIZE(table_name), \
+ .table = table_name, \
+ }, \
+ }
+
// These macros are used to declare and define constant staticmethond and classmethod objects
// You can put "static" in front of the definitions to make them local
diff --git a/py/py.mk b/py/py.mk
index c5073d0f0..49fb0acaf 100644
--- a/py/py.mk
+++ b/py/py.mk
@@ -19,7 +19,7 @@ endif
QSTR_GLOBAL_DEPENDENCIES += $(PY_SRC)/mpconfig.h mpconfigport.h
# some code is performance bottleneck and compiled with other optimization options
-CSUPEROPT = -O3
+_CSUPEROPT = -O3
# this sets the config file for FatFs
CFLAGS_MOD += -DFFCONF_H=\"lib/oofatfs/ffconf.h\"