HF Interface Wrapper 0.1.0-dev
Embedded C++ hardware abstraction layer
Loading...
Searching...
No Matches
BaseGpio.h File Reference

Unified GPIO base class for all digital GPIO implementations. More...

#include "HardwareTypes.h"
#include <cstdint>
#include <string_view>
Include dependency graph for BaseGpio.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  InterruptStatus
 GPIO interrupt status structure. More...
 
struct  hf_gpio_statistics_t
 GPIO operation statistics. More...
 
struct  hf_gpio_diagnostics_t
 GPIO diagnostic information. More...
 
class  BaseGpio
 Unified GPIO base class for all digital GPIO implementations. More...
 

Macros

#define HF_GPIO_ERR_LIST(X)
 HardFOC GPIO error codes macro list.
 
#define X(NAME, VALUE, DESC)   NAME = VALUE,
 
#define X(NAME, VALUE, DESC)
 

Typedefs

using InterruptCallback
 GPIO interrupt callback function type.
 

Enumerations

enum class  hf_gpio_err_t : hf_u8_t {
  hf_gpio_err_t::X , hf_gpio_err_t::GPIO_SUCCESS = 0 , hf_gpio_err_t::GPIO_ERR_FAILURE = 1 , hf_gpio_err_t::GPIO_ERR_NOT_INITIALIZED = 2 ,
  hf_gpio_err_t::GPIO_ERR_ALREADY_INITIALIZED = 3 , hf_gpio_err_t::GPIO_ERR_INVALID_PARAMETER = 4 , hf_gpio_err_t::GPIO_ERR_NULL_POINTER = 5 , hf_gpio_err_t::GPIO_ERR_OUT_OF_MEMORY = 6 ,
  hf_gpio_err_t::GPIO_ERR_INVALID_PIN = 7 , hf_gpio_err_t::GPIO_ERR_PIN_NOT_FOUND = 8 , hf_gpio_err_t::GPIO_ERR_PIN_NOT_CONFIGURED = 9 , hf_gpio_err_t::GPIO_ERR_PIN_ALREADY_REGISTERED = 10 ,
  hf_gpio_err_t::GPIO_ERR_PIN_ACCESS_DENIED = 11 , hf_gpio_err_t::GPIO_ERR_PIN_BUSY = 12 , hf_gpio_err_t::GPIO_ERR_HARDWARE_FAULT = 13 , hf_gpio_err_t::GPIO_ERR_COMMUNICATION_FAILURE = 14 ,
  hf_gpio_err_t::GPIO_ERR_DEVICE_NOT_RESPONDING = 15 , hf_gpio_err_t::GPIO_ERR_TIMEOUT = 16 , hf_gpio_err_t::GPIO_ERR_VOLTAGE_OUT_OF_RANGE = 17 , hf_gpio_err_t::GPIO_ERR_INVALID_CONFIGURATION = 18 ,
  hf_gpio_err_t::GPIO_ERR_UNSUPPORTED_OPERATION = 19 , hf_gpio_err_t::GPIO_ERR_RESOURCE_BUSY = 20 , hf_gpio_err_t::GPIO_ERR_RESOURCE_UNAVAILABLE = 21 , hf_gpio_err_t::GPIO_ERR_READ_FAILURE = 22 ,
  hf_gpio_err_t::GPIO_ERR_WRITE_FAILURE = 23 , hf_gpio_err_t::GPIO_ERR_DIRECTION_MISMATCH = 24 , hf_gpio_err_t::GPIO_ERR_PULL_RESISTOR_FAILURE = 25 , hf_gpio_err_t::GPIO_ERR_INTERRUPT_NOT_SUPPORTED = 26 ,
  hf_gpio_err_t::GPIO_ERR_INTERRUPT_ALREADY_ENABLED = 27 , hf_gpio_err_t::GPIO_ERR_INTERRUPT_NOT_ENABLED = 28 , hf_gpio_err_t::GPIO_ERR_INTERRUPT_HANDLER_FAILED = 29 , hf_gpio_err_t::GPIO_ERR_SYSTEM_ERROR = 30 ,
  hf_gpio_err_t::GPIO_ERR_PERMISSION_DENIED = 31 , hf_gpio_err_t::GPIO_ERR_OPERATION_ABORTED = 32 , hf_gpio_err_t::GPIO_ERR_NOT_SUPPORTED = 33 , hf_gpio_err_t::GPIO_ERR_DRIVER_ERROR = 34 ,
  hf_gpio_err_t::GPIO_ERR_INVALID_STATE = 35 , hf_gpio_err_t::GPIO_ERR_INVALID_ARG = 36 , hf_gpio_err_t::GPIO_ERR_CALIBRATION_FAILURE = 37 , hf_gpio_err_t::GPIO_ERR_UNKNOWN = 38 ,
  hf_gpio_err_t::GPIO_ERR_COUNT
}
 HardFOC GPIO error codes. More...
 
