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

ESP32 SPI type definitions for hardware abstraction. More...

#include "BaseSpi.h"
#include "EspTypes_Base.h"
#include "HardwareTypes.h"
#include "McuSelect.h"
#include "driver/spi_master.h"
Include dependency graph for EspTypes_SPI.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  hf_spi_bus_config_t
 Platform-agnostic SPI bus configuration for STM32. More...
 
struct  hf_spi_device_config_t
 SPI device configuration for STM32. More...
 

Macros

#define HF_SPI_IS_VALID_HOST(host)    ((host) < static_cast<uint8_t>(spi_host_device_t::HF_SPI_HOST_MAX))
 
#define HF_SPI_IS_VALID_CLOCK_SPEED(speed)    ((speed) >= HF_SPI_MIN_CLOCK_SPEED && (speed) <= HF_SPI_MAX_CLOCK_SPEED)
 
#define HF_SPI_IS_VALID_MODE(mode)   ((mode) >= 0 && (mode) <= 3)
 
#define HF_SPI_IS_VALID_TRANSFER_SIZE(size)   ((size) > 0 && (size) <= HF_SPI_MAX_TRANSFER_SIZE)
 
#define HF_SPI_DEVICE_HALFDUPLEX   (1 << 0)
 
#define HF_SPI_DEVICE_POSITIVE_CS   (1 << 1)
 
#define HF_SPI_DEVICE_CLK_AS_CS   (1 << 2)
 
#define HF_SPI_DEVICE_NO_DUMMY   (1 << 3)
 
#define HF_SPI_DEVICE_DDRCLK   (1 << 4)
 

Typedefs

using hf_spi_device_handle_t = spi_device_handle_t
 
using hf_spi_device_interface_config_t = spi_device_interface_config_t
 
using hf_spi_transaction_t = spi_transaction_t
 
using hf_spi_clock_source_t = spi_clock_source_t
 
using hf_spi_sampling_point_t = spi_sampling_point_t
 

Enumerations

enum class  hf_spi_mode_t : uint8_t { HF_SPI_MODE_0 = 0 , HF_SPI_MODE_1 = 1 , HF_SPI_MODE_2 = 2 , HF_SPI_MODE_3 = 3 }
 ESP32 SPI mode configuration. More...
 
enum class  hf_spi_transfer_mode_t : uint8_t { HF_SPI_TRANSFER_MODE_SINGLE = 0 , HF_SPI_TRANSFER_MODE_DUAL = 1 , HF_SPI_TRANSFER_MODE_QUAD = 2 , HF_SPI_TRANSFER_MODE_OCTAL = 3 }
 SPI transfer modes for ESP32. More...
 
enum class  hf_spi_event_type_t : int {
  HF_SPI_EVENT_TRANSACTION_COMPLETE = 0 , HF_SPI_EVENT_TRANSACTION_ERROR = 1 , HF_SPI_EVENT_BUS_SUSPENDED = 2 , HF_SPI_EVENT_BUS_RESUMED = 3 ,
  HF_SPI_EVENT_DMA_ERROR = 4
}
 SPI event types for callback notifications. More...
 

Variables

static constexpr uint32_t HF_SPI_MIN_CLOCK_SPEED = 1000
 Minimum SPI clock speed (Hz)
 
static constexpr uint32_t HF_SPI_MAX_CLOCK_SPEED = 80000000
 Maximum SPI clock speed (Hz)
 
static constexpr uint32_t HF_SPI_MAX_TRANSFER_SIZE = 4092
 Maximum transfer size (bytes)
 
static constexpr uint8_t HF_SPI_MAX_HOSTS = 3
 Maximum SPI hosts.
 

Detailed Description

ESP32 SPI type definitions for hardware abstraction.

This header defines only the essential SPI-specific types used by the EspSpi implementation. Clean and minimal approach.

Author
Nebiyu Tadesse
Date
2025

Macro Definition Documentation

◆ HF_SPI_DEVICE_CLK_AS_CS

#define HF_SPI_DEVICE_CLK_AS_CS   (1 << 2)

◆ HF_SPI_DEVICE_DDRCLK

#define HF_SPI_DEVICE_DDRCLK   (1 << 4)

◆ HF_SPI_DEVICE_HALFDUPLEX

#define HF_SPI_DEVICE_HALFDUPLEX   (1 << 0)

