|
HF-AS5047U Driver
0.1.0-dev
HF-AS5047U C++ Driver
|
CRTP-based template interface for SPI bus operations. More...
#include <as5047u_spi_interface.hpp>
Public Member Functions | |
| void | transfer (const uint8_t *tx, uint8_t *rx, std::size_t len) |
| Perform a full-duplex SPI data transfer. | |
| SpiInterface (const SpiInterface &)=delete | |
| SpiInterface & | operator= (const SpiInterface &)=delete |
Protected Member Functions | |
| SpiInterface ()=default | |
| Protected constructor to prevent direct instantiation. | |
| SpiInterface (SpiInterface &&)=default | |
| SpiInterface & | operator= (SpiInterface &&)=default |
| ~SpiInterface ()=default | |
| Protected destructor. | |
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:
Example usage:
| Derived | The derived class type (CRTP pattern) |
|
delete |
|
protecteddefault |
Protected constructor to prevent direct instantiation.
|
protecteddefault |
|
protecteddefault |
Protected destructor.
|
delete |
|
protecteddefault |
|
inline |
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.
| 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. |