SPI device migration (#490)

- Implement SPI devices in dts files for all devices
- Removed `tt::hal::spi` HAL and its configurations
- Fix for devicetree generator "boolean" support
- Remove unused custom locks in all `DisplayDevice` implementations
- Fixed some bugs with devices
- Updated XPT2046 driver
- Fix for `WifiEsp` deadlock
- Export a lot of new `math.h` symbols with `tt_init.cpp`
- Created `SpiDeviceLock` in `TactilityCore` as a wrapper for kernel SPI locking
- Improved `TactilityKernel` SPI driver.
This commit is contained in:
Ken Van Hoeylandt
2026-02-08 22:14:18 +01:00
committed by GitHub
parent 74127a5f6c
commit d27404964a
177 changed files with 1091 additions and 2205 deletions
@@ -3,13 +3,10 @@
#include <driver/gpio.h>
#include <Tactility/hal/Configuration.h>
#include <Tactility/lvgl/LvglSync.h>
#include <PwmBacklight.h>
using namespace tt::hal;
constexpr auto* TAG = "Waveshare";
static DeviceVector createDevices() {
return {
createDisplay(),
@@ -24,57 +21,5 @@ static bool initBoot() {
extern const Configuration hardwareConfiguration = {
.initBoot = initBoot,
.uiScale = UiScale::Smallest,
.createDevices = createDevices,
.spi {
// Display
spi::Configuration {
.device = SPI2_HOST,
.dma = SPI_DMA_DISABLED,
.config = {
.mosi_io_num = GPIO_NUM_11,
.miso_io_num = GPIO_NUM_12,
.sclk_io_num = GPIO_NUM_10,
.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 = ((240 * (240 / 10)) * LV_COLOR_DEPTH / 8),
.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
},
// SD card available via external sd card module and uses VSYS (5V) / GND / IO15 / IO16 / IO17 / IO18 pins.
// Common micro sd card module you'd find on aliexpress with voltage regulator onboard. Others may work.
// JST SH 1.0 Header, GND / VSYS (5V) / RESET / BOOT / GND / 3.3V / IO15 / IO16 / IO17 / IO18 / IO21 / IO33
spi::Configuration {
.device = SPI3_HOST,
.dma = SPI_DMA_CH_AUTO,
.config = {
.mosi_io_num = GPIO_NUM_16,
.miso_io_num = GPIO_NUM_15,
.sclk_io_num = GPIO_NUM_17,
.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 = 32768,
.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
}
}
.createDevices = createDevices
};
@@ -1,8 +1,8 @@
#include "SdCard.h"
#include <tactility/device.h>
#include <Tactility/lvgl/LvglSync.h>
#include <Tactility/hal/sdcard/SpiSdCardDevice.h>
#include <Tactility/RecursiveMutex.h>
using tt::hal::sdcard::SpiSdCardDevice;
@@ -13,12 +13,16 @@ std::shared_ptr<SdCardDevice> createSdCard() {
GPIO_NUM_NC,
GPIO_NUM_NC,
SdCardDevice::MountBehaviour::AtBoot,
std::make_shared<tt::RecursiveMutex>(),
nullptr,
std::vector<gpio_num_t>(),
SPI3_HOST
);
auto* spi_controller = device_find_by_name("spi1");
check(spi_controller, "spi1 not found");
return std::make_shared<SpiSdCardDevice>(
std::move(configuration)
std::move(configuration),
spi_controller
);
}
@@ -18,4 +18,10 @@ shape=circle
dpi=265
[lvgl]
colorDepth=16
colorDepth=16
[sdkconfig]
# Fix error "PSRAM space not enough for the Flash instructions" on boot:
CONFIG_SPIRAM_FETCH_INSTRUCTIONS=n
CONFIG_SPIRAM_RODATA=n
CONFIG_SPIRAM_XIP_FROM_PSRAM=n
@@ -3,7 +3,9 @@
#include <tactility/bindings/root.h>
#include <tactility/bindings/esp32_gpio.h>
#include <tactility/bindings/esp32_i2c.h>
#include <tactility/bindings/esp32_spi.h>
// Reference: https://www.waveshare.com/wiki/ESP32-S3-Touch-LCD-1.28
/ {
compatible = "root";
model = "Waveshare S3 Touch LCD 1.28";
@@ -13,11 +15,33 @@
gpio-count = <49>;
};
i2c_main {
i2c0 {
compatible = "espressif,esp32-i2c";
port = <I2C_NUM_0>;
clock-frequency = <400000>;
pin-sda = <6>;
pin-scl = <7>;
};
display_spi: spi0 {
compatible = "espressif,esp32-spi";
host = <SPI2_HOST>;
pin-mosi = <11>;
pin-miso = <12>;
pin-sclk = <10>;
pin-wp = <GPIO_PIN_NONE>;
pin-hd = <GPIO_PIN_NONE>;
max-transfer-size = <0>;
};
sdcard_spi: spi1 {
compatible = "espressif,esp32-spi";
host = <SPI3_HOST>;
pin-mosi = <16>;
pin-miso = <15>;
pin-sclk = <17>;
pin-wp = <GPIO_PIN_NONE>;
pin-hd = <GPIO_PIN_NONE>;
max-transfer-size = <0>;
};
};