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

#include <SpiMasterLowLevel.hpp>

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

Public Member Functions

virtual ~SpiMasterLowLevel ()=0
 SpiMasterLowLevel's destructor. More...
 
virtual std::pair< int, uint32_t > configure (SpiMode mode, uint32_t clockFrequency, uint8_t wordLength, bool lsbFirst)=0
 Configures parameters of low-level SPI master driver. More...
 
virtual int start (SpiMasterBase &spiMasterBase)=0
 Starts low-level SPI master driver. More...
 
virtual int startTransfer (const void *writeBuffer, void *readBuffer, size_t size)=0
 Starts asynchronous transfer. More...
 
virtual int 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()

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

SpiMasterLowLevel's destructor.

Member Function Documentation

◆ configure()

virtual std::pair<int, uint32_t> distortos::devices::SpiMasterLowLevel::configure ( SpiMode  mode,
uint32_t  clockFrequency,
uint8_t  wordLength,
bool  lsbFirst 
)
pure virtual

Configures parameters of low-level SPI master driver.

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
Returns
pair with return code (0 on success, error code otherwise) and real clock frequency; error codes:
  • EBADF - the driver is not started;
  • EBUSY - transfer is in progress;
  • EINVAL - selected mode and/or clock frequency and/or format are invalid;

Implemented in distortos::chip::ChipSpiMasterLowLevel.

Here is the caller graph for this function:

◆ start()

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

Starts low-level SPI master driver.

Parameters
[in]spiMasterBaseis a reference to SpiMasterBase object that will be associated with this one
Returns
0 on success, error code otherwise:
  • EBADF - the driver is not stopped;

Implemented in distortos::chip::ChipSpiMasterLowLevel.

Here is the caller graph for this function:

◆ startTransfer()

virtual int distortos::devices::SpiMasterLowLevel::startTransfer ( 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.

Parameters
[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, 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]
Returns
0 on success, error code otherwise:
  • EBADF - the driver is not started;
  • EBUSY - transfer is in progress;
  • EINVAL - size is invalid;

Implemented in distortos::chip::ChipSpiMasterLowLevel.

Here is the caller graph for this function:

◆ stop()

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

Stops low-level SPI master driver.

Returns
0 on success, error code otherwise:
  • EBADF - the driver is not started;
  • EBUSY - transfer is in progress;

Implemented in distortos::chip::ChipSpiMasterLowLevel.

Here is the caller graph for this function:

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