peary::interface::iface_spi
peary::interface::iface_spi
SPI interface class. More…
#include <peary/interfaces/SPI/spi.hpp>
Inherits from peary::interface::Interface< uint8_t, spi_t >
Inherited by peary::interface::iface_spi_CLICpix2, peary::interface::iface_spi_bus
Public Types
| Name | |
|---|---|
| using REG_T | spi_reg_t |
Public Functions
| Name | |
|---|---|
| iface_spi() =deleteDeleted default constructor to prevent instantiation without configuration. |
Protected Functions
| Name | |
|---|---|
| iface_spi(const Interface<>::configuration_type & config)Constructor for iface_spi. | |
| ~iface_spi() overrideDestructor for iface_spi. | |
| std::pair< REG_T, spi_t > | write(const std::pair< REG_T, spi_t > & data) overrideWrite data to a register. |
| Interface ::dataVector_type | write(const REG_T & reg, const Interface<>::dataVector_type & data) overrideWrite multiple data to registers. |
| std::vector< std::pair< REG_T, spi_t > > | write(const std::vector< std::pair< REG_T, spi_t » & data) overrideWrite multiple data to registers. |
| Interface ::dataVector_type | read(const REG_T & reg, const unsigned int length) overrideRead multiple data from a register. |
Protected Attributes
| Name | |
|---|---|
| int | spiDesc |
| std::mutex | mutex |
| const uint32_t | bits_per_word |
Friends
| Name | |
|---|---|
| iface_spi & | InterfaceManager::getInterface(const Interface<>::configuration_type & ) Only InterfaceManager can create instances of this class. |
| void | InterfaceManager::deleteInterface(iface_spi< REG_T > * ) Only InterfaceManager can delete instances of this class. |
Additional inherited members
Public Types inherited from peary::interface::Interface< uint8_t, spi_t >
| Name | |
|---|---|
| using REG_T | reg_type Type aliases for register type, data type, configuration type, and data vector type. |
| using DATA_T | data_type |
| using CONFIG_T | configuration_type |
| using std::vector< data_type > | dataVector_type |
Public Functions inherited from peary::interface::Interface< uint8_t, spi_t >
| Name | |
|---|---|
| std::string | devicePath() constGet the device path associated with the interface. |
Protected Functions inherited from peary::interface::Interface< uint8_t, spi_t >
| Name | |
|---|---|
| Interface(const InterfaceConfiguration & config)Constructor for Interface class. | |
| virtual | ~Interface() =defaultVirtual destructor for Interface class. |
Detailed Description
template <typename REG_T =uint8_t>
class peary::interface::iface_spi;
SPI interface class.
Template Parameters:
- REG_T The type used for the register address (e.g., uint8_t, uint16_t, etc.)
Public Types Documentation
using spi_reg_t
using peary::interface::iface_spi< REG_T >::spi_reg_t = REG_T;
Public Functions Documentation
function iface_spi
iface_spi() =delete
Deleted default constructor to prevent instantiation without configuration.
Protected Functions Documentation
function iface_spi
explicit iface_spi(
const Interface<>::configuration_type & config
)
Constructor for iface_spi.
Parameters:
- config The configuration object for the SPI interface
function ~iface_spi
~iface_spi() override
Destructor for iface_spi.
function write
std::pair< REG_T, spi_t > write(
const std::pair< REG_T, spi_t > & data
) override
Write data to a register.
Parameters:
- data A pair containing the register address and the data to be written
Return: A pair containing the register address and the data read back from the device
function write
Interface ::dataVector_type write(
const REG_T & reg,
const Interface<>::dataVector_type & data
) override
Write multiple data to registers.
Parameters:
- reg The register address to write to
- data A vector containing the data to be written
Return: A vector containing the data read back from the device
function write
std::vector< std::pair< REG_T, spi_t > > write(
const std::vector< std::pair< REG_T, spi_t >> & data
) override
Write multiple data to registers.
Parameters:
- data A vector of pairs containing the register addresses and the data to be written
Return: A vector of pairs containing the register addresses and the data read back from the device
function read
Interface ::dataVector_type read(
const REG_T & reg,
const unsigned int length
) override
Read multiple data from a register.
Parameters:
- reg The register address to read from
- length The number of data items to read
Return: A vector containing the data read from the device
Protected Attributes Documentation
variable spiDesc
int spiDesc;
variable mutex
std::mutex mutex;
variable bits_per_word
const uint32_t bits_per_word = 8;
Friends
friend InterfaceManager::getInterface
friend iface_spi & InterfaceManager::getInterface(
const Interface<>::configuration_type &
);
Only InterfaceManager can create instances of this class.
Return: A reference to the created SPI interface
friend InterfaceManager::deleteInterface
friend void InterfaceManager::deleteInterface(
iface_spi< REG_T > *
);
Only InterfaceManager can delete instances of this class.
Updated on 2025-11-14 at 11:31:23 +0100