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

Abstract base class for SPI device implementations in the HardFOC system. More...

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

Go to the source code of this file.

Classes

struct  hf_spi_statistics_t
 SPI operation statistics. More...
 
struct  hf_spi_diagnostics_t
 SPI diagnostic information. More...
 
class  BaseSpi
 Abstract base class for SPI device implementations. More...
 

Macros

#define HF_SPI_ERR_LIST(X)
 HardFOC SPI error codes.
 
#define X(NAME, VALUE, DESC)   NAME = VALUE,
 
#define X(NAME, VALUE, DESC)
 

Enumerations

enum class  hf_spi_err_t : hf_u8_t {
  X , SPI_SUCCESS = 0 , SPI_ERR_FAILURE = 1 , SPI_ERR_NOT_INITIALIZED = 2 ,
  SPI_ERR_ALREADY_INITIALIZED = 3 , SPI_ERR_INVALID_PARAMETER = 4 , SPI_ERR_NULL_POINTER = 5 , SPI_ERR_OUT_OF_MEMORY = 6 ,
  SPI_ERR_BUS_BUSY = 7 , SPI_ERR_BUS_ERROR = 8 , SPI_ERR_BUS_NOT_AVAILABLE = 9 , SPI_ERR_BUS_TIMEOUT = 10 ,
  SPI_ERR_TRANSFER_FAILED = 11 , SPI_ERR_TRANSFER_TIMEOUT = 12 , SPI_ERR_TRANSFER_TOO_LONG = 13 , SPI_ERR_TRANSFER_SIZE_MISMATCH = 14 ,
  SPI_ERR_DEVICE_NOT_FOUND = 15 , SPI_ERR_DEVICE_NOT_RESPONDING = 16 , SPI_ERR_CS_CONTROL_FAILED = 17 , SPI_ERR_HARDWARE_FAULT = 18 ,
  SPI_ERR_COMMUNICATION_FAILURE = 19 , SPI_ERR_VOLTAGE_OUT_OF_RANGE = 20 , SPI_ERR_CLOCK_ERROR = 21 , SPI_ERR_INVALID_CONFIGURATION = 22 ,
  SPI_ERR_UNSUPPORTED_OPERATION = 23 , SPI_ERR_INVALID_CLOCK_SPEED = 24 , SPI_ERR_INVALID_MODE = 25 , SPI_ERR_PIN_CONFIGURATION_ERROR = 26 ,
  SPI_ERR_SYSTEM_ERROR = 27 , SPI_ERR_PERMISSION_DENIED = 28 , SPI_ERR_OPERATION_ABORTED = 29 , SPI_ERR_UNKNOWN = 30
}
 

Functions

constexpr std::string_view HfSpiErrToString (hf_spi_err_t err) noexcept
 Convert hf_spi_err_t to human-readable string.
 

Detailed Description

Abstract base class for SPI device implementations in the HardFOC system.

This header-only file defines the abstract base class for SPI device communication that provides a consistent API across different SPI controller implementations. Concrete implementations for various microcontrollers inherit from this class to provide high-speed serial communication and transfer management. Each BaseSpi instance represents a single SPI device with pre-configured settings.

Author
Nebiyu Tadesse
Date
2025
Note
This is a header-only abstract base class following the same pattern as BaseCan.
Users should program against this interface, not specific implementations.
Each BaseSpi instance represents a specific SPI device, not the SPI bus itself.

Macro Definition Documentation

◆ X [1/2]

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

◆ X [2/2]

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

Enumeration Type Documentation

◆ hf_spi_err_t

enum class hf_spi_err_t : hf_u8_t
strong
Enumerator
SPI_SUCCESS 
SPI_ERR_FAILURE 
SPI_ERR_NOT_INITIALIZED 
SPI_ERR_ALREADY_INITIALIZED 
SPI_ERR_INVALID_PARAMETER 
SPI_ERR_NULL_POINTER 
SPI_ERR_OUT_OF_MEMORY 
SPI_ERR_BUS_BUSY 
SPI_ERR_BUS_ERROR 
SPI_ERR_BUS_NOT_AVAILABLE 
SPI_ERR_BUS_TIMEOUT 
SPI_ERR_TRANSFER_FAILED 
SPI_ERR_TRANSFER_TIMEOUT 
SPI_ERR_TRANSFER_TOO_LONG 
SPI_ERR_TRANSFER_SIZE_MISMATCH 
SPI_ERR_DEVICE_NOT_FOUND 
SPI_ERR_DEVICE_NOT_RESPONDING 
SPI_ERR_CS_CONTROL_FAILED 
SPI_ERR_HARDWARE_FAULT 
SPI_ERR_COMMUNICATION_FAILURE 
SPI_ERR_VOLTAGE_OUT_OF_RANGE 
SPI_ERR_CLOCK_ERROR 
SPI_ERR_INVALID_CONFIGURATION 
SPI_ERR_UNSUPPORTED_OPERATION 
SPI_ERR_INVALID_CLOCK_SPEED 
SPI_ERR_INVALID_MODE 
SPI_ERR_PIN_CONFIGURATION_ERROR 
SPI_ERR_SYSTEM_ERROR 
SPI_ERR_PERMISSION_DENIED 
SPI_ERR_OPERATION_ABORTED 
SPI_ERR_UNKNOWN 

Function Documentation

◆ HfSpiErrToString()

constexpr std::string_view HfSpiErrToString ( hf_spi_err_t err)
constexprnoexcept

Convert hf_spi_err_t to human-readable string.

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