GPIO refactored (#495)
* **Refactor** * GPIO subsystem moved to a descriptor-based model for per-pin ownership and runtime pin management; many platform drivers now acquire/release descriptors. * Device trees and drivers now use GPIO phandle-style pin specifications across all boards and all drivers. * **Behavior** * Device list now encodes per-device status (ok/disabled); boot will skip disabled devices accordingly. * **Deprecation** * Legacy GPIO HAL marked deprecated and replaced with descriptor-based interfaces. * **Chores** * Bindings and platform configs updated to the new GPIO pin-spec format.
This commit is contained in:
committed by
GitHub
parent
dff93cb655
commit
26c17986c6
@@ -7,33 +7,12 @@ extern "C" {
|
||||
|
||||
using namespace tt::hal;
|
||||
|
||||
static Device* find_first_gpio_controller() {
|
||||
Device* device_result = nullptr;
|
||||
device_for_each_of_type(&GPIO_CONTROLLER_TYPE, &device_result, [](Device* device, void* context) {
|
||||
if (device_is_ready(device)) {
|
||||
auto** device_result_ptr = static_cast<Device**>(context);
|
||||
*device_result_ptr = device;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
return device_result;
|
||||
}
|
||||
|
||||
bool tt_hal_gpio_get_level(GpioPin pin) {
|
||||
Device* device_result = find_first_gpio_controller();
|
||||
if (device_result == nullptr) return false;
|
||||
bool pin_state = false;
|
||||
if (gpio_controller_get_level(device_result, pin, &pin_state) != ERROR_NONE) return false;
|
||||
return pin_state;
|
||||
return false;
|
||||
}
|
||||
|
||||
int tt_hal_gpio_get_pin_count() {
|
||||
Device* device_result = find_first_gpio_controller();
|
||||
if (device_result == nullptr) return 0;
|
||||
uint32_t pin_count = 0;
|
||||
if (gpio_controller_get_pin_count(device_result, &pin_count) != ERROR_NONE) return 0;
|
||||
return (int)pin_count;
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user