HardFOC Core
API reference
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
HalSpiMax22200Comm Class Reference

CRTP SPI communication adapter for MAX22200 using BaseSpi and BaseGpio. More...

#include <Max22200Handler.h>

Inheritance diagram for HalSpiMax22200Comm:

Public Member Functions

 HalSpiMax22200Comm (BaseSpi &spi, BaseGpio &enable, BaseGpio &cmd, BaseGpio *fault=nullptr) noexcept
 Construct the SPI adapter.
 
CRTP-Required Methods
bool Initialize () noexcept
 Park ENABLE/CMD, optional nFAULT input, and 5 ms VM settle.
 
bool Transfer (const uint8_t *tx_data, uint8_t *rx_data, size_t length) noexcept
 SPI exchange via aligned internal-SRAM staging buffers.
 
bool SetChipSelect (bool state) noexcept
 Soft-CS no-op — chip select is owned by StmSpiDevice.
 
bool Configure (uint32_t speed_hz, uint8_t mode, bool msb_first=true) noexcept
 SPI mode/speed no-op — BaseSpi is pre-configured (Mode 0).
 
bool IsReady () const noexcept
 True when comm adapter and all bound GPIO/SPI objects are ready.
 
void DelayUs (uint32_t us) noexcept
 Blocking microsecond delay (handler_utils::DelayUs).
 
void GpioSet (max22200::CtrlPin pin, max22200::GpioSignal signal) noexcept
 Drive ENABLE, CMD, or nFAULT through BaseGpio.
 
bool GpioRead (max22200::CtrlPin pin, max22200::GpioSignal &signal) noexcept
 Read ENABLE, CMD, or nFAULT level.
 

Private Attributes

BaseSpi & spi_
 
BaseGpio & enable_
 
BaseGpio & cmd_
 
BaseGpio * fault_
 
bool initialized_ {false}
 

Detailed Description

CRTP SPI communication adapter for MAX22200 using BaseSpi and BaseGpio.

Implements all methods required by max22200::SpiInterface<HalSpiMax22200Comm>. Handles the two-phase CMD-pin SPI protocol (CMD HIGH = command byte, CMD LOW = data). Live actuators typically use Mode 0 soft-CS SPI; EN/CMD/nFLT may be expander-backed — claim board GPIO map ownership before Initialize.

Constructor & Destructor Documentation

◆ HalSpiMax22200Comm()

HalSpiMax22200Comm::HalSpiMax22200Comm ( BaseSpi &  spi,
BaseGpio &  enable,
BaseGpio &  cmd,
BaseGpio *  fault = nullptr 
)
noexcept

Construct the SPI adapter.

Parameters
spiReference to pre-configured BaseSpi (Mode 0, 8-bit).
enableBaseGpio for ENABLE pin (active HIGH).
cmdBaseGpio for CMD pin (HIGH=command phase, LOW=data phase).
faultOptional BaseGpio for nFAULT (active LOW, open-drain).

Member Function Documentation

◆ Configure()

bool HalSpiMax22200Comm::Configure ( uint32_t  speed_hz,
uint8_t  mode,
bool  msb_first = true 
)
noexcept

SPI mode/speed no-op — BaseSpi is pre-configured (Mode 0).

Returns
Always true.

◆ DelayUs()

void HalSpiMax22200Comm::DelayUs ( uint32_t  us)
noexcept

Blocking microsecond delay (handler_utils::DelayUs).

◆ GpioRead()

bool HalSpiMax22200Comm::GpioRead ( max22200::CtrlPin  pin,
max22200::GpioSignal &  signal 
)
noexcept

Read ENABLE, CMD, or nFAULT level.

Parameters
[out]signalACTIVE or INACTIVE on success.
Returns
false if not ready, pin unsupported, or GPIO read failed.

◆ GpioSet()

void HalSpiMax22200Comm::GpioSet ( max22200::CtrlPin  pin,
max22200::GpioSignal  signal 
)
noexcept

Drive ENABLE, CMD, or nFAULT through BaseGpio.

Note
ENABLE (expander-backed) gets a 2 ms settle; CMD is local GPIO.

◆ Initialize()

bool HalSpiMax22200Comm::Initialize ( )
noexcept

Park ENABLE/CMD, optional nFAULT input, and 5 ms VM settle.

◆ IsReady()

bool HalSpiMax22200Comm::IsReady ( ) const
noexcept

True when comm adapter and all bound GPIO/SPI objects are ready.

◆ SetChipSelect()

bool HalSpiMax22200Comm::SetChipSelect ( bool  state)
noexcept

Soft-CS no-op — chip select is owned by StmSpiDevice.

Returns
Always true.

◆ Transfer()

bool HalSpiMax22200Comm::Transfer ( const uint8_t *  tx_data,
uint8_t *  rx_data,
size_t  length 
)
noexcept

SPI exchange via aligned internal-SRAM staging buffers.

Parameters
tx_dataTX buffer (may live outside tightly-coupled memory).
rx_dataRX buffer (updated in place via aligned word stores).
lengthFrame length in bytes (max 8).
Returns
false if not IsReady, null pointers, or SPI failure.

Member Data Documentation

◆ cmd_

BaseGpio& HalSpiMax22200Comm::cmd_
private

◆ enable_

BaseGpio& HalSpiMax22200Comm::enable_
private

◆ fault_

BaseGpio* HalSpiMax22200Comm::fault_
private

◆ initialized_

bool HalSpiMax22200Comm::initialized_ {false}
private

◆ spi_

BaseSpi& HalSpiMax22200Comm::spi_
private

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