Compare commits

..

11 Commits

Author SHA1 Message Date
Adolfo Reyna 99ac246ab5 Associate .mp3 files with the Mp3Player application in Files browser 2026-06-28 22:24:45 -04:00
Ken Van Hoeylandt 599fa46766 Driver improvements (#535)
- New drivers:
  - SD SPI
  - spi_peripheral
  - touch_placeholder
  - display_placeholder
- Devicetree compiler:
  - Implement phandle-arrays
  - Implement device addresses
- Add placeholder drivers to all devices with a SPI display
- SPI driver: add `cs-pins` and set them to high on driver start
- FileSystem: add `file_system_set_owner()` and `file_system_get_owner()`
- File locking is now checking if the related `FileSystem` is part of a shared SPI bus
- Add `device_get_child_count()`
- SDMMC driver: Remove default of `slot` value
- Fix for Crowpanel Basic 3.5" display (add delay to booting)
- Fix for LilyGO T-HMI SD card mounting (delayed mounting by disabling it initially in the dts)
2026-06-27 17:32:05 +02:00
Ken Van Hoeylandt e50659a3fb Fix for Gt911Touch. (#538) 2026-06-22 08:18:55 +02:00
Ken Van Hoeylandt aeccc15ab6 Fix for Gt911Touch when using new I2C driver. (#536)
Committing this straight to main branch to avoid wasting pipelines.
2026-06-21 22:20:07 +02:00
Shadowtrance 594b8bd27e Smart tab5keyboard (#533) 2026-06-19 22:14:07 +02:00
Ken Van Hoeylandt e8b9a1f2a9 Fixes and improvements (#534) 2026-06-19 20:46:56 +02:00
Ken Van Hoeylandt a35c88c8fd Grove driver, I2C migrations, bugfixes and docs (#532) 2026-06-19 00:52:31 +02:00
Ken Van Hoeylandt 8dabda2b5b Implement new I2C driver (#531) 2026-06-12 18:46:22 +02:00
Shadowtrance 8dd9bee8d0 M5Stack Tab5 TinyUSB MSC support implemented (#530) 2026-06-10 22:39:36 +02:00
Ken Van Hoeylandt 543390a977 Fix for CoreS3 touch (#529)
The FT6 driver does a hardware ID check, which fails on the CoreS3 but
not on Stackchan for some reason. FT5 works on Stackchan, so we'll use
that for all devices, just like M5GFX does.
2026-06-10 00:24:18 +02:00
Shadowtrance 62266dff58 Tab5 Keyboard (#528) 2026-06-09 23:19:56 +02:00
325 changed files with 4158 additions and 2894 deletions
+3
View File
@@ -23,3 +23,6 @@ dependencies.lock
sdkconfig.board.*.dev sdkconfig.board.*.dev
.tactility/ .tactility/
.caveman.json
.ai/mcp
@@ -45,6 +45,7 @@ def parse_binding(file_path: str, binding_dirs: list[str]) -> Binding:
required=details.get('required', False), required=details.get('required', False),
description=details.get('description', '').strip(), description=details.get('description', '').strip(),
default=details.get('default', None), default=details.get('default', None),
element_type=details.get('element-type', None),
) )
properties_dict[name] = prop properties_dict[name] = prop
filename = os.path.basename(file_path) filename = os.path.basename(file_path)
@@ -80,7 +80,7 @@ def property_to_string(property: DeviceProperty, devices: list[Device]) -> str:
return "{ " + ",".join(value_list) + " }" return "{ " + ",".join(value_list) + " }"
elif type == "phandle": elif type == "phandle":
return find_phandle(devices, property.value) return find_phandle(devices, property.value)
elif type == "phandle-array": elif type == "phandles":
value_list = list() value_list = list()
if isinstance(property.value, list): if isinstance(property.value, list):
for item in property.value: for item in property.value:
@@ -93,10 +93,26 @@ def property_to_string(property: DeviceProperty, devices: list[Device]) -> str:
# If it's a string, assume it's a #define and show it as-is # If it's a string, assume it's a #define and show it as-is
return property.value return property.value
else: else:
raise Exception(f"Unsupported phandle-array type for {property.value}") raise Exception(f"Unsupported phandles type for {property.name} with value {property.value} ")
else: else:
raise DevicetreeException(f"property_to_string() has an unsupported type: {type}") raise DevicetreeException(f"property_to_string() has an unsupported type: {type}")
def resolve_phandle_array_entries(device_property, devices):
"""Convert a phandle-array DTS property into a list of C initializer strings."""
entries = []
if device_property.type == "phandle-array":
items = device_property.value
elif device_property.type == "values":
items = [PropertyValue(type="values", value=device_property.value)]
else:
return []
for item in items:
if isinstance(item, PropertyValue):
entries.append(property_to_string(DeviceProperty(name="", type=item.type, value=item.value), devices))
else:
entries.append(str(item))
return entries
def resolve_parameters_from_bindings(device: Device, bindings: list[Binding], devices: list[Device]) -> list: def resolve_parameters_from_bindings(device: Device, bindings: list[Binding], devices: list[Device]) -> list:
compatible_property = find_device_property(device, "compatible") compatible_property = find_device_property(device, "compatible")
if compatible_property is None: if compatible_property is None:
@@ -119,11 +135,32 @@ def resolve_parameters_from_bindings(device: Device, bindings: list[Binding], de
if device_property.name not in binding_property_names: if device_property.name not in binding_property_names:
raise DevicetreeException(f"Device '{device.node_name}' has invalid property '{device_property.name}'") raise DevicetreeException(f"Device '{device.node_name}' has invalid property '{device_property.name}'")
# Allocate total expected configuration arguments node_name = get_device_node_name_safe(device)
result = [0] * len(binding_properties) result = []
for index, binding_property in enumerate(binding_properties): phandle_arrays = []
for binding_property in binding_properties:
device_property = find_device_property(device, binding_property.name) device_property = find_device_property(device, binding_property.name)
# No property specified in DTS, use binding defaults
if binding_property.type == "phandle-array":
if binding_property.element_type is None:
raise DevicetreeException(f"phandle-array property '{binding_property.name}' requires 'element-type' in binding")
prop_safe = binding_property.name.replace("-", "_")
array_var = f"{node_name}_{prop_safe}"
if device_property is not None:
entries = resolve_phandle_array_entries(device_property, devices)
phandle_arrays.append((array_var, binding_property.element_type, entries))
result.append(f"({binding_property.element_type}*){array_var}")
result.append(str(len(entries)))
elif binding_property.default is not None:
result.append("NULL")
result.append("0")
elif binding_property.required:
raise DevicetreeException(f"device {device.node_name} doesn't have property '{binding_property.name}'")
else:
result.append("NULL")
result.append("0")
continue
if device_property is None: if device_property is None:
if binding_property.default is not None: if binding_property.default is not None:
temp_prop = DeviceProperty( temp_prop = DeviceProperty(
@@ -131,30 +168,38 @@ def resolve_parameters_from_bindings(device: Device, bindings: list[Binding], de
type=binding_property.type, type=binding_property.type,
value=binding_property.default value=binding_property.default
) )
result[index] = property_to_string(temp_prop, devices) result.append(property_to_string(temp_prop, devices))
elif binding_property.required: elif binding_property.required:
raise DevicetreeException(f"device {device.node_name} doesn't have property '{binding_property.name}'") raise DevicetreeException(f"device {device.node_name} doesn't have property '{binding_property.name}'")
elif binding_property.type == "bool" or binding_property.type == "boolean": elif binding_property.type == "bool" or binding_property.type == "boolean":
if binding_property.default == "true" or binding_property.default == None: if binding_property.default == "true" or binding_property.default == None:
result[index] = "true" result.append("true")
else: # Explicit or implied false else:
result[index] = "false" result.append("false")
else: else:
raise DevicetreeException(f"Device {device.node_name} doesn't have property '{binding_property.name}' and no default value is set") raise DevicetreeException(f"Device {device.node_name} doesn't have property '{binding_property.name}' and no default value is set")
else: else:
result[index] = property_to_string(device_property, devices) result.append(property_to_string(device_property, devices))
return result
return result, phandle_arrays
def write_config(file, device: Device, bindings: list[Binding], devices: list[Device], type_name: str): def write_config(file, device: Device, bindings: list[Binding], devices: list[Device], type_name: str):
node_name = get_device_node_name_safe(device) node_name = get_device_node_name_safe(device)
config_type = f"{type_name}_config_dt" config_type = f"{type_name}_config_dt"
config_variable_name = f"{node_name}_config" config_variable_name = f"{node_name}_config"
config_params, phandle_arrays = resolve_parameters_from_bindings(device, bindings, devices)
# Write phandle-array variables before the config struct
for array_var, element_type, entries in phandle_arrays:
entries_str = ", ".join(entries)
file.write(f"static {element_type} {array_var}[] = {{ {entries_str} }};\n")
file.write(f"static const {config_type} {config_variable_name}" " = {\n") file.write(f"static const {config_type} {config_variable_name}" " = {\n")
config_params = resolve_parameters_from_bindings(device, bindings, devices)
# Indent all params # Indent all params
for index, config_param in enumerate(config_params): for index, config_param in enumerate(config_params):
config_params[index] = f"\t{config_param}" config_params[index] = f"\t{config_param}"
# Join with command and newline # Join with comma and newline
if len(config_params) > 0: if len(config_params) > 0:
config_params_joined = ",\n".join(config_params) config_params_joined = ",\n".join(config_params)
file.write(f"{config_params_joined}\n") file.write(f"{config_params_joined}\n")
@@ -178,7 +223,9 @@ def write_device_structs(file, device: Device, parent_device: Device, bindings:
# Write config struct # Write config struct
write_config(file, device, bindings, devices, type_name) write_config(file, device, bindings, devices, type_name)
# Write device struct # Write device struct
address_value = device.node_address if device.node_address is not None else "0"
file.write(f"static struct Device {node_name}" " = {\n") file.write(f"static struct Device {node_name}" " = {\n")
file.write(f"\t.address = {address_value},\n")
file.write(f"\t.name = \"{device.node_name}\",\n") # Use original name file.write(f"\t.name = \"{device.node_name}\",\n") # Use original name
file.write(f"\t.config = &{config_variable_name},\n") file.write(f"\t.config = &{config_variable_name},\n")
file.write(f"\t.parent = {parent_value},\n") file.write(f"\t.parent = {parent_value},\n")
@@ -37,13 +37,17 @@ value: VALUE
values: VALUE+ values: VALUE+
array: NUMBER+ array: NUMBER+
property_value: quoted_text_array | QUOTED_TEXT | "<" value ">" | "<" values ">" | "[" array "]" | PHANDLE phandle_array_entry: "<" values ">"
phandle_array: phandle_array_entry ("," phandle_array_entry)+
property_value: quoted_text_array | QUOTED_TEXT | phandle_array | "<" value ">" | "<" values ">" | "[" array "]" | PHANDLE
device_property: PROPERTY_NAME ["=" property_value] ";" device_property: PROPERTY_NAME ["=" property_value] ";"
NODE_ALIAS: /[a-zA-Z0-9_\-\/@]+/ NODE_ALIAS: /[a-zA-Z0-9_\-\/]+/
NODE_NAME: /[a-zA-Z0-9_\-\/@]+/ NODE_NAME: /[a-zA-Z0-9_\-\/]+/
NODE_ADDRESS: /[0-9a-zA-Z_]+/
device: (NODE_ALIAS ":")? NODE_NAME "{" (device | device_property)* "};" device: (NODE_ALIAS ":")? NODE_NAME ("@" NODE_ADDRESS)? "{" (device | device_property)* "};"
dts_version: /[0-9a-zA-Z\-]+/ dts_version: /[0-9a-zA-Z\-]+/
@@ -8,6 +8,7 @@ class DtsVersion:
class Device: class Device:
node_name: str node_name: str
node_alias: str node_alias: str
node_address: str
status: str status: str
properties: list properties: list
devices: list devices: list
@@ -38,6 +39,7 @@ class BindingProperty:
required: bool required: bool
description: str description: str
default: object = None default: object = None
element_type: str = None
@dataclass @dataclass
class Binding: class Binding:
@@ -29,6 +29,7 @@ class DtsTransformer(Transformer):
def device(self, tokens: list): def device(self, tokens: list):
node_name = None node_name = None
node_alias = None node_alias = None
node_address = None
status = None status = None
properties = list() properties = list()
child_devices = list() child_devices = list()
@@ -37,6 +38,8 @@ class DtsTransformer(Transformer):
node_name = item.value node_name = item.value
elif type(item) is Token and item.type == 'NODE_ALIAS': elif type(item) is Token and item.type == 'NODE_ALIAS':
node_alias = item.value node_alias = item.value
elif type(item) is Token and item.type == 'NODE_ADDRESS':
node_address = item.value
elif type(item) is DeviceProperty: elif type(item) is DeviceProperty:
if item.name == "status": if item.name == "status":
status = item.value status = item.value
@@ -44,7 +47,7 @@ class DtsTransformer(Transformer):
properties.append(item) properties.append(item)
elif type(item) is Device: elif type(item) is Device:
child_devices.append(item) child_devices.append(item)
return Device(node_name, node_alias, status, properties, child_devices) return Device(node_name, node_alias, node_address, status, properties, child_devices)
def device_property(self, objects: List[object]): def device_property(self, objects: List[object]):
name = objects[0] name = objects[0]
# Boolean property has no value as the value is implied to be true # Boolean property has no value as the value is implied to be true
@@ -67,6 +70,10 @@ class DtsTransformer(Transformer):
if isinstance(object[0], PropertyValue): if isinstance(object[0], PropertyValue):
return object[0] return object[0]
return PropertyValue(type="value", value=object[0]) return PropertyValue(type="value", value=object[0])
def phandle_array_entry(self, tokens: list):
return tokens[0]
def phandle_array(self, tokens: list):
return PropertyValue(type="phandle-array", value=tokens)
def array(self, object): def array(self, object):
return PropertyValue(type="array", value=object) return PropertyValue(type="array", value=object)
def VALUE(self, token: Token): def VALUE(self, token: Token):
@@ -10,21 +10,23 @@ static const root_config_dt root_config = {
}; };
static struct Device root = { static struct Device root = {
.address = 0,
.name = "/", .name = "/",
.config = &root_config, .config = &root_config,
.parent = NULL, .parent = NULL,
.internal = NULL .internal = NULL
}; };
static const generic_device_config_dt test_device@0_config = { static const generic_device_config_dt test_device_config = {
0, 0,
42, 42,
"hello" "hello"
}; };
static struct Device test_device@0 = { static struct Device test_device = {
.name = "test-device@0", .address = 0,
.config = &test_device@0_config, .name = "test-device",
.config = &test_device_config,
.parent = &root, .parent = &root,
.internal = NULL .internal = NULL
}; };
@@ -38,6 +40,7 @@ static const bool_device_config_dt bool_test_device_config = {
}; };
static struct Device bool_test_device = { static struct Device bool_test_device = {
.address = 0,
.name = "bool-test-device", .name = "bool-test-device",
.config = &bool_test_device_config, .config = &bool_test_device_config,
.parent = &root, .parent = &root,
@@ -46,7 +49,7 @@ static struct Device bool_test_device = {
struct DtsDevice dts_devices[] = { struct DtsDevice dts_devices[] = {
{ &root, "test,root", DTS_DEVICE_STATUS_OKAY }, { &root, "test,root", DTS_DEVICE_STATUS_OKAY },
{ &test_device@0, "test,generic-device", DTS_DEVICE_STATUS_OKAY }, { &test_device, "test,generic-device", DTS_DEVICE_STATUS_OKAY },
{ &bool_test_device, "test,bool-device", DTS_DEVICE_STATUS_OKAY }, { &bool_test_device, "test,bool-device", DTS_DEVICE_STATUS_OKAY },
DTS_DEVICE_TERMINATOR DTS_DEVICE_TERMINATOR
}; };
@@ -26,7 +26,6 @@ macro(tactility_project project_name)
set(COMPONENTS set(COMPONENTS
TactilityFreeRtos TactilityFreeRtos
bm8563-module bm8563-module
bm8563-module
bmi270-module bmi270-module
mpu6886-module mpu6886-module
pi4ioe5v6408-module pi4ioe5v6408-module
@@ -38,3 +38,5 @@ CONFIG_WL_SECTOR_SIZE_512=y
CONFIG_WL_SECTOR_SIZE=512 CONFIG_WL_SECTOR_SIZE=512
CONFIG_WL_SECTOR_MODE_SAFE=y CONFIG_WL_SECTOR_MODE_SAFE=y
CONFIG_WL_SECTOR_MODE=1 CONFIG_WL_SECTOR_MODE=1
# Allow new i2c_master API (used by Tab5Keyboard for LP_I2C_NUM_0) to coexist with legacy i2c driver
CONFIG_I2C_SKIP_LEGACY_CONFLICT_CHECK=y
Symlink
+1
View File
@@ -0,0 +1 @@
Documentation/README.md
@@ -3,11 +3,15 @@
#include <Gt911Touch.h> #include <Gt911Touch.h>
#include <PwmBacklight.h> #include <PwmBacklight.h>
#include <RgbDisplay.h> #include <RgbDisplay.h>
#include <tactility/check.h>
#include <tactility/device.h>
std::shared_ptr<tt::hal::touch::TouchDevice> createTouch() { std::shared_ptr<tt::hal::touch::TouchDevice> createTouch() {
// Note for future changes: Reset pin is 41 and interrupt pin is 40 // Note for future changes: Reset pin is 41 and interrupt pin is 40
auto* i2c = device_find_by_name("i2c0");
check(i2c);
auto configuration = std::make_unique<Gt911Touch::Configuration>( auto configuration = std::make_unique<Gt911Touch::Configuration>(
I2C_NUM_0, i2c,
800, 800,
480 480
); );
@@ -1,9 +1,7 @@
#include "devices/Display.h" #include "devices/Display.h"
#include "devices/SdCard.h"
#include <driver/gpio.h> #include <driver/gpio.h>
#include <Tactility/hal/Configuration.h> #include <Tactility/hal/Configuration.h>
#include <Tactility/lvgl/LvglSync.h>
#include <PwmBacklight.h> #include <PwmBacklight.h>
static bool initBoot() { static bool initBoot() {
@@ -23,7 +21,6 @@ static bool initBoot() {
static tt::hal::DeviceVector createDevices() { static tt::hal::DeviceVector createDevices() {
return { return {
createDisplay(), createDisplay(),
createSdCard()
}; };
} }
@@ -1,34 +0,0 @@
#include "SdCard.h"
#define TAG "twodotfour_sdcard"
#include <tactility/device.h>
#include <Tactility/hal/sdcard/SpiSdCardDevice.h>
#include <Tactility/RecursiveMutex.h>
constexpr auto SDCARD_SPI_HOST = SPI3_HOST;
constexpr auto SDCARD_PIN_CS = GPIO_NUM_5;
using tt::hal::sdcard::SpiSdCardDevice;
std::shared_ptr<SdCardDevice> createSdCard() {
auto configuration = std::make_unique<SpiSdCardDevice::Config>(
SDCARD_PIN_CS,
GPIO_NUM_NC,
GPIO_NUM_NC,
GPIO_NUM_NC,
SdCardDevice::MountBehaviour::AtBoot,
nullptr,
std::vector<gpio_num_t>(),
SDCARD_SPI_HOST
);
auto* spi_controller = device_find_by_name("spi1");
check(spi_controller, "spi1 not found");
return std::make_shared<SpiSdCardDevice>(
std::move(configuration),
spi_controller
);
}
@@ -1,8 +0,0 @@
#pragma once
#include "Tactility/hal/sdcard/SdCardDevice.h"
using tt::hal::sdcard::SdCardDevice;
std::shared_ptr<SdCardDevice> createSdCard();
+15 -2
View File
@@ -4,6 +4,8 @@
#include <tactility/bindings/esp32_gpio.h> #include <tactility/bindings/esp32_gpio.h>
#include <tactility/bindings/esp32_i2c.h> #include <tactility/bindings/esp32_i2c.h>
#include <tactility/bindings/esp32_spi.h> #include <tactility/bindings/esp32_spi.h>
#include <tactility/bindings/esp32_sdspi.h>
#include <tactility/bindings/display_placeholder.h>
/ { / {
compatible = "root"; compatible = "root";
@@ -22,18 +24,29 @@
pin-scl = <&gpio0 32 GPIO_FLAG_NONE>; pin-scl = <&gpio0 32 GPIO_FLAG_NONE>;
}; };
display_spi: spi0 { spi0 {
compatible = "espressif,esp32-spi"; compatible = "espressif,esp32-spi";
host = <SPI2_HOST>; host = <SPI2_HOST>;
cs-gpios = <&gpio0 15 GPIO_FLAG_NONE>;
pin-mosi = <&gpio0 13 GPIO_FLAG_NONE>; pin-mosi = <&gpio0 13 GPIO_FLAG_NONE>;
pin-sclk = <&gpio0 14 GPIO_FLAG_NONE>; pin-sclk = <&gpio0 14 GPIO_FLAG_NONE>;
display {
compatible = "display-placeholder";
};
}; };
sdcard_spi: spi1 { spi1 {
compatible = "espressif,esp32-spi"; compatible = "espressif,esp32-spi";
host = <SPI3_HOST>; host = <SPI3_HOST>;
cs-gpios = <&gpio0 5 GPIO_FLAG_NONE>;
pin-mosi = <&gpio0 23 GPIO_FLAG_NONE>; pin-mosi = <&gpio0 23 GPIO_FLAG_NONE>;
pin-miso = <&gpio0 19 GPIO_FLAG_NONE>; pin-miso = <&gpio0 19 GPIO_FLAG_NONE>;
pin-sclk = <&gpio0 18 GPIO_FLAG_NONE>; pin-sclk = <&gpio0 18 GPIO_FLAG_NONE>;
sdcard@0 {
compatible = "espressif,esp32-sdspi";
frequency-khz = <20000>;
};
}; };
}; };
@@ -1,9 +1,6 @@
#include "devices/Display.h" #include "devices/Display.h"
#include "devices/SdCard.h"
#include <driver/gpio.h>
#include <Tactility/hal/Configuration.h> #include <Tactility/hal/Configuration.h>
#include <Tactility/lvgl/LvglSync.h>
#include <PwmBacklight.h> #include <PwmBacklight.h>
using namespace tt::hal; using namespace tt::hal;
@@ -14,8 +11,7 @@ static bool initBoot() {
static DeviceVector createDevices() { static DeviceVector createDevices() {
return { return {
createDisplay(), createDisplay()
createSdCard()
}; };
} }
@@ -1,23 +0,0 @@
#include "SdCard.h"
#include <tactility/device.h>
#include <Tactility/hal/sdcard/SpiSdCardDevice.h>
using tt::hal::sdcard::SpiSdCardDevice;
std::shared_ptr<SdCardDevice> createSdCard() {
auto config = std::make_unique<SpiSdCardDevice::Config>(
GPIO_NUM_5,
GPIO_NUM_NC,
GPIO_NUM_NC,
GPIO_NUM_NC,
SdCardDevice::MountBehaviour::AtBoot,
nullptr,
std::vector<gpio_num_t>(),
SPI3_HOST
);
auto* spi_controller = device_find_by_name("spi1");
check(spi_controller, "spi1 not found");
return std::make_shared<SpiSdCardDevice>(std::move(config), spi_controller);
}
@@ -1,8 +0,0 @@
#pragma once
#include "Tactility/hal/sdcard/SdCardDevice.h"
using tt::hal::sdcard::SdCardDevice;
std::shared_ptr<SdCardDevice> createSdCard();
+21 -2
View File
@@ -3,6 +3,9 @@
#include <tactility/bindings/root.h> #include <tactility/bindings/root.h>
#include <tactility/bindings/esp32_gpio.h> #include <tactility/bindings/esp32_gpio.h>
#include <tactility/bindings/esp32_spi.h> #include <tactility/bindings/esp32_spi.h>
#include <tactility/bindings/esp32_sdspi.h>
#include <tactility/bindings/display_placeholder.h>
#include <tactility/bindings/touch_placeholder.h>
#include <tactility/bindings/esp32_uart.h> #include <tactility/bindings/esp32_uart.h>
/ { / {
@@ -14,20 +17,36 @@
gpio-count = <40>; gpio-count = <40>;
}; };
display_spi: spi0 { spi0 {
compatible = "espressif,esp32-spi"; compatible = "espressif,esp32-spi";
host = <SPI2_HOST>; host = <SPI2_HOST>;
pin-mosi = <&gpio0 13 GPIO_FLAG_NONE>; pin-mosi = <&gpio0 13 GPIO_FLAG_NONE>;
pin-miso = <&gpio0 12 GPIO_FLAG_NONE>; pin-miso = <&gpio0 12 GPIO_FLAG_NONE>;
pin-sclk = <&gpio0 14 GPIO_FLAG_NONE>; pin-sclk = <&gpio0 14 GPIO_FLAG_NONE>;
cs-gpios = <&gpio0 15 GPIO_FLAG_NONE>, // Display
<&gpio0 33 GPIO_FLAG_NONE>; // Touch
display@0 {
compatible = "display-placeholder";
}; };
sdcard_spi: spi1 { touch@1 {
compatible = "touch-placeholder";
};
};
spi1 {
compatible = "espressif,esp32-spi"; compatible = "espressif,esp32-spi";
host = <SPI3_HOST>; host = <SPI3_HOST>;
pin-mosi = <&gpio0 23 GPIO_FLAG_NONE>; pin-mosi = <&gpio0 23 GPIO_FLAG_NONE>;
pin-miso = <&gpio0 19 GPIO_FLAG_NONE>; pin-miso = <&gpio0 19 GPIO_FLAG_NONE>;
pin-sclk = <&gpio0 18 GPIO_FLAG_NONE>; pin-sclk = <&gpio0 18 GPIO_FLAG_NONE>;
cs-gpios = <&gpio0 5 GPIO_FLAG_NONE>;
sdcard@0 {
compatible = "espressif,esp32-sdspi";
frequency-khz = <20000>;
};
}; };
uart1 { uart1 {
@@ -1,9 +1,7 @@
#include "devices/Display.h" #include "devices/Display.h"
#include "devices/SdCard.h"
#include <driver/gpio.h> #include <driver/gpio.h>
#include <Tactility/hal/Configuration.h> #include <Tactility/hal/Configuration.h>
#include <Tactility/lvgl/LvglSync.h>
#include <PwmBacklight.h> #include <PwmBacklight.h>
using namespace tt::hal; using namespace tt::hal;
@@ -25,7 +23,6 @@ static bool initBoot() {
static DeviceVector createDevices() { static DeviceVector createDevices() {
return { return {
createDisplay(), createDisplay(),
createSdCard()
}; };
} }
@@ -1,25 +0,0 @@
#include "SdCard.h"
#include <tactility/device.h>
#include <Tactility/hal/sdcard/SpiSdCardDevice.h>
using tt::hal::sdcard::SpiSdCardDevice;
std::shared_ptr<SdCardDevice> createSdCard() {
auto config = std::make_unique<SpiSdCardDevice::Config>(
GPIO_NUM_5,
GPIO_NUM_NC,
GPIO_NUM_NC,
GPIO_NUM_NC,
SdCardDevice::MountBehaviour::AtBoot,
nullptr,
std::vector<gpio_num_t>(),
SPI3_HOST
);
auto* spi_controller = device_find_by_name("spi1");
check(spi_controller, "spi1 not found");
return std::make_shared<SpiSdCardDevice>(std::move(config), spi_controller);
}
@@ -1,8 +0,0 @@
#pragma once
#include "Tactility/hal/sdcard/SdCardDevice.h"
using tt::hal::sdcard::SdCardDevice;
std::shared_ptr<SdCardDevice> createSdCard();
+21 -2
View File
@@ -5,6 +5,9 @@
#include <tactility/bindings/esp32_i2c.h> #include <tactility/bindings/esp32_i2c.h>
#include <tactility/bindings/esp32_spi.h> #include <tactility/bindings/esp32_spi.h>
#include <tactility/bindings/esp32_uart.h> #include <tactility/bindings/esp32_uart.h>
#include <tactility/bindings/esp32_sdspi.h>
#include <tactility/bindings/display_placeholder.h>
#include <tactility/bindings/touch_placeholder.h>
/ { / {
compatible = "root"; compatible = "root";
@@ -23,20 +26,36 @@
pin-scl = <&gpio0 22 GPIO_FLAG_NONE>; pin-scl = <&gpio0 22 GPIO_FLAG_NONE>;
}; };
display_spi: spi0 { spi0 {
compatible = "espressif,esp32-spi"; compatible = "espressif,esp32-spi";
host = <SPI2_HOST>; host = <SPI2_HOST>;
cs-gpios = <&gpio0 15 GPIO_FLAG_NONE>, // Display
<&gpio0 33 GPIO_FLAG_NONE>; // Touch
pin-mosi = <&gpio0 13 GPIO_FLAG_NONE>; pin-mosi = <&gpio0 13 GPIO_FLAG_NONE>;
pin-miso = <&gpio0 12 GPIO_FLAG_NONE>; pin-miso = <&gpio0 12 GPIO_FLAG_NONE>;
pin-sclk = <&gpio0 14 GPIO_FLAG_NONE>; pin-sclk = <&gpio0 14 GPIO_FLAG_NONE>;
display@0 {
compatible = "display-placeholder";
}; };
sdcard_spi: spi1 { touch@1 {
compatible = "touch-placeholder";
};
};
spi1 {
compatible = "espressif,esp32-spi"; compatible = "espressif,esp32-spi";
host = <SPI3_HOST>; host = <SPI3_HOST>;
pin-mosi = <&gpio0 23 GPIO_FLAG_NONE>; pin-mosi = <&gpio0 23 GPIO_FLAG_NONE>;
pin-miso = <&gpio0 19 GPIO_FLAG_NONE>; pin-miso = <&gpio0 19 GPIO_FLAG_NONE>;
pin-sclk = <&gpio0 18 GPIO_FLAG_NONE>; pin-sclk = <&gpio0 18 GPIO_FLAG_NONE>;
cs-gpios = <&gpio0 5 GPIO_FLAG_NONE>;
sdcard@0 {
compatible = "espressif,esp32-sdspi";
frequency-khz = <20000>;
};
}; };
uart1 { uart1 {
@@ -1,9 +1,7 @@
#include "devices/Display.h" #include "devices/Display.h"
#include "devices/SdCard.h"
#include <driver/gpio.h> #include <driver/gpio.h>
#include <Tactility/hal/Configuration.h> #include <Tactility/hal/Configuration.h>
#include <Tactility/lvgl/LvglSync.h>
#include <PwmBacklight.h> #include <PwmBacklight.h>
using namespace tt::hal; using namespace tt::hal;
@@ -25,7 +23,6 @@ static bool initBoot() {
static DeviceVector createDevices() { static DeviceVector createDevices() {
return { return {
createDisplay(), createDisplay(),
createSdCard()
}; };
} }
@@ -1,25 +0,0 @@
#include "SdCard.h"
#include <tactility/device.h>
#include <Tactility/hal/sdcard/SpiSdCardDevice.h>
using tt::hal::sdcard::SpiSdCardDevice;
std::shared_ptr<SdCardDevice> createSdCard() {
auto config = std::make_unique<SpiSdCardDevice::Config>(
GPIO_NUM_5,
GPIO_NUM_NC,
GPIO_NUM_NC,
GPIO_NUM_NC,
SdCardDevice::MountBehaviour::AtBoot,
nullptr,
std::vector<gpio_num_t>(),
SPI3_HOST
);
auto* spi_controller = device_find_by_name("spi1");
check(spi_controller, "spi1 not found");
return std::make_shared<SpiSdCardDevice>(std::move(config), spi_controller);
}
@@ -1,8 +0,0 @@
#pragma once
#include "Tactility/hal/sdcard/SdCardDevice.h"
using tt::hal::sdcard::SdCardDevice;
std::shared_ptr<SdCardDevice> createSdCard();
+21 -2
View File
@@ -5,6 +5,9 @@
#include <tactility/bindings/esp32_i2c.h> #include <tactility/bindings/esp32_i2c.h>
#include <tactility/bindings/esp32_uart.h> #include <tactility/bindings/esp32_uart.h>
#include <tactility/bindings/esp32_spi.h> #include <tactility/bindings/esp32_spi.h>
#include <tactility/bindings/esp32_sdspi.h>
#include <tactility/bindings/display_placeholder.h>
#include <tactility/bindings/touch_placeholder.h>
/ { / {
compatible = "root"; compatible = "root";
@@ -23,20 +26,36 @@
pin-scl = <&gpio0 22 GPIO_FLAG_NONE>; pin-scl = <&gpio0 22 GPIO_FLAG_NONE>;
}; };
display_spi: spi0 { spi0 {
compatible = "espressif,esp32-spi"; compatible = "espressif,esp32-spi";
host = <SPI2_HOST>; host = <SPI2_HOST>;
cs-gpios = <&gpio0 15 GPIO_FLAG_NONE>, // Display
<&gpio0 33 GPIO_FLAG_NONE>; // Touch
pin-mosi = <&gpio0 13 GPIO_FLAG_NONE>; pin-mosi = <&gpio0 13 GPIO_FLAG_NONE>;
pin-miso = <&gpio0 12 GPIO_FLAG_NONE>; pin-miso = <&gpio0 12 GPIO_FLAG_NONE>;
pin-sclk = <&gpio0 14 GPIO_FLAG_NONE>; pin-sclk = <&gpio0 14 GPIO_FLAG_NONE>;
display@0 {
compatible = "display-placeholder";
}; };
sdcard_spi: spi1 { touch@1 {
compatible = "touch-placeholder";
};
};
spi1 {
compatible = "espressif,esp32-spi"; compatible = "espressif,esp32-spi";
host = <SPI3_HOST>; host = <SPI3_HOST>;
cs-gpios = <&gpio0 5 GPIO_FLAG_NONE>;
pin-mosi = <&gpio0 23 GPIO_FLAG_NONE>; pin-mosi = <&gpio0 23 GPIO_FLAG_NONE>;
pin-miso = <&gpio0 19 GPIO_FLAG_NONE>; pin-miso = <&gpio0 19 GPIO_FLAG_NONE>;
pin-sclk = <&gpio0 18 GPIO_FLAG_NONE>; pin-sclk = <&gpio0 18 GPIO_FLAG_NONE>;
sdcard@0 {
compatible = "espressif,esp32-sdspi";
frequency-khz = <20000>;
};
}; };
uart1 { uart1 {
@@ -1,5 +1,4 @@
#include "devices/Display.h" #include "devices/Display.h"
#include "devices/SdCard.h"
#include <driver/gpio.h> #include <driver/gpio.h>
#include <Tactility/hal/Configuration.h> #include <Tactility/hal/Configuration.h>
@@ -39,7 +38,6 @@ static bool initBoot() {
static tt::hal::DeviceVector createDevices() { static tt::hal::DeviceVector createDevices() {
return { return {
createDisplay(), createDisplay(),
createSdCard()
}; };
} }
@@ -3,10 +3,14 @@
#include <Gt911Touch.h> #include <Gt911Touch.h>
#include <Ili934xDisplay.h> #include <Ili934xDisplay.h>
#include <PwmBacklight.h> #include <PwmBacklight.h>
#include <tactility/check.h>
#include <tactility/device.h>
static std::shared_ptr<tt::hal::touch::TouchDevice> createTouch() { static std::shared_ptr<tt::hal::touch::TouchDevice> createTouch() {
auto* i2c = device_find_by_name("i2c0");
check(i2c);
auto configuration = std::make_unique<Gt911Touch::Configuration>( auto configuration = std::make_unique<Gt911Touch::Configuration>(
I2C_NUM_0, i2c,
LCD_HORIZONTAL_RESOLUTION, LCD_HORIZONTAL_RESOLUTION,
LCD_VERTICAL_RESOLUTION LCD_VERTICAL_RESOLUTION
); );
@@ -1,33 +0,0 @@
#include "SdCard.h"
#include <tactility/device.h>
#include <Tactility/hal/sdcard/SpiSdCardDevice.h>
#include <Tactility/lvgl/LvglSync.h>
#include <Tactility/RecursiveMutex.h>
constexpr auto SDCARD_SPI_HOST = SPI3_HOST;
constexpr auto SDCARD_PIN_CS = GPIO_NUM_5;
using tt::hal::sdcard::SpiSdCardDevice;
std::shared_ptr<SdCardDevice> createSdCard() {
auto configuration = std::make_unique<SpiSdCardDevice::Config>(
SDCARD_PIN_CS,
GPIO_NUM_NC,
GPIO_NUM_NC,
GPIO_NUM_NC,
SdCardDevice::MountBehaviour::AtBoot,
std::make_shared<tt::RecursiveMutex>(),
std::vector<gpio_num_t>(),
SDCARD_SPI_HOST
);
auto* spi_controller = device_find_by_name("spi1");
check(spi_controller, "spi1 not found");
return std::make_shared<SpiSdCardDevice>(
std::move(configuration),
spi_controller
);
}
@@ -1,8 +0,0 @@
#pragma once
#include <Tactility/hal/sdcard/SdCardDevice.h>
using tt::hal::sdcard::SdCardDevice;
std::shared_ptr<SdCardDevice> createSdCard();
+23 -10
View File
@@ -4,12 +4,14 @@
#include <tactility/bindings/esp32_gpio.h> #include <tactility/bindings/esp32_gpio.h>
#include <tactility/bindings/esp32_i2c.h> #include <tactility/bindings/esp32_i2c.h>
#include <tactility/bindings/esp32_spi.h> #include <tactility/bindings/esp32_spi.h>
#include <tactility/bindings/esp32_sdspi.h>
#include <tactility/bindings/display_placeholder.h>
/ { / {
compatible = "root"; compatible = "root";
model = "CYD 2432S032C"; model = "CYD 2432S032C";
gpio1 { gpio0 {
compatible = "espressif,esp32-gpio"; compatible = "espressif,esp32-gpio";
gpio-count = <40>; gpio-count = <40>;
}; };
@@ -18,22 +20,33 @@
compatible = "espressif,esp32-i2c"; compatible = "espressif,esp32-i2c";
port = <I2C_NUM_0>; port = <I2C_NUM_0>;
clock-frequency = <400000>; clock-frequency = <400000>;
pin-sda = <&gpio1 33 GPIO_FLAG_NONE>; pin-sda = <&gpio0 33 GPIO_FLAG_NONE>;
pin-scl = <&gpio1 32 GPIO_FLAG_NONE>; pin-scl = <&gpio0 32 GPIO_FLAG_NONE>;
}; };
display_spi: spi0 { spi0 {
compatible = "espressif,esp32-spi"; compatible = "espressif,esp32-spi";
host = <SPI2_HOST>; host = <SPI2_HOST>;
pin-mosi = <&gpio1 13 GPIO_FLAG_NONE>; cs-gpios = <&gpio0 15 GPIO_FLAG_NONE>;
pin-sclk = <&gpio1 14 GPIO_FLAG_NONE>; 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"; compatible = "espressif,esp32-spi";
host = <SPI3_HOST>; host = <SPI3_HOST>;
pin-mosi = <&gpio1 23 GPIO_FLAG_NONE>; cs-gpios = <&gpio0 5 GPIO_FLAG_NONE>;
pin-miso = <&gpio1 19 GPIO_FLAG_NONE>; pin-mosi = <&gpio0 23 GPIO_FLAG_NONE>;
pin-sclk = <&gpio1 18 GPIO_FLAG_NONE>; pin-miso = <&gpio0 19 GPIO_FLAG_NONE>;
pin-sclk = <&gpio0 18 GPIO_FLAG_NONE>;
sdcard@0 {
compatible = "espressif,esp32-sdspi";
frequency-khz = <20000>;
};
}; };
}; };
@@ -1,5 +1,4 @@
#include "devices/Display.h" #include "devices/Display.h"
#include "devices/SdCard.h"
#include <driver/gpio.h> #include <driver/gpio.h>
#include <PwmBacklight.h> #include <PwmBacklight.h>
@@ -24,7 +23,6 @@ static bool initBoot() {
static DeviceVector createDevices() { static DeviceVector createDevices() {
return { return {
createDisplay(), createDisplay(),
createSdCard()
}; };
} }
@@ -3,10 +3,14 @@
#include <Gt911Touch.h> #include <Gt911Touch.h>
#include <PwmBacklight.h> #include <PwmBacklight.h>
#include <St7796Display.h> #include <St7796Display.h>
#include <tactility/check.h>
#include <tactility/device.h>
static std::shared_ptr<tt::hal::touch::TouchDevice> createTouch() { static std::shared_ptr<tt::hal::touch::TouchDevice> createTouch() {
auto* i2c = device_find_by_name("i2c0");
check(i2c);
auto configuration = std::make_unique<Gt911Touch::Configuration>( auto configuration = std::make_unique<Gt911Touch::Configuration>(
I2C_NUM_0, i2c,
LCD_HORIZONTAL_RESOLUTION, LCD_HORIZONTAL_RESOLUTION,
LCD_VERTICAL_RESOLUTION LCD_VERTICAL_RESOLUTION
); );
@@ -1,31 +0,0 @@
#include "SdCard.h"
#include <tactility/device.h>
#include <Tactility/hal/sdcard/SpiSdCardDevice.h>
constexpr auto SDCARD_SPI_HOST = SPI3_HOST;
constexpr auto SDCARD_PIN_CS = GPIO_NUM_5;
using tt::hal::sdcard::SpiSdCardDevice;
std::shared_ptr<SdCardDevice> createSdCard() {
auto configuration = std::make_unique<SpiSdCardDevice::Config>(
SDCARD_PIN_CS,
GPIO_NUM_NC,
GPIO_NUM_NC,
GPIO_NUM_NC,
SdCardDevice::MountBehaviour::AtBoot,
nullptr,
std::vector<gpio_num_t>(),
SDCARD_SPI_HOST
);
auto* spi_controller = device_find_by_name("spi1");
check(spi_controller, "spi1 not found");
return std::make_shared<SpiSdCardDevice>(
std::move(configuration),
spi_controller
);
}
@@ -1,8 +0,0 @@
#pragma once
#include <Tactility/hal/sdcard/SdCardDevice.h>
using tt::hal::sdcard::SdCardDevice;
std::shared_ptr<SdCardDevice> createSdCard();
+15 -2
View File
@@ -5,6 +5,8 @@
#include <tactility/bindings/esp32_i2c.h> #include <tactility/bindings/esp32_i2c.h>
#include <tactility/bindings/esp32_spi.h> #include <tactility/bindings/esp32_spi.h>
#include <tactility/bindings/esp32_uart.h> #include <tactility/bindings/esp32_uart.h>
#include <tactility/bindings/esp32_sdspi.h>
#include <tactility/bindings/display_placeholder.h>
/ { / {
compatible = "root"; compatible = "root";
@@ -32,19 +34,30 @@
pin-scl = <&gpio0 22 GPIO_FLAG_NONE>; pin-scl = <&gpio0 22 GPIO_FLAG_NONE>;
}; };
display_spi: spi0 { spi0 {
compatible = "espressif,esp32-spi"; compatible = "espressif,esp32-spi";
host = <SPI2_HOST>; host = <SPI2_HOST>;
cs-gpios = <&gpio0 15 GPIO_FLAG_NONE>;
pin-mosi = <&gpio0 13 GPIO_FLAG_NONE>; pin-mosi = <&gpio0 13 GPIO_FLAG_NONE>;
pin-sclk = <&gpio0 14 GPIO_FLAG_NONE>; pin-sclk = <&gpio0 14 GPIO_FLAG_NONE>;
display {
compatible = "display-placeholder";
};
}; };
sdcard_spi: spi1 { spi1 {
compatible = "espressif,esp32-spi"; compatible = "espressif,esp32-spi";
host = <SPI3_HOST>; host = <SPI3_HOST>;
cs-gpios = <&gpio0 5 GPIO_FLAG_NONE>;
pin-mosi = <&gpio0 23 GPIO_FLAG_NONE>; pin-mosi = <&gpio0 23 GPIO_FLAG_NONE>;
pin-miso = <&gpio0 19 GPIO_FLAG_NONE>; pin-miso = <&gpio0 19 GPIO_FLAG_NONE>;
pin-sclk = <&gpio0 18 GPIO_FLAG_NONE>; pin-sclk = <&gpio0 18 GPIO_FLAG_NONE>;
sdcard@0 {
compatible = "espressif,esp32-sdspi";
frequency-khz = <20000>;
};
}; };
// CN1 header, JST SH 1.25, GND / IO22 / IO21 / 3.3V // CN1 header, JST SH 1.25, GND / IO22 / IO21 / 3.3V
@@ -1,10 +1,6 @@
#include "devices/St7701Display.h" #include "devices/St7701Display.h"
#include "devices/SdCard.h"
#include <driver/gpio.h>
#include <Tactility/hal/Configuration.h> #include <Tactility/hal/Configuration.h>
#include <Tactility/kernel/SystemEvents.h>
#include <Tactility/lvgl/LvglSync.h>
#include <PwmBacklight.h> #include <PwmBacklight.h>
using namespace tt::hal; using namespace tt::hal;
@@ -16,7 +12,6 @@ static bool initBoot() {
static DeviceVector createDevices() { static DeviceVector createDevices() {
return { return {
std::make_shared<St7701Display>(), std::make_shared<St7701Display>(),
createSdCard()
}; };
} }
@@ -1,28 +0,0 @@
#include "SdCard.h"
#include <tactility/device.h>
#include <Tactility/hal/sdcard/SpiSdCardDevice.h>
#include <Tactility/lvgl/LvglSync.h>
using tt::hal::sdcard::SpiSdCardDevice;
std::shared_ptr<SdCardDevice> createSdCard() {
auto config = std::make_unique<SpiSdCardDevice::Config>(
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<SpiSdCardDevice>(
std::move(config),
spi_controller
);
}
@@ -1,8 +0,0 @@
#pragma once
#include "Tactility/hal/sdcard/SdCardDevice.h"
using tt::hal::sdcard::SdCardDevice;
std::shared_ptr<SdCardDevice> createSdCard();
@@ -3,6 +3,8 @@
#include <Gt911Touch.h> #include <Gt911Touch.h>
#include <PwmBacklight.h> #include <PwmBacklight.h>
#include <Tactility/Logger.h> #include <Tactility/Logger.h>
#include <tactility/check.h>
#include <tactility/device.h>
#include <driver/gpio.h> #include <driver/gpio.h>
#include <esp_err.h> #include <esp_err.h>
@@ -221,8 +223,10 @@ lvgl_port_display_rgb_cfg_t St7701Display::getLvglPortDisplayRgbConfig(esp_lcd_p
std::shared_ptr<tt::hal::touch::TouchDevice> St7701Display::getTouchDevice() { std::shared_ptr<tt::hal::touch::TouchDevice> St7701Display::getTouchDevice() {
if (touchDevice == nullptr) { if (touchDevice == nullptr) {
auto* i2c = device_find_by_name("i2c0");
check(i2c);
auto configuration = std::make_unique<Gt911Touch::Configuration>( auto configuration = std::make_unique<Gt911Touch::Configuration>(
I2C_NUM_0, i2c,
480, 480,
480 480
); );
+7 -1
View File
@@ -5,6 +5,7 @@
#include <tactility/bindings/esp32_gpio.h> #include <tactility/bindings/esp32_gpio.h>
#include <tactility/bindings/esp32_i2c.h> #include <tactility/bindings/esp32_i2c.h>
#include <tactility/bindings/esp32_spi.h> #include <tactility/bindings/esp32_spi.h>
#include <tactility/bindings/esp32_sdspi.h>
/ { / {
compatible = "root"; compatible = "root";
@@ -30,9 +31,14 @@
spi0 { spi0 {
compatible = "espressif,esp32-spi"; compatible = "espressif,esp32-spi";
host = <SPI2_HOST>; host = <SPI2_HOST>;
cs-gpios = <&gpio0 42 GPIO_FLAG_NONE>;
pin-mosi = <&gpio0 47 GPIO_FLAG_NONE>; pin-mosi = <&gpio0 47 GPIO_FLAG_NONE>;
pin-miso = <&gpio0 41 GPIO_FLAG_NONE>; pin-miso = <&gpio0 41 GPIO_FLAG_NONE>;
pin-sclk = <&gpio0 48 GPIO_FLAG_NONE>; pin-sclk = <&gpio0 48 GPIO_FLAG_NONE>;
pin-hd = <&gpio0 42 GPIO_FLAG_NONE>;
sdcard@0 {
compatible = "espressif,esp32-sdspi";
frequency-khz = <20000>;
};
}; };
}; };
@@ -1,7 +1,5 @@
#include "PwmBacklight.h" #include "PwmBacklight.h"
#include "devices/Display.h" #include "devices/Display.h"
#include "devices/SdCard.h"
#include <driver/gpio.h>
#include <Tactility/hal/Configuration.h> #include <Tactility/hal/Configuration.h>
@@ -15,7 +13,6 @@ static bool initBoot() {
static DeviceVector createDevices() { static DeviceVector createDevices() {
return { return {
createDisplay(), createDisplay(),
createSdCard()
}; };
} }
@@ -3,12 +3,16 @@
#include <Gt911Touch.h> #include <Gt911Touch.h>
#include <PwmBacklight.h> #include <PwmBacklight.h>
#include <RgbDisplay.h> #include <RgbDisplay.h>
#include <tactility/check.h>
#include <tactility/device.h>
std::shared_ptr<tt::hal::touch::TouchDevice> createTouch() { std::shared_ptr<tt::hal::touch::TouchDevice> createTouch() {
// Note for future changes: Reset pin is 38 and interrupt pin is 18 // Note for future changes: Reset pin is 38 and interrupt pin is 18
// or INT = NC, schematic and other info floating around is kinda conflicting... // or INT = NC, schematic and other info floating around is kinda conflicting...
auto* i2c = device_find_by_name("i2c_internal");
check(i2c);
auto configuration = std::make_unique<Gt911Touch::Configuration>( auto configuration = std::make_unique<Gt911Touch::Configuration>(
I2C_NUM_0, i2c,
800, 800,
480 480
); );
@@ -1,25 +0,0 @@
#include "SdCard.h"
#include <tactility/device.h>
#include <Tactility/hal/sdcard/SpiSdCardDevice.h>
#include <Tactility/lvgl/LvglSync.h>
using tt::hal::sdcard::SpiSdCardDevice;
std::shared_ptr<SdCardDevice> createSdCard() {
auto config = std::make_unique<SpiSdCardDevice::Config>(
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<SpiSdCardDevice>(
std::move(config),
spi_controller
);
}
@@ -1,7 +0,0 @@
#pragma once
#include "Tactility/hal/sdcard/SdCardDevice.h"
using tt::hal::sdcard::SdCardDevice;
std::shared_ptr<SdCardDevice> createSdCard();
+7
View File
@@ -6,6 +6,7 @@
#include <tactility/bindings/esp32_i2c.h> #include <tactility/bindings/esp32_i2c.h>
#include <tactility/bindings/esp32_uart.h> #include <tactility/bindings/esp32_uart.h>
#include <tactility/bindings/esp32_spi.h> #include <tactility/bindings/esp32_spi.h>
#include <tactility/bindings/esp32_sdspi.h>
/ { / {
compatible = "root"; compatible = "root";
@@ -39,9 +40,15 @@
spi0 { spi0 {
compatible = "espressif,esp32-spi"; compatible = "espressif,esp32-spi";
host = <SPI2_HOST>; host = <SPI2_HOST>;
cs-gpios = <&gpio0 10 GPIO_FLAG_NONE>;
pin-mosi = <&gpio0 11 GPIO_FLAG_NONE>; pin-mosi = <&gpio0 11 GPIO_FLAG_NONE>;
pin-miso = <&gpio0 13 GPIO_FLAG_NONE>; pin-miso = <&gpio0 13 GPIO_FLAG_NONE>;
pin-sclk = <&gpio0 12 GPIO_FLAG_NONE>; pin-sclk = <&gpio0 12 GPIO_FLAG_NONE>;
sdcard@0 {
compatible = "espressif,esp32-sdspi";
frequency-khz = <20000>;
};
}; };
uart1 { uart1 {
@@ -1,8 +1,6 @@
#include "devices/SdCard.h"
#include "devices/Display.h" #include "devices/Display.h"
#include <Tactility/hal/Configuration.h> #include <Tactility/hal/Configuration.h>
#include <Tactility/lvgl/LvglSync.h>
#include <PwmBacklight.h> #include <PwmBacklight.h>
static bool initBoot() { static bool initBoot() {
@@ -12,7 +10,6 @@ static bool initBoot() {
static tt::hal::DeviceVector createDevices() { static tt::hal::DeviceVector createDevices() {
return { return {
createDisplay(), createDisplay(),
createSdCard()
}; };
} }
@@ -1,28 +0,0 @@
#include "SdCard.h"
#include <tactility/device.h>
#include <Tactility/hal/sdcard/SpiSdCardDevice.h>
#include <Tactility/RecursiveMutex.h>
using tt::hal::sdcard::SpiSdCardDevice;
std::shared_ptr<SdCardDevice> createSdCard() {
auto configuration = std::make_unique<SpiSdCardDevice::Config>(
GPIO_NUM_5,
GPIO_NUM_NC,
GPIO_NUM_NC,
GPIO_NUM_NC,
SdCardDevice::MountBehaviour::AtBoot,
nullptr,
std::vector<gpio_num_t>(),
SPI3_HOST
);
auto* spi_controller = device_find_by_name("spi1");
check(spi_controller, "spi1 not found");
return std::make_shared<SpiSdCardDevice>(
std::move(configuration),
spi_controller
);
}
@@ -1,7 +0,0 @@
#pragma once
#include <Tactility/hal/sdcard/SdCardDevice.h>
using tt::hal::sdcard::SdCardDevice;
std::shared_ptr<SdCardDevice> createSdCard();
+21 -2
View File
@@ -3,6 +3,9 @@
#include <tactility/bindings/root.h> #include <tactility/bindings/root.h>
#include <tactility/bindings/esp32_gpio.h> #include <tactility/bindings/esp32_gpio.h>
#include <tactility/bindings/esp32_spi.h> #include <tactility/bindings/esp32_spi.h>
#include <tactility/bindings/esp32_sdspi.h>
#include <tactility/bindings/display_placeholder.h>
#include <tactility/bindings/touch_placeholder.h>
/ { / {
compatible = "root"; compatible = "root";
@@ -13,19 +16,35 @@
gpio-count = <40>; gpio-count = <40>;
}; };
display_spi: spi0 { spi0 {
compatible = "espressif,esp32-spi"; compatible = "espressif,esp32-spi";
host = <SPI2_HOST>; host = <SPI2_HOST>;
cs-gpios = <&gpio0 15 GPIO_FLAG_NONE>, // Display
<&gpio0 33 GPIO_FLAG_NONE>; // Touch
pin-mosi = <&gpio0 13 GPIO_FLAG_NONE>; pin-mosi = <&gpio0 13 GPIO_FLAG_NONE>;
pin-miso = <&gpio0 12 GPIO_FLAG_NONE>; pin-miso = <&gpio0 12 GPIO_FLAG_NONE>;
pin-sclk = <&gpio0 14 GPIO_FLAG_NONE>; pin-sclk = <&gpio0 14 GPIO_FLAG_NONE>;
display@0 {
compatible = "display-placeholder";
}; };
sdcard_spi: spi1 { touch@1 {
compatible = "touch-placeholder";
};
};
spi1 {
compatible = "espressif,esp32-spi"; compatible = "espressif,esp32-spi";
host = <SPI3_HOST>; host = <SPI3_HOST>;
cs-gpios = <&gpio0 5 GPIO_FLAG_NONE>;
pin-mosi = <&gpio0 23 GPIO_FLAG_NONE>; pin-mosi = <&gpio0 23 GPIO_FLAG_NONE>;
pin-miso = <&gpio0 19 GPIO_FLAG_NONE>; pin-miso = <&gpio0 19 GPIO_FLAG_NONE>;
pin-sclk = <&gpio0 18 GPIO_FLAG_NONE>; pin-sclk = <&gpio0 18 GPIO_FLAG_NONE>;
sdcard@0 {
compatible = "espressif,esp32-sdspi";
frequency-khz = <20000>;
};
}; };
}; };
@@ -1,10 +1,7 @@
#include "devices/SdCard.h"
#include "devices/Display.h" #include "devices/Display.h"
#include "devices/Power.h" #include "devices/Power.h"
#include <driver/gpio.h>
#include <Tactility/hal/Configuration.h> #include <Tactility/hal/Configuration.h>
#include <Tactility/lvgl/LvglSync.h>
#include <PwmBacklight.h> #include <PwmBacklight.h>
using namespace tt::hal; using namespace tt::hal;
@@ -17,7 +14,6 @@ static tt::hal::DeviceVector createDevices() {
return { return {
createPower(), createPower(),
createDisplay(), createDisplay(),
createSdCard()
}; };
} }
@@ -1,29 +0,0 @@
#include "SdCard.h"
#include <tactility/device.h>
#include <Tactility/hal/sdcard/SpiSdCardDevice.h>
#include <Tactility/RecursiveMutex.h>
using tt::hal::sdcard::SpiSdCardDevice;
using SdCardDevice = tt::hal::sdcard::SdCardDevice;
std::shared_ptr<SdCardDevice> createSdCard() {
auto configuration = std::make_unique<SpiSdCardDevice::Config>(
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<tt::RecursiveMutex>(),
std::vector<gpio_num_t>(),
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<SpiSdCardDevice>(
std::move(configuration),
spi_controller
);
}
@@ -1,13 +0,0 @@
#pragma once
#include <Tactility/hal/sdcard/SdCardDevice.h>
#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<SdCardDevice> createSdCard();
+21 -2
View File
@@ -4,6 +4,9 @@
#include <tactility/bindings/esp32_gpio.h> #include <tactility/bindings/esp32_gpio.h>
#include <tactility/bindings/esp32_i2c.h> #include <tactility/bindings/esp32_i2c.h>
#include <tactility/bindings/esp32_spi.h> #include <tactility/bindings/esp32_spi.h>
#include <tactility/bindings/esp32_sdspi.h>
#include <tactility/bindings/display_placeholder.h>
#include <tactility/bindings/touch_placeholder.h>
/ { / {
compatible = "root"; compatible = "root";
@@ -22,19 +25,35 @@
pin-scl = <&gpio0 25 GPIO_FLAG_NONE>; pin-scl = <&gpio0 25 GPIO_FLAG_NONE>;
}; };
display_spi: spi0 { spi0 {
compatible = "espressif,esp32-spi"; compatible = "espressif,esp32-spi";
host = <SPI2_HOST>; host = <SPI2_HOST>;
cs-gpios = <&gpio0 15 GPIO_FLAG_NONE>, // Display
<&gpio0 33 GPIO_FLAG_NONE>; // Touch
pin-mosi = <&gpio0 13 GPIO_FLAG_NONE>; pin-mosi = <&gpio0 13 GPIO_FLAG_NONE>;
pin-miso = <&gpio0 12 GPIO_FLAG_NONE>; pin-miso = <&gpio0 12 GPIO_FLAG_NONE>;
pin-sclk = <&gpio0 14 GPIO_FLAG_NONE>; pin-sclk = <&gpio0 14 GPIO_FLAG_NONE>;
display@0 {
compatible = "display-placeholder";
}; };
sdcard_spi: spi1 { touch@1 {
compatible = "touch-placeholder";
};
};
spi1 {
compatible = "espressif,esp32-spi"; compatible = "espressif,esp32-spi";
host = <SPI3_HOST>; host = <SPI3_HOST>;
cs-gpios = <&gpio0 5 GPIO_FLAG_NONE>;
pin-mosi = <&gpio0 23 GPIO_FLAG_NONE>; pin-mosi = <&gpio0 23 GPIO_FLAG_NONE>;
pin-miso = <&gpio0 19 GPIO_FLAG_NONE>; pin-miso = <&gpio0 19 GPIO_FLAG_NONE>;
pin-sclk = <&gpio0 18 GPIO_FLAG_NONE>; pin-sclk = <&gpio0 18 GPIO_FLAG_NONE>;
sdcard@0 {
compatible = "espressif,esp32-sdspi";
frequency-khz = <20000>;
};
}; };
}; };
@@ -1,7 +1,5 @@
#include "PwmBacklight.h" #include "PwmBacklight.h"
#include "devices/Display.h" #include "devices/Display.h"
#include "devices/SdCard.h"
#include <driver/gpio.h>
#include <Tactility/hal/Configuration.h> #include <Tactility/hal/Configuration.h>
@@ -14,7 +12,6 @@ static bool initBoot() {
static DeviceVector createDevices() { static DeviceVector createDevices() {
return { return {
createDisplay(), createDisplay(),
createSdCard()
}; };
} }
@@ -1,29 +0,0 @@
#include "SdCard.h"
#include <tactility/device.h>
#include <Tactility/hal/sdcard/SpiSdCardDevice.h>
using tt::hal::sdcard::SpiSdCardDevice;
constexpr auto CROWPANEL_SDCARD_PIN_CS = GPIO_NUM_7;
std::shared_ptr<SdCardDevice> createSdCard() {
auto configuration = std::make_unique<SpiSdCardDevice::Config>(
CROWPANEL_SDCARD_PIN_CS,
GPIO_NUM_NC,
GPIO_NUM_NC,
GPIO_NUM_NC,
SdCardDevice::MountBehaviour::AtBoot,
nullptr,
std::vector<gpio_num_t>(),
SPI3_HOST
);
auto* spi_controller = device_find_by_name("spi1");
check(spi_controller, "spi1 not found");
return std::make_shared<SpiSdCardDevice>(
std::move(configuration),
spi_controller
);
}
@@ -1,7 +0,0 @@
#pragma once
#include "Tactility/hal/sdcard/SdCardDevice.h"
using tt::hal::sdcard::SdCardDevice;
std::shared_ptr<SdCardDevice> createSdCard();
@@ -6,6 +6,8 @@
#include <tactility/bindings/esp32_i2c.h> #include <tactility/bindings/esp32_i2c.h>
#include <tactility/bindings/esp32_spi.h> #include <tactility/bindings/esp32_spi.h>
#include <tactility/bindings/esp32_uart.h> #include <tactility/bindings/esp32_uart.h>
#include <tactility/bindings/esp32_sdspi.h>
#include <tactility/bindings/display_placeholder.h>
/ { / {
compatible = "root"; compatible = "root";
@@ -28,19 +30,30 @@
pin-scl = <&gpio0 16 GPIO_FLAG_NONE>; pin-scl = <&gpio0 16 GPIO_FLAG_NONE>;
}; };
display_spi: spi0 { spi0 {
compatible = "espressif,esp32-spi"; compatible = "espressif,esp32-spi";
host = <SPI2_HOST>; host = <SPI2_HOST>;
cs-gpios = <&gpio0 40 GPIO_FLAG_NONE>;
pin-mosi = <&gpio0 39 GPIO_FLAG_NONE>; pin-mosi = <&gpio0 39 GPIO_FLAG_NONE>;
pin-sclk = <&gpio0 42 GPIO_FLAG_NONE>; pin-sclk = <&gpio0 42 GPIO_FLAG_NONE>;
display {
compatible = "display-placeholder";
};
}; };
sdcard_spi: spi1 { spi1 {
compatible = "espressif,esp32-spi"; compatible = "espressif,esp32-spi";
host = <SPI3_HOST>; host = <SPI3_HOST>;
cs-gpios = <&gpio0 7 GPIO_FLAG_NONE>;
pin-mosi = <&gpio0 6 GPIO_FLAG_NONE>; pin-mosi = <&gpio0 6 GPIO_FLAG_NONE>;
pin-miso = <&gpio0 4 GPIO_FLAG_NONE>; pin-miso = <&gpio0 4 GPIO_FLAG_NONE>;
pin-sclk = <&gpio0 5 GPIO_FLAG_NONE>; pin-sclk = <&gpio0 5 GPIO_FLAG_NONE>;
sdcard@0 {
compatible = "espressif,esp32-sdspi";
frequency-khz = <20000>;
};
}; };
uart0 { uart0 {
@@ -1,6 +1,4 @@
#include "devices/Display.h" #include "devices/Display.h"
#include "devices/SdCard.h"
#include <driver/gpio.h>
#include <Tactility/hal/Configuration.h> #include <Tactility/hal/Configuration.h>
#include <PwmBacklight.h> #include <PwmBacklight.h>
@@ -14,7 +12,6 @@ static bool initBoot() {
static DeviceVector createDevices() { static DeviceVector createDevices() {
return { return {
createDisplay(), createDisplay(),
createSdCard()
}; };
} }
@@ -3,10 +3,14 @@
#include <Gt911Touch.h> #include <Gt911Touch.h>
#include <PwmBacklight.h> #include <PwmBacklight.h>
#include <Ili9488Display.h> #include <Ili9488Display.h>
#include <tactility/check.h>
#include <tactility/device.h>
static std::shared_ptr<tt::hal::touch::TouchDevice> createTouch() { static std::shared_ptr<tt::hal::touch::TouchDevice> createTouch() {
auto* i2c = device_find_by_name("i2c0");
check(i2c);
auto configuration = std::make_unique<Gt911Touch::Configuration>( auto configuration = std::make_unique<Gt911Touch::Configuration>(
I2C_NUM_0, i2c,
320, 320,
480 480
); );
@@ -1,29 +0,0 @@
#include "SdCard.h"
#include <tactility/device.h>
#include <Tactility/hal/sdcard/SpiSdCardDevice.h>
using tt::hal::sdcard::SpiSdCardDevice;
constexpr auto CROWPANEL_SDCARD_PIN_CS = GPIO_NUM_7;
std::shared_ptr<SdCardDevice> createSdCard() {
auto configuration = std::make_unique<SpiSdCardDevice::Config>(
CROWPANEL_SDCARD_PIN_CS,
GPIO_NUM_NC,
GPIO_NUM_NC,
GPIO_NUM_NC,
SdCardDevice::MountBehaviour::AtBoot,
nullptr,
std::vector<gpio_num_t>(),
SPI3_HOST
);
auto* spi_controller = device_find_by_name("spi1");
check(spi_controller, "spi1 not found");
return std::make_shared<SpiSdCardDevice>(
std::move(configuration),
spi_controller
);
}
@@ -1,7 +0,0 @@
#pragma once
#include "Tactility/hal/sdcard/SdCardDevice.h"
using tt::hal::sdcard::SdCardDevice;
std::shared_ptr<SdCardDevice> createSdCard();
@@ -6,6 +6,8 @@
#include <tactility/bindings/esp32_i2c.h> #include <tactility/bindings/esp32_i2c.h>
#include <tactility/bindings/esp32_spi.h> #include <tactility/bindings/esp32_spi.h>
#include <tactility/bindings/esp32_uart.h> #include <tactility/bindings/esp32_uart.h>
#include <tactility/bindings/esp32_sdspi.h>
#include <tactility/bindings/display_placeholder.h>
/ { / {
compatible = "root"; compatible = "root";
@@ -28,19 +30,30 @@
pin-scl = <&gpio0 16 GPIO_FLAG_NONE>; pin-scl = <&gpio0 16 GPIO_FLAG_NONE>;
}; };
display_spi: spi0 { spi0 {
compatible = "espressif,esp32-spi"; compatible = "espressif,esp32-spi";
host = <SPI2_HOST>; host = <SPI2_HOST>;
cs-gpios = <&gpio0 40 GPIO_FLAG_NONE>;
pin-mosi = <&gpio0 39 GPIO_FLAG_NONE>; pin-mosi = <&gpio0 39 GPIO_FLAG_NONE>;
pin-sclk = <&gpio0 42 GPIO_FLAG_NONE>; pin-sclk = <&gpio0 42 GPIO_FLAG_NONE>;
display {
compatible = "display-placeholder";
};
}; };
sdcard_spi: spi1 { spi1 {
compatible = "espressif,esp32-spi"; compatible = "espressif,esp32-spi";
host = <SPI3_HOST>; host = <SPI3_HOST>;
cs-gpios = <&gpio0 7 GPIO_FLAG_NONE>;
pin-mosi = <&gpio0 6 GPIO_FLAG_NONE>; pin-mosi = <&gpio0 6 GPIO_FLAG_NONE>;
pin-miso = <&gpio0 4 GPIO_FLAG_NONE>; pin-miso = <&gpio0 4 GPIO_FLAG_NONE>;
pin-sclk = <&gpio0 5 GPIO_FLAG_NONE>; pin-sclk = <&gpio0 5 GPIO_FLAG_NONE>;
sdcard@0 {
compatible = "espressif,esp32-sdspi";
frequency-khz = <20000>;
};
}; };
uart0 { uart0 {
@@ -1,6 +1,4 @@
#include "devices/Display.h" #include "devices/Display.h"
#include "devices/SdCard.h"
#include <driver/gpio.h>
#include <Tactility/hal/Configuration.h> #include <Tactility/hal/Configuration.h>
#include <TCA9534.h> #include <TCA9534.h>
@@ -25,7 +23,6 @@ static bool initBoot() {
static DeviceVector createDevices() { static DeviceVector createDevices() {
return { return {
createDisplay(), createDisplay(),
createSdCard()
}; };
} }
@@ -2,12 +2,16 @@
#include <Gt911Touch.h> #include <Gt911Touch.h>
#include <RgbDisplay.h> #include <RgbDisplay.h>
#include <tactility/check.h>
#include <tactility/device.h>
std::shared_ptr<tt::hal::touch::TouchDevice> createTouch() { std::shared_ptr<tt::hal::touch::TouchDevice> createTouch() {
// Note for future changes: Reset pin is 38 and interrupt pin is 18 // Note for future changes: Reset pin is 38 and interrupt pin is 18
// or INT = NC, schematic and other info floating around is kinda conflicting... // or INT = NC, schematic and other info floating around is kinda conflicting...
auto* i2c = device_find_by_name("i2c0");
check(i2c);
auto configuration = std::make_unique<Gt911Touch::Configuration>( auto configuration = std::make_unique<Gt911Touch::Configuration>(
I2C_NUM_0, i2c,
800, 800,
480 480
); );
@@ -1,25 +0,0 @@
#include "SdCard.h"
#include <tactility/device.h>
#include <Tactility/hal/sdcard/SpiSdCardDevice.h>
using tt::hal::sdcard::SpiSdCardDevice;
std::shared_ptr<SdCardDevice> createSdCard() {
auto configuration = std::make_unique<SpiSdCardDevice::Config>(
// See https://github.com/Elecrow-RD/CrowPanel-Advance-HMI-ESP32-AI-Display/blob/master/5.0/factory_code/factory_code.ino
GPIO_NUM_0, // It's actually not connected, but in the demo pin 0 is used
GPIO_NUM_NC,
GPIO_NUM_NC,
GPIO_NUM_NC,
SdCardDevice::MountBehaviour::AtBoot
);
auto* spi_controller = device_find_by_name("spi0");
check(spi_controller, "spi0 not found");
return std::make_shared<SpiSdCardDevice>(
std::move(configuration),
spi_controller
);
}
@@ -1,7 +0,0 @@
#pragma once
#include <Tactility/hal/sdcard/SdCardDevice.h>
using tt::hal::sdcard::SdCardDevice;
std::shared_ptr<SdCardDevice> createSdCard();
@@ -6,6 +6,7 @@
#include <tactility/bindings/esp32_i2c.h> #include <tactility/bindings/esp32_i2c.h>
#include <tactility/bindings/esp32_spi.h> #include <tactility/bindings/esp32_spi.h>
#include <tactility/bindings/esp32_uart.h> #include <tactility/bindings/esp32_uart.h>
#include <tactility/bindings/esp32_sdspi.h>
/ { / {
compatible = "root"; compatible = "root";
@@ -28,12 +29,18 @@
pin-scl = <&gpio0 16 GPIO_FLAG_NONE>; pin-scl = <&gpio0 16 GPIO_FLAG_NONE>;
}; };
sdcard_spi: spi0 { spi0 {
compatible = "espressif,esp32-spi"; compatible = "espressif,esp32-spi";
host = <SPI2_HOST>; host = <SPI2_HOST>;
cs-gpios = <&gpio0 0 GPIO_FLAG_NONE>;
pin-mosi = <&gpio0 6 GPIO_FLAG_NONE>; pin-mosi = <&gpio0 6 GPIO_FLAG_NONE>;
pin-miso = <&gpio0 4 GPIO_FLAG_NONE>; pin-miso = <&gpio0 4 GPIO_FLAG_NONE>;
pin-sclk = <&gpio0 5 GPIO_FLAG_NONE>; pin-sclk = <&gpio0 5 GPIO_FLAG_NONE>;
sdcard@0 {
compatible = "espressif,esp32-sdspi";
frequency-khz = <20000>;
};
}; };
uart0 { uart0 {
@@ -1,7 +1,5 @@
#include "PwmBacklight.h" #include "PwmBacklight.h"
#include "devices/Display.h" #include "devices/Display.h"
#include "devices/SdCard.h"
#include <driver/gpio.h>
#include <Tactility/hal/Configuration.h> #include <Tactility/hal/Configuration.h>
@@ -14,7 +12,6 @@ static bool initBoot() {
static DeviceVector createDevices() { static DeviceVector createDevices() {
return { return {
createDisplay(), createDisplay(),
createSdCard()
}; };
} }
@@ -1,28 +0,0 @@
#include "SdCard.h"
#include <tactility/device.h>
#include <Tactility/lvgl/LvglSync.h>
#include <Tactility/hal/sdcard/SpiSdCardDevice.h>
using tt::hal::sdcard::SpiSdCardDevice;
std::shared_ptr<SdCardDevice> createSdCard() {
auto configuration = std::make_unique<SpiSdCardDevice::Config>(
GPIO_NUM_5,
GPIO_NUM_NC,
GPIO_NUM_NC,
GPIO_NUM_NC,
SdCardDevice::MountBehaviour::AtBoot,
tt::lvgl::getSyncLock(),
std::vector<gpio_num_t>(),
SPI3_HOST
);
auto* spi_controller = device_find_by_name("spi1");
check(spi_controller, "spi1 not found");
return std::make_shared<SpiSdCardDevice>(
std::move(configuration),
spi_controller
);
}
@@ -1,7 +0,0 @@
#pragma once
#include "Tactility/hal/sdcard/SdCardDevice.h"
using tt::hal::sdcard::SdCardDevice;
std::shared_ptr<SdCardDevice> createSdCard();
@@ -5,6 +5,9 @@
#include <tactility/bindings/esp32_i2c.h> #include <tactility/bindings/esp32_i2c.h>
#include <tactility/bindings/esp32_spi.h> #include <tactility/bindings/esp32_spi.h>
#include <tactility/bindings/esp32_uart.h> #include <tactility/bindings/esp32_uart.h>
#include <tactility/bindings/esp32_sdspi.h>
#include <tactility/bindings/display_placeholder.h>
#include <tactility/bindings/touch_placeholder.h>
/ { / {
compatible = "root"; compatible = "root";
@@ -23,21 +26,37 @@
pin-scl = <&gpio0 21 GPIO_FLAG_NONE>; pin-scl = <&gpio0 21 GPIO_FLAG_NONE>;
}; };
display_spi: spi0 { spi0 {
compatible = "espressif,esp32-spi"; compatible = "espressif,esp32-spi";
host = <SPI2_HOST>; host = <SPI2_HOST>;
cs-gpios = <&gpio0 15 GPIO_FLAG_NONE>, // Display
<&gpio0 33 GPIO_FLAG_NONE>; // Touch
pin-mosi = <&gpio0 13 GPIO_FLAG_NONE>; pin-mosi = <&gpio0 13 GPIO_FLAG_NONE>;
pin-miso = <&gpio0 12 GPIO_FLAG_NONE>; pin-miso = <&gpio0 12 GPIO_FLAG_NONE>;
pin-sclk = <&gpio0 14 GPIO_FLAG_NONE>; pin-sclk = <&gpio0 14 GPIO_FLAG_NONE>;
max-transfer-size = <65536>; max-transfer-size = <65536>;
display@0 {
compatible = "display-placeholder";
}; };
sdcard_spi: spi1 { touch@1 {
compatible = "touch-placeholder";
};
};
spi1 {
compatible = "espressif,esp32-spi"; compatible = "espressif,esp32-spi";
host = <SPI3_HOST>; host = <SPI3_HOST>;
cs-gpios = <&gpio0 5 GPIO_FLAG_NONE>;
pin-mosi = <&gpio0 23 GPIO_FLAG_NONE>; pin-mosi = <&gpio0 23 GPIO_FLAG_NONE>;
pin-miso = <&gpio0 19 GPIO_FLAG_NONE>; pin-miso = <&gpio0 19 GPIO_FLAG_NONE>;
pin-sclk = <&gpio0 18 GPIO_FLAG_NONE>; pin-sclk = <&gpio0 18 GPIO_FLAG_NONE>;
sdcard@0 {
compatible = "espressif,esp32-sdspi";
frequency-khz = <20000>;
};
}; };
uart1 { uart1 {
@@ -1,20 +1,21 @@
#include "PwmBacklight.h" #include "PwmBacklight.h"
#include "devices/Display.h" #include "devices/Display.h"
#include "devices/SdCard.h"
#include <driver/gpio.h>
#include <Tactility/hal/Configuration.h> #include <Tactility/hal/Configuration.h>
using namespace tt::hal; using namespace tt::hal;
static bool initBoot() { static bool initBoot() {
return driver::pwmbacklight::init(GPIO_NUM_27); driver::pwmbacklight::init(GPIO_NUM_27);
// Delay is required, or GUI will lock up.
// It's possibly related to the increased power draw when turning on the backlight.
vTaskDelay(100);
return true;
} }
static DeviceVector createDevices() { static DeviceVector createDevices() {
return { return {
createDisplay(), createDisplay(),
createSdCard()
}; };
} }
@@ -1,28 +0,0 @@
#include "SdCard.h"
#include <tactility/device.h>
#include <Tactility/lvgl/LvglSync.h>
#include <Tactility/hal/sdcard/SpiSdCardDevice.h>
using tt::hal::sdcard::SpiSdCardDevice;
std::shared_ptr<SdCardDevice> createSdCard() {
auto configuration = std::make_unique<SpiSdCardDevice::Config>(
GPIO_NUM_5,
GPIO_NUM_NC,
GPIO_NUM_NC,
GPIO_NUM_NC,
SdCardDevice::MountBehaviour::AtBoot,
tt::lvgl::getSyncLock(),
std::vector<gpio_num_t>(),
SPI3_HOST
);
auto* spi_controller = device_find_by_name("spi1");
check(spi_controller, "spi1 not found");
return std::make_shared<SpiSdCardDevice>(
std::move(configuration),
spi_controller
);
}
@@ -1,7 +0,0 @@
#pragma once
#include "Tactility/hal/sdcard/SdCardDevice.h"
using tt::hal::sdcard::SdCardDevice;
std::shared_ptr<SdCardDevice> createSdCard();
@@ -5,6 +5,9 @@
#include <tactility/bindings/esp32_i2c.h> #include <tactility/bindings/esp32_i2c.h>
#include <tactility/bindings/esp32_spi.h> #include <tactility/bindings/esp32_spi.h>
#include <tactility/bindings/esp32_uart.h> #include <tactility/bindings/esp32_uart.h>
#include <tactility/bindings/esp32_sdspi.h>
#include <tactility/bindings/display_placeholder.h>
#include <tactility/bindings/touch_placeholder.h>
/ { / {
compatible = "root"; compatible = "root";
@@ -23,21 +26,37 @@
pin-scl = <&gpio0 21 GPIO_FLAG_NONE>; pin-scl = <&gpio0 21 GPIO_FLAG_NONE>;
}; };
display_spi: spi0 { spi0 {
compatible = "espressif,esp32-spi"; compatible = "espressif,esp32-spi";
host = <SPI2_HOST>; host = <SPI2_HOST>;
cs-gpios = <&gpio0 15 GPIO_FLAG_NONE>, // Display
<&gpio0 12 GPIO_FLAG_NONE>; // Touch
pin-mosi = <&gpio0 13 GPIO_FLAG_NONE>; pin-mosi = <&gpio0 13 GPIO_FLAG_NONE>;
pin-miso = <&gpio0 33 GPIO_FLAG_NONE>; pin-miso = <&gpio0 33 GPIO_FLAG_NONE>;
pin-sclk = <&gpio0 14 GPIO_FLAG_NONE>; pin-sclk = <&gpio0 14 GPIO_FLAG_NONE>;
max-transfer-size = <65536>; max-transfer-size = <65536>;
display@0 {
compatible = "display-placeholder";
}; };
sdcard_spi: spi1 { touch@1 {
compatible = "touch-placeholder";
};
};
spi1 {
compatible = "espressif,esp32-spi"; compatible = "espressif,esp32-spi";
host = <SPI3_HOST>; host = <SPI3_HOST>;
cs-gpios = <&gpio0 5 GPIO_FLAG_NONE>;
pin-mosi = <&gpio0 23 GPIO_FLAG_NONE>; pin-mosi = <&gpio0 23 GPIO_FLAG_NONE>;
pin-miso = <&gpio0 19 GPIO_FLAG_NONE>; pin-miso = <&gpio0 19 GPIO_FLAG_NONE>;
pin-sclk = <&gpio0 18 GPIO_FLAG_NONE>; pin-sclk = <&gpio0 18 GPIO_FLAG_NONE>;
sdcard@0 {
compatible = "espressif,esp32-sdspi";
frequency-khz = <20000>;
};
}; };
uart1 { uart1 {
@@ -1,6 +1,4 @@
#include "devices/Display.h" #include "devices/Display.h"
#include "devices/SdCard.h"
#include <driver/gpio.h>
#include <Tactility/hal/Configuration.h> #include <Tactility/hal/Configuration.h>
#include <PwmBacklight.h> #include <PwmBacklight.h>
@@ -15,7 +13,6 @@ static bool initBoot() {
static DeviceVector createDevices() { static DeviceVector createDevices() {
return { return {
createDisplay(), createDisplay(),
createSdCard(),
}; };
} }
@@ -3,12 +3,16 @@
#include <Gt911Touch.h> #include <Gt911Touch.h>
#include <PwmBacklight.h> #include <PwmBacklight.h>
#include <RgbDisplay.h> #include <RgbDisplay.h>
#include <tactility/check.h>
#include <tactility/device.h>
std::shared_ptr<tt::hal::touch::TouchDevice> createTouch() { std::shared_ptr<tt::hal::touch::TouchDevice> createTouch() {
// Note for future changes: Reset pin is 38 and interrupt pin is 18 // Note for future changes: Reset pin is 38 and interrupt pin is 18
// or INT = NC, schematic and other info floating around is kinda conflicting... // or INT = NC, schematic and other info floating around is kinda conflicting...
auto* i2c = device_find_by_name("i2c0");
check(i2c);
auto configuration = std::make_unique<Gt911Touch::Configuration>( auto configuration = std::make_unique<Gt911Touch::Configuration>(
I2C_NUM_0, i2c,
800, 800,
480 480
); );
@@ -1,24 +0,0 @@
#include "SdCard.h"
#include <tactility/device.h>
#include <Tactility/hal/sdcard/SpiSdCardDevice.h>
using tt::hal::sdcard::SpiSdCardDevice;
std::shared_ptr<SdCardDevice> createSdCard() {
auto configuration = std::make_unique<SpiSdCardDevice::Config>(
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<SpiSdCardDevice>(
std::move(configuration),
spi_controller
);
}
@@ -1,7 +0,0 @@
#pragma once
#include <Tactility/hal/sdcard/SdCardDevice.h>
using tt::hal::sdcard::SdCardDevice;
std::shared_ptr<SdCardDevice> createSdCard();
@@ -6,6 +6,7 @@
#include <tactility/bindings/esp32_i2c.h> #include <tactility/bindings/esp32_i2c.h>
#include <tactility/bindings/esp32_spi.h> #include <tactility/bindings/esp32_spi.h>
#include <tactility/bindings/esp32_uart.h> #include <tactility/bindings/esp32_uart.h>
#include <tactility/bindings/esp32_sdspi.h>
/ { / {
compatible = "root"; compatible = "root";
@@ -28,12 +29,18 @@
pin-scl = <&gpio0 20 GPIO_FLAG_NONE>; pin-scl = <&gpio0 20 GPIO_FLAG_NONE>;
}; };
sdcard_spi: spi0 { spi0 {
compatible = "espressif,esp32-spi"; compatible = "espressif,esp32-spi";
host = <SPI2_HOST>; host = <SPI2_HOST>;
cs-gpios = <&gpio0 10 GPIO_FLAG_NONE>;
pin-mosi = <&gpio0 11 GPIO_FLAG_NONE>; pin-mosi = <&gpio0 11 GPIO_FLAG_NONE>;
pin-miso = <&gpio0 13 GPIO_FLAG_NONE>; pin-miso = <&gpio0 13 GPIO_FLAG_NONE>;
pin-sclk = <&gpio0 12 GPIO_FLAG_NONE>; pin-sclk = <&gpio0 12 GPIO_FLAG_NONE>;
sdcard@0 {
compatible = "espressif,esp32-sdspi";
frequency-khz = <20000>;
};
}; };
uart0 { uart0 {
@@ -1,6 +1,5 @@
#include "devices/Display.h" #include "devices/Display.h"
#include "devices/Power.h" #include "devices/Power.h"
#include "devices/SdCard.h"
#include <Tactility/hal/Configuration.h> #include <Tactility/hal/Configuration.h>
@@ -9,7 +8,6 @@ using namespace tt::hal;
static DeviceVector createDevices() { static DeviceVector createDevices() {
return { return {
createDisplay(), createDisplay(),
createSdCard(),
createPower() createPower()
}; };
} }
@@ -5,21 +5,22 @@
#include <PwmBacklight.h> #include <PwmBacklight.h>
#include <Tactility/Logger.h> #include <Tactility/Logger.h>
#include <Tactility/Mutex.h> #include <Tactility/Mutex.h>
#include <tactility/check.h>
#include <tactility/device.h>
constexpr auto LCD_PIN_RESET = GPIO_NUM_0; // Match P4 EV board reset line constexpr auto LCD_PIN_RESET = GPIO_NUM_0; // Match P4 EV board reset line
constexpr auto LCD_PIN_BACKLIGHT = GPIO_NUM_23; constexpr auto LCD_PIN_BACKLIGHT = GPIO_NUM_23;
constexpr auto LCD_HORIZONTAL_RESOLUTION = 1024; constexpr auto LCD_HORIZONTAL_RESOLUTION = 1024;
constexpr auto LCD_VERTICAL_RESOLUTION = 600; constexpr auto LCD_VERTICAL_RESOLUTION = 600;
constexpr auto TOUCH_I2C_PORT = I2C_NUM_0;
constexpr auto TOUCH_I2C_SDA = GPIO_NUM_7;
constexpr auto TOUCH_I2C_SCL = GPIO_NUM_8;
constexpr auto TOUCH_PIN_RESET = GPIO_NUM_NC; constexpr auto TOUCH_PIN_RESET = GPIO_NUM_NC;
constexpr auto TOUCH_PIN_INTERRUPT = GPIO_NUM_NC; constexpr auto TOUCH_PIN_INTERRUPT = GPIO_NUM_NC;
static std::shared_ptr<tt::hal::touch::TouchDevice> createTouch() { static std::shared_ptr<tt::hal::touch::TouchDevice> createTouch() {
auto* i2c = device_find_by_name("i2c_internal");
check(i2c);
auto configuration = std::make_unique<Gt911Touch::Configuration>( auto configuration = std::make_unique<Gt911Touch::Configuration>(
TOUCH_I2C_PORT, i2c,
LCD_HORIZONTAL_RESOLUTION, LCD_HORIZONTAL_RESOLUTION,
LCD_VERTICAL_RESOLUTION, LCD_VERTICAL_RESOLUTION,
false, // swapXY false, // swapXY
@@ -1,128 +0,0 @@
#include "SdCard.h"
#include <Tactility/Logger.h>
#include <Tactility/Mutex.h>
#include <Tactility/hal/sdcard/SdCardDevice.h>
#include <driver/sdmmc_defs.h>
#include <driver/sdmmc_host.h>
#include <esp_check.h>
#include <esp_ldo_regulator.h>
#include <esp_vfs_fat.h>
#include <sdmmc_cmd.h>
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<tt::Lock> lock = std::make_shared<NoLock>();
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<tt::Lock> getLock() const override { return lock; }
State getState(TickType_t /*timeout*/) const override {
return mounted ? State::Mounted : State::Unmounted;
}
};
std::shared_ptr<SdCardDevice> createSdCard() {
return std::make_shared<SdCardDeviceImpl>();
}
@@ -1,6 +0,0 @@
#pragma once
#include <Tactility/hal/sdcard/SdCardDevice.h>
// Create SD card device for jc1060p470ciwy using SDMMC slot 0 (4-bit)
std::shared_ptr<tt::hal::sdcard::SdCardDevice> createSdCard();
@@ -5,6 +5,7 @@
#include <tactility/bindings/esp32_gpio.h> #include <tactility/bindings/esp32_gpio.h>
#include <tactility/bindings/esp32_i2c.h> #include <tactility/bindings/esp32_i2c.h>
#include <tactility/bindings/esp32_i2s.h> #include <tactility/bindings/esp32_i2s.h>
#include <tactility/bindings/esp32_sdmmc.h>
/** /**
* For future reference: * For future reference:
@@ -44,4 +45,17 @@
pin-data-in = <&gpio0 48 GPIO_FLAG_NONE>; pin-data-in = <&gpio0 48 GPIO_FLAG_NONE>;
pin-mclk = <&gpio0 13 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>;
slot = <SDMMC_HOST_SLOT_0>;
bus-width = <4>;
on-chip-ldo-chan = <4>;
};
}; };
@@ -1,5 +1,4 @@
#include "devices/Display.h" #include "devices/Display.h"
#include "devices/SdCard.h"
#include <driver/gpio.h> #include <driver/gpio.h>
#include <PwmBacklight.h> #include <PwmBacklight.h>
@@ -24,7 +23,6 @@ static bool initBoot() {
static DeviceVector createDevices() { static DeviceVector createDevices() {
return { return {
createDisplay(), createDisplay(),
createSdCard()
}; };
} }
@@ -1,31 +0,0 @@
#include "SdCard.h"
#include <tactility/device.h>
#include <Tactility/hal/sdcard/SpiSdCardDevice.h>
constexpr auto SDCARD_SPI_HOST = SPI3_HOST;
constexpr auto SDCARD_PIN_CS = GPIO_NUM_5;
using tt::hal::sdcard::SpiSdCardDevice;
std::shared_ptr<SdCardDevice> createSdCard() {
auto configuration = std::make_unique<SpiSdCardDevice::Config>(
SDCARD_PIN_CS,
GPIO_NUM_NC,
GPIO_NUM_NC,
GPIO_NUM_NC,
SdCardDevice::MountBehaviour::AtBoot,
nullptr,
std::vector<gpio_num_t>(),
SDCARD_SPI_HOST
);
auto* spi_controller = device_find_by_name("spi1");
check(spi_controller, "spi1 not found");
return std::make_shared<SpiSdCardDevice>(
std::move(configuration),
spi_controller
);
}
@@ -1,8 +0,0 @@
#pragma once
#include <Tactility/hal/sdcard/SdCardDevice.h>
using tt::hal::sdcard::SdCardDevice;
std::shared_ptr<SdCardDevice> createSdCard();
@@ -5,6 +5,8 @@
#include <tactility/bindings/esp32_i2c.h> #include <tactility/bindings/esp32_i2c.h>
#include <tactility/bindings/esp32_spi.h> #include <tactility/bindings/esp32_spi.h>
#include <tactility/bindings/esp32_uart.h> #include <tactility/bindings/esp32_uart.h>
#include <tactility/bindings/esp32_sdspi.h>
#include <tactility/bindings/display_placeholder.h>
/ { / {
compatible = "root"; compatible = "root";
@@ -32,19 +34,30 @@
pin-scl = <&gpio0 22 GPIO_FLAG_NONE>; pin-scl = <&gpio0 22 GPIO_FLAG_NONE>;
}; };
display_spi: spi0 { spi0 {
compatible = "espressif,esp32-spi"; compatible = "espressif,esp32-spi";
host = <SPI2_HOST>; host = <SPI2_HOST>;
cs-gpios = <&gpio0 15 GPIO_FLAG_NONE>;
pin-mosi = <&gpio0 13 GPIO_FLAG_NONE>; pin-mosi = <&gpio0 13 GPIO_FLAG_NONE>;
pin-sclk = <&gpio0 14 GPIO_FLAG_NONE>; pin-sclk = <&gpio0 14 GPIO_FLAG_NONE>;
display {
compatible = "display-placeholder";
};
}; };
sdcard_spi: spi1 { spi1 {
compatible = "espressif,esp32-spi"; compatible = "espressif,esp32-spi";
host = <SPI3_HOST>; host = <SPI3_HOST>;
cs-gpios = <&gpio0 5 GPIO_FLAG_NONE>;
pin-mosi = <&gpio0 23 GPIO_FLAG_NONE>; pin-mosi = <&gpio0 23 GPIO_FLAG_NONE>;
pin-miso = <&gpio0 19 GPIO_FLAG_NONE>; pin-miso = <&gpio0 19 GPIO_FLAG_NONE>;
pin-sclk = <&gpio0 18 GPIO_FLAG_NONE>; pin-sclk = <&gpio0 18 GPIO_FLAG_NONE>;
sdcard@0 {
compatible = "espressif,esp32-sdspi";
frequency-khz = <20000>;
};
}; };
// CN1 header, JST SH 1.25, GND / IO22 / IO21 / 3.3V // CN1 header, JST SH 1.25, GND / IO22 / IO21 / 3.3V
@@ -2,7 +2,6 @@
#include <Tactility/Logger.h> #include <Tactility/Logger.h>
#include <Tactility/hal/touch/TouchDevice.h> #include <Tactility/hal/touch/TouchDevice.h>
#include <Tactility/lvgl/LvglSync.h>
#include <Axs15231b/Axs15231bTouch.h> #include <Axs15231b/Axs15231bTouch.h>
#include <EspLcdDisplayDriver.h> #include <EspLcdDisplayDriver.h>
@@ -1,6 +1,4 @@
#include "devices/Display.h" #include "devices/Display.h"
#include "devices/SdCard.h"
#include <driver/gpio.h>
#include <Tactility/hal/Configuration.h> #include <Tactility/hal/Configuration.h>
#include <PwmBacklight.h> #include <PwmBacklight.h>
@@ -10,7 +8,6 @@ using namespace tt::hal;
static DeviceVector createDevices() { static DeviceVector createDevices() {
return { return {
createDisplay(), createDisplay(),
createSdCard()
}; };
} }
@@ -1,30 +0,0 @@
#include "SdCard.h"
#include <tactility/device.h>
#include <Tactility/hal/sdcard/SpiSdCardDevice.h>
constexpr auto SDCARD_SPI_HOST = SPI3_HOST;
constexpr auto SDCARD_PIN_CS = GPIO_NUM_10;
using tt::hal::sdcard::SpiSdCardDevice;
std::shared_ptr<SdCardDevice> createSdCard() {
auto configuration = std::make_unique<SpiSdCardDevice::Config>(
SDCARD_PIN_CS,
GPIO_NUM_NC,
GPIO_NUM_NC,
GPIO_NUM_NC,
SdCardDevice::MountBehaviour::AtBoot,
nullptr,
std::vector<gpio_num_t>(),
SDCARD_SPI_HOST
);
auto* spi_controller = device_find_by_name("spi1");
check(spi_controller, "spi1 not found");
return std::make_shared<SpiSdCardDevice>(
std::move(configuration),
spi_controller
);
}
@@ -1,7 +0,0 @@
#pragma once
#include <Tactility/hal/sdcard/SdCardDevice.h>
using tt::hal::sdcard::SdCardDevice;
std::shared_ptr<SdCardDevice> createSdCard();
@@ -7,6 +7,8 @@
#include <tactility/bindings/esp32_i2s.h> #include <tactility/bindings/esp32_i2s.h>
#include <tactility/bindings/esp32_spi.h> #include <tactility/bindings/esp32_spi.h>
#include <tactility/bindings/esp32_uart.h> #include <tactility/bindings/esp32_uart.h>
#include <tactility/bindings/esp32_sdspi.h>
#include <tactility/bindings/display_placeholder.h>
/ { / {
compatible = "root"; compatible = "root";
@@ -45,22 +47,33 @@
pin-data-out = <&gpio0 41 GPIO_FLAG_NONE>; pin-data-out = <&gpio0 41 GPIO_FLAG_NONE>;
}; };
display_spi: spi0 { spi0 {
compatible = "espressif,esp32-spi"; compatible = "espressif,esp32-spi";
host = <SPI2_HOST>; host = <SPI2_HOST>;
cs-gpios = <&gpio0 45 GPIO_FLAG_NONE>;
pin-mosi = <&gpio0 21 GPIO_FLAG_NONE>; pin-mosi = <&gpio0 21 GPIO_FLAG_NONE>;
pin-miso = <&gpio0 48 GPIO_FLAG_NONE>; pin-miso = <&gpio0 48 GPIO_FLAG_NONE>;
pin-sclk = <&gpio0 47 GPIO_FLAG_NONE>; pin-sclk = <&gpio0 47 GPIO_FLAG_NONE>;
pin-wp = <&gpio0 40 GPIO_FLAG_NONE>; pin-wp = <&gpio0 40 GPIO_FLAG_NONE>;
pin-hd = <&gpio0 39 GPIO_FLAG_NONE>; pin-hd = <&gpio0 39 GPIO_FLAG_NONE>;
display {
compatible = "display-placeholder";
};
}; };
sdcard_spi: spi1 { spi1 {
compatible = "espressif,esp32-spi"; compatible = "espressif,esp32-spi";
host = <SPI3_HOST>; host = <SPI3_HOST>;
cs-gpios = <&gpio0 10 GPIO_FLAG_NONE>;
pin-mosi = <&gpio0 11 GPIO_FLAG_NONE>; pin-mosi = <&gpio0 11 GPIO_FLAG_NONE>;
pin-miso = <&gpio0 13 GPIO_FLAG_NONE>; pin-miso = <&gpio0 13 GPIO_FLAG_NONE>;
pin-sclk = <&gpio0 12 GPIO_FLAG_NONE>; pin-sclk = <&gpio0 12 GPIO_FLAG_NONE>;
sdcard@0 {
compatible = "espressif,esp32-sdspi";
frequency-khz = <20000>;
};
}; };
// P1 header // P1 header
@@ -1,7 +1,5 @@
#include "PwmBacklight.h" #include "PwmBacklight.h"
#include "devices/Display.h" #include "devices/Display.h"
#include "devices/SdCard.h"
#include <driver/gpio.h>
#include <Tactility/hal/Configuration.h> #include <Tactility/hal/Configuration.h>
@@ -14,7 +12,6 @@ static bool initBoot() {
static DeviceVector createDevices() { static DeviceVector createDevices() {
return { return {
createDisplay(), createDisplay(),
createSdCard()
}; };
} }
@@ -3,12 +3,16 @@
#include <Gt911Touch.h> #include <Gt911Touch.h>
#include <PwmBacklight.h> #include <PwmBacklight.h>
#include <RgbDisplay.h> #include <RgbDisplay.h>
#include <tactility/check.h>
#include <tactility/device.h>
std::shared_ptr<tt::hal::touch::TouchDevice> createTouch() { std::shared_ptr<tt::hal::touch::TouchDevice> createTouch() {
// Note for future changes: Reset pin is 38 and interrupt pin is 18 // Note for future changes: Reset pin is 38 and interrupt pin is 18
// or INT = NC, schematic and other info floating around is kinda conflicting... // or INT = NC, schematic and other info floating around is kinda conflicting...
auto* i2c = device_find_by_name("i2c0");
check(i2c);
auto configuration = std::make_unique<Gt911Touch::Configuration>( auto configuration = std::make_unique<Gt911Touch::Configuration>(
I2C_NUM_0, i2c,
800, 800,
480 480
); );
@@ -1,24 +0,0 @@
#include "SdCard.h"
#include <tactility/device.h>
#include <Tactility/hal/sdcard/SpiSdCardDevice.h>
using tt::hal::sdcard::SpiSdCardDevice;
std::shared_ptr<SdCardDevice> createSdCard() {
auto config = std::make_unique<SpiSdCardDevice::Config>(
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<SpiSdCardDevice>(
std::move(config),
spi_controller
);
}
@@ -1,7 +0,0 @@
#pragma once
#include <Tactility/hal/sdcard/SdCardDevice.h>
using tt::hal::sdcard::SdCardDevice;
std::shared_ptr<SdCardDevice> createSdCard();

Some files were not shown because too many files have changed in this diff Show More