ESP32 SPI transport implementation for MAX22200 driver.
More...
#include <esp32_max22200_bus.hpp>
|
| | 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 |
| |
| 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).
|
| |
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.
◆ Esp32Max22200SpiBus()
| Esp32Max22200SpiBus::Esp32Max22200SpiBus |
( |
const SPIConfig & | config | ) |
|
|
inlineexplicit |
Constructor with SPI configuration (pins must be set by caller)
- Parameters
-
| config | SPI configuration parameters |
◆ ~Esp32Max22200SpiBus()
| Esp32Max22200SpiBus::~Esp32Max22200SpiBus |
( |
| ) |
|
|
inline |
Destructor - cleans up SPI resources.
◆ Configure()
| bool Esp32Max22200SpiBus::Configure |
( |
uint32_t | speed_hz, |
|
|
uint8_t | mode, |
|
|
bool | msb_first = true ) |
|
inline |
Configure SPI parameters.
- Parameters
-
| speed_hz | SPI clock speed in Hz |
| mode | SPI mode (0-3) |
| msb_first | true 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()
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
-
| pin | Which control pin to read |
| signal | Receives the current signal state |
- Returns
- true if read was successful, false if pin not configured
◆ GpioSet()
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
-
| pin | Which control pin to drive |
| signal | ACTIVE 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
-
| state | true to assert CS (active low), false to deassert |
◆ SetTrigA()
| void Esp32Max22200SpiBus::SetTrigA |
( |
bool | active | ) |
|
|
inline |
Set TRIGA pin level (direct-drive trigger A)
- Parameters
-
| active | true = drive high (inactive), false = drive low (trigger) |
◆ SetTrigB()
| void Esp32Max22200SpiBus::SetTrigB |
( |
bool | active | ) |
|
|
inline |
Set TRIGB pin level (direct-drive trigger B)
- Parameters
-
| active | true = drive high (inactive), false = drive low (trigger) |
◆ Transfer()
| bool Esp32Max22200SpiBus::Transfer |
( |
const uint8_t * | tx_data, |
|
|
uint8_t * | rx_data, |
|
|
size_t | length ) |
|
inline |
◆ LOG_SPI_HEX
Perform a full-duplex SPI data transfer.
- Parameters
-
| tx_data | Pointer to data to transmit |
| rx_data | Pointer to buffer for received data |
| length | Number 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: