modm API documentation
modm_test::platform::SpiMaster Class Reference

#include </tmp/tmpjuwu__vz/stm32l072vzt6/modm-test/src/modm-test/mock/spi_master.hpp>

Inheritance diagram for modm_test::platform::SpiMaster:
modm::SpiMaster modm::PeripheralDriver modm::Spi

Public Typedefs

using ArrayContainer = modm::DoublyLinkedList< uint8_t >
 
using ConfigurationHandler = void (*)()
 The signature of the configuration function.
 

Public Types

enum  DataMode : uint8_t { DataMode::Mode0 = 0b00, DataMode::Mode1 = 0b01, DataMode::Mode2 = 0b10, DataMode::Mode3 = 0b11 }
 Spi Data Mode, Mode0 is the most common mode. More...
 
enum  DataOrder : uint8_t { MsbFirst = 0b0, LsbFirst = 0b1 }
 Spi Data Order, MsbFirst is the most common mode.
 

Static Public Member Functions

static void initialize ()
 
static void setDataMode (DataMode mode)
 
static void setDataOrder (DataOrder order)
 
static uint8_t acquire (void *ctx, ConfigurationHandler handler=nullptr)
 
static uint8_t release (void *ctx)
 
static uint8_t transferBlocking (uint8_t data)
 
static void transferBlocking (uint8_t *tx, uint8_t *rx, std::size_t length)
 
static modm::ResumableResult< uint8_t > transfer (uint8_t data)
 
static modm::ResumableResult< void > transfer (uint8_t *tx, uint8_t *rx, std::size_t length)
 
static std::size_t getTxBufferLength ()
 
static void popTxBuffer (uint8_t *buf)
 
static void appendRxBuffer (uint8_t *data, std::size_t length)
 
static void clearBuffers ()
 
static void acknowledgeInterruptFlag ()
 
template<uint64_t available, uint64_t requested, percent_t tolerance>
static void assertBaudrateInTolerance ()
 
template<double available, double requested, percent_t tolerance>
static void assertDurationInTolerance ()
 
static void configurePurpose ()
 configures a peripheral for a specific purpose
 
template<class... Signals>
static void connect ()
 
static bool getInterruptFlag ()
 Read an interrupt flag.
 
static void getParameter ()
 returns a parameter
 
static void initialize ()
 initializes the peripheral, must be called before use.
 
static void setParameter ()
 sets a parameter
 
static modm::ResumableResult< void > transfer (const uint8_t *tx, uint8_t *rx, std::size_t length)
 
static void transferBlocking (const uint8_t *tx, uint8_t *rx, std::size_t length)
 

Detailed Description

Mock serial peripheral interface for unittests.

Author
Raphael Lehmann

Member Enumeration Documentation

enum modm::Spi::DataMode : uint8_t
inheritedstrong

Spi Data Mode, Mode0 is the most common mode.

Enum ValuesDocumentation
Mode0 

clock normal, sample on rising edge

Mode1 

clock normal, sample on falling edge

Mode2 

clock inverted, sample on falling edge

Mode3 

clock inverted, sample on rising edge

Member Function Documentation

static void modm::PeripheralDriver::acknowledgeInterruptFlag ( )
inheritedstatic

Acknowledge an interrupt flag.

We use acknowledge here, since it describes the intention rather than the actual implementation.

template<uint64_t available, uint64_t requested, percent_t tolerance>
static void modm::PeripheralDriver::assertBaudrateInTolerance ( )
inheritedinlinestatic

Since baudrates are usually generated by prescaling a system clock, only several distinct values can be generated. This method checks if the user requested baudrate is within error tolerance of the system achievable baudrate.

template<class... Signals>
static void modm::SpiMaster::connect ( )
inheritedstatic

Connect GPIOs to the peripheral and configure them.

This configures the Sck, Mosi and Miso signals and connects them.

Template Parameters
SignalsOne Scl and one Mosi signal are required (one Miso signal is optional) and can be passed out-of-order.
static modm::ResumableResult<void> modm::SpiMaster::transfer ( const uint8_t *  tx,
uint8_t *  rx,
std::size_t  length 
)
inheritedstatic

Set the data buffers and length with options and starts a non-blocking transfer. This may be hardware accelerated (DMA or Interrupt), but not guaranteed.

You must call this inside a Protothread or Resumable using PT_CALL or RF_CALL respectively.

Warning
These methods differ from Resumables by lacking context protection! You must ensure that only one driver is accessing this resumable function by using acquire(ctx) and release(ctx).
Parameters
[in]txpointer to transmit buffer, set to nullptr to send dummy bytes
[out]rxpointer to receive buffer, set to nullptr to discard received bytes
lengthnumber of bytes to be shifted out
static void modm::SpiMaster::transferBlocking ( const uint8_t *  tx,
uint8_t *  rx,
std::size_t  length 
)
inheritedstatic

Set the data buffers and length with options and starts a transfer. This may be hardware accelerated (DMA or Interrupt), but not guaranteed.

Parameters
[in]txpointer to transmit buffer, set to nullptr to send dummy bytes
[out]rxpointer to receive buffer, set to nullptr to discard received bytes
lengthnumber of bytes to be shifted out

The documentation for this class was generated from the following files: