distortos  v0.7.0
object-oriented C++ RTOS for microcontrollers
distortos::devices::SpiMasterHandle Class Reference

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

Collaboration diagram for distortos::devices::SpiMasterHandle:
[legend]

Public Member Functions

 SpiMasterHandle (SpiMaster &spiMaster)
 SpiMasterHandle's constructor. More...
 
 ~SpiMasterHandle ()
 SpiMasterHandle's destructor. More...
 
void close () const
 Closes associated SPI master. More...
 
void configure (const SpiMode mode, const uint32_t clockFrequency, const uint8_t wordLength, const bool lsbFirst, const uint32_t dummyData) const
 Configures parameters of associated SPI master. More...
 
int executeTransaction (const SpiMasterTransfersRange transfersRange) const
 Executes series of transfers as a single atomic transaction. More...
 
int open () const
 Opens associated SPI master. More...
 
 SpiMasterHandle (const SpiMasterHandle &)=delete
 
SpiMasterHandleoperator= (const SpiMasterHandle &)=delete
 

Private Attributes

SpiMasterspiMaster_
 reference to SpiMaster associated with this handle More...
 

Detailed Description

SpiMasterHandle is a std::lock_guard-like class for locking SpiMaster and for accessing its core functionality.

Note
Locks are recursive.

Constructor & Destructor Documentation

◆ SpiMasterHandle()

distortos::devices::SpiMasterHandle::SpiMasterHandle ( SpiMaster spiMaster)
inlineexplicit

SpiMasterHandle's constructor.

Warning
This function must not be called from interrupt context!
Parameters
[in]spiMasteris a reference to SpiMaster associated with this handle

◆ ~SpiMasterHandle()

distortos::devices::SpiMasterHandle::~SpiMasterHandle ( )
inline

SpiMasterHandle's destructor.

Warning
This function must not be called from interrupt context!
Here is the call graph for this function:

Member Function Documentation

◆ close()

void distortos::devices::SpiMasterHandle::close ( ) const
inline

Closes associated SPI master.

Precondition
Associated SPI master is opened.
Here is the call graph for this function:

◆ configure()

void distortos::devices::SpiMasterHandle::configure ( const SpiMode  mode,
const uint32_t  clockFrequency,
const uint8_t  wordLength,
const bool  lsbFirst,
const uint32_t  dummyData 
) const
inline

Configures parameters of associated SPI master.

Precondition
Associated SPI master is opened.
clockFrequency and wordLength are valid for associated low-level implementation of SpiMasterLowLevel interface.
Parameters
[in]modeis the desired SPI mode
[in]clockFrequencyis the desired clock frequency, Hz
[in]wordLengthselects word length, bits
[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
Here is the call graph for this function:
Here is the caller graph for this function:

◆ executeTransaction()

int distortos::devices::SpiMasterHandle::executeTransaction ( const SpiMasterTransfersRange  transfersRange) const
inline

Executes series of transfers as a single atomic transaction.

Warning
This function must not be called from interrupt context!
Precondition
Associated SPI master is opened.
transfersRange has at least one transfer.
Parameters
[in]transfersRangeis the range of transfers that will be executed
Returns
0 on success, error code otherwise:
  • error codes returned by SpiMasterLowLevel::executeTransaction();
Here is the call graph for this function:
Here is the caller graph for this function:

◆ open()

int distortos::devices::SpiMasterHandle::open ( ) const
inline

Opens associated SPI master.

Precondition
The number of times the device is opened is less than 255.
Returns
0 on success, error code otherwise:
Here is the call graph for this function:

Member Data Documentation

◆ spiMaster_

SpiMaster& distortos::devices::SpiMasterHandle::spiMaster_
private

reference to SpiMaster associated with this handle


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