template<typename Derived>
class ads7952::SpiInterface< Derived >
CRTP-based template interface for SPI bus operations.
This template class provides a hardware-agnostic interface for SPI communication using the CRTP pattern. Platform-specific implementations should inherit from this template with themselves as the template parameter.
Benefits of CRTP:
- Compile-time polymorphism (no virtual function overhead)
- Static dispatch instead of dynamic dispatch
- Better optimization opportunities for the compiler
Example usage:
public:
void transfer(const uint8_t* tx, uint8_t* rx, std::size_t len) {
}
};
CRTP-based template interface for SPI bus operations.
- Template Parameters
-
| Derived | The derived class type (CRTP pattern) |
Definition at line 44 of file ads7952_spi_interface.hpp.
template<typename Derived >
Perform a full-duplex SPI data transfer.
Sends len bytes from tx and simultaneously receives len bytes into rx. Implementations should assert the device's chip select for the duration of the transfer.
- Parameters
-
| tx | Pointer to data to transmit (len bytes). If nullptr, zeros can be sent. |
| rx | Pointer to buffer for received data (len bytes). If nullptr, received data can be ignored. |
| len | Number of bytes to transfer. |
Definition at line 59 of file ads7952_spi_interface.hpp.
References ads7952::SpiInterface< Derived >::transfer().
Referenced by ads7952::SpiInterface< Derived >::transfer().