From d82dc89d11e757d8f4962d672646db7115efe027 Mon Sep 17 00:00:00 2001 From: Ken Van Hoeylandt Date: Mon, 13 Oct 2025 23:18:58 +0200 Subject: [PATCH] Add StickC Plus2 implementation --- .github/workflows/build-firmware.yml | 27 +++ Boards/M5stackStickCPlus2/CMakeLists.txt | 2 +- Boards/M5stackStickCPlus2/README.md | 8 +- Boards/M5stackStickCPlus2/Source/InitBoot.cpp | 153 -------------- Boards/M5stackStickCPlus2/Source/InitBoot.h | 9 - .../Source/M5StackStickCPlus2.cpp | 125 ++++++++++++ .../Source/M5StackStickCPlus2.h | 5 + .../Source/M5stackCoreS3.cpp | 193 ------------------ .../M5stackStickCPlus2/Source/M5stackCoreS3.h | 5 - .../Source/devices/Display.cpp | 56 ++--- .../Source/devices/Display.h | 19 +- .../Source/devices/SdCard.cpp | 28 --- .../Source/devices/SdCard.h | 7 - Buildscripts/board.cmake | 2 + Firmware/Kconfig | 2 + Firmware/Source/Boards.h | 3 + sdkconfig.board.m5stack-stickc-plus2 | 24 ++- 17 files changed, 209 insertions(+), 459 deletions(-) delete mode 100644 Boards/M5stackStickCPlus2/Source/InitBoot.cpp delete mode 100644 Boards/M5stackStickCPlus2/Source/InitBoot.h create mode 100644 Boards/M5stackStickCPlus2/Source/M5StackStickCPlus2.cpp create mode 100644 Boards/M5stackStickCPlus2/Source/M5StackStickCPlus2.h delete mode 100644 Boards/M5stackStickCPlus2/Source/M5stackCoreS3.cpp delete mode 100644 Boards/M5stackStickCPlus2/Source/M5stackCoreS3.h delete mode 100644 Boards/M5stackStickCPlus2/Source/devices/SdCard.cpp delete mode 100644 Boards/M5stackStickCPlus2/Source/devices/SdCard.h diff --git a/.github/workflows/build-firmware.yml b/.github/workflows/build-firmware.yml index 1ccf1c10..4151ec2a 100644 --- a/.github/workflows/build-firmware.yml +++ b/.github/workflows/build-firmware.yml @@ -144,6 +144,15 @@ jobs: with: board_id: lilygo-tdeck arch: esp32s3 + lilygo-tdongle-s3: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: "Build" + uses: ./.github/actions/build-firmware + with: + board_id: lilygo-tdongle-s3 + arch: esp32s3 lilygo-tlora-pager: runs-on: ubuntu-latest steps: @@ -180,6 +189,24 @@ jobs: with: board_id: m5stack-cores3 arch: esp32s3 + m5stack-stickc-plus: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: "Build" + uses: ./.github/actions/build-firmware + with: + board_id: m5stack-stickc-plus + arch: esp32 + m5stack-stickc-plus2: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: "Build" + uses: ./.github/actions/build-firmware + with: + board_id: m5stack-stickc-plus2 + arch: esp32 unphone: runs-on: ubuntu-latest steps: diff --git a/Boards/M5stackStickCPlus2/CMakeLists.txt b/Boards/M5stackStickCPlus2/CMakeLists.txt index b2553f94..ac0756d3 100644 --- a/Boards/M5stackStickCPlus2/CMakeLists.txt +++ b/Boards/M5stackStickCPlus2/CMakeLists.txt @@ -3,5 +3,5 @@ file(GLOB_RECURSE SOURCE_FILES Source/*.c*) idf_component_register( SRCS ${SOURCE_FILES} INCLUDE_DIRS "Source" - REQUIRES Tactility esp_lvgl_port ILI934x FT5x06 AXP2101 AW9523 driver vfs fatfs + REQUIRES Tactility esp_lvgl_port esp_lcd ST7789 PwmBacklight ButtonControl ) diff --git a/Boards/M5stackStickCPlus2/README.md b/Boards/M5stackStickCPlus2/README.md index e1381612..bcf12f13 100644 --- a/Boards/M5stackStickCPlus2/README.md +++ b/Boards/M5stackStickCPlus2/README.md @@ -1,7 +1,5 @@ -# M5Stack CoreS3 - -Reference implementations: -- [ESP-BSP](https://github.com/espressif/esp-bsp/tree/master/bsp/m5stack_core_s3) +# M5Stack StickC Plus2 Docs: -- [M5Stack.com](https://docs.m5stack.com/en/core/CoreS3) + +- [M5Stack.com](https://docs.m5stack.com/en/core/M5StickC%20PLUS2) diff --git a/Boards/M5stackStickCPlus2/Source/InitBoot.cpp b/Boards/M5stackStickCPlus2/Source/InitBoot.cpp deleted file mode 100644 index 956ab56f..00000000 --- a/Boards/M5stackStickCPlus2/Source/InitBoot.cpp +++ /dev/null @@ -1,153 +0,0 @@ -#include "InitBoot.h" - -#include -#include - -constexpr auto* TAG = "CoreS3"; - -std::shared_ptr axp2101; -std::shared_ptr aw9523; - -/** - * For details see https://github.com/espressif/esp-bsp/blob/master/bsp/m5stack_core_s3/m5stack_core_s3.c - * and schematic: https://m5stack.oss-cn-shenzhen.aliyuncs.com/resource/docs/datasheet/core/K128%20CoreS3/Sch_M5_CoreS3_v1.0.pdf - */ -bool initGpioExpander() { - TT_LOG_I(TAG, "AW9523 init"); - - /** - * P0 pins: - * 0: Touch reset - * 1: Bus out enable - * 2: AW88298 reset (I2S) - * 3: ES7210 interrupt (Audio ADC) - * 4: SD Card SW(itch on?) - * 5: USB OTG enable - * 6: / - * 7: / - */ - - /** - * P1 pins: - * 0: Cam reset - * 1: LCD reset - * 2: Touch interrupt - * 3: AW88298 interrupt (I2S) - * 4: / - * 5: / - * 6: / - * 7: Boost enable - */ - - uint8_t p0_state = 0U; - uint8_t p1_state = 0U; - - // Enable touch - p0_state |= (1U); - // Bus out enable - p0_state |= (1U << 1U); - // I2S - p0_state |= (1U << 2U); - // SD card - p0_state |= (1U << 4U); - - // Enable LCD - p1_state |= (1U << 1U); - // Boost enable - p1_state |= (1U << 7U); - - /* AW9523 P0 is in push-pull mode */ - if (!aw9523->writeCTL(0x10)) { - TT_LOG_E(TAG, "AW9523: Failed to set CTL"); - return false; - } - - if (!aw9523->writeP0(p0_state)) { - TT_LOG_E(TAG, "AW9523: Failed to set P0"); - return false; - } - - if (!aw9523->writeP1(p1_state)) { - TT_LOG_E(TAG, "AW9523: Failed to set P1"); - return false; - } - - if (axp2101->isVBus()) { - float voltage = 0.0f; - axp2101->getVBusVoltage(voltage); - TT_LOG_I(TAG, "AXP2101: VBus at %.2f", voltage); - } else { - TT_LOG_W(TAG, "AXP2101: VBus disabled"); - } - - return true; -} - -bool initPowerControl() { - TT_LOG_I(TAG, "Init power control (AXP2101)"); - - // Source: https://github.com/m5stack/M5Unified/blob/b8cfec7fed046242da7f7b8024a4e92004a51ff7/src/utility/Power_Class.cpp#L61 - aw9523->bitOnP1(0b10000000); // SY7088 boost enable - - /** AXP2101 usage - Source: https://github.com/m5stack/M5Unified/blob/b8cfec7fed046242da7f7b8024a4e92004a51ff7/README.md?plain=1#L223 - | |M5Stack
CoreS3
CoreS3SE| | - |:---------:|:-----------------:|:---------:| - | ALDO1 |VDD 1v8 | ALDO1 | - | ALDO2 |VDDA 3v3 | ALDO2 | - | ALDO3 |CAM 3v3 | ALDO3 | - | ALDO4 |TF 3v3 | ALDO4 | - | BLDO1 |AVDD | BLDO1 | - | BLDO2 |DVDD | BLDO2 | - | DLDO1/DC1 |LCD BL | DLDO1/DC1 | - | DLDO2/DC2 | --- | DLDO2/DC2 | - | BACKUP |RTC BAT | BACKUP | - */ - - /** - * 0x92 = ALD01 - * 0x93 = ALD02 - * 0x94 = ALD03 - * 0x95 = ALD04 - * 0x96 = BLD01 - * 0x97 = BLD02 - * - * DCDC1 : 0.7-3.5V, 25mV/step 1200mA - * DCDC2 : 0.7-2.275V,25mV/step 1600mA - * DCDC3 : 0.7-3.5V, 25mV/step 700mA - - * LDOio0: 1.8-3.3V, 100mV/step 50mA - * LDO1 : 30mA always on - * LDO2 : 1.8-3.3V, 100mV/step 200mA - * LDO3 : 1.8-3.3V, 100mV/step 200mA - */ - // Source: https://github.com/m5stack/M5Unified/blob/b8cfec7fed046242da7f7b8024a4e92004a51ff7/src/utility/Power_Class.cpp#L64 - static constexpr uint8_t reg_data_array[] = { - 0x90U, 0xBFU, // LDOS ON/OFF control 0 (backlight) - 0x92U, 18U -5U, // ALDO1 set to 1.8v // for AW88298 - 0x93U, 33U -5U, // ALDO2 set to 3.3v // for ES7210 - 0x94U, 33U -5U, // ALDO3 set to 3.3v // for camera - 0x95U, 33U -5U, // ALDO3 set to 3.3v // for TF card slot - 0x27, 0x00, // PowerKey Hold=1sec / PowerOff=4sec - 0x69, 0x11, // CHGLED setting - 0x10, 0x30, // PMU common config - 0x30, 0x0F // ADC enabled (for voltage measurement) - }; - - if (axp2101->setRegisters((uint8_t*)reg_data_array, sizeof(reg_data_array))) { - TT_LOG_I(TAG, "AXP2101 initialized with %d registers", sizeof(reg_data_array) / 2); - return true; - } else { - TT_LOG_E(TAG, "AXP2101: Failed to set registers"); - return false; - } -} - -bool initBoot() { - TT_LOG_I(TAG, "initBoot()"); - - axp2101 = std::make_shared(I2C_NUM_0); - aw9523 = std::make_shared(I2C_NUM_0); - - return initPowerControl() && initGpioExpander(); -} \ No newline at end of file diff --git a/Boards/M5stackStickCPlus2/Source/InitBoot.h b/Boards/M5stackStickCPlus2/Source/InitBoot.h deleted file mode 100644 index 70156960..00000000 --- a/Boards/M5stackStickCPlus2/Source/InitBoot.h +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once - -#include -#include - -extern std::shared_ptr axp2101; -extern std::shared_ptr aw9523; - -bool initBoot(); diff --git a/Boards/M5stackStickCPlus2/Source/M5StackStickCPlus2.cpp b/Boards/M5stackStickCPlus2/Source/M5StackStickCPlus2.cpp new file mode 100644 index 00000000..aa8cb0e0 --- /dev/null +++ b/Boards/M5stackStickCPlus2/Source/M5StackStickCPlus2.cpp @@ -0,0 +1,125 @@ +#include "M5StackStickCPlus2.h" +#include "devices/Display.h" + +#include +#include +#include + +#define SPI_TRANSFER_SIZE_LIMIT (LCD_DRAW_BUFFER_SIZE * LV_COLOR_DEPTH / 8) + +using namespace tt::hal; + +constexpr auto* TAG = "StickCPlus2"; + +bool initBoot() { + TT_LOG_I(TAG, "initBoot"); + + // CH552 applies 4 V to GPIO 0, which reduces Wi-Fi sensitivity + // Setting output to high adds a bias of 3.3 V and suppresses over-voltage: + gpio::configure(0, gpio::Mode::Output, false, false); + gpio::setLevel(0, true); + + // "Hold power" pin: must be set to high to keep the device powered on: + gpio::configure(4, gpio::Mode::Output, false, false); + gpio::setLevel(4, true); + return driver::pwmbacklight::init(GPIO_NUM_27, 512); +} + +static DeviceVector createDevices() { + return { + ButtonControl::createTwoButtonControl(37, 39), + createDisplay() + }; +} + +extern const Configuration m5stack_stickc_plus2 = { + .initBoot = initBoot, + .uiScale = UiScale::Smallest, + .createDevices = createDevices, + .i2c = { + i2c::Configuration { + .name = "Internal", + .port = I2C_NUM_0, + .initMode = i2c::InitMode::ByTactility, + .isMutable = false, + .config = (i2c_config_t) { + .mode = I2C_MODE_MASTER, + .sda_io_num = GPIO_NUM_21, + .scl_io_num = GPIO_NUM_22, + .sda_pullup_en = true, + .scl_pullup_en = true, + .master = { + .clk_speed = 400000 + }, + .clk_flags = 0 + } + }, + i2c::Configuration { + .name = "Grove", + .port = I2C_NUM_1, + .initMode = i2c::InitMode::ByTactility, + .isMutable = true, + .config = (i2c_config_t) { + .mode = I2C_MODE_MASTER, + .sda_io_num = GPIO_NUM_32, + .scl_io_num = GPIO_NUM_33, + .sda_pullup_en = true, + .scl_pullup_en = true, + .master = { + .clk_speed = 400000 + }, + .clk_flags = 0 + } + } + }, + .spi { + spi::Configuration { + .device = SPI2_HOST, + .dma = SPI_DMA_CH_AUTO, + .config = { + .mosi_io_num = GPIO_NUM_15, + .miso_io_num = GPIO_NUM_NC, + .sclk_io_num = GPIO_NUM_13, + .quadwp_io_num = GPIO_NUM_NC, + .quadhd_io_num = GPIO_NUM_NC, + .data4_io_num = GPIO_NUM_NC, + .data5_io_num = GPIO_NUM_NC, + .data6_io_num = GPIO_NUM_NC, + .data7_io_num = GPIO_NUM_NC, + .data_io_default_level = false, + .max_transfer_sz = SPI_TRANSFER_SIZE_LIMIT, + .flags = 0, + .isr_cpu_id = ESP_INTR_CPU_AFFINITY_AUTO, + .intr_flags = 0 + }, + .initMode = spi::InitMode::ByTactility, + .isMutable = false, + .lock = tt::lvgl::getSyncLock() // esp_lvgl_port owns the lock for the display + } + }, + .uart { + uart::Configuration { + .name = "Grove", + .port = UART_NUM_1, + .rxPin = GPIO_NUM_32, + .txPin = GPIO_NUM_33, + .rtsPin = GPIO_NUM_NC, + .ctsPin = GPIO_NUM_NC, + .rxBufferSize = 1024, + .txBufferSize = 1024, + .config = { + .baud_rate = 115200, + .data_bits = UART_DATA_8_BITS, + .parity = UART_PARITY_DISABLE, + .stop_bits = UART_STOP_BITS_1, + .flow_ctrl = UART_HW_FLOWCTRL_DISABLE, + .rx_flow_ctrl_thresh = 0, + .source_clk = UART_SCLK_DEFAULT, + .flags = { + .allow_pd = 0, + .backup_before_sleep = 0, + } + } + }, + } +}; diff --git a/Boards/M5stackStickCPlus2/Source/M5StackStickCPlus2.h b/Boards/M5stackStickCPlus2/Source/M5StackStickCPlus2.h new file mode 100644 index 00000000..df4950d0 --- /dev/null +++ b/Boards/M5stackStickCPlus2/Source/M5StackStickCPlus2.h @@ -0,0 +1,5 @@ +#pragma once + +#include + +extern const tt::hal::Configuration m5stack_stickc_plus2; diff --git a/Boards/M5stackStickCPlus2/Source/M5stackCoreS3.cpp b/Boards/M5stackStickCPlus2/Source/M5stackCoreS3.cpp deleted file mode 100644 index dc843a52..00000000 --- a/Boards/M5stackStickCPlus2/Source/M5stackCoreS3.cpp +++ /dev/null @@ -1,193 +0,0 @@ -#include "M5stackCoreS3.h" -#include "InitBoot.h" -#include "devices/Display.h" -#include "devices/SdCard.h" - -#include -#include -#include - -#define CORES3_TRANSACTION_SIZE (CORES3_LCD_DRAW_BUFFER_SIZE * LV_COLOR_DEPTH / 8) - -using namespace tt::hal; - -static DeviceVector createDevices() { - return { - axp2101, - aw9523, - std::make_shared(axp2101), - createSdCard(), - createDisplay() - }; -} - -const Configuration m5stack_cores3 = { - .initBoot = initBoot, - .createDevices = createDevices, - .i2c = { - i2c::Configuration { - .name = "Internal", - .port = I2C_NUM_0, - .initMode = i2c::InitMode::ByTactility, - .isMutable = false, - .config = (i2c_config_t) { - .mode = I2C_MODE_MASTER, - .sda_io_num = GPIO_NUM_12, - .scl_io_num = GPIO_NUM_11, - .sda_pullup_en = true, - .scl_pullup_en = true, - .master = { - .clk_speed = 400000 - }, - .clk_flags = 0 - } - }, - i2c::Configuration { - .name = "Port A", // Grove - .port = I2C_NUM_1, - .initMode = i2c::InitMode::Disabled, - .isMutable = true, - .config = (i2c_config_t) { - .mode = I2C_MODE_MASTER, - .sda_io_num = GPIO_NUM_2, - .scl_io_num = GPIO_NUM_1, - .sda_pullup_en = true, - .scl_pullup_en = true, - .master = { - .clk_speed = 400000 - }, - .clk_flags = 0 - } - }, - i2c::Configuration { - .name = "Port B", // Grove - .port = I2C_NUM_1, - .initMode = i2c::InitMode::Disabled, - .isMutable = true, - .config = (i2c_config_t) { - .mode = I2C_MODE_MASTER, - .sda_io_num = GPIO_NUM_9, - .scl_io_num = GPIO_NUM_8, - .sda_pullup_en = true, - .scl_pullup_en = true, - .master = { - .clk_speed = 400000 - }, - .clk_flags = 0 - } - }, - i2c::Configuration { - .name = "Port C", // Grove - .port = I2C_NUM_1, - .initMode = i2c::InitMode::Disabled, - .isMutable = true, - .config = (i2c_config_t) { - .mode = I2C_MODE_MASTER, - .sda_io_num = GPIO_NUM_18, - .scl_io_num = GPIO_NUM_17, - .sda_pullup_en = true, - .scl_pullup_en = true, - .master = { - .clk_speed = 400000 - }, - .clk_flags = 0 - } - } - }, - .spi { - spi::Configuration { - .device = SPI3_HOST, - .dma = SPI_DMA_CH_AUTO, - .config = { - .mosi_io_num = GPIO_NUM_37, - .miso_io_num = GPIO_NUM_35, - .sclk_io_num = GPIO_NUM_36, - .data2_io_num = GPIO_NUM_NC, - .data3_io_num = GPIO_NUM_NC, - .data4_io_num = GPIO_NUM_NC, - .data5_io_num = GPIO_NUM_NC, - .data6_io_num = GPIO_NUM_NC, - .data7_io_num = GPIO_NUM_NC, - .data_io_default_level = false, - .max_transfer_sz = CORES3_TRANSACTION_SIZE, - .flags = 0, - .isr_cpu_id = ESP_INTR_CPU_AFFINITY_AUTO, - .intr_flags = 0 - }, - .initMode = spi::InitMode::ByTactility, - .isMutable = false, - .lock = tt::lvgl::getSyncLock() // esp_lvgl_port owns the lock for the display - } - }, - .uart { - uart::Configuration { - .name = "Port A", - .port = UART_NUM_1, - .rxPin = GPIO_NUM_2, - .txPin = GPIO_NUM_1, - .rtsPin = GPIO_NUM_NC, - .ctsPin = GPIO_NUM_NC, - .rxBufferSize = 1024, - .txBufferSize = 1024, - .config = { - .baud_rate = 115200, - .data_bits = UART_DATA_8_BITS, - .parity = UART_PARITY_DISABLE, - .stop_bits = UART_STOP_BITS_1, - .flow_ctrl = UART_HW_FLOWCTRL_DISABLE, - .rx_flow_ctrl_thresh = 0, - .source_clk = UART_SCLK_DEFAULT, - .flags = { - .allow_pd = 0, - .backup_before_sleep = 0, - } - } - }, - uart::Configuration { - .name = "Port B", - .port = UART_NUM_1, - .rxPin = GPIO_NUM_9, - .txPin = GPIO_NUM_8, - .rtsPin = GPIO_NUM_NC, - .ctsPin = GPIO_NUM_NC, - .rxBufferSize = 1024, - .txBufferSize = 1024, - .config = { - .baud_rate = 115200, - .data_bits = UART_DATA_8_BITS, - .parity = UART_PARITY_DISABLE, - .stop_bits = UART_STOP_BITS_1, - .flow_ctrl = UART_HW_FLOWCTRL_DISABLE, - .rx_flow_ctrl_thresh = 0, - .source_clk = UART_SCLK_DEFAULT, - .flags = { - .allow_pd = 0, - .backup_before_sleep = 0, - } - } - }, - uart::Configuration { - .name = "Port C", - .port = UART_NUM_1, - .rxPin = GPIO_NUM_18, - .txPin = GPIO_NUM_17, - .rtsPin = GPIO_NUM_NC, - .ctsPin = GPIO_NUM_NC, - .rxBufferSize = 1024, - .txBufferSize = 1024, - .config = { - .baud_rate = 115200, - .data_bits = UART_DATA_8_BITS, - .parity = UART_PARITY_DISABLE, - .stop_bits = UART_STOP_BITS_1, - .flow_ctrl = UART_HW_FLOWCTRL_DISABLE, - .rx_flow_ctrl_thresh = 0, - .source_clk = UART_SCLK_DEFAULT, - .flags = { - .allow_pd = 0, - .backup_before_sleep = 0, - } - } - } - } -}; diff --git a/Boards/M5stackStickCPlus2/Source/M5stackCoreS3.h b/Boards/M5stackStickCPlus2/Source/M5stackCoreS3.h deleted file mode 100644 index 120c7697..00000000 --- a/Boards/M5stackStickCPlus2/Source/M5stackCoreS3.h +++ /dev/null @@ -1,5 +0,0 @@ -#pragma once - -#include - -extern const tt::hal::Configuration m5stack_cores3; diff --git a/Boards/M5stackStickCPlus2/Source/devices/Display.cpp b/Boards/M5stackStickCPlus2/Source/devices/Display.cpp index 42105e71..f97b88c8 100644 --- a/Boards/M5stackStickCPlus2/Source/devices/Display.cpp +++ b/Boards/M5stackStickCPlus2/Source/devices/Display.cpp @@ -1,51 +1,29 @@ #include "Display.h" -#include -#include -#include -#include -#include - -constexpr auto* TAG = "CoreS3Display"; - -static void setBacklightDuty(uint8_t backlightDuty) { - const uint8_t voltage = 20 + ((8 * backlightDuty) / 255); // [0b00000, 0b11100] - under 20 is too dark - // TODO: Refactor to use Axp2102 driver subproject. Reference: https://github.com/m5stack/M5Unified/blob/b8cfec7fed046242da7f7b8024a4e92004a51ff7/src/utility/AXP2101_Class.cpp#L42 - if (!tt::hal::i2c::masterWriteRegister(I2C_NUM_0, AXP2101_ADDRESS, 0x99, &voltage, 1, 1000)) { // Sets DLD01 - TT_LOG_E(TAG, "Failed to set display backlight voltage"); - } -} - -static std::shared_ptr createTouch() { - // Note for future changes: Reset pin is 48 and interrupt pin is 47 - auto configuration = std::make_unique( - I2C_NUM_0, - 320, - 240 - ); - - auto touch = std::make_shared(std::move(configuration)); - return std::reinterpret_pointer_cast(touch); -} +#include +#include std::shared_ptr createDisplay() { - auto touch = createTouch(); - - auto configuration = std::make_unique( - SPI3_HOST, - GPIO_NUM_3, - GPIO_NUM_35, - 320, - 240, - touch, + auto configuration = std::make_unique( + LCD_SPI_HOST, + LCD_PIN_CS, + LCD_PIN_DC, + LCD_HORIZONTAL_RESOLUTION, + LCD_VERTICAL_RESOLUTION, + nullptr, false, false, false, - true + true, + LCD_DRAW_BUFFER_SIZE, + 52, + 40 ); - configuration->backlightDutyFunction = ::setBacklightDuty; + configuration->pixelClockFrequency = 40'000'000; + configuration->resetPin = LCD_PIN_RESET; + configuration->backlightDutyFunction = driver::pwmbacklight::setBacklightDuty; - auto display = std::make_shared(std::move(configuration)); + const auto display = std::make_shared(std::move(configuration)); return std::reinterpret_pointer_cast(display); } diff --git a/Boards/M5stackStickCPlus2/Source/devices/Display.h b/Boards/M5stackStickCPlus2/Source/devices/Display.h index b180a5fb..87c666dc 100644 --- a/Boards/M5stackStickCPlus2/Source/devices/Display.h +++ b/Boards/M5stackStickCPlus2/Source/devices/Display.h @@ -1,14 +1,15 @@ #pragma once -#include +#include "Tactility/hal/display/DisplayDevice.h" +#include -// Display -#define CORES3_LCD_SPI_HOST SPI3_HOST -#define CORES3_LCD_PIN_CS GPIO_NUM_3 -#define CORES3_LCD_PIN_DC GPIO_NUM_35 -#define CORES3_LCD_HORIZONTAL_RESOLUTION 320 -#define CORES3_LCD_VERTICAL_RESOLUTION 240 -#define CORES3_LCD_DRAW_BUFFER_HEIGHT (CORES3_LCD_VERTICAL_RESOLUTION / 10) -#define CORES3_LCD_DRAW_BUFFER_SIZE (CORES3_LCD_HORIZONTAL_RESOLUTION * CORES3_LCD_DRAW_BUFFER_HEIGHT) +#define LCD_SPI_HOST SPI2_HOST +#define LCD_PIN_CS GPIO_NUM_5 +#define LCD_PIN_DC GPIO_NUM_14 +#define LCD_PIN_RESET GPIO_NUM_12 +#define LCD_HORIZONTAL_RESOLUTION 135 +#define LCD_VERTICAL_RESOLUTION 240 +#define LCD_DRAW_BUFFER_HEIGHT (LCD_VERTICAL_RESOLUTION / 3) +#define LCD_DRAW_BUFFER_SIZE (LCD_HORIZONTAL_RESOLUTION * LCD_DRAW_BUFFER_HEIGHT) std::shared_ptr createDisplay(); diff --git a/Boards/M5stackStickCPlus2/Source/devices/SdCard.cpp b/Boards/M5stackStickCPlus2/Source/devices/SdCard.cpp deleted file mode 100644 index f314b5f5..00000000 --- a/Boards/M5stackStickCPlus2/Source/devices/SdCard.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include "SdCard.h" - -#include -#include - -constexpr auto CORES3_SDCARD_PIN_CS = GPIO_NUM_4; -constexpr auto CORES3_LCD_PIN_CS = GPIO_NUM_3; - -using tt::hal::sdcard::SpiSdCardDevice; - -std::shared_ptr createSdCard() { - auto configuration = std::make_unique( - CORES3_SDCARD_PIN_CS, - GPIO_NUM_NC, - GPIO_NUM_NC, - GPIO_NUM_NC, - SdCardDevice::MountBehaviour::AtBoot, - tt::lvgl::getSyncLock(), - std::vector { - CORES3_LCD_PIN_CS - }, - SPI3_HOST - ); - - return std::make_shared( - std::move(configuration) - ); -} diff --git a/Boards/M5stackStickCPlus2/Source/devices/SdCard.h b/Boards/M5stackStickCPlus2/Source/devices/SdCard.h deleted file mode 100644 index 5cb65a73..00000000 --- a/Boards/M5stackStickCPlus2/Source/devices/SdCard.h +++ /dev/null @@ -1,7 +0,0 @@ -#pragma once - -#include "Tactility/hal/sdcard/SdCardDevice.h" - -using tt::hal::sdcard::SdCardDevice; - -std::shared_ptr createSdCard(); diff --git a/Buildscripts/board.cmake b/Buildscripts/board.cmake index 2002ab38..d9961b2e 100644 --- a/Buildscripts/board.cmake +++ b/Buildscripts/board.cmake @@ -63,6 +63,8 @@ function(INIT_TACTILITY_GLOBALS SDKCONFIG_FILE) set(TACTILITY_BOARD_PROJECT M5stackCoreS3) elseif (board_id STREQUAL "m5stack-stickc-plus") set(TACTILITY_BOARD_PROJECT M5stackStickCPlus) + elseif (board_id STREQUAL "m5stack-stickc-plus2") + set(TACTILITY_BOARD_PROJECT M5stackStickCPlus2) elseif (board_id STREQUAL "unphone") set(TACTILITY_BOARD_PROJECT UnPhone) elseif (board_id STREQUAL "waveshare-s3-touch-43") diff --git a/Firmware/Kconfig b/Firmware/Kconfig index 26316734..caf41383 100644 --- a/Firmware/Kconfig +++ b/Firmware/Kconfig @@ -53,6 +53,8 @@ menu "Tactility App" bool "M5Stack CoreS3" config TT_BOARD_M5STACK_STICKC_PLUS bool "M5Stack StickC Plus" + config TT_BOARD_M5STACK_STICKC_PLUS2 + bool "M5Stack StickC Plus2" config TT_BOARD_UNPHONE bool "unPhone" config TT_BOARD_WAVESHARE_S3_TOUCH_43 diff --git a/Firmware/Source/Boards.h b/Firmware/Source/Boards.h index 74283d48..cc1e4e0f 100644 --- a/Firmware/Source/Boards.h +++ b/Firmware/Source/Boards.h @@ -56,6 +56,9 @@ #elif defined(CONFIG_TT_BOARD_M5STACK_STICKC_PLUS) #include "M5StackStickCPlus.h" #define TT_BOARD_HARDWARE &m5stack_stickc_plus +#elif defined(CONFIG_TT_BOARD_M5STACK_STICKC_PLUS2) +#include "M5StackStickCPlus2.h" +#define TT_BOARD_HARDWARE &m5stack_stickc_plus2 #elif defined(CONFIG_TT_BOARD_UNPHONE) #include "UnPhone.h" #define TT_BOARD_HARDWARE &unPhone diff --git a/sdkconfig.board.m5stack-stickc-plus2 b/sdkconfig.board.m5stack-stickc-plus2 index 8ca6d986..9f7bbb16 100644 --- a/sdkconfig.board.m5stack-stickc-plus2 +++ b/sdkconfig.board.m5stack-stickc-plus2 @@ -33,24 +33,28 @@ CONFIG_WL_SECTOR_MODE=1 CONFIG_PARTITION_TABLE_CUSTOM=y CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions-8mb.csv" CONFIG_PARTITION_TABLE_FILENAME="partitions-8mb.csv" -CONFIG_TT_BOARD_LILYGO_TDECK=y +CONFIG_TT_BOARD_M5STACK_STICKC_PLUS2=y CONFIG_TT_BOARD_NAME="M5Stack StickC Plus2" CONFIG_TT_BOARD_ID="m5stack-stickc-plus2" CONFIG_IDF_EXPERIMENTAL_FEATURES=y -CONFIG_IDF_TARGET="esp32s3" +CONFIG_IDF_TARGET="esp32" CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y CONFIG_ESP32_DEFAULT_CPU_FREQ_240=y CONFIG_ESPTOOLPY_FLASHSIZE_8MB=y +CONFIG_ESPTOOLPY_FLASHFREQ_80M=y CONFIG_FLASHMODE_QIO=y # Hardware: SPI RAM -CONFIG_ESP32S3_SPIRAM_SUPPORT=y -CONFIG_SPIRAM_MODE_OCT=y -CONFIG_SPIRAM_SPEED_120M=y -CONFIG_SPIRAM_USE_MALLOC=y +CONFIG_ESP32_SPIRAM_SUPPORT=y +CONFIG_SPIRAM=y +CONFIG_SPIRAM_MODE_QUAD=y +CONFIG_SPIRAM_SPEED_80M=y CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP=y -# SPI Flash (can set back to 80MHz after ESP-IDF bug is resolved) -CONFIG_ESPTOOLPY_FLASHFREQ_120M=y # LVGL -CONFIG_LV_DPI_DEF=241 CONFIG_LV_DISP_DEF_REFR_PERIOD=10 -CONFIG_LV_THEME_DEFAULT_DARK=y \ No newline at end of file +CONFIG_LV_DPI_DEF=241 +CONFIG_LV_THEME_DEFAULT_DARK=y +# Fix for IRAM +CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH=y +CONFIG_FREERTOS_PLACE_SNAPSHOT_FUNS_INTO_FLASH=y +CONFIG_HEAP_PLACE_FUNCTION_INTO_FLASH=y +CONFIG_RINGBUF_PLACE_FUNCTIONS_INTO_FLASH=y