mirror of
https://github.com/ByteWelder/Tactility.git
synced 2026-02-19 03:13:14 +00:00
* **New Features** * Thread API with lifecycle, priority, affinity and state monitoring * Timer subsystem: one-shot/periodic timers, reset, pending callbacks, expiry queries * Expanded I²C: register-level ops, bulk writes, presence checks, ESP32 integration and new config properties * GPIO controller: pin level and options APIs * Error utilities: new error code, error-to-string, timeout helper and common macros * Device construction helpers (construct+start) * **Tests** * New unit tests for thread and timer behavior * **Documentation** * Expanded coding style guide (files/folders, C conventions)
99 lines
3.3 KiB
C
99 lines
3.3 KiB
C
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
#pragma once
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#include "gpio.h"
|
|
#include <tactility/error.h>
|
|
|
|
struct GpioControllerApi {
|
|
/**
|
|
* @brief Sets the logical level of a GPIO pin.
|
|
* @param[in] device the GPIO controller device
|
|
* @param[in] pin the pin index
|
|
* @param[in] high true to set the pin high, false to set it low
|
|
* @return ERROR_NONE if successful
|
|
*/
|
|
error_t (*set_level)(struct Device* device, gpio_pin_t pin, bool high);
|
|
|
|
/**
|
|
* @brief Gets the logical level of a GPIO pin.
|
|
* @param[in] device the GPIO controller device
|
|
* @param[in] pin the pin index
|
|
* @param[out] high pointer to store the pin level
|
|
* @return ERROR_NONE if successful
|
|
*/
|
|
error_t (*get_level)(struct Device* device, gpio_pin_t pin, bool* high);
|
|
|
|
/**
|
|
* @brief Configures the options for a GPIO pin.
|
|
* @param[in] device the GPIO controller device
|
|
* @param[in] pin the pin index
|
|
* @param[in] options configuration flags (direction, pull-up/down, etc.)
|
|
* @return ERROR_NONE if successful
|
|
*/
|
|
error_t (*set_options)(struct Device* device, gpio_pin_t pin, gpio_flags_t options);
|
|
|
|
/**
|
|
* @brief Gets the configuration options for a GPIO pin.
|
|
* @param[in] device the GPIO controller device
|
|
* @param[in] pin the pin index
|
|
* @param[out] options pointer to store the configuration flags
|
|
* @return ERROR_NONE if successful
|
|
*/
|
|
error_t (*get_options)(struct Device* device, gpio_pin_t pin, gpio_flags_t* options);
|
|
};
|
|
|
|
/**
|
|
* @brief Sets the logical level of a GPIO pin.
|
|
* @param[in] device the GPIO controller device
|
|
* @param[in] pin the pin index
|
|
* @param[in] high true to set the pin high, false to set it low
|
|
* @return ERROR_NONE if successful
|
|
*/
|
|
error_t gpio_controller_set_level(struct Device* device, gpio_pin_t pin, bool high);
|
|
|
|
/**
|
|
* @brief Gets the logical level of a GPIO pin.
|
|
* @param[in] device the GPIO controller device
|
|
* @param[in] pin the pin index
|
|
* @param[out] high pointer to store the pin level
|
|
* @return ERROR_NONE if successful
|
|
*/
|
|
error_t gpio_controller_get_level(struct Device* device, gpio_pin_t pin, bool* high);
|
|
|
|
/**
|
|
* @brief Configures the options for a GPIO pin.
|
|
* @param[in] device the GPIO controller device
|
|
* @param[in] pin the pin index
|
|
* @param[in] options configuration flags (direction, pull-up/down, etc.)
|
|
* @return ERROR_NONE if successful
|
|
*/
|
|
error_t gpio_controller_set_options(struct Device* device, gpio_pin_t pin, gpio_flags_t options);
|
|
|
|
/**
|
|
* @brief Gets the configuration options for a GPIO pin.
|
|
* @param[in] device the GPIO controller device
|
|
* @param[in] pin the pin index
|
|
* @param[out] options pointer to store the configuration flags
|
|
* @return ERROR_NONE if successful
|
|
*/
|
|
error_t gpio_controller_get_options(struct Device* device, gpio_pin_t pin, gpio_flags_t* options);
|
|
|
|
/**
|
|
* @brief Configures the options for a GPIO pin using a pin configuration structure.
|
|
* @param[in] device the GPIO controller device
|
|
* @param[in] config the pin configuration structure
|
|
* @return ERROR_NONE if successful
|
|
*/
|
|
static inline error_t gpio_set_options_config(struct Device* device, const struct GpioPinConfig* config) {
|
|
return gpio_controller_set_options(device, config->pin, config->flags);
|
|
}
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|