Board implementations and fixes (#247)

- Implemented Elecrow Crowpanel Basic 5.0"
- Implemented Elecrow Crowpanel Advance 5.0"
- Implemented CYD 2432S032C
- Fix for CYD 4848S040C rendering drift (lower transfer speed)
- Fix for SD card locking mechanism for various boards
This commit is contained in:
Ken Van Hoeylandt 2025-03-14 22:37:09 +01:00 committed by GitHub
parent 21936f7e9e
commit f85d0239ff
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
64 changed files with 1587 additions and 134 deletions

View File

@ -18,6 +18,15 @@ jobs:
with:
board_id: cyd-2432S024c
arch: esp32
cyd-2432S032c:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: "Build"
uses: ./.github/actions/build-firmware
with:
board_id: cyd-2432S032c
arch: esp32
cyd-jc2432w328c:
runs-on: ubuntu-latest
steps:
@ -72,6 +81,15 @@ jobs:
with:
board_id: elecrow-crowpanel-advance-35
arch: esp32s3
elecrow-crowpanel-advance-50:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: "Build"
uses: ./.github/actions/build-firmware
with:
board_id: elecrow-crowpanel-advance-50
arch: esp32s3
elecrow-crowpanel-basic-28:
runs-on: ubuntu-latest
steps:
@ -90,6 +108,15 @@ jobs:
with:
board_id: elecrow-crowpanel-basic-35
arch: esp32
elecrow-crowpanel-basic-50:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: "Build"
uses: ./.github/actions/build-firmware
with:
board_id: elecrow-crowpanel-basic-50
arch: esp32s3
lilygo-tdeck:
runs-on: ubuntu-latest
steps:

View File

@ -6,23 +6,26 @@ if (DEFINED ENV{ESP_IDF_VERSION})
if("${IDF_TARGET}" STREQUAL "esp32")
list(APPEND BOARD_COMPONENTS
CYD-2432S024C
CYD-2432S032C
CYD-JC2432W328C
ElecrowCrowpanelBasic28
ElecrowCrowpanelBasic35
M5stackCore2
CYD-JC2432W328C
)
endif()
if("${IDF_TARGET}" STREQUAL "esp32s3")
list(APPEND BOARD_COMPONENTS
CYD-4848S040C
CYD-8048S043C
CYD-JC8048W550C
ElecrowCrowpanelAdvance28
ElecrowCrowpanelAdvance35
ElecrowCrowpanelAdvance50
ElecrowCrowpanelBasic50
LilygoTdeck
M5stackCoreS3
UnPhone
CYD-8048S043C
CYD-JC8048W550C
CYD-4848S040C
)
endif()

View File

@ -13,6 +13,8 @@ menu "Tactility App"
bool "Custom"
config TT_BOARD_CYD_2432S024C
bool "CYD 2432S024C"
config TT_BOARD_CYD_2432S032C
bool "CYD 2432S032C"
config TT_BOARD_CYD_8048S043C
bool "CYD 8048S043C"
config TT_BOARD_CYD_JC2432W328C
@ -25,10 +27,14 @@ menu "Tactility App"
bool "Elecrow CrowPanel Advance 2.8"
config TT_BOARD_ELECROW_CROWPANEL_ADVANCE_35
bool "Elecrow CrowPanel Advance 3.5"
config TT_BOARD_ELECROW_CROWPANEL_ADVANCE_50
bool "Elecrow CrowPanel Advance 5.0"
config TT_BOARD_ELECROW_CROWPANEL_BASIC_28
bool "Elecrow CrowPanel Basic 2.8"
config TT_BOARD_ELECROW_CROWPANEL_BASIC_35
bool "Elecrow CrowPanel Basic 3.5"
config TT_BOARD_ELECROW_CROWPANEL_BASIC_50
bool "Elecrow CrowPanel Basic 5.0"
config TT_BOARD_LILYGO_TDECK
bool "LilyGo T-Deck"
config TT_BOARD_M5STACK_CORE2

View File

@ -10,18 +10,27 @@
#elif defined(CONFIG_TT_BOARD_CYD_2432S024C)
#include "CYD2432S024C.h"
#define TT_BOARD_HARDWARE &cyd_2432S024c_config
#elif defined(CONFIG_TT_BOARD_CYD_2432S032C)
#include "CYD2432S032C.h"
#define TT_BOARD_HARDWARE &cyd_2432S032c_config
#elif (defined(CONFIG_TT_BOARD_ELECROW_CROWPANEL_ADVANCE_28))
#define TT_BOARD_HARDWARE &crowpanel_advance_28
#include "CrowPanelAdvance28.h"
#elif (defined(CONFIG_TT_BOARD_ELECROW_CROWPANEL_ADVANCE_35))
#define TT_BOARD_HARDWARE &crowpanel_advance_35
#include "CrowPanelAdvance35.h"
#elif (defined(CONFIG_TT_BOARD_ELECROW_CROWPANEL_ADVANCE_50))
#define TT_BOARD_HARDWARE &crowpanel_advance_50
#include "CrowPanelAdvance50.h"
#elif (defined(CONFIG_TT_BOARD_ELECROW_CROWPANEL_BASIC_28))
#define TT_BOARD_HARDWARE &crowpanel_basic_28
#include "CrowPanelBasic28.h"
#elif (defined(CONFIG_TT_BOARD_ELECROW_CROWPANEL_BASIC_35))
#define TT_BOARD_HARDWARE &crowpanel_basic_35
#include "CrowPanelBasic35.h"
#elif (defined(CONFIG_TT_BOARD_ELECROW_CROWPANEL_BASIC_50))
#define TT_BOARD_HARDWARE &crowpanel_basic_50
#include "CrowPanelBasic50.h"
#elif defined(CONFIG_TT_BOARD_M5STACK_CORE2)
#include "M5stackCore2.h"
#define TT_BOARD_HARDWARE &m5stack_core2

View File

@ -61,12 +61,12 @@ const tt::hal::Configuration cyd_2432S024c_config = {
.mosi_io_num = GPIO_NUM_13,
.miso_io_num = GPIO_NUM_NC,
.sclk_io_num = GPIO_NUM_14,
.quadwp_io_num = -1, // Quad SPI LCD driver is not yet supported
.quadhd_io_num = -1, // Quad SPI LCD driver is not yet supported
.data4_io_num = 0,
.data5_io_num = 0,
.data6_io_num = 0,
.data7_io_num = 0,
.quadwp_io_num = GPIO_NUM_NC, // Quad SPI LCD driver is not yet supported
.quadhd_io_num = GPIO_NUM_NC, // Quad SPI LCD driver is not yet supported
.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 = CYD_SPI_TRANSFER_SIZE_LIMIT,
.flags = 0,
@ -84,12 +84,12 @@ const tt::hal::Configuration cyd_2432S024c_config = {
.mosi_io_num = GPIO_NUM_23,
.miso_io_num = GPIO_NUM_19,
.sclk_io_num = GPIO_NUM_18,
.quadwp_io_num = -1, // Quad SPI LCD driver is not yet supported
.quadhd_io_num = -1, // Quad SPI LCD driver is not yet supported
.data4_io_num = 0,
.data5_io_num = 0,
.data6_io_num = 0,
.data7_io_num = 0,
.quadwp_io_num = GPIO_NUM_NC, // Quad SPI LCD driver is not yet supported
.quadhd_io_num = GPIO_NUM_NC, // Quad SPI LCD driver is not yet supported
.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 = 8192,
.flags = 0,

View File

@ -3,7 +3,6 @@
#define TAG "twodotfour_sdcard"
#include <Tactility/hal/sdcard/SpiSdCardDevice.h>
#include <Tactility/lvgl/LvglSync.h>
#define SDCARD_SPI_HOST SPI3_HOST
#define SDCARD_PIN_CS GPIO_NUM_5

View File

@ -0,0 +1,7 @@
file(GLOB_RECURSE SOURCE_FILES Source/*.c*)
idf_component_register(
SRCS ${SOURCE_FILES}
INCLUDE_DIRS "Source"
REQUIRES Tactility esp_lvgl_port ILI934x GT911 PwmBacklight driver vfs fatfs
)

View File

@ -0,0 +1,86 @@
#include "CYD2432S032C.h"
#include "Tactility/lvgl/LvglSync.h"
#include "hal/CydDisplay.h"
#include "hal/CydSdCard.h"
#include <PwmBacklight.h>
#define CYD_SPI_TRANSFER_SIZE_LIMIT (TWODOTFOUR_LCD_DRAW_BUFFER_SIZE * LV_COLOR_DEPTH / 8)
bool initBoot() {
return driver::pwmbacklight::init(GPIO_NUM_27);
}
const tt::hal::Configuration cyd_2432S032c_config = {
.initBoot = initBoot,
.createDisplay = createDisplay,
.sdcard = createSdCard(),
.power = nullptr,
.i2c = {
tt::hal::i2c::Configuration {
.name = "Internal",
.port = I2C_NUM_0,
.initMode = tt::hal::i2c::InitMode::ByTactility,
.isMutable = true,
.config = (i2c_config_t) {
.mode = I2C_MODE_MASTER,
.sda_io_num = GPIO_NUM_33,
.scl_io_num = GPIO_NUM_32,
.sda_pullup_en = false,
.scl_pullup_en = false,
.master = {
.clk_speed = 400000
},
.clk_flags = 0
}
}
},
.spi {
tt::hal::spi::Configuration {
.device = SPI2_HOST,
.dma = SPI_DMA_CH_AUTO,
.config = {
.mosi_io_num = GPIO_NUM_13,
.miso_io_num = GPIO_NUM_NC,
.sclk_io_num = GPIO_NUM_14,
.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 = 0,
.flags = 0,
.isr_cpu_id = ESP_INTR_CPU_AFFINITY_AUTO,
.intr_flags = 0
},
.initMode = tt::hal::spi::InitMode::ByTactility,
.isMutable = false,
.lock = tt::lvgl::getSyncLock() // esp_lvgl_port owns the lock for the display
},
tt::hal::spi::Configuration {
.device = SPI3_HOST,
.dma = SPI_DMA_CH_AUTO,
.config = {
.mosi_io_num = GPIO_NUM_23,
.miso_io_num = GPIO_NUM_19,
.sclk_io_num = GPIO_NUM_18,
.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 = 0,
.flags = 0,
.isr_cpu_id = ESP_INTR_CPU_AFFINITY_AUTO,
.intr_flags = 0
},
.initMode = tt::hal::spi::InitMode::ByTactility,
.isMutable = false,
.lock = nullptr
},
}
};

View File

@ -0,0 +1,6 @@
#pragma once
#include <Tactility/hal/Configuration.h>
// Capacitive touch version of the 2.4" yellow board
extern const tt::hal::Configuration cyd_2432S032c_config;

View File

@ -0,0 +1,39 @@
#include "CydDisplay.h"
#include <Gt911Touch.h>
#include <Ili934xDisplay.h>
#include <PwmBacklight.h>
static std::shared_ptr<tt::hal::touch::TouchDevice> createTouch() {
auto configuration = std::make_unique<Gt911Touch::Configuration>(
I2C_NUM_0,
240,
320
);
return std::make_shared<Gt911Touch>(std::move(configuration));
}
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay() {
auto touch = createTouch();
auto configuration = std::make_unique<Ili934xDisplay::Configuration>(
SPI2_HOST,
GPIO_NUM_15,
GPIO_NUM_2,
240,
320,
touch,
true,
true,
true,
true,
0,
LCD_RGB_ELEMENT_ORDER_RGB
);
configuration->backlightDutyFunction = driver::pwmbacklight::setBacklightDuty;
return std::make_shared<Ili934xDisplay>(std::move(configuration));
}

View File

@ -0,0 +1,6 @@
#pragma once
#include "Tactility/hal/display/DisplayDevice.h"
#include <memory>
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay();

View File

@ -0,0 +1,29 @@
#include "CydSdCard.h"
#include <Tactility/hal/sdcard/SpiSdCardDevice.h>
#include <Tactility/lvgl/LvglSync.h>
#define SDCARD_SPI_HOST SPI3_HOST
#define SDCARD_PIN_CS GPIO_NUM_5
using tt::hal::sdcard::SpiSdCardDevice;
std::shared_ptr<SdCardDevice> createSdCard() {
auto* configuration = new SpiSdCardDevice::Config(
SDCARD_PIN_CS,
GPIO_NUM_NC,
GPIO_NUM_NC,
GPIO_NUM_NC,
SdCardDevice::MountBehaviour::AtBoot,
std::make_shared<tt::Mutex>(),
std::vector<gpio_num_t>(),
SDCARD_SPI_HOST
);
auto* sdcard = (SdCardDevice*) new SpiSdCardDevice(
std::unique_ptr<SpiSdCardDevice::Config>(configuration)
);
return std::shared_ptr<SdCardDevice>(sdcard);
}

View File

@ -0,0 +1,8 @@
#pragma once
#include "Tactility/hal/sdcard/SdCardDevice.h"
using tt::hal::sdcard::SdCardDevice;
std::shared_ptr<SdCardDevice> createSdCard();

View File

@ -76,7 +76,7 @@ bool CydDisplay::start() {
const esp_lcd_rgb_panel_config_t rgb_config = {
.clk_src = LCD_CLK_SRC_DEFAULT,
.timings = {
.pclk_hz = 16000000,
.pclk_hz = 14000000,
.h_res = 480,
.v_res = 480,
.hsync_pulse_width = 10,

View File

@ -11,10 +11,7 @@ std::shared_ptr<SdCardDevice> createSdCard() {
GPIO_NUM_NC,
GPIO_NUM_NC,
GPIO_NUM_NC,
SdCardDevice::MountBehaviour::AtBoot,
std::make_shared<tt::Mutex>(),
std::vector<gpio_num_t>(),
SPI2_HOST
SdCardDevice::MountBehaviour::AtBoot
);
auto sdcard = std::make_shared<SpiSdCardDevice>(

View File

@ -61,12 +61,12 @@ const Configuration cyd_8048s043c_config = {
.mosi_io_num = GPIO_NUM_11,
.miso_io_num = GPIO_NUM_13,
.sclk_io_num = GPIO_NUM_12,
.quadwp_io_num = -1,
.quadhd_io_num = -1,
.data4_io_num = 0,
.data5_io_num = 0,
.data6_io_num = 0,
.data7_io_num = 0,
.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 = 8192,
.flags = 0,

View File

@ -1,9 +1,8 @@
#include "RgbDisplay.h"
#include "CydDisplay.h"
#include <PwmBacklight.h>
#include <Gt911Touch.h>
#include <PwmBacklight.h>
#include <RgbDisplay.h>
#include <Tactility/Log.h>
std::shared_ptr<tt::hal::touch::TouchDevice> _Nullable createTouch() {

View File

@ -11,10 +11,7 @@ std::shared_ptr<SdCardDevice> createSdCard() {
GPIO_NUM_NC,
GPIO_NUM_NC,
GPIO_NUM_NC,
SdCardDevice::MountBehaviour::AtBoot,
std::make_shared<tt::Mutex>(),
std::vector<gpio_num_t>(),
SPI2_HOST
SdCardDevice::MountBehaviour::AtBoot
);
auto sdcard = std::make_shared<SpiSdCardDevice>(

View File

@ -78,12 +78,12 @@ const Configuration cyd_jc2432w328c_config = {
.mosi_io_num = GPIO_NUM_13,
.miso_io_num = GPIO_NUM_NC,
.sclk_io_num = GPIO_NUM_14,
.quadwp_io_num = -1,
.quadhd_io_num = -1,
.data4_io_num = 0,
.data5_io_num = 0,
.data6_io_num = 0,
.data7_io_num = 0,
.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 = CYD_SPI_TRANSFER_SIZE_LIMIT,
.flags = 0,
@ -102,12 +102,12 @@ const Configuration cyd_jc2432w328c_config = {
.mosi_io_num = GPIO_NUM_23,
.miso_io_num = GPIO_NUM_19,
.sclk_io_num = GPIO_NUM_18,
.quadwp_io_num = -1,
.quadhd_io_num = -1,
.data4_io_num = 0,
.data5_io_num = 0,
.data6_io_num = 0,
.data7_io_num = 0,
.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 = 8192,
.flags = 0,

View File

@ -62,12 +62,12 @@ const Configuration cyd_jc8048w550c_config = {
.mosi_io_num = GPIO_NUM_11,
.miso_io_num = GPIO_NUM_13,
.sclk_io_num = GPIO_NUM_12,
.quadwp_io_num = -1,
.quadhd_io_num = -1,
.data4_io_num = 0,
.data5_io_num = 0,
.data6_io_num = 0,
.data7_io_num = 0,
.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 = 8192,
.flags = 0,

View File

@ -50,10 +50,10 @@ extern const Configuration crowpanel_advance_28 = {
.sclk_io_num = GPIO_NUM_42,
.quadwp_io_num = GPIO_NUM_NC,
.quadhd_io_num = GPIO_NUM_NC,
.data4_io_num = 0,
.data5_io_num = 0,
.data6_io_num = 0,
.data7_io_num = 0,
.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 = CROWPANEL_SPI_TRANSFER_SIZE_LIMIT,
.flags = 0,
@ -74,10 +74,10 @@ extern const Configuration crowpanel_advance_28 = {
.sclk_io_num = GPIO_NUM_5,
.quadwp_io_num = GPIO_NUM_NC,
.quadhd_io_num = GPIO_NUM_NC,
.data4_io_num = 0,
.data5_io_num = 0,
.data6_io_num = 0,
.data7_io_num = 0,
.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 = 32768,
.flags = 0,

View File

@ -50,10 +50,10 @@ extern const Configuration crowpanel_advance_35 = {
.sclk_io_num = GPIO_NUM_42,
.quadwp_io_num = GPIO_NUM_NC,
.quadhd_io_num = GPIO_NUM_NC,
.data4_io_num = 0,
.data5_io_num = 0,
.data6_io_num = 0,
.data7_io_num = 0,
.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 = CROWPANEL_SPI_TRANSFER_SIZE_LIMIT,
.flags = 0,
@ -74,10 +74,10 @@ extern const Configuration crowpanel_advance_35 = {
.sclk_io_num = GPIO_NUM_5,
.quadwp_io_num = GPIO_NUM_NC,
.quadhd_io_num = GPIO_NUM_NC,
.data4_io_num = 0,
.data5_io_num = 0,
.data6_io_num = 0,
.data7_io_num = 0,
.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 = 32768,
.flags = 0,

View File

@ -0,0 +1,7 @@
file(GLOB_RECURSE SOURCE_FILES Source/*.c*)
idf_component_register(
SRCS ${SOURCE_FILES}
INCLUDE_DIRS "Source"
REQUIRES Tactility esp_lvgl_port RgbDisplay GT911 TCA9534 driver
)

View File

@ -0,0 +1,126 @@
#include "hal/CrowPanelDisplay.h"
#include "hal/CrowPanelSdCard.h"
#include <Tactility/hal/Configuration.h>
#include <TCA9534.h>
using namespace tt::hal;
bool initBoot() {
TCA9534_IO_EXP io_expander = {
.I2C_ADDR = 0x18,
.i2c_master_port = I2C_NUM_0,
.interrupt_pin = GPIO_NUM_NC,
.interrupt_task = nullptr
};
// Enable LCD backlight
set_tca9534_io_pin_direction(&io_expander, TCA9534_IO1, TCA9534_OUTPUT);
set_tca9534_io_pin_output_state(&io_expander, TCA9534_IO1, 255);
return true;
}
extern const Configuration crowpanel_advance_50 = {
.initBoot = initBoot,
.createDisplay = createDisplay,
.sdcard = createSdCard(),
.i2c = {
// There is only 1 (internal for touch, and also serves as "I2C-OUT" port)
// Note: You could repurpose 1 or more UART interfaces as I2C interfaces
i2c::Configuration {
.name = "Main",
.port = I2C_NUM_0,
.initMode = i2c::InitMode::ByTactility,
.isMutable = false,
.config = (i2c_config_t) {
.mode = I2C_MODE_MASTER,
.sda_io_num = GPIO_NUM_15,
.scl_io_num = GPIO_NUM_16,
.sda_pullup_en = true,
.scl_pullup_en = true,
.master = {
.clk_speed = 400000
},
.clk_flags = 0
}
}
},
.spi {
// SD card
spi::Configuration {
.device = SPI2_HOST,
.dma = SPI_DMA_CH_AUTO,
.config = {
.mosi_io_num = GPIO_NUM_6,
.miso_io_num = GPIO_NUM_4,
.sclk_io_num = GPIO_NUM_5,
.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 = 8192,
.flags = 0,
.isr_cpu_id = ESP_INTR_CPU_AFFINITY_AUTO,
.intr_flags = 0
},
.initMode = spi::InitMode::ByTactility,
.isMutable = false,
.lock = nullptr // No custom lock needed
}
},
.uart {
// "UART0-OUT"
uart::Configuration {
.name = "UART0",
.port = UART_NUM_1,
.rxPin = GPIO_NUM_44,
.txPin = GPIO_NUM_43,
.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,
}
}
},
// "UART1-OUT"
uart::Configuration {
.name = "UART1",
.port = UART_NUM_2,
.rxPin = GPIO_NUM_19,
.txPin = GPIO_NUM_20,
.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,
}
}
}
},
.gps = {}
};

View File

@ -0,0 +1,5 @@
#pragma once
#include <Tactility/hal/Configuration.h>
extern const tt::hal::Configuration crowpanel_advance_50;

View File

@ -0,0 +1,103 @@
#include "CrowPanelDisplay.h"
#include <Gt911Touch.h>
#include <RgbDisplay.h>
#include <Tactility/Log.h>
std::shared_ptr<tt::hal::touch::TouchDevice> _Nullable createTouch() {
// Note for future changes: Reset pin is 38 and interrupt pin is 18
// or INT = NC, schematic and other info floating around is kinda conflicting...
auto configuration = std::make_unique<Gt911Touch::Configuration>(
I2C_NUM_0,
800,
480
);
return std::make_shared<Gt911Touch>(std::move(configuration));
}
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay() {
auto touch = createTouch();
constexpr uint32_t bufferPixels = 800 * 10;
esp_lcd_rgb_panel_config_t rgb_panel_config = {
.clk_src = LCD_CLK_SRC_DEFAULT,
.timings = {
.pclk_hz = 15000000, // TODO: 21 MHz was too much and caused drift when opening wifi/SD/apps. Try something inbetween 15 and 21 MHz.
.h_res = 800,
.v_res = 480,
.hsync_pulse_width = 4,
.hsync_back_porch = 8,
.hsync_front_porch = 8,
.vsync_pulse_width = 4,
.vsync_back_porch = 8,
.vsync_front_porch = 8,
.flags = {
.hsync_idle_low = false,
.vsync_idle_low = false,
.de_idle_high = false,
.pclk_active_neg = true,
.pclk_idle_high = false
}
},
.data_width = 16,
.bits_per_pixel = 0,
.num_fbs = 2,
.bounce_buffer_size_px = bufferPixels,
.sram_trans_align = 8,
.psram_trans_align = 64,
.hsync_gpio_num = GPIO_NUM_40,
.vsync_gpio_num = GPIO_NUM_41,
.de_gpio_num = GPIO_NUM_42 ,
.pclk_gpio_num = GPIO_NUM_39,
.disp_gpio_num = GPIO_NUM_NC,
.data_gpio_nums = {
GPIO_NUM_21, // B3
GPIO_NUM_47, // B4
GPIO_NUM_48, // B5
GPIO_NUM_45, // B6
GPIO_NUM_38, // B7
GPIO_NUM_9, // G2
GPIO_NUM_10, // G3
GPIO_NUM_11, // G4
GPIO_NUM_12, // G5
GPIO_NUM_13, // G6
GPIO_NUM_14, // G7
GPIO_NUM_7, // R3
GPIO_NUM_17, // R4
GPIO_NUM_18, // R5
GPIO_NUM_3, // R6
GPIO_NUM_46, // R7
},
.flags = {
.disp_active_low = false,
.refresh_on_demand = false,
.fb_in_psram = true,
.double_fb = true,
.no_fb = false,
.bb_invalidate_cache = false
}
};
RgbDisplay::BufferConfiguration buffer_config = {
.size = (800 * 480),
.useSpi = true,
.doubleBuffer = true,
.bounceBufferMode = true,
.avoidTearing = false
};
auto configuration = std::make_unique<RgbDisplay::Configuration>(
rgb_panel_config,
buffer_config,
touch,
LV_COLOR_FORMAT_RGB565,
false,
false,
false,
false
);
return std::make_shared<RgbDisplay>(std::move(configuration));
}

View File

@ -0,0 +1,5 @@
#pragma once
#include "Tactility/hal/display/DisplayDevice.h"
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay();

View File

@ -0,0 +1,25 @@
#include "CrowPanelSdCard.h"
#include <Tactility/hal/sdcard/SpiSdCardDevice.h>
#include <Tactility/lvgl/LvglSync.h>
#include <esp_vfs_fat.h>
using tt::hal::sdcard::SpiSdCardDevice;
std::shared_ptr<SdCardDevice> createSdCard() {
auto* configuration = new SpiSdCardDevice::Config(
// See https://github.com/Elecrow-RD/CrowPanel-Advance-HMI-ESP32-AI-Display/blob/master/5.0/factory_code/factory_code.ino
GPIO_NUM_0, // It's actually not connected, but in the demo pin 0 is used
GPIO_NUM_NC,
GPIO_NUM_NC,
GPIO_NUM_NC,
SdCardDevice::MountBehaviour::AtBoot
);
auto* sdcard = (SdCardDevice*) new SpiSdCardDevice(
std::unique_ptr<SpiSdCardDevice::Config>(configuration)
);
return std::shared_ptr<SdCardDevice>(sdcard);
}

View File

@ -0,0 +1,7 @@
#pragma once
#include "Tactility/hal/sdcard/SdCardDevice.h"
using tt::hal::sdcard::SdCardDevice;
std::shared_ptr<SdCardDevice> createSdCard();

View File

@ -52,10 +52,10 @@ extern const Configuration crowpanel_basic_28 = {
.sclk_io_num = GPIO_NUM_14,
.quadwp_io_num = GPIO_NUM_NC,
.quadhd_io_num = GPIO_NUM_NC,
.data4_io_num = 0,
.data5_io_num = 0,
.data6_io_num = 0,
.data7_io_num = 0,
.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 = CROWPANEL_SPI_TRANSFER_SIZE_LIMIT,
.flags = 0,
@ -76,10 +76,10 @@ extern const Configuration crowpanel_basic_28 = {
.sclk_io_num = GPIO_NUM_18,
.quadwp_io_num = GPIO_NUM_NC,
.quadhd_io_num = GPIO_NUM_NC,
.data4_io_num = 0,
.data5_io_num = 0,
.data6_io_num = 0,
.data7_io_num = 0,
.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 = 32768,
.flags = 0,

View File

@ -52,10 +52,10 @@ extern const Configuration crowpanel_basic_35 = {
.sclk_io_num = GPIO_NUM_14,
.quadwp_io_num = GPIO_NUM_NC,
.quadhd_io_num = GPIO_NUM_NC,
.data4_io_num = 0,
.data5_io_num = 0,
.data6_io_num = 0,
.data7_io_num = 0,
.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 = CROWPANEL_SPI_TRANSFER_SIZE_LIMIT,
.flags = 0,
@ -76,10 +76,10 @@ extern const Configuration crowpanel_basic_35 = {
.sclk_io_num = GPIO_NUM_18,
.quadwp_io_num = GPIO_NUM_NC,
.quadhd_io_num = GPIO_NUM_NC,
.data4_io_num = 0,
.data5_io_num = 0,
.data6_io_num = 0,
.data7_io_num = 0,
.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 = 32768,
.flags = 0,

View File

@ -0,0 +1,7 @@
file(GLOB_RECURSE SOURCE_FILES Source/*.c*)
idf_component_register(
SRCS ${SOURCE_FILES}
INCLUDE_DIRS "Source"
REQUIRES Tactility esp_lvgl_port RgbDisplay GT911 PwmBacklight driver
)

View File

@ -0,0 +1,91 @@
#include "hal/CrowPanelDisplay.h"
#include "hal/CrowPanelSdCard.h"
#include <PwmBacklight.h>
#include <Tactility/hal/Configuration.h>
using namespace tt::hal;
bool initBoot() {
return driver::pwmbacklight::init(GPIO_NUM_2);
}
extern const Configuration crowpanel_basic_50 = {
.initBoot = initBoot,
.createDisplay = createDisplay,
.sdcard = createSdCard(),
.i2c = {
// There is only 1 (internal for touch, and also serves as "I2C-OUT" port)
// Note: You could repurpose 1 or more UART interfaces as I2C interfaces
i2c::Configuration {
.name = "Main",
.port = I2C_NUM_0,
.initMode = i2c::InitMode::ByTactility,
.isMutable = false,
.config = (i2c_config_t) {
.mode = I2C_MODE_MASTER,
.sda_io_num = GPIO_NUM_19,
.scl_io_num = GPIO_NUM_20,
.sda_pullup_en = true,
.scl_pullup_en = true,
.master = {
.clk_speed = 400000
},
.clk_flags = 0
}
}
},
.spi {
// SD card
spi::Configuration {
.device = SPI2_HOST,
.dma = SPI_DMA_CH_AUTO,
.config = {
.mosi_io_num = GPIO_NUM_11,
.miso_io_num = GPIO_NUM_13,
.sclk_io_num = GPIO_NUM_12,
.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 = 8192,
.flags = 0,
.isr_cpu_id = ESP_INTR_CPU_AFFINITY_AUTO,
.intr_flags = 0
},
.initMode = spi::InitMode::ByTactility,
.isMutable = false,
.lock = nullptr
}
},
.uart {
// "UART1"
uart::Configuration {
.name = "UART1",
.port = UART_NUM_1,
.rxPin = GPIO_NUM_44,
.txPin = GPIO_NUM_43,
.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,
}
}
}
},
.gps = {}
};

View File

@ -0,0 +1,5 @@
#pragma once
#include <Tactility/hal/Configuration.h>
extern const tt::hal::Configuration crowpanel_basic_50;

View File

@ -0,0 +1,105 @@
#include "CrowPanelDisplay.h"
#include <Gt911Touch.h>
#include <PwmBacklight.h>
#include <RgbDisplay.h>
#include <Tactility/Log.h>
std::shared_ptr<tt::hal::touch::TouchDevice> _Nullable createTouch() {
// Note for future changes: Reset pin is 38 and interrupt pin is 18
// or INT = NC, schematic and other info floating around is kinda conflicting...
auto configuration = std::make_unique<Gt911Touch::Configuration>(
I2C_NUM_0,
800,
480
);
return std::make_shared<Gt911Touch>(std::move(configuration));
}
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay() {
auto touch = createTouch();
constexpr uint32_t bufferPixels = 800 * 10;
esp_lcd_rgb_panel_config_t rgb_panel_config = {
.clk_src = LCD_CLK_SRC_DEFAULT,
.timings = {
.pclk_hz = 15000000,
.h_res = 800,
.v_res = 480,
.hsync_pulse_width = 4,
.hsync_back_porch = 43,
.hsync_front_porch = 8,
.vsync_pulse_width = 4,
.vsync_back_porch = 12,
.vsync_front_porch = 8,
.flags = {
.hsync_idle_low = false,
.vsync_idle_low = false,
.de_idle_high = false,
.pclk_active_neg = true,
.pclk_idle_high = false
}
},
.data_width = 16,
.bits_per_pixel = 0,
.num_fbs = 2,
.bounce_buffer_size_px = bufferPixels,
.sram_trans_align = 8,
.psram_trans_align = 64,
.hsync_gpio_num = GPIO_NUM_39,
.vsync_gpio_num = GPIO_NUM_41,
.de_gpio_num = GPIO_NUM_40 ,
.pclk_gpio_num = GPIO_NUM_0,
.disp_gpio_num = GPIO_NUM_NC,
.data_gpio_nums = {
GPIO_NUM_8, // B0
GPIO_NUM_3, // B1
GPIO_NUM_46, // B2
GPIO_NUM_9, // B3
GPIO_NUM_1, // B4
GPIO_NUM_5, // G0
GPIO_NUM_6, // G1
GPIO_NUM_7, // G2
GPIO_NUM_15, // G3
GPIO_NUM_16, // G4
GPIO_NUM_4, // G5
GPIO_NUM_45, // R0
GPIO_NUM_48, // R1
GPIO_NUM_47, // R2
GPIO_NUM_21, // R3
GPIO_NUM_14, // R4
},
.flags = {
.disp_active_low = false,
.refresh_on_demand = false,
.fb_in_psram = true,
.double_fb = true,
.no_fb = false,
.bb_invalidate_cache = false
}
};
RgbDisplay::BufferConfiguration buffer_config = {
.size = (800 * 480),
.useSpi = true,
.doubleBuffer = true,
.bounceBufferMode = true,
.avoidTearing = false
};
auto configuration = std::make_unique<RgbDisplay::Configuration>(
rgb_panel_config,
buffer_config,
touch,
LV_COLOR_FORMAT_RGB565,
false,
false,
false,
false,
driver::pwmbacklight::setBacklightDuty
);
return std::make_shared<RgbDisplay>(std::move(configuration));
}

View File

@ -0,0 +1,5 @@
#pragma once
#include "Tactility/hal/display/DisplayDevice.h"
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay();

View File

@ -0,0 +1,24 @@
#include "CrowPanelSdCard.h"
#include <Tactility/hal/sdcard/SpiSdCardDevice.h>
#include <Tactility/lvgl/LvglSync.h>
#include <esp_vfs_fat.h>
using tt::hal::sdcard::SpiSdCardDevice;
std::shared_ptr<SdCardDevice> createSdCard() {
auto* configuration = new SpiSdCardDevice::Config(
GPIO_NUM_10,
GPIO_NUM_NC,
GPIO_NUM_NC,
GPIO_NUM_NC,
SdCardDevice::MountBehaviour::AtBoot
);
auto* sdcard = (SdCardDevice*) new SpiSdCardDevice(
std::unique_ptr<SpiSdCardDevice::Config>(configuration)
);
return std::shared_ptr<SdCardDevice>(sdcard);
}

View File

@ -0,0 +1,7 @@
#pragma once
#include "Tactility/hal/sdcard/SdCardDevice.h"
using tt::hal::sdcard::SdCardDevice;
std::shared_ptr<SdCardDevice> createSdCard();

View File

@ -63,12 +63,12 @@ extern const Configuration lilygo_tdeck = {
.mosi_io_num = GPIO_NUM_41,
.miso_io_num = GPIO_NUM_38,
.sclk_io_num = GPIO_NUM_40,
.quadwp_io_num = -1, // Quad SPI LCD driver is not yet supported
.quadhd_io_num = -1, // Quad SPI LCD driver is not yet supported
.data4_io_num = 0,
.data5_io_num = 0,
.data6_io_num = 0,
.data7_io_num = 0,
.quadwp_io_num = GPIO_NUM_NC, // Quad SPI LCD driver is not yet supported
.quadhd_io_num = GPIO_NUM_NC, // Quad SPI LCD driver is not yet supported
.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 = TDECK_SPI_TRANSFER_SIZE_LIMIT,
.flags = 0,

View File

@ -58,12 +58,12 @@ extern const tt::hal::Configuration m5stack_core2 = {
.mosi_io_num = GPIO_NUM_23,
.miso_io_num = GPIO_NUM_38,
.sclk_io_num = GPIO_NUM_18,
.quadwp_io_num = -1, // Quad SPI LCD driver is not yet supported
.quadhd_io_num = -1, // Quad SPI LCD driver is not yet supported
.data4_io_num = 0,
.data5_io_num = 0,
.data6_io_num = 0,
.data7_io_num = 0,
.quadwp_io_num = GPIO_NUM_NC, // Quad SPI LCD driver is not yet supported
.quadhd_io_num = GPIO_NUM_NC, // Quad SPI LCD driver is not yet supported
.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 = CORE2_SPI_TRANSFER_SIZE_LIMIT,
.flags = 0,

View File

@ -61,10 +61,10 @@ extern const tt::hal::Configuration unPhone = {
.sclk_io_num = GPIO_NUM_39,
.quadwp_io_num = -1, // Quad SPI LCD driver is not yet supported
.quadhd_io_num = -1, // Quad SPI LCD driver is not yet supported
.data4_io_num = 0,
.data5_io_num = 0,
.data6_io_num = 0,
.data7_io_num = 0,
.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 = UNPHONE_SPI_TRANSFER_SIZE_LIMIT,
.flags = 0,

View File

@ -20,12 +20,18 @@ release elecrow-crowpanel-advance-28
build elecrow-crowpanel-advance-35
release elecrow-crowpanel-advance-35
build elecrow-crowpanel-advance-50
release elecrow-crowpanel-advance-50
build elecrow-crowpanel-basic-28
release elecrow-crowpanel-basic-28
build elecrow-crowpanel-basic-35
release elecrow-crowpanel-basic-35
build elecrow-crowpanel-basic-50
release elecrow-crowpanel-basic-50
build lilygo-tdeck
release lilygo-tdeck
@ -34,6 +40,9 @@ releaseSdk release/TactilitySDK-esp32s3
build cyd-2432s024c
release cyd-2432s024c
build cyd-2432s032c
release cyd-2432s032c
build cyd-8048s043c
release cyd-8048s043c

View File

@ -41,6 +41,8 @@ if (DEFINED ENV{ESP_IDF_VERSION})
set(EXCLUDE_COMPONENTS "CYD-4848S040C")
set(EXCLUDE_COMPONENTS "ElecrowCrowpanelAdvance28")
set(EXCLUDE_COMPONENTS "ElecrowCrowpanelAdvance35")
set(EXCLUDE_COMPONENTS "ElecrowCrowpanelAdvance50")
set(EXCLUDE_COMPONENTS "ElecrowCrowpanelBasic50")
set(EXCLUDE_COMPONENTS "LilygoTdeck")
set(EXCLUDE_COMPONENTS "M5stackCoreS3")
set(EXCLUDE_COMPONENTS "UnPhone")
@ -49,6 +51,7 @@ if (DEFINED ENV{ESP_IDF_VERSION})
# ESP32-S3 target should exclude ESP32 boards
if("${IDF_TARGET}" STREQUAL "esp32s3")
set(EXCLUDE_COMPONENTS "CYD-2432S024C")
set(EXCLUDE_COMPONENTS "CYD-2432S032C")
set(EXCLUDE_COMPONENTS "CYD-JC2432W328C")
set(EXCLUDE_COMPONENTS "ElecrowCrowpanelBasic28")
set(EXCLUDE_COMPONENTS "ElecrowCrowpanelBasic35")

View File

@ -31,20 +31,15 @@ Some examples of non-serious issues include:
### New board implementations
I only support boards that I also own. If I don't own a board, I can't properly test the reliability of the firmware.
If you wish to send me a board, please [contact me](https://tactility.one/#/support).
Please open an [issue](https://github.com/ByteWelder/Tactility/issues/new) on GitHub to discuss new boards.
If you implemented a board yourself, I'm willing to refer to your implementation on the main website. Please [contact me](https://tactility.one/#/support).
### Anything that doesn't fall in the above categories?
Please [contact me](https://tactility.one/#/support) me first!
Please [contact me](https://tactility.one/#/support) first!
## Pull Requests
Pull requests should only contain a single set of changes that are related to eachother.
Pull requests should only contain a single set of changes that are related to each other.
That way, an approved set of changes will not be blocked by an unapproved set of changes.
## Code Style

View File

@ -42,7 +42,7 @@ bool Ili934xDisplay::start() {
const esp_lcd_panel_dev_config_t panel_config = {
.reset_gpio_num = configuration->resetPin,
.rgb_ele_order = LCD_RGB_ELEMENT_ORDER_BGR,
.rgb_ele_order = configuration->rgbElementOrder,
.data_endian = LCD_RGB_DATA_ENDIAN_LITTLE,
.bits_per_pixel = 16,
.flags = {

View File

@ -28,7 +28,8 @@ public:
bool mirrorX = false,
bool mirrorY = false,
bool invertColor = false,
uint32_t bufferSize = 0 // Size in pixel count. 0 means default, which is 1/10 of the screen size
uint32_t bufferSize = 0, // Size in pixel count. 0 means default, which is 1/10 of the screen size,
lcd_rgb_element_order_t rgbElementOrder = LCD_RGB_ELEMENT_ORDER_BGR
) : spiBusHandle(spi_bus_handle),
csPin(csPin),
dcPin(dcPin),
@ -39,6 +40,7 @@ public:
mirrorY(mirrorY),
invertColor(invertColor),
bufferSize(bufferSize),
rgbElementOrder(rgbElementOrder),
touch(std::move(touch))
{}
@ -55,6 +57,7 @@ public:
bool mirrorY = false;
bool invertColor = false;
uint32_t bufferSize = 0; // Size in pixel count. 0 means default, which is 1/10 of the screen size
lcd_rgb_element_order_t rgbElementOrder = LCD_RGB_ELEMENT_ORDER_BGR;
std::shared_ptr<tt::hal::touch::TouchDevice> touch;
std::function<void(uint8_t)> _Nullable backlightDutyFunction = nullptr;
};

56
Drivers/TCA9534/.gitignore vendored Normal file
View File

@ -0,0 +1,56 @@
# Prerequisites
*.d
# Object files
*.o
*.ko
*.obj
*.elf
# Linker output
*.ilk
*.map
*.exp
# Precompiled Headers
*.gch
*.pch
# Libraries
*.lib
*.a
*.la
*.lo
# Shared objects (inc. Windows DLLs)
*.dll
*.so
*.so.*
*.dylib
# Executables
*.exe
*.out
*.app
*.i*86
*.x86_64
*.hex
# Debug files
*.dSYM/
*.su
*.idb
*.pdb
# Kernel Module Compile Results
*.mod*
*.cmd
.tmp_versions/
modules.order
Module.symvers
Mkfile.old
dkms.conf
.vscode/
.idea/
build/
cmake-build-debug-esp-idf/

View File

@ -0,0 +1,7 @@
file(GLOB_RECURSE SOURCES src/*.c)
idf_component_register(
SRCS ${SOURCES}
INCLUDE_DIRS include
REQUIRES driver
)

View File

@ -0,0 +1,17 @@
menu "Example Configuration"
config I2C_MASTER_SCL
int "SCL GPIO Num"
default 6 if IDF_TARGET_ESP32C3
default 19 if IDF_TARGET_ESP32 || IDF_TARGET_ESP32S2 || IDF_TARGET_ESP32S3
help
GPIO number for I2C Master clock line.
config I2C_MASTER_SDA
int "SDA GPIO Num"
default 5 if IDF_TARGET_ESP32C3
default 18 if IDF_TARGET_ESP32 || IDF_TARGET_ESP32S2 || IDF_TARGET_ESP32S3
help
GPIO number for I2C Master data line.
endmenu

21
Drivers/TCA9534/LICENSE Normal file
View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2022 Victor Hogeweij
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

8
Drivers/TCA9534/Makefile Normal file
View File

@ -0,0 +1,8 @@
#
# This is a project Makefile. It is assumed the directory this Makefile resides in is a
# project subdirectory.
#
PROJECT_NAME := i2c-simple
include $(IDF_PATH)/make/project.mk

49
Drivers/TCA9534/README.md Normal file
View File

@ -0,0 +1,49 @@
# I2C Simple Example
(See the README.md file in the upper level 'examples' directory for more information about examples.)
## Overview
This example demonstrates basic usage of I2C driver by reading and writing from a I2C connected sensor:
If you have a new I2C application to go (for example, read the temperature data from external sensor with I2C interface), try this as a basic template, then add your own code.
## How to use example
### Hardware Required
To run this example, you should have one ESP32, ESP32-S or ESP32-C based development board as well as a MPU9250. MPU9250 is a inertial measurement unit, which contains a accelerometer, gyroscope as well as a magnetometer, for more information about it, you can read the [PDF](https://invensense.tdk.com/wp-content/uploads/2015/02/PS-MPU-9250A-01-v1.1.pdf) of this sensor.
#### Pin Assignment:
**Note:** The following pin assignments are used by default, you can change these in the `menuconfig` .
| | SDA | SCL |
| ---------------- | -------------- | -------------- |
| ESP I2C Master | I2C_MASTER_SDA | I2C_MASTER_SCL |
| MPU9250 Sensor | SDA | SCL |
For the actual default value of `I2C_MASTER_SDA` and `I2C_MASTER_SCL` see `Example Configuration` in `menuconfig`.
**Note: ** Theres no need to add an external pull-up resistors for SDA/SCL pin, because the driver will enable the internal pull-up resistors.
### Build and Flash
Enter `idf.py -p PORT flash monitor` to build, flash and monitor the project.
(To exit the serial monitor, type ``Ctrl-]``.)
See the [Getting Started Guide](https://docs.espressif.com/projects/esp-idf/en/latest/get-started/index.html) for full steps to configure and use ESP-IDF to build projects.
## Example Output
```bash
I (328) i2c-simple-example: I2C initialized successfully
I (338) i2c-simple-example: WHO_AM_I = 71
I (338) i2c-simple-example: I2C unitialized successfully
```
## Troubleshooting
(For any technical queries, please open an [issue](https://github.com/espressif/esp-idf/issues) on GitHub. We will get back to you as soon as possible.)

View File

@ -0,0 +1,3 @@
#
# Main Makefile. This is basically the same as a component makefile .
#

View File

@ -0,0 +1,6 @@
# The following lines of boilerplate have to be in your project's CMakeLists
# in this exact order for cmake to work correctly
cmake_minimum_required(VERSION 3.5)
set(EXTRA_COMPONENT_DIRS read)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(TCA9534_Examples)

View File

@ -0,0 +1,59 @@
#include "esp_log.h"
#include "driver/i2c.h"
#include "TCA9534.h"
#define I2C_MASTER_SCL_IO CONFIG_I2C_MASTER_SCL /*!< GPIO number used for I2C master clock */
#define I2C_MASTER_SDA_IO CONFIG_I2C_MASTER_SDA /*!< GPIO number used for I2C master data */
#define I2C_MASTER_NUM 0 /*!< I2C master i2c port number, the number of i2c peripheral interfaces available will depend on the chip */
#define I2C_MASTER_FREQ_HZ 400000 /*!< I2C master clock frequency */
#define I2C_MASTER_TX_BUF_DISABLE 0 /*!< I2C master doesn't need buffer */
#define I2C_MASTER_RX_BUF_DISABLE 0 /*!< I2C master doesn't need buffer */
/**
* @brief i2c master initialization
*/
static esp_err_t i2c_master_init(i2c_config_t *conf) {
int i2c_master_port = I2C_MASTER_NUM;
conf->mode = I2C_MODE_MASTER;
conf->master.clk_speed = I2C_MASTER_FREQ_HZ;
conf->sda_io_num = I2C_MASTER_SDA_IO;
conf->scl_io_num = I2C_MASTER_SCL_IO;
conf->sda_pullup_en = GPIO_PULLUP_ENABLE;
conf->scl_pullup_en = GPIO_PULLUP_ENABLE;
i2c_param_config(i2c_master_port, conf);
return i2c_driver_install(i2c_master_port, conf->mode, I2C_MASTER_RX_BUF_DISABLE, I2C_MASTER_TX_BUF_DISABLE, 0);
}
static const char *TAG = "TCA9534-Example";
void app_main(void) {
TCA9534_IO_EXP IO_EXP1;
esp_err_t status = i2c_master_init(&IO_EXP1.i2c_conf);
if (status == ESP_OK) {
ESP_LOGI(TAG, "I2C initialized successfully");
IO_EXP1.I2C_ADDR = 0b0100000;
IO_EXP1.i2c_master_port = I2C_MASTER_NUM;
set_tca9534_io_pin_direction(IO_EXP1, TCA9534_IO0, TCA9534_INPUT);
set_tca9534_io_pin_direction(IO_EXP1, TCA9534_IO1, TCA9534_OUTPUT);
int pin_state = 0;
while (1) {
pin_state = get_io_pin_input_status(IO_EXP1, TCA9534_IO0);
if (pin_state == -1) {
ESP_LOGE(TAG, "Cannot get pin status from TCA9534");
break;
}
set_tca9534_io_pin_output_state(IO_EXP1, TCA9534_IO1, pin_state);
vTaskDelay(100 / portTICK_RATE_MS);
}
ESP_ERROR_CHECK(i2c_driver_delete(I2C_MASTER_NUM));
ESP_LOGI(TAG, "I2C unitialized successfully");
}
}

View File

@ -0,0 +1,170 @@
#ifndef TCA9534_IDF_TCA9534_H
#define TCA9534_IDF_TCA9534_H
#include <driver/i2c.h>
#include <driver/gpio.h>
#define TCA9534_ERROR -1
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief TCA9534 IO Pins mapping
*/
typedef enum {
TCA9534_IO0,
TCA9534_IO1,
TCA9534_IO2,
TCA9534_IO3,
TCA9534_IO4,
TCA9534_IO5,
TCA9534_IO6,
TCA9534_IO7
} TCA9534_PINS;
/**
* @brief TCA9534 Port direction parameters
*/
typedef enum {
TCA9534_OUTPUT,
TCA9534_INPUT
} TCA9534_PORT_DIRECTION;
/**
* @brief TCA9534 initialization parameters
*/
typedef struct {
uint8_t I2C_ADDR;
int i2c_master_port;
//Only when mode is set to interrupt, otherwise it won't be used..
gpio_num_t interrupt_pin;
TaskHandle_t* interrupt_task;
} TCA9534_IO_EXP;
/**
* @brief Setup interrupts using the builtin IO_EXP_INT pin of the tca9534 and interrupt handler+task
* @param io_exp which contains the gpio pin where IO_EXP_INT is connected(interrupt_pin)
* And optionally contains the task to run when interrupt triggered (interrupt_task) if not defined the
* default handler will be used.
*/
void setup_tca9534_interrupt_handler(TCA9534_IO_EXP* io_exp);
/**
* @brief Get the current input state of the specified input pin (1 or 0)
*
* @param io_exp The io expander instance to read from or write to
* @param io_pin The io expander pin to read the state from
*
* @return
* - 0 Success! Pin is Low
* - 1 Success! Pin is High
* - TCA9534_ERROR(-1) Error! Something went wrong in the process of reading the io expander
*/
int16_t get_io_pin_input_status(TCA9534_IO_EXP* io_exp, TCA9534_PINS io_pin);
/**
* @brief Get the current input state of all the io expander pins
*
* @param io_exp The io expander instance to read from or write to
*
* @return
* - 0x00 - 0xFF Success! Dump of input register, 1 bit is equal to 1 of the physical pins (Lower 8 bits of 16 bits result)
* - TCA9534_ERROR(-1) Error! Something went wrong in the process of reading the io expander
*/
int16_t get_tca9534_all_io_pin_input_status(TCA9534_IO_EXP* io_exp);
/**
* @brief Get the current direction of all the io expander pins
*
* @param io_exp The io expander instance to read from or write to
*
* @return
* - 0x00 - 0xFF Success! Dump of configuration register, 1 bit is equal to 1 of the physical pins (Lower 8 bits of 16 bits result)
* - TCA9534_ERROR(-1) Error! Something went wrong in the process of reading the io expander
*/
int16_t get_all_io_pin_direction(TCA9534_IO_EXP* io_exp);
/**
* @brief Get the current polarity inversion state of all the io expander pins
*
* @param io_exp The io expander instance to read from or write to
*
* @return
* - 0x00 - 0xFF Success! Dump of configuration register, 1 bit is equal to 1 of the physical pins (Lower 8 bits of 16 bits result)
* - TCA9534_ERROR(-1) Error! Something went wrong in the process of reading the io expander
*/
int16_t get_all_io_polarity_inversion(TCA9534_IO_EXP* io_exp);
/**
* @brief Get the current direction of the specified io expander pin
*
* @param io_exp The io expander instance to read from or write to
* @param io_pin The io expander pin to read polarity inversion from
*
* @return
* - 0 Success! Pin is Not inverted
* - 1 Success! Pin is Inverted
* - TCA9534_ERROR(-1) Error! Something went wrong in the process of reading the io expander
*/
int16_t get_io_pin_polarity_inversion(TCA9534_IO_EXP* io_exp, TCA9534_PINS io_pin);
/**
* @brief Get the current direction of the specified physical pin (0 means OUTPUT or 1 means INPUT)
*
* @param io_exp The io expander instance to read from or write to
* @param io_pin The io expander pin to read the state from
*
* @return
* - 0 Success! Pin is OUTPUT
* - 1 Success! Pin is INPUT
* - TCA9534_ERROR(-1) Error! Something went wrong in the process of reading the io expander
*/
int16_t get_io_pin_direction(TCA9534_IO_EXP* io_exp, TCA9534_PINS io_pin);
/**
* @brief Sets all physical pins of the io expander to a specified direction (INPUT or OUTPUT)
*
* @param io_exp The io expander instance to read from or write to
* @param properties The pin direction to be set (INPUT or OUTPUT)
*
* @return
* - ESP_OK Success!
* - ESP_ERR Error!
*/
esp_err_t set_all_tca9534_io_pins_direction(TCA9534_IO_EXP* io_exp, TCA9534_PORT_DIRECTION properties);
/**
* @brief Set physical pin of the io expander to a specified direction (INPUT or OUTPUT)
*
* @param io_exp The io expander instance to read from or write to
* @param io_pin The io expander physical pin to be set
* @param properties The pin direction to be set (INPUT or OUTPUT)
*
* @return
* - ESP_OK Success!
* - ESP_ERR Error!
*/
esp_err_t set_tca9534_io_pin_direction(TCA9534_IO_EXP* io_exp, TCA9534_PINS io_pin, TCA9534_PORT_DIRECTION properties);
/**
* @brief Set physical pin of the io expander to an specified output state (HIGH(1) or LOW(0))
*
* @param io_exp The io expander instance to read from or write to
* @param io_pin The io expander physical pin to be set
* @param state The pin state to be set (1 or 0)
*
* @return
* - ESP_OK Success!
* - ESP_ERR Error!
*
* @note Pin output state can be inverted with the inversion register
*/
esp_err_t set_tca9534_io_pin_output_state(TCA9534_IO_EXP* io_exp, TCA9534_PINS io_pin, uint8_t state);
#ifdef __cplusplus
}
#endif
#endif //TCA9534_IDF_TCA9534_H

View File

@ -0,0 +1,151 @@
#include "TCA9534.h"
#include "driver/i2c.h"
#include "esp_log.h"
#include <rom/gpio.h>
#define I2C_MASTER_TIMEOUT_MS 1000
#define TCA9534_LIB_TAG "TCA9534"
#define TCA9534_IO_NUM 8
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief TCA9534 Internal configuration and pin registers
*/
typedef enum {
TCA9534_REG_INPUT_PORT,
TCA9534_REG_OUTPUT_PORT,
TCA9534_REG_POLARITY_INVERSION,
TCA9534_REG_CONFIGURATION
} TCA9534_REGISTER;
/**
* @brief Default TCA9534 interrupt task
*/
void TCA9534_default_interrupt_task(void * pvParameters){
ESP_LOGW(TCA9534_LIB_TAG, "No interrupt task defined! Using standard TCA9523 interrupt task!");
TCA9534_IO_EXP* io_exp = (TCA9534_IO_EXP*) pvParameters;
uint32_t io_num;
while(1){
if(xTaskNotifyWait(0,0,&io_num,portTICK_PERIOD_MS) == pdTRUE) {
uint8_t input_status = get_tca9534_all_io_pin_input_status(io_exp);
printf("Current input status (pin : status):\n");
for (uint8_t i = 0; i < TCA9534_IO_NUM; i++)
printf("P%d : %d\n", i, (input_status & (1<<i)) == (1 << i));
}
}
}
/**
* @brief TCA9534 interrupt handler
*/
static void IRAM_ATTR TCA9534_interrupt_handler(void *args){
TCA9534_IO_EXP* io_exp = (TCA9534_IO_EXP*) args;
xTaskNotifyFromISR(*io_exp->interrupt_task, 0, eNoAction, 0);
}
/**
* @brief Setup TCA9534 interrupts
*/
void setup_tca9534_interrupt_handler(TCA9534_IO_EXP* io_exp){
if(io_exp->interrupt_task == NULL){
xTaskCreate(
TCA9534_default_interrupt_task, /* Function that implements the task. */
"NAME", /* Text name for the task. */
2048, /* Stack size in words, not bytes. */
( void * ) io_exp, /* Parameter passed into the task. */
10,/* Priority at which the task is created. */
io_exp->interrupt_task); /* Used to pass out the created task's handle. */
}
gpio_pad_select_gpio(GPIO_NUM_26);
gpio_set_direction(GPIO_NUM_26,GPIO_MODE_INPUT);
gpio_intr_enable(GPIO_NUM_26);
gpio_set_intr_type(io_exp->interrupt_pin, GPIO_INTR_NEGEDGE);
gpio_install_isr_service(0);
gpio_isr_handler_add(io_exp->interrupt_pin, TCA9534_interrupt_handler, (void *)io_exp);
}
esp_err_t write_tca9534_reg(TCA9534_IO_EXP* io_exp, TCA9534_REGISTER cmd, uint8_t data) {
uint8_t write_buffer[2] = {cmd, data};
return i2c_master_write_to_device(io_exp->i2c_master_port, io_exp->I2C_ADDR, write_buffer,
sizeof(write_buffer), I2C_MASTER_TIMEOUT_MS / portTICK_PERIOD_MS);
}
esp_err_t read_tca9534_reg(TCA9534_IO_EXP* io_exp, TCA9534_REGISTER cmd, uint8_t *read_buff) {
uint8_t reg = cmd;
return i2c_master_write_read_device(io_exp->i2c_master_port, io_exp->I2C_ADDR, &reg,
1, read_buff, 1, I2C_MASTER_TIMEOUT_MS / portTICK_PERIOD_MS);
}
int16_t get_tca9534_all_io_pin_input_status(TCA9534_IO_EXP* io_exp) {
uint8_t result = 0;
esp_err_t status = read_tca9534_reg(io_exp, TCA9534_REG_INPUT_PORT, &result);
return (status == ESP_OK) ? result : TCA9534_ERROR;
}
int16_t get_io_pin_input_status(TCA9534_IO_EXP* io_exp, TCA9534_PINS io_pin) {
int16_t result = get_tca9534_all_io_pin_input_status(io_exp);
if (result != TCA9534_ERROR)
result &= (1 << io_pin);
return (result == (1<< io_pin));
}
int16_t get_all_io_pin_direction(TCA9534_IO_EXP* io_exp) {
uint8_t result;
esp_err_t status = read_tca9534_reg(io_exp, TCA9534_REG_CONFIGURATION, &result);
return (status == ESP_OK) ? result : TCA9534_ERROR;
}
int16_t get_io_pin_direction(TCA9534_IO_EXP* io_exp, TCA9534_PINS io_pin) {
int16_t result = get_all_io_pin_direction(io_exp);
if (result != TCA9534_ERROR)
result &= (1 << io_pin);
return (result == (1<< io_pin));
}
int16_t get_all_io_polarity_inversion(TCA9534_IO_EXP* io_exp) {
uint8_t result;
esp_err_t status = read_tca9534_reg(io_exp, TCA9534_REG_POLARITY_INVERSION, &result);
return (status == ESP_OK) ? result : TCA9534_ERROR;
}
int16_t get_io_pin_polarity_inversion(TCA9534_IO_EXP* io_exp, TCA9534_PINS io_pin) {
int16_t result = get_all_io_polarity_inversion(io_exp);
if (result != TCA9534_ERROR)
result &= (1 << io_pin);
return (result == (1<< io_pin));
}
esp_err_t set_all_tca9534_io_pins_direction(TCA9534_IO_EXP* io_exp, TCA9534_PORT_DIRECTION properties) {
uint8_t dir = (properties == TCA9534_OUTPUT) ? 0x00 : 0xFF;
esp_err_t status = write_tca9534_reg(io_exp, TCA9534_REG_CONFIGURATION, dir);
return status;
}
esp_err_t set_tca9534_io_pin_direction(TCA9534_IO_EXP* io_exp, TCA9534_PINS io_pin, TCA9534_PORT_DIRECTION properties) {
uint8_t port_status = 0;
esp_err_t status = read_tca9534_reg(io_exp, TCA9534_REG_CONFIGURATION, &port_status);
port_status = (properties != TCA9534_OUTPUT) ? (port_status | (1 << io_pin)) : (port_status & ~(1 << io_pin));
status |= write_tca9534_reg(io_exp, TCA9534_REG_CONFIGURATION, port_status);
return status;
}
esp_err_t set_tca9534_io_pin_output_state(TCA9534_IO_EXP* io_exp, TCA9534_PINS io_pin, uint8_t state) {
uint8_t port_status = 0;
esp_err_t status = read_tca9534_reg(io_exp, TCA9534_REG_OUTPUT_PORT, &port_status);
port_status = (state != 0) ? (port_status | (1 << io_pin)) : (port_status & ~(1 << io_pin));
status |= write_tca9534_reg(io_exp, TCA9534_REG_OUTPUT_PORT, port_status);
return status;
}
#ifdef __cplusplus
}
#endif

View File

@ -4,6 +4,8 @@
#include "SdCardDevice.h"
#include <Tactility/hal/spi/Spi.h>
#include <sd_protocol_types.h>
#include <utility>
#include <vector>
@ -26,7 +28,8 @@ public:
gpio_num_t spiPinWp,
gpio_num_t spiPinInt,
MountBehaviour mountBehaviourAtBoot,
std::shared_ptr<Lock> lock = std::make_shared<Mutex>(),
/** When custom lock is nullptr, use the SPI default one */
std::shared_ptr<Lock> _Nullable customLock = nullptr,
std::vector<gpio_num_t> csPinWorkAround = std::vector<gpio_num_t>(),
spi_host_device_t spiHost = SPI2_HOST,
int spiFrequencyKhz = SDMMC_FREQ_DEFAULT
@ -36,12 +39,10 @@ public:
spiPinWp(spiPinWp),
spiPinInt(spiPinInt),
mountBehaviourAtBoot(mountBehaviourAtBoot),
lock(std::move(lock)),
customLock(customLock ? std::move(customLock) : nullptr),
csPinWorkAround(std::move(csPinWorkAround)),
spiHost(spiHost)
{
assert(this->lock != nullptr);
}
{}
int spiFrequencyKhz;
gpio_num_t spiPinCs; // Clock
@ -49,7 +50,7 @@ public:
gpio_num_t spiPinWp; // Write-protect
gpio_num_t spiPinInt; // Interrupt
SdCardDevice::MountBehaviour mountBehaviourAtBoot;
std::shared_ptr<Lock> _Nullable lock;
std::shared_ptr<Lock> _Nullable customLock;
std::vector<gpio_num_t> csPinWorkAround;
spi_host_device_t spiHost;
bool formatOnMountFailed = false;
@ -80,7 +81,13 @@ public:
bool unmount() final;
std::string getMountPath() const final { return mountPath; }
Lock& getLock() const final { return *config->lock; }
Lock& getLock() const final {
if (config->customLock) {
return *config->customLock;
} else {
return *spi::getLock(config->spiHost);
}
}
State getState() const override;

View File

@ -43,6 +43,6 @@ bool stop(spi_host_device_t device);
bool isStarted(spi_host_device_t device);
/** @return the lock that represents the specified device. Can be used with third party SPI implementations or native API calls (e.g. ESP-IDF). */
Lock& getLock(spi_host_device_t device);
std::shared_ptr<Lock> getLock(spi_host_device_t device);
} // namespace tt::hal::spi

View File

@ -134,20 +134,15 @@ SdCardDevice::State SpiSdCardDevice::getState() const {
* Writing and reading to the bus from 2 devices at the same time causes crashes.
* This work-around ensures that this check is only happening when LVGL isn't rendering.
*/
if (config->lock) {
bool locked = config->lock->lock(50); // TODO: Refactor to a more reliable locking mechanism
auto lock = getLock().asScopedLock();
bool locked = lock.lock(50); // TODO: Refactor to a more reliable locking mechanism
if (!locked) {
TT_LOG_E(TAG, LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "LVGL");
return State::Unknown;
}
}
bool result = sdmmc_get_status(card) == ESP_OK;
if (config->lock) {
config->lock->unlock();
}
if (result) {
return State::Mounted;
} else {

View File

@ -42,7 +42,7 @@ bool init(const std::vector<spi::Configuration>& configurations) {
}
bool configure(spi_host_device_t device, const spi_bus_config_t& configuration) {
auto lock = getLock(device).asScopedLock();
auto lock = getLock(device)->asScopedLock();
lock.lock();
Data& data = dataArray[device];
@ -59,7 +59,7 @@ bool configure(spi_host_device_t device, const spi_bus_config_t& configuration)
}
bool start(spi_host_device_t device) {
auto lock = getLock(device).asScopedLock();
auto lock = getLock(device)->asScopedLock();
lock.lock();
Data& data = dataArray[device];
@ -96,7 +96,7 @@ bool start(spi_host_device_t device) {
}
bool stop(spi_host_device_t device) {
auto lock = getLock(device).asScopedLock();
auto lock = getLock(device)->asScopedLock();
lock.lock();
Data& data = dataArray[device];
@ -133,14 +133,14 @@ bool stop(spi_host_device_t device) {
}
bool isStarted(spi_host_device_t device) {
auto lock = getLock(device).asScopedLock();
auto lock = getLock(device)->asScopedLock();
lock.lock();
return dataArray[device].isStarted;
}
Lock& getLock(spi_host_device_t device) {
return *dataArray[device].lock;
std::shared_ptr<Lock> getLock(spi_host_device_t device) {
return dataArray[device].lock;
}
}

View File

@ -0,0 +1,46 @@
# Software defaults
# Increase stack size for WiFi (fixes crash after scan)
CONFIG_ESP_SYSTEM_EVENT_TASK_STACK_SIZE=3072
CONFIG_LV_FONT_MONTSERRAT_14=y
CONFIG_LV_FONT_MONTSERRAT_18=y
CONFIG_LV_USE_USER_DATA=y
CONFIG_LV_USE_FS_STDIO=y
CONFIG_LV_FS_STDIO_LETTER=65
CONFIG_LV_FS_STDIO_PATH=""
CONFIG_LV_FS_STDIO_CACHE_SIZE=4096
CONFIG_LV_USE_LODEPNG=y
CONFIG_LV_USE_BUILTIN_MALLOC=n
CONFIG_LV_USE_CLIB_MALLOC=y
CONFIG_LV_USE_MSGBOX=n
CONFIG_LV_USE_SPINNER=n
CONFIG_LV_USE_WIN=n
CONFIG_LV_USE_SNAPSHOT=y
CONFIG_FREERTOS_HZ=1000
CONFIG_FREERTOS_TASK_NOTIFICATION_ARRAY_ENTRIES=2
CONFIG_FREERTOS_SMP=n
CONFIG_FREERTOS_UNICORE=n
CONFIG_FREERTOS_TIMER_TASK_STACK_DEPTH=4096
CONFIG_FREERTOS_USE_TRACE_FACILITY=y
CONFIG_PARTITION_TABLE_CUSTOM=y
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv"
CONFIG_PARTITION_TABLE_FILENAME="partitions.csv"
CONFIG_FATFS_LFN_HEAP=y
CONFIG_FATFS_VOLUME_COUNT=3
# Hardware: Main
CONFIG_TT_BOARD_CYD_2432S032C=y
CONFIG_TT_BOARD_NAME="CYD 2432S032C"
CONFIG_TT_BOARD_ID="cyd-2432S032c"
CONFIG_IDF_TARGET="esp32"
CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y
CONFIG_ESP32_DEFAULT_CPU_FREQ_240=y
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
CONFIG_FLASHMODE_QIO=y
# LVGL
CONFIG_LV_DISP_DEF_REFR_PERIOD=10
CONFIG_LV_DPI_DEF=160
# 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

View File

@ -0,0 +1,54 @@
# Software defaults
# Increase stack size for WiFi (fixes crash after scan)
CONFIG_ESP_SYSTEM_EVENT_TASK_STACK_SIZE=3072
CONFIG_LV_FONT_MONTSERRAT_14=y
CONFIG_LV_FONT_MONTSERRAT_18=y
CONFIG_LV_USE_USER_DATA=y
CONFIG_LV_USE_FS_STDIO=y
CONFIG_LV_FS_STDIO_LETTER=65
CONFIG_LV_FS_STDIO_PATH=""
CONFIG_LV_FS_STDIO_CACHE_SIZE=4096
CONFIG_LV_USE_LODEPNG=y
CONFIG_LV_USE_BUILTIN_MALLOC=n
CONFIG_LV_USE_CLIB_MALLOC=y
CONFIG_LV_USE_MSGBOX=n
CONFIG_LV_USE_SPINNER=n
CONFIG_LV_USE_WIN=n
CONFIG_LV_USE_SNAPSHOT=y
CONFIG_FREERTOS_HZ=1000
CONFIG_FREERTOS_TASK_NOTIFICATION_ARRAY_ENTRIES=2
CONFIG_FREERTOS_SMP=n
CONFIG_FREERTOS_UNICORE=n
CONFIG_FREERTOS_TIMER_TASK_STACK_DEPTH=4096
CONFIG_FREERTOS_USE_TRACE_FACILITY=y
CONFIG_PARTITION_TABLE_CUSTOM=y
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv"
CONFIG_PARTITION_TABLE_FILENAME="partitions.csv"
CONFIG_FATFS_LFN_HEAP=y
CONFIG_FATFS_VOLUME_COUNT=3
# Hardware: Main
CONFIG_TT_BOARD_ELECROW_CROWPANEL_ADVANCE_50=y
CONFIG_TT_BOARD_NAME="CrowPanel Advance 5.0"
CONFIG_TT_BOARD_ID="crowpanel-advance-50"
CONFIG_IDF_EXPERIMENTAL_FEATURES=y
CONFIG_IDF_TARGET="esp32s3"
CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y
CONFIG_ESP32_DEFAULT_CPU_FREQ_240=y
CONFIG_ESPTOOLPY_FLASHSIZE_16MB=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_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
# TODO: Update DPI
CONFIG_LV_DPI_DEF=143
CONFIG_LV_DISP_DEF_REFR_PERIOD=10
# USB
CONFIG_TINYUSB_MSC_ENABLED=y
CONFIG_TINYUSB_MSC_MOUNT_PATH="/sdcard"

View File

@ -0,0 +1,54 @@
# Software defaults
# Increase stack size for WiFi (fixes crash after scan)
CONFIG_ESP_SYSTEM_EVENT_TASK_STACK_SIZE=3072
CONFIG_LV_FONT_MONTSERRAT_14=y
CONFIG_LV_FONT_MONTSERRAT_18=y
CONFIG_LV_USE_USER_DATA=y
CONFIG_LV_USE_FS_STDIO=y
CONFIG_LV_FS_STDIO_LETTER=65
CONFIG_LV_FS_STDIO_PATH=""
CONFIG_LV_FS_STDIO_CACHE_SIZE=4096
CONFIG_LV_USE_LODEPNG=y
CONFIG_LV_USE_BUILTIN_MALLOC=n
CONFIG_LV_USE_CLIB_MALLOC=y
CONFIG_LV_USE_MSGBOX=n
CONFIG_LV_USE_SPINNER=n
CONFIG_LV_USE_WIN=n
CONFIG_LV_USE_SNAPSHOT=y
CONFIG_FREERTOS_HZ=1000
CONFIG_FREERTOS_TASK_NOTIFICATION_ARRAY_ENTRIES=2
CONFIG_FREERTOS_SMP=n
CONFIG_FREERTOS_UNICORE=n
CONFIG_FREERTOS_TIMER_TASK_STACK_DEPTH=4096
CONFIG_FREERTOS_USE_TRACE_FACILITY=y
CONFIG_PARTITION_TABLE_CUSTOM=y
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv"
CONFIG_PARTITION_TABLE_FILENAME="partitions.csv"
CONFIG_FATFS_LFN_HEAP=y
CONFIG_FATFS_VOLUME_COUNT=3
# Hardware: Main
CONFIG_TT_BOARD_ELECROW_CROWPANEL_BASIC_50=y
CONFIG_TT_BOARD_NAME="CrowPanel Basic 5.0"
CONFIG_TT_BOARD_ID="crowpanel-basic-50"
CONFIG_IDF_EXPERIMENTAL_FEATURES=y
CONFIG_IDF_TARGET="esp32s3"
CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y
CONFIG_ESP32_DEFAULT_CPU_FREQ_240=y
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=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_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
# TODO: Update DPI
CONFIG_LV_DPI_DEF=143
CONFIG_LV_DISP_DEF_REFR_PERIOD=10
# USB
CONFIG_TINYUSB_MSC_ENABLED=y
CONFIG_TINYUSB_MSC_MOUNT_PATH="/sdcard"