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

Abstract base class for Programmable IO Channel implementations in the HardFOC system. More...

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

Go to the source code of this file.

Classes

struct  hf_pio_channel_config_t
 PIO channel configuration structure. More...
 
struct  hf_pio_symbol_t
 PIO symbol structure for precise timing. More...
 
struct  hf_pio_channel_status_t
 PIO channel status information. More...
 
struct  hf_pio_capabilities_t
 PIO capability information. More...
 
struct  hf_pio_statistics_t
 PIO operation statistics. More...
 
struct  hf_pio_diagnostics_t
 PIO diagnostic information. More...
 
class  BasePio
 Abstract base class for Programmable IO Channel implementations. More...
 

Macros

#define HF_PIO_ERR_LIST(X)
 HardFOC PIO error codes.
 
#define X(NAME, VALUE, DESC)   NAME = VALUE,
 
#define X(NAME, VALUE, DESC)
 

Typedefs

using hf_pio_transmit_callback_t
 Callback for PIO transmission complete events.
 
using hf_pio_receive_callback_t = void(*)( hf_u8_t channel_id, const hf_pio_symbol_t* symbols, size_t symbol_count, void* user_data)
 Callback for PIO reception complete events.
 
using hf_pio_error_callback_t
 Callback for PIO error events.
 

Enumerations

enum class  hf_pio_err_t : hf_u8_t {
  X , PIO_SUCCESS = 0 , PIO_ERR_FAILURE = 1 , PIO_ERR_NOT_INITIALIZED = 2 ,
  PIO_ERR_ALREADY_INITIALIZED = 3 , PIO_ERR_INVALID_PARAMETER = 4 , PIO_ERR_NULL_POINTER = 5 , PIO_ERR_OUT_OF_MEMORY = 6 ,
  PIO_ERR_INVALID_CHANNEL = 7 , PIO_ERR_CHANNEL_BUSY = 8 , PIO_ERR_CHANNEL_NOT_AVAILABLE = 9 , PIO_ERR_INSUFFICIENT_CHANNELS = 10 ,
  PIO_ERR_INVALID_RESOLUTION = 11 , PIO_ERR_RESOLUTION_TOO_HIGH = 12 , PIO_ERR_RESOLUTION_TOO_LOW = 13 , PIO_ERR_DURATION_TOO_LONG = 14 ,
  PIO_ERR_DURATION_TOO_SHORT = 15 , PIO_ERR_BUFFER_OVERFLOW = 16 , PIO_ERR_BUFFER_UNDERFLOW = 17 , PIO_ERR_BUFFER_TOO_SMALL = 18 ,
  PIO_ERR_BUFFER_TOO_LARGE = 19 , PIO_ERR_HARDWARE_FAULT = 20 , PIO_ERR_COMMUNICATION_TIMEOUT = 21 , PIO_ERR_COMMUNICATION_FAILURE = 22 ,
  PIO_ERR_DEVICE_NOT_RESPONDING = 23 , PIO_ERR_INVALID_CONFIGURATION = 24 , PIO_ERR_UNSUPPORTED_OPERATION = 25 , PIO_ERR_PIN_CONFLICT = 26 ,
  PIO_ERR_RESOURCE_BUSY = 27 , PIO_ERR_SYSTEM_ERROR = 28 , PIO_ERR_PERMISSION_DENIED = 29 , PIO_ERR_OPERATION_ABORTED = 30 ,
  PIO_ERR_UNKNOWN = 31
}
 
enum class  hf_pio_direction_t : hf_u8_t { Transmit = 0 , Receive = 1 , Bidirectional = 2 }
 PIO channel direction. More...
 
enum class  hf_pio_polarity_t : hf_u8_t { Normal = 0 , Inverted = 1 }
 PIO signal polarity. More...
 
enum class  hf_pio_idle_state_t : hf_u8_t { Low = 0 , High = 1 }
 PIO idle state. More...
 

Functions

constexpr std::string_view HfPioErrToString (hf_pio_err_t err) noexcept
 Convert hf_pio_err_t to human-readable string.
 

Detailed Description

Abstract base class for Programmable IO Channel implementations in the HardFOC system.

This header defines the abstract base class for precise, buffered digital signal I/O that provides a consistent API across different PIO implementations. Concrete implementations for various microcontrollers inherit from this class.

