141 bool Transfer(
const uint8_t *tx_data, uint8_t *rx_data,
size_t length) {
142 return static_cast<Derived *
>(
this)->
Transfer(tx_data, rx_data, length);
179 bool Configure(uint32_t speed_hz, uint8_t mode,
bool msb_first =
true) {
180 return static_cast<Derived *
>(
this)->
Configure(speed_hz, mode, msb_first);
232 static_cast<Derived *
>(
this)->
GpioSet(pin, signal);
254 return static_cast<Derived *
>(
this)->
GpioRead(pin, signal);
CRTP-based template interface for SPI communication.
Definition max22200_spi_interface.hpp:114
bool GpioRead(CtrlPin pin, GpioSignal &signal)
Read the current state of a control pin.
Definition max22200_spi_interface.hpp:253
SpiInterface & operator=(SpiInterface &&)=default
void GpioSetInactive(CtrlPin pin)
Deassert a control pin (set to INACTIVE). Convenience wrapper for GpioSet(pin, GpioSignal::INACTIVE).
Definition max22200_spi_interface.hpp:269
SpiInterface(SpiInterface &&)=default
bool Configure(uint32_t speed_hz, uint8_t mode, bool msb_first=true)
Configure SPI parameters.
Definition max22200_spi_interface.hpp:179
bool Initialize()
Initialize the SPI interface.
Definition max22200_spi_interface.hpp:125
SpiInterface()=default
Protected constructor to prevent direct instantiation.
SpiInterface(const SpiInterface &)=delete
SpiInterface & operator=(const SpiInterface &)=delete
bool Transfer(const uint8_t *tx_data, uint8_t *rx_data, size_t length)
Transfer data over SPI interface.
Definition max22200_spi_interface.hpp:141
void SetChipSelect(bool state)
Set chip select state.
Definition max22200_spi_interface.hpp:155
void GpioSet(CtrlPin pin, GpioSignal signal)
Set a control pin to the specified signal state.
Definition max22200_spi_interface.hpp:231
void GpioSetActive(CtrlPin pin)
Assert a control pin (set to ACTIVE). Convenience wrapper for GpioSet(pin, GpioSignal::ACTIVE).
Definition max22200_spi_interface.hpp:262
bool IsReady() const
Check if SPI interface is ready.
Definition max22200_spi_interface.hpp:191
~SpiInterface()=default
Protected destructor.
void DelayUs(uint32_t us)
Blocking delay in microseconds (from comm/CRTP implementation).
Definition max22200_spi_interface.hpp:202
Definition max22200.hpp:78
GpioSignal
Abstract signal level for control pins.
Definition max22200_spi_interface.hpp:85
@ ACTIVE
Pin function asserted (ENABLE on, CMD high, fault present on FAULT)
@ INACTIVE
Pin function deasserted (ENABLE off, CMD low, no fault on FAULT)
CtrlPin
Identifies the hardware control pins of the MAX22200.
Definition max22200_spi_interface.hpp:71
@ FAULT
nFAULT pin — active-low open-drain fault output (read via GpioRead)
@ CMD
CMD pin — ACTIVE = Command Register phase; INACTIVE = data phase.
@ ENABLE
ENABLE pin — active-high; device sleep when INACTIVE.