|
HardFOC Flux V1 HAL
Unified HAL API for the HardFOC Flux valve-control platform (ESP32-S3)
|
Singleton that manages all MCU GPIO pins defined in the X-MACRO pin config. More...
#include <GpioManager.h>
Public Member Functions | |
| GpioManager (const GpioManager &)=delete | |
| GpioManager & | operator= (const GpioManager &)=delete |
| GpioManager (GpioManager &&)=delete | |
| GpioManager & | operator= (GpioManager &&)=delete |
| bool | EnsureInitialized () noexcept |
| Register all GPIO pins and initialise drivers (idempotent). | |
| bool | IsInitialized () const noexcept |
| Check whether the manager is initialised. | |
| bool | Deinitialize () noexcept |
| Reset GPIO manager to uninitialized state. | |
| hf_gpio_err_t | GetLastError () const noexcept |
| Get the most recent error code. | |
| flux::hal::ManagerError | GetManagerError () const noexcept |
Lifecycle / bind error of the last EnsureInitialized() (shared catalog). | |
| BaseGpio * | Get (std::string_view name) noexcept |
| Get the BaseGpio driver for a named pin. Returns nullptr if not found. | |
| BaseGpio * | Get (HfFunctionalGpioPin pin) noexcept |
| Get the BaseGpio driver for a functional pin enum. Returns nullptr if not found. | |
| bool | Contains (std::string_view name) const noexcept |
| Check if a named pin exists in the registry. | |
| size_t | Size () const noexcept |
| Number of registered GPIO pins. | |
| hf_gpio_err_t | Set (std::string_view name, bool value) noexcept |
| Set a GPIO output to high (true) or low (false). | |
| hf_gpio_err_t | SetActive (std::string_view name) noexcept |
| Drive a pin to its active state. | |
| hf_gpio_err_t | SetInactive (std::string_view name) noexcept |
| Drive a pin to its inactive state. | |
| hf_gpio_err_t | Read (std::string_view name, bool &state) noexcept |
| Read the current digital level of a pin. | |
| hf_gpio_err_t | Toggle (std::string_view name) noexcept |
| Toggle pin output between high and low. | |
| hf_gpio_err_t | IsActive (std::string_view name, bool &active) noexcept |
| Check whether a pin is currently in its active state. | |
| hf_gpio_err_t | SetDirection (std::string_view name, hf_gpio_direction_t direction) noexcept |
| Change pin direction (input / output / open-drain). | |
| hf_gpio_err_t | SetPullMode (std::string_view name, hf_gpio_pull_mode_t pull_mode) noexcept |
| Configure internal pull-up / pull-down resistors. | |
| hf_gpio_err_t | SetOutputMode (std::string_view name, hf_gpio_output_mode_t mode) noexcept |
| Configure output driver mode (push-pull or open-drain). | |
| hf_gpio_err_t | ConfigureInterrupt (std::string_view name, hf_gpio_interrupt_trigger_t trigger, InterruptCallback callback, void *user_data=nullptr) noexcept |
| Configure interrupt on a named GPIO pin. | |
| hf_gpio_err_t | EnableInterrupt (std::string_view name) noexcept |
| Enable a previously configured interrupt on a named pin. | |
| hf_gpio_err_t | DisableInterrupt (std::string_view name) noexcept |
| Disable the interrupt on a named pin. | |
| bool | SupportsInterrupts (std::string_view name) const noexcept |
| Check whether a pin's underlying driver supports interrupts. | |
| hf_gpio_err_t | GetSystemDiagnostics (GpioSystemDiagnostics &diagnostics) const noexcept |
| Populate a diagnostics snapshot. | |
| void | DumpStatistics () const noexcept |
| Log current GPIO state and statistics to the console. | |
Static Public Member Functions | |
| static GpioManager & | GetInstance () noexcept |
| Access the singleton instance (Meyers singleton, thread-safe). | |
Private Member Functions | |
| GpioManager () noexcept=default | |
| ~GpioManager ()=default | |
| bool | Initialize () noexcept |
| void | ReleaseLocked () noexcept |
| size_t | FindByName (std::string_view name) const noexcept |
| Find entry index by string name. Returns kInvalidIndex if not found. | |
Private Attributes | |
| std::array< GpioEntry, kMaxEntries > | entries_ {} |
| size_t | registered_count_ {0} |
| uint64_t | init_time_ms_ {0} |
| Timestamp (ms) when Initialize() completed. | |
| uint32_t | total_ops_ {0} |
| uint32_t | successful_ops_ {0} |
| uint32_t | failed_ops_ {0} |
| hf_gpio_err_t | last_error_ {hf_gpio_err_t::GPIO_SUCCESS} |
| std::atomic< bool > | initialized_ {false} |
| std::atomic< flux::hal::ManagerError > | manager_error_ {flux::hal::ManagerError::NotInitialized} |
| RtosMutex | mutex_ |
Static Private Attributes | |
| static constexpr size_t | kMaxEntries = static_cast<size_t>(HfFunctionalGpioPin::HF_FUNCTIONAL_GPIO_COUNT) |
| Maximum registerable GPIO entries (all GPIO + USER pins from pincfg). | |
| static constexpr size_t | kInvalidIndex = SIZE_MAX |
Singleton that manages all MCU GPIO pins defined in the X-MACRO pin config.
Registers GPIO and USER category pins, provides name-based and enum-based access to the underlying BaseGpio drivers, and offers high-level Set/Read/Toggle/Interrupt operations routed by pin name. Thread-safe via RtosMutex.
|
delete |
|
delete |
|
privatedefaultnoexcept |
|
privatedefault |
|
noexcept |
Configure interrupt on a named GPIO pin.
| name | Pin name from pincfg |
| trigger | Interrupt trigger edge/level |
| callback | Function called on interrupt (keep minimal — ISR context) |
| user_data | Optional user data passed to callback |
|
noexcept |
Check if a named pin exists in the registry.
|
noexcept |
Reset GPIO manager to uninitialized state.
|
noexcept |
Disable the interrupt on a named pin.
| name | Pin name from pincfg. |
|
noexcept |
Log current GPIO state and statistics to the console.
|
noexcept |
Enable a previously configured interrupt on a named pin.
| name | Pin name from pincfg. |
|
noexcept |
Register all GPIO pins and initialise drivers (idempotent).
|
privatenoexcept |
Find entry index by string name. Returns kInvalidIndex if not found.
|
noexcept |
Get the BaseGpio driver for a functional pin enum. Returns nullptr if not found.
|
noexcept |
Get the BaseGpio driver for a named pin. Returns nullptr if not found.
|
staticnoexcept |
Access the singleton instance (Meyers singleton, thread-safe).
|
inlinenoexcept |
Get the most recent error code.
|
inlinenoexcept |
Lifecycle / bind error of the last EnsureInitialized() (shared catalog).
BindFailed when any GPIO-category pin of the pin map could not be created or initialised (fail-closed: the manager then stays uninitialised).
|
noexcept |
Populate a diagnostics snapshot.
| [out] | diagnostics | Struct filled with current counters and state. |
|
privatenoexcept |
|
noexcept |
Check whether a pin is currently in its active state.
| name | Pin name from pincfg. | |
| [out] | active | true if pin is active. |
|
inlinenoexcept |
Check whether the manager is initialised.
|
delete |
|
delete |
|
noexcept |
Read the current digital level of a pin.
| name | Pin name from pincfg. | |
| [out] | state | true = high, false = low. |
|
privatenoexcept |
|
noexcept |
Set a GPIO output to high (true) or low (false).
| name | Pin name from pincfg. |
| value | true = active/high, false = inactive/low. |
|
noexcept |
Drive a pin to its active state.
| name | Pin name from pincfg. |
|
noexcept |
Change pin direction (input / output / open-drain).
| name | Pin name from pincfg. |
| direction | Desired direction. |
|
noexcept |
Drive a pin to its inactive state.
| name | Pin name from pincfg. |
|
noexcept |
Configure output driver mode (push-pull or open-drain).
| name | Pin name from pincfg. |
| mode | Desired output mode. |
|
noexcept |
Configure internal pull-up / pull-down resistors.
| name | Pin name from pincfg. |
| pull_mode | Desired pull mode. |
|
noexcept |
Number of registered GPIO pins.
|
noexcept |
Check whether a pin's underlying driver supports interrupts.
| name | Pin name from pincfg. |
|
noexcept |
Toggle pin output between high and low.
| name | Pin name from pincfg. |
|
private |
|
private |
|
private |
Timestamp (ms) when Initialize() completed.
|
private |
|
staticconstexprprivate |
|
staticconstexprprivate |
Maximum registerable GPIO entries (all GPIO + USER pins from pincfg).
|
private |
|
private |
|
mutableprivate |
|
private |
|
private |
|
private |