Embedded Artistry Framework
Embedded Systems C++ Framework
Classes | Namespaces | Typedefs | Enumerations | Variables
spi.hpp File Reference
#include "driver.hpp"
#include <cstdint>
#include <driver/communication_bus.hpp>
#include <inplace_function/inplace_function.hpp>
Include dependency graph for spi.hpp:
This graph shows which files directly or indirectly include this file:

Classes

struct  embvm::spi::op_t
 SPI operation definition. More...
 
class  embvm::spi::master
 This class provides the SPI master interface definition. More...
 

Namespaces

 embvm
 Embedded framework core interfaces, classes, and definitions.
 
 embvm::spi
 Definitions, functions, and classes related to SPI communication bus devices.
 

Typedefs

using embvm::spi::baud_t = uint32_t
 SPI baudrate is specified as an integral value with units Hz. More...
 
using embvm::spi::status = embvm::comm::status
 
using embvm::spi::commBus = commBus< spi::op_t, spi::baud_t, spi::SPI_MASTER_REQD_STATIC_FUNCTION_SIZE >
 Convenience alias for the declaration of the SPI commBus. More...
 

Enumerations

enum  embvm::spi::mode : uint8_t { embvm::spi::mode::mode0 = 0, embvm::spi::mode::mode1 = 1, embvm::spi::mode::mode2 = 2, embvm::spi::mode::mode3 = 3 }
 SPI bus operational modes. More...
 
enum  embvm::spi::order : uint8_t { embvm::spi::order::msbFirst = 0, embvm::spi::order::lsbFirst }
 SPI bus transmission order options. More...
 

Variables

static constexpr size_t embvm::spi::SPI_MASTER_REQD_STATIC_FUNCTION_SIZE = 80
 Maximum size of the SPI master callback functor object. More...
 
static constexpr spi::baud_t embvm::spi::DEFAULT_SPI_BAUD = UINT32_C(125000)
 Default baudrate, which is used in the default constructor. More...
 

Class Documentation

◆ embvm::spi::op_t

struct embvm::spi::op_t

SPI operation definition.

The SPI bus is full-duplex and always transmits and receives simultaneously.

A TX operation involves a valid tx_buffer pointer with rx_buffer set to nullptr.

An RX operation involves a valid rx_buffer pointer with tx_buffer set to nullptr. When tx_buffer is set to nullptr, the driver should clock out empty bytes.

An equal number of bytes are transmitted and received during a SPI transaction. The transfer size is controlled by the length argument.

Class Members
size_t length Number of bytes to transfer over the bus.
uint8_t * rx_buffer Pointer to buffer holding receive bytes.

Can be set to nullptr to ignore reception.

uint8_t * tx_buffer Pointer to buffer holding transmit bytes.

Can be set to nullptr to transmit empty bytes.