mirror of
https://github.com/ByteWelder/Tactility.git
synced 2026-02-20 23:45:05 +00:00
Add StickC Plus2 implementation
This commit is contained in:
parent
bd7e6197f4
commit
d82dc89d11
27
.github/workflows/build-firmware.yml
vendored
27
.github/workflows/build-firmware.yml
vendored
@ -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:
|
||||
|
||||
@ -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
|
||||
)
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -1,153 +0,0 @@
|
||||
#include "InitBoot.h"
|
||||
|
||||
#include <Tactility/Log.h>
|
||||
#include <Tactility/kernel/Kernel.h>
|
||||
|
||||
constexpr auto* TAG = "CoreS3";
|
||||
|
||||
std::shared_ptr<Axp2101> axp2101;
|
||||
std::shared_ptr<Aw9523> 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<BR>CoreS3<BR>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<Axp2101>(I2C_NUM_0);
|
||||
aw9523 = std::make_shared<Aw9523>(I2C_NUM_0);
|
||||
|
||||
return initPowerControl() && initGpioExpander();
|
||||
}
|
||||
@ -1,9 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <Axp2101.h>
|
||||
#include <Aw9523.h>
|
||||
|
||||
extern std::shared_ptr<Axp2101> axp2101;
|
||||
extern std::shared_ptr<Aw9523> aw9523;
|
||||
|
||||
bool initBoot();
|
||||
125
Boards/M5stackStickCPlus2/Source/M5StackStickCPlus2.cpp
Normal file
125
Boards/M5stackStickCPlus2/Source/M5StackStickCPlus2.cpp
Normal file
@ -0,0 +1,125 @@
|
||||
#include "M5StackStickCPlus2.h"
|
||||
#include "devices/Display.h"
|
||||
|
||||
#include <ButtonControl.h>
|
||||
#include <PwmBacklight.h>
|
||||
#include <Tactility/lvgl/LvglSync.h>
|
||||
|
||||
#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,
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
};
|
||||
5
Boards/M5stackStickCPlus2/Source/M5StackStickCPlus2.h
Normal file
5
Boards/M5stackStickCPlus2/Source/M5StackStickCPlus2.h
Normal file
@ -0,0 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include <Tactility/hal/Configuration.h>
|
||||
|
||||
extern const tt::hal::Configuration m5stack_stickc_plus2;
|
||||
@ -1,193 +0,0 @@
|
||||
#include "M5stackCoreS3.h"
|
||||
#include "InitBoot.h"
|
||||
#include "devices/Display.h"
|
||||
#include "devices/SdCard.h"
|
||||
|
||||
#include <Axp2101Power.h>
|
||||
#include <Tactility/lvgl/LvglSync.h>
|
||||
#include <Tactility/hal/uart/Uart.h>
|
||||
|
||||
#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<Axp2101Power>(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,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -1,5 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <Tactility/hal/Configuration.h>
|
||||
|
||||
extern const tt::hal::Configuration m5stack_cores3;
|
||||
@ -1,51 +1,29 @@
|
||||
#include "Display.h"
|
||||
|
||||
#include <Axp2101.h>
|
||||
#include <Ft5x06Touch.h>
|
||||
#include <Ili934xDisplay.h>
|
||||
#include <Tactility/Log.h>
|
||||
#include <Tactility/hal/i2c/I2c.h>
|
||||
|
||||
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<tt::hal::touch::TouchDevice> createTouch() {
|
||||
// Note for future changes: Reset pin is 48 and interrupt pin is 47
|
||||
auto configuration = std::make_unique<Ft5x06Touch::Configuration>(
|
||||
I2C_NUM_0,
|
||||
320,
|
||||
240
|
||||
);
|
||||
|
||||
auto touch = std::make_shared<Ft5x06Touch>(std::move(configuration));
|
||||
return std::reinterpret_pointer_cast<tt::hal::touch::TouchDevice>(touch);
|
||||
}
|
||||
#include <PwmBacklight.h>
|
||||
#include <St7789Display.h>
|
||||
|
||||
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay() {
|
||||
auto touch = createTouch();
|
||||
|
||||
auto configuration = std::make_unique<Ili934xDisplay::Configuration>(
|
||||
SPI3_HOST,
|
||||
GPIO_NUM_3,
|
||||
GPIO_NUM_35,
|
||||
320,
|
||||
240,
|
||||
touch,
|
||||
auto configuration = std::make_unique<St7789Display::Configuration>(
|
||||
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<Ili934xDisplay>(std::move(configuration));
|
||||
const auto display = std::make_shared<St7789Display>(std::move(configuration));
|
||||
return std::reinterpret_pointer_cast<tt::hal::display::DisplayDevice>(display);
|
||||
}
|
||||
|
||||
@ -1,14 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
#include <Tactility/hal/display/DisplayDevice.h>
|
||||
#include "Tactility/hal/display/DisplayDevice.h"
|
||||
#include <memory>
|
||||
|
||||
// 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<tt::hal::display::DisplayDevice> createDisplay();
|
||||
|
||||
@ -1,28 +0,0 @@
|
||||
#include "SdCard.h"
|
||||
|
||||
#include <Tactility/lvgl/LvglSync.h>
|
||||
#include <Tactility/hal/sdcard/SpiSdCardDevice.h>
|
||||
|
||||
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<SdCardDevice> createSdCard() {
|
||||
auto configuration = std::make_unique<SpiSdCardDevice::Config>(
|
||||
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<SpiSdCardDevice>(
|
||||
std::move(configuration)
|
||||
);
|
||||
}
|
||||
@ -1,7 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "Tactility/hal/sdcard/SdCardDevice.h"
|
||||
|
||||
using tt::hal::sdcard::SdCardDevice;
|
||||
|
||||
std::shared_ptr<SdCardDevice> createSdCard();
|
||||
@ -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")
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user