SPI HAL implemented and more (#207)

- Cleanup unused code and move ISR/IRQ checks to `Kernel.h`
- Improve clang-format
- Fix for LVGL lock transfer: ensure lock isn't activate when changing the lock
- Implement SPI HAL
- Remove `initHardware` HAL configuration entry
- Fix `I2cScanner`: don't scan when port isn't started
This commit is contained in:
Ken Van Hoeylandt
2025-02-08 00:21:50 +01:00
committed by GitHub
parent 88b3bfbe3e
commit c1f55429b6
41 changed files with 634 additions and 428 deletions
-84
View File
@@ -1,84 +0,0 @@
#include "YellowConfig.h"
#include "hal/YellowTouchConstants.h"
#include <Tactility/TactilityCore.h>
#include <driver/spi_common.h>
#define TAG "twodotfour_bootstrap"
static bool init_i2c() {
TT_LOG_I(TAG, LOG_MESSAGE_I2C_INIT_START);
const i2c_config_t i2c_conf = {
.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
}
};
if (i2c_param_config(TWODOTFOUR_TOUCH_I2C_PORT, &i2c_conf) != ESP_OK) {
TT_LOG_E(TAG, LOG_MESSAGE_I2C_INIT_CONFIG_FAILED );
return false;
}
if (i2c_driver_install(TWODOTFOUR_TOUCH_I2C_PORT, i2c_conf.mode, 0, 0, 0) != ESP_OK) {
TT_LOG_E(TAG, LOG_MESSAGE_I2C_INIT_DRIVER_INSTALL_FAILED);
return false;
}
return true;
}
static bool init_spi2() {
TT_LOG_I(TAG, LOG_MESSAGE_SPI_INIT_START_FMT, SPI2_HOST);
const spi_bus_config_t bus_config = {
.mosi_io_num = TWODOTFOUR_SPI2_PIN_MOSI,
.miso_io_num = GPIO_NUM_NC,
.sclk_io_num = TWODOTFOUR_SPI2_PIN_SCLK,
.quadwp_io_num = GPIO_NUM_NC,
.quadhd_io_num = GPIO_NUM_NC,
.max_transfer_sz = TWODOTFOUR_SPI2_TRANSACTION_LIMIT
};
if (spi_bus_initialize(SPI2_HOST, &bus_config, SPI_DMA_CH_AUTO) != ESP_OK) {
TT_LOG_E(TAG, LOG_MESSAGE_SPI_INIT_FAILED_FMT, SPI2_HOST);
return false;
}
return true;
}
static bool init_spi3() {
TT_LOG_I(TAG, LOG_MESSAGE_SPI_INIT_START_FMT, SPI3_HOST);
const spi_bus_config_t bus_config = {
.mosi_io_num = TWODOTFOUR_SPI3_PIN_MOSI,
.miso_io_num = TWODOTFOUR_SPI3_PIN_MISO,
.sclk_io_num = TWODOTFOUR_SPI3_PIN_SCLK,
.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,
.max_transfer_sz = TWODOTFOUR_SPI3_TRANSACTION_LIMIT,
.flags = 0,
.isr_cpu_id = ESP_INTR_CPU_AFFINITY_AUTO,
.intr_flags = 0
};
if (spi_bus_initialize(SPI3_HOST, &bus_config, SPI_DMA_CH_AUTO) != ESP_OK) {
TT_LOG_E(TAG, LOG_MESSAGE_SPI_INIT_FAILED_FMT, SPI3_HOST);
return false;
}
return true;
}
bool twodotfour_boot() {
return init_i2c() && init_spi2() && init_spi3();
}
+57 -5
View File
@@ -1,12 +1,14 @@
#include "CYD2432S024C.h"
#include "Tactility/lvgl/LvglSync.h"
#include "hal/YellowDisplay.h"
#include "hal/YellowDisplayConstants.h"
#include "hal/YellowSdCard.h"
#define CYD_SPI_TRANSFER_SIZE_LIMIT (TWODOTFOUR_LCD_DRAW_BUFFER_SIZE * LV_COLOR_DEPTH / 8)
bool twodotfour_lvgl_init();
bool twodotfour_boot();
const tt::hal::Configuration cyd_2432S024c_config = {
.initBoot = &twodotfour_boot,
.initLvgl = &twodotfour_lvgl_init,
.createDisplay = createDisplay,
.sdcard = createYellowSdCard(),
@@ -15,13 +17,13 @@ const tt::hal::Configuration cyd_2432S024c_config = {
tt::hal::i2c::Configuration {
.name = "First",
.port = I2C_NUM_0,
.initMode = tt::hal::i2c::InitMode::Disabled,
.initMode = tt::hal::i2c::InitMode::ByTactility,
.canReinit = true,
.hasMutableConfiguration = true,
.config = (i2c_config_t) {
.mode = I2C_MODE_MASTER,
.sda_io_num = GPIO_NUM_NC,
.scl_io_num = GPIO_NUM_NC,
.sda_io_num = GPIO_NUM_33,
.scl_io_num = GPIO_NUM_32,
.sda_pullup_en = false,
.scl_pullup_en = false,
.master = {
@@ -48,5 +50,55 @@ const tt::hal::Configuration cyd_2432S024c_config = {
.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 = -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,
.data_io_default_level = false,
.max_transfer_sz = CYD_SPI_TRANSFER_SIZE_LIMIT,
.flags = 0,
.isr_cpu_id = ESP_INTR_CPU_AFFINITY_AUTO,
.intr_flags = 0
},
.initMode = tt::hal::spi::InitMode::ByTactility,
.canReinit = false,
.hasMutableConfiguration = false,
.lock = tt::lvgl::getLvglSyncLockable() // 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 = -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,
.data_io_default_level = false,
.max_transfer_sz = 8192,
.flags = 0,
.isr_cpu_id = ESP_INTR_CPU_AFFINITY_AUTO,
.intr_flags = 0
},
.initMode = tt::hal::spi::InitMode::ByTactility,
.canReinit = false,
.hasMutableConfiguration = false,
.lock = nullptr
},
}
};
@@ -1,17 +0,0 @@
#pragma once
#include "driver/spi_common.h"
#include "driver/i2c.h"
#include "driver/gpio.h"
#include "hal/YellowDisplayConstants.h"
// SPI 2 - display
#define TWODOTFOUR_SPI2_PIN_SCLK GPIO_NUM_14
#define TWODOTFOUR_SPI2_PIN_MOSI GPIO_NUM_13
#define TWODOTFOUR_SPI2_TRANSACTION_LIMIT TWODOTFOUR_LCD_DRAW_BUFFER_SIZE
// SPI 3 - sdcard
#define TWODOTFOUR_SPI3_PIN_SCLK GPIO_NUM_18
#define TWODOTFOUR_SPI3_PIN_MOSI GPIO_NUM_23
#define TWODOTFOUR_SPI3_PIN_MISO GPIO_NUM_19
#define TWODOTFOUR_SPI3_TRANSACTION_LIMIT 8192 // TODO: Determine proper limit
@@ -1,51 +0,0 @@
#include "hal/TdeckDisplayConstants.h"
#include <Tactility/TactilityCore.h>
#include <driver/spi_common.h>
#include <soc/gpio_num.h>
#define TAG "tdeck"
// SPI
#define TDECK_SPI_HOST SPI2_HOST
#define TDECK_SPI_PIN_SCLK GPIO_NUM_40
#define TDECK_SPI_PIN_MOSI GPIO_NUM_41
#define TDECK_SPI_PIN_MISO GPIO_NUM_38
#define TDECK_SPI_TRANSFER_SIZE_LIMIT (TDECK_LCD_HORIZONTAL_RESOLUTION * TDECK_LCD_SPI_TRANSFER_HEIGHT * (TDECK_LCD_BITS_PER_PIXEL / 8))
#define TDECK_LCD_BACKLIGHT_LEDC_TIMER LEDC_TIMER_0
#define TDECK_LCD_BACKLIGHT_LEDC_MODE LEDC_LOW_SPEED_MODE
#define TDECK_LCD_BACKLIGHT_LEDC_CHANNEL LEDC_CHANNEL_0
#define TDECK_LCD_BACKLIGHT_LEDC_DUTY_RES LEDC_TIMER_8_BIT
#define TDECK_LCD_BACKLIGHT_LEDC_FREQUENCY (4000)
static bool init_spi() {
TT_LOG_I(TAG, LOG_MESSAGE_SPI_INIT_START_FMT, TDECK_SPI_HOST);
spi_bus_config_t bus_config = {
.mosi_io_num = TDECK_SPI_PIN_MOSI,
.miso_io_num = TDECK_SPI_PIN_MISO,
.sclk_io_num = TDECK_SPI_PIN_SCLK,
.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,
.data_io_default_level = false,
.max_transfer_sz = TDECK_SPI_TRANSFER_SIZE_LIMIT,
.flags = 0,
.isr_cpu_id = ESP_INTR_CPU_AFFINITY_AUTO,
.intr_flags = 0
};
if (spi_bus_initialize(TDECK_SPI_HOST, &bus_config, SPI_DMA_CH_AUTO) != ESP_OK) {
TT_LOG_E(TAG, LOG_MESSAGE_SPI_INIT_FAILED_FMT, TDECK_SPI_HOST);
return false;
}
return true;
}
bool tdeck_init_hardware() {
return init_spi();
}
+30 -2
View File
@@ -1,17 +1,19 @@
#include "Tactility/lvgl/LvglSync.h"
#include "hal/TdeckDisplay.h"
#include "hal/TdeckDisplayConstants.h"
#include "hal/TdeckKeyboard.h"
#include "hal/TdeckPower.h"
#include "hal/TdeckSdCard.h"
#include <Tactility/hal/Configuration.h>
#define TDECK_SPI_TRANSFER_SIZE_LIMIT (TDECK_LCD_HORIZONTAL_RESOLUTION * TDECK_LCD_SPI_TRANSFER_HEIGHT * (TDECK_LCD_BITS_PER_PIXEL / 8))
bool tdeck_init_power();
bool tdeck_init_hardware();
bool tdeck_init_lvgl();
extern const tt::hal::Configuration lilygo_tdeck = {
.initBoot = tdeck_init_power,
.initHardware = tdeck_init_hardware,
.initLvgl = tdeck_init_lvgl,
.createDisplay = createDisplay,
.createKeyboard = createKeyboard,
@@ -54,5 +56,31 @@ extern const tt::hal::Configuration lilygo_tdeck = {
.clk_flags = 0
}
}
},
.spi {
tt::hal::spi::Configuration {
.device = SPI2_HOST,
.dma = SPI_DMA_CH_AUTO,
.config = {
.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,
.data_io_default_level = false,
.max_transfer_sz = TDECK_SPI_TRANSFER_SIZE_LIMIT,
.flags = 0,
.isr_cpu_id = ESP_INTR_CPU_AFFINITY_AUTO,
.intr_flags = 0
},
.initMode = tt::hal::spi::InitMode::ByTactility,
.canReinit = false,
.hasMutableConfiguration = false,
.lock = tt::lvgl::getLvglSyncLockable() // esp_lvgl_port owns the lock for the display
}
}
};
+3 -36
View File
@@ -1,4 +1,3 @@
#include "hal/Core2DisplayConstants.h"
#include "axp192/axp192.h"
#include <Tactility/Log.h>
@@ -7,14 +6,9 @@
#include <driver/i2c.h>
#include <driver/spi_master.h>
#include <esp_intr_types.h>
#define TAG "core2"
#define CORE2_SPI2_PIN_SCLK GPIO_NUM_18
#define CORE2_SPI2_PIN_MOSI GPIO_NUM_23
#define CORE2_SPI2_PIN_MISO GPIO_NUM_38
axp192_t axpDevice;
static int32_t axpI2cRead(TT_UNUSED void* handle, uint8_t address, uint8_t reg, uint8_t* buffer, uint16_t size) {
@@ -33,33 +27,7 @@ static int32_t axpI2cWrite(TT_UNUSED void* handle, uint8_t address, uint8_t reg,
}
}
static bool initSpi2() {
TT_LOG_I(TAG, LOG_MESSAGE_SPI_INIT_START_FMT, SPI2_HOST);
const spi_bus_config_t bus_config = {
.mosi_io_num = CORE2_SPI2_PIN_MOSI,
.miso_io_num = CORE2_SPI2_PIN_MISO,
.sclk_io_num = CORE2_SPI2_PIN_SCLK,
.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,
.max_transfer_sz = CORE2_LCD_DRAW_BUFFER_SIZE,
.flags = 0,
.isr_cpu_id = ESP_INTR_CPU_AFFINITY_AUTO,
.intr_flags = 0
};
if (spi_bus_initialize(SPI2_HOST, &bus_config, SPI_DMA_CH_AUTO) != ESP_OK) {
TT_LOG_E(TAG, LOG_MESSAGE_SPI_INIT_FAILED_FMT, SPI2_HOST);
return false;
}
return true;
}
bool initAxp() {
void initAxp() {
axpDevice.read = axpI2cRead;
axpDevice.write = axpI2cWrite;
@@ -74,11 +42,10 @@ bool initAxp() {
axp192_write(&axpDevice, AXP192_PWM1_DUTY_CYCLE_2, 255); // PWM 255 (LED OFF)
axp192_write(&axpDevice, AXP192_GPIO1_CONTROL, 0x02); // GPIO1 PWM
// TODO: We could charge at 390mA according to the M5Unified code, but the AXP driver in M5Unified limits to 132mA, so it's unclear what the AXP supports.
return true;
}
bool initBoot() {
TT_LOG_I(TAG, "initBoot");
return initAxp() && initSpi2();
initAxp();
return true;
}
+31 -1
View File
@@ -1,9 +1,13 @@
#include "M5stackCore2.h"
#include "InitBoot.h"
#include "InitLvgl.h"
#include "Tactility/lvgl/LvglSync.h"
#include "hal/Core2Display.h"
#include "hal/Core2SdCard.h"
#include "hal/Core2DisplayConstants.h"
#include "hal/Core2Power.h"
#include "hal/Core2SdCard.h"
#define CORE2_SPI_TRANSFER_SIZE_LIMIT (CORE2_LCD_DRAW_BUFFER_SIZE * LV_COLOR_DEPTH / 8)
extern const tt::hal::Configuration m5stack_core2 = {
.initBoot = initBoot,
@@ -48,5 +52,31 @@ extern const tt::hal::Configuration m5stack_core2 = {
.clk_flags = 0
}
}
},
.spi {
tt::hal::spi::Configuration {
.device = SPI2_HOST,
.dma = SPI_DMA_CH_AUTO,
.config = {
.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,
.data_io_default_level = false,
.max_transfer_sz = CORE2_SPI_TRANSFER_SIZE_LIMIT,
.flags = 0,
.isr_cpu_id = ESP_INTR_CPU_AFFINITY_AUTO,
.intr_flags = 0
},
.initMode = tt::hal::spi::InitMode::ByTactility,
.canReinit = false,
.hasMutableConfiguration = false,
.lock = tt::lvgl::getLvglSyncLockable() // esp_lvgl_port owns the lock for the display
}
}
};
+1 -39
View File
@@ -5,48 +5,12 @@
#include <Tactility/Log.h>
#include <Tactility/kernel/Kernel.h>
#include <driver/i2c.h>
#include <driver/spi_master.h>
#include <esp_intr_types.h>
#define TAG "core2"
#define CORES3_SPI2_PIN_SCLK GPIO_NUM_36
#define CORES3_SPI2_PIN_MOSI GPIO_NUM_37
#define CORES3_SPI2_PIN_MISO GPIO_NUM_35
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
*/
static bool initSpi3() {
TT_LOG_I(TAG, LOG_MESSAGE_SPI_INIT_START_FMT, SPI3_HOST);
const spi_bus_config_t bus_config = {
.mosi_io_num = CORES3_SPI2_PIN_MOSI,
.miso_io_num = CORES3_SPI2_PIN_MISO,
.sclk_io_num = CORES3_SPI2_PIN_SCLK,
.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_LCD_DRAW_BUFFER_SIZE,
.flags = 0,
.isr_cpu_id = ESP_INTR_CPU_AFFINITY_AUTO,
.intr_flags = 0
};
if (spi_bus_initialize(SPI3_HOST, &bus_config, SPI_DMA_CH_AUTO) != ESP_OK) {
TT_LOG_E(TAG, LOG_MESSAGE_SPI_INIT_FAILED_FMT, SPI3_HOST);
return false;
}
return true;
}
/**
* 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
@@ -184,7 +148,5 @@ bool initBoot() {
aw9523 = std::make_shared<Aw9523>(I2C_NUM_0);
tt::hal::registerDevice(aw9523);
return initPowerControl() &&
initGpioExpander() &&
initSpi3();
return initPowerControl() && initGpioExpander();
}
+31 -1
View File
@@ -1,9 +1,13 @@
#include "M5stackCoreS3.h"
#include "InitBoot.h"
#include "InitLvgl.h"
#include "Tactility/lvgl/LvglSync.h"
#include "hal/CoreS3Display.h"
#include "hal/CoreS3SdCard.h"
#include "hal/CoreS3DisplayConstants.h"
#include "hal/CoreS3Power.h"
#include "hal/CoreS3SdCard.h"
#define CORES3_TRANSACTION_SIZE (CORES3_LCD_DRAW_BUFFER_SIZE * LV_COLOR_DEPTH / 8)
const tt::hal::Configuration m5stack_cores3 = {
.initBoot = initBoot,
@@ -48,5 +52,31 @@ const tt::hal::Configuration m5stack_cores3 = {
.clk_flags = 0
}
}
},
.spi {
tt::hal::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 = tt::hal::spi::InitMode::ByTactility,
.canReinit = false,
.hasMutableConfiguration = false,
.lock = tt::lvgl::getLvglSyncLockable() // esp_lvgl_port owns the lock for the display
}
}
};
-47
View File
@@ -1,47 +0,0 @@
#include "hal/UnPhoneDisplayConstants.h"
#include "hx8357/disp_spi.h"
#include <Tactility/TactilityCore.h>
#include <driver/spi_common.h>
#include <soc/gpio_num.h>
#include <lvgl.h>
#define TAG "unphone"
// SPI
#define UNPHONE_SPI_HOST SPI2_HOST
#define UNPHONE_SPI_PIN_SCLK GPIO_NUM_39
#define UNPHONE_SPI_PIN_MOSI GPIO_NUM_40
#define UNPHONE_SPI_PIN_MISO GPIO_NUM_41
#define UNPHONE_SPI_TRANSFER_SIZE_LIMIT (UNPHONE_LCD_HORIZONTAL_RESOLUTION * UNPHONE_LCD_SPI_TRANSFER_HEIGHT * LV_COLOR_DEPTH / 8)
static bool initSpi() {
TT_LOG_I(TAG, LOG_MESSAGE_SPI_INIT_START_FMT, UNPHONE_SPI_HOST);
spi_bus_config_t bus_config = {
.mosi_io_num = UNPHONE_SPI_PIN_MOSI,
.miso_io_num = UNPHONE_SPI_PIN_MISO,
.sclk_io_num = UNPHONE_SPI_PIN_SCLK,
.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,
.data_io_default_level = false,
.max_transfer_sz = UNPHONE_SPI_TRANSFER_SIZE_LIMIT,
.flags = 0,
.isr_cpu_id = ESP_INTR_CPU_AFFINITY_AUTO,
.intr_flags = 0
};
if (spi_bus_initialize(UNPHONE_SPI_HOST, &bus_config, SPI_DMA_CH_AUTO) != ESP_OK) {
TT_LOG_E(TAG, LOG_MESSAGE_SPI_INIT_FAILED_FMT, UNPHONE_SPI_HOST);
return false;
}
return true;
}
bool unPhoneInitHardware() {
return initSpi();
}
-2
View File
@@ -1,5 +1,3 @@
#include "hal/UnPhoneDisplay.h"
#include <Tactility/Log.h>
#include <Tactility/Thread.h>
#include <Tactility/lvgl/LvglSync.h>
+30 -2
View File
@@ -1,16 +1,18 @@
#include "Tactility/lvgl/LvglSync.h"
#include "UnPhoneFeatures.h"
#include "hal/UnPhoneDisplayConstants.h"
#include "hal/UnPhoneDisplay.h"
#include "hal/UnPhonePower.h"
#include "hal/UnPhoneSdCard.h"
#include <Tactility/hal/Configuration.h>
#define UNPHONE_SPI_TRANSFER_SIZE_LIMIT (UNPHONE_LCD_HORIZONTAL_RESOLUTION * UNPHONE_LCD_SPI_TRANSFER_HEIGHT * LV_COLOR_DEPTH / 8)
bool unPhoneInitPower();
bool unPhoneInitHardware();
bool unPhoneInitLvgl();
extern const tt::hal::Configuration unPhone = {
.initBoot = unPhoneInitPower,
.initHardware = unPhoneInitHardware,
.initLvgl = unPhoneInitLvgl,
.createDisplay = createDisplay,
.sdcard = createUnPhoneSdCard(),
@@ -52,5 +54,31 @@ extern const tt::hal::Configuration unPhone = {
.clk_flags = 0
}
}
},
.spi {
tt::hal::spi::Configuration {
.device = SPI2_HOST,
.dma = SPI_DMA_CH_AUTO,
.config = {
.mosi_io_num = GPIO_NUM_40,
.miso_io_num = GPIO_NUM_41,
.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,
.data_io_default_level = false,
.max_transfer_sz = UNPHONE_SPI_TRANSFER_SIZE_LIMIT,
.flags = 0,
.isr_cpu_id = ESP_INTR_CPU_AFFINITY_AUTO,
.intr_flags = 0
},
.initMode = tt::hal::spi::InitMode::ByTactility,
.canReinit = false,
.hasMutableConfiguration = false,
.lock = tt::lvgl::getLvglSyncLockable() // esp_lvgl_port owns the lock for the display
}
}
};