Class hal::spi
Serial peripheral interface (SPI) communication protocol hardware abstract interface.
#include <spi.hpp>
Inherited by the following classes: hal::lpc40::spi, hal::mock::write_only_spi
Classes
Type | Name |
---|---|
struct | settings Generic settings for a standard SPI device. |
struct | transfer_t Feedback from performing a transfer on the spi bus. |
Public Static Attributes
Type | Name |
---|---|
constexpr hal::byte | default_filler = = hal::byte |
Public Functions
Type | Name |
---|---|
status | configure (const settings & p_settings) Configure spi to match the settings supplied. |
result< transfer_t > | transfer (std::span< const hal::byte > p_data_out, std::span< hal::byte > p_data_in, hal::byte p_filler=default_filler) Send and receive data between a selected device on the spi bus. This function will block until the entire transfer is finished. |
virtual | ~spi () = default |
Public Static Attributes Documentation
variable default_filler
constexpr hal::byte hal::spi::default_filler;
Default filler data placed on the bus in place of actual write data when the write buffer has been exhausted.
Public Functions Documentation
function configure
Configure spi to match the settings supplied.
inline status hal::spi::configure (
const settings & p_settings
)
Parameters:
p_settings
- settings to apply to spi
Returns:
status - success or failure
Exception:
std::errc::invalid_argument
if the settings could not be achieved.
function transfer
Send and receive data between a selected device on the spi bus. This function will block until the entire transfer is finished.
inline result< transfer_t > hal::spi::transfer (
std::span< const hal::byte > p_data_out,
std::span< hal::byte > p_data_in,
hal::byte p_filler=default_filler
)
Parameters:
p_data_out
- buffer to write data to the bus. If this is set to null/empty then writing is ignored and the p_filler will be written to the bus. If the length is less than p_data_in, then p_filler will be written to the bus after this buffer has been sent.p_data_in
- buffer to read the data off of the bus. If this is null/empty, then the transfer will be write only and the incoming data will be ignored. If the length of this buffer is less than p_data_out, once this buffer has been filled, the rest of the received bytes on the bus will be dropped.p_filler
- filler data placed on the bus in place of actual write data when p_data_out has been exhausted.
Returns:
result<transfer_t> - success or failure
function ~spi
virtual hal::spi::~spi () = default
The documentation for this class was generated from the following file libraries/include/libhal/spi.hpp