From 497568f85ea68ede07749788feaec32ca1c2f964 Mon Sep 17 00:00:00 2001 From: Ken Van Hoeylandt Date: Sat, 20 Jun 2026 00:52:58 +0200 Subject: [PATCH] WIP --- .../cyd-2432s024c/Source/Configuration.cpp | 2 - .../cyd-2432s024c/Source/devices/SdCard.cpp | 34 ---- Devices/cyd-2432s024c/Source/devices/SdCard.h | 8 - Devices/cyd-2432s024c/cyd,2432s024c.dts | 16 +- .../cyd-2432s024r/Source/Configuration.cpp | 4 +- .../cyd-2432s024r/Source/devices/SdCard.cpp | 23 --- Devices/cyd-2432s024r/Source/devices/SdCard.h | 8 - Devices/cyd-2432s024r/cyd,2432s024r.dts | 16 +- .../cyd-2432s028r/Source/Configuration.cpp | 2 - .../cyd-2432s028r/Source/devices/SdCard.cpp | 25 --- Devices/cyd-2432s028r/Source/devices/SdCard.h | 8 - Devices/cyd-2432s028r/cyd,2432s028r.dts | 16 +- .../cyd-2432s028rv3/Source/Configuration.cpp | 2 - .../cyd-2432s028rv3/Source/devices/SdCard.cpp | 25 --- .../cyd-2432s028rv3/Source/devices/SdCard.h | 8 - Devices/cyd-2432s028rv3/cyd,2432s028rv3.dts | 16 +- .../cyd-2432s032c/Source/Configuration.cpp | 2 - .../cyd-2432s032c/Source/devices/SdCard.cpp | 33 ---- Devices/cyd-2432s032c/Source/devices/SdCard.h | 8 - Devices/cyd-2432s032c/cyd,2432s032c.dts | 16 +- .../cyd-3248s035c/Source/Configuration.cpp | 66 ++++---- .../cyd-3248s035c/Source/devices/SdCard.cpp | 31 ---- Devices/cyd-3248s035c/Source/devices/SdCard.h | 8 - Devices/cyd-3248s035c/cyd,3248s035c.dts | 128 +++++++------- .../cyd-4848s040c/Source/Configuration.cpp | 2 - .../cyd-4848s040c/Source/devices/SdCard.cpp | 28 --- Devices/cyd-4848s040c/Source/devices/SdCard.h | 8 - Devices/cyd-4848s040c/cyd,4848s040c.dts | 7 + .../cyd-8048s043c/Source/Configuration.cpp | 2 - .../cyd-8048s043c/Source/devices/SdCard.cpp | 25 --- Devices/cyd-8048s043c/Source/devices/SdCard.h | 7 - Devices/cyd-8048s043c/cyd,8048s043c.dts | 7 + Devices/cyd-e32r28t/Source/Configuration.cpp | 2 - Devices/cyd-e32r28t/Source/devices/SdCard.cpp | 28 --- Devices/cyd-e32r28t/Source/devices/SdCard.h | 7 - Devices/cyd-e32r28t/cyd,e32r28t.dts | 16 +- Devices/cyd-e32r32p/Source/Configuration.cpp | 2 - Devices/cyd-e32r32p/Source/devices/SdCard.cpp | 29 ---- Devices/cyd-e32r32p/Source/devices/SdCard.h | 13 -- Devices/cyd-e32r32p/cyd,e32r32p.dts | 16 +- .../Source/Configuration.cpp | 2 - .../Source/devices/SdCard.cpp | 29 ---- .../Source/devices/SdCard.h | 7 - .../elecrow,crowpanel-advance-28.dts | 16 +- .../Source/Configuration.cpp | 2 - .../Source/devices/SdCard.cpp | 29 ---- .../Source/devices/SdCard.h | 7 - .../elecrow,crowpanel-advance-35.dts | 16 +- .../Source/Configuration.cpp | 2 - .../Source/devices/SdCard.cpp | 25 --- .../Source/devices/SdCard.h | 7 - .../elecrow,crowpanel-advance-50.dts | 9 +- .../Source/Configuration.cpp | 2 - .../Source/devices/SdCard.cpp | 28 --- .../Source/devices/SdCard.h | 7 - .../elecrow,crowpanel-basic-28.dts | 16 +- .../Source/Configuration.cpp | 2 - .../Source/devices/SdCard.cpp | 28 --- .../Source/devices/SdCard.h | 7 - .../elecrow,crowpanel-basic-35.dts | 16 +- .../Source/Configuration.cpp | 2 - .../Source/devices/SdCard.cpp | 24 --- .../Source/devices/SdCard.h | 7 - .../elecrow,crowpanel-basic-50.dts | 9 +- .../Source/Configuration.cpp | 2 - .../Source/devices/SdCard.cpp | 128 -------------- .../Source/devices/SdCard.h | 6 - .../guition,jc1060p470ciwy.dts | 13 ++ .../Source/Configuration.cpp | 2 - .../Source/devices/SdCard.cpp | 31 ---- .../Source/devices/SdCard.h | 8 - .../guition,jc2432w328c.dts | 16 +- .../Source/Configuration.cpp | 2 - .../Source/devices/SdCard.cpp | 30 ---- .../Source/devices/SdCard.h | 7 - .../guition,jc3248w535c.dts | 11 +- .../Source/Configuration.cpp | 2 - .../Source/devices/SdCard.cpp | 24 --- .../Source/devices/SdCard.h | 7 - .../guition,jc8048w550c.dts | 7 + Devices/lilygo-tdeck/Source/Configuration.cpp | 2 - .../lilygo-tdeck/Source/devices/Sdcard.cpp | 34 ---- Devices/lilygo-tdeck/Source/devices/Sdcard.h | 7 - Devices/lilygo-tdeck/lilygo,tdeck.dts | 12 ++ Devices/lilygo-tdisplay/lilygo,tdisplay.dts | 5 + .../lilygo-tdongle-s3/lilygo,tdongle-s3.dts | 5 + .../Source/Configuration.cpp | 1 - .../Source/devices/SdCard.cpp | 36 ---- .../Source/devices/SdCard.h | 8 - .../lilygo-tlora-pager/lilygo,tlora-pager.dts | 12 ++ .../Source/Configuration.cpp | 2 - .../Source/devices/SdCard.cpp | 30 ---- .../Source/devices/SdCard.h | 8 - .../m5stack,cardputer-adv.dts | 16 +- .../Source/Configuration.cpp | 2 - .../Source/devices/SdCard.cpp | 29 ---- .../m5stack-cardputer/Source/devices/SdCard.h | 8 - .../m5stack-cardputer/m5stack,cardputer.dts | 16 +- .../m5stack-core2/Source/Configuration.cpp | 2 - .../m5stack-core2/Source/devices/SdCard.cpp | 32 ---- Devices/m5stack-core2/Source/devices/SdCard.h | 7 - Devices/m5stack-core2/m5stack,core2.dts | 12 ++ .../m5stack-cores3/Source/Configuration.cpp | 2 - .../m5stack-cores3/Source/devices/SdCard.cpp | 30 ---- .../m5stack-cores3/Source/devices/SdCard.h | 7 - Devices/m5stack-cores3/m5stack,cores3.dts | 12 ++ .../m5stack-papers3/Source/Configuration.cpp | 2 - .../m5stack-papers3/Source/devices/SdCard.cpp | 27 --- .../m5stack-papers3/Source/devices/SdCard.h | 7 - Devices/m5stack-papers3/m5stack,papers3.dts | 7 + .../Source/Configuration.cpp | 2 - .../Source/devices/SdCard.cpp | 30 ---- .../m5stack-stackchan/Source/devices/SdCard.h | 7 - .../m5stack-stackchan/m5stack,stackchan.dts | 12 ++ .../m5stack,stickc-plus.dts | 5 + .../m5stack,stickc-plus2.dts | 5 + .../m5stack-sticks3/Source/Configuration.cpp | 2 - .../m5stack-sticks3/Source/devices/SdCard.cpp | 30 ---- .../m5stack-sticks3/Source/devices/SdCard.h | 8 - Devices/m5stack-sticks3/m5stack,sticks3.dts | 12 ++ Devices/m5stack-tab5/Source/Configuration.cpp | 2 - .../m5stack-tab5/Source/devices/SdCard.cpp | 26 --- Devices/m5stack-tab5/Source/devices/SdCard.h | 8 - Devices/m5stack-tab5/m5stack,tab5.dts | 9 +- Devices/unphone/Source/Configuration.cpp | 2 - Devices/unphone/Source/devices/SdCard.cpp | 36 ---- Devices/unphone/Source/devices/SdCard.h | 7 - Devices/unphone/unphone.dts | 7 + .../waveshare,esp32-s3-geek.dts | 5 + .../Source/Configuration.cpp | 2 - .../Source/devices/SdCard.cpp | 28 --- .../Source/devices/SdCard.h | 7 - .../waveshare,s3-lcd-13.dts | 12 ++ .../Source/Configuration.cpp | 2 - .../Source/devices/SdCard.cpp | 28 --- .../Source/devices/SdCard.h | 7 - .../waveshare,s3-touch-lcd-128.dts | 16 +- .../Source/Configuration.cpp | 2 - .../Source/devices/Sdcard.cpp | 30 ---- .../Source/devices/Sdcard.h | 7 - .../waveshare,s3-touch-lcd-147.dts | 11 +- .../Source/Configuration.cpp | 2 - .../Source/devices/SdCard.cpp | 26 --- .../Source/devices/SdCard.h | 7 - .../waveshare,s3-touch-lcd-43.dts | 7 + .../Source/Configuration.cpp | 46 +++-- .../Source/devices/SdCard.cpp | 28 --- .../Source/devices/SdCard.h | 7 - .../wireless-tag,wt32-sc01-plus.dts | 7 + .../bindings/espressif,esp32-sdspi.yaml | 27 +++ .../include/tactility/bindings/esp32_sdspi.h | 15 ++ .../include/tactility/drivers/esp32_sdcard.h | 21 +++ .../include/tactility/drivers/esp32_sdspi.h | 23 +++ .../tactility/drivers/esp32_sdspi_fs.h | 22 +++ .../source/drivers/esp32_sdcard.cpp | 27 +++ .../source/drivers/esp32_sdmmc.cpp | 1 + .../source/drivers/esp32_sdspi.cpp | 159 ++++++++++++++++++ .../source/drivers/esp32_sdspi_fs.cpp | 126 ++++++++++++++ Platforms/platform-esp32/source/module.cpp | 3 + .../Tactility/hal/sdcard/SpiSdCardDevice.h | 104 ------------ Tactility/Source/hal/sdcard/SdCard.cpp | 49 ++++-- .../Source/hal/sdcard/SpiSdCardDevice.cpp | 156 ----------------- Tactility/Source/hal/usb/Usb.cpp | 47 ++---- .../Source/service/statusbar/Statusbar.cpp | 23 ++- .../bindings/display-placeholder.yaml | 5 + TactilityKernel/bindings/spi-peripheral.yaml | 9 + .../tactility/bindings/display_placeholder.h | 15 ++ .../tactility/bindings/spi_peripheral.h | 15 ++ TactilityKernel/include/tactility/device.h | 7 + .../include/tactility/drivers/display.h | 14 ++ .../tactility/drivers/display_placeholder.h | 16 ++ .../tactility/drivers/spi_peripheral.h | 25 +++ .../tactility/filesystem/file_system.h | 14 ++ TactilityKernel/source/device.cpp | 4 + TactilityKernel/source/drivers/display.cpp | 10 ++ .../source/drivers/display_placeholder.cpp | 26 +++ .../source/drivers/spi_peripheral.cpp | 77 +++++++++ .../source/filesystem/file_system.cpp | 11 ++ TactilityKernel/source/kernel_init.cpp | 4 + 179 files changed, 1287 insertions(+), 1944 deletions(-) delete mode 100644 Devices/cyd-2432s024c/Source/devices/SdCard.cpp delete mode 100644 Devices/cyd-2432s024c/Source/devices/SdCard.h delete mode 100644 Devices/cyd-2432s024r/Source/devices/SdCard.cpp delete mode 100644 Devices/cyd-2432s024r/Source/devices/SdCard.h delete mode 100644 Devices/cyd-2432s028r/Source/devices/SdCard.cpp delete mode 100644 Devices/cyd-2432s028r/Source/devices/SdCard.h delete mode 100644 Devices/cyd-2432s028rv3/Source/devices/SdCard.cpp delete mode 100644 Devices/cyd-2432s028rv3/Source/devices/SdCard.h delete mode 100644 Devices/cyd-2432s032c/Source/devices/SdCard.cpp delete mode 100644 Devices/cyd-2432s032c/Source/devices/SdCard.h delete mode 100644 Devices/cyd-3248s035c/Source/devices/SdCard.cpp delete mode 100644 Devices/cyd-3248s035c/Source/devices/SdCard.h delete mode 100644 Devices/cyd-4848s040c/Source/devices/SdCard.cpp delete mode 100644 Devices/cyd-4848s040c/Source/devices/SdCard.h delete mode 100644 Devices/cyd-8048s043c/Source/devices/SdCard.cpp delete mode 100644 Devices/cyd-8048s043c/Source/devices/SdCard.h delete mode 100644 Devices/cyd-e32r28t/Source/devices/SdCard.cpp delete mode 100644 Devices/cyd-e32r28t/Source/devices/SdCard.h delete mode 100644 Devices/cyd-e32r32p/Source/devices/SdCard.cpp delete mode 100644 Devices/cyd-e32r32p/Source/devices/SdCard.h delete mode 100644 Devices/elecrow-crowpanel-advance-28/Source/devices/SdCard.cpp delete mode 100644 Devices/elecrow-crowpanel-advance-28/Source/devices/SdCard.h delete mode 100644 Devices/elecrow-crowpanel-advance-35/Source/devices/SdCard.cpp delete mode 100644 Devices/elecrow-crowpanel-advance-35/Source/devices/SdCard.h delete mode 100644 Devices/elecrow-crowpanel-advance-50/Source/devices/SdCard.cpp delete mode 100644 Devices/elecrow-crowpanel-advance-50/Source/devices/SdCard.h delete mode 100644 Devices/elecrow-crowpanel-basic-28/Source/devices/SdCard.cpp delete mode 100644 Devices/elecrow-crowpanel-basic-28/Source/devices/SdCard.h delete mode 100644 Devices/elecrow-crowpanel-basic-35/Source/devices/SdCard.cpp delete mode 100644 Devices/elecrow-crowpanel-basic-35/Source/devices/SdCard.h delete mode 100644 Devices/elecrow-crowpanel-basic-50/Source/devices/SdCard.cpp delete mode 100644 Devices/elecrow-crowpanel-basic-50/Source/devices/SdCard.h delete mode 100644 Devices/guition-jc1060p470ciwy/Source/devices/SdCard.cpp delete mode 100644 Devices/guition-jc1060p470ciwy/Source/devices/SdCard.h delete mode 100644 Devices/guition-jc2432w328c/Source/devices/SdCard.cpp delete mode 100644 Devices/guition-jc2432w328c/Source/devices/SdCard.h delete mode 100644 Devices/guition-jc3248w535c/Source/devices/SdCard.cpp delete mode 100644 Devices/guition-jc3248w535c/Source/devices/SdCard.h delete mode 100644 Devices/guition-jc8048w550c/Source/devices/SdCard.cpp delete mode 100644 Devices/guition-jc8048w550c/Source/devices/SdCard.h delete mode 100644 Devices/lilygo-tdeck/Source/devices/Sdcard.cpp delete mode 100644 Devices/lilygo-tdeck/Source/devices/Sdcard.h delete mode 100644 Devices/lilygo-tlora-pager/Source/devices/SdCard.cpp delete mode 100644 Devices/lilygo-tlora-pager/Source/devices/SdCard.h delete mode 100644 Devices/m5stack-cardputer-adv/Source/devices/SdCard.cpp delete mode 100644 Devices/m5stack-cardputer-adv/Source/devices/SdCard.h delete mode 100644 Devices/m5stack-cardputer/Source/devices/SdCard.cpp delete mode 100644 Devices/m5stack-cardputer/Source/devices/SdCard.h delete mode 100644 Devices/m5stack-core2/Source/devices/SdCard.cpp delete mode 100644 Devices/m5stack-core2/Source/devices/SdCard.h delete mode 100644 Devices/m5stack-cores3/Source/devices/SdCard.cpp delete mode 100644 Devices/m5stack-cores3/Source/devices/SdCard.h delete mode 100644 Devices/m5stack-papers3/Source/devices/SdCard.cpp delete mode 100644 Devices/m5stack-papers3/Source/devices/SdCard.h delete mode 100644 Devices/m5stack-stackchan/Source/devices/SdCard.cpp delete mode 100644 Devices/m5stack-stackchan/Source/devices/SdCard.h delete mode 100644 Devices/m5stack-sticks3/Source/devices/SdCard.cpp delete mode 100644 Devices/m5stack-sticks3/Source/devices/SdCard.h delete mode 100644 Devices/m5stack-tab5/Source/devices/SdCard.cpp delete mode 100644 Devices/m5stack-tab5/Source/devices/SdCard.h delete mode 100644 Devices/unphone/Source/devices/SdCard.cpp delete mode 100644 Devices/unphone/Source/devices/SdCard.h delete mode 100644 Devices/waveshare-s3-lcd-13/Source/devices/SdCard.cpp delete mode 100644 Devices/waveshare-s3-lcd-13/Source/devices/SdCard.h delete mode 100644 Devices/waveshare-s3-touch-lcd-128/Source/devices/SdCard.cpp delete mode 100644 Devices/waveshare-s3-touch-lcd-128/Source/devices/SdCard.h delete mode 100644 Devices/waveshare-s3-touch-lcd-147/Source/devices/Sdcard.cpp delete mode 100644 Devices/waveshare-s3-touch-lcd-147/Source/devices/Sdcard.h delete mode 100644 Devices/waveshare-s3-touch-lcd-43/Source/devices/SdCard.cpp delete mode 100644 Devices/waveshare-s3-touch-lcd-43/Source/devices/SdCard.h delete mode 100644 Devices/wireless-tag-wt32-sc01-plus/Source/devices/SdCard.cpp delete mode 100644 Devices/wireless-tag-wt32-sc01-plus/Source/devices/SdCard.h create mode 100644 Platforms/platform-esp32/bindings/espressif,esp32-sdspi.yaml create mode 100644 Platforms/platform-esp32/include/tactility/bindings/esp32_sdspi.h create mode 100644 Platforms/platform-esp32/include/tactility/drivers/esp32_sdcard.h create mode 100644 Platforms/platform-esp32/include/tactility/drivers/esp32_sdspi.h create mode 100644 Platforms/platform-esp32/private/tactility/drivers/esp32_sdspi_fs.h create mode 100644 Platforms/platform-esp32/source/drivers/esp32_sdcard.cpp create mode 100644 Platforms/platform-esp32/source/drivers/esp32_sdspi.cpp create mode 100644 Platforms/platform-esp32/source/drivers/esp32_sdspi_fs.cpp delete mode 100644 Tactility/Include/Tactility/hal/sdcard/SpiSdCardDevice.h delete mode 100644 Tactility/Source/hal/sdcard/SpiSdCardDevice.cpp create mode 100644 TactilityKernel/bindings/display-placeholder.yaml create mode 100644 TactilityKernel/bindings/spi-peripheral.yaml create mode 100644 TactilityKernel/include/tactility/bindings/display_placeholder.h create mode 100644 TactilityKernel/include/tactility/bindings/spi_peripheral.h create mode 100644 TactilityKernel/include/tactility/drivers/display.h create mode 100644 TactilityKernel/include/tactility/drivers/display_placeholder.h create mode 100644 TactilityKernel/include/tactility/drivers/spi_peripheral.h create mode 100644 TactilityKernel/source/drivers/display.cpp create mode 100644 TactilityKernel/source/drivers/display_placeholder.cpp create mode 100644 TactilityKernel/source/drivers/spi_peripheral.cpp diff --git a/Devices/cyd-2432s024c/Source/Configuration.cpp b/Devices/cyd-2432s024c/Source/Configuration.cpp index 055d6deec..a6d9b6164 100644 --- a/Devices/cyd-2432s024c/Source/Configuration.cpp +++ b/Devices/cyd-2432s024c/Source/Configuration.cpp @@ -1,5 +1,4 @@ #include "devices/Display.h" -#include "devices/SdCard.h" #include #include @@ -23,7 +22,6 @@ static bool initBoot() { static tt::hal::DeviceVector createDevices() { return { createDisplay(), - createSdCard() }; } diff --git a/Devices/cyd-2432s024c/Source/devices/SdCard.cpp b/Devices/cyd-2432s024c/Source/devices/SdCard.cpp deleted file mode 100644 index 7f102d97a..000000000 --- a/Devices/cyd-2432s024c/Source/devices/SdCard.cpp +++ /dev/null @@ -1,34 +0,0 @@ -#include "SdCard.h" - -#define TAG "twodotfour_sdcard" - -#include -#include -#include - -constexpr auto SDCARD_SPI_HOST = SPI3_HOST; -constexpr auto SDCARD_PIN_CS = GPIO_NUM_5; - -using tt::hal::sdcard::SpiSdCardDevice; - -std::shared_ptr createSdCard() { - auto configuration = std::make_unique( - SDCARD_PIN_CS, - GPIO_NUM_NC, - GPIO_NUM_NC, - GPIO_NUM_NC, - SdCardDevice::MountBehaviour::AtBoot, - nullptr, - std::vector(), - SDCARD_SPI_HOST - ); - - auto* spi_controller = device_find_by_name("spi1"); - check(spi_controller, "spi1 not found"); - - return std::make_shared( - std::move(configuration), - spi_controller - ); -} - diff --git a/Devices/cyd-2432s024c/Source/devices/SdCard.h b/Devices/cyd-2432s024c/Source/devices/SdCard.h deleted file mode 100644 index 4da9f5b97..000000000 --- a/Devices/cyd-2432s024c/Source/devices/SdCard.h +++ /dev/null @@ -1,8 +0,0 @@ -#pragma once - -#include "Tactility/hal/sdcard/SdCardDevice.h" - -using tt::hal::sdcard::SdCardDevice; - -std::shared_ptr createSdCard(); - diff --git a/Devices/cyd-2432s024c/cyd,2432s024c.dts b/Devices/cyd-2432s024c/cyd,2432s024c.dts index c1cace0f7..ccc1ad75d 100644 --- a/Devices/cyd-2432s024c/cyd,2432s024c.dts +++ b/Devices/cyd-2432s024c/cyd,2432s024c.dts @@ -4,6 +4,8 @@ #include #include #include +#include +#include / { compatible = "root"; @@ -22,18 +24,28 @@ pin-scl = <&gpio0 32 GPIO_FLAG_NONE>; }; - display_spi: spi0 { + spi0 { compatible = "espressif,esp32-spi"; host = ; pin-mosi = <&gpio0 13 GPIO_FLAG_NONE>; pin-sclk = <&gpio0 14 GPIO_FLAG_NONE>; + + display { + compatible = "display-placeholder"; + }; }; - sdcard_spi: spi1 { + spi1 { compatible = "espressif,esp32-spi"; host = ; pin-mosi = <&gpio0 23 GPIO_FLAG_NONE>; pin-miso = <&gpio0 19 GPIO_FLAG_NONE>; pin-sclk = <&gpio0 18 GPIO_FLAG_NONE>; + + sdcard { + compatible = "espressif,esp32-sdspi"; + pin-cs = <&gpio0 5 GPIO_FLAG_NONE>; + frequency-khz = <20000>; + }; }; }; diff --git a/Devices/cyd-2432s024r/Source/Configuration.cpp b/Devices/cyd-2432s024r/Source/Configuration.cpp index f6d5e149d..1f715033f 100644 --- a/Devices/cyd-2432s024r/Source/Configuration.cpp +++ b/Devices/cyd-2432s024r/Source/Configuration.cpp @@ -1,5 +1,4 @@ #include "devices/Display.h" -#include "devices/SdCard.h" #include #include @@ -14,8 +13,7 @@ static bool initBoot() { static DeviceVector createDevices() { return { - createDisplay(), - createSdCard() + createDisplay() }; } diff --git a/Devices/cyd-2432s024r/Source/devices/SdCard.cpp b/Devices/cyd-2432s024r/Source/devices/SdCard.cpp deleted file mode 100644 index cd8f648ab..000000000 --- a/Devices/cyd-2432s024r/Source/devices/SdCard.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include "SdCard.h" -#include -#include - -using tt::hal::sdcard::SpiSdCardDevice; - -std::shared_ptr createSdCard() { - auto config = std::make_unique( - GPIO_NUM_5, - GPIO_NUM_NC, - GPIO_NUM_NC, - GPIO_NUM_NC, - SdCardDevice::MountBehaviour::AtBoot, - nullptr, - std::vector(), - SPI3_HOST - ); - - auto* spi_controller = device_find_by_name("spi1"); - check(spi_controller, "spi1 not found"); - - return std::make_shared(std::move(config), spi_controller); -} diff --git a/Devices/cyd-2432s024r/Source/devices/SdCard.h b/Devices/cyd-2432s024r/Source/devices/SdCard.h deleted file mode 100644 index 4da9f5b97..000000000 --- a/Devices/cyd-2432s024r/Source/devices/SdCard.h +++ /dev/null @@ -1,8 +0,0 @@ -#pragma once - -#include "Tactility/hal/sdcard/SdCardDevice.h" - -using tt::hal::sdcard::SdCardDevice; - -std::shared_ptr createSdCard(); - diff --git a/Devices/cyd-2432s024r/cyd,2432s024r.dts b/Devices/cyd-2432s024r/cyd,2432s024r.dts index 0c151b587..737cd00bc 100644 --- a/Devices/cyd-2432s024r/cyd,2432s024r.dts +++ b/Devices/cyd-2432s024r/cyd,2432s024r.dts @@ -3,6 +3,8 @@ #include #include #include +#include +#include #include / { @@ -14,20 +16,30 @@ gpio-count = <40>; }; - display_spi: spi0 { + spi0 { compatible = "espressif,esp32-spi"; host = ; pin-mosi = <&gpio0 13 GPIO_FLAG_NONE>; pin-miso = <&gpio0 12 GPIO_FLAG_NONE>; pin-sclk = <&gpio0 14 GPIO_FLAG_NONE>; + + display { + compatible = "display-placeholder"; + }; }; - sdcard_spi: spi1 { + spi1 { compatible = "espressif,esp32-spi"; host = ; pin-mosi = <&gpio0 23 GPIO_FLAG_NONE>; pin-miso = <&gpio0 19 GPIO_FLAG_NONE>; pin-sclk = <&gpio0 18 GPIO_FLAG_NONE>; + + sdcard { + compatible = "espressif,esp32-sdspi"; + pin-cs = <&gpio0 5 GPIO_FLAG_NONE>; + frequency-khz = <20000>; + }; }; uart1 { diff --git a/Devices/cyd-2432s028r/Source/Configuration.cpp b/Devices/cyd-2432s028r/Source/Configuration.cpp index 5033e9759..bf458b5cb 100644 --- a/Devices/cyd-2432s028r/Source/Configuration.cpp +++ b/Devices/cyd-2432s028r/Source/Configuration.cpp @@ -1,5 +1,4 @@ #include "devices/Display.h" -#include "devices/SdCard.h" #include #include @@ -25,7 +24,6 @@ static bool initBoot() { static DeviceVector createDevices() { return { createDisplay(), - createSdCard() }; } diff --git a/Devices/cyd-2432s028r/Source/devices/SdCard.cpp b/Devices/cyd-2432s028r/Source/devices/SdCard.cpp deleted file mode 100644 index 85960aacb..000000000 --- a/Devices/cyd-2432s028r/Source/devices/SdCard.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include "SdCard.h" - -#include -#include - -using tt::hal::sdcard::SpiSdCardDevice; - -std::shared_ptr createSdCard() { - auto config = std::make_unique( - GPIO_NUM_5, - GPIO_NUM_NC, - GPIO_NUM_NC, - GPIO_NUM_NC, - SdCardDevice::MountBehaviour::AtBoot, - nullptr, - std::vector(), - SPI3_HOST - ); - - auto* spi_controller = device_find_by_name("spi1"); - check(spi_controller, "spi1 not found"); - - return std::make_shared(std::move(config), spi_controller); -} - diff --git a/Devices/cyd-2432s028r/Source/devices/SdCard.h b/Devices/cyd-2432s028r/Source/devices/SdCard.h deleted file mode 100644 index 4da9f5b97..000000000 --- a/Devices/cyd-2432s028r/Source/devices/SdCard.h +++ /dev/null @@ -1,8 +0,0 @@ -#pragma once - -#include "Tactility/hal/sdcard/SdCardDevice.h" - -using tt::hal::sdcard::SdCardDevice; - -std::shared_ptr createSdCard(); - diff --git a/Devices/cyd-2432s028r/cyd,2432s028r.dts b/Devices/cyd-2432s028r/cyd,2432s028r.dts index 2987df17c..4179d8e05 100644 --- a/Devices/cyd-2432s028r/cyd,2432s028r.dts +++ b/Devices/cyd-2432s028r/cyd,2432s028r.dts @@ -5,6 +5,8 @@ #include #include #include +#include +#include / { compatible = "root"; @@ -23,20 +25,30 @@ pin-scl = <&gpio0 22 GPIO_FLAG_NONE>; }; - display_spi: spi0 { + spi0 { compatible = "espressif,esp32-spi"; host = ; pin-mosi = <&gpio0 13 GPIO_FLAG_NONE>; pin-miso = <&gpio0 12 GPIO_FLAG_NONE>; pin-sclk = <&gpio0 14 GPIO_FLAG_NONE>; + + display { + compatible = "display-placeholder"; + }; }; - sdcard_spi: spi1 { + spi1 { compatible = "espressif,esp32-spi"; host = ; pin-mosi = <&gpio0 23 GPIO_FLAG_NONE>; pin-miso = <&gpio0 19 GPIO_FLAG_NONE>; pin-sclk = <&gpio0 18 GPIO_FLAG_NONE>; + + sdcard { + compatible = "espressif,esp32-sdspi"; + pin-cs = <&gpio0 5 GPIO_FLAG_NONE>; + frequency-khz = <20000>; + }; }; uart1 { diff --git a/Devices/cyd-2432s028rv3/Source/Configuration.cpp b/Devices/cyd-2432s028rv3/Source/Configuration.cpp index 5033e9759..bf458b5cb 100644 --- a/Devices/cyd-2432s028rv3/Source/Configuration.cpp +++ b/Devices/cyd-2432s028rv3/Source/Configuration.cpp @@ -1,5 +1,4 @@ #include "devices/Display.h" -#include "devices/SdCard.h" #include #include @@ -25,7 +24,6 @@ static bool initBoot() { static DeviceVector createDevices() { return { createDisplay(), - createSdCard() }; } diff --git a/Devices/cyd-2432s028rv3/Source/devices/SdCard.cpp b/Devices/cyd-2432s028rv3/Source/devices/SdCard.cpp deleted file mode 100644 index 85960aacb..000000000 --- a/Devices/cyd-2432s028rv3/Source/devices/SdCard.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include "SdCard.h" - -#include -#include - -using tt::hal::sdcard::SpiSdCardDevice; - -std::shared_ptr createSdCard() { - auto config = std::make_unique( - GPIO_NUM_5, - GPIO_NUM_NC, - GPIO_NUM_NC, - GPIO_NUM_NC, - SdCardDevice::MountBehaviour::AtBoot, - nullptr, - std::vector(), - SPI3_HOST - ); - - auto* spi_controller = device_find_by_name("spi1"); - check(spi_controller, "spi1 not found"); - - return std::make_shared(std::move(config), spi_controller); -} - diff --git a/Devices/cyd-2432s028rv3/Source/devices/SdCard.h b/Devices/cyd-2432s028rv3/Source/devices/SdCard.h deleted file mode 100644 index 4da9f5b97..000000000 --- a/Devices/cyd-2432s028rv3/Source/devices/SdCard.h +++ /dev/null @@ -1,8 +0,0 @@ -#pragma once - -#include "Tactility/hal/sdcard/SdCardDevice.h" - -using tt::hal::sdcard::SdCardDevice; - -std::shared_ptr createSdCard(); - diff --git a/Devices/cyd-2432s028rv3/cyd,2432s028rv3.dts b/Devices/cyd-2432s028rv3/cyd,2432s028rv3.dts index 5425e99a3..6105b94a3 100644 --- a/Devices/cyd-2432s028rv3/cyd,2432s028rv3.dts +++ b/Devices/cyd-2432s028rv3/cyd,2432s028rv3.dts @@ -5,6 +5,8 @@ #include #include #include +#include +#include / { compatible = "root"; @@ -23,20 +25,30 @@ pin-scl = <&gpio0 22 GPIO_FLAG_NONE>; }; - display_spi: spi0 { + spi0 { compatible = "espressif,esp32-spi"; host = ; pin-mosi = <&gpio0 13 GPIO_FLAG_NONE>; pin-miso = <&gpio0 12 GPIO_FLAG_NONE>; pin-sclk = <&gpio0 14 GPIO_FLAG_NONE>; + + display { + compatible = "display-placeholder"; + }; }; - sdcard_spi: spi1 { + spi1 { compatible = "espressif,esp32-spi"; host = ; pin-mosi = <&gpio0 23 GPIO_FLAG_NONE>; pin-miso = <&gpio0 19 GPIO_FLAG_NONE>; pin-sclk = <&gpio0 18 GPIO_FLAG_NONE>; + + sdcard { + compatible = "espressif,esp32-sdspi"; + pin-cs = <&gpio0 5 GPIO_FLAG_NONE>; + frequency-khz = <20000>; + }; }; uart1 { diff --git a/Devices/cyd-2432s032c/Source/Configuration.cpp b/Devices/cyd-2432s032c/Source/Configuration.cpp index af80ae199..52aaab007 100644 --- a/Devices/cyd-2432s032c/Source/Configuration.cpp +++ b/Devices/cyd-2432s032c/Source/Configuration.cpp @@ -1,5 +1,4 @@ #include "devices/Display.h" -#include "devices/SdCard.h" #include #include @@ -39,7 +38,6 @@ static bool initBoot() { static tt::hal::DeviceVector createDevices() { return { createDisplay(), - createSdCard() }; } diff --git a/Devices/cyd-2432s032c/Source/devices/SdCard.cpp b/Devices/cyd-2432s032c/Source/devices/SdCard.cpp deleted file mode 100644 index 48e5a00d3..000000000 --- a/Devices/cyd-2432s032c/Source/devices/SdCard.cpp +++ /dev/null @@ -1,33 +0,0 @@ -#include "SdCard.h" - -#include -#include -#include -#include - -constexpr auto SDCARD_SPI_HOST = SPI3_HOST; -constexpr auto SDCARD_PIN_CS = GPIO_NUM_5; - -using tt::hal::sdcard::SpiSdCardDevice; - -std::shared_ptr createSdCard() { - auto configuration = std::make_unique( - SDCARD_PIN_CS, - GPIO_NUM_NC, - GPIO_NUM_NC, - GPIO_NUM_NC, - SdCardDevice::MountBehaviour::AtBoot, - std::make_shared(), - std::vector(), - SDCARD_SPI_HOST - ); - - auto* spi_controller = device_find_by_name("spi1"); - check(spi_controller, "spi1 not found"); - - return std::make_shared( - std::move(configuration), - spi_controller - ); -} - diff --git a/Devices/cyd-2432s032c/Source/devices/SdCard.h b/Devices/cyd-2432s032c/Source/devices/SdCard.h deleted file mode 100644 index fea58cef5..000000000 --- a/Devices/cyd-2432s032c/Source/devices/SdCard.h +++ /dev/null @@ -1,8 +0,0 @@ -#pragma once - -#include - -using tt::hal::sdcard::SdCardDevice; - -std::shared_ptr createSdCard(); - diff --git a/Devices/cyd-2432s032c/cyd,2432s032c.dts b/Devices/cyd-2432s032c/cyd,2432s032c.dts index 6dc9534e4..74beaf2da 100644 --- a/Devices/cyd-2432s032c/cyd,2432s032c.dts +++ b/Devices/cyd-2432s032c/cyd,2432s032c.dts @@ -4,6 +4,8 @@ #include #include #include +#include +#include / { compatible = "root"; @@ -22,18 +24,28 @@ pin-scl = <&gpio1 32 GPIO_FLAG_NONE>; }; - display_spi: spi0 { + spi0 { compatible = "espressif,esp32-spi"; host = ; pin-mosi = <&gpio1 13 GPIO_FLAG_NONE>; pin-sclk = <&gpio1 14 GPIO_FLAG_NONE>; + + display { + compatible = "display-placeholder"; + }; }; - sdcard_spi: spi1 { + spi1 { compatible = "espressif,esp32-spi"; host = ; pin-mosi = <&gpio1 23 GPIO_FLAG_NONE>; pin-miso = <&gpio1 19 GPIO_FLAG_NONE>; pin-sclk = <&gpio1 18 GPIO_FLAG_NONE>; + + sdcard { + compatible = "espressif,esp32-sdspi"; + pin-cs = <&gpio0 5 GPIO_FLAG_NONE>; + frequency-khz = <20000>; + }; }; }; diff --git a/Devices/cyd-3248s035c/Source/Configuration.cpp b/Devices/cyd-3248s035c/Source/Configuration.cpp index 123cfab3b..9734b668f 100644 --- a/Devices/cyd-3248s035c/Source/Configuration.cpp +++ b/Devices/cyd-3248s035c/Source/Configuration.cpp @@ -1,34 +1,32 @@ -#include "devices/Display.h" -#include "devices/SdCard.h" -#include - -#include -#include - -using namespace tt::hal; - -static bool initBoot() { - //Set the RGB Led Pins to output and turn them off - ESP_ERROR_CHECK(gpio_set_direction(GPIO_NUM_4, GPIO_MODE_OUTPUT)); //Red - ESP_ERROR_CHECK(gpio_set_direction(GPIO_NUM_16, GPIO_MODE_OUTPUT)); //Green - ESP_ERROR_CHECK(gpio_set_direction(GPIO_NUM_17, GPIO_MODE_OUTPUT)); //Blue - - //0 on, 1 off... yep it's backwards. - ESP_ERROR_CHECK(gpio_set_level(GPIO_NUM_4, 1)); //Red - ESP_ERROR_CHECK(gpio_set_level(GPIO_NUM_16, 1)); //Green - ESP_ERROR_CHECK(gpio_set_level(GPIO_NUM_17, 1)); //Blue - - return driver::pwmbacklight::init(LCD_PIN_BACKLIGHT); -} - -static DeviceVector createDevices() { - return { - createDisplay(), - createSdCard() - }; -} - -extern const Configuration hardwareConfiguration = { - .initBoot = initBoot, - .createDevices = createDevices -}; +#include "devices/Display.h" +#include + +#include +#include + +using namespace tt::hal; + +static bool initBoot() { + //Set the RGB Led Pins to output and turn them off + ESP_ERROR_CHECK(gpio_set_direction(GPIO_NUM_4, GPIO_MODE_OUTPUT)); //Red + ESP_ERROR_CHECK(gpio_set_direction(GPIO_NUM_16, GPIO_MODE_OUTPUT)); //Green + ESP_ERROR_CHECK(gpio_set_direction(GPIO_NUM_17, GPIO_MODE_OUTPUT)); //Blue + + //0 on, 1 off... yep it's backwards. + ESP_ERROR_CHECK(gpio_set_level(GPIO_NUM_4, 1)); //Red + ESP_ERROR_CHECK(gpio_set_level(GPIO_NUM_16, 1)); //Green + ESP_ERROR_CHECK(gpio_set_level(GPIO_NUM_17, 1)); //Blue + + return driver::pwmbacklight::init(LCD_PIN_BACKLIGHT); +} + +static DeviceVector createDevices() { + return { + createDisplay(), + }; +} + +extern const Configuration hardwareConfiguration = { + .initBoot = initBoot, + .createDevices = createDevices +}; diff --git a/Devices/cyd-3248s035c/Source/devices/SdCard.cpp b/Devices/cyd-3248s035c/Source/devices/SdCard.cpp deleted file mode 100644 index fd4e1989f..000000000 --- a/Devices/cyd-3248s035c/Source/devices/SdCard.cpp +++ /dev/null @@ -1,31 +0,0 @@ -#include "SdCard.h" - -#include -#include - -constexpr auto SDCARD_SPI_HOST = SPI3_HOST; -constexpr auto SDCARD_PIN_CS = GPIO_NUM_5; - -using tt::hal::sdcard::SpiSdCardDevice; - -std::shared_ptr createSdCard() { - auto configuration = std::make_unique( - SDCARD_PIN_CS, - GPIO_NUM_NC, - GPIO_NUM_NC, - GPIO_NUM_NC, - SdCardDevice::MountBehaviour::AtBoot, - nullptr, - std::vector(), - SDCARD_SPI_HOST - ); - - auto* spi_controller = device_find_by_name("spi1"); - check(spi_controller, "spi1 not found"); - - return std::make_shared( - std::move(configuration), - spi_controller - ); -} - diff --git a/Devices/cyd-3248s035c/Source/devices/SdCard.h b/Devices/cyd-3248s035c/Source/devices/SdCard.h deleted file mode 100644 index 051907e1b..000000000 --- a/Devices/cyd-3248s035c/Source/devices/SdCard.h +++ /dev/null @@ -1,8 +0,0 @@ -#pragma once - -#include - -using tt::hal::sdcard::SdCardDevice; - -std::shared_ptr createSdCard(); - diff --git a/Devices/cyd-3248s035c/cyd,3248s035c.dts b/Devices/cyd-3248s035c/cyd,3248s035c.dts index 7463e6bb2..a4b8aea3f 100644 --- a/Devices/cyd-3248s035c/cyd,3248s035c.dts +++ b/Devices/cyd-3248s035c/cyd,3248s035c.dts @@ -1,58 +1,70 @@ -/dts-v1/; - -#include -#include -#include -#include -#include - -/ { - compatible = "root"; - model = "CYD 3248S035C"; - - gpio0 { - compatible = "espressif,esp32-gpio"; - gpio-count = <40>; - }; - - i2c_internal: i2c0 { - compatible = "espressif,esp32-i2c"; - port = ; - clock-frequency = <400000>; - pin-sda = <&gpio0 33 GPIO_FLAG_NONE>; - pin-scl = <&gpio0 32 GPIO_FLAG_NONE>; - }; - - // CN1 header - i2c_external: i2c1 { - compatible = "espressif,esp32-i2c"; - port = ; - clock-frequency = <400000>; - pin-sda = <&gpio0 21 GPIO_FLAG_NONE>; - pin-scl = <&gpio0 22 GPIO_FLAG_NONE>; - }; - - display_spi: spi0 { - compatible = "espressif,esp32-spi"; - host = ; - pin-mosi = <&gpio0 13 GPIO_FLAG_NONE>; - pin-sclk = <&gpio0 14 GPIO_FLAG_NONE>; - }; - - sdcard_spi: spi1 { - compatible = "espressif,esp32-spi"; - host = ; - pin-mosi = <&gpio0 23 GPIO_FLAG_NONE>; - pin-miso = <&gpio0 19 GPIO_FLAG_NONE>; - pin-sclk = <&gpio0 18 GPIO_FLAG_NONE>; - }; - - // CN1 header, JST SH 1.25, GND / IO22 / IO21 / 3.3V - uart1 { - compatible = "espressif,esp32-uart"; - status = "disabled"; - port = ; - pin-tx = <&gpio0 22 GPIO_FLAG_NONE>; - pin-rx = <&gpio0 21 GPIO_FLAG_NONE>; - }; -}; +/dts-v1/; + +#include +#include +#include +#include +#include +#include +#include + +/ { + compatible = "root"; + model = "CYD 3248S035C"; + + gpio0 { + compatible = "espressif,esp32-gpio"; + gpio-count = <40>; + }; + + i2c_internal: i2c0 { + compatible = "espressif,esp32-i2c"; + port = ; + clock-frequency = <400000>; + pin-sda = <&gpio0 33 GPIO_FLAG_NONE>; + pin-scl = <&gpio0 32 GPIO_FLAG_NONE>; + }; + + // CN1 header + i2c_external: i2c1 { + compatible = "espressif,esp32-i2c"; + port = ; + clock-frequency = <400000>; + pin-sda = <&gpio0 21 GPIO_FLAG_NONE>; + pin-scl = <&gpio0 22 GPIO_FLAG_NONE>; + }; + + spi0 { + compatible = "espressif,esp32-spi"; + host = ; + pin-mosi = <&gpio0 13 GPIO_FLAG_NONE>; + pin-sclk = <&gpio0 14 GPIO_FLAG_NONE>; + + display { + compatible = "display-placeholder"; + }; + }; + + spi1 { + compatible = "espressif,esp32-spi"; + host = ; + pin-mosi = <&gpio0 23 GPIO_FLAG_NONE>; + pin-miso = <&gpio0 19 GPIO_FLAG_NONE>; + pin-sclk = <&gpio0 18 GPIO_FLAG_NONE>; + + sdcard { + compatible = "espressif,esp32-sdspi"; + pin-cs = <&gpio0 5 GPIO_FLAG_NONE>; + frequency-khz = <20000>; + }; + }; + + // CN1 header, JST SH 1.25, GND / IO22 / IO21 / 3.3V + uart1 { + compatible = "espressif,esp32-uart"; + status = "disabled"; + port = ; + pin-tx = <&gpio0 22 GPIO_FLAG_NONE>; + pin-rx = <&gpio0 21 GPIO_FLAG_NONE>; + }; +}; diff --git a/Devices/cyd-4848s040c/Source/Configuration.cpp b/Devices/cyd-4848s040c/Source/Configuration.cpp index 6121b6af4..e8c7701d1 100644 --- a/Devices/cyd-4848s040c/Source/Configuration.cpp +++ b/Devices/cyd-4848s040c/Source/Configuration.cpp @@ -1,5 +1,4 @@ #include "devices/St7701Display.h" -#include "devices/SdCard.h" #include #include @@ -16,7 +15,6 @@ static bool initBoot() { static DeviceVector createDevices() { return { std::make_shared(), - createSdCard() }; } diff --git a/Devices/cyd-4848s040c/Source/devices/SdCard.cpp b/Devices/cyd-4848s040c/Source/devices/SdCard.cpp deleted file mode 100644 index 4ad5857e5..000000000 --- a/Devices/cyd-4848s040c/Source/devices/SdCard.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include "SdCard.h" - -#include -#include -#include - -using tt::hal::sdcard::SpiSdCardDevice; - -std::shared_ptr createSdCard() { - auto config = std::make_unique( - GPIO_NUM_42, - GPIO_NUM_NC, - GPIO_NUM_NC, - GPIO_NUM_NC, - SdCardDevice::MountBehaviour::AtBoot, - tt::lvgl::getSyncLock(), - std::vector { GPIO_NUM_39 } - ); - - auto* spi_controller = device_find_by_name("spi0"); - check(spi_controller, "spi0 not found"); - - return std::make_shared( - std::move(config), - spi_controller - ); -} - diff --git a/Devices/cyd-4848s040c/Source/devices/SdCard.h b/Devices/cyd-4848s040c/Source/devices/SdCard.h deleted file mode 100644 index 4da9f5b97..000000000 --- a/Devices/cyd-4848s040c/Source/devices/SdCard.h +++ /dev/null @@ -1,8 +0,0 @@ -#pragma once - -#include "Tactility/hal/sdcard/SdCardDevice.h" - -using tt::hal::sdcard::SdCardDevice; - -std::shared_ptr createSdCard(); - diff --git a/Devices/cyd-4848s040c/cyd,4848s040c.dts b/Devices/cyd-4848s040c/cyd,4848s040c.dts index 06dffdbd3..f9b4c5886 100644 --- a/Devices/cyd-4848s040c/cyd,4848s040c.dts +++ b/Devices/cyd-4848s040c/cyd,4848s040c.dts @@ -5,6 +5,7 @@ #include #include #include +#include / { compatible = "root"; @@ -34,5 +35,11 @@ pin-miso = <&gpio0 41 GPIO_FLAG_NONE>; pin-sclk = <&gpio0 48 GPIO_FLAG_NONE>; pin-hd = <&gpio0 42 GPIO_FLAG_NONE>; + + sdcard { + compatible = "espressif,esp32-sdspi"; + pin-cs = <&gpio0 42 GPIO_FLAG_NONE>; + frequency-khz = <20000>; + }; }; }; diff --git a/Devices/cyd-8048s043c/Source/Configuration.cpp b/Devices/cyd-8048s043c/Source/Configuration.cpp index df1706ac7..d4fc2b98c 100644 --- a/Devices/cyd-8048s043c/Source/Configuration.cpp +++ b/Devices/cyd-8048s043c/Source/Configuration.cpp @@ -1,6 +1,5 @@ #include "PwmBacklight.h" #include "devices/Display.h" -#include "devices/SdCard.h" #include #include @@ -15,7 +14,6 @@ static bool initBoot() { static DeviceVector createDevices() { return { createDisplay(), - createSdCard() }; } diff --git a/Devices/cyd-8048s043c/Source/devices/SdCard.cpp b/Devices/cyd-8048s043c/Source/devices/SdCard.cpp deleted file mode 100644 index 8b80cfc81..000000000 --- a/Devices/cyd-8048s043c/Source/devices/SdCard.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include "SdCard.h" - -#include -#include -#include - -using tt::hal::sdcard::SpiSdCardDevice; - -std::shared_ptr createSdCard() { - auto config = std::make_unique( - GPIO_NUM_10, - GPIO_NUM_NC, - GPIO_NUM_NC, - GPIO_NUM_NC, - SdCardDevice::MountBehaviour::AtBoot - ); - - auto* spi_controller = device_find_by_name("spi0"); - check(spi_controller, "spi0 not found"); - - return std::make_shared( - std::move(config), - spi_controller - ); -} diff --git a/Devices/cyd-8048s043c/Source/devices/SdCard.h b/Devices/cyd-8048s043c/Source/devices/SdCard.h deleted file mode 100644 index 5cb65a735..000000000 --- a/Devices/cyd-8048s043c/Source/devices/SdCard.h +++ /dev/null @@ -1,7 +0,0 @@ -#pragma once - -#include "Tactility/hal/sdcard/SdCardDevice.h" - -using tt::hal::sdcard::SdCardDevice; - -std::shared_ptr createSdCard(); diff --git a/Devices/cyd-8048s043c/cyd,8048s043c.dts b/Devices/cyd-8048s043c/cyd,8048s043c.dts index 9054bf0bc..222850fff 100644 --- a/Devices/cyd-8048s043c/cyd,8048s043c.dts +++ b/Devices/cyd-8048s043c/cyd,8048s043c.dts @@ -6,6 +6,7 @@ #include #include #include +#include / { compatible = "root"; @@ -42,6 +43,12 @@ pin-mosi = <&gpio0 11 GPIO_FLAG_NONE>; pin-miso = <&gpio0 13 GPIO_FLAG_NONE>; pin-sclk = <&gpio0 12 GPIO_FLAG_NONE>; + + sdcard { + compatible = "espressif,esp32-sdspi"; + pin-cs = <&gpio0 10 GPIO_FLAG_NONE>; + frequency-khz = <20000>; + }; }; uart1 { diff --git a/Devices/cyd-e32r28t/Source/Configuration.cpp b/Devices/cyd-e32r28t/Source/Configuration.cpp index 4ba1576f8..387502f4b 100644 --- a/Devices/cyd-e32r28t/Source/Configuration.cpp +++ b/Devices/cyd-e32r28t/Source/Configuration.cpp @@ -1,4 +1,3 @@ -#include "devices/SdCard.h" #include "devices/Display.h" #include @@ -12,7 +11,6 @@ static bool initBoot() { static tt::hal::DeviceVector createDevices() { return { createDisplay(), - createSdCard() }; } diff --git a/Devices/cyd-e32r28t/Source/devices/SdCard.cpp b/Devices/cyd-e32r28t/Source/devices/SdCard.cpp deleted file mode 100644 index 40cf9caaf..000000000 --- a/Devices/cyd-e32r28t/Source/devices/SdCard.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include "SdCard.h" - -#include -#include -#include - -using tt::hal::sdcard::SpiSdCardDevice; - -std::shared_ptr createSdCard() { - auto configuration = std::make_unique( - GPIO_NUM_5, - GPIO_NUM_NC, - GPIO_NUM_NC, - GPIO_NUM_NC, - SdCardDevice::MountBehaviour::AtBoot, - nullptr, - std::vector(), - SPI3_HOST - ); - - auto* spi_controller = device_find_by_name("spi1"); - check(spi_controller, "spi1 not found"); - - return std::make_shared( - std::move(configuration), - spi_controller - ); -} diff --git a/Devices/cyd-e32r28t/Source/devices/SdCard.h b/Devices/cyd-e32r28t/Source/devices/SdCard.h deleted file mode 100644 index 6f5443c78..000000000 --- a/Devices/cyd-e32r28t/Source/devices/SdCard.h +++ /dev/null @@ -1,7 +0,0 @@ -#pragma once - -#include - -using tt::hal::sdcard::SdCardDevice; - -std::shared_ptr createSdCard(); diff --git a/Devices/cyd-e32r28t/cyd,e32r28t.dts b/Devices/cyd-e32r28t/cyd,e32r28t.dts index c002e4a4e..d79230fc4 100644 --- a/Devices/cyd-e32r28t/cyd,e32r28t.dts +++ b/Devices/cyd-e32r28t/cyd,e32r28t.dts @@ -3,6 +3,8 @@ #include #include #include +#include +#include / { compatible = "root"; @@ -13,19 +15,29 @@ gpio-count = <40>; }; - display_spi: spi0 { + spi0 { compatible = "espressif,esp32-spi"; host = ; pin-mosi = <&gpio0 13 GPIO_FLAG_NONE>; pin-miso = <&gpio0 12 GPIO_FLAG_NONE>; pin-sclk = <&gpio0 14 GPIO_FLAG_NONE>; + + display { + compatible = "display-placeholder"; + }; }; - sdcard_spi: spi1 { + spi1 { compatible = "espressif,esp32-spi"; host = ; pin-mosi = <&gpio0 23 GPIO_FLAG_NONE>; pin-miso = <&gpio0 19 GPIO_FLAG_NONE>; pin-sclk = <&gpio0 18 GPIO_FLAG_NONE>; + + sdcard { + compatible = "espressif,esp32-sdspi"; + pin-cs = <&gpio0 5 GPIO_FLAG_NONE>; + frequency-khz = <20000>; + }; }; }; diff --git a/Devices/cyd-e32r32p/Source/Configuration.cpp b/Devices/cyd-e32r32p/Source/Configuration.cpp index 452896b69..77ac6fbc9 100644 --- a/Devices/cyd-e32r32p/Source/Configuration.cpp +++ b/Devices/cyd-e32r32p/Source/Configuration.cpp @@ -1,4 +1,3 @@ -#include "devices/SdCard.h" #include "devices/Display.h" #include "devices/Power.h" #include @@ -17,7 +16,6 @@ static tt::hal::DeviceVector createDevices() { return { createPower(), createDisplay(), - createSdCard() }; } diff --git a/Devices/cyd-e32r32p/Source/devices/SdCard.cpp b/Devices/cyd-e32r32p/Source/devices/SdCard.cpp deleted file mode 100644 index 58de45419..000000000 --- a/Devices/cyd-e32r32p/Source/devices/SdCard.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include "SdCard.h" - -#include -#include -#include - -using tt::hal::sdcard::SpiSdCardDevice; -using SdCardDevice = tt::hal::sdcard::SdCardDevice; - -std::shared_ptr createSdCard() { - auto configuration = std::make_unique( - SD_CS_PIN, // CS pin (IO5 on the module) - GPIO_NUM_NC, // MOSI override: leave NC to use SPI host pins - GPIO_NUM_NC, // MISO override: leave NC - GPIO_NUM_NC, // SCLK override: leave NC - SdCardDevice::MountBehaviour::AtBoot, - std::make_shared(), - std::vector(), - SD_SPI_HOST // SPI host for SD card (SPI3_HOST) - ); - - auto* spi_controller = device_find_by_name("spi1"); - check(spi_controller, "spi1 not found"); - - return std::make_shared( - std::move(configuration), - spi_controller - ); -} \ No newline at end of file diff --git a/Devices/cyd-e32r32p/Source/devices/SdCard.h b/Devices/cyd-e32r32p/Source/devices/SdCard.h deleted file mode 100644 index dc381d79c..000000000 --- a/Devices/cyd-e32r32p/Source/devices/SdCard.h +++ /dev/null @@ -1,13 +0,0 @@ -#pragma once - -#include -#include "driver/gpio.h" -#include "driver/spi_common.h" - -using tt::hal::sdcard::SdCardDevice; - -// SD card (microSD) -constexpr auto SD_CS_PIN = GPIO_NUM_5; -constexpr auto SD_SPI_HOST = SPI3_HOST; - -std::shared_ptr createSdCard(); diff --git a/Devices/cyd-e32r32p/cyd,e32r32p.dts b/Devices/cyd-e32r32p/cyd,e32r32p.dts index 61d9a1a14..da75b1a4a 100644 --- a/Devices/cyd-e32r32p/cyd,e32r32p.dts +++ b/Devices/cyd-e32r32p/cyd,e32r32p.dts @@ -4,6 +4,8 @@ #include #include #include +#include +#include / { compatible = "root"; @@ -22,19 +24,29 @@ pin-scl = <&gpio0 25 GPIO_FLAG_NONE>; }; - display_spi: spi0 { + spi0 { compatible = "espressif,esp32-spi"; host = ; pin-mosi = <&gpio0 13 GPIO_FLAG_NONE>; pin-miso = <&gpio0 12 GPIO_FLAG_NONE>; pin-sclk = <&gpio0 14 GPIO_FLAG_NONE>; + + display { + compatible = "display-placeholder"; + }; }; - sdcard_spi: spi1 { + spi1 { compatible = "espressif,esp32-spi"; host = ; pin-mosi = <&gpio0 23 GPIO_FLAG_NONE>; pin-miso = <&gpio0 19 GPIO_FLAG_NONE>; pin-sclk = <&gpio0 18 GPIO_FLAG_NONE>; + + sdcard { + compatible = "espressif,esp32-sdspi"; + pin-cs = <&gpio0 5 GPIO_FLAG_NONE>; + frequency-khz = <20000>; + }; }; }; diff --git a/Devices/elecrow-crowpanel-advance-28/Source/Configuration.cpp b/Devices/elecrow-crowpanel-advance-28/Source/Configuration.cpp index 09a0ca1f2..1cbf523da 100644 --- a/Devices/elecrow-crowpanel-advance-28/Source/Configuration.cpp +++ b/Devices/elecrow-crowpanel-advance-28/Source/Configuration.cpp @@ -1,6 +1,5 @@ #include "PwmBacklight.h" #include "devices/Display.h" -#include "devices/SdCard.h" #include #include @@ -14,7 +13,6 @@ static bool initBoot() { static DeviceVector createDevices() { return { createDisplay(), - createSdCard() }; } diff --git a/Devices/elecrow-crowpanel-advance-28/Source/devices/SdCard.cpp b/Devices/elecrow-crowpanel-advance-28/Source/devices/SdCard.cpp deleted file mode 100644 index a7308c95f..000000000 --- a/Devices/elecrow-crowpanel-advance-28/Source/devices/SdCard.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include "SdCard.h" - -#include -#include - -using tt::hal::sdcard::SpiSdCardDevice; - -constexpr auto CROWPANEL_SDCARD_PIN_CS = GPIO_NUM_7; - -std::shared_ptr createSdCard() { - auto configuration = std::make_unique( - CROWPANEL_SDCARD_PIN_CS, - GPIO_NUM_NC, - GPIO_NUM_NC, - GPIO_NUM_NC, - SdCardDevice::MountBehaviour::AtBoot, - nullptr, - std::vector(), - SPI3_HOST - ); - - auto* spi_controller = device_find_by_name("spi1"); - check(spi_controller, "spi1 not found"); - - return std::make_shared( - std::move(configuration), - spi_controller - ); -} diff --git a/Devices/elecrow-crowpanel-advance-28/Source/devices/SdCard.h b/Devices/elecrow-crowpanel-advance-28/Source/devices/SdCard.h deleted file mode 100644 index 5cb65a735..000000000 --- a/Devices/elecrow-crowpanel-advance-28/Source/devices/SdCard.h +++ /dev/null @@ -1,7 +0,0 @@ -#pragma once - -#include "Tactility/hal/sdcard/SdCardDevice.h" - -using tt::hal::sdcard::SdCardDevice; - -std::shared_ptr createSdCard(); diff --git a/Devices/elecrow-crowpanel-advance-28/elecrow,crowpanel-advance-28.dts b/Devices/elecrow-crowpanel-advance-28/elecrow,crowpanel-advance-28.dts index b0b50de79..cf8eaa1bb 100644 --- a/Devices/elecrow-crowpanel-advance-28/elecrow,crowpanel-advance-28.dts +++ b/Devices/elecrow-crowpanel-advance-28/elecrow,crowpanel-advance-28.dts @@ -6,6 +6,8 @@ #include #include #include +#include +#include / { compatible = "root"; @@ -28,19 +30,29 @@ pin-scl = <&gpio0 16 GPIO_FLAG_NONE>; }; - display_spi: spi0 { + spi0 { compatible = "espressif,esp32-spi"; host = ; pin-mosi = <&gpio0 39 GPIO_FLAG_NONE>; pin-sclk = <&gpio0 42 GPIO_FLAG_NONE>; + + display { + compatible = "display-placeholder"; + }; }; - sdcard_spi: spi1 { + spi1 { compatible = "espressif,esp32-spi"; host = ; pin-mosi = <&gpio0 6 GPIO_FLAG_NONE>; pin-miso = <&gpio0 4 GPIO_FLAG_NONE>; pin-sclk = <&gpio0 5 GPIO_FLAG_NONE>; + + sdcard { + compatible = "espressif,esp32-sdspi"; + pin-cs = <&gpio0 7 GPIO_FLAG_NONE>; + frequency-khz = <20000>; + }; }; uart0 { diff --git a/Devices/elecrow-crowpanel-advance-35/Source/Configuration.cpp b/Devices/elecrow-crowpanel-advance-35/Source/Configuration.cpp index 33bdf3347..0e8b0418d 100644 --- a/Devices/elecrow-crowpanel-advance-35/Source/Configuration.cpp +++ b/Devices/elecrow-crowpanel-advance-35/Source/Configuration.cpp @@ -1,5 +1,4 @@ #include "devices/Display.h" -#include "devices/SdCard.h" #include #include @@ -14,7 +13,6 @@ static bool initBoot() { static DeviceVector createDevices() { return { createDisplay(), - createSdCard() }; } diff --git a/Devices/elecrow-crowpanel-advance-35/Source/devices/SdCard.cpp b/Devices/elecrow-crowpanel-advance-35/Source/devices/SdCard.cpp deleted file mode 100644 index a7308c95f..000000000 --- a/Devices/elecrow-crowpanel-advance-35/Source/devices/SdCard.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include "SdCard.h" - -#include -#include - -using tt::hal::sdcard::SpiSdCardDevice; - -constexpr auto CROWPANEL_SDCARD_PIN_CS = GPIO_NUM_7; - -std::shared_ptr createSdCard() { - auto configuration = std::make_unique( - CROWPANEL_SDCARD_PIN_CS, - GPIO_NUM_NC, - GPIO_NUM_NC, - GPIO_NUM_NC, - SdCardDevice::MountBehaviour::AtBoot, - nullptr, - std::vector(), - SPI3_HOST - ); - - auto* spi_controller = device_find_by_name("spi1"); - check(spi_controller, "spi1 not found"); - - return std::make_shared( - std::move(configuration), - spi_controller - ); -} diff --git a/Devices/elecrow-crowpanel-advance-35/Source/devices/SdCard.h b/Devices/elecrow-crowpanel-advance-35/Source/devices/SdCard.h deleted file mode 100644 index 5cb65a735..000000000 --- a/Devices/elecrow-crowpanel-advance-35/Source/devices/SdCard.h +++ /dev/null @@ -1,7 +0,0 @@ -#pragma once - -#include "Tactility/hal/sdcard/SdCardDevice.h" - -using tt::hal::sdcard::SdCardDevice; - -std::shared_ptr createSdCard(); diff --git a/Devices/elecrow-crowpanel-advance-35/elecrow,crowpanel-advance-35.dts b/Devices/elecrow-crowpanel-advance-35/elecrow,crowpanel-advance-35.dts index f2abee9cf..0050ecd46 100644 --- a/Devices/elecrow-crowpanel-advance-35/elecrow,crowpanel-advance-35.dts +++ b/Devices/elecrow-crowpanel-advance-35/elecrow,crowpanel-advance-35.dts @@ -6,6 +6,8 @@ #include #include #include +#include +#include / { compatible = "root"; @@ -28,19 +30,29 @@ pin-scl = <&gpio0 16 GPIO_FLAG_NONE>; }; - display_spi: spi0 { + spi0 { compatible = "espressif,esp32-spi"; host = ; pin-mosi = <&gpio0 39 GPIO_FLAG_NONE>; pin-sclk = <&gpio0 42 GPIO_FLAG_NONE>; + + display { + compatible = "display-placeholder"; + }; }; - sdcard_spi: spi1 { + spi1 { compatible = "espressif,esp32-spi"; host = ; pin-mosi = <&gpio0 6 GPIO_FLAG_NONE>; pin-miso = <&gpio0 4 GPIO_FLAG_NONE>; pin-sclk = <&gpio0 5 GPIO_FLAG_NONE>; + + sdcard { + compatible = "espressif,esp32-sdspi"; + pin-cs = <&gpio0 7 GPIO_FLAG_NONE>; + frequency-khz = <20000>; + }; }; uart0 { diff --git a/Devices/elecrow-crowpanel-advance-50/Source/Configuration.cpp b/Devices/elecrow-crowpanel-advance-50/Source/Configuration.cpp index 76b3a79da..73b8fca3c 100644 --- a/Devices/elecrow-crowpanel-advance-50/Source/Configuration.cpp +++ b/Devices/elecrow-crowpanel-advance-50/Source/Configuration.cpp @@ -1,5 +1,4 @@ #include "devices/Display.h" -#include "devices/SdCard.h" #include #include @@ -25,7 +24,6 @@ static bool initBoot() { static DeviceVector createDevices() { return { createDisplay(), - createSdCard() }; } diff --git a/Devices/elecrow-crowpanel-advance-50/Source/devices/SdCard.cpp b/Devices/elecrow-crowpanel-advance-50/Source/devices/SdCard.cpp deleted file mode 100644 index 048f57ca3..000000000 --- a/Devices/elecrow-crowpanel-advance-50/Source/devices/SdCard.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include "SdCard.h" - -#include -#include - -using tt::hal::sdcard::SpiSdCardDevice; - -std::shared_ptr createSdCard() { - auto configuration = std::make_unique( - // 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* spi_controller = device_find_by_name("spi0"); - check(spi_controller, "spi0 not found"); - - return std::make_shared( - std::move(configuration), - spi_controller - ); -} diff --git a/Devices/elecrow-crowpanel-advance-50/Source/devices/SdCard.h b/Devices/elecrow-crowpanel-advance-50/Source/devices/SdCard.h deleted file mode 100644 index 6f5443c78..000000000 --- a/Devices/elecrow-crowpanel-advance-50/Source/devices/SdCard.h +++ /dev/null @@ -1,7 +0,0 @@ -#pragma once - -#include - -using tt::hal::sdcard::SdCardDevice; - -std::shared_ptr createSdCard(); diff --git a/Devices/elecrow-crowpanel-advance-50/elecrow,crowpanel-advance-50.dts b/Devices/elecrow-crowpanel-advance-50/elecrow,crowpanel-advance-50.dts index 17d236d36..6b27e4467 100644 --- a/Devices/elecrow-crowpanel-advance-50/elecrow,crowpanel-advance-50.dts +++ b/Devices/elecrow-crowpanel-advance-50/elecrow,crowpanel-advance-50.dts @@ -6,6 +6,7 @@ #include #include #include +#include / { compatible = "root"; @@ -28,12 +29,18 @@ pin-scl = <&gpio0 16 GPIO_FLAG_NONE>; }; - sdcard_spi: spi0 { + spi0 { compatible = "espressif,esp32-spi"; host = ; pin-mosi = <&gpio0 6 GPIO_FLAG_NONE>; pin-miso = <&gpio0 4 GPIO_FLAG_NONE>; pin-sclk = <&gpio0 5 GPIO_FLAG_NONE>; + + sdcard { + compatible = "espressif,esp32-sdspi"; + pin-cs = <&gpio0 0 GPIO_FLAG_NONE>; + frequency-khz = <20000>; + }; }; uart0 { diff --git a/Devices/elecrow-crowpanel-basic-28/Source/Configuration.cpp b/Devices/elecrow-crowpanel-basic-28/Source/Configuration.cpp index d773cbaac..59cf64f6b 100644 --- a/Devices/elecrow-crowpanel-basic-28/Source/Configuration.cpp +++ b/Devices/elecrow-crowpanel-basic-28/Source/Configuration.cpp @@ -1,6 +1,5 @@ #include "PwmBacklight.h" #include "devices/Display.h" -#include "devices/SdCard.h" #include #include @@ -14,7 +13,6 @@ static bool initBoot() { static DeviceVector createDevices() { return { createDisplay(), - createSdCard() }; } diff --git a/Devices/elecrow-crowpanel-basic-28/Source/devices/SdCard.cpp b/Devices/elecrow-crowpanel-basic-28/Source/devices/SdCard.cpp deleted file mode 100644 index 38cfc75b7..000000000 --- a/Devices/elecrow-crowpanel-basic-28/Source/devices/SdCard.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include "SdCard.h" - -#include -#include -#include - -using tt::hal::sdcard::SpiSdCardDevice; - -std::shared_ptr createSdCard() { - auto configuration = std::make_unique( - GPIO_NUM_5, - GPIO_NUM_NC, - GPIO_NUM_NC, - GPIO_NUM_NC, - SdCardDevice::MountBehaviour::AtBoot, - tt::lvgl::getSyncLock(), - std::vector(), - SPI3_HOST - ); - - auto* spi_controller = device_find_by_name("spi1"); - check(spi_controller, "spi1 not found"); - - return std::make_shared( - std::move(configuration), - spi_controller - ); -} diff --git a/Devices/elecrow-crowpanel-basic-28/Source/devices/SdCard.h b/Devices/elecrow-crowpanel-basic-28/Source/devices/SdCard.h deleted file mode 100644 index 5cb65a735..000000000 --- a/Devices/elecrow-crowpanel-basic-28/Source/devices/SdCard.h +++ /dev/null @@ -1,7 +0,0 @@ -#pragma once - -#include "Tactility/hal/sdcard/SdCardDevice.h" - -using tt::hal::sdcard::SdCardDevice; - -std::shared_ptr createSdCard(); diff --git a/Devices/elecrow-crowpanel-basic-28/elecrow,crowpanel-basic-28.dts b/Devices/elecrow-crowpanel-basic-28/elecrow,crowpanel-basic-28.dts index 377123adb..89c6e3213 100644 --- a/Devices/elecrow-crowpanel-basic-28/elecrow,crowpanel-basic-28.dts +++ b/Devices/elecrow-crowpanel-basic-28/elecrow,crowpanel-basic-28.dts @@ -5,6 +5,8 @@ #include #include #include +#include +#include / { compatible = "root"; @@ -23,21 +25,31 @@ pin-scl = <&gpio0 21 GPIO_FLAG_NONE>; }; - display_spi: spi0 { + spi0 { compatible = "espressif,esp32-spi"; host = ; pin-mosi = <&gpio0 13 GPIO_FLAG_NONE>; pin-miso = <&gpio0 12 GPIO_FLAG_NONE>; pin-sclk = <&gpio0 14 GPIO_FLAG_NONE>; max-transfer-size = <65536>; + + display { + compatible = "display-placeholder"; + }; }; - sdcard_spi: spi1 { + spi1 { compatible = "espressif,esp32-spi"; host = ; pin-mosi = <&gpio0 23 GPIO_FLAG_NONE>; pin-miso = <&gpio0 19 GPIO_FLAG_NONE>; pin-sclk = <&gpio0 18 GPIO_FLAG_NONE>; + + sdcard { + compatible = "espressif,esp32-sdspi"; + pin-cs = <&gpio0 5 GPIO_FLAG_NONE>; + frequency-khz = <20000>; + }; }; uart1 { diff --git a/Devices/elecrow-crowpanel-basic-35/Source/Configuration.cpp b/Devices/elecrow-crowpanel-basic-35/Source/Configuration.cpp index d773cbaac..59cf64f6b 100644 --- a/Devices/elecrow-crowpanel-basic-35/Source/Configuration.cpp +++ b/Devices/elecrow-crowpanel-basic-35/Source/Configuration.cpp @@ -1,6 +1,5 @@ #include "PwmBacklight.h" #include "devices/Display.h" -#include "devices/SdCard.h" #include #include @@ -14,7 +13,6 @@ static bool initBoot() { static DeviceVector createDevices() { return { createDisplay(), - createSdCard() }; } diff --git a/Devices/elecrow-crowpanel-basic-35/Source/devices/SdCard.cpp b/Devices/elecrow-crowpanel-basic-35/Source/devices/SdCard.cpp deleted file mode 100644 index 38cfc75b7..000000000 --- a/Devices/elecrow-crowpanel-basic-35/Source/devices/SdCard.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include "SdCard.h" - -#include -#include -#include - -using tt::hal::sdcard::SpiSdCardDevice; - -std::shared_ptr createSdCard() { - auto configuration = std::make_unique( - GPIO_NUM_5, - GPIO_NUM_NC, - GPIO_NUM_NC, - GPIO_NUM_NC, - SdCardDevice::MountBehaviour::AtBoot, - tt::lvgl::getSyncLock(), - std::vector(), - SPI3_HOST - ); - - auto* spi_controller = device_find_by_name("spi1"); - check(spi_controller, "spi1 not found"); - - return std::make_shared( - std::move(configuration), - spi_controller - ); -} diff --git a/Devices/elecrow-crowpanel-basic-35/Source/devices/SdCard.h b/Devices/elecrow-crowpanel-basic-35/Source/devices/SdCard.h deleted file mode 100644 index 5cb65a735..000000000 --- a/Devices/elecrow-crowpanel-basic-35/Source/devices/SdCard.h +++ /dev/null @@ -1,7 +0,0 @@ -#pragma once - -#include "Tactility/hal/sdcard/SdCardDevice.h" - -using tt::hal::sdcard::SdCardDevice; - -std::shared_ptr createSdCard(); diff --git a/Devices/elecrow-crowpanel-basic-35/elecrow,crowpanel-basic-35.dts b/Devices/elecrow-crowpanel-basic-35/elecrow,crowpanel-basic-35.dts index e812efb02..8226b5e6d 100644 --- a/Devices/elecrow-crowpanel-basic-35/elecrow,crowpanel-basic-35.dts +++ b/Devices/elecrow-crowpanel-basic-35/elecrow,crowpanel-basic-35.dts @@ -5,6 +5,8 @@ #include #include #include +#include +#include / { compatible = "root"; @@ -23,21 +25,31 @@ pin-scl = <&gpio0 21 GPIO_FLAG_NONE>; }; - display_spi: spi0 { + spi0 { compatible = "espressif,esp32-spi"; host = ; pin-mosi = <&gpio0 13 GPIO_FLAG_NONE>; pin-miso = <&gpio0 33 GPIO_FLAG_NONE>; pin-sclk = <&gpio0 14 GPIO_FLAG_NONE>; max-transfer-size = <65536>; + + display { + compatible = "display-placeholder"; + }; }; - sdcard_spi: spi1 { + spi1 { compatible = "espressif,esp32-spi"; host = ; pin-mosi = <&gpio0 23 GPIO_FLAG_NONE>; pin-miso = <&gpio0 19 GPIO_FLAG_NONE>; pin-sclk = <&gpio0 18 GPIO_FLAG_NONE>; + + sdcard { + compatible = "espressif,esp32-sdspi"; + pin-cs = <&gpio0 5 GPIO_FLAG_NONE>; + frequency-khz = <20000>; + }; }; uart1 { diff --git a/Devices/elecrow-crowpanel-basic-50/Source/Configuration.cpp b/Devices/elecrow-crowpanel-basic-50/Source/Configuration.cpp index 9df5ad4af..7fbe23221 100644 --- a/Devices/elecrow-crowpanel-basic-50/Source/Configuration.cpp +++ b/Devices/elecrow-crowpanel-basic-50/Source/Configuration.cpp @@ -1,5 +1,4 @@ #include "devices/Display.h" -#include "devices/SdCard.h" #include #include @@ -15,7 +14,6 @@ static bool initBoot() { static DeviceVector createDevices() { return { createDisplay(), - createSdCard(), }; } diff --git a/Devices/elecrow-crowpanel-basic-50/Source/devices/SdCard.cpp b/Devices/elecrow-crowpanel-basic-50/Source/devices/SdCard.cpp deleted file mode 100644 index dbf0f03f3..000000000 --- a/Devices/elecrow-crowpanel-basic-50/Source/devices/SdCard.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include "SdCard.h" - -#include -#include - -using tt::hal::sdcard::SpiSdCardDevice; - -std::shared_ptr createSdCard() { - auto configuration = std::make_unique( - GPIO_NUM_10, - GPIO_NUM_NC, - GPIO_NUM_NC, - GPIO_NUM_NC, - SdCardDevice::MountBehaviour::AtBoot - ); - - auto* spi_controller = device_find_by_name("spi0"); - check(spi_controller, "spi0 not found"); - - return std::make_shared( - std::move(configuration), - spi_controller - ); -} diff --git a/Devices/elecrow-crowpanel-basic-50/Source/devices/SdCard.h b/Devices/elecrow-crowpanel-basic-50/Source/devices/SdCard.h deleted file mode 100644 index 6f5443c78..000000000 --- a/Devices/elecrow-crowpanel-basic-50/Source/devices/SdCard.h +++ /dev/null @@ -1,7 +0,0 @@ -#pragma once - -#include - -using tt::hal::sdcard::SdCardDevice; - -std::shared_ptr createSdCard(); diff --git a/Devices/elecrow-crowpanel-basic-50/elecrow,crowpanel-basic-50.dts b/Devices/elecrow-crowpanel-basic-50/elecrow,crowpanel-basic-50.dts index e35ecd568..b5dae9648 100644 --- a/Devices/elecrow-crowpanel-basic-50/elecrow,crowpanel-basic-50.dts +++ b/Devices/elecrow-crowpanel-basic-50/elecrow,crowpanel-basic-50.dts @@ -6,6 +6,7 @@ #include #include #include +#include / { compatible = "root"; @@ -28,12 +29,18 @@ pin-scl = <&gpio0 20 GPIO_FLAG_NONE>; }; - sdcard_spi: spi0 { + spi0 { compatible = "espressif,esp32-spi"; host = ; pin-mosi = <&gpio0 11 GPIO_FLAG_NONE>; pin-miso = <&gpio0 13 GPIO_FLAG_NONE>; pin-sclk = <&gpio0 12 GPIO_FLAG_NONE>; + + sdcard { + compatible = "espressif,esp32-sdspi"; + pin-cs = <&gpio0 10 GPIO_FLAG_NONE>; + frequency-khz = <20000>; + }; }; uart0 { diff --git a/Devices/guition-jc1060p470ciwy/Source/Configuration.cpp b/Devices/guition-jc1060p470ciwy/Source/Configuration.cpp index e43b7a87e..ab3a805f2 100644 --- a/Devices/guition-jc1060p470ciwy/Source/Configuration.cpp +++ b/Devices/guition-jc1060p470ciwy/Source/Configuration.cpp @@ -1,6 +1,5 @@ #include "devices/Display.h" #include "devices/Power.h" -#include "devices/SdCard.h" #include @@ -9,7 +8,6 @@ using namespace tt::hal; static DeviceVector createDevices() { return { createDisplay(), - createSdCard(), createPower() }; } diff --git a/Devices/guition-jc1060p470ciwy/Source/devices/SdCard.cpp b/Devices/guition-jc1060p470ciwy/Source/devices/SdCard.cpp deleted file mode 100644 index 9bee001c8..000000000 --- a/Devices/guition-jc1060p470ciwy/Source/devices/SdCard.cpp +++ /dev/null @@ -1,128 +0,0 @@ -#include "SdCard.h" - -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -using tt::hal::sdcard::SdCardDevice; - -static const auto LOGGER = tt::Logger("JcSdCard"); - -// ESP32-P4 Slot 0 uses IO MUX (fixed pins, not manually configurable) -// CLK=43, CMD=44, D0=39, D1=40, D2=41, D3=42 (defined automatically by hardware) - -// TODO: Migrate to "espressif,esp32-sdmmc" driver (needs LDO code porting) -class SdCardDeviceImpl final : public SdCardDevice { - - class NoLock final : public tt::Lock { - bool lock(TickType_t timeout) const override { return true; } - void unlock() const override { /* NO-OP */ } - }; - - std::shared_ptr lock = std::make_shared(); - sdmmc_card_t* card = nullptr; - bool mounted = false; - std::string mountPath; - -public: - SdCardDeviceImpl() : SdCardDevice(MountBehaviour::AtBoot) {} - ~SdCardDeviceImpl() override { - if (mounted) { - unmount(); - } - } - - std::string getName() const override { return "SD Card"; } - std::string getDescription() const override { return "SD card via SDMMC host"; } - - bool mount(const std::string& newMountPath) override { - if (mounted) { - return true; - } - - esp_vfs_fat_sdmmc_mount_config_t mount_config = { - .format_if_mount_failed = false, - .max_files = 5, - .allocation_unit_size = 64 * 1024, - .disk_status_check_enable = false, - .use_one_fat = false, - }; - - sdmmc_host_t host = SDMMC_HOST_DEFAULT(); - host.slot = SDMMC_HOST_SLOT_0; - host.max_freq_khz = SDMMC_FREQ_DEFAULT; // 20MHz - more stable for initialization - host.flags = SDMMC_HOST_FLAG_4BIT; // Force 4-bit mode - // Configure LDO power supply for SD card (critical on ESP32-P4) - esp_ldo_channel_handle_t ldo_handle = nullptr; - esp_ldo_channel_config_t ldo_config = { - .chan_id = 4, // LDO channel 4 for SD power - .voltage_mv = 3300, // 3.3V - .flags { - .adjustable = 0, - .owned_by_hw = 0, - .bypass = 0 - } - }; - - esp_err_t ldo_ret = esp_ldo_acquire_channel(&ldo_config, &ldo_handle); - if (ldo_ret != ESP_OK) { - LOGGER.warn("Failed to acquire LDO for SD power: {} (continuing anyway)", esp_err_to_name(ldo_ret)); - } - - // Slot 0 uses IO MUX - pins are fixed and not specified - sdmmc_slot_config_t slot_config = SDMMC_SLOT_CONFIG_DEFAULT(); - slot_config.width = 4; - slot_config.cd = SDMMC_SLOT_NO_CD; // No card detect - slot_config.wp = SDMMC_SLOT_NO_WP; // No write protect - slot_config.flags = 0; - - esp_err_t ret = esp_vfs_fat_sdmmc_mount(newMountPath.c_str(), &host, &slot_config, &mount_config, &card); - if (ret != ESP_OK) { - LOGGER.error("Failed to mount SD card: {}", esp_err_to_name(ret)); - card = nullptr; - return false; - } - - mountPath = newMountPath; - mounted = true; - LOGGER.info("SD card mounted at {}", mountPath); - return true; - } - - bool unmount() override { - if (!mounted) { - return true; - } - - esp_err_t ret = esp_vfs_fat_sdcard_unmount(mountPath.c_str(), card); - if (ret != ESP_OK) { - LOGGER.error("Failed to unmount SD card: {}", esp_err_to_name(ret)); - return false; - } - card = nullptr; - mounted = false; - LOGGER.info("SD card unmounted"); - return true; - } - - std::string getMountPath() const override { - return mountPath; - } - - std::shared_ptr getLock() const override { return lock; } - - State getState(TickType_t /*timeout*/) const override { - return mounted ? State::Mounted : State::Unmounted; - } -}; - -std::shared_ptr createSdCard() { - return std::make_shared(); -} diff --git a/Devices/guition-jc1060p470ciwy/Source/devices/SdCard.h b/Devices/guition-jc1060p470ciwy/Source/devices/SdCard.h deleted file mode 100644 index 3e170a56b..000000000 --- a/Devices/guition-jc1060p470ciwy/Source/devices/SdCard.h +++ /dev/null @@ -1,6 +0,0 @@ -#pragma once - -#include - -// Create SD card device for jc1060p470ciwy using SDMMC slot 0 (4-bit) -std::shared_ptr createSdCard(); diff --git a/Devices/guition-jc1060p470ciwy/guition,jc1060p470ciwy.dts b/Devices/guition-jc1060p470ciwy/guition,jc1060p470ciwy.dts index e328c0ee7..c84754d3f 100644 --- a/Devices/guition-jc1060p470ciwy/guition,jc1060p470ciwy.dts +++ b/Devices/guition-jc1060p470ciwy/guition,jc1060p470ciwy.dts @@ -5,6 +5,7 @@ #include #include #include +#include /** * For future reference: @@ -44,4 +45,16 @@ pin-data-in = <&gpio0 48 GPIO_FLAG_NONE>; pin-mclk = <&gpio0 13 GPIO_FLAG_NONE>; }; + + sdcard { + compatible = "espressif,esp32-sdmmc"; + pin-clk = <&gpio0 43 GPIO_FLAG_NONE>; + pin-cmd = <&gpio0 44 GPIO_FLAG_NONE>; + pin-d0 = <&gpio0 39 GPIO_FLAG_NONE>; + pin-d1 = <&gpio0 40 GPIO_FLAG_NONE>; + pin-d2 = <&gpio0 41 GPIO_FLAG_NONE>; + pin-d3 = <&gpio0 42 GPIO_FLAG_NONE>; + bus-width = <4>; + on-chip-ldo-chan = <4>; + }; }; diff --git a/Devices/guition-jc2432w328c/Source/Configuration.cpp b/Devices/guition-jc2432w328c/Source/Configuration.cpp index ee79f6c67..9734b668f 100644 --- a/Devices/guition-jc2432w328c/Source/Configuration.cpp +++ b/Devices/guition-jc2432w328c/Source/Configuration.cpp @@ -1,5 +1,4 @@ #include "devices/Display.h" -#include "devices/SdCard.h" #include #include @@ -24,7 +23,6 @@ static bool initBoot() { static DeviceVector createDevices() { return { createDisplay(), - createSdCard() }; } diff --git a/Devices/guition-jc2432w328c/Source/devices/SdCard.cpp b/Devices/guition-jc2432w328c/Source/devices/SdCard.cpp deleted file mode 100644 index 45238df8c..000000000 --- a/Devices/guition-jc2432w328c/Source/devices/SdCard.cpp +++ /dev/null @@ -1,31 +0,0 @@ -#include "SdCard.h" - -#include -#include - -constexpr auto SDCARD_SPI_HOST = SPI3_HOST; -constexpr auto SDCARD_PIN_CS = GPIO_NUM_5; - -using tt::hal::sdcard::SpiSdCardDevice; - -std::shared_ptr createSdCard() { - auto configuration = std::make_unique( - SDCARD_PIN_CS, - GPIO_NUM_NC, - GPIO_NUM_NC, - GPIO_NUM_NC, - SdCardDevice::MountBehaviour::AtBoot, - nullptr, - std::vector(), - SDCARD_SPI_HOST - ); - - auto* spi_controller = device_find_by_name("spi1"); - check(spi_controller, "spi1 not found"); - - return std::make_shared( - std::move(configuration), - spi_controller - ); -} - diff --git a/Devices/guition-jc2432w328c/Source/devices/SdCard.h b/Devices/guition-jc2432w328c/Source/devices/SdCard.h deleted file mode 100644 index fea58cef5..000000000 --- a/Devices/guition-jc2432w328c/Source/devices/SdCard.h +++ /dev/null @@ -1,8 +0,0 @@ -#pragma once - -#include - -using tt::hal::sdcard::SdCardDevice; - -std::shared_ptr createSdCard(); - diff --git a/Devices/guition-jc2432w328c/guition,jc2432w328c.dts b/Devices/guition-jc2432w328c/guition,jc2432w328c.dts index adfc64c8e..78c3570ba 100644 --- a/Devices/guition-jc2432w328c/guition,jc2432w328c.dts +++ b/Devices/guition-jc2432w328c/guition,jc2432w328c.dts @@ -5,6 +5,8 @@ #include #include #include +#include +#include / { compatible = "root"; @@ -32,19 +34,29 @@ pin-scl = <&gpio0 22 GPIO_FLAG_NONE>; }; - display_spi: spi0 { + spi0 { compatible = "espressif,esp32-spi"; host = ; pin-mosi = <&gpio0 13 GPIO_FLAG_NONE>; pin-sclk = <&gpio0 14 GPIO_FLAG_NONE>; + + display { + compatible = "display-placeholder"; + }; }; - sdcard_spi: spi1 { + spi1 { compatible = "espressif,esp32-spi"; host = ; pin-mosi = <&gpio0 23 GPIO_FLAG_NONE>; pin-miso = <&gpio0 19 GPIO_FLAG_NONE>; pin-sclk = <&gpio0 18 GPIO_FLAG_NONE>; + + sdcard { + compatible = "espressif,esp32-sdspi"; + pin-cs = <&gpio0 5 GPIO_FLAG_NONE>; + frequency-khz = <20000>; + }; }; // CN1 header, JST SH 1.25, GND / IO22 / IO21 / 3.3V diff --git a/Devices/guition-jc3248w535c/Source/Configuration.cpp b/Devices/guition-jc3248w535c/Source/Configuration.cpp index 0ceef45ae..f35f8e659 100644 --- a/Devices/guition-jc3248w535c/Source/Configuration.cpp +++ b/Devices/guition-jc3248w535c/Source/Configuration.cpp @@ -1,5 +1,4 @@ #include "devices/Display.h" -#include "devices/SdCard.h" #include #include @@ -10,7 +9,6 @@ using namespace tt::hal; static DeviceVector createDevices() { return { createDisplay(), - createSdCard() }; } diff --git a/Devices/guition-jc3248w535c/Source/devices/SdCard.cpp b/Devices/guition-jc3248w535c/Source/devices/SdCard.cpp deleted file mode 100644 index e4b2e2345..000000000 --- a/Devices/guition-jc3248w535c/Source/devices/SdCard.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include "SdCard.h" - -#include -#include - -constexpr auto SDCARD_SPI_HOST = SPI3_HOST; -constexpr auto SDCARD_PIN_CS = GPIO_NUM_10; - -using tt::hal::sdcard::SpiSdCardDevice; - -std::shared_ptr createSdCard() { - auto configuration = std::make_unique( - SDCARD_PIN_CS, - GPIO_NUM_NC, - GPIO_NUM_NC, - GPIO_NUM_NC, - SdCardDevice::MountBehaviour::AtBoot, - nullptr, - std::vector(), - SDCARD_SPI_HOST - ); - - auto* spi_controller = device_find_by_name("spi1"); - check(spi_controller, "spi1 not found"); - - return std::make_shared( - std::move(configuration), - spi_controller - ); -} diff --git a/Devices/guition-jc3248w535c/Source/devices/SdCard.h b/Devices/guition-jc3248w535c/Source/devices/SdCard.h deleted file mode 100644 index 6f5443c78..000000000 --- a/Devices/guition-jc3248w535c/Source/devices/SdCard.h +++ /dev/null @@ -1,7 +0,0 @@ -#pragma once - -#include - -using tt::hal::sdcard::SdCardDevice; - -std::shared_ptr createSdCard(); diff --git a/Devices/guition-jc3248w535c/guition,jc3248w535c.dts b/Devices/guition-jc3248w535c/guition,jc3248w535c.dts index 4749ddc35..f48fa1814 100644 --- a/Devices/guition-jc3248w535c/guition,jc3248w535c.dts +++ b/Devices/guition-jc3248w535c/guition,jc3248w535c.dts @@ -7,6 +7,7 @@ #include #include #include +#include / { compatible = "root"; @@ -45,7 +46,7 @@ pin-data-out = <&gpio0 41 GPIO_FLAG_NONE>; }; - display_spi: spi0 { + spi0 { compatible = "espressif,esp32-spi"; host = ; pin-mosi = <&gpio0 21 GPIO_FLAG_NONE>; @@ -55,12 +56,18 @@ pin-hd = <&gpio0 39 GPIO_FLAG_NONE>; }; - sdcard_spi: spi1 { + spi1 { compatible = "espressif,esp32-spi"; host = ; pin-mosi = <&gpio0 11 GPIO_FLAG_NONE>; pin-miso = <&gpio0 13 GPIO_FLAG_NONE>; pin-sclk = <&gpio0 12 GPIO_FLAG_NONE>; + + sdcard { + compatible = "espressif,esp32-sdspi"; + pin-cs = <&gpio0 10 GPIO_FLAG_NONE>; + frequency-khz = <20000>; + }; }; // P1 header diff --git a/Devices/guition-jc8048w550c/Source/Configuration.cpp b/Devices/guition-jc8048w550c/Source/Configuration.cpp index 174ca14fa..f19ffaf92 100644 --- a/Devices/guition-jc8048w550c/Source/Configuration.cpp +++ b/Devices/guition-jc8048w550c/Source/Configuration.cpp @@ -1,6 +1,5 @@ #include "PwmBacklight.h" #include "devices/Display.h" -#include "devices/SdCard.h" #include #include @@ -14,7 +13,6 @@ static bool initBoot() { static DeviceVector createDevices() { return { createDisplay(), - createSdCard() }; } diff --git a/Devices/guition-jc8048w550c/Source/devices/SdCard.cpp b/Devices/guition-jc8048w550c/Source/devices/SdCard.cpp deleted file mode 100644 index 1b44c476c..000000000 --- a/Devices/guition-jc8048w550c/Source/devices/SdCard.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include "SdCard.h" - -#include -#include - -using tt::hal::sdcard::SpiSdCardDevice; - -std::shared_ptr createSdCard() { - auto config = std::make_unique( - GPIO_NUM_10, - GPIO_NUM_NC, - GPIO_NUM_NC, - GPIO_NUM_NC, - SdCardDevice::MountBehaviour::AtBoot - ); - - auto* spi_controller = device_find_by_name("spi0"); - check(spi_controller, "spi0 not found"); - - return std::make_shared( - std::move(config), - spi_controller - ); -} diff --git a/Devices/guition-jc8048w550c/Source/devices/SdCard.h b/Devices/guition-jc8048w550c/Source/devices/SdCard.h deleted file mode 100644 index 6f5443c78..000000000 --- a/Devices/guition-jc8048w550c/Source/devices/SdCard.h +++ /dev/null @@ -1,7 +0,0 @@ -#pragma once - -#include - -using tt::hal::sdcard::SdCardDevice; - -std::shared_ptr createSdCard(); diff --git a/Devices/guition-jc8048w550c/guition,jc8048w550c.dts b/Devices/guition-jc8048w550c/guition,jc8048w550c.dts index 97ac59477..6000feaea 100644 --- a/Devices/guition-jc8048w550c/guition,jc8048w550c.dts +++ b/Devices/guition-jc8048w550c/guition,jc8048w550c.dts @@ -7,6 +7,7 @@ #include #include #include +#include / { compatible = "root"; @@ -52,6 +53,12 @@ pin-mosi = <&gpio0 11 GPIO_FLAG_NONE>; pin-miso = <&gpio0 13 GPIO_FLAG_NONE>; pin-sclk = <&gpio0 12 GPIO_FLAG_NONE>; + + sdcard { + compatible = "espressif,esp32-sdspi"; + pin-cs = <&gpio0 10 GPIO_FLAG_NONE>; + frequency-khz = <20000>; + }; }; uart1 { diff --git a/Devices/lilygo-tdeck/Source/Configuration.cpp b/Devices/lilygo-tdeck/Source/Configuration.cpp index 4f620aced..3eca6c8e9 100644 --- a/Devices/lilygo-tdeck/Source/Configuration.cpp +++ b/Devices/lilygo-tdeck/Source/Configuration.cpp @@ -1,7 +1,6 @@ #include "devices/Display.h" #include "devices/KeyboardBacklight.h" #include "devices/Power.h" -#include "devices/Sdcard.h" #include "devices/TdeckKeyboard.h" #include "devices/TrackballDevice.h" @@ -23,7 +22,6 @@ static std::vector> createDevices() { std::make_shared(i2c_internal), std::make_shared(), std::make_shared(), - createSdCard() }; } diff --git a/Devices/lilygo-tdeck/Source/devices/Sdcard.cpp b/Devices/lilygo-tdeck/Source/devices/Sdcard.cpp deleted file mode 100644 index 6b926d794..000000000 --- a/Devices/lilygo-tdeck/Source/devices/Sdcard.cpp +++ /dev/null @@ -1,34 +0,0 @@ -#include "Sdcard.h" - -#include - -#include -#include - -using tt::hal::sdcard::SpiSdCardDevice; - -constexpr auto TDECK_SDCARD_PIN_CS = GPIO_NUM_39; -constexpr auto TDECK_LCD_PIN_CS = GPIO_NUM_12; -constexpr auto TDECK_RADIO_PIN_CS = GPIO_NUM_9; - -std::shared_ptr createSdCard() { - auto configuration = std::make_unique( - TDECK_SDCARD_PIN_CS, - GPIO_NUM_NC, - GPIO_NUM_NC, - GPIO_NUM_NC, - SdCardDevice::MountBehaviour::AtBoot, - tt::lvgl::getSyncLock(), - std::vector { - TDECK_RADIO_PIN_CS, - TDECK_LCD_PIN_CS - } - ); - - ::Device* spiController = device_find_by_name("spi0"); - check(spiController != nullptr, "spi0 not found"); - return std::make_shared( - std::move(configuration), - spiController - ); -} diff --git a/Devices/lilygo-tdeck/Source/devices/Sdcard.h b/Devices/lilygo-tdeck/Source/devices/Sdcard.h deleted file mode 100644 index 5cb65a735..000000000 --- a/Devices/lilygo-tdeck/Source/devices/Sdcard.h +++ /dev/null @@ -1,7 +0,0 @@ -#pragma once - -#include "Tactility/hal/sdcard/SdCardDevice.h" - -using tt::hal::sdcard::SdCardDevice; - -std::shared_ptr createSdCard(); diff --git a/Devices/lilygo-tdeck/lilygo,tdeck.dts b/Devices/lilygo-tdeck/lilygo,tdeck.dts index a60e6ef77..ad6bba49a 100644 --- a/Devices/lilygo-tdeck/lilygo,tdeck.dts +++ b/Devices/lilygo-tdeck/lilygo,tdeck.dts @@ -8,6 +8,8 @@ #include #include #include +#include +#include // Reference: https://wiki.lilygo.cc/get_started/en/Wearable/T-Deck-Plus/T-Deck-Plus.html#Pin-Overview / { @@ -45,6 +47,16 @@ pin-mosi = <&gpio0 41 GPIO_FLAG_NONE>; pin-miso = <&gpio0 38 GPIO_FLAG_NONE>; pin-sclk = <&gpio0 40 GPIO_FLAG_NONE>; + + sdcard { + compatible = "espressif,esp32-sdspi"; + pin-cs = <&gpio0 39 GPIO_FLAG_NONE>; + frequency-khz = <20000>; + }; + + display { + compatible = "display-placeholder"; + }; }; uart0 { diff --git a/Devices/lilygo-tdisplay/lilygo,tdisplay.dts b/Devices/lilygo-tdisplay/lilygo,tdisplay.dts index ecf6ca866..750ed3ec0 100644 --- a/Devices/lilygo-tdisplay/lilygo,tdisplay.dts +++ b/Devices/lilygo-tdisplay/lilygo,tdisplay.dts @@ -4,6 +4,7 @@ #include #include #include +#include / { compatible = "root"; @@ -19,5 +20,9 @@ host = ; pin-mosi = <&gpio0 19 GPIO_FLAG_NONE>; pin-sclk = <&gpio0 18 GPIO_FLAG_NONE>; + + display { + compatible = "display-placeholder"; + }; }; }; diff --git a/Devices/lilygo-tdongle-s3/lilygo,tdongle-s3.dts b/Devices/lilygo-tdongle-s3/lilygo,tdongle-s3.dts index 616fbb706..2c26cbb3e 100644 --- a/Devices/lilygo-tdongle-s3/lilygo,tdongle-s3.dts +++ b/Devices/lilygo-tdongle-s3/lilygo,tdongle-s3.dts @@ -7,6 +7,7 @@ #include #include #include +#include / { compatible = "root"; @@ -34,6 +35,10 @@ host = ; pin-mosi = <&gpio0 3 GPIO_FLAG_NONE>; pin-sclk = <&gpio0 5 GPIO_FLAG_NONE>; + + display { + compatible = "display-placeholder"; + }; }; sdmmc0 { diff --git a/Devices/lilygo-tlora-pager/Source/Configuration.cpp b/Devices/lilygo-tlora-pager/Source/Configuration.cpp index 363e0cc16..13bd752e2 100644 --- a/Devices/lilygo-tlora-pager/Source/Configuration.cpp +++ b/Devices/lilygo-tlora-pager/Source/Configuration.cpp @@ -1,5 +1,4 @@ #include "devices/Display.h" -#include "devices/SdCard.h" #include "devices/TpagerEncoder.h" #include "devices/TpagerKeyboard.h" #include "devices/TpagerPower.h" diff --git a/Devices/lilygo-tlora-pager/Source/devices/SdCard.cpp b/Devices/lilygo-tlora-pager/Source/devices/SdCard.cpp deleted file mode 100644 index eb8f48e9c..000000000 --- a/Devices/lilygo-tlora-pager/Source/devices/SdCard.cpp +++ /dev/null @@ -1,36 +0,0 @@ -#include "SdCard.h" - -#include -#include -#include - -using tt::hal::sdcard::SpiSdCardDevice; - -constexpr auto TPAGER_SDCARD_PIN_CS = GPIO_NUM_21; -constexpr auto TPAGER_LCD_PIN_CS = GPIO_NUM_38; -constexpr auto TPAGER_RADIO_PIN_CS = GPIO_NUM_36; -constexpr auto TPAGER_NFC_PIN_CS = GPIO_NUM_39; - -std::shared_ptr createTpagerSdCard() { - auto configuration = std::make_unique( - TPAGER_SDCARD_PIN_CS, - GPIO_NUM_NC, - GPIO_NUM_NC, - GPIO_NUM_NC, - SdCardDevice::MountBehaviour::AtBoot, - tt::lvgl::getSyncLock(), - std::vector { - TPAGER_RADIO_PIN_CS, - TPAGER_LCD_PIN_CS, - TPAGER_NFC_PIN_CS - } - ); - - auto* spi_controller = device_find_by_name("spi0"); - check(spi_controller, "spi0 not found"); - - return std::make_shared( - std::move(configuration), - spi_controller - ); -} diff --git a/Devices/lilygo-tlora-pager/Source/devices/SdCard.h b/Devices/lilygo-tlora-pager/Source/devices/SdCard.h deleted file mode 100644 index 7b830f875..000000000 --- a/Devices/lilygo-tlora-pager/Source/devices/SdCard.h +++ /dev/null @@ -1,8 +0,0 @@ -#pragma once - -#include -#include - -using tt::hal::sdcard::SdCardDevice; - -std::shared_ptr createTpagerSdCard(); diff --git a/Devices/lilygo-tlora-pager/lilygo,tlora-pager.dts b/Devices/lilygo-tlora-pager/lilygo,tlora-pager.dts index 45b12562e..6697036ce 100644 --- a/Devices/lilygo-tlora-pager/lilygo,tlora-pager.dts +++ b/Devices/lilygo-tlora-pager/lilygo,tlora-pager.dts @@ -7,6 +7,8 @@ #include #include #include +#include +#include // Reference: https://wiki.lilygo.cc/get_started/en/LoRa_GPS/T-LoraPager/T-LoraPager.html#Pin-Overview / { @@ -36,6 +38,16 @@ pin-mosi = <&gpio0 34 GPIO_FLAG_NONE>; pin-miso = <&gpio0 33 GPIO_FLAG_NONE>; pin-sclk = <&gpio0 35 GPIO_FLAG_NONE>; + + sdcard { + compatible = "espressif,esp32-sdspi"; + pin-cs = <&gpio0 21 GPIO_FLAG_NONE>; + frequency-khz = <20000>; + }; + + display { + compatible = "display-placeholder"; + }; }; // ES8311 diff --git a/Devices/m5stack-cardputer-adv/Source/Configuration.cpp b/Devices/m5stack-cardputer-adv/Source/Configuration.cpp index bb8ca682d..41906807f 100644 --- a/Devices/m5stack-cardputer-adv/Source/Configuration.cpp +++ b/Devices/m5stack-cardputer-adv/Source/Configuration.cpp @@ -1,5 +1,4 @@ #include "devices/Display.h" -#include "devices/SdCard.h" #include "devices/CardputerKeyboard.h" #include "devices/CardputerPower.h" #include @@ -19,7 +18,6 @@ static bool initBoot() { static DeviceVector createDevices() { auto tca8418 = std::make_shared(device_find_by_name("i2c_internal")); return { - createSdCard(), createDisplay(), tca8418, std::make_shared(tca8418), diff --git a/Devices/m5stack-cardputer-adv/Source/devices/SdCard.cpp b/Devices/m5stack-cardputer-adv/Source/devices/SdCard.cpp deleted file mode 100644 index abc1703e4..000000000 --- a/Devices/m5stack-cardputer-adv/Source/devices/SdCard.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include "SdCard.h" - -#include -#include - -constexpr auto SDCARD_PIN_CS = GPIO_NUM_12; -constexpr auto EXPANSION_HEADER_PIN_CS = GPIO_NUM_5; - -using tt::hal::sdcard::SpiSdCardDevice; - -std::shared_ptr createSdCard() { - auto configuration = std::make_unique( - SDCARD_PIN_CS, - GPIO_NUM_NC, - GPIO_NUM_NC, - GPIO_NUM_NC, - SdCardDevice::MountBehaviour::AtBoot, - nullptr, - std::vector { EXPANSION_HEADER_PIN_CS }, - SPI3_HOST - ); - - auto* spi_controller = device_find_by_name("spi1"); - check(spi_controller, "spi1 not found"); - - return std::make_shared( - std::move(configuration), - spi_controller - ); -} diff --git a/Devices/m5stack-cardputer-adv/Source/devices/SdCard.h b/Devices/m5stack-cardputer-adv/Source/devices/SdCard.h deleted file mode 100644 index 98b222fa6..000000000 --- a/Devices/m5stack-cardputer-adv/Source/devices/SdCard.h +++ /dev/null @@ -1,8 +0,0 @@ -#pragma once - -#include -#include - -using tt::hal::sdcard::SdCardDevice; - -std::shared_ptr createSdCard(); diff --git a/Devices/m5stack-cardputer-adv/m5stack,cardputer-adv.dts b/Devices/m5stack-cardputer-adv/m5stack,cardputer-adv.dts index fefd953fc..155940187 100644 --- a/Devices/m5stack-cardputer-adv/m5stack,cardputer-adv.dts +++ b/Devices/m5stack-cardputer-adv/m5stack,cardputer-adv.dts @@ -9,6 +9,8 @@ #include #include #include +#include +#include // Reference: https://docs.m5stack.com/en/core/Cardputer-Adv / { @@ -47,19 +49,29 @@ i2cClockFrequency = <400000>; }; - display_spi: spi0 { + spi0 { compatible = "espressif,esp32-spi"; host = ; pin-mosi = <&gpio0 35 GPIO_FLAG_NONE>; pin-sclk = <&gpio0 36 GPIO_FLAG_NONE>; + + display { + compatible = "display-placeholder"; + }; }; - sdcard_spi: spi1 { + spi1 { compatible = "espressif,esp32-spi"; host = ; pin-mosi = <&gpio0 14 GPIO_FLAG_NONE>; pin-miso = <&gpio0 39 GPIO_FLAG_NONE>; pin-sclk = <&gpio0 40 GPIO_FLAG_NONE>; + + sdcard { + compatible = "espressif,esp32-sdspi"; + pin-cs = <&gpio0 12 GPIO_FLAG_NONE>; + frequency-khz = <20000>; + }; }; // Speaker and microphone (ES8311) diff --git a/Devices/m5stack-cardputer/Source/Configuration.cpp b/Devices/m5stack-cardputer/Source/Configuration.cpp index 80989e044..d7f52ed0c 100644 --- a/Devices/m5stack-cardputer/Source/Configuration.cpp +++ b/Devices/m5stack-cardputer/Source/Configuration.cpp @@ -1,5 +1,4 @@ #include "devices/Display.h" -#include "devices/SdCard.h" #include "devices/CardputerEncoder.h" #include "devices/CardputerKeyboard.h" #include "devices/CardputerPower.h" @@ -16,7 +15,6 @@ static bool initBoot() { static DeviceVector createDevices() { return { - createSdCard(), createDisplay(), std::make_shared(), std::make_shared(), diff --git a/Devices/m5stack-cardputer/Source/devices/SdCard.cpp b/Devices/m5stack-cardputer/Source/devices/SdCard.cpp deleted file mode 100644 index 7ab98cfa1..000000000 --- a/Devices/m5stack-cardputer/Source/devices/SdCard.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include "SdCard.h" - -#include -#include - -constexpr auto SDCARD_PIN_CS = GPIO_NUM_12; - -using tt::hal::sdcard::SpiSdCardDevice; - -std::shared_ptr createSdCard() { - auto configuration = std::make_unique( - SDCARD_PIN_CS, - GPIO_NUM_NC, - GPIO_NUM_NC, - GPIO_NUM_NC, - SdCardDevice::MountBehaviour::AtBoot, - nullptr, - std::vector(), - SPI3_HOST - ); - - auto* spi_controller = device_find_by_name("spi1"); - check(spi_controller, "spi1 not found"); - - return std::make_shared( - std::move(configuration), - spi_controller - ); -} diff --git a/Devices/m5stack-cardputer/Source/devices/SdCard.h b/Devices/m5stack-cardputer/Source/devices/SdCard.h deleted file mode 100644 index 98b222fa6..000000000 --- a/Devices/m5stack-cardputer/Source/devices/SdCard.h +++ /dev/null @@ -1,8 +0,0 @@ -#pragma once - -#include -#include - -using tt::hal::sdcard::SdCardDevice; - -std::shared_ptr createSdCard(); diff --git a/Devices/m5stack-cardputer/m5stack,cardputer.dts b/Devices/m5stack-cardputer/m5stack,cardputer.dts index dde6df8c6..1e205b35a 100644 --- a/Devices/m5stack-cardputer/m5stack,cardputer.dts +++ b/Devices/m5stack-cardputer/m5stack,cardputer.dts @@ -8,6 +8,8 @@ #include #include #include +#include +#include // Reference: https://docs.m5stack.com/en/core/Cardputer / { @@ -33,19 +35,29 @@ i2cClockFrequency = <400000>; }; - display_spi: spi0 { + spi0 { compatible = "espressif,esp32-spi"; host = ; pin-mosi = <&gpio0 35 GPIO_FLAG_NONE>; pin-sclk = <&gpio0 36 GPIO_FLAG_NONE>; + + display { + compatible = "display-placeholder"; + }; }; - sdcard_spi: spi1 { + spi1 { compatible = "espressif,esp32-spi"; host = ; pin-mosi = <&gpio0 14 GPIO_FLAG_NONE>; pin-miso = <&gpio0 39 GPIO_FLAG_NONE>; pin-sclk = <&gpio0 40 GPIO_FLAG_NONE>; + + sdcard { + compatible = "espressif,esp32-sdspi"; + pin-cs = <&gpio0 12 GPIO_FLAG_NONE>; + frequency-khz = <20000>; + }; }; // Speaker and microphone diff --git a/Devices/m5stack-core2/Source/Configuration.cpp b/Devices/m5stack-core2/Source/Configuration.cpp index 7883adff4..c7059fe58 100644 --- a/Devices/m5stack-core2/Source/Configuration.cpp +++ b/Devices/m5stack-core2/Source/Configuration.cpp @@ -1,5 +1,4 @@ #include "devices/Display.h" -#include "devices/SdCard.h" #include "devices/Power.h" #include @@ -13,7 +12,6 @@ static bool initBoot() { static DeviceVector createDevices() { return { getAxp192(), - createSdCard(), createDisplay() }; } diff --git a/Devices/m5stack-core2/Source/devices/SdCard.cpp b/Devices/m5stack-core2/Source/devices/SdCard.cpp deleted file mode 100644 index 3d0a8e306..000000000 --- a/Devices/m5stack-core2/Source/devices/SdCard.cpp +++ /dev/null @@ -1,32 +0,0 @@ -#include "SdCard.h" - -#include -#include -#include - -constexpr auto CORE2_SDCARD_PIN_CS = GPIO_NUM_4; -constexpr auto CORE2_LCD_PIN_CS = GPIO_NUM_5; - -using tt::hal::sdcard::SpiSdCardDevice; - -std::shared_ptr createSdCard() { - auto configuration = std::make_unique( - CORE2_SDCARD_PIN_CS, - GPIO_NUM_NC, - GPIO_NUM_NC, - GPIO_NUM_NC, - SdCardDevice::MountBehaviour::AtBoot, - tt::lvgl::getSyncLock(), - std::vector { - CORE2_LCD_PIN_CS - } - ); - - auto* spi_controller = device_find_by_name("spi0"); - check(spi_controller, "spi0 not found"); - - return std::make_shared( - std::move(configuration), - spi_controller - ); -} diff --git a/Devices/m5stack-core2/Source/devices/SdCard.h b/Devices/m5stack-core2/Source/devices/SdCard.h deleted file mode 100644 index 6f5443c78..000000000 --- a/Devices/m5stack-core2/Source/devices/SdCard.h +++ /dev/null @@ -1,7 +0,0 @@ -#pragma once - -#include - -using tt::hal::sdcard::SdCardDevice; - -std::shared_ptr createSdCard(); diff --git a/Devices/m5stack-core2/m5stack,core2.dts b/Devices/m5stack-core2/m5stack,core2.dts index 06aedc7de..7bd48e78d 100644 --- a/Devices/m5stack-core2/m5stack,core2.dts +++ b/Devices/m5stack-core2/m5stack,core2.dts @@ -9,6 +9,8 @@ #include #include #include +#include +#include // Reference: https://docs.m5stack.com/en/core/Core2 / { @@ -54,6 +56,16 @@ pin-mosi = <&gpio0 23 GPIO_FLAG_NONE>; pin-miso = <&gpio0 38 GPIO_FLAG_NONE>; pin-sclk = <&gpio0 18 GPIO_FLAG_NONE>; + + sdcard { + compatible = "espressif,esp32-sdspi"; + pin-cs = <&gpio0 4 GPIO_FLAG_NONE>; + frequency-khz = <20000>; + }; + + display { + compatible = "display-placeholder"; + }; }; // NS4168: Speaker and microphone diff --git a/Devices/m5stack-cores3/Source/Configuration.cpp b/Devices/m5stack-cores3/Source/Configuration.cpp index d00a16c34..cad04d565 100644 --- a/Devices/m5stack-cores3/Source/Configuration.cpp +++ b/Devices/m5stack-cores3/Source/Configuration.cpp @@ -1,6 +1,5 @@ #include "InitBoot.h" #include "devices/Display.h" -#include "devices/SdCard.h" #include #include @@ -13,7 +12,6 @@ static DeviceVector createDevices() { axp2101, aw9523, std::make_shared(axp2101), - createSdCard(), createDisplay() }; } diff --git a/Devices/m5stack-cores3/Source/devices/SdCard.cpp b/Devices/m5stack-cores3/Source/devices/SdCard.cpp deleted file mode 100644 index 9083ef803..000000000 --- a/Devices/m5stack-cores3/Source/devices/SdCard.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include "SdCard.h" - -#include -#include -#include - -constexpr auto CORES3_SDCARD_PIN_CS = GPIO_NUM_4; -constexpr auto CORES3_LCD_PIN_CS = GPIO_NUM_3; - -using tt::hal::sdcard::SpiSdCardDevice; - -std::shared_ptr createSdCard() { - auto configuration = std::make_unique( - CORES3_SDCARD_PIN_CS, - GPIO_NUM_NC, - GPIO_NUM_NC, - GPIO_NUM_NC, - SdCardDevice::MountBehaviour::AtBoot, - tt::lvgl::getSyncLock(), - std::vector { CORES3_LCD_PIN_CS } - ); - - auto* spi_controller = device_find_by_name("spi0"); - check(spi_controller, "spi0 not found"); - - return std::make_shared( - std::move(configuration), - spi_controller - ); -} diff --git a/Devices/m5stack-cores3/Source/devices/SdCard.h b/Devices/m5stack-cores3/Source/devices/SdCard.h deleted file mode 100644 index 5cb65a735..000000000 --- a/Devices/m5stack-cores3/Source/devices/SdCard.h +++ /dev/null @@ -1,7 +0,0 @@ -#pragma once - -#include "Tactility/hal/sdcard/SdCardDevice.h" - -using tt::hal::sdcard::SdCardDevice; - -std::shared_ptr createSdCard(); diff --git a/Devices/m5stack-cores3/m5stack,cores3.dts b/Devices/m5stack-cores3/m5stack,cores3.dts index 60b54a24c..4d4040f34 100644 --- a/Devices/m5stack-cores3/m5stack,cores3.dts +++ b/Devices/m5stack-cores3/m5stack,cores3.dts @@ -10,6 +10,8 @@ #include #include #include +#include +#include // Reference: https://docs.m5stack.com/en/core/CoreS3 / { @@ -79,6 +81,16 @@ pin-mosi = <&gpio0 37 GPIO_FLAG_NONE>; pin-miso = <&gpio0 35 GPIO_FLAG_NONE>; pin-sclk = <&gpio0 36 GPIO_FLAG_NONE>; + + sdcard { + compatible = "espressif,esp32-sdspi"; + pin-cs = <&gpio0 4 GPIO_FLAG_NONE>; + frequency-khz = <20000>; + }; + + display { + compatible = "display-placeholder"; + }; }; // TODO: Enable speaker via ES7210 I2C: https://github.com/m5stack/M5Unified/blob/a6256725481f1bc366655fa48cf03b6095e30ad1/src/M5Unified.cpp#L417 diff --git a/Devices/m5stack-papers3/Source/Configuration.cpp b/Devices/m5stack-papers3/Source/Configuration.cpp index 3754d1437..f6d90bb50 100644 --- a/Devices/m5stack-papers3/Source/Configuration.cpp +++ b/Devices/m5stack-papers3/Source/Configuration.cpp @@ -1,5 +1,4 @@ #include "devices/Display.h" -#include "devices/SdCard.h" #include "devices/Power.h" #include @@ -12,7 +11,6 @@ static DeviceVector createDevices() { return { createPower(), createDisplay(), - createSdCard(), }; } diff --git a/Devices/m5stack-papers3/Source/devices/SdCard.cpp b/Devices/m5stack-papers3/Source/devices/SdCard.cpp deleted file mode 100644 index cc51ba7da..000000000 --- a/Devices/m5stack-papers3/Source/devices/SdCard.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include "SdCard.h" - -#include -#include -#include - -constexpr auto PAPERS3_SDCARD_PIN_CS = GPIO_NUM_47; - -using tt::hal::sdcard::SpiSdCardDevice; - -std::shared_ptr createSdCard() { - auto configuration = std::make_unique( - PAPERS3_SDCARD_PIN_CS, - GPIO_NUM_NC, - GPIO_NUM_NC, - GPIO_NUM_NC, - SdCardDevice::MountBehaviour::AtBoot - ); - - auto* spi_controller = device_find_by_name("spi0"); - check(spi_controller, "spi0 not found"); - - return std::make_shared( - std::move(configuration), - spi_controller - ); -} diff --git a/Devices/m5stack-papers3/Source/devices/SdCard.h b/Devices/m5stack-papers3/Source/devices/SdCard.h deleted file mode 100644 index 5cb65a735..000000000 --- a/Devices/m5stack-papers3/Source/devices/SdCard.h +++ /dev/null @@ -1,7 +0,0 @@ -#pragma once - -#include "Tactility/hal/sdcard/SdCardDevice.h" - -using tt::hal::sdcard::SdCardDevice; - -std::shared_ptr createSdCard(); diff --git a/Devices/m5stack-papers3/m5stack,papers3.dts b/Devices/m5stack-papers3/m5stack,papers3.dts index 9367a3aa2..946de1a79 100644 --- a/Devices/m5stack-papers3/m5stack,papers3.dts +++ b/Devices/m5stack-papers3/m5stack,papers3.dts @@ -7,6 +7,7 @@ #include #include #include +#include / { compatible = "root"; @@ -46,5 +47,11 @@ pin-miso = <&gpio0 40 GPIO_FLAG_NONE>; pin-sclk = <&gpio0 39 GPIO_FLAG_NONE>; max-transfer-size = <4096>; + + sdcard { + compatible = "espressif,esp32-sdspi"; + pin-cs = <&gpio0 47 GPIO_FLAG_NONE>; + frequency-khz = <20000>; + }; }; }; diff --git a/Devices/m5stack-stackchan/Source/Configuration.cpp b/Devices/m5stack-stackchan/Source/Configuration.cpp index dd3d0ef11..3a1eea9d5 100644 --- a/Devices/m5stack-stackchan/Source/Configuration.cpp +++ b/Devices/m5stack-stackchan/Source/Configuration.cpp @@ -1,6 +1,5 @@ #include "devices/Display.h" #include "devices/Power.h" -#include "devices/SdCard.h" #include #include @@ -243,7 +242,6 @@ static DeviceVector createDevices() { axp2101, std::make_shared(axp2101), createPower(), - createSdCard(), createDisplay(), }; } diff --git a/Devices/m5stack-stackchan/Source/devices/SdCard.cpp b/Devices/m5stack-stackchan/Source/devices/SdCard.cpp deleted file mode 100644 index 0fbc268b0..000000000 --- a/Devices/m5stack-stackchan/Source/devices/SdCard.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include "SdCard.h" - -#include -#include -#include - -constexpr auto STACKCHAN_SDCARD_PIN_CS = GPIO_NUM_4; -constexpr auto STACKCHAN_LCD_PIN_CS = GPIO_NUM_3; - -using tt::hal::sdcard::SpiSdCardDevice; - -std::shared_ptr createSdCard() { - auto configuration = std::make_unique( - STACKCHAN_SDCARD_PIN_CS, - GPIO_NUM_NC, - GPIO_NUM_NC, - GPIO_NUM_NC, - SdCardDevice::MountBehaviour::AtBoot, - tt::lvgl::getSyncLock(), - std::vector { STACKCHAN_LCD_PIN_CS } - ); - - auto* spi_controller = device_find_by_name("spi0"); - check(spi_controller, "spi0 not found"); - - return std::make_shared( - std::move(configuration), - spi_controller - ); -} diff --git a/Devices/m5stack-stackchan/Source/devices/SdCard.h b/Devices/m5stack-stackchan/Source/devices/SdCard.h deleted file mode 100644 index 5cb65a735..000000000 --- a/Devices/m5stack-stackchan/Source/devices/SdCard.h +++ /dev/null @@ -1,7 +0,0 @@ -#pragma once - -#include "Tactility/hal/sdcard/SdCardDevice.h" - -using tt::hal::sdcard::SdCardDevice; - -std::shared_ptr createSdCard(); diff --git a/Devices/m5stack-stackchan/m5stack,stackchan.dts b/Devices/m5stack-stackchan/m5stack,stackchan.dts index 5440b6c1c..5659c2776 100644 --- a/Devices/m5stack-stackchan/m5stack,stackchan.dts +++ b/Devices/m5stack-stackchan/m5stack,stackchan.dts @@ -12,6 +12,8 @@ #include #include #include +#include +#include // Reference: https://docs.m5stack.com/en/StackChan / { @@ -113,6 +115,16 @@ pin-mosi = <&gpio0 37 GPIO_FLAG_NONE>; pin-miso = <&gpio0 35 GPIO_FLAG_NONE>; pin-sclk = <&gpio0 36 GPIO_FLAG_NONE>; + + sdcard { + compatible = "espressif,esp32-sdspi"; + pin-cs = <&gpio0 4 GPIO_FLAG_NONE>; + frequency-khz = <20000>; + }; + + display { + compatible = "display-placeholder"; + }; }; // AW88298 speaker + ES7210 microphone diff --git a/Devices/m5stack-stickc-plus/m5stack,stickc-plus.dts b/Devices/m5stack-stickc-plus/m5stack,stickc-plus.dts index 55bdbf6e7..86de033f8 100644 --- a/Devices/m5stack-stickc-plus/m5stack,stickc-plus.dts +++ b/Devices/m5stack-stickc-plus/m5stack,stickc-plus.dts @@ -7,6 +7,7 @@ #include #include #include +#include / { compatible = "root"; @@ -48,6 +49,10 @@ host = ; pin-mosi = <&gpio0 15 GPIO_FLAG_NONE>; pin-sclk = <&gpio0 13 GPIO_FLAG_NONE>; + + display { + compatible = "display-placeholder"; + }; }; uart_grove: uart1 { diff --git a/Devices/m5stack-stickc-plus2/m5stack,stickc-plus2.dts b/Devices/m5stack-stickc-plus2/m5stack,stickc-plus2.dts index 9f86c6800..e299548a3 100644 --- a/Devices/m5stack-stickc-plus2/m5stack,stickc-plus2.dts +++ b/Devices/m5stack-stickc-plus2/m5stack,stickc-plus2.dts @@ -6,6 +6,7 @@ #include #include #include +#include / { compatible = "root"; @@ -47,6 +48,10 @@ host = ; pin-mosi = <&gpio0 15 GPIO_FLAG_NONE>; pin-sclk = <&gpio0 13 GPIO_FLAG_NONE>; + + display { + compatible = "display-placeholder"; + }; }; uart_grove: uart1 { diff --git a/Devices/m5stack-sticks3/Source/Configuration.cpp b/Devices/m5stack-sticks3/Source/Configuration.cpp index 6743208c6..501726d02 100644 --- a/Devices/m5stack-sticks3/Source/Configuration.cpp +++ b/Devices/m5stack-sticks3/Source/Configuration.cpp @@ -1,5 +1,4 @@ #include "devices/Display.h" -#include "devices/SdCard.h" #include "devices/Power.h" #include @@ -104,7 +103,6 @@ static DeviceVector createDevices() { createPower(), ButtonControl::createTwoButtonControl(11, 12), // top button, side button createDisplay(), - createSdCard() }; } diff --git a/Devices/m5stack-sticks3/Source/devices/SdCard.cpp b/Devices/m5stack-sticks3/Source/devices/SdCard.cpp deleted file mode 100644 index 361dcf551..000000000 --- a/Devices/m5stack-sticks3/Source/devices/SdCard.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include "SdCard.h" - -#include -#include - -constexpr auto SDCARD_SPI_HOST = SPI3_HOST; -constexpr auto SDCARD_PIN_CS = GPIO_NUM_7; - -using tt::hal::sdcard::SpiSdCardDevice; - -std::shared_ptr createSdCard() { - auto configuration = std::make_unique( - SDCARD_PIN_CS, - GPIO_NUM_NC, - GPIO_NUM_NC, - GPIO_NUM_NC, - SdCardDevice::MountBehaviour::AtBoot, - nullptr, - std::vector(), - SDCARD_SPI_HOST - ); - - auto* spi_controller = device_find_by_name("spi1"); - check(spi_controller, "spi1 not found"); - - return std::make_shared( - std::move(configuration), - spi_controller - ); -} diff --git a/Devices/m5stack-sticks3/Source/devices/SdCard.h b/Devices/m5stack-sticks3/Source/devices/SdCard.h deleted file mode 100644 index 98b222fa6..000000000 --- a/Devices/m5stack-sticks3/Source/devices/SdCard.h +++ /dev/null @@ -1,8 +0,0 @@ -#pragma once - -#include -#include - -using tt::hal::sdcard::SdCardDevice; - -std::shared_ptr createSdCard(); diff --git a/Devices/m5stack-sticks3/m5stack,sticks3.dts b/Devices/m5stack-sticks3/m5stack,sticks3.dts index 4d194c8d9..34dc0155a 100644 --- a/Devices/m5stack-sticks3/m5stack,sticks3.dts +++ b/Devices/m5stack-sticks3/m5stack,sticks3.dts @@ -8,6 +8,8 @@ #include #include #include +#include +#include / { compatible = "root"; @@ -53,6 +55,10 @@ host = ; pin-mosi = <&gpio0 39 GPIO_FLAG_NONE>; pin-sclk = <&gpio0 40 GPIO_FLAG_NONE>; + + display { + compatible = "display-placeholder"; + }; }; //DIY SD Card - https://wiki.bruce.computer/wiring-diagrams/m5sticks3/sd-card/ @@ -62,6 +68,12 @@ pin-mosi = <&gpio0 6 GPIO_FLAG_NONE>; pin-miso = <&gpio0 4 GPIO_FLAG_NONE>; pin-sclk = <&gpio0 5 GPIO_FLAG_NONE>; + + sdcard { + compatible = "espressif,esp32-sdspi"; + pin-cs = <&gpio0 7 GPIO_FLAG_NONE>; + frequency-khz = <20000>; + }; }; // Speaker and microphone (ES8311) diff --git a/Devices/m5stack-tab5/Source/Configuration.cpp b/Devices/m5stack-tab5/Source/Configuration.cpp index e1f3348d9..cb6be2316 100644 --- a/Devices/m5stack-tab5/Source/Configuration.cpp +++ b/Devices/m5stack-tab5/Source/Configuration.cpp @@ -1,5 +1,4 @@ #include "devices/Display.h" -#include "devices/SdCard.h" #include "devices/Power.h" #include "devices/Tab5Keyboard.h" @@ -17,7 +16,6 @@ static DeviceVector createDevices() { return { createPower(), createDisplay(), - createSdCard(), std::make_shared(i2c2) }; } diff --git a/Devices/m5stack-tab5/Source/devices/SdCard.cpp b/Devices/m5stack-tab5/Source/devices/SdCard.cpp deleted file mode 100644 index 639eed882..000000000 --- a/Devices/m5stack-tab5/Source/devices/SdCard.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#include "SdCard.h" - -#include -#include - -constexpr auto SDCARD_PIN_CS = GPIO_NUM_42; - -using tt::hal::sdcard::SpiSdCardDevice; - -std::shared_ptr createSdCard() { - auto configuration = std::make_unique( - SDCARD_PIN_CS, - GPIO_NUM_NC, - GPIO_NUM_NC, - GPIO_NUM_NC, - SdCardDevice::MountBehaviour::AtBoot - ); - - auto* spi_controller = device_find_by_name("spi0"); - check(spi_controller, "spi0 not found"); - - return std::make_shared( - std::move(configuration), - spi_controller - ); -} diff --git a/Devices/m5stack-tab5/Source/devices/SdCard.h b/Devices/m5stack-tab5/Source/devices/SdCard.h deleted file mode 100644 index 98b222fa6..000000000 --- a/Devices/m5stack-tab5/Source/devices/SdCard.h +++ /dev/null @@ -1,8 +0,0 @@ -#pragma once - -#include -#include - -using tt::hal::sdcard::SdCardDevice; - -std::shared_ptr createSdCard(); diff --git a/Devices/m5stack-tab5/m5stack,tab5.dts b/Devices/m5stack-tab5/m5stack,tab5.dts index 060b15c5c..aea748d8b 100644 --- a/Devices/m5stack-tab5/m5stack,tab5.dts +++ b/Devices/m5stack-tab5/m5stack,tab5.dts @@ -13,6 +13,7 @@ #include #include #include +#include / { compatible = "root"; @@ -78,12 +79,18 @@ pin-scl = <&gpio0 1 GPIO_FLAG_PULL_UP>; }; - sdcard_spi: spi0 { + spi0 { compatible = "espressif,esp32-spi"; host = ; pin-mosi = <&gpio0 44 GPIO_FLAG_NONE>; pin-miso = <&gpio0 39 GPIO_FLAG_NONE>; pin-sclk = <&gpio0 43 GPIO_FLAG_NONE>; + + sdcard { + compatible = "espressif,esp32-sdspi"; + pin-cs = <&gpio0 42 GPIO_FLAG_NONE>; + frequency-khz = <20000>; + }; }; // ES8388 and ES7210 diff --git a/Devices/unphone/Source/Configuration.cpp b/Devices/unphone/Source/Configuration.cpp index e51ecfd1d..b32363ff9 100644 --- a/Devices/unphone/Source/Configuration.cpp +++ b/Devices/unphone/Source/Configuration.cpp @@ -1,6 +1,5 @@ #include "UnPhoneFeatures.h" #include "devices/Hx8357Display.h" -#include "devices/SdCard.h" #include @@ -9,7 +8,6 @@ bool initBoot(); static tt::hal::DeviceVector createDevices() { return { createDisplay(), - createSdCard() }; } diff --git a/Devices/unphone/Source/devices/SdCard.cpp b/Devices/unphone/Source/devices/SdCard.cpp deleted file mode 100644 index c75ca5638..000000000 --- a/Devices/unphone/Source/devices/SdCard.cpp +++ /dev/null @@ -1,36 +0,0 @@ -#include "SdCard.h" - -#include -#include -#include - -#define UNPHONE_SDCARD_PIN_CS GPIO_NUM_43 -#define UNPHONE_LCD_PIN_CS GPIO_NUM_48 -#define UNPHONE_LORA_PIN_CS GPIO_NUM_44 -#define UNPHONE_TOUCH_PIN_CS GPIO_NUM_38 - -using tt::hal::sdcard::SpiSdCardDevice; - -std::shared_ptr createSdCard() { - auto configuration = std::make_unique( - UNPHONE_SDCARD_PIN_CS, - GPIO_NUM_NC, - GPIO_NUM_NC, - GPIO_NUM_NC, - SdCardDevice::MountBehaviour::AtBoot, - tt::lvgl::getSyncLock(), - std::vector { - UNPHONE_LORA_PIN_CS, - UNPHONE_LCD_PIN_CS, - UNPHONE_TOUCH_PIN_CS - } - ); - - auto* spi_controller = device_find_by_name("spi0"); - check(spi_controller, "spi0 not found"); - - return std::make_shared( - std::move(configuration), - spi_controller - ); -} diff --git a/Devices/unphone/Source/devices/SdCard.h b/Devices/unphone/Source/devices/SdCard.h deleted file mode 100644 index 5cb65a735..000000000 --- a/Devices/unphone/Source/devices/SdCard.h +++ /dev/null @@ -1,7 +0,0 @@ -#pragma once - -#include "Tactility/hal/sdcard/SdCardDevice.h" - -using tt::hal::sdcard::SdCardDevice; - -std::shared_ptr createSdCard(); diff --git a/Devices/unphone/unphone.dts b/Devices/unphone/unphone.dts index 5dcc2ef58..e46ad3b2b 100644 --- a/Devices/unphone/unphone.dts +++ b/Devices/unphone/unphone.dts @@ -5,6 +5,7 @@ #include #include #include +#include / { compatible = "root"; @@ -34,5 +35,11 @@ pin-miso = <&gpio0 41 GPIO_FLAG_NONE>; pin-sclk = <&gpio0 39 GPIO_FLAG_NONE>; max-transfer-size = <65536>; + + sdcard { + compatible = "espressif,esp32-sdspi"; + pin-cs = <&gpio0 43 GPIO_FLAG_NONE>; + frequency-khz = <20000>; + }; }; }; diff --git a/Devices/waveshare-esp32-s3-geek/waveshare,esp32-s3-geek.dts b/Devices/waveshare-esp32-s3-geek/waveshare,esp32-s3-geek.dts index dc51c36f0..40ff3582d 100644 --- a/Devices/waveshare-esp32-s3-geek/waveshare,esp32-s3-geek.dts +++ b/Devices/waveshare-esp32-s3-geek/waveshare,esp32-s3-geek.dts @@ -7,6 +7,7 @@ #include #include #include +#include / { compatible = "root"; @@ -34,6 +35,10 @@ host = ; pin-mosi = <&gpio0 11 GPIO_FLAG_NONE>; pin-sclk = <&gpio0 12 GPIO_FLAG_NONE>; + + display { + compatible = "display-placeholder"; + }; }; sdmmc0 { diff --git a/Devices/waveshare-s3-lcd-13/Source/Configuration.cpp b/Devices/waveshare-s3-lcd-13/Source/Configuration.cpp index aef2df4b9..b8d6553da 100644 --- a/Devices/waveshare-s3-lcd-13/Source/Configuration.cpp +++ b/Devices/waveshare-s3-lcd-13/Source/Configuration.cpp @@ -1,5 +1,4 @@ #include "devices/Display.h" -#include "devices/SdCard.h" #include #include @@ -10,7 +9,6 @@ using namespace tt::hal; static DeviceVector createDevices() { return { createDisplay(), - createSdCard() }; } diff --git a/Devices/waveshare-s3-lcd-13/Source/devices/SdCard.cpp b/Devices/waveshare-s3-lcd-13/Source/devices/SdCard.cpp deleted file mode 100644 index b01a45b4d..000000000 --- a/Devices/waveshare-s3-lcd-13/Source/devices/SdCard.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include "SdCard.h" - -#include -#include -#include - -using tt::hal::sdcard::SpiSdCardDevice; - -std::shared_ptr createSdCard() { - auto configuration = std::make_unique( - GPIO_NUM_17, - GPIO_NUM_NC, - GPIO_NUM_NC, - GPIO_NUM_NC, - SdCardDevice::MountBehaviour::AtBoot, - nullptr, - std::vector(), - SPI3_HOST - ); - - auto* spi_controller = device_find_by_name("spi1"); - check(spi_controller, "spi1 not found"); - - return std::make_shared( - std::move(configuration), - spi_controller - ); -} diff --git a/Devices/waveshare-s3-lcd-13/Source/devices/SdCard.h b/Devices/waveshare-s3-lcd-13/Source/devices/SdCard.h deleted file mode 100644 index 5cb65a735..000000000 --- a/Devices/waveshare-s3-lcd-13/Source/devices/SdCard.h +++ /dev/null @@ -1,7 +0,0 @@ -#pragma once - -#include "Tactility/hal/sdcard/SdCardDevice.h" - -using tt::hal::sdcard::SdCardDevice; - -std::shared_ptr createSdCard(); diff --git a/Devices/waveshare-s3-lcd-13/waveshare,s3-lcd-13.dts b/Devices/waveshare-s3-lcd-13/waveshare,s3-lcd-13.dts index 0d11d1bfa..7da91d261 100644 --- a/Devices/waveshare-s3-lcd-13/waveshare,s3-lcd-13.dts +++ b/Devices/waveshare-s3-lcd-13/waveshare,s3-lcd-13.dts @@ -6,6 +6,8 @@ #include #include #include +#include +#include // Reference: https://www.waveshare.com/wiki/ESP32-S3-LCD-1.3 / { @@ -39,6 +41,10 @@ host = ; pin-mosi = <&gpio0 41 GPIO_FLAG_NONE>; pin-sclk = <&gpio0 40 GPIO_FLAG_NONE>; + + display { + compatible = "display-placeholder"; + }; }; spi1 { @@ -47,5 +53,11 @@ pin-mosi = <&gpio0 18 GPIO_FLAG_NONE>; pin-miso = <&gpio0 16 GPIO_FLAG_NONE>; pin-sclk = <&gpio0 21 GPIO_FLAG_NONE>; + + sdcard { + compatible = "espressif,esp32-sdspi"; + pin-cs = <&gpio0 17 GPIO_FLAG_NONE>; + frequency-khz = <20000>; + }; }; }; diff --git a/Devices/waveshare-s3-touch-lcd-128/Source/Configuration.cpp b/Devices/waveshare-s3-touch-lcd-128/Source/Configuration.cpp index 5a2a1ca53..c78cfff15 100644 --- a/Devices/waveshare-s3-touch-lcd-128/Source/Configuration.cpp +++ b/Devices/waveshare-s3-touch-lcd-128/Source/Configuration.cpp @@ -1,5 +1,4 @@ #include "devices/Display.h" -#include "devices/SdCard.h" #include #include @@ -10,7 +9,6 @@ using namespace tt::hal; static DeviceVector createDevices() { return { createDisplay(), - createSdCard() }; } diff --git a/Devices/waveshare-s3-touch-lcd-128/Source/devices/SdCard.cpp b/Devices/waveshare-s3-touch-lcd-128/Source/devices/SdCard.cpp deleted file mode 100644 index e56e5361f..000000000 --- a/Devices/waveshare-s3-touch-lcd-128/Source/devices/SdCard.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include "SdCard.h" - -#include -#include -#include - -using tt::hal::sdcard::SpiSdCardDevice; - -std::shared_ptr createSdCard() { - auto configuration = std::make_unique( - GPIO_NUM_18, - GPIO_NUM_NC, - GPIO_NUM_NC, - GPIO_NUM_NC, - SdCardDevice::MountBehaviour::AtBoot, - nullptr, - std::vector(), - SPI3_HOST - ); - - auto* spi_controller = device_find_by_name("spi1"); - check(spi_controller, "spi1 not found"); - - return std::make_shared( - std::move(configuration), - spi_controller - ); -} diff --git a/Devices/waveshare-s3-touch-lcd-128/Source/devices/SdCard.h b/Devices/waveshare-s3-touch-lcd-128/Source/devices/SdCard.h deleted file mode 100644 index 5cb65a735..000000000 --- a/Devices/waveshare-s3-touch-lcd-128/Source/devices/SdCard.h +++ /dev/null @@ -1,7 +0,0 @@ -#pragma once - -#include "Tactility/hal/sdcard/SdCardDevice.h" - -using tt::hal::sdcard::SdCardDevice; - -std::shared_ptr createSdCard(); diff --git a/Devices/waveshare-s3-touch-lcd-128/waveshare,s3-touch-lcd-128.dts b/Devices/waveshare-s3-touch-lcd-128/waveshare,s3-touch-lcd-128.dts index 5a781dd60..da213dbda 100644 --- a/Devices/waveshare-s3-touch-lcd-128/waveshare,s3-touch-lcd-128.dts +++ b/Devices/waveshare-s3-touch-lcd-128/waveshare,s3-touch-lcd-128.dts @@ -6,6 +6,8 @@ #include #include #include +#include +#include // Reference: https://www.waveshare.com/wiki/ESP32-S3-Touch-LCD-1.28 / { @@ -34,19 +36,29 @@ }; }; - display_spi: spi0 { + spi0 { compatible = "espressif,esp32-spi"; host = ; pin-mosi = <&gpio0 11 GPIO_FLAG_NONE>; pin-miso = <&gpio0 12 GPIO_FLAG_NONE>; pin-sclk = <&gpio0 10 GPIO_FLAG_NONE>; + + display { + compatible = "display-placeholder"; + }; }; - sdcard_spi: spi1 { + spi1 { compatible = "espressif,esp32-spi"; host = ; pin-mosi = <&gpio0 16 GPIO_FLAG_NONE>; pin-miso = <&gpio0 15 GPIO_FLAG_NONE>; pin-sclk = <&gpio0 17 GPIO_FLAG_NONE>; + + sdcard { + compatible = "espressif,esp32-sdspi"; + pin-cs = <&gpio0 18 GPIO_FLAG_NONE>; + frequency-khz = <20000>; + }; }; }; diff --git a/Devices/waveshare-s3-touch-lcd-147/Source/Configuration.cpp b/Devices/waveshare-s3-touch-lcd-147/Source/Configuration.cpp index 8358fd2e9..dbd7799cf 100644 --- a/Devices/waveshare-s3-touch-lcd-147/Source/Configuration.cpp +++ b/Devices/waveshare-s3-touch-lcd-147/Source/Configuration.cpp @@ -1,5 +1,4 @@ #include "devices/Display.h" -#include "devices/Sdcard.h" #include @@ -10,7 +9,6 @@ using namespace tt::hal; static std::vector> createDevices() { return { createDisplay(), - createSdCard() }; } diff --git a/Devices/waveshare-s3-touch-lcd-147/Source/devices/Sdcard.cpp b/Devices/waveshare-s3-touch-lcd-147/Source/devices/Sdcard.cpp deleted file mode 100644 index f419562c0..000000000 --- a/Devices/waveshare-s3-touch-lcd-147/Source/devices/Sdcard.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include "Sdcard.h" - -#include -#include -#include - -using tt::hal::sdcard::SpiSdCardDevice; - -constexpr auto SDCARD_PIN_CS = GPIO_NUM_14; - -std::shared_ptr createSdCard() { - auto configuration = std::make_unique( - SDCARD_PIN_CS, - GPIO_NUM_NC, - GPIO_NUM_NC, - GPIO_NUM_NC, - SdCardDevice::MountBehaviour::AtBoot, - nullptr, - std::vector { }, - SPI3_HOST - ); - - auto* spi_controller = device_find_by_name("spi1"); - check(spi_controller, "spi1 not found"); - - return std::make_shared( - std::move(configuration), - spi_controller - ); -} diff --git a/Devices/waveshare-s3-touch-lcd-147/Source/devices/Sdcard.h b/Devices/waveshare-s3-touch-lcd-147/Source/devices/Sdcard.h deleted file mode 100644 index 6f5443c78..000000000 --- a/Devices/waveshare-s3-touch-lcd-147/Source/devices/Sdcard.h +++ /dev/null @@ -1,7 +0,0 @@ -#pragma once - -#include - -using tt::hal::sdcard::SdCardDevice; - -std::shared_ptr createSdCard(); diff --git a/Devices/waveshare-s3-touch-lcd-147/waveshare,s3-touch-lcd-147.dts b/Devices/waveshare-s3-touch-lcd-147/waveshare,s3-touch-lcd-147.dts index 8afd056cc..0877d8131 100644 --- a/Devices/waveshare-s3-touch-lcd-147/waveshare,s3-touch-lcd-147.dts +++ b/Devices/waveshare-s3-touch-lcd-147/waveshare,s3-touch-lcd-147.dts @@ -5,6 +5,7 @@ #include #include #include +#include // Reference: https://www.waveshare.com/wiki/ESP32-S3-Touch-LCD-1.47 / { @@ -28,18 +29,24 @@ pin-scl = <&gpio0 41 GPIO_FLAG_NONE>; }; - display_spi: spi0 { + spi0 { compatible = "espressif,esp32-spi"; host = ; pin-mosi = <&gpio0 39 GPIO_FLAG_NONE>; pin-sclk = <&gpio0 38 GPIO_FLAG_NONE>; }; - sdcard_spi: spi1 { + spi1 { compatible = "espressif,esp32-spi"; host = ; pin-mosi = <&gpio0 15 GPIO_FLAG_NONE>; pin-miso = <&gpio0 17 GPIO_FLAG_NONE>; pin-sclk = <&gpio0 16 GPIO_FLAG_NONE>; + + sdcard { + compatible = "espressif,esp32-sdspi"; + pin-cs = <&gpio0 14 GPIO_FLAG_NONE>; + frequency-khz = <20000>; + }; }; }; diff --git a/Devices/waveshare-s3-touch-lcd-43/Source/Configuration.cpp b/Devices/waveshare-s3-touch-lcd-43/Source/Configuration.cpp index 7ec8c4ce4..3e32ef538 100644 --- a/Devices/waveshare-s3-touch-lcd-43/Source/Configuration.cpp +++ b/Devices/waveshare-s3-touch-lcd-43/Source/Configuration.cpp @@ -1,5 +1,4 @@ #include "devices/Display.h" -#include "devices/SdCard.h" #include @@ -8,7 +7,6 @@ using namespace tt::hal; static DeviceVector createDevices() { return { createDisplay(), - createSdCard() }; } diff --git a/Devices/waveshare-s3-touch-lcd-43/Source/devices/SdCard.cpp b/Devices/waveshare-s3-touch-lcd-43/Source/devices/SdCard.cpp deleted file mode 100644 index 891129943..000000000 --- a/Devices/waveshare-s3-touch-lcd-43/Source/devices/SdCard.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#include "SdCard.h" - -#include -#include -#include - -using tt::hal::sdcard::SpiSdCardDevice; - -std::shared_ptr createSdCard() { - auto configuration = std::make_unique( - GPIO_NUM_10, - GPIO_NUM_NC, - GPIO_NUM_NC, - GPIO_NUM_NC, - SdCardDevice::MountBehaviour::AtBoot, - tt::lvgl::getSyncLock() - ); - - auto* spi_controller = device_find_by_name("spi0"); - check(spi_controller, "spi0 not found"); - - return std::make_shared( - std::move(configuration), - spi_controller - ); -} diff --git a/Devices/waveshare-s3-touch-lcd-43/Source/devices/SdCard.h b/Devices/waveshare-s3-touch-lcd-43/Source/devices/SdCard.h deleted file mode 100644 index 5cb65a735..000000000 --- a/Devices/waveshare-s3-touch-lcd-43/Source/devices/SdCard.h +++ /dev/null @@ -1,7 +0,0 @@ -#pragma once - -#include "Tactility/hal/sdcard/SdCardDevice.h" - -using tt::hal::sdcard::SdCardDevice; - -std::shared_ptr createSdCard(); diff --git a/Devices/waveshare-s3-touch-lcd-43/waveshare,s3-touch-lcd-43.dts b/Devices/waveshare-s3-touch-lcd-43/waveshare,s3-touch-lcd-43.dts index 22513fa40..8be9aeb7d 100644 --- a/Devices/waveshare-s3-touch-lcd-43/waveshare,s3-touch-lcd-43.dts +++ b/Devices/waveshare-s3-touch-lcd-43/waveshare,s3-touch-lcd-43.dts @@ -6,6 +6,7 @@ #include #include #include +#include / { compatible = "root"; @@ -34,6 +35,12 @@ pin-mosi = <&gpio0 11 GPIO_FLAG_NONE>; pin-miso = <&gpio0 13 GPIO_FLAG_NONE>; pin-sclk = <&gpio0 12 GPIO_FLAG_NONE>; + + sdcard { + compatible = "espressif,esp32-sdspi"; + pin-cs = <&gpio0 10 GPIO_FLAG_NONE>; + frequency-khz = <20000>; + }; }; uart1 { diff --git a/Devices/wireless-tag-wt32-sc01-plus/Source/Configuration.cpp b/Devices/wireless-tag-wt32-sc01-plus/Source/Configuration.cpp index b33fbb08a..ce0fb67f9 100644 --- a/Devices/wireless-tag-wt32-sc01-plus/Source/Configuration.cpp +++ b/Devices/wireless-tag-wt32-sc01-plus/Source/Configuration.cpp @@ -1,24 +1,22 @@ -#include "devices/Display.h" -#include "devices/SdCard.h" -#include - -#include -#include - -using namespace tt::hal; - -static DeviceVector createDevices() { - return { - createDisplay(), - createSdCard() - }; -} - -static bool initBoot() { - return driver::pwmbacklight::init(GPIO_NUM_45); -} - -extern const Configuration hardwareConfiguration = { - .initBoot = initBoot, - .createDevices = createDevices -}; +#include "devices/Display.h" +#include + +#include +#include + +using namespace tt::hal; + +static DeviceVector createDevices() { + return { + createDisplay(), + }; +} + +static bool initBoot() { + return driver::pwmbacklight::init(GPIO_NUM_45); +} + +extern const Configuration hardwareConfiguration = { + .initBoot = initBoot, + .createDevices = createDevices +}; diff --git a/Devices/wireless-tag-wt32-sc01-plus/Source/devices/SdCard.cpp b/Devices/wireless-tag-wt32-sc01-plus/Source/devices/SdCard.cpp deleted file mode 100644 index b2e4dc428..000000000 --- a/Devices/wireless-tag-wt32-sc01-plus/Source/devices/SdCard.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include "SdCard.h" - -#include -#include -#include - -using tt::hal::sdcard::SpiSdCardDevice; - -std::shared_ptr createSdCard() { - auto configuration = std::make_unique( - GPIO_NUM_41, - GPIO_NUM_NC, - GPIO_NUM_NC, - GPIO_NUM_NC, - SdCardDevice::MountBehaviour::AtBoot, - tt::lvgl::getSyncLock(), - std::vector(), - SPI2_HOST - ); - - ::Device* spiController = device_find_by_name("spi0"); - check(spiController != nullptr, "spi0 not found"); - - return std::make_shared( - std::move(configuration), - spiController - ); -} diff --git a/Devices/wireless-tag-wt32-sc01-plus/Source/devices/SdCard.h b/Devices/wireless-tag-wt32-sc01-plus/Source/devices/SdCard.h deleted file mode 100644 index b38d94894..000000000 --- a/Devices/wireless-tag-wt32-sc01-plus/Source/devices/SdCard.h +++ /dev/null @@ -1,7 +0,0 @@ -#pragma once - -#include "Tactility/hal/sdcard/SdCardDevice.h" - -using tt::hal::sdcard::SdCardDevice; - -std::shared_ptr createSdCard(); diff --git a/Devices/wireless-tag-wt32-sc01-plus/wireless-tag,wt32-sc01-plus.dts b/Devices/wireless-tag-wt32-sc01-plus/wireless-tag,wt32-sc01-plus.dts index 6beff46d9..a09f37a61 100644 --- a/Devices/wireless-tag-wt32-sc01-plus/wireless-tag,wt32-sc01-plus.dts +++ b/Devices/wireless-tag-wt32-sc01-plus/wireless-tag,wt32-sc01-plus.dts @@ -5,6 +5,7 @@ #include #include #include +#include / { compatible = "root"; @@ -33,5 +34,11 @@ pin-mosi = <&gpio0 40 GPIO_FLAG_NONE>; pin-miso = <&gpio0 38 GPIO_FLAG_NONE>; pin-sclk = <&gpio0 39 GPIO_FLAG_NONE>; + + sdcard { + compatible = "espressif,esp32-sdspi"; + pin-cs = <&gpio0 41 GPIO_FLAG_NONE>; + frequency-khz = <20000>; + }; }; }; diff --git a/Platforms/platform-esp32/bindings/espressif,esp32-sdspi.yaml b/Platforms/platform-esp32/bindings/espressif,esp32-sdspi.yaml new file mode 100644 index 000000000..45c4d0e06 --- /dev/null +++ b/Platforms/platform-esp32/bindings/espressif,esp32-sdspi.yaml @@ -0,0 +1,27 @@ +description: ESP32 SD card over SPI + +compatible: "espressif,esp32-sdspi" + +bus: spi + +properties: + pin-cs: + type: phandle-array + required: true + description: Chip select GPIO + pin-cd: + type: phandle-array + default: GPIO_PIN_SPEC_NONE + description: Card detect GPIO + pin-wp: + type: phandle-array + default: GPIO_PIN_SPEC_NONE + description: Write protect GPIO + pin-int: + type: phandle-array + default: GPIO_PIN_SPEC_NONE + description: Interrupt GPIO + frequency-khz: + type: int + required: true + description: SPI clock frequency in kHz diff --git a/Platforms/platform-esp32/include/tactility/bindings/esp32_sdspi.h b/Platforms/platform-esp32/include/tactility/bindings/esp32_sdspi.h new file mode 100644 index 000000000..729d00330 --- /dev/null +++ b/Platforms/platform-esp32/include/tactility/bindings/esp32_sdspi.h @@ -0,0 +1,15 @@ +// SPDX-License-Identifier: Apache-2.0 +#pragma once + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +DEFINE_DEVICETREE(esp32_sdspi, struct Esp32SdspiConfig) + +#ifdef __cplusplus +} +#endif diff --git a/Platforms/platform-esp32/include/tactility/drivers/esp32_sdcard.h b/Platforms/platform-esp32/include/tactility/drivers/esp32_sdcard.h new file mode 100644 index 000000000..6405c893f --- /dev/null +++ b/Platforms/platform-esp32/include/tactility/drivers/esp32_sdcard.h @@ -0,0 +1,21 @@ +// SPDX-License-Identifier: Apache-2.0 +#pragma once + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +struct Device; + +/** + * Try to get the sdmmc_card_t* for the given device. + * @param device any device. + * @return the sdmmc_card_t* if it is available for this device, otherwise return null + */ +sdmmc_card_t* esp32_sdcard_get_card(struct Device* device); + +#ifdef __cplusplus +} +#endif diff --git a/Platforms/platform-esp32/include/tactility/drivers/esp32_sdspi.h b/Platforms/platform-esp32/include/tactility/drivers/esp32_sdspi.h new file mode 100644 index 000000000..eba9b4161 --- /dev/null +++ b/Platforms/platform-esp32/include/tactility/drivers/esp32_sdspi.h @@ -0,0 +1,23 @@ +// SPDX-License-Identifier: Apache-2.0 +#pragma once + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +struct Esp32SdspiConfig { + struct GpioPinSpec pin_cs; + struct GpioPinSpec pin_cd; + struct GpioPinSpec pin_wp; + struct GpioPinSpec pin_int; + uint32_t frequency_khz; +}; + +sdmmc_card_t* esp32_sdspi_get_card(struct Device* device); + +#ifdef __cplusplus +} +#endif diff --git a/Platforms/platform-esp32/private/tactility/drivers/esp32_sdspi_fs.h b/Platforms/platform-esp32/private/tactility/drivers/esp32_sdspi_fs.h new file mode 100644 index 000000000..bb50eff59 --- /dev/null +++ b/Platforms/platform-esp32/private/tactility/drivers/esp32_sdspi_fs.h @@ -0,0 +1,22 @@ +// SPDX-License-Identifier: Apache-2.0 +#pragma once + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +struct Esp32SdspiConfig; +typedef void* Esp32SdspiHandle; + +Esp32SdspiHandle esp32_sdspi_fs_alloc(const struct Esp32SdspiConfig* config, int spi_host, const char* mount_path); +void esp32_sdspi_fs_free(Esp32SdspiHandle handle); +sdmmc_card_t* esp32_sdspi_fs_get_card(Esp32SdspiHandle handle); + +extern const FileSystemApi esp32_sdspi_fs_api; + +#ifdef __cplusplus +} +#endif diff --git a/Platforms/platform-esp32/source/drivers/esp32_sdcard.cpp b/Platforms/platform-esp32/source/drivers/esp32_sdcard.cpp new file mode 100644 index 000000000..0ca4eed16 --- /dev/null +++ b/Platforms/platform-esp32/source/drivers/esp32_sdcard.cpp @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: Apache-2.0 +#include +#include +#include +#include + +#include +#if SOC_SDMMC_HOST_SUPPORTED +#include +#endif + +extern "C" { + +sdmmc_card_t* esp32_sdcard_get_card(Device* device) { + auto* driver = device_get_driver(device); + if (driver_is_compatible(driver, "espressif,esp32-sdspi")) { + return esp32_sdspi_get_card(device); + } +#if SOC_SDMMC_HOST_SUPPORTED + if (driver_is_compatible(driver, "espressif,esp32-sdmmc")) { + return esp32_sdmmc_get_card(device); + } +#endif + return nullptr; +} + +} diff --git a/Platforms/platform-esp32/source/drivers/esp32_sdmmc.cpp b/Platforms/platform-esp32/source/drivers/esp32_sdmmc.cpp index d36fe5aeb..b1fe993ab 100644 --- a/Platforms/platform-esp32/source/drivers/esp32_sdmmc.cpp +++ b/Platforms/platform-esp32/source/drivers/esp32_sdmmc.cpp @@ -115,6 +115,7 @@ static error_t start(Device* device) { } data->file_system = file_system_add(&esp32_sdmmc_fs_api, data->esp32_sdmmc_fs_handle); + file_system_set_owner(data->file_system, device); if (file_system_mount(data->file_system) != ERROR_NONE) { // Error is not recoverable at the time, but it might be recoverable later, // so we don't return start() failure. diff --git a/Platforms/platform-esp32/source/drivers/esp32_sdspi.cpp b/Platforms/platform-esp32/source/drivers/esp32_sdspi.cpp new file mode 100644 index 000000000..cb42d283c --- /dev/null +++ b/Platforms/platform-esp32/source/drivers/esp32_sdspi.cpp @@ -0,0 +1,159 @@ +// SPDX-License-Identifier: Apache-2.0 +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define TAG "esp32_sdspi" + +#define GET_CONFIG(device) ((const struct Esp32SdspiConfig*)device->config) +#define GET_DATA(device) ((struct Esp32SdspiInternal*)device_get_driver_data(device)) + +extern "C" { + +struct Esp32SdspiInternal { + RecursiveMutex mutex = {}; + Esp32SdspiHandle fs_handle = nullptr; + FileSystem* file_system = nullptr; + GpioDescriptor* pin_cs_descriptor = nullptr; + GpioDescriptor* pin_cd_descriptor = nullptr; + GpioDescriptor* pin_wp_descriptor = nullptr; + GpioDescriptor* pin_int_descriptor = nullptr; + + Esp32SdspiInternal() { + recursive_mutex_construct(&mutex); + } + + ~Esp32SdspiInternal() { + cleanup_pins(); + recursive_mutex_destruct(&mutex); + if (fs_handle) esp32_sdspi_fs_free(fs_handle); + } + + void cleanup_pins() { + release_pin(&pin_cs_descriptor); + release_pin(&pin_cd_descriptor); + release_pin(&pin_wp_descriptor); + release_pin(&pin_int_descriptor); + } + + void lock() { recursive_mutex_lock(&mutex); } + void unlock() { recursive_mutex_unlock(&mutex); } +}; + +static error_t start(Device* device) { + LOG_I(TAG, "start %s", device->name); + + auto* parent = device_get_parent(device); + if (device_get_type(parent) != &SPI_CONTROLLER_TYPE) { + LOG_E(TAG, "Parent device is not an SPI controller"); + return ERROR_INVALID_STATE; + } + + auto* data = new (std::nothrow) Esp32SdspiInternal(); + if (!data) return ERROR_OUT_OF_MEMORY; + + data->lock(); + device_set_driver_data(device, data); + + auto* config = GET_CONFIG(device); + + bool pins_ok = + acquire_pin_or_set_null(config->pin_cs, &data->pin_cs_descriptor) && + acquire_pin_or_set_null(config->pin_cd, &data->pin_cd_descriptor) && + acquire_pin_or_set_null(config->pin_wp, &data->pin_wp_descriptor) && + acquire_pin_or_set_null(config->pin_int, &data->pin_int_descriptor); + + if (!pins_ok) { + LOG_E(TAG, "Failed to acquire one or more pins"); + data->cleanup_pins(); + device_set_driver_data(device, nullptr); + data->unlock(); + delete data; + return ERROR_RESOURCE; + } + + auto* spi_config = static_cast(parent->config); + data->fs_handle = esp32_sdspi_fs_alloc(config, spi_config->host, "/sdcard"); + if (!data->fs_handle) { + data->cleanup_pins(); + device_set_driver_data(device, nullptr); + data->unlock(); + delete data; + return ERROR_OUT_OF_MEMORY; + } + + data->file_system = file_system_add(&esp32_sdspi_fs_api, data->fs_handle); + file_system_set_owner(data->file_system, device); + if (file_system_mount(data->file_system) != ERROR_NONE) { + LOG_E(TAG, "Failed to mount SD card filesystem"); + } + + data->unlock(); + return ERROR_NONE; +} + +static error_t stop(Device* device) { + LOG_I(TAG, "stop %s", device->name); + auto* data = GET_DATA(device); + if (!data) return ERROR_NONE; + + data->lock(); + + if (file_system_is_mounted(data->file_system)) { + if (file_system_unmount(data->file_system) != ERROR_NONE) { + LOG_E(TAG, "Failed to unmount SD card filesystem"); + data->unlock(); + return ERROR_RESOURCE; + } + } + + file_system_remove(data->file_system); + data->file_system = nullptr; + + esp32_sdspi_fs_free(data->fs_handle); + data->fs_handle = nullptr; + + data->cleanup_pins(); + device_set_driver_data(device, nullptr); + + data->unlock(); + delete data; + return ERROR_NONE; +} + +sdmmc_card_t* esp32_sdspi_get_card(Device* device) { + if (!device_is_ready(device)) return nullptr; + auto* data = GET_DATA(device); + if (!data) return nullptr; + + data->lock(); + auto* card = esp32_sdspi_fs_get_card(data->fs_handle); + data->unlock(); + + return card; +} + +extern Module platform_esp32_module; + +Driver esp32_sdspi_driver = { + .name = "esp32_sdspi", + .compatible = (const char*[]) { "espressif,esp32-sdspi", nullptr }, + .start_device = start, + .stop_device = stop, + .api = nullptr, + .device_type = nullptr, + .owner = &platform_esp32_module, + .internal = nullptr +}; + +} // extern "C" diff --git a/Platforms/platform-esp32/source/drivers/esp32_sdspi_fs.cpp b/Platforms/platform-esp32/source/drivers/esp32_sdspi_fs.cpp new file mode 100644 index 000000000..78d8282cb --- /dev/null +++ b/Platforms/platform-esp32/source/drivers/esp32_sdspi_fs.cpp @@ -0,0 +1,126 @@ +// SPDX-License-Identifier: Apache-2.0 +#include +#include +#include +#include + +#include +#include +#include +#include + +#define TAG "esp32_sdspi_fs" + +#define GET_DATA(data) static_cast(data) + +struct Esp32SdspiFsData { + const std::string mount_path; + const Esp32SdspiConfig* config; + int spi_host; + sdmmc_card_t* card; + + Esp32SdspiFsData(const Esp32SdspiConfig* config, int spi_host, const std::string& mount_path) : + mount_path(mount_path), + config(config), + spi_host(spi_host), + card(nullptr) + {} +}; + +static gpio_num_t to_native_pin(GpioPinSpec pin_spec) { + if (pin_spec.gpio_controller == nullptr) { return GPIO_NUM_NC; } + return static_cast(pin_spec.pin); +} + +extern "C" { + +Esp32SdspiHandle esp32_sdspi_fs_alloc(const Esp32SdspiConfig* config, int spi_host, const char* mount_path) { + return new(std::nothrow) Esp32SdspiFsData(config, spi_host, mount_path); +} + +void esp32_sdspi_fs_free(Esp32SdspiHandle handle) { + delete GET_DATA(handle); +} + +sdmmc_card_t* esp32_sdspi_fs_get_card(Esp32SdspiHandle handle) { + return GET_DATA(handle)->card; +} + +static error_t mount(void* data) { + auto* fs_data = GET_DATA(data); + auto* config = fs_data->config; + + LOG_I(TAG, "Mounting %s", fs_data->mount_path.c_str()); + + esp_vfs_fat_sdmmc_mount_config_t mount_config = { + .format_if_mount_failed = false, + .max_files = 4, + .allocation_unit_size = 0, + .disk_status_check_enable = false, + .use_one_fat = false + }; + + sdspi_device_config_t slot_config = SDSPI_DEVICE_CONFIG_DEFAULT(); + slot_config.host_id = static_cast(fs_data->spi_host); + slot_config.gpio_cs = to_native_pin(config->pin_cs); + slot_config.gpio_cd = to_native_pin(config->pin_cd); + slot_config.gpio_wp = to_native_pin(config->pin_wp); + slot_config.gpio_int = to_native_pin(config->pin_int); + + sdmmc_host_t host = SDSPI_HOST_DEFAULT(); + host.max_freq_khz = static_cast(config->frequency_khz); + host.slot = fs_data->spi_host; + + esp_err_t result = esp_vfs_fat_sdspi_mount( + fs_data->mount_path.c_str(), &host, &slot_config, &mount_config, &fs_data->card + ); + + if (result != ESP_OK || fs_data->card == nullptr) { + if (result == ESP_FAIL) { + LOG_E(TAG, "Mounting failed. Ensure the card is formatted with FAT."); + } else { + LOG_E(TAG, "Mounting failed: %s", esp_err_to_name(result)); + } + return ERROR_UNDEFINED; + } + + sdmmc_card_print_info(stdout, fs_data->card); + LOG_I(TAG, "Mounted %s", fs_data->mount_path.c_str()); + return ERROR_NONE; +} + +static error_t unmount(void* data) { + auto* fs_data = GET_DATA(data); + LOG_I(TAG, "Unmounting %s", fs_data->mount_path.c_str()); + + if (esp_vfs_fat_sdcard_unmount(fs_data->mount_path.c_str(), fs_data->card) != ESP_OK) { + LOG_E(TAG, "Unmount failed for %s", fs_data->mount_path.c_str()); + return ERROR_UNDEFINED; + } + + fs_data->card = nullptr; + LOG_I(TAG, "Unmounted %s", fs_data->mount_path.c_str()); + return ERROR_NONE; +} + +static bool is_mounted(void* data) { + const auto* fs_data = GET_DATA(data); + if (fs_data->card == nullptr) return false; + return sdmmc_get_status(fs_data->card) == ESP_OK; +} + +static error_t get_path(void* data, char* out_path, size_t out_path_size) { + const auto* fs_data = GET_DATA(data); + if (fs_data->mount_path.size() >= out_path_size) return ERROR_BUFFER_OVERFLOW; + strncpy(out_path, fs_data->mount_path.c_str(), out_path_size); + return ERROR_NONE; +} + +const FileSystemApi esp32_sdspi_fs_api = { + .mount = mount, + .unmount = unmount, + .is_mounted = is_mounted, + .get_path = get_path +}; + +} // extern "C" diff --git a/Platforms/platform-esp32/source/module.cpp b/Platforms/platform-esp32/source/module.cpp index b6a3fc670..0bd3cfd30 100644 --- a/Platforms/platform-esp32/source/module.cpp +++ b/Platforms/platform-esp32/source/module.cpp @@ -18,6 +18,7 @@ extern Driver esp32_i2s_driver; #if SOC_SDMMC_HOST_SUPPORTED extern Driver esp32_sdmmc_driver; #endif +extern Driver esp32_sdspi_driver; extern Driver esp32_spi_driver; extern Driver esp32_uart_driver; extern Driver esp32_grove_driver; @@ -44,6 +45,7 @@ static error_t start() { #if SOC_SDMMC_HOST_SUPPORTED check(driver_construct_add(&esp32_sdmmc_driver) == ERROR_NONE); #endif + check(driver_construct_add(&esp32_sdspi_driver) == ERROR_NONE); check(driver_construct_add(&esp32_spi_driver) == ERROR_NONE); check(driver_construct_add(&esp32_uart_driver) == ERROR_NONE); check(driver_construct_add(&esp32_grove_driver) == ERROR_NONE); @@ -84,6 +86,7 @@ static error_t stop() { #if SOC_SDMMC_HOST_SUPPORTED check(driver_remove_destruct(&esp32_sdmmc_driver) == ERROR_NONE); #endif + check(driver_remove_destruct(&esp32_sdspi_driver) == ERROR_NONE); check(driver_remove_destruct(&esp32_spi_driver) == ERROR_NONE); check(driver_remove_destruct(&esp32_uart_driver) == ERROR_NONE); check(driver_remove_destruct(&esp32_grove_driver) == ERROR_NONE); diff --git a/Tactility/Include/Tactility/hal/sdcard/SpiSdCardDevice.h b/Tactility/Include/Tactility/hal/sdcard/SpiSdCardDevice.h deleted file mode 100644 index cb9d08158..000000000 --- a/Tactility/Include/Tactility/hal/sdcard/SpiSdCardDevice.h +++ /dev/null @@ -1,104 +0,0 @@ -#ifdef ESP_PLATFORM - -#pragma once - -#include "SdCardDevice.h" -#include "Tactility/kernel/SpiDeviceLock.h" - -#include -#include - -#include -#include -#include - -namespace tt::hal::sdcard { - -/** - * SD card interface at the default SPI interface - */ -class SpiSdCardDevice final : public SdCardDevice { - -public: - - struct Config { - Config( - gpio_num_t spiPinCs, - gpio_num_t spiPinCd, - gpio_num_t spiPinWp, - gpio_num_t spiPinInt, - MountBehaviour mountBehaviourAtBoot, - /** When customLock is a nullptr, use the SPI default one */ - std::shared_ptr customLock = nullptr, - std::vector csPinWorkAround = std::vector(), - spi_host_device_t spiHost = SPI2_HOST, - int spiFrequencyKhz = SDMMC_FREQ_DEFAULT - ) : spiFrequencyKhz(spiFrequencyKhz), - spiPinCs(spiPinCs), - spiPinCd(spiPinCd), - spiPinWp(spiPinWp), - spiPinInt(spiPinInt), - mountBehaviourAtBoot(mountBehaviourAtBoot), - customLock(customLock ? std::move(customLock) : nullptr), - csPinWorkAround(std::move(csPinWorkAround)), - spiHost(spiHost) - {} - - int spiFrequencyKhz; - gpio_num_t spiPinCs; // Clock - gpio_num_t spiPinCd; // Card detect - gpio_num_t spiPinWp; // Write-protect - gpio_num_t spiPinInt; // Interrupt - MountBehaviour mountBehaviourAtBoot; - std::shared_ptr customLock; // can be nullptr - std::vector csPinWorkAround; - spi_host_device_t spiHost; - bool formatOnMountFailed = false; - uint16_t maxOpenFiles = 4; - uint16_t allocUnitSize = 16 * 1024; - bool statusCheckEnabled = false; - }; - -private: - - std::string mountPath; - sdmmc_card_t* card = nullptr; - std::shared_ptr config; - std::shared_ptr lock; - - bool applyGpioWorkAround(); - bool mountInternal(const std::string& mountPath); - -public: - - explicit SpiSdCardDevice(std::unique_ptr newConfig, ::Device* spiController) : SdCardDevice(newConfig->mountBehaviourAtBoot), - config(std::move(newConfig)) - { - if (config->customLock == nullptr) { - auto spi_lock = std::make_shared(spiController); - lock = std::static_pointer_cast(spi_lock); - } else { - lock = config->customLock; - } - } - - std::string getName() const override { return "SD Card"; } - std::string getDescription() const override { return "SD card via SPI interface"; } - - bool mount(const std::string& mountPath) override; - bool unmount() override; - std::string getMountPath() const override { return mountPath; } - - std::shared_ptr getLock() const override { - return lock; - } - - State getState(TickType_t timeout) const override; - - /** return card when mounted, otherwise return nullptr */ - sdmmc_card_t* getCard() { return card; } -}; - -} - -#endif diff --git a/Tactility/Source/hal/sdcard/SdCard.cpp b/Tactility/Source/hal/sdcard/SdCard.cpp index 8a284ea4f..63aaa74bc 100644 --- a/Tactility/Source/hal/sdcard/SdCard.cpp +++ b/Tactility/Source/hal/sdcard/SdCard.cpp @@ -1,26 +1,41 @@ -#include #include "Tactility/hal/sdcard/SdCardDevice.h" +#include + +#include +#include + +#include +#include + namespace tt::hal::sdcard { -std::shared_ptr find(const std::string& path) { - auto sdcards = findDevices(Device::Type::SdCard); - for (auto& sdcard : sdcards) { - if (sdcard->isMounted() && path.starts_with(sdcard->getMountPath())) { - return sdcard; - } - } - - return nullptr; -} - std::shared_ptr findSdCardLock(const std::string& path) { - auto sdcard = find(path); - if (sdcard != nullptr) { - return sdcard->getLock(); - } + struct Ctx { + const std::string& path; + std::shared_ptr result; + }; + Ctx ctx = { path, nullptr }; - return nullptr; + file_system_for_each(&ctx, [](FileSystem* fs, void* context) { + auto* c = static_cast(context); + char mount_path[64]; + if (file_system_get_path(fs, mount_path, sizeof(mount_path)) != ERROR_NONE) return true; + if (!c->path.starts_with(mount_path)) return true; + + auto* owner = file_system_get_owner(fs); + if (owner != nullptr) { + // Check for I2C controller: if it has more than 2 children, assume it's the display + // TODO: Improve this + auto* parent = device_get_parent(owner); + if (parent != nullptr && device_get_child_count(parent) >= 2) { + c->result = lvgl::getSyncLock(); + } + } + return false; + }); + + return ctx.result; } } diff --git a/Tactility/Source/hal/sdcard/SpiSdCardDevice.cpp b/Tactility/Source/hal/sdcard/SpiSdCardDevice.cpp deleted file mode 100644 index 7cdcc52bc..000000000 --- a/Tactility/Source/hal/sdcard/SpiSdCardDevice.cpp +++ /dev/null @@ -1,156 +0,0 @@ -#ifdef ESP_PLATFORM - -#include -#include -#include - -#include -#include - -namespace tt::hal::sdcard { - -static const auto LOGGER = Logger("SpiSdCardDevice"); - -/** - * Before we can initialize the sdcard's SPI communications, we have to set all - * other SPI pins on the board high. - * See https://github.com/espressif/esp-idf/issues/1597 - * See https://github.com/Xinyuan-LilyGO/T-Deck/blob/master/examples/UnitTest/UnitTest.ino - * @return success result - */ -bool SpiSdCardDevice::applyGpioWorkAround() { - LOGGER.info("applyGpioWorkAround"); - - uint64_t pin_bit_mask = config->spiPinCs != GPIO_NUM_NC ? BIT64(config->spiPinCs) : 0; - for (auto const& pin: config->csPinWorkAround) { - pin_bit_mask |= BIT64(pin); - } - - // Nothing to do - if (pin_bit_mask == 0) { - return true; - } - - if (!gpio::configureWithPinBitmask(pin_bit_mask, gpio::Mode::Output, false, false)) { - LOGGER.error("GPIO work-around failed"); - return false; - } - - for (auto const& pin: config->csPinWorkAround) { - if (!gpio::setLevel(pin, true)) { - LOGGER.error("Failed to set board CS pin high"); - return false; - } - } - - return true; -} - -bool SpiSdCardDevice::mountInternal(const std::string& newMountPath) { - LOGGER.info("Mounting {}", newMountPath); - - esp_vfs_fat_sdmmc_mount_config_t mount_config = { - .format_if_mount_failed = config->formatOnMountFailed, - .max_files = config->maxOpenFiles, - .allocation_unit_size = config->allocUnitSize, - .disk_status_check_enable = config->statusCheckEnabled, - .use_one_fat = false - }; - - // Init without card detect (CD) and write protect (WD) - sdspi_device_config_t slot_config = SDSPI_DEVICE_CONFIG_DEFAULT(); - slot_config.host_id = config->spiHost; - slot_config.gpio_cs = config->spiPinCs; - slot_config.gpio_cd = config->spiPinCd; - slot_config.gpio_wp = config->spiPinWp; - slot_config.gpio_int = config->spiPinInt; - - sdmmc_host_t host = SDSPI_HOST_DEFAULT(); - // The following value is from T-Deck repo's UnitTest.ino project: - // https://github.com/Xinyuan-LilyGO/T-Deck/blob/master/examples/UnitTest/UnitTest.ino - // Observation: Using this automatically sets the bus to 20MHz - host.max_freq_khz = config->spiFrequencyKhz; - host.slot = config->spiHost; - - esp_err_t result = esp_vfs_fat_sdspi_mount(newMountPath.c_str(), &host, &slot_config, &mount_config, &card); - - if (result != ESP_OK || card == nullptr) { - if (result == ESP_FAIL) { - LOGGER.error("Mounting failed. Ensure the card is formatted with FAT."); - } else { - LOGGER.error("Mounting failed ({})", esp_err_to_name(result)); - } - return false; - } - - mountPath = newMountPath; - - return true; -} - -bool SpiSdCardDevice::mount(const std::string& newMountPath) { - auto lock = getLock()->asScopedLock(); - lock.lock(); - - if (!applyGpioWorkAround()) { - LOGGER.error("Failed to apply GPIO work-around"); - return false; - } - - if (mountInternal(newMountPath)) { - LOGGER.info("Mounted at {}", newMountPath); - sdmmc_card_print_info(stdout, card); - return true; - } else { - LOGGER.error("Mount failed for {}", newMountPath); - return false; - } -} - -bool SpiSdCardDevice::unmount() { - auto lock = getLock()->asScopedLock(); - lock.lock(); - - if (card == nullptr) { - LOGGER.error("Can't unmount: not mounted"); - return false; - } - - if (esp_vfs_fat_sdcard_unmount(mountPath.c_str(), card) != ESP_OK) { - LOGGER.error("Unmount failed for {}", mountPath); - return false; - } - - LOGGER.info("Unmounted {}", mountPath); - mountPath = ""; - card = nullptr; - return true; -} - -// TODO: Refactor to "bool getStatus(Status* status)" method so that it can fail when the lvgl lock fails -SdCardDevice::State SpiSdCardDevice::getState(TickType_t timeout) const { - if (card == nullptr) { - return State::Unmounted; - } - - /** - * The SD card and the screen are on the same SPI bus. - * 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. - */ - auto lock = getLock()->asScopedLock(); - bool locked = lock.lock(timeout); - if (!locked) { - return State::Timeout; - } - - if (sdmmc_get_status(card) != ESP_OK) { - return State::Error; - } - - return State::Mounted; -} - -} - -#endif \ No newline at end of file diff --git a/Tactility/Source/hal/usb/Usb.cpp b/Tactility/Source/hal/usb/Usb.cpp index c52a0c52a..4a5155e95 100644 --- a/Tactility/Source/hal/usb/Usb.cpp +++ b/Tactility/Source/hal/usb/Usb.cpp @@ -3,11 +3,12 @@ #include #include -#include #include #include -#include +#include +#include +#include namespace tt::hal::usb { @@ -24,41 +25,23 @@ static Mode currentMode = Mode::Default; static RTC_NOINIT_ATTR BootModeData bootModeData; sdmmc_card_t* getCard() { - sdmmc_card_t* sdcard = nullptr; + sdmmc_card_t* card = nullptr; - // Find old HAL SD card device: - auto sdcards = findDevices(Device::Type::SdCard); - for (auto& device : sdcards) { - auto sdcard_device= std::static_pointer_cast(device); - if (sdcard_device != nullptr && sdcard_device->isMounted() && sdcard_device->getCard() != nullptr) { - sdcard = sdcard_device->getCard(); - break; - } - } + device_for_each(&card, [](auto* device, void* context) { + auto* driver = device_get_driver(device); + if (driver == nullptr) return true; + if (!driver_is_compatible(driver, "espressif,esp32-sdspi") && + !driver_is_compatible(driver, "espressif,esp32-sdmmc")) return true; + auto** out = static_cast(context); + *out = esp32_sdcard_get_card(device); + return *out == nullptr; + }); -#if SOC_SDMMC_HOST_SUPPORTED - // Find ESP32 SDMMC device: - if (sdcard == nullptr) { - device_for_each(&sdcard, [](auto* device, void* context) { - if (device_is_ready(device) && device_is_compatible(device, "espressif,esp32-sdmmc")) { - auto** sdcard = static_cast(context); - auto* sdmmc_card = esp32_sdmmc_get_card(device); - if (sdmmc_card) { - *sdcard = sdmmc_card; - return false; - } - return true; - } - return true; - }); - } -#endif - - if (sdcard == nullptr) { + if (card == nullptr) { LOGGER.warn("Couldn't find a mounted SD card"); } - return sdcard; + return card; } static bool canStartNewMode() { diff --git a/Tactility/Source/service/statusbar/Statusbar.cpp b/Tactility/Source/service/statusbar/Statusbar.cpp index 7ae4619e6..20afd61ba 100644 --- a/Tactility/Source/service/statusbar/Statusbar.cpp +++ b/Tactility/Source/service/statusbar/Statusbar.cpp @@ -2,10 +2,9 @@ #include #include -#include #include #include -#include +#include #include #include #include @@ -239,11 +238,21 @@ class StatusbarService final : public Service { } void updateSdCardIcon() { - auto* sdcard_fs = findSdcardFileSystem(false); - // TODO: Support multiple SD cards - if (sdcard_fs != nullptr) { - auto mounted = file_system_is_mounted(sdcard_fs); - auto* desired_icon = getSdCardStatusIcon(mounted); + struct SdCardState { bool found; bool mounted; }; + SdCardState state = { false, false }; + + file_system_for_each(&state, [](FileSystem* fs, void* context) { + auto* s = static_cast(context); + char path[64]; + if (file_system_get_path(fs, path, sizeof(path)) != ERROR_NONE) return true; + if (strncmp(path, "/sdcard", 7) != 0) return true; + s->found = true; + s->mounted = file_system_is_mounted(fs); + return false; + }); + + if (state.found) { + auto* desired_icon = getSdCardStatusIcon(state.mounted); if (sdcard_last_icon != desired_icon) { lvgl::statusbar_icon_set_image(sdcard_icon_id, desired_icon); lvgl::statusbar_icon_set_visibility(sdcard_icon_id, true); diff --git a/TactilityKernel/bindings/display-placeholder.yaml b/TactilityKernel/bindings/display-placeholder.yaml new file mode 100644 index 000000000..aab1050c0 --- /dev/null +++ b/TactilityKernel/bindings/display-placeholder.yaml @@ -0,0 +1,5 @@ +description: Display placeholder + +compatible: "display-placeholder" + +properties: {} diff --git a/TactilityKernel/bindings/spi-peripheral.yaml b/TactilityKernel/bindings/spi-peripheral.yaml new file mode 100644 index 000000000..baa052a5b --- /dev/null +++ b/TactilityKernel/bindings/spi-peripheral.yaml @@ -0,0 +1,9 @@ +description: SPI peripheral with chip select + +compatible: "spi-peripheral" + +properties: + pin-cs: + type: phandle-array + required: true + description: Chip select GPIO diff --git a/TactilityKernel/include/tactility/bindings/display_placeholder.h b/TactilityKernel/include/tactility/bindings/display_placeholder.h new file mode 100644 index 000000000..9a7466c02 --- /dev/null +++ b/TactilityKernel/include/tactility/bindings/display_placeholder.h @@ -0,0 +1,15 @@ +// SPDX-License-Identifier: Apache-2.0 +#pragma once + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +DEFINE_DEVICETREE(display_placeholder, struct DisplayPlaceholderConfig) + +#ifdef __cplusplus +} +#endif diff --git a/TactilityKernel/include/tactility/bindings/spi_peripheral.h b/TactilityKernel/include/tactility/bindings/spi_peripheral.h new file mode 100644 index 000000000..30cccd85f --- /dev/null +++ b/TactilityKernel/include/tactility/bindings/spi_peripheral.h @@ -0,0 +1,15 @@ +// SPDX-License-Identifier: Apache-2.0 +#pragma once + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +DEFINE_DEVICETREE(spi_peripheral, struct SpiPeripheralConfig) + +#ifdef __cplusplus +} +#endif diff --git a/TactilityKernel/include/tactility/device.h b/TactilityKernel/include/tactility/device.h index e5313b7ee..1ebc97aaa 100644 --- a/TactilityKernel/include/tactility/device.h +++ b/TactilityKernel/include/tactility/device.h @@ -248,6 +248,13 @@ void device_for_each(void* callback_context, bool(*on_device)(struct Device* dev */ void device_for_each_child(struct Device* device, void* callback_context, bool(*on_device)(struct Device* device, void* context)); +/** + * @brief Get the number of child devices. + * @param[in] device non-null device pointer + * @return the number of children + */ +size_t device_get_child_count(struct Device* device); + /** * Iterate through all the known devices of a specific type * diff --git a/TactilityKernel/include/tactility/drivers/display.h b/TactilityKernel/include/tactility/drivers/display.h new file mode 100644 index 000000000..982e679ef --- /dev/null +++ b/TactilityKernel/include/tactility/drivers/display.h @@ -0,0 +1,14 @@ +// SPDX-License-Identifier: Apache-2.0 +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +extern const struct DeviceType DISPLAY_TYPE; + +#ifdef __cplusplus +} +#endif diff --git a/TactilityKernel/include/tactility/drivers/display_placeholder.h b/TactilityKernel/include/tactility/drivers/display_placeholder.h new file mode 100644 index 000000000..9415e8333 --- /dev/null +++ b/TactilityKernel/include/tactility/drivers/display_placeholder.h @@ -0,0 +1,16 @@ +// SPDX-License-Identifier: Apache-2.0 +#pragma once + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +struct DisplayPlaceholderConfig { + uint8_t _unused; +}; + +#ifdef __cplusplus +} +#endif diff --git a/TactilityKernel/include/tactility/drivers/spi_peripheral.h b/TactilityKernel/include/tactility/drivers/spi_peripheral.h new file mode 100644 index 000000000..e7b1c3545 --- /dev/null +++ b/TactilityKernel/include/tactility/drivers/spi_peripheral.h @@ -0,0 +1,25 @@ +// SPDX-License-Identifier: Apache-2.0 +#pragma once + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +struct SpiPeripheralConfig { + struct GpioPinSpec pin_cs; +}; + +struct SpiPeripheralApi { + struct GpioDescriptor* (*get_cs_descriptor)(struct Device* device); +}; + +struct GpioDescriptor* spi_peripheral_get_cs_descriptor(struct Device* device); + +extern const struct DeviceType SPI_PERIPHERAL_TYPE; + +#ifdef __cplusplus +} +#endif diff --git a/TactilityKernel/include/tactility/filesystem/file_system.h b/TactilityKernel/include/tactility/filesystem/file_system.h index 40a6bec75..4f7710155 100644 --- a/TactilityKernel/include/tactility/filesystem/file_system.h +++ b/TactilityKernel/include/tactility/filesystem/file_system.h @@ -101,6 +101,20 @@ bool file_system_is_mounted(struct FileSystem* fs); */ error_t file_system_get_path(struct FileSystem* fs, char* out_path, size_t out_path_size); +/** + * @brief Sets the owner device of the file system. + * @param[in] fs the FileSystem object + * @param[in] owner the owning device, or NULL + */ +void file_system_set_owner(struct FileSystem* fs, struct Device* owner); + +/** + * @brief Gets the owner device of the file system. + * @param[in] fs the FileSystem object + * @return the owning device, or NULL if not set + */ +struct Device* file_system_get_owner(struct FileSystem* fs); + #ifdef __cplusplus } #endif diff --git a/TactilityKernel/source/device.cpp b/TactilityKernel/source/device.cpp index d01cd192c..7bb7f100c 100644 --- a/TactilityKernel/source/device.cpp +++ b/TactilityKernel/source/device.cpp @@ -328,6 +328,10 @@ void device_for_each_child(Device* device, void* callbackContext, bool(*on_devic } } +size_t device_get_child_count(Device* device) { + return device->internal->children.size(); +} + void device_for_each_of_type(const DeviceType* type, void* callbackContext, bool(*on_device)(Device* device, void* context)) { ledger_lock(); for (auto* device : ledger.devices) { diff --git a/TactilityKernel/source/drivers/display.cpp b/TactilityKernel/source/drivers/display.cpp new file mode 100644 index 000000000..3b49e4963 --- /dev/null +++ b/TactilityKernel/source/drivers/display.cpp @@ -0,0 +1,10 @@ +// SPDX-License-Identifier: Apache-2.0 +#include + +extern "C" { + +const struct DeviceType DISPLAY_TYPE { + .name = "display" +}; + +} diff --git a/TactilityKernel/source/drivers/display_placeholder.cpp b/TactilityKernel/source/drivers/display_placeholder.cpp new file mode 100644 index 000000000..948acdd47 --- /dev/null +++ b/TactilityKernel/source/drivers/display_placeholder.cpp @@ -0,0 +1,26 @@ +// SPDX-License-Identifier: Apache-2.0 +#include +#include +#include +#include +#include + +extern "C" { + +static error_t start(Device*) { return ERROR_NONE; } +static error_t stop(Device*) { return ERROR_NONE; } + +extern Module root_module; + +Driver display_placeholder_driver = { + .name = "display_placeholder", + .compatible = (const char*[]) { "display-placeholder", nullptr }, + .start_device = start, + .stop_device = stop, + .api = nullptr, + .device_type = &DISPLAY_TYPE, + .owner = &root_module, + .internal = nullptr +}; + +} diff --git a/TactilityKernel/source/drivers/spi_peripheral.cpp b/TactilityKernel/source/drivers/spi_peripheral.cpp new file mode 100644 index 000000000..3b7b1b600 --- /dev/null +++ b/TactilityKernel/source/drivers/spi_peripheral.cpp @@ -0,0 +1,77 @@ +// SPDX-License-Identifier: Apache-2.0 +#include +#include +#include +#include +#include +#include + +#define TAG "spi_peripheral" + +#define GET_CONFIG(device) ((const struct SpiPeripheralConfig*)device->config) + +extern "C" { + +static error_t start(Device* device) { + auto* parent = device_get_parent(device); + if (parent == nullptr || device_get_type(parent) != &SPI_CONTROLLER_TYPE) { + LOG_E(TAG, "Parent is not an SPI controller"); + return ERROR_INVALID_STATE; + } + + auto* config = GET_CONFIG(device); + GpioDescriptor* cs = nullptr; + if (config->pin_cs.gpio_controller != nullptr) { + cs = gpio_descriptor_acquire(config->pin_cs.gpio_controller, config->pin_cs.pin, GPIO_OWNER_SPI); + if (cs == nullptr) { + LOG_E(TAG, "Failed to acquire CS pin"); + return ERROR_RESOURCE; + } + gpio_descriptor_set_flags(cs, GPIO_FLAG_DIRECTION_OUTPUT); + gpio_descriptor_set_level(cs, true); + } + + device_set_driver_data(device, cs); + return ERROR_NONE; +} + +static error_t stop(Device* device) { + auto* cs = static_cast(device_get_driver_data(device)); + if (cs != nullptr) { + gpio_descriptor_release(cs); + } + device_set_driver_data(device, nullptr); + return ERROR_NONE; +} + +static GpioDescriptor* get_cs_descriptor(Device* device) { + return static_cast(device_get_driver_data(device)); +} + +static const SpiPeripheralApi spi_peripheral_api = { + .get_cs_descriptor = get_cs_descriptor +}; + +GpioDescriptor* spi_peripheral_get_cs_descriptor(Device* device) { + auto* driver = device_get_driver(device); + return ((const SpiPeripheralApi*)driver->api)->get_cs_descriptor(device); +} + +const DeviceType SPI_PERIPHERAL_TYPE = { + .name = "spi_peripheral" +}; + +extern Module root_module; + +Driver spi_peripheral_driver = { + .name = "spi_peripheral", + .compatible = (const char*[]) { "spi-peripheral", nullptr }, + .start_device = start, + .stop_device = stop, + .api = &spi_peripheral_api, + .device_type = &SPI_PERIPHERAL_TYPE, + .owner = &root_module, + .internal = nullptr +}; + +} diff --git a/TactilityKernel/source/filesystem/file_system.cpp b/TactilityKernel/source/filesystem/file_system.cpp index d22dd31a7..453105abb 100644 --- a/TactilityKernel/source/filesystem/file_system.cpp +++ b/TactilityKernel/source/filesystem/file_system.cpp @@ -1,6 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 #include +#include #include #include #include @@ -10,6 +11,7 @@ struct FileSystem { const FileSystemApi* api; void* data; + Device* owner; }; // Global list of file systems and its mutex @@ -42,6 +44,7 @@ FileSystem* file_system_add(const FileSystemApi* fs_api, void* data) { check(fs != nullptr); fs->api = fs_api; fs->data = data; + fs->owner = nullptr; ledger.file_systems.push_back(fs); ledger.unlock(); @@ -90,4 +93,12 @@ error_t file_system_get_path(FileSystem* fs, char* out_path, size_t out_path_siz return fs->api->get_path(fs->data, out_path, out_path_size); } +void file_system_set_owner(FileSystem* fs, Device* owner) { + fs->owner = owner; +} + +Device* file_system_get_owner(FileSystem* fs) { + return fs->owner; +} + } diff --git a/TactilityKernel/source/kernel_init.cpp b/TactilityKernel/source/kernel_init.cpp index b13ed71b5..9c99278f2 100644 --- a/TactilityKernel/source/kernel_init.cpp +++ b/TactilityKernel/source/kernel_init.cpp @@ -14,6 +14,10 @@ extern const ModuleSymbol KERNEL_SYMBOLS[]; static error_t start() { extern Driver root_driver; if (driver_construct_add(&root_driver) != ERROR_NONE) return ERROR_RESOURCE; + extern Driver display_placeholder_driver; + if (driver_construct_add(&display_placeholder_driver) != ERROR_NONE) return ERROR_RESOURCE; + extern Driver spi_peripheral_driver; + if (driver_construct_add(&spi_peripheral_driver) != ERROR_NONE) return ERROR_RESOURCE; return ERROR_NONE; }