#include "distortos/devices/communication/SpiMasterHandle.hpp"
SpiMasterHandle is a std::lock_guard-like class for locking SpiMaster and for accessing its core functionality.
- Note
- Locks are recursive.
◆ SpiMasterHandle()
distortos::devices::SpiMasterHandle::SpiMasterHandle |
( |
SpiMaster & |
spiMaster | ) |
|
|
inlineexplicit |
SpiMasterHandle's constructor.
- Warning
- This function must not be called from interrupt context!
- Parameters
-
[in] | spiMaster | is 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!
◆ close()
void distortos::devices::SpiMasterHandle::close |
( |
| ) |
const |
|
inline |
Closes associated SPI master.
- Precondition
- Associated SPI master is opened.
◆ 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] | mode | is the desired SPI mode |
[in] | clockFrequency | is the desired clock frequency, Hz |
[in] | wordLength | selects word length, bits |
[in] | lsbFirst | selects whether MSB (false) or LSB (true) is transmitted first |
[in] | dummyData | is the dummy data that will be sent if write buffer of transfer is nullptr |
◆ executeTransaction()
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] | transfersRange | is the range of transfers that will be executed |
- Returns
- 0 on success, error code otherwise:
- error codes returned by SpiMasterLowLevel::executeTransaction();
◆ 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:
◆ 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: