From cf116f1cd0e13b315b58edab1fc1971be77e4a57 Mon Sep 17 00:00:00 2001 From: Stella Date: Sun, 29 Dec 2024 19:09:13 -0500 Subject: [PATCH 01/11] create m5stack_stamps3 board --- .../espressif/boards/m5stack_stamp_s3/board.c | 95 +++++++++++ .../boards/m5stack_stamp_s3/mpconfigboard.h | 24 +++ .../boards/m5stack_stamp_s3/mpconfigboard.mk | 14 ++ .../espressif/boards/m5stack_stamp_s3/pins.c | 153 ++++++++++++++++++ .../boards/m5stack_stamp_s3/sdkconfig | 14 ++ 5 files changed, 300 insertions(+) create mode 100644 ports/espressif/boards/m5stack_stamp_s3/board.c create mode 100644 ports/espressif/boards/m5stack_stamp_s3/mpconfigboard.h create mode 100644 ports/espressif/boards/m5stack_stamp_s3/mpconfigboard.mk create mode 100644 ports/espressif/boards/m5stack_stamp_s3/pins.c create mode 100644 ports/espressif/boards/m5stack_stamp_s3/sdkconfig diff --git a/ports/espressif/boards/m5stack_stamp_s3/board.c b/ports/espressif/boards/m5stack_stamp_s3/board.c new file mode 100644 index 0000000000000..6fdc2f8ea5c46 --- /dev/null +++ b/ports/espressif/boards/m5stack_stamp_s3/board.c @@ -0,0 +1,95 @@ +// This file is part of the CircuitPython project: https://circuitpython.org +// +// SPDX-FileCopyrightText: Copyright (c) 2020 Scott Shawcroft for Adafruit Industries +// +// SPDX-License-Identifier: MIT + +#include "mpconfigboard.h" +#include "supervisor/board.h" +#include "supervisor/shared/serial.h" +#include "shared-bindings/busio/SPI.h" +#include "shared-bindings/fourwire/FourWire.h" +#include "shared-bindings/microcontroller/Pin.h" +#include "shared-module/displayio/__init__.h" +#include "shared-module/displayio/mipi_constants.h" +#include "shared-bindings/board/__init__.h" +#include "py/runtime.h" +#include "py/ringbuf.h" +#include "shared/runtime/interrupt_char.h" + + +#define DELAY 0x80 + +uint8_t display_init_sequence[] = { + // SWRESET and Delay 140ms + 0x01, 0 | DELAY, 140, + // SLPOUT and Delay 10ms + 0x11, 0 | DELAY, 10, + // COLMOD 65k colors and 16 bit 5-6-5 + 0x3A, 1, 0x55, + // INVON Iiversion on + 0x21, 0, + // NORON normal operation (full update) + 0x13, 0, + // MADCTL columns RTL, page/column reverse order + 0x36, 1, 0x60, + // RAMCTRL color word little endian + 0xB0, 2, 0x00, 0xF8, + // DIPON display on + 0x29, 0, +}; + + +// Overrides the weakly linked function from supervisor/shared/board.c +void board_init(void) { + busio_spi_obj_t *spi = common_hal_board_create_spi(0); + fourwire_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; + bus->base.type = &fourwire_fourwire_type; + + // see here for inspiration: https://github.com/m5stack/M5GFX/blob/33d7d3135e816a86a008fae8ab3757938cee95d2/src/M5GFX.cpp#L1350 + common_hal_fourwire_fourwire_construct( + bus, + spi, + &pin_GPIO34, // DC + &pin_GPIO37, // CS + &pin_GPIO33, // RST + 40000000, // baudrate + 0, // polarity + 0 // phase + ); + busdisplay_busdisplay_obj_t *display = &allocate_display()->display; + display->base.type = &busdisplay_busdisplay_type; + + common_hal_busdisplay_busdisplay_construct( + display, + bus, + 240, // width (after rotation) + 135, // height (after rotation) + 40, // column start + 53, // row start + 0, // rotation + 16, // color depth + false, // grayscale + false, // pixels in a byte share a row. Only valid for depths < 8 + 1, // bytes per cell. Only valid for depths < 8 + false, // reverse_pixels_in_byte. Only valid for depths < 8 + false, // reverse_pixels_in_word + MIPI_COMMAND_SET_COLUMN_ADDRESS, // set column command + MIPI_COMMAND_SET_PAGE_ADDRESS, // set row command + MIPI_COMMAND_WRITE_MEMORY_START, // write memory command + display_init_sequence, + sizeof(display_init_sequence), + &pin_GPIO38, // backlight pin + NO_BRIGHTNESS_COMMAND, + 1.0f, // brightness + false, // single_byte_bounds + false, // data_as_commands + true, // auto_refresh + 60, // native_frames_per_second + true, // backlight_on_high + false, // SH1107_addressing + 350 // backlight pwm frequency + ); +} + +// TODO: Should we turn off the display when asleep, in board_deinit() ? diff --git a/ports/espressif/boards/m5stack_stamp_s3/mpconfigboard.h b/ports/espressif/boards/m5stack_stamp_s3/mpconfigboard.h new file mode 100644 index 0000000000000..78ff721eae546 --- /dev/null +++ b/ports/espressif/boards/m5stack_stamp_s3/mpconfigboard.h @@ -0,0 +1,24 @@ +// This file is part of the CircuitPython project: https://circuitpython.org +// +// SPDX-FileCopyrightText: Copyright (c) 2019 Scott Shawcroft for Adafruit Industries +// +// SPDX-License-Identifier: MIT + +#pragma once + +// Micropython setup + +#define MICROPY_HW_BOARD_NAME "M5Stack Stamp-S3" +#define MICROPY_HW_MCU_NAME "ESP32S3" + +#define MICROPY_HW_NEOPIXEL (&pin_GPIO21) + +#define DEFAULT_I2C_BUS_SCL (&pin_GPIO15) +#define DEFAULT_I2C_BUS_SDA (&pin_GPIO13) + +#define DEFAULT_UART_BUS_RX (&pin_GPIO44) +#define DEFAULT_UART_BUS_TX (&pin_GPIO43) + +#define CIRCUITPY_BOARD_SPI (2) +#define CIRCUITPY_BOARD_SPI_PIN {{.clock = &pin_GPIO36, .mosi = &pin_GPIO35}, \ + {.clock = &pin_GPIO40, .mosi = &pin_GPIO14, .miso = &pin_GPIO39}} diff --git a/ports/espressif/boards/m5stack_stamp_s3/mpconfigboard.mk b/ports/espressif/boards/m5stack_stamp_s3/mpconfigboard.mk new file mode 100644 index 0000000000000..7e11fd7b8d07f --- /dev/null +++ b/ports/espressif/boards/m5stack_stamp_s3/mpconfigboard.mk @@ -0,0 +1,14 @@ +USB_VID = 0x303A +USB_PID = 0x816B +USB_PRODUCT = "M5Stack StampS3 - CircuitPython" +USB_MANUFACTURER = "M5STACK" + +IDF_TARGET = esp32s3 + +CIRCUITPY_ESP_FLASH_MODE = qio +CIRCUITPY_ESP_FLASH_FREQ = 80m +CIRCUITPY_ESP_FLASH_SIZE = 8MB +CIRCUITPY_ESPCAMERA = 0 + +CIRCUITPY_GIFIO = 1 +CIRCUITPY_MAX3421E = 0 diff --git a/ports/espressif/boards/m5stack_stamp_s3/pins.c b/ports/espressif/boards/m5stack_stamp_s3/pins.c new file mode 100644 index 0000000000000..e630f9ebdee06 --- /dev/null +++ b/ports/espressif/boards/m5stack_stamp_s3/pins.c @@ -0,0 +1,153 @@ +// This file is part of the CircuitPython project: https://circuitpython.org +// +// SPDX-FileCopyrightText: Copyright (c) 2020 Scott Shawcroft for Adafruit Industries +// +// SPDX-License-Identifier: MIT + +#include "shared-bindings/board/__init__.h" + +#include "shared-module/displayio/__init__.h" +CIRCUITPY_BOARD_BUS_SINGLETON(sd_spi, spi, 1) +static const mp_rom_map_elem_t board_module_globals_table[] = { + CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS + + // Button + { MP_ROM_QSTR(MP_QSTR_BUTTON), MP_ROM_PTR(&pin_GPIO0) }, + { MP_ROM_QSTR(MP_QSTR_BOOT0), MP_ROM_PTR(&pin_GPIO0) }, + { MP_ROM_QSTR(MP_QSTR_IO0), MP_ROM_PTR(&pin_GPIO0) }, + { MP_ROM_QSTR(MP_QSTR_G0), MP_ROM_PTR(&pin_GPIO0) }, + + // GPIO + { MP_ROM_QSTR(MP_QSTR_IO1), MP_ROM_PTR(&pin_GPIO1) }, + { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_GPIO1) }, + { MP_ROM_QSTR(MP_QSTR_G1), MP_ROM_PTR(&pin_GPIO1) }, + { MP_ROM_QSTR(MP_QSTR_TCH1), MP_ROM_PTR(&pin_GPIO1) }, + + { MP_ROM_QSTR(MP_QSTR_IO2), MP_ROM_PTR(&pin_GPIO2) }, + { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_GPIO2) }, + { MP_ROM_QSTR(MP_QSTR_G2), MP_ROM_PTR(&pin_GPIO2) }, + { MP_ROM_QSTR(MP_QSTR_TCH2), MP_ROM_PTR(&pin_GPIO2) }, + + { MP_ROM_QSTR(MP_QSTR_IO3), MP_ROM_PTR(&pin_GPIO3) }, + { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_GPIO3) }, + { MP_ROM_QSTR(MP_QSTR_G3), MP_ROM_PTR(&pin_GPIO3) }, + { MP_ROM_QSTR(MP_QSTR_TCH3), MP_ROM_PTR(&pin_GPIO3) }, + + { MP_ROM_QSTR(MP_QSTR_IO4), MP_ROM_PTR(&pin_GPIO4) }, + { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_GPIO4) }, + { MP_ROM_QSTR(MP_QSTR_G4), MP_ROM_PTR(&pin_GPIO4) }, + { MP_ROM_QSTR(MP_QSTR_TCH4), MP_ROM_PTR(&pin_GPIO4) }, + + { MP_ROM_QSTR(MP_QSTR_IO5), MP_ROM_PTR(&pin_GPIO5) }, + { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_GPIO5) }, + { MP_ROM_QSTR(MP_QSTR_G5), MP_ROM_PTR(&pin_GPIO5) }, + { MP_ROM_QSTR(MP_QSTR_TCH5), MP_ROM_PTR(&pin_GPIO5) }, + + { MP_ROM_QSTR(MP_QSTR_IO6), MP_ROM_PTR(&pin_GPIO6) }, + { MP_ROM_QSTR(MP_QSTR_A6), MP_ROM_PTR(&pin_GPIO6) }, + { MP_ROM_QSTR(MP_QSTR_G6), MP_ROM_PTR(&pin_GPIO6) }, + { MP_ROM_QSTR(MP_QSTR_TCH6), MP_ROM_PTR(&pin_GPIO6) }, + + { MP_ROM_QSTR(MP_QSTR_IO7), MP_ROM_PTR(&pin_GPIO7) }, + { MP_ROM_QSTR(MP_QSTR_A7), MP_ROM_PTR(&pin_GPIO7) }, + { MP_ROM_QSTR(MP_QSTR_G7), MP_ROM_PTR(&pin_GPIO7) }, + { MP_ROM_QSTR(MP_QSTR_TCH7), MP_ROM_PTR(&pin_GPIO7) }, + + { MP_ROM_QSTR(MP_QSTR_IO8), MP_ROM_PTR(&pin_GPIO8) }, + { MP_ROM_QSTR(MP_QSTR_A8), MP_ROM_PTR(&pin_GPIO8) }, + { MP_ROM_QSTR(MP_QSTR_G8), MP_ROM_PTR(&pin_GPIO8) }, + { MP_ROM_QSTR(MP_QSTR_TCH8), MP_ROM_PTR(&pin_GPIO8) }, + + { MP_ROM_QSTR(MP_QSTR_IO9), MP_ROM_PTR(&pin_GPIO9) }, + { MP_ROM_QSTR(MP_QSTR_A9), MP_ROM_PTR(&pin_GPIO9) }, + { MP_ROM_QSTR(MP_QSTR_G9), MP_ROM_PTR(&pin_GPIO9) }, + { MP_ROM_QSTR(MP_QSTR_TCH9), MP_ROM_PTR(&pin_GPIO9) }, + + { MP_ROM_QSTR(MP_QSTR_IO10), MP_ROM_PTR(&pin_GPIO10) }, + { MP_ROM_QSTR(MP_QSTR_A10), MP_ROM_PTR(&pin_GPIO10) }, + { MP_ROM_QSTR(MP_QSTR_G10), MP_ROM_PTR(&pin_GPIO10) }, + { MP_ROM_QSTR(MP_QSTR_TCH10), MP_ROM_PTR(&pin_GPIO10) }, + + { MP_ROM_QSTR(MP_QSTR_IO11), MP_ROM_PTR(&pin_GPIO11) }, + { MP_ROM_QSTR(MP_QSTR_A11), MP_ROM_PTR(&pin_GPIO11) }, + { MP_ROM_QSTR(MP_QSTR_G11), MP_ROM_PTR(&pin_GPIO11) }, + { MP_ROM_QSTR(MP_QSTR_TCH11), MP_ROM_PTR(&pin_GPIO11) }, + + { MP_ROM_QSTR(MP_QSTR_IO12), MP_ROM_PTR(&pin_GPIO12) }, + { MP_ROM_QSTR(MP_QSTR_A12), MP_ROM_PTR(&pin_GPIO12) }, + { MP_ROM_QSTR(MP_QSTR_G12), MP_ROM_PTR(&pin_GPIO12) }, + { MP_ROM_QSTR(MP_QSTR_TCH12), MP_ROM_PTR(&pin_GPIO12) }, + + { MP_ROM_QSTR(MP_QSTR_IO13), MP_ROM_PTR(&pin_GPIO13) }, + { MP_ROM_QSTR(MP_QSTR_A13), MP_ROM_PTR(&pin_GPIO13) }, + { MP_ROM_QSTR(MP_QSTR_G13), MP_ROM_PTR(&pin_GPIO13) }, + { MP_ROM_QSTR(MP_QSTR_TCH13), MP_ROM_PTR(&pin_GPIO13) }, + + { MP_ROM_QSTR(MP_QSTR_IO14), MP_ROM_PTR(&pin_GPIO14) }, + { MP_ROM_QSTR(MP_QSTR_A14), MP_ROM_PTR(&pin_GPIO14) }, + { MP_ROM_QSTR(MP_QSTR_G14), MP_ROM_PTR(&pin_GPIO14) }, + { MP_ROM_QSTR(MP_QSTR_TCH14), MP_ROM_PTR(&pin_GPIO14) }, + + { MP_ROM_QSTR(MP_QSTR_IO15), MP_ROM_PTR(&pin_GPIO15) }, + { MP_ROM_QSTR(MP_QSTR_A15), MP_ROM_PTR(&pin_GPIO15) }, + { MP_ROM_QSTR(MP_QSTR_G15), MP_ROM_PTR(&pin_GPIO15) }, + + { MP_ROM_QSTR(MP_QSTR_IO39), MP_ROM_PTR(&pin_GPIO39) }, + { MP_ROM_QSTR(MP_QSTR_G39), MP_ROM_PTR(&pin_GPIO39) }, + + { MP_ROM_QSTR(MP_QSTR_IO40), MP_ROM_PTR(&pin_GPIO40) }, + { MP_ROM_QSTR(MP_QSTR_G40), MP_ROM_PTR(&pin_GPIO40) }, + + { MP_ROM_QSTR(MP_QSTR_IO41), MP_ROM_PTR(&pin_GPIO41) }, + { MP_ROM_QSTR(MP_QSTR_G41), MP_ROM_PTR(&pin_GPIO41) }, + + { MP_ROM_QSTR(MP_QSTR_IO42), MP_ROM_PTR(&pin_GPIO42) }, + { MP_ROM_QSTR(MP_QSTR_G42), MP_ROM_PTR(&pin_GPIO42) }, + + { MP_ROM_QSTR(MP_QSTR_IO43), MP_ROM_PTR(&pin_GPIO43) }, + { MP_ROM_QSTR(MP_QSTR_G43), MP_ROM_PTR(&pin_GPIO43) }, + + { MP_ROM_QSTR(MP_QSTR_IO44), MP_ROM_PTR(&pin_GPIO44) }, + { MP_ROM_QSTR(MP_QSTR_G44), MP_ROM_PTR(&pin_GPIO44) }, + + { MP_ROM_QSTR(MP_QSTR_IO46), MP_ROM_PTR(&pin_GPIO46) }, + { MP_ROM_QSTR(MP_QSTR_G46), MP_ROM_PTR(&pin_GPIO46) }, + + // I2C + { MP_ROM_QSTR(MP_QSTR_I2C_SCL), MP_ROM_PTR(&pin_GPIO15) }, + { MP_ROM_QSTR(MP_QSTR_I2C_SDA), MP_ROM_PTR(&pin_GPIO13) }, + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + + // UART + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO43) }, + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO44) }, + { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, + + // Neopixel + { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO21) }, + + // Display + { MP_ROM_QSTR(MP_QSTR_TFT_RST), MP_ROM_PTR(&pin_GPIO33) }, + { MP_ROM_QSTR(MP_QSTR_TFT_RESET), MP_ROM_PTR(&pin_GPIO33) }, + { MP_ROM_QSTR(MP_QSTR_TFT_DC), MP_ROM_PTR(&pin_GPIO34) }, + { MP_ROM_QSTR(MP_QSTR_TFT_RS), MP_ROM_PTR(&pin_GPIO34) }, + { MP_ROM_QSTR(MP_QSTR_TFT_MOSI), MP_ROM_PTR(&pin_GPIO35) }, + { MP_ROM_QSTR(MP_QSTR_TFT_DATA), MP_ROM_PTR(&pin_GPIO35) }, + { MP_ROM_QSTR(MP_QSTR_TFT_SCK), MP_ROM_PTR(&pin_GPIO36) }, + { MP_ROM_QSTR(MP_QSTR_TFT_CS), MP_ROM_PTR(&pin_GPIO37) }, + { MP_ROM_QSTR(MP_QSTR_TFT_BACKLIGHT), MP_ROM_PTR(&pin_GPIO38) }, + { MP_ROM_QSTR(MP_QSTR_TFT_BL), MP_ROM_PTR(&pin_GPIO38) }, + { MP_ROM_QSTR(MP_QSTR_TFT_SPI), MP_ROM_PTR(&board_spi_obj) }, + + // Extended Port Pins + { MP_ROM_QSTR(MP_QSTR_IO16), MP_ROM_PTR(&pin_GPIO16) }, + { MP_ROM_QSTR(MP_QSTR_G16), MP_ROM_PTR(&pin_GPIO16) }, + { MP_ROM_QSTR(MP_QSTR_IO17), MP_ROM_PTR(&pin_GPIO17) }, + { MP_ROM_QSTR(MP_QSTR_G17), MP_ROM_PTR(&pin_GPIO17) }, + { MP_ROM_QSTR(MP_QSTR_IO18), MP_ROM_PTR(&pin_GPIO18) }, + { MP_ROM_QSTR(MP_QSTR_G18), MP_ROM_PTR(&pin_GPIO18) }, + + // Display object + { MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].display)}, +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/espressif/boards/m5stack_stamp_s3/sdkconfig b/ports/espressif/boards/m5stack_stamp_s3/sdkconfig new file mode 100644 index 0000000000000..e962866216039 --- /dev/null +++ b/ports/espressif/boards/m5stack_stamp_s3/sdkconfig @@ -0,0 +1,14 @@ +# +# Espressif IoT Development Framework Configuration +# +# +# Component config +# +# +# LWIP +# +# end of LWIP + +# end of Component config + +# end of Espressif IoT Development Framework Configuration From 993eed2de40415fae059701db84803eb78ace729 Mon Sep 17 00:00:00 2001 From: Stella Date: Fri, 10 Jan 2025 21:40:22 -0500 Subject: [PATCH 02/11] Disabled code for optional LCD --- ports/espressif/boards/m5stack_stamp_s3/board.c | 10 +++++++++- .../boards/m5stack_stamp_s3/mpconfigboard.h | 17 +++++++++++------ .../boards/m5stack_stamp_s3/mpconfigboard.mk | 4 ++-- ports/espressif/boards/m5stack_stamp_s3/pins.c | 8 ++++++-- 4 files changed, 28 insertions(+), 11 deletions(-) diff --git a/ports/espressif/boards/m5stack_stamp_s3/board.c b/ports/espressif/boards/m5stack_stamp_s3/board.c index 6fdc2f8ea5c46..37bd2d9d8eb55 100644 --- a/ports/espressif/boards/m5stack_stamp_s3/board.c +++ b/ports/espressif/boards/m5stack_stamp_s3/board.c @@ -4,8 +4,14 @@ // // SPDX-License-Identifier: MIT -#include "mpconfigboard.h" #include "supervisor/board.h" + +// Below section commented out due to LCD not being included by default with StampS3 +// Can be re-enabled to add LCD functionality included by Cardputer replacement kit + +/* + +#include "mpconfigboard.h" #include "supervisor/shared/serial.h" #include "shared-bindings/busio/SPI.h" #include "shared-bindings/fourwire/FourWire.h" @@ -93,3 +99,5 @@ void board_init(void) { } // TODO: Should we turn off the display when asleep, in board_deinit() ? + +*/ diff --git a/ports/espressif/boards/m5stack_stamp_s3/mpconfigboard.h b/ports/espressif/boards/m5stack_stamp_s3/mpconfigboard.h index 78ff721eae546..d5c07a5e9b0b2 100644 --- a/ports/espressif/boards/m5stack_stamp_s3/mpconfigboard.h +++ b/ports/espressif/boards/m5stack_stamp_s3/mpconfigboard.h @@ -9,16 +9,21 @@ // Micropython setup #define MICROPY_HW_BOARD_NAME "M5Stack Stamp-S3" -#define MICROPY_HW_MCU_NAME "ESP32S3" +#define MICROPY_HW_MCU_NAME "ESP32-S3FN8" -#define MICROPY_HW_NEOPIXEL (&pin_GPIO21) +#define MICROPY_HW_NEOPIXEL (&pin_GPIO21) -#define DEFAULT_I2C_BUS_SCL (&pin_GPIO15) -#define DEFAULT_I2C_BUS_SDA (&pin_GPIO13) +#define DEFAULT_I2C_BUS_SCL (&pin_GPIO15) +#define DEFAULT_I2C_BUS_SDA (&pin_GPIO13) -#define DEFAULT_UART_BUS_RX (&pin_GPIO44) -#define DEFAULT_UART_BUS_TX (&pin_GPIO43) +#define DEFAULT_UART_BUS_RX (&pin_GPIO44) +#define DEFAULT_UART_BUS_TX (&pin_GPIO43) +// Below section commented out due to LCD not being included by default with StampS3 +// Can be re-enabled to add LCD functionality included by Cardputer replacement kit + +/* #define CIRCUITPY_BOARD_SPI (2) #define CIRCUITPY_BOARD_SPI_PIN {{.clock = &pin_GPIO36, .mosi = &pin_GPIO35}, \ {.clock = &pin_GPIO40, .mosi = &pin_GPIO14, .miso = &pin_GPIO39}} +*/ diff --git a/ports/espressif/boards/m5stack_stamp_s3/mpconfigboard.mk b/ports/espressif/boards/m5stack_stamp_s3/mpconfigboard.mk index 7e11fd7b8d07f..b27fbb3dc2c14 100644 --- a/ports/espressif/boards/m5stack_stamp_s3/mpconfigboard.mk +++ b/ports/espressif/boards/m5stack_stamp_s3/mpconfigboard.mk @@ -10,5 +10,5 @@ CIRCUITPY_ESP_FLASH_FREQ = 80m CIRCUITPY_ESP_FLASH_SIZE = 8MB CIRCUITPY_ESPCAMERA = 0 -CIRCUITPY_GIFIO = 1 -CIRCUITPY_MAX3421E = 0 +# Include these Python libraries in firmware. +FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_NeoPixel diff --git a/ports/espressif/boards/m5stack_stamp_s3/pins.c b/ports/espressif/boards/m5stack_stamp_s3/pins.c index e630f9ebdee06..2c0e56469f0e7 100644 --- a/ports/espressif/boards/m5stack_stamp_s3/pins.c +++ b/ports/espressif/boards/m5stack_stamp_s3/pins.c @@ -132,6 +132,7 @@ static const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_TFT_DC), MP_ROM_PTR(&pin_GPIO34) }, { MP_ROM_QSTR(MP_QSTR_TFT_RS), MP_ROM_PTR(&pin_GPIO34) }, { MP_ROM_QSTR(MP_QSTR_TFT_MOSI), MP_ROM_PTR(&pin_GPIO35) }, + { MP_ROM_QSTR(MP_QSTR_TFT_DAT), MP_ROM_PTR(&pin_GPIO35) }, { MP_ROM_QSTR(MP_QSTR_TFT_DATA), MP_ROM_PTR(&pin_GPIO35) }, { MP_ROM_QSTR(MP_QSTR_TFT_SCK), MP_ROM_PTR(&pin_GPIO36) }, { MP_ROM_QSTR(MP_QSTR_TFT_CS), MP_ROM_PTR(&pin_GPIO37) }, @@ -147,7 +148,10 @@ static const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_IO18), MP_ROM_PTR(&pin_GPIO18) }, { MP_ROM_QSTR(MP_QSTR_G18), MP_ROM_PTR(&pin_GPIO18) }, - // Display object - { MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].display)}, + // Below Display Object commented out due to LCD not being included by default with StampS3 + // Can be re-enabled to add LCD functionality included by Cardputer replacement kit + + // Display Object + // { MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].display)}, }; MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); From a79dc97c6ec75a1bbbcb4b01a0b16bc86761d6cd Mon Sep 17 00:00:00 2001 From: Stella Date: Fri, 10 Jan 2025 23:24:33 -0500 Subject: [PATCH 03/11] Update author credit line --- ports/espressif/boards/m5stack_stamp_s3/board.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/espressif/boards/m5stack_stamp_s3/board.c b/ports/espressif/boards/m5stack_stamp_s3/board.c index 37bd2d9d8eb55..9d8b61025aada 100644 --- a/ports/espressif/boards/m5stack_stamp_s3/board.c +++ b/ports/espressif/boards/m5stack_stamp_s3/board.c @@ -1,6 +1,6 @@ // This file is part of the CircuitPython project: https://circuitpython.org // -// SPDX-FileCopyrightText: Copyright (c) 2020 Scott Shawcroft for Adafruit Industries +// SPDX-FileCopyrightText: 2025 Stella Schwankl for Adafruit Industries // // SPDX-License-Identifier: MIT From 81d9a3e2af05c30274752f2ab2048f3d61c9a973 Mon Sep 17 00:00:00 2001 From: Stella Date: Fri, 10 Jan 2025 23:25:23 -0500 Subject: [PATCH 04/11] Update author credit line --- ports/espressif/boards/m5stack_stamp_s3/mpconfigboard.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/espressif/boards/m5stack_stamp_s3/mpconfigboard.h b/ports/espressif/boards/m5stack_stamp_s3/mpconfigboard.h index d5c07a5e9b0b2..6a46abf337dce 100644 --- a/ports/espressif/boards/m5stack_stamp_s3/mpconfigboard.h +++ b/ports/espressif/boards/m5stack_stamp_s3/mpconfigboard.h @@ -1,6 +1,6 @@ // This file is part of the CircuitPython project: https://circuitpython.org // -// SPDX-FileCopyrightText: Copyright (c) 2019 Scott Shawcroft for Adafruit Industries +// SPDX-FileCopyrightText: 2025 Stella Schwankl for Adafruit Industries // // SPDX-License-Identifier: MIT From 1f277219e6ec3fa23ae79325c42c9ca142206097 Mon Sep 17 00:00:00 2001 From: Stella Date: Fri, 10 Jan 2025 23:26:49 -0500 Subject: [PATCH 05/11] Update author credit line --- ports/espressif/boards/m5stack_stamp_s3/pins.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/espressif/boards/m5stack_stamp_s3/pins.c b/ports/espressif/boards/m5stack_stamp_s3/pins.c index 2c0e56469f0e7..a46c1a8dbf568 100644 --- a/ports/espressif/boards/m5stack_stamp_s3/pins.c +++ b/ports/espressif/boards/m5stack_stamp_s3/pins.c @@ -1,6 +1,6 @@ // This file is part of the CircuitPython project: https://circuitpython.org // -// SPDX-FileCopyrightText: Copyright (c) 2020 Scott Shawcroft for Adafruit Industries +// SPDX-FileCopyrightText: 2025 Stella Schwankl for Adafruit Industries // // SPDX-License-Identifier: MIT From 1d138452ecf6e500e42c9a390595a0dae53ca0ae Mon Sep 17 00:00:00 2001 From: Stella Date: Mon, 13 Jan 2025 13:36:44 -0500 Subject: [PATCH 06/11] Update ports/espressif/boards/m5stack_stamp_s3/mpconfigboard.h Co-authored-by: Scott Shawcroft --- ports/espressif/boards/m5stack_stamp_s3/mpconfigboard.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/espressif/boards/m5stack_stamp_s3/mpconfigboard.h b/ports/espressif/boards/m5stack_stamp_s3/mpconfigboard.h index 6a46abf337dce..b1d6d657bed09 100644 --- a/ports/espressif/boards/m5stack_stamp_s3/mpconfigboard.h +++ b/ports/espressif/boards/m5stack_stamp_s3/mpconfigboard.h @@ -1,6 +1,6 @@ // This file is part of the CircuitPython project: https://circuitpython.org // -// SPDX-FileCopyrightText: 2025 Stella Schwankl for Adafruit Industries +// SPDX-FileCopyrightText: 2025 Stella Schwankl // // SPDX-License-Identifier: MIT From 8ecf35b7ee876d9af13bcd831b067376388a6a47 Mon Sep 17 00:00:00 2001 From: Stella Date: Mon, 13 Jan 2025 13:42:55 -0500 Subject: [PATCH 07/11] Update copyright line --- ports/espressif/boards/m5stack_stamp_s3/pins.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/espressif/boards/m5stack_stamp_s3/pins.c b/ports/espressif/boards/m5stack_stamp_s3/pins.c index a46c1a8dbf568..18955ffc02416 100644 --- a/ports/espressif/boards/m5stack_stamp_s3/pins.c +++ b/ports/espressif/boards/m5stack_stamp_s3/pins.c @@ -1,6 +1,6 @@ // This file is part of the CircuitPython project: https://circuitpython.org // -// SPDX-FileCopyrightText: 2025 Stella Schwankl for Adafruit Industries +// SPDX-FileCopyrightText: 2025 Stella Schwankl // // SPDX-License-Identifier: MIT From eb956202ab1dc78299290564df33d2a1a1cffa82 Mon Sep 17 00:00:00 2001 From: Stella Date: Mon, 13 Jan 2025 13:44:07 -0500 Subject: [PATCH 08/11] Update copyright line --- ports/espressif/boards/m5stack_stamp_s3/board.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/espressif/boards/m5stack_stamp_s3/board.c b/ports/espressif/boards/m5stack_stamp_s3/board.c index 9d8b61025aada..14ada1b09b7a5 100644 --- a/ports/espressif/boards/m5stack_stamp_s3/board.c +++ b/ports/espressif/boards/m5stack_stamp_s3/board.c @@ -1,6 +1,6 @@ // This file is part of the CircuitPython project: https://circuitpython.org // -// SPDX-FileCopyrightText: 2025 Stella Schwankl for Adafruit Industries +// SPDX-FileCopyrightText: 2025 Stella Schwankl // // SPDX-License-Identifier: MIT From 4a586e627945ce765b148ba0636436644a30a329 Mon Sep 17 00:00:00 2001 From: Stella Date: Wed, 15 Jan 2025 09:30:33 -0500 Subject: [PATCH 09/11] Remove LCD code comments --- .../espressif/boards/m5stack_stamp_s3/board.c | 96 ------------------- 1 file changed, 96 deletions(-) diff --git a/ports/espressif/boards/m5stack_stamp_s3/board.c b/ports/espressif/boards/m5stack_stamp_s3/board.c index 14ada1b09b7a5..2978eb0ca1275 100644 --- a/ports/espressif/boards/m5stack_stamp_s3/board.c +++ b/ports/espressif/boards/m5stack_stamp_s3/board.c @@ -5,99 +5,3 @@ // SPDX-License-Identifier: MIT #include "supervisor/board.h" - -// Below section commented out due to LCD not being included by default with StampS3 -// Can be re-enabled to add LCD functionality included by Cardputer replacement kit - -/* - -#include "mpconfigboard.h" -#include "supervisor/shared/serial.h" -#include "shared-bindings/busio/SPI.h" -#include "shared-bindings/fourwire/FourWire.h" -#include "shared-bindings/microcontroller/Pin.h" -#include "shared-module/displayio/__init__.h" -#include "shared-module/displayio/mipi_constants.h" -#include "shared-bindings/board/__init__.h" -#include "py/runtime.h" -#include "py/ringbuf.h" -#include "shared/runtime/interrupt_char.h" - - -#define DELAY 0x80 - -uint8_t display_init_sequence[] = { - // SWRESET and Delay 140ms - 0x01, 0 | DELAY, 140, - // SLPOUT and Delay 10ms - 0x11, 0 | DELAY, 10, - // COLMOD 65k colors and 16 bit 5-6-5 - 0x3A, 1, 0x55, - // INVON Iiversion on - 0x21, 0, - // NORON normal operation (full update) - 0x13, 0, - // MADCTL columns RTL, page/column reverse order - 0x36, 1, 0x60, - // RAMCTRL color word little endian - 0xB0, 2, 0x00, 0xF8, - // DIPON display on - 0x29, 0, -}; - - -// Overrides the weakly linked function from supervisor/shared/board.c -void board_init(void) { - busio_spi_obj_t *spi = common_hal_board_create_spi(0); - fourwire_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; - bus->base.type = &fourwire_fourwire_type; - - // see here for inspiration: https://github.com/m5stack/M5GFX/blob/33d7d3135e816a86a008fae8ab3757938cee95d2/src/M5GFX.cpp#L1350 - common_hal_fourwire_fourwire_construct( - bus, - spi, - &pin_GPIO34, // DC - &pin_GPIO37, // CS - &pin_GPIO33, // RST - 40000000, // baudrate - 0, // polarity - 0 // phase - ); - busdisplay_busdisplay_obj_t *display = &allocate_display()->display; - display->base.type = &busdisplay_busdisplay_type; - - common_hal_busdisplay_busdisplay_construct( - display, - bus, - 240, // width (after rotation) - 135, // height (after rotation) - 40, // column start - 53, // row start - 0, // rotation - 16, // color depth - false, // grayscale - false, // pixels in a byte share a row. Only valid for depths < 8 - 1, // bytes per cell. Only valid for depths < 8 - false, // reverse_pixels_in_byte. Only valid for depths < 8 - false, // reverse_pixels_in_word - MIPI_COMMAND_SET_COLUMN_ADDRESS, // set column command - MIPI_COMMAND_SET_PAGE_ADDRESS, // set row command - MIPI_COMMAND_WRITE_MEMORY_START, // write memory command - display_init_sequence, - sizeof(display_init_sequence), - &pin_GPIO38, // backlight pin - NO_BRIGHTNESS_COMMAND, - 1.0f, // brightness - false, // single_byte_bounds - false, // data_as_commands - true, // auto_refresh - 60, // native_frames_per_second - true, // backlight_on_high - false, // SH1107_addressing - 350 // backlight pwm frequency - ); -} - -// TODO: Should we turn off the display when asleep, in board_deinit() ? - -*/ From 673d6360daf79008b744e35ec5ebf8d7baa4ba79 Mon Sep 17 00:00:00 2001 From: Stella Date: Wed, 15 Jan 2025 09:31:16 -0500 Subject: [PATCH 10/11] Remove LCD code comments --- ports/espressif/boards/m5stack_stamp_s3/mpconfigboard.h | 9 --------- 1 file changed, 9 deletions(-) diff --git a/ports/espressif/boards/m5stack_stamp_s3/mpconfigboard.h b/ports/espressif/boards/m5stack_stamp_s3/mpconfigboard.h index b1d6d657bed09..568ba94be9a2e 100644 --- a/ports/espressif/boards/m5stack_stamp_s3/mpconfigboard.h +++ b/ports/espressif/boards/m5stack_stamp_s3/mpconfigboard.h @@ -18,12 +18,3 @@ #define DEFAULT_UART_BUS_RX (&pin_GPIO44) #define DEFAULT_UART_BUS_TX (&pin_GPIO43) - -// Below section commented out due to LCD not being included by default with StampS3 -// Can be re-enabled to add LCD functionality included by Cardputer replacement kit - -/* -#define CIRCUITPY_BOARD_SPI (2) -#define CIRCUITPY_BOARD_SPI_PIN {{.clock = &pin_GPIO36, .mosi = &pin_GPIO35}, \ - {.clock = &pin_GPIO40, .mosi = &pin_GPIO14, .miso = &pin_GPIO39}} -*/ From 7b747ffed9f2acc76af989635de1fd9c4f728e22 Mon Sep 17 00:00:00 2001 From: Stella Date: Wed, 15 Jan 2025 09:32:00 -0500 Subject: [PATCH 11/11] Remove LCD code comments --- ports/espressif/boards/m5stack_stamp_s3/pins.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/ports/espressif/boards/m5stack_stamp_s3/pins.c b/ports/espressif/boards/m5stack_stamp_s3/pins.c index 18955ffc02416..11995b8c0f801 100644 --- a/ports/espressif/boards/m5stack_stamp_s3/pins.c +++ b/ports/espressif/boards/m5stack_stamp_s3/pins.c @@ -148,10 +148,5 @@ static const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_IO18), MP_ROM_PTR(&pin_GPIO18) }, { MP_ROM_QSTR(MP_QSTR_G18), MP_ROM_PTR(&pin_GPIO18) }, - // Below Display Object commented out due to LCD not being included by default with StampS3 - // Can be re-enabled to add LCD functionality included by Cardputer replacement kit - - // Display Object - // { MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].display)}, }; MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table);