Author
Nebiyu Tadesse
Date
2025
Note
This is a header-only abstract base class following the same pattern as BaseCan/BaseAdc/BasePwm.
Users should program against this interface, not specific implementations.

Macro Definition Documentation

◆ X [1/2]

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

◆ X [2/2]

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

Typedef Documentation

◆ hf_pio_error_callback_t

Initial value:
void(*)(hf_u8_t channel_id, hf_pio_err_t error, void* user_data)
hf_pio_err_t
Definition BasePio.h:83
uint8_t hf_u8_t
Platform-agnostic 8-bit unsigned integer type.
Definition HardwareTypes.h:40

Callback for PIO error events.

Parameters
channel_idChannel that encountered error
errorError that occurred
user_dataUser-provided data

◆ hf_pio_receive_callback_t

using hf_pio_receive_callback_t = void(*)( hf_u8_t channel_id, const hf_pio_symbol_t* symbols, size_t symbol_count, void* user_data)

Callback for PIO reception complete events.

Parameters
channel_idChannel that received data
symbolsReceived symbols
symbol_countNumber of symbols received
user_dataUser-provided data

◆ hf_pio_transmit_callback_t

Initial value:
void(*)(hf_u8_t channel_id, size_t symbols_sent, void* user_data)

Callback for PIO transmission complete events.

Parameters
channel_idChannel that completed transmission
symbols_sentNumber of symbols transmitted
user_dataUser-provided data

Enumeration Type Documentation

◆ hf_pio_direction_t

enum class hf_pio_direction_t : hf_u8_t
strong

PIO channel direction.

Enumerator
Transmit 

Transmit mode (output)

Receive 

Receive mode (input)

Bidirectional 

Bidirectional mode (if supported)

◆ hf_pio_err_t

enum class hf_pio_err_t : hf_u8_t
strong
Enumerator
PIO_SUCCESS 
PIO_ERR_FAILURE 
PIO_ERR_NOT_INITIALIZED 
PIO_ERR_ALREADY_INITIALIZED 
PIO_ERR_INVALID_PARAMETER 
PIO_ERR_NULL_POINTER 
PIO_ERR_OUT_OF_MEMORY 
PIO_ERR_INVALID_CHANNEL 
PIO_ERR_CHANNEL_BUSY 
PIO_ERR_CHANNEL_NOT_AVAILABLE 
PIO_ERR_INSUFFICIENT_CHANNELS 
PIO_ERR_INVALID_RESOLUTION 
PIO_ERR_RESOLUTION_TOO_HIGH 
PIO_ERR_RESOLUTION_TOO_LOW 
PIO_ERR_DURATION_TOO_LONG 
PIO_ERR_DURATION_TOO_SHORT 
PIO_ERR_BUFFER_OVERFLOW 
PIO_ERR_BUFFER_UNDERFLOW 
PIO_ERR_BUFFER_TOO_SMALL 
PIO_ERR_BUFFER_TOO_LARGE 
PIO_ERR_HARDWARE_FAULT 
PIO_ERR_COMMUNICATION_TIMEOUT 
PIO_ERR_COMMUNICATION_FAILURE 
PIO_ERR_DEVICE_NOT_RESPONDING 
PIO_ERR_INVALID_CONFIGURATION 
PIO_ERR_UNSUPPORTED_OPERATION 
PIO_ERR_PIN_CONFLICT 
PIO_ERR_RESOURCE_BUSY 
PIO_ERR_SYSTEM_ERROR 
PIO_ERR_PERMISSION_DENIED 
PIO_ERR_OPERATION_ABORTED 
PIO_ERR_UNKNOWN 

◆ hf_pio_idle_state_t

enum class hf_pio_idle_state_t : hf_u8_t
strong

PIO idle state.

Enumerator
Low 

Idle state is low.

High 

Idle state is high.

◆ hf_pio_polarity_t

enum class hf_pio_polarity_t : hf_u8_t
strong

PIO signal polarity.

Enumerator
Normal 

Normal polarity (idle low, active high)

Inverted 

Inverted polarity (idle high, active low)

Function Documentation

◆ HfPioErrToString()

constexpr std::string_view HfPioErrToString ( hf_pio_err_t err)
constexprnoexcept

Convert hf_pio_err_t to human-readable string.

Parameters
errThe error code to convert
Returns
String view of the error description