#include "distortos/chip/SpiMasterLowLevelInterruptBased.hpp"
SpiMasterLowLevelInterruptBased class is a low-level SPI master driver for SPIv1 in STM32.
This driver uses interrupts for data transfers.
◆ SpiMasterLowLevelInterruptBased()
constexpr distortos::chip::SpiMasterLowLevelInterruptBased::SpiMasterLowLevelInterruptBased |
( |
const SpiPeripheral & |
spiPeripheral | ) |
|
|
inlineexplicit |
◆ ~SpiMasterLowLevelInterruptBased()
distortos::chip::SpiMasterLowLevelInterruptBased::~SpiMasterLowLevelInterruptBased |
( |
| ) |
|
|
override |
◆ configure()
void distortos::chip::SpiMasterLowLevelInterruptBased::configure |
( |
devices::SpiMode |
mode, |
|
|
uint32_t |
clockFrequency, |
|
|
uint8_t |
wordLength, |
|
|
bool |
lsbFirst, |
|
|
uint32_t |
dummyData |
|
) |
| |
|
overridevirtual |
Configures parameters of low-level SPI master driver.
- Precondition
- Driver is started.
-
No transfer is in progress.
-
clockFrequency is greater than or equal to
spiPeripheral_.getPeripheralFrequency() / 256
.
-
wordLength is valid.
- Parameters
-
[in] | mode | is the desired SPI mode |
[in] | clockFrequency | is the desired clock frequency, Hz |
[in] | wordLength | selects word length, bits, {8, 16} |
[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 |
Implements distortos::devices::SpiMasterLowLevel.
◆ interruptHandler()
void distortos::chip::SpiMasterLowLevelInterruptBased::interruptHandler |
( |
| ) |
|
Interrupt handler.
- Note
- this must not be called by user code
◆ isStarted()
bool distortos::chip::SpiMasterLowLevelInterruptBased::isStarted |
( |
| ) |
const |
|
inlineprivate |
- Returns
- true if driver is started, false otherwise
◆ isTransferInProgress()
bool distortos::chip::SpiMasterLowLevelInterruptBased::isTransferInProgress |
( |
| ) |
const |
|
inlineprivate |
- Returns
- true if transfer is in progress, false otherwise
◆ start()
int distortos::chip::SpiMasterLowLevelInterruptBased::start |
( |
| ) |
|
|
overridevirtual |
◆ startTransfer()
void distortos::chip::SpiMasterLowLevelInterruptBased::startTransfer |
( |
devices::SpiMasterBase & |
spiMasterBase, |
|
|
const void * |
writeBuffer, |
|
|
void * |
readBuffer, |
|
|
size_t |
size |
|
) |
| |
|
overridevirtual |
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] | spiMasterBase | is a reference to SpiMasterBase object that will be notified about completed transfer |
[in] | writeBuffer | is the buffer with data that will be written, nullptr to send dummy data |
[out] | readBuffer | is the buffer with data that will be read, nullptr to ignore received data |
[in] | size | is 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] |
Implements distortos::devices::SpiMasterLowLevel.
◆ stop()
void distortos::chip::SpiMasterLowLevelInterruptBased::stop |
( |
| ) |
|
|
overridevirtual |
◆ writeNextItem()
void distortos::chip::SpiMasterLowLevelInterruptBased::writeNextItem |
( |
| ) |
|
|
private |
Writes next item to SPI peripheral.
◆ dummyData_
uint16_t distortos::chip::SpiMasterLowLevelInterruptBased::dummyData_ |
|
private |
dummy data that will be sent if write buffer of transfer is nullptr
◆ readBuffer_
uint8_t* volatile distortos::chip::SpiMasterLowLevelInterruptBased::readBuffer_ |
|
private |
buffer to which the data is being written, nullptr to ignore received data
◆ readPosition_
volatile size_t distortos::chip::SpiMasterLowLevelInterruptBased::readPosition_ |
|
private |
current position in readBuffer_
◆ size_
volatile size_t distortos::chip::SpiMasterLowLevelInterruptBased::size_ |
|
private |
size of transfer (size of readBuffer_ and/or writeBuffer_), bytes
◆ spiMasterBase_
pointer to SpiMasterBase object associated with this one
◆ spiPeripheral_
const SpiPeripheral& distortos::chip::SpiMasterLowLevelInterruptBased::spiPeripheral_ |
|
private |
reference to raw SPI peripheral
◆ started_
bool distortos::chip::SpiMasterLowLevelInterruptBased::started_ |
|
private |
true if driver is started, false otherwise
◆ wordLength_
uint8_t distortos::chip::SpiMasterLowLevelInterruptBased::wordLength_ |
|
private |
selected word length, bits, {8, 16}
◆ writeBuffer_
const uint8_t* volatile distortos::chip::SpiMasterLowLevelInterruptBased::writeBuffer_ |
|
private |
buffer with data that is being transmitted, nullptr to send dummy data
◆ writePosition_
volatile size_t distortos::chip::SpiMasterLowLevelInterruptBased::writePosition_ |
|
private |
current position in writeBuffer_
The documentation for this class was generated from the following files: