HF Interface Wrapper 0.1.0-dev
Embedded C++ hardware abstraction layer
Loading...
Searching...
No Matches
HardwareTypes.h
Go to the documentation of this file.
1
27#pragma once
28
29#include <cstdint>
30#include <limits>
31
32//==============================================================================
33// PLATFORM-AGNOSTIC TYPE WRAPPING
34//==============================================================================
35
40using hf_u8_t = uint8_t;
41
46using hf_u16_t = uint16_t;
47
52using hf_u32_t = uint32_t;
53
58using hf_u64_t = uint64_t;
59
64using hf_i8_t = int8_t;
65
70using hf_i16_t = int16_t;
71
76using hf_i32_t = int32_t;
77
82using hf_i64_t = int64_t;
83
88using hf_bool_t = bool;
89
90//==============================================================================
91// PLATFORM-AGNOSTIC GPIO TYPES
92//==============================================================================
93
100
105
110
111//==============================================================================
112// PLATFORM-AGNOSTIC PORT/CONTROLLER TYPES
113//==============================================================================
114
121
125constexpr hf_port_num_t HF_INVALID_PORT = std::numeric_limits<hf_port_num_t>::max();
126
132
136constexpr hf_host_id_t HF_INVALID_HOST = std::numeric_limits<hf_host_id_t>::max();
137
138//==============================================================================
139// COMMUNICATION FREQUENCY TYPES
140//==============================================================================
141
146
149
154
155//==============================================================================
156// CHANNEL AND TIMING TYPES
157//==============================================================================
158
164
168constexpr hf_channel_id_t HF_INVALID_CHANNEL = std::numeric_limits<hf_channel_id_t>::max();
169
174
179
184
189
190//==============================================================================
191// TIMEOUT CONSTANTS
192//==============================================================================
193
198
203
207constexpr hf_time_t HF_TIMEOUT_MAX = std::numeric_limits<hf_time_t>::max();
208
209//==============================================================================
210// VALIDATION FUNCTIONS
211//==============================================================================
212
218constexpr bool IsValidPin(hf_pin_num_t pin) noexcept {
219 return pin >= 0 && pin <= HF_MAX_PIN_NUMBER;
220}
221
227constexpr bool IsValidPort(hf_port_num_t port) noexcept {
228 return port != HF_INVALID_PORT;
229}
230
236constexpr bool IsValidHost(hf_host_id_t host) noexcept {
237 return host != HF_INVALID_HOST;
238}
239
245constexpr bool IsValidChannel(hf_channel_id_t channel) noexcept {
246 return channel != HF_INVALID_CHANNEL;
247}
hf_u64_t hf_timestamp_us_t
Definition BasePeriodicTimer.h:27
uint32_t hf_u32_t
Platform-agnostic 32-bit unsigned integer type.
Definition HardwareTypes.h:52
hf_frequency_hz_t hf_frequency_t
Backward compatibility alias.
Definition HardwareTypes.h:148
hf_time_t hf_timeout_ms_t
Timeout value in milliseconds.
Definition HardwareTypes.h:178
int16_t hf_i16_t
Platform-agnostic 16-bit signed integer type.
Definition HardwareTypes.h:70
constexpr hf_time_t HF_TIMEOUT_DEFAULT_MS
Default timeout value in milliseconds.
Definition HardwareTypes.h:197
hf_u32_t hf_time_t
Platform-agnostic time type in milliseconds.
Definition HardwareTypes.h:173
constexpr hf_time_t HF_TIMEOUT_NONE
No timeout (wait indefinitely).
Definition HardwareTypes.h:202
constexpr hf_time_t HF_TIMEOUT_MAX
Maximum timeout value.
Definition HardwareTypes.h:207
uint8_t hf_u8_t
Platform-agnostic 8-bit unsigned integer type.
Definition HardwareTypes.h:40
constexpr hf_pin_num_t HF_INVALID_PIN
Invalid pin constant for unassigned or invalid pins.
Definition HardwareTypes.h:104
constexpr bool IsValidHost(hf_host_id_t host) noexcept
Check if a host ID is valid.
Definition HardwareTypes.h:236
hf_u32_t hf_port_num_t
Platform-agnostic port/controller identifier type.
Definition HardwareTypes.h:120
hf_i32_t hf_pin_num_t
Platform-agnostic GPIO pin number type.
Definition HardwareTypes.h:99
int32_t hf_i32_t
Platform-agnostic 32-bit signed integer type.
Definition HardwareTypes.h:76
hf_time_t hf_timeout_us_t
Timeout value in microseconds.
Definition HardwareTypes.h:183
constexpr hf_host_id_t HF_INVALID_HOST
Invalid host constant for unassigned or invalid hosts.
Definition HardwareTypes.h:136
int8_t hf_i8_t
Platform-agnostic 8-bit signed integer type.
Definition HardwareTypes.h:64
constexpr hf_pin_num_t HF_MAX_PIN_NUMBER
Maximum pin number supported by the abstraction layer.
Definition HardwareTypes.h:109
bool hf_bool_t
Platform-agnostic boolean type.
Definition HardwareTypes.h:88
hf_u32_t hf_host_id_t
Platform-agnostic host/controller identifier type.
Definition HardwareTypes.h:131
constexpr bool IsValidChannel(hf_channel_id_t channel) noexcept
Check if a channel ID is valid.
Definition HardwareTypes.h:245
constexpr bool IsValidPin(hf_pin_num_t pin) noexcept
Check if a pin number is valid.
Definition HardwareTypes.h:218
uint64_t hf_u64_t
Platform-agnostic 64-bit unsigned integer type.
Definition HardwareTypes.h:58
int64_t hf_i64_t
Platform-agnostic 64-bit signed integer type.
Definition HardwareTypes.h:82
constexpr bool IsValidPort(hf_port_num_t port) noexcept
Check if a port number is valid.
Definition HardwareTypes.h:227
uint16_t hf_u16_t
Platform-agnostic 16-bit unsigned integer type.
Definition HardwareTypes.h:46
constexpr hf_port_num_t HF_INVALID_PORT
Invalid port constant for unassigned or invalid ports.
Definition HardwareTypes.h:125
hf_u32_t hf_channel_id_t
Platform-agnostic channel identifier type.
Definition HardwareTypes.h:163
hf_u32_t hf_frequency_hz_t
Platform-agnostic frequency type (in Hz).
Definition HardwareTypes.h:145
hf_u32_t hf_baud_rate_t
Platform-agnostic baud rate type.
Definition HardwareTypes.h:153
constexpr hf_channel_id_t HF_INVALID_CHANNEL
Invalid channel constant for unassigned or invalid channels.
Definition HardwareTypes.h:168