◆ HF_SPI_DEVICE_NO_DUMMY

#define HF_SPI_DEVICE_NO_DUMMY   (1 << 3)

◆ HF_SPI_DEVICE_POSITIVE_CS

#define HF_SPI_DEVICE_POSITIVE_CS   (1 << 1)

◆ HF_SPI_IS_VALID_CLOCK_SPEED

#define HF_SPI_IS_VALID_CLOCK_SPEED ( speed)     ((speed) >= HF_SPI_MIN_CLOCK_SPEED && (speed) <= HF_SPI_MAX_CLOCK_SPEED)

◆ HF_SPI_IS_VALID_HOST

#define HF_SPI_IS_VALID_HOST ( host)     ((host) < static_cast<uint8_t>(spi_host_device_t::HF_SPI_HOST_MAX))

◆ HF_SPI_IS_VALID_MODE

#define HF_SPI_IS_VALID_MODE ( mode)    ((mode) >= 0 && (mode) <= 3)

◆ HF_SPI_IS_VALID_TRANSFER_SIZE

#define HF_SPI_IS_VALID_TRANSFER_SIZE ( size)    ((size) > 0 && (size) <= HF_SPI_MAX_TRANSFER_SIZE)

Typedef Documentation

◆ hf_spi_clock_source_t

using hf_spi_clock_source_t = spi_clock_source_t

◆ hf_spi_device_handle_t

using hf_spi_device_handle_t = spi_device_handle_t

◆ hf_spi_device_interface_config_t

using hf_spi_device_interface_config_t = spi_device_interface_config_t

◆ hf_spi_sampling_point_t

using hf_spi_sampling_point_t = spi_sampling_point_t

◆ hf_spi_transaction_t

using hf_spi_transaction_t = spi_transaction_t

Enumeration Type Documentation

◆ hf_spi_event_type_t

enum class hf_spi_event_type_t : int
strong

SPI event types for callback notifications.

Event types reported via SPI event callbacks.

Enumerator
HF_SPI_EVENT_TRANSACTION_COMPLETE 

Transaction completed.

HF_SPI_EVENT_TRANSACTION_ERROR 

Transaction error occurred.

HF_SPI_EVENT_BUS_SUSPENDED 

Bus suspended for power saving.

HF_SPI_EVENT_BUS_RESUMED 

Bus resumed from suspension.

HF_SPI_EVENT_DMA_ERROR 

DMA error occurred.

◆ hf_spi_mode_t

enum class hf_spi_mode_t : uint8_t
strong

ESP32 SPI mode configuration.

Enumerator
HF_SPI_MODE_0 

CPOL=0, CPHA=0.

HF_SPI_MODE_1 

CPOL=0, CPHA=1.

HF_SPI_MODE_2 

CPOL=1, CPHA=0.

HF_SPI_MODE_3 

CPOL=1, CPHA=1.

◆ hf_spi_transfer_mode_t

enum class hf_spi_transfer_mode_t : uint8_t
strong

SPI transfer modes for ESP32.

Advanced transfer modes including octal SPI support.

Enumerator
HF_SPI_TRANSFER_MODE_SINGLE 

Standard SPI (1-bit MOSI/MISO)

HF_SPI_TRANSFER_MODE_DUAL 

Dual SPI (2-bit data lines)

HF_SPI_TRANSFER_MODE_QUAD 

Quad SPI (4-bit data lines)

HF_SPI_TRANSFER_MODE_OCTAL 

Octal SPI (8-bit data lines) - ESP32 specific.

Variable Documentation

◆ HF_SPI_MAX_CLOCK_SPEED

constexpr uint32_t HF_SPI_MAX_CLOCK_SPEED = 80000000
staticconstexpr

Maximum SPI clock speed (Hz)

◆ HF_SPI_MAX_HOSTS

constexpr uint8_t HF_SPI_MAX_HOSTS = 3
staticconstexpr

Maximum SPI hosts.

◆ HF_SPI_MAX_TRANSFER_SIZE

constexpr uint32_t HF_SPI_MAX_TRANSFER_SIZE = 4092
staticconstexpr

Maximum transfer size (bytes)

◆ HF_SPI_MIN_CLOCK_SPEED

constexpr uint32_t HF_SPI_MIN_CLOCK_SPEED = 1000
staticconstexpr

Minimum SPI clock speed (Hz)