#include "distortos/chip/SpiMasterLowLevelDmaBased.hpp"
|
constexpr | SpiMasterLowLevelDmaBased (const SpiPeripheral &spiPeripheral, DmaChannel &rxDmaChannel, const uint8_t rxDmaRequest, DmaChannel &txDmaChannel, const uint8_t txDmaRequest) |
| SpiMasterLowLevelDmaBased's constructor. More...
|
|
| ~SpiMasterLowLevelDmaBased () override |
| SpiMasterLowLevelDmaBased's destructor. More...
|
|
void | configure (devices::SpiMode mode, uint32_t clockFrequency, uint8_t wordLength, bool lsbFirst, uint32_t dummyData) override |
| Configures parameters of low-level SPI master driver. More...
|
|
int | start () override |
| Starts low-level SPI master driver. More...
|
|
void | startTransfer (devices::SpiMasterBase &spiMasterBase, const void *writeBuffer, void *readBuffer, size_t size) override |
| Starts asynchronous transfer. More...
|
|
void | stop () override |
| Stops low-level SPI master driver. More...
|
|
virtual | ~SpiMasterLowLevel ()=default |
| SpiMasterLowLevel's destructor. More...
|
|
SpiMasterLowLevelDmaBased class is a low-level SPI master driver for SPIv1 in STM32.
This driver uses DMA for data transfers.
◆ SpiMasterLowLevelDmaBased()
constexpr distortos::chip::SpiMasterLowLevelDmaBased::SpiMasterLowLevelDmaBased |
( |
const SpiPeripheral & |
spiPeripheral, |
|
|
DmaChannel & |
rxDmaChannel, |
|
|
const uint8_t |
rxDmaRequest, |
|
|
DmaChannel & |
txDmaChannel, |
|
|
const uint8_t |
txDmaRequest |
|
) |
| |
|
inline |
SpiMasterLowLevelDmaBased's constructor.
- Parameters
-
[in] | spiPeripheral | is a reference to raw SPI peripheral |
[in] | rxDmaChannel | is a reference to DMA channel used for reception |
[in] | rxDmaRequest | is the request identifier for DMA channel used for reception |
[in] | txDmaChannel | is a reference to DMA channel used for transmission |
[in] | txDmaRequest | is the request identifier for DMA channel used for transmission |
◆ ~SpiMasterLowLevelDmaBased()
distortos::chip::SpiMasterLowLevelDmaBased::~SpiMasterLowLevelDmaBased |
( |
| ) |
|
|
override |
◆ configure()
void distortos::chip::SpiMasterLowLevelDmaBased::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, [4; 16] or [minSpiWordLength; maxSpiWordLength] |
[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.
◆ eventHandler()
void distortos::chip::SpiMasterLowLevelDmaBased::eventHandler |
( |
bool |
success | ) |
|
|
private |
"Transfer complete" and "transfer error" event handler
- Parameters
-
[in] | success | tells whether the transfer was successful (true) or not (false) |
◆ isStarted()
bool distortos::chip::SpiMasterLowLevelDmaBased::isStarted |
( |
| ) |
const |
|
inlineprivate |
- Returns
- true if driver is started, false otherwise
◆ isTransferInProgress()
bool distortos::chip::SpiMasterLowLevelDmaBased::isTransferInProgress |
( |
| ) |
const |
|
inlineprivate |
- Returns
- true if transfer is in progress, false otherwise
◆ start()
int distortos::chip::SpiMasterLowLevelDmaBased::start |
( |
| ) |
|
|
overridevirtual |
◆ startTransfer()
void distortos::chip::SpiMasterLowLevelDmaBased::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::SpiMasterLowLevelDmaBased::stop |
( |
| ) |
|
|
overridevirtual |
◆ rxDmaChannel_
DmaChannel& distortos::chip::SpiMasterLowLevelDmaBased::rxDmaChannel_ |
|
private |
reference to DMA channel used for reception
◆ rxDmaChannelFunctor_
functor for DMA channel used for reception
◆ rxDmaChannelHandle_
DmaChannelHandle distortos::chip::SpiMasterLowLevelDmaBased::rxDmaChannelHandle_ |
|
private |
handle of DMA channel used for reception
◆ rxDmaRequest_
uint8_t distortos::chip::SpiMasterLowLevelDmaBased::rxDmaRequest_ |
|
private |
request identifier for DMA channel used for reception
◆ rxDummyData_
uint16_t distortos::chip::SpiMasterLowLevelDmaBased::rxDummyData_ |
|
private |
object used as reception DMA target if read buffer of transfer is nullptr
◆ spiMasterBase_
pointer to SpiMasterBase object associated with this one
◆ spiPeripheral_
const SpiPeripheral& distortos::chip::SpiMasterLowLevelDmaBased::spiPeripheral_ |
|
private |
reference to raw SPI peripheral
◆ started_
bool distortos::chip::SpiMasterLowLevelDmaBased::started_ |
|
private |
true if driver is started, false otherwise
◆ txDmaChannel_
DmaChannel& distortos::chip::SpiMasterLowLevelDmaBased::txDmaChannel_ |
|
private |
reference to DMA channel used for transmission
◆ txDmaChannelFunctor_
functor for DMA channel used for transmission
◆ txDmaChannelHandle_
DmaChannelHandle distortos::chip::SpiMasterLowLevelDmaBased::txDmaChannelHandle_ |
|
private |
handle of DMA channel used for transmission
◆ txDmaRequest_
uint8_t distortos::chip::SpiMasterLowLevelDmaBased::txDmaRequest_ |
|
private |
request identifier for DMA channel used for transmission
◆ txDummyData_
uint16_t distortos::chip::SpiMasterLowLevelDmaBased::txDummyData_ |
|
private |
dummy data that will be sent if write buffer of transfer is nullptr
◆ wordLength_
uint8_t distortos::chip::SpiMasterLowLevelDmaBased::wordLength_ |
|
private |
selected word length, bits, [4; 16] or [minSpiWordLength; maxSpiWordLength]
The documentation for this class was generated from the following files: