HF-MAX22200 Driver 0.1.0-dev
HF-MAX22200 C++ Driver
Loading...
Searching...
No Matches
Esp32Max22200SpiBus Class Reference

ESP32 SPI transport implementation for MAX22200 driver. More...

#include <esp32_max22200_bus.hpp>

Inheritance diagram for Esp32Max22200SpiBus:
[legend]
Collaboration diagram for Esp32Max22200SpiBus:
[legend]

Classes

struct  SPIConfig
 SPI configuration structure. More...
 

Public Member Functions

 Esp32Max22200SpiBus (const SPIConfig &config)
 Constructor with SPI configuration (pins must be set by caller)
 
 ~Esp32Max22200SpiBus ()
 Destructor - cleans up SPI resources.
 
bool Initialize ()
 Initialize the SPI bus.
 
bool Transfer (const uint8_t *tx_data, uint8_t *rx_data, size_t length)
 
void SetChipSelect (bool state)
 Set chip select state.
 
bool Configure (uint32_t speed_hz, uint8_t mode, bool msb_first=true)
 Configure SPI parameters.
 
bool IsReady () const
 Check if SPI interface is ready.
 
void DelayUs (uint32_t us)
 Blocking delay in microseconds (for MAX22200 power-up, etc.). Uses ESP-ROM delay so it is safe before scheduler or with SPI timing.
 
void GpioSet (max22200::CtrlPin pin, max22200::GpioSignal signal)
 Set a control pin to the specified signal state.
 
bool GpioRead (max22200::CtrlPin pin, max22200::GpioSignal &signal)
 Read the current state of a control pin.
 
void SetTrigA (bool active)
 Set TRIGA pin level (direct-drive trigger A)
 
void SetTrigB (bool active)
 Set TRIGB pin level (direct-drive trigger B)
 
bool HasTrigA () const
 
bool HasTrigB () const
 
- Public Member Functions inherited from max22200::SpiInterface< Esp32Max22200SpiBus >
bool Initialize ()
 Initialize the SPI interface.
 
bool Transfer (const uint8_t *tx_data, uint8_t *rx_data, size_t length)
 Transfer data over SPI interface.
 
void SetChipSelect (bool state)
 Set chip select state.
 
bool Configure (uint32_t speed_hz, uint8_t mode, bool msb_first=true)
 Configure SPI parameters.
 
bool IsReady () const
 Check if SPI interface is ready.
 
void DelayUs (uint32_t us)
 Blocking delay in microseconds (from comm/CRTP implementation).
 
void GpioSet (CtrlPin pin, GpioSignal signal)
 Set a control pin to the specified signal state.
 
bool GpioRead (CtrlPin pin, GpioSignal &signal)
 Read the current state of a control pin.
 
void GpioSetActive (CtrlPin pin)
 Assert a control pin (set to ACTIVE). Convenience wrapper for GpioSet(pin, GpioSignal::ACTIVE).
 
void GpioSetInactive (CtrlPin pin)
 Deassert a control pin (set to INACTIVE). Convenience wrapper for GpioSet(pin, GpioSignal::INACTIVE).
 

Static Public Attributes

static constexpr bool LOG_SPI_HEX = (ESP32_MAX22200_ENABLE_DETAILED_SPI_LOGGING != 0)
 Perform a full-duplex SPI data transfer.
 

Additional Inherited Members

- Protected Member Functions inherited from max22200::SpiInterface< Esp32Max22200SpiBus >
 SpiInterface ()=default
 Protected constructor to prevent direct instantiation.
 
 SpiInterface (const SpiInterface &)=delete
 
 SpiInterface (SpiInterface &&)=default
 
SpiInterfaceoperator= (const SpiInterface &)=delete
 
SpiInterfaceoperator= (SpiInterface &&)=default
 
 ~SpiInterface ()=default
 Protected destructor.
 

Detailed Description

ESP32 SPI transport implementation for MAX22200 driver.

This class implements the max22200::SpiInterface using ESP-IDF's SPI driver with CRTP pattern. It supports configurable SPI pins, frequency, and chip select.

Constructor & Destructor Documentation

◆ Esp32Max22200SpiBus()

Esp32Max22200SpiBus::Esp32Max22200SpiBus ( const SPIConfig & config)
inlineexplicit