enum class  hf_gpio_state_t : hf_u8_t { hf_gpio_state_t::HF_GPIO_STATE_INACTIVE = 0 , hf_gpio_state_t::HF_GPIO_STATE_ACTIVE = 1 }
 GPIO pin logical states. More...
 
enum class  hf_gpio_level_t : hf_u8_t { hf_gpio_level_t::HF_GPIO_LEVEL_LOW = 0 , hf_gpio_level_t::HF_GPIO_LEVEL_HIGH = 1 }
 GPIO pin electrical levels. More...
 
enum class  hf_gpio_active_state_t : hf_u8_t { hf_gpio_active_state_t::HF_GPIO_ACTIVE_LOW = 0 , hf_gpio_active_state_t::HF_GPIO_ACTIVE_HIGH = 1 }
 GPIO active state polarity configuration. More...
 
enum class  hf_gpio_direction_t : hf_u8_t { hf_gpio_direction_t::HF_GPIO_DIRECTION_INPUT = 0 , hf_gpio_direction_t::HF_GPIO_DIRECTION_OUTPUT = 1 }
 GPIO pin direction/mode configuration. More...
 
enum class  hf_gpio_output_mode_t : hf_u8_t { hf_gpio_output_mode_t::HF_GPIO_OUTPUT_MODE_PUSH_PULL = 0 , hf_gpio_output_mode_t::HF_GPIO_OUTPUT_MODE_OPEN_DRAIN = 1 }
 GPIO output drive modes. More...
 
enum class  hf_gpio_pull_mode_t : hf_u8_t { hf_gpio_pull_mode_t::HF_GPIO_PULL_MODE_FLOATING = 0 , hf_gpio_pull_mode_t::HF_GPIO_PULL_MODE_UP = 1 , hf_gpio_pull_mode_t::HF_GPIO_PULL_MODE_DOWN = 2 , hf_gpio_pull_mode_t::HF_GPIO_PULL_MODE_UP_DOWN = 3 }
 GPIO pull resistor configuration. More...
 
enum class  hf_gpio_interrupt_trigger_t : hf_u8_t {
  hf_gpio_interrupt_trigger_t::HF_GPIO_INTERRUPT_TRIGGER_NONE = 0 , hf_gpio_interrupt_trigger_t::HF_GPIO_INTERRUPT_TRIGGER_RISING_EDGE = 1 , hf_gpio_interrupt_trigger_t::HF_GPIO_INTERRUPT_TRIGGER_FALLING_EDGE = 2 , hf_gpio_interrupt_trigger_t::HF_GPIO_INTERRUPT_TRIGGER_BOTH_EDGES = 3 ,
  hf_gpio_interrupt_trigger_t::HF_GPIO_INTERRUPT_TRIGGER_LOW_LEVEL = 4 , hf_gpio_interrupt_trigger_t::HF_GPIO_INTERRUPT_TRIGGER_HIGH_LEVEL = 5
}
 GPIO interrupt trigger types. More...
 

Functions

constexpr std::string_view HfGpioErrToString (hf_gpio_err_t err) noexcept
 Convert hf_gpio_err_t to human-readable string.
 

Detailed Description

Unified GPIO base class for all digital GPIO implementations.

This file contains the declaration of the BaseGpio abstract class, which provides a comprehensive GPIO abstraction that serves as the base for all GPIO implementations in the HardFOC system. It supports dynamic mode switching, configurable polarity, pull resistors, interrupt handling, and works across different hardware platforms including MCU GPIOs, I2C GPIO expanders, SPI GPIO expanders, and other GPIO hardware.

Author
Nebiyu Tadesse
Date
2025
Note
This class is not thread-safe. Use appropriate synchronization if accessed from multiple contexts.

Macro Definition Documentation

◆ X [1/2]

#define X ( NAME,
VALUE,
DESC )   NAME = VALUE,

◆ X [2/2]

#define X ( NAME,
VALUE,
DESC )
Value:
case hf_gpio_err_t::NAME: \
return DESC;