From 1e2a94578289511f042f3934fe2039daf6af021c Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Fri, 14 May 2021 21:52:54 -0400 Subject: [PATCH] Make busio.SPI be NotImplementedError on proxlight to save space --- .../adafruit_proxlight_trinkey_m0/mpconfigboard.mk | 7 +++++-- .../boards/neopixel_trinkey_m0/mpconfigboard.mk | 10 +++++----- ports/atmel-samd/mpconfigport.mk | 8 ++++++-- py/circuitpy_mpconfig.mk | 3 +++ shared-bindings/busio/SPI.c | 9 +++++++++ 5 files changed, 28 insertions(+), 9 deletions(-) diff --git a/ports/atmel-samd/boards/adafruit_proxlight_trinkey_m0/mpconfigboard.mk b/ports/atmel-samd/boards/adafruit_proxlight_trinkey_m0/mpconfigboard.mk index 39aa5d62e1..cee8049231 100644 --- a/ports/atmel-samd/boards/adafruit_proxlight_trinkey_m0/mpconfigboard.mk +++ b/ports/atmel-samd/boards/adafruit_proxlight_trinkey_m0/mpconfigboard.mk @@ -8,14 +8,17 @@ CHIP_FAMILY = samd21 INTERNAL_FLASH_FILESYSTEM = 1 LONGINT_IMPL = NONE + CIRCUITPY_FULL_BUILD = 0 CIRCUITPY_ANALOGIO = 0 CIRCUITPY_AUDIOCORE = 0 -CIRCUITPY_ROTARYIO = 0 -CIRCUITPY_RTC = 0 +CIRCUITPY_BUSIO_SPI = 0 CIRCUITPY_PULSEIO = 0 CIRCUITPY_PWMIO = 0 +CIRCUITPY_ROTARYIO = 0 +CIRCUITPY_RTC = 0 +CIRCUITPY_USB_MIDI = 0 CIRCUITPY_PIXELBUF = 1 diff --git a/ports/atmel-samd/boards/neopixel_trinkey_m0/mpconfigboard.mk b/ports/atmel-samd/boards/neopixel_trinkey_m0/mpconfigboard.mk index 8f0ed95a47..2eb9ebd33e 100644 --- a/ports/atmel-samd/boards/neopixel_trinkey_m0/mpconfigboard.mk +++ b/ports/atmel-samd/boards/neopixel_trinkey_m0/mpconfigboard.mk @@ -12,15 +12,15 @@ LONGINT_IMPL = NONE CIRCUITPY_FULL_BUILD = 0 CIRCUITPY_ANALOGIO = 0 -CIRCUITPY_ROTARYIO = 0 -CIRCUITPY_RTC = 0 -CIRCUITPY_PULSEIO = 0 -CIRCUITPY_PWMIO = 0 CIRCUITPY_AUDIOCORE = 0 CIRCUITPY_BUSIO = 0 +CIRCUITPY_PULSEIO = 0 +CIRCUITPY_PWMIO = 0 +CIRCUITPY_ROTARYIO = 0 +CIRCUITPY_RTC = 0 CIRCUITPY_PIXELBUF = 1 # Include these Python libraries in firmware. -FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_NeoPixel FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_HID +FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_NeoPixel diff --git a/ports/atmel-samd/mpconfigport.mk b/ports/atmel-samd/mpconfigport.mk index 060b17daf5..aaa3bfccbe 100644 --- a/ports/atmel-samd/mpconfigport.mk +++ b/ports/atmel-samd/mpconfigport.mk @@ -60,15 +60,19 @@ CIRCUITPY_VECTORIO = 0 MICROPY_PY_ASYNC_AWAIT = 0 -ifeq ($(TRANSLATION), ja) +ifeq ($(TRANSLATION),ja) +ifeq ($(CIRCUITPY_DISPLAYIO),1) RELEASE_NEEDS_CLEAN_BUILD = 1 CIRCUITPY_TERMINALIO = 0 endif +endif -ifeq ($(TRANSLATION), ko) +ifeq ($(TRANSLATION),ko) +ifeq ($(CIRCUITPY_DISPLAYIO),1) RELEASE_NEEDS_CLEAN_BUILD = 1 CIRCUITPY_TERMINALIO = 0 endif +endif SUPEROPT_GC = 0 SUPEROPT_VM = 0 diff --git a/py/circuitpy_mpconfig.mk b/py/circuitpy_mpconfig.mk index c7b83dba21..b5cd699a09 100644 --- a/py/circuitpy_mpconfig.mk +++ b/py/circuitpy_mpconfig.mk @@ -121,6 +121,9 @@ CFLAGS += -DCIRCUITPY_BUILTINS_POW3=$(CIRCUITPY_BUILTINS_POW3) CIRCUITPY_BUSIO ?= 1 CFLAGS += -DCIRCUITPY_BUSIO=$(CIRCUITPY_BUSIO) +CIRCUITPY_BUSIO_SPI ?= 1 +CFLAGS += -DCIRCUITPY_BUSIO_SPI=$(CIRCUITPY_BUSIO_SPI) + CIRCUITPY_CAMERA ?= 0 CFLAGS += -DCIRCUITPY_CAMERA=$(CIRCUITPY_CAMERA) diff --git a/shared-bindings/busio/SPI.c b/shared-bindings/busio/SPI.c index 893ebeb5cd..5a82ac0b41 100644 --- a/shared-bindings/busio/SPI.c +++ b/shared-bindings/busio/SPI.c @@ -81,6 +81,7 @@ // TODO(tannewt): Support LSB SPI. STATIC mp_obj_t busio_spi_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { + #if CIRCUITPY_BUSIO_SPI busio_spi_obj_t *self = m_new_obj(busio_spi_obj_t); self->base.type = &busio_spi_type; enum { ARG_clock, ARG_MOSI, ARG_MISO }; @@ -102,8 +103,12 @@ STATIC mp_obj_t busio_spi_make_new(const mp_obj_type_t *type, size_t n_args, con common_hal_busio_spi_construct(self, clock, mosi, miso); return MP_OBJ_FROM_PTR(self); + #else + mp_raise_NotImplementedError(NULL); + #endif // CIRCUITPY_BUSIO_SPI } +#if CIRCUITPY_BUSIO_SPI //| def deinit(self) -> None: //| """Turn off the SPI bus.""" //| ... @@ -399,8 +404,11 @@ const mp_obj_property_t busio_spi_frequency_obj = { MP_ROM_NONE, MP_ROM_NONE}, }; +#endif // CIRCUITPY_BUSIO_SPI + STATIC const mp_rom_map_elem_t busio_spi_locals_dict_table[] = { + #if CIRCUITPY_BUSIO_SPI { MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&busio_spi_deinit_obj) }, { MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&default___enter___obj) }, { MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&busio_spi_obj___exit___obj) }, @@ -413,6 +421,7 @@ STATIC const mp_rom_map_elem_t busio_spi_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_write), MP_ROM_PTR(&busio_spi_write_obj) }, { MP_ROM_QSTR(MP_QSTR_write_readinto), MP_ROM_PTR(&busio_spi_write_readinto_obj) }, { MP_ROM_QSTR(MP_QSTR_frequency), MP_ROM_PTR(&busio_spi_frequency_obj) } + #endif // CIRCUITPY_BUSIO_SPI }; STATIC MP_DEFINE_CONST_DICT(busio_spi_locals_dict, busio_spi_locals_dict_table);