HardFOC Flux V1 HAL
Unified HAL API for the HardFOC Flux valve-control platform (ESP32-S3)
Loading...
Searching...
No Matches
flux_hal_types.hpp
Go to the documentation of this file.
1
24#ifndef FLUX_HAL_TYPES_HPP_
25#define FLUX_HAL_TYPES_HPP_
26
27#include <cstdint>
28
29namespace flux::hal {
30
37enum class ManagerError : uint16_t {
38 None = 0,
39 NotInitialized = 1,
40 BindFailed = 2,
41 HardwareFault = 3,
42 InvalidArgument = 4,
43 Busy = 5,
44 Unsupported = 6,
46};
47
49constexpr const char* ToString(ManagerError e) noexcept {
50 switch (e) {
51 case ManagerError::None: return "None";
52 case ManagerError::NotInitialized: return "NotInitialized";
53 case ManagerError::BindFailed: return "BindFailed";
54 case ManagerError::HardwareFault: return "HardwareFault";
55 case ManagerError::InvalidArgument: return "InvalidArgument";
56 case ManagerError::Busy: return "Busy";
57 case ManagerError::Unsupported: return "Unsupported";
58 case ManagerError::DependencyNotReady: return "DependencyNotReady";
59 }
60 return "Unknown";
61}
62
69struct HalResult {
70 bool ok;
72 uint32_t detail;
73
75 static constexpr HalResult Ok() noexcept { return {true, ManagerError::None, 0}; }
76
78 static constexpr HalResult Err(ManagerError c, uint32_t d = 0) noexcept { return {false, c, d}; }
79};
80
81} // namespace flux::hal
82
83#endif // FLUX_HAL_TYPES_HPP_
Definition flux_hal_types.hpp:29
ManagerError
Lifecycle / bind failure catalog shared by every manager (GetManagerError()).
Definition flux_hal_types.hpp:37
@ BindFailed
A bus, pin or platform object could not be created.
@ InvalidArgument
Caller passed an invalid argument.
@ DependencyNotReady
A manager this one needs is not initialised.
@ HardwareFault
A fitted chip did not come up or reported a fault.
@ None
No error recorded.
@ NotInitialized
Manager not initialised (or shut down)
@ Unsupported
Operation or part not supported on this build.
@ Busy
Manager busy / re-entrant call refused.
constexpr const char * ToString(ManagerError e) noexcept
Short name of a ManagerError, for logs and diagnostics.
Definition flux_hal_types.hpp:49
Facade operation result.
Definition flux_hal_types.hpp:69
uint32_t detail
Optional manager / driver code (0 if unused)
Definition flux_hal_types.hpp:72
bool ok
true on success
Definition flux_hal_types.hpp:70
static constexpr HalResult Err(ManagerError c, uint32_t d=0) noexcept
A failure result.
Definition flux_hal_types.hpp:78
ManagerError code
None on success.
Definition flux_hal_types.hpp:71
static constexpr HalResult Ok() noexcept
A success result.
Definition flux_hal_types.hpp:75