This commit is contained in:
Ken Van Hoeylandt 2026-01-23 23:58:21 +01:00
parent 44c6f565ac
commit 46447f8f5a
3 changed files with 10 additions and 26 deletions

View File

@ -31,12 +31,6 @@ def find_device_property(device: Device, name: str) -> DeviceProperty:
return property
return None
def find_binding_property(device: Device, name: str) -> BindingProperty:
for property in device.properties:
if property.name == name:
return property
return None
def find_device_binding(device: Device, bindings: list[Binding]) -> Binding:
compatible_property = find_device_property(device, "compatible")
if compatible_property is None:
@ -64,7 +58,7 @@ def property_to_string(property: DeviceProperty) -> str:
raise Exception(f"property_to_string() has an unsupported type: {type}")
def resolve_parameters_from_bindings(device: Device, bindings: list[Binding]) -> list:
compatible_property = find_binding_property(device, "compatible")
compatible_property = find_device_property(device, "compatible")
if compatible_property is None:
raise Exception(f"Cannot find 'compatible' property for {device.identifier}")
device_binding = find_binding(compatible_property.value, bindings)
@ -108,7 +102,7 @@ def write_device_structs(file, device: Device, parent_device: Device, bindings:
print(f"Writing device struct for '{device.identifier}'")
# Assemble some pre-requisites
type_name = get_device_type_name(device, bindings)
compatible_property = find_binding_property(device, "compatible")
compatible_property = find_device_property(device, "compatible")
if compatible_property is None:
raise Exception(f"Cannot find 'compatible' property for {device.identifier}")
identifier = get_device_identifier_safe(device)
@ -134,7 +128,7 @@ def write_device_init(file, device: Device, bindings: list[Binding], verbose: bo
if verbose:
print(f"Processing device init code for '{device.identifier}'")
# Assemble some pre-requisites
compatible_property = find_binding_property(device, "compatible")
compatible_property = find_device_property(device, "compatible")
if compatible_property is None:
raise Exception(f"Cannot find 'compatible' property for {device.identifier}")
# Type & instance names
@ -166,7 +160,7 @@ def generate_devicetree_c(filename: str, items: list[object], bindings: list[Bin
#define TAG LOG_TAG(devicetree)
static int init_builtin_device(struct Device* device, const char* compatible) {
struct Driver* driver = driver_find(compatible);
struct Driver* driver = driver_find_compatible(compatible);
if (driver == NULL) {
LOG_E(TAG, "Can't find driver: %s", compatible);
return -1;

View File

@ -29,7 +29,7 @@ static bool set_options(Device* device, gpio_pin_t pin, gpio_flags_t options) {
}
gpio_mode_t mode;
if (options & (GPIO_DIRECTION_INPUT_OUTPUT)) {
if ((options & GPIO_DIRECTION_INPUT_OUTPUT) == GPIO_DIRECTION_INPUT_OUTPUT) {
mode = GPIO_MODE_INPUT_OUTPUT;
} else if (options & GPIO_DIRECTION_INPUT) {
mode = GPIO_MODE_INPUT;
@ -77,10 +77,6 @@ static bool get_options(Device* device, gpio_pin_t pin, gpio_flags_t* options) {
output |= GPIO_DIRECTION_OUTPUT;
}
if (esp_config.oe) {
output |= GPIO_DIRECTION_OUTPUT;
}
if (esp_config.oe_inv) {
output |= GPIO_ACTIVE_LOW;
}

View File

@ -1,14 +1,8 @@
#pragma once
#include <errno.h>
#define CUSTOM_ERROR_CODE(x) (2000 + x)
// TODO: Make more aliases for common errors
#define ERROR_UNDEFINED CUSTOM_ERROR_CODE(1)
#define ERROR_INVALID_STATE CUSTOM_ERROR_CODE(2)
#define ERROR_INVALID_ARGUMENT EINVAL
#define ERROR_MISSING_PARAMETER CUSTOM_ERROR_CODE(3)
#define ERROR_NOT_FOUND CUSTOM_ERROR_CODE(4)
#define ERROR_UNDEFINED 1
#define ERROR_INVALID_STATE 2
#define ERROR_INVALID_ARGUMENT 3
#define ERROR_MISSING_PARAMETER 4
#define ERROR_NOT_FOUND 5