mirror of
https://github.com/ByteWelder/Tactility.git
synced 2026-02-18 19:03:16 +00:00
* **New Features** * Added public accessors for querying module/device start and ready state. * **Refactor** * Internal state moved to opaque internal objects; module/device/driver initializers now explicitly initialize internal pointers. * Lifecycle handling updated to construct/destruct internal state and use accessors. * **Tests** * Tests updated to use public accessors and explicit construct/destruct lifecycle calls. * **Chores** * Test build/include paths and small metadata updated.
40 lines
1.3 KiB
C++
40 lines
1.3 KiB
C++
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
#include <tactility/driver.h>
|
|
#include <tactility/drivers/gpio_controller.h>
|
|
|
|
#define GPIO_DRIVER_API(driver) ((struct GpioControllerApi*)driver->api)
|
|
|
|
extern "C" {
|
|
|
|
error_t gpio_controller_set_level(Device* device, gpio_pin_t pin, bool high) {
|
|
const auto* driver = device_get_driver(device);
|
|
return GPIO_DRIVER_API(driver)->set_level(device, pin, high);
|
|
}
|
|
|
|
error_t gpio_controller_get_level(Device* device, gpio_pin_t pin, bool* high) {
|
|
const auto* driver = device_get_driver(device);
|
|
return GPIO_DRIVER_API(driver)->get_level(device, pin, high);
|
|
}
|
|
|
|
error_t gpio_controller_set_options(Device* device, gpio_pin_t pin, gpio_flags_t options) {
|
|
const auto* driver = device_get_driver(device);
|
|
return GPIO_DRIVER_API(driver)->set_options(device, pin, options);
|
|
}
|
|
|
|
error_t gpio_controller_get_options(Device* device, gpio_pin_t pin, gpio_flags_t* options) {
|
|
const auto* driver = device_get_driver(device);
|
|
return GPIO_DRIVER_API(driver)->get_options(device, pin, options);
|
|
}
|
|
|
|
error_t gpio_controller_get_pin_count(struct Device* device, uint32_t* count) {
|
|
const auto* driver = device_get_driver(device);
|
|
return GPIO_DRIVER_API(driver)->get_pin_count(device, count);
|
|
}
|
|
|
|
extern const struct DeviceType GPIO_CONTROLLER_TYPE {
|
|
.name = "gpio-controller"
|
|
};
|
|
|
|
}
|