This commit is contained in:
Ken Van Hoeylandt 2026-01-22 08:16:22 +01:00
parent 0d9cfe8e8b
commit 33fbf44a68
7 changed files with 15 additions and 38 deletions

View File

@ -8,7 +8,7 @@ class DeviceTreeConfig:
bindings: list[str] = field(default_factory=list)
dts: str = ""
def parse_config(file_path: str, project_root: str) -> list[DeviceTreeConfig]:
def parse_config(file_path: str, project_root: str) -> DeviceTreeConfig:
"""
Parses devicetree.yaml and recursively finds dependencies.
Returns a list of DeviceTreeConfig objects in post-order (dependencies first).

View File

@ -146,23 +146,6 @@ def write_device_init(file, device: Device, bindings: list[Binding], verbose: bo
for child_device in device.devices:
write_device_init(file, child_device, bindings, verbose)
def write_device_list_entry(file, device: Device):
compatible_property = find_binding_property(device, "compatible")
if compatible_property is None:
raise Exception(f"Cannot find 'compatible' property for {device.identifier}")
identifier = get_device_identifier_safe(device)
file.write(f"\t&{identifier},\n")
for child in device.devices:
write_device_list_entry(file, child)
def write_device_list(file, devices: list[Device]):
file.write("struct device* devices_builtin[] = {\n")
for device in devices:
write_device_list_entry(file, device)
# Terminator
file.write(f"\tNULL\n")
file.write("};\n\n")
def generate_devicetree_c(filename: str, items: list[object], bindings: list[Binding], verbose: bool):
with open(filename, "w") as file:
file.write(dedent('''\

View File

@ -19,7 +19,7 @@ struct InternalData {
}
};
#define GET_CONFIG(device) ((Esp32I2cConfig*)device->internal.driver_data)
#define GET_CONFIG(device) ((Esp32I2cConfig*)device->config)
#define GET_DATA(device) ((InternalData*)device->internal.driver_data)
#define lock(data) mutex_lock(&data->mutex);
@ -52,7 +52,7 @@ static bool write_read(Device* device, uint8_t address, const uint8_t* write_dat
auto* driver_data = GET_DATA(device);
lock(driver_data);
const esp_err_t result = i2c_master_write_read_device(GET_CONFIG(device)->port, address, write_data, write_data_size, read_data, read_data_size, timeout);
unlock(driver_data)
unlock(driver_data);
ESP_ERROR_CHECK_WITHOUT_ABORT(result);
return result == ESP_OK;
}

View File

@ -2,26 +2,17 @@ cmake_minimum_required(VERSION 3.20)
file(GLOB_RECURSE SOURCE_FILES "Source/*.c*")
# Determine device identifier and project location
if (DEFINED ENV{ESP_IDF_VERSION})
include("../Buildscripts/device.cmake")
init_tactility_globals("../sdkconfig")
get_property(TACTILITY_DEVICE_PROJECT GLOBAL PROPERTY TACTILITY_DEVICE_PROJECT)
else ()
set(TACTILITY_DEVICE_PROJECT "Devices/simulator")
endif ()
set(DEVICETREE_LOCATION "Devices/${TACTILITY_DEVICE_ID}")
if (NOT DEFINED ${COMPONENT_LIB})
if (NOT DEFINED ENV{ESP_IDF_VERSION})
set(COMPONENT_LIB FirmwareSim)
endif ()
if (DEFINED ENV{ESP_IDF_VERSION})
include("../Buildscripts/device.cmake")
init_tactility_globals("../sdkconfig")
get_property(TACTILITY_DEVICE_PROJECT GLOBAL PROPERTY TACTILITY_DEVICE_PROJECT)
idf_component_register(
SRCS ${SOURCE_FILES}
REQUIRES ${DEVICE_COMPONENTS}
REQUIRES Tactility TactilityC TactilityKernel drivers-esp ${TACTILITY_DEVICE_PROJECT}
)

View File

@ -2,7 +2,7 @@
#include <sys/errno.h>
#define CUSTOM_ERROR_CODE(x) (-__ELASTERROR - x)
#define CUSTOM_ERROR_CODE(x) (-2000 - x)
#define ERROR_UNDEFINED CUSTOM_ERROR_CODE(1)
#define ERROR_INVALID_STATE CUSTOM_ERROR_CODE(2)

View File

@ -1,5 +1,8 @@
#pragma once
#include "freertos/semphr.h"
#include <Tactility/FreeRTOS/semphr.h>
#ifdef __cplusplus
@ -23,7 +26,7 @@ inline static void recursive_mutex_destruct(struct RecursiveMutex* mutex) {
inline static void recursive_mutex_lock(struct RecursiveMutex* mutex) {
assert(mutex->handle != NULL);
xSemaphoreTake(mutex->handle, portMAX_DELAY);
xSemaphoreTakeRecursive(mutex->handle, portMAX_DELAY);
}
inline static bool recursive_mutex_is_locked(struct RecursiveMutex* mutex) {
@ -33,12 +36,12 @@ inline static bool recursive_mutex_is_locked(struct RecursiveMutex* mutex) {
inline static bool recursive_mutex_try_lock(struct RecursiveMutex* mutex) {
assert(mutex->handle != NULL);
return xSemaphoreTake(mutex->handle, 0) == pdTRUE;
return xSemaphoreTakeRecursive(mutex->handle, 0) == pdTRUE;
}
inline static void recursive_mutex_unlock(struct RecursiveMutex* mutex) {
assert(mutex->handle != NULL);
xSemaphoreGive(mutex->handle);
xSemaphoreGiveRecursive(mutex->handle);
}
#ifdef __cplusplus

View File

@ -1,6 +1,6 @@
#ifndef ESP_PLATFORM
#include <tactility/log.h>
#include <Tactility/Log.h>
#include <stdio.h>
#include <stdarg.h>