Partial reimplementation of TactilityC GPIO (#469)

* **New Features**
  * Added a GPIO hardware abstraction layer for reading pin levels from applications.
  * Applications can now query the number of available GPIO pins so they can adapt to different devices.
* **Chores**
  * Integrations updated so GPIO capabilities are discoverable and exported to running applications.
This commit is contained in:
Ken Van Hoeylandt
2026-01-31 12:34:45 +01:00
committed by GitHub
parent c9185740d7
commit 399dca5e14
7 changed files with 107 additions and 3 deletions
@@ -45,6 +45,14 @@ struct GpioControllerApi {
* @return ERROR_NONE if successful
*/
error_t (*get_options)(struct Device* device, gpio_pin_t pin, gpio_flags_t* options);
/**
* @brief Gets the number of pins supported by the controller.
* @param[in] device the GPIO controller device
* @param[out] count pointer to store the number of pins
* @return ERROR_NONE if successful
*/
error_t (*get_pin_count)(struct Device* device, uint32_t* count);
};
/**
@@ -83,6 +91,14 @@ error_t gpio_controller_set_options(struct Device* device, gpio_pin_t pin, gpio_
*/
error_t gpio_controller_get_options(struct Device* device, gpio_pin_t pin, gpio_flags_t* options);
/**
* @brief Gets the number of pins supported by the controller.
* @param[in] device the GPIO controller device
* @param[out] count pointer to store the number of pins
* @return ERROR_NONE if successful
*/
error_t gpio_controller_get_pin_count(struct Device* device, uint32_t* count);
/**
* @brief Configures the options for a GPIO pin using a pin configuration structure.
* @param[in] device the GPIO controller device
@@ -93,6 +109,8 @@ static inline error_t gpio_set_options_config(struct Device* device, const struc
return gpio_controller_set_options(device, config->pin, config->flags);
}
extern const struct DeviceType GPIO_CONTROLLER_TYPE;
#ifdef __cplusplus
}
#endif
@@ -27,4 +27,11 @@ error_t gpio_controller_get_options(Device* device, gpio_pin_t pin, gpio_flags_t
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);
}
const struct DeviceType GPIO_CONTROLLER_TYPE { 0 };
}