distortos  v0.7.0
object-oriented C++ RTOS for microcontrollers
distortos::devices::SpiMasterLowLevel Class Referenceabstract

#include "distortos/devices/communication/SpiMasterLowLevel.hpp"

Inheritance diagram for distortos::devices::SpiMasterLowLevel:
[legend]

Public Member Functions

virtual ~SpiMasterLowLevel ()=default
 SpiMasterLowLevel's destructor. More...
 
virtual void configure (SpiMode mode, uint32_t clockFrequency, uint8_t wordLength, bool lsbFirst, uint32_t dummyData)=0
 Configures parameters of low-level SPI master driver. More...
 
virtual int start ()=0
 Starts low-level SPI master driver. More...
 
virtual void startTransfer (SpiMasterBase &spiMasterBase, const void *writeBuffer, void *readBuffer, size_t size)=0
 Starts asynchronous transfer. More...
 
virtual void stop ()=0
 Stops low-level SPI master driver. More...
 

Detailed Description

SpiMasterLowLevel class is an interface for low-level SPI master driver

Constructor & Destructor Documentation

◆ ~SpiMasterLowLevel()

virtual distortos::devices::SpiMasterLowLevel::~SpiMasterLowLevel ( )
virtualdefault

SpiMasterLowLevel's destructor.

Precondition
Driver is stopped.

Member Function Documentation

◆ configure()

virtual void distortos::devices::SpiMasterLowLevel::configure ( SpiMode  mode,
uint32_t  clockFrequency,
uint8_t  wordLength,
bool  lsbFirst,
uint32_t  dummyData 
)
pure virtual

Configures parameters of low-level SPI master driver.

Precondition
Driver is started.
No transfer is in progress.
mode, clockFrequency, wordLength and lsbFirst are valid for implementation of this interface.
Parameters
[in]modeis the desired SPI mode
[in]clockFrequencyis the desired clock frequency, Hz
[in]wordLengthselects word length, bits, [1; 32]
[in]lsbFirstselects whether MSB (false) or LSB (true) is transmitted first
[in]dummyDatais the dummy data that will be sent if write buffer of transfer is nullptr

Implemented in distortos::chip::SpiMasterLowLevelDmaBased, and distortos::chip::SpiMasterLowLevelInterruptBased.

Here is the caller graph for this function:

◆ start()

virtual int distortos::devices::SpiMasterLowLevel::start ( )
pure virtual

Starts low-level SPI master driver.

Precondition
Driver is stopped.
Returns
0 on success, error code otherwise

Implemented in distortos::chip::SpiMasterLowLevelDmaBased, and distortos::chip::SpiMasterLowLevelInterruptBased.

Here is the caller graph for this function:

◆ startTransfer()

virtual void distortos::devices::SpiMasterLowLevel::startTransfer ( SpiMasterBase spiMasterBase,
const void *  writeBuffer,
void *  readBuffer,
size_t  size 
)
pure virtual

Starts asynchronous transfer.

This function returns immediately. When the transfer is physically finished (either expected number of bytes were written and read or an error was detected), SpiMasterBase::transferCompleteEvent() will be executed.

Precondition
Driver is started.
No transfer is in progress.
size is valid.
Postcondition
Transfer is in progress.
Parameters
[in]spiMasterBaseis a reference to SpiMasterBase object that will be notified about completed transfer
[in]writeBufferis the buffer with data that will be written, nullptr to send dummy data
[out]readBufferis the buffer with data that will be read, nullptr to ignore received data
[in]sizeis the size of transfer (size of writeBuffer and/or readBuffer), bytes, most not be zero, must be even if number of data bits is in range (8; 16], divisible by 3 if number of data bits is in range (16; 24] or divisible by 4 if number of data bits is in range (24; 32]

Implemented in distortos::chip::SpiMasterLowLevelDmaBased, and distortos::chip::SpiMasterLowLevelInterruptBased.

Here is the caller graph for this function:

◆ stop()

virtual void distortos::devices::SpiMasterLowLevel::stop ( )
pure virtual

Stops low-level SPI master driver.

Precondition
Driver is started.
No transfer is in progress.
Postcondition
Driver is stopped.

Implemented in distortos::chip::SpiMasterLowLevelDmaBased, and distortos::chip::SpiMasterLowLevelInterruptBased.

Here is the caller graph for this function:

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