|
HF Interface Wrapper 0.1.0-dev
Embedded C++ hardware abstraction layer
|
STM32 GPIO implementation with full HAL integration. More...
#include <StmGpio.h>
Public Member Functions | |
| StmGpio (hf_pin_num_t pin_num, GPIO_TypeDef *port, hf_u16_t hal_pin_mask, hf_gpio_direction_t direction=hf_gpio_direction_t::HF_GPIO_DIRECTION_INPUT, hf_gpio_active_state_t active_state=hf_gpio_active_state_t::HF_GPIO_ACTIVE_HIGH, hf_gpio_output_mode_t output_mode=hf_gpio_output_mode_t::HF_GPIO_OUTPUT_MODE_PUSH_PULL, hf_gpio_pull_mode_t pull_mode=hf_gpio_pull_mode_t::HF_GPIO_PULL_MODE_FLOATING, hf_gpio_drive_cap_t drive_capability=hf_gpio_drive_cap_t::HF_GPIO_DRIVE_CAP_MEDIUM) noexcept | |
| Full constructor with HAL port + pin mask. | |
| StmGpio (const hf_stm32_gpio_config_t &config) noexcept | |
| Construct from config struct. | |
| ~StmGpio () noexcept override | |
| bool | Initialize () noexcept override |
| Initialize the GPIO pin with current configuration. | |
| bool | IsPinAvailable () const noexcept override |
| Check if the pin is available for GPIO operations. | |
| hf_u8_t | GetMaxPins () const noexcept override |
| Get the maximum number of pins supported by this GPIO instance. | |
| const char * | GetDescription () const noexcept override |
| Get human-readable description of this GPIO instance. | |
| GPIO_TypeDef * | GetPort () const noexcept |
| hf_u16_t | GetHalPinMask () const noexcept |
Public Member Functions inherited from BaseGpio | |
| BaseGpio (const BaseGpio ©)=delete | |
| Copy constructor is deleted to avoid copying instances. | |
| BaseGpio & | operator= (const BaseGpio ©)=delete |
| Assignment operator is deleted to avoid copying instances. | |
| virtual | ~BaseGpio () noexcept=default |
| Virtual destructor for proper cleanup of derived classes. | |
| bool | IsInitialized () const noexcept |
| Check if the pin is initialized. | |
| bool | EnsureInitialized () noexcept |
| Ensures the pin is initialized (lazy initialization). | |
| bool | EnsureDeinitialized () noexcept |
| Ensures the pin is deinitialized (lazy deinitialization). | |
| hf_pin_num_t | GetPin () const noexcept |
| Get the GPIO pin number/identifier. | |
| hf_gpio_direction_t | GetDirection () const noexcept |
| Get the current pin direction. | |
| hf_gpio_err_t | SetDirection (hf_gpio_direction_t direction) noexcept |
| Set the pin direction (input or output). | |
| bool | IsInput () const noexcept |
| Check if the pin is currently configured as input. | |
| bool | IsOutput () const noexcept |
| Check if the pin is currently configured as output. | |
| hf_gpio_output_mode_t | GetOutputMode () const noexcept |
| Get the output drive mode. | |
| hf_gpio_err_t | SetOutputMode (hf_gpio_output_mode_t mode) noexcept |
| Set the output drive mode. | |
| hf_gpio_pull_mode_t | GetPullMode () const noexcept |
| Get the current pull resistor mode. | |
| hf_gpio_err_t | SetPullMode (hf_gpio_pull_mode_t mode) noexcept |
| Set the pull resistor mode. | |
| hf_gpio_state_t | GetCurrentState () const noexcept |
| Get the current logical state of the pin. | |
| hf_gpio_err_t | SetState (hf_gpio_state_t state) noexcept |
| Set the pin to a specific logical state. | |
| hf_gpio_active_state_t | GetActiveState () const noexcept |
| Get the active state polarity configuration. | |
| void | SetActiveState (hf_gpio_active_state_t active_state) noexcept |
| Set the active state polarity configuration. | |
| hf_gpio_err_t | SetActive () noexcept |
| Set the GPIO to active state. | |
| hf_gpio_err_t | SetInactive () noexcept |
| Set the GPIO to inactive state. | |
| hf_gpio_err_t | Toggle () noexcept |
| Toggle the GPIO state. | |
| hf_gpio_err_t | IsActive (bool &is_active) noexcept |
| Check if the GPIO is currently active. | |
| hf_gpio_err_t | VerifyDirection (hf_gpio_direction_t &direction) const noexcept |
| Verify current direction setting by reading from hardware registers. | |
| hf_gpio_err_t | VerifyOutputMode (hf_gpio_output_mode_t &mode) const noexcept |
| Verify current output mode setting by reading from hardware registers. | |
| hf_gpio_err_t | VerifyHardwareConfiguration () const noexcept |
| Perform comprehensive hardware verification of all pin settings. | |
| virtual hf_gpio_err_t | SupportsInterrupts () const noexcept |
| Check if this GPIO implementation supports interrupts. | |
| virtual hf_gpio_err_t | ConfigureInterrupt (hf_gpio_interrupt_trigger_t trigger, InterruptCallback callback=nullptr, void *user_data=nullptr) noexcept |
| Configure GPIO interrupt settings. | |
| virtual hf_gpio_err_t | EnableInterrupt () noexcept |
| Enable GPIO interrupt. | |
| virtual hf_gpio_err_t | DisableInterrupt () noexcept |
| Disable GPIO interrupt. | |
| virtual hf_gpio_err_t | WaitForInterrupt (hf_u32_t timeout_ms=0) noexcept |
| Wait for GPIO interrupt to occur. | |
| virtual hf_gpio_err_t | GetInterruptStatus (InterruptStatus &status) noexcept |
| Get interrupt status information. | |
| virtual hf_gpio_err_t | ClearInterruptStats () noexcept |
| Clear interrupt statistics. | |
| virtual hf_gpio_err_t | ResetStatistics () noexcept |
| Reset GPIO operation statistics. | |
| virtual hf_gpio_err_t | ResetDiagnostics () noexcept |
| Reset GPIO diagnostic information. | |
| virtual hf_gpio_err_t | GetStatistics (hf_gpio_statistics_t &statistics) const noexcept |
| Get GPIO operation statistics. | |
| virtual hf_gpio_err_t | GetDiagnostics (hf_gpio_diagnostics_t &diagnostics) const noexcept |
| Get GPIO diagnostic information. | |
| virtual bool | Deinitialize () noexcept |
| Deinitialize the GPIO pin. | |
Static Public Member Functions | |
| static void | ExtiCallbackDispatch (hf_u16_t gpio_pin_mask) noexcept |
| Route EXTI callback to the registered StmGpio instance. | |
Static Public Member Functions inherited from BaseGpio | |
| static const char * | ToString (hf_gpio_state_t state) noexcept |
| static const char * | ToString (hf_gpio_level_t level) noexcept |
| static const char * | ToString (hf_gpio_active_state_t active_state) noexcept |
| static const char * | ToString (hf_gpio_direction_t direction) noexcept |
| static const char * | ToString (hf_gpio_output_mode_t output_mode) noexcept |
| static const char * | ToString (hf_gpio_pull_mode_t pull_mode) noexcept |
| static const char * | ToString (hf_gpio_interrupt_trigger_t trigger) noexcept |
Protected Member Functions | |
| hf_gpio_err_t | SetDirectionImpl (hf_gpio_direction_t direction) noexcept override |
| Platform-specific implementation for setting pin direction. | |
| hf_gpio_err_t | GetDirectionImpl (hf_gpio_direction_t &direction) const noexcept override |
| Hardware read-back of current pin direction from registers. | |
| hf_gpio_err_t | SetOutputModeImpl (hf_gpio_output_mode_t mode) noexcept override |
| Platform-specific implementation for setting output mode. | |
| hf_gpio_err_t | GetOutputModeImpl (hf_gpio_output_mode_t &mode) const noexcept override |
| Hardware read-back of current output mode from registers. | |
| hf_gpio_err_t | SetPullModeImpl (hf_gpio_pull_mode_t mode) noexcept override |
| Platform-specific implementation for setting pull resistor mode. | |
| hf_gpio_pull_mode_t | GetPullModeImpl () const noexcept override |
| Hardware read-back of current pull resistor mode from registers. | |
| hf_gpio_err_t | SetPinLevelImpl (hf_gpio_level_t level) noexcept override |
| Platform-specific implementation for setting pin electrical level. | |
| hf_gpio_err_t | GetPinLevelImpl (hf_gpio_level_t &level) noexcept override |
| Platform-specific implementation for getting pin electrical level. | |
Protected Member Functions inherited from BaseGpio | |
| hf_gpio_err_t | ValidateBasicOperation () const noexcept |
| Validate basic parameters before GPIO operations. | |
| hf_gpio_level_t | StateToLevel (hf_gpio_state_t state) const noexcept |
| Convert logical state to electrical level based on polarity. | |
| hf_gpio_state_t | LevelToState (hf_gpio_level_t level) const noexcept |
| Convert electrical level to logical state based on polarity. | |
| BaseGpio (hf_pin_num_t pin_num, hf_gpio_direction_t direction=hf_gpio_direction_t::HF_GPIO_DIRECTION_INPUT, hf_gpio_active_state_t active_state=hf_gpio_active_state_t::HF_GPIO_ACTIVE_HIGH, hf_gpio_output_mode_t output_mode=hf_gpio_output_mode_t::HF_GPIO_OUTPUT_MODE_PUSH_PULL, hf_gpio_pull_mode_t pull_mode=hf_gpio_pull_mode_t::HF_GPIO_PULL_MODE_FLOATING) noexcept | |
| Protected constructor with configuration. | |
Private Member Functions | |
| void | ApplyHalConfig () noexcept |
| Rebuild and apply HAL_GPIO_Init for the current config. | |
Private Attributes | |
| GPIO_TypeDef * | port_ |
| hf_u16_t | hal_pin_mask_ |
| hf_gpio_direction_t | direction_ |
| hf_gpio_output_mode_t | output_mode_ |
| hf_gpio_pull_mode_t | pull_mode_ |
| hf_gpio_drive_cap_t | drive_cap_ |
Static Private Attributes | |
| static StmGpio * | s_exti_instances_ [16] = {} |
| Static EXTI dispatch table — one slot per EXTI line (0–15). | |
Additional Inherited Members | |
Protected Attributes inherited from BaseGpio | |
| const hf_pin_num_t | pin_ |
| GPIO pin number/identifier. | |
| bool | initialized_ |
| Initialization state flag. | |
| hf_gpio_direction_t | current_direction_ |
| Current pin direction. | |
| hf_gpio_active_state_t | active_state_ |
| Active state polarity. | |
| hf_gpio_output_mode_t | output_mode_ |
| Output drive mode. | |
| hf_gpio_pull_mode_t | pull_mode_ |
| Pull resistor configuration. | |
| hf_gpio_state_t | current_state_ |
| Current logical state. | |
| hf_gpio_statistics_t | statistics_ |
| GPIO operation statistics. | |
| hf_gpio_diagnostics_t | diagnostics_ |
| GPIO diagnostic information. | |
STM32 GPIO implementation with full HAL integration.
Design:
|
explicitnoexcept |
Full constructor with HAL port + pin mask.
| pin_num | Logical pin number (encoded: port*16 + pin_index). |
| port | GPIO_TypeDef* port (e.g. GPIOA). |
| hal_pin_mask | HAL pin bitmask (e.g. GPIO_PIN_5 = 1<<5). |
| direction | Input / Output / Bidirectional. |
| active_state | Active high / low. |
| output_mode | Push-pull / Open-drain. |
| pull_mode | None / Pull-up / Pull-down. |
| drive_capability | Low / Medium / High / Very-High. |
|
explicitnoexcept |
Construct from config struct.
|
overridenoexcept |
|
privatenoexcept |
Rebuild and apply HAL_GPIO_Init for the current config.
|
staticnoexcept |
Route EXTI callback to the registered StmGpio instance.
Usage:
|
overridevirtualnoexcept |
Get human-readable description of this GPIO instance.
Implements BaseGpio.
|
overrideprotectedvirtualnoexcept |
Hardware read-back of current pin direction from registers.
| direction | Output parameter: actual hardware pin direction |
Reads the actual direction configuration from hardware registers. Useful for fault detection and hardware verification.
Implements BaseGpio.
|
inlinenoexcept |
|
overridevirtualnoexcept |
Get the maximum number of pins supported by this GPIO instance.
Implements BaseGpio.
|
overrideprotectedvirtualnoexcept |
Hardware read-back of current output mode from registers.
| mode | Output parameter: actual hardware output mode |
Reads the actual output mode configuration from hardware registers. Useful for fault detection and hardware verification.
Implements BaseGpio.
|
overrideprotectedvirtualnoexcept |
Platform-specific implementation for getting pin electrical level.
| level | Output parameter: current electrical level (Low or High) |
Implements BaseGpio.
|
inlinenoexcept |
|
overrideprotectedvirtualnoexcept |
Hardware read-back of current pull resistor mode from registers.
Reads the actual pull resistor configuration from hardware registers. Useful for fault detection and hardware verification.
Implements BaseGpio.
|
overridevirtualnoexcept |
Initialize the GPIO pin with current configuration.
Implements BaseGpio.
|
overridevirtualnoexcept |
Check if the pin is available for GPIO operations.
Implements BaseGpio.
|
overrideprotectedvirtualnoexcept |
Platform-specific implementation for setting pin direction.
| direction | New pin direction (Input or Output) |
Implements BaseGpio.
|
overrideprotectedvirtualnoexcept |
Platform-specific implementation for setting output mode.
| mode | New output mode (PushPull or OpenDrain) |
Implements BaseGpio.
|
overrideprotectedvirtualnoexcept |
Platform-specific implementation for setting pin electrical level.
| level | New electrical level (Low or High) |
Implements BaseGpio.
|
overrideprotectedvirtualnoexcept |
Platform-specific implementation for setting pull resistor mode.
| mode | New pull resistor mode (Floating, PullUp, PullDown) |
Implements BaseGpio.
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
staticprivate |
Static EXTI dispatch table — one slot per EXTI line (0–15).