Add name to DeviceType

This commit is contained in:
Ken Van Hoeylandt 2026-02-06 15:10:24 +01:00
parent adef122b00
commit 36817aaaea
4 changed files with 10 additions and 5 deletions

View File

@ -20,8 +20,7 @@ struct DeviceInternal;
/** Enables discovering devices of the same type */ /** Enables discovering devices of the same type */
struct DeviceType { struct DeviceType {
/* Placeholder because empty structs have a different size with C vs C++ compilers */ const char* name;
uint8_t _;
}; };
/** Represents a piece of hardware */ /** Represents a piece of hardware */

View File

@ -32,6 +32,8 @@ error_t gpio_controller_get_pin_count(struct Device* device, uint32_t* count) {
return GPIO_DRIVER_API(driver)->get_pin_count(device, count); return GPIO_DRIVER_API(driver)->get_pin_count(device, count);
} }
extern const struct DeviceType GPIO_CONTROLLER_TYPE { 0 }; extern const struct DeviceType GPIO_CONTROLLER_TYPE {
.name = "gpio-controller"
};
} }

View File

@ -49,6 +49,8 @@ error_t i2c_controller_has_device_at_address(Device* device, uint8_t address, Ti
return I2C_DRIVER_API(driver)->write(device, address, message, 2, timeout); return I2C_DRIVER_API(driver)->write(device, address, message, 2, timeout);
} }
extern const struct DeviceType I2C_CONTROLLER_TYPE { 0 }; extern const struct DeviceType I2C_CONTROLLER_TYPE {
.name = "i2c-controller"
};
} }

View File

@ -32,6 +32,8 @@ error_t i2s_controller_reset(struct Device* device) {
return I2S_DRIVER_API(driver)->reset(device); return I2S_DRIVER_API(driver)->reset(device);
} }
extern const struct DeviceType I2S_CONTROLLER_TYPE { 0 }; extern const struct DeviceType I2S_CONTROLLER_TYPE {
.name = "i2s-controller"
};
} }