Constructor with SPI configuration (pins must be set by caller)

Parameters
configSPI configuration parameters

◆ ~Esp32Max22200SpiBus()

Esp32Max22200SpiBus::~Esp32Max22200SpiBus ( )
inline

Destructor - cleans up SPI resources.

Member Function Documentation

◆ Configure()

bool Esp32Max22200SpiBus::Configure ( uint32_t speed_hz,
uint8_t mode,
bool msb_first = true )
inline

Configure SPI parameters.

Parameters
speed_hzSPI clock speed in Hz
modeSPI mode (0-3)
msb_firsttrue for MSB first, false for LSB first
Returns
true if successful, false otherwise

◆ DelayUs()

void Esp32Max22200SpiBus::DelayUs ( uint32_t us)
inline

Blocking delay in microseconds (for MAX22200 power-up, etc.). Uses ESP-ROM delay so it is safe before scheduler or with SPI timing.

◆ GpioRead()

bool Esp32Max22200SpiBus::GpioRead ( max22200::CtrlPin pin,
max22200::GpioSignal & signal )
inline

Read the current state of a control pin.

FAULT pin: active-low, inactive-high.

  • ACTIVE (fault present) = physical LOW (GPIO 0)
  • INACTIVE (no fault) = physical HIGH (GPIO 1), e.g. pull-up when open-drain released
Parameters
pinWhich control pin to read
signalReceives the current signal state
Returns
true if read was successful, false if pin not configured

◆ GpioSet()

void Esp32Max22200SpiBus::GpioSet ( max22200::CtrlPin pin,
max22200::GpioSignal signal )
inline

Set a control pin to the specified signal state.

Maps GpioSignal to physical level based on pin polarity:

  • ENABLE: active-high (ACTIVE → GPIO 1, INACTIVE → GPIO 0)
  • CMD: active-high (ACTIVE → GPIO 1, INACTIVE → GPIO 0)
  • FAULT: read-only, GpioSet on FAULT returns silently
Parameters
pinWhich control pin to drive
signalACTIVE to assert, INACTIVE to deassert

◆ HasTrigA()

bool Esp32Max22200SpiBus::HasTrigA ( ) const
inline
Returns
true if TRIGA pin is configured

◆ HasTrigB()

bool Esp32Max22200SpiBus::HasTrigB ( ) const
inline
Returns
true if TRIGB pin is configured

◆ Initialize()

bool Esp32Max22200SpiBus::Initialize ( )
inline

Initialize the SPI bus.

Returns
true if successful, false otherwise

◆ IsReady()

bool Esp32Max22200SpiBus::IsReady ( ) const
inline

Check if SPI interface is ready.

Returns
true if ready, false otherwise

◆ SetChipSelect()

void Esp32Max22200SpiBus::SetChipSelect ( bool state)
inline

Set chip select state.

Parameters
statetrue to assert CS (active low), false to deassert

◆ SetTrigA()

void Esp32Max22200SpiBus::SetTrigA ( bool active)
inline

Set TRIGA pin level (direct-drive trigger A)

Parameters
activetrue = drive high (inactive), false = drive low (trigger)

◆ SetTrigB()

void Esp32Max22200SpiBus::SetTrigB ( bool active)
inline

Set TRIGB pin level (direct-drive trigger B)

Parameters
activetrue = drive high (inactive), false = drive low (trigger)

◆ Transfer()

bool Esp32Max22200SpiBus::Transfer ( const uint8_t * tx_data,
uint8_t * rx_data,
size_t length )
inline

Member Data Documentation

◆ LOG_SPI_HEX

constexpr bool Esp32Max22200SpiBus::LOG_SPI_HEX = (ESP32_MAX22200_ENABLE_DETAILED_SPI_LOGGING != 0)
staticconstexpr

Perform a full-duplex SPI data transfer.

Parameters
tx_dataPointer to data to transmit
rx_dataPointer to buffer for received data
lengthNumber of bytes to transfer
Returns
true if successful, false otherwise If true, log every SPI transfer as hex TX/RX bytes (TX1/RX1, TX2/RX2, ...). Controlled by ESP32_MAX22200_ENABLE_DETAILED_SPI_LOGGING in esp32_max22200_test_config.hpp.

The documentation for this class was generated from the following file: