Skyward boardcore
Loading...
Searching...
No Matches
Boardcore::DMAStream Class Reference

This class represents the actual DMA stream. It can be used to setup, start and stop DMA transactions. More...

#include <DMA.h>

Public Member Functions

void setup (DMATransaction &transaction)
 Setup the stream with the given configuration.
 
void enable ()
 Activate the stream. As soon as the stream is enabled, it serves any DMA request from/to the peripheral connected to the stream.
 
void disable ()
 Stop the DMA transaction (if running). This is equivalent to killing the transaction: DO NOT expect to be able to restart the transaction from where it was interrupted. The work completed up to the call will still be valid.
 
void waitForHalfTransfer ()
 Wait for the half transfer complete signal. The caller waits for the corresponding interrupt, if enabled. Otherwise it goes to polling mode on the flag.
 
void waitForTransferComplete ()
 Wait for the transfer complete signal. The caller waits for the corresponding interrupt, if enabled. Otherwise it goes to polling mode on the flag. In case cache is used, this method invalidates the cache lines, so that the user can see the memory as is in ram.
 
bool timedWaitForHalfTransfer (std::chrono::nanoseconds timeout_ns)
 Wait for the half transfer complete signal. The caller waits for the corresponding interrupt, if enabled. Otherwise it goes to polling mode on the flag.
 
bool timedWaitForTransferComplete (std::chrono::nanoseconds timeout_ns)
 Wait for the transfer complete signal. The caller waits for the corresponding interrupt, if enabled. Otherwise it goes to polling mode on the flag. In case cache is used, this method invalidates the cache lines, so that the user can see the memory as is in ram.
 
void setHalfTransferCallback (std::function< void()> callback)
 
void resetHalfTransferCallback ()
 
void setTransferCompleteCallback (std::function< void()> callback)
 
void resetTransferCompleteCallback ()
 
void setErrorCallback (std::function< void()> callback)
 
void resetErrorCallback ()
 
void readFlags ()
 Reads the current flags status.
 
bool setNumberOfDataItems (const uint16_t nBytes)
 Set the number of bytes to be exchanged during a dma transaction. Useful in case you don't want to change the entire configuration. Use while the stream is not enabled.
 
void setChannel (const DMADefs::Channel channel)
 Select the channel to be used by the stream during the transactions.
 
bool getHalfTransferFlagStatus ()
 Returns the last read status of the half transfer flag.
 
bool getTransferCompleteFlagStatus ()
 Returns the last read status of the transfer complete flag.
 
bool getTransferErrorFlagStatus ()
 Returns the last read status of the transfer error flag.
 
bool getFifoErrorFlagStatus ()
 Returns the last read status of the fifo error flag.
 
bool getDirectModeErrorFlagStatus ()
 Returns the last read status of the direct mode (default mode) error flag.
 
int getCurrentBufferNumber ()
 Returns the number of the buffer currently in use when in double buffer mode.
 
DMADefs::DMAStreamId getStreamId ()
 
DMADefs::Channel getCurrentChannel ()
 
void clearHalfTransferFlag ()
 
void clearTransferCompleteFlag ()
 
void clearTransferErrorFlag ()
 
void clearFifoErrorFlag ()
 
void clearDirectModeErrorFlag ()
 
void clearAllFlags ()
 Clear all the flags for the selected stream in the DMA ISR register (LISR or HISR depending on the selected stream id).
 
 DMAStream (const DMAStream &)=delete
 
DMAStreamoperator= (const DMAStream &)=delete
 
 DMAStream (DMAStream &&) noexcept=default
 
DMAStreamoperator= (DMAStream &&) noexcept=default
 

Detailed Description

This class represents the actual DMA stream. It can be used to setup, start and stop DMA transactions.

Definition at line 218 of file DMA.h.

Constructor & Destructor Documentation

◆ DMAStream() [1/2]

Boardcore::DMAStream::DMAStream ( const DMAStream & )
delete

◆ DMAStream() [2/2]

Boardcore::DMAStream::DMAStream ( DMAStream && )
defaultnoexcept

Member Function Documentation

◆ clearAllFlags()

void Boardcore::DMAStream::clearAllFlags ( )
inline

Clear all the flags for the selected stream in the DMA ISR register (LISR or HISR depending on the selected stream id).

Definition at line 386 of file DMA.h.

◆ clearDirectModeErrorFlag()

void Boardcore::DMAStream::clearDirectModeErrorFlag ( )
inline

Definition at line 377 of file DMA.h.

◆ clearFifoErrorFlag()

void Boardcore::DMAStream::clearFifoErrorFlag ( )
inline

Definition at line 375 of file DMA.h.

◆ clearHalfTransferFlag()

void Boardcore::DMAStream::clearHalfTransferFlag ( )
inline

Definition at line 360 of file DMA.h.

◆ clearTransferCompleteFlag()

void Boardcore::DMAStream::clearTransferCompleteFlag ( )
inline

Definition at line 365 of file DMA.h.

◆ clearTransferErrorFlag()

void Boardcore::DMAStream::clearTransferErrorFlag ( )
inline

Definition at line 370 of file DMA.h.

◆ disable()

void Boardcore::DMAStream::disable ( )

Stop the DMA transaction (if running). This is equivalent to killing the transaction: DO NOT expect to be able to restart the transaction from where it was interrupted. The work completed up to the call will still be valid.

Warning
If set, the transfer complete interrupt will be fired.

Definition at line 554 of file DMA.cpp.

◆ enable()

void Boardcore::DMAStream::enable ( )

Activate the stream. As soon as the stream is enabled, it serves any DMA request from/to the peripheral connected to the stream.

Definition at line 536 of file DMA.cpp.

◆ getCurrentBufferNumber()

int Boardcore::DMAStream::getCurrentBufferNumber ( )

Returns the number of the buffer currently in use when in double buffer mode.

Returns
1 or 2 depending on the buffer currently in use.

Definition at line 703 of file DMA.cpp.

◆ getCurrentChannel()

DMADefs::Channel Boardcore::DMAStream::getCurrentChannel ( )
inline

Definition at line 358 of file DMA.h.

◆ getDirectModeErrorFlagStatus()

bool Boardcore::DMAStream::getDirectModeErrorFlagStatus ( )
inline

Returns the last read status of the direct mode (default mode) error flag.

Definition at line 347 of file DMA.h.

◆ getFifoErrorFlagStatus()

bool Boardcore::DMAStream::getFifoErrorFlagStatus ( )
inline

Returns the last read status of the fifo error flag.

Definition at line 341 of file DMA.h.

◆ getHalfTransferFlagStatus()

bool Boardcore::DMAStream::getHalfTransferFlagStatus ( )
inline

Returns the last read status of the half transfer flag.

Definition at line 326 of file DMA.h.

◆ getStreamId()

DMADefs::DMAStreamId Boardcore::DMAStream::getStreamId ( )
inline

Definition at line 356 of file DMA.h.

◆ getTransferCompleteFlagStatus()

bool Boardcore::DMAStream::getTransferCompleteFlagStatus ( )
inline

Returns the last read status of the transfer complete flag.

Definition at line 331 of file DMA.h.

◆ getTransferErrorFlagStatus()

bool Boardcore::DMAStream::getTransferErrorFlagStatus ( )
inline

Returns the last read status of the transfer error flag.

Definition at line 336 of file DMA.h.

◆ operator=() [1/2]

DMAStream & Boardcore::DMAStream::operator= ( const DMAStream & )
delete

◆ operator=() [2/2]

DMAStream & Boardcore::DMAStream::operator= ( DMAStream && )
defaultnoexcept

◆ readFlags()

void Boardcore::DMAStream::readFlags ( )

Reads the current flags status.

The values can be read with the get***FlagStatus functions.

Definition at line 673 of file DMA.cpp.

◆ resetErrorCallback()

void Boardcore::DMAStream::resetErrorCallback ( )

Definition at line 671 of file DMA.cpp.

◆ resetHalfTransferCallback()

void Boardcore::DMAStream::resetHalfTransferCallback ( )

Definition at line 654 of file DMA.cpp.

◆ resetTransferCompleteCallback()

void Boardcore::DMAStream::resetTransferCompleteCallback ( )

Definition at line 661 of file DMA.cpp.

◆ setChannel()

void Boardcore::DMAStream::setChannel ( const DMADefs::Channel channel)

Select the channel to be used by the stream during the transactions.

Definition at line 698 of file DMA.cpp.

◆ setErrorCallback()

void Boardcore::DMAStream::setErrorCallback ( std::function< void()> callback)

Definition at line 666 of file DMA.cpp.

◆ setHalfTransferCallback()

void Boardcore::DMAStream::setHalfTransferCallback ( std::function< void()> callback)

Definition at line 649 of file DMA.cpp.

◆ setNumberOfDataItems()

bool Boardcore::DMAStream::setNumberOfDataItems ( const uint16_t nBytes)

Set the number of bytes to be exchanged during a dma transaction. Useful in case you don't want to change the entire configuration. Use while the stream is not enabled.

Returns
True if the operation succeeded, false otherwise.

Definition at line 684 of file DMA.cpp.

◆ setTransferCompleteCallback()

void Boardcore::DMAStream::setTransferCompleteCallback ( std::function< void()> callback)

Definition at line 656 of file DMA.cpp.

◆ setup()

void Boardcore::DMAStream::setup ( DMATransaction & transaction)

Setup the stream with the given configuration.

Definition at line 427 of file DMA.cpp.

◆ timedWaitForHalfTransfer()

bool Boardcore::DMAStream::timedWaitForHalfTransfer ( std::chrono::nanoseconds timeout_ns)

Wait for the half transfer complete signal. The caller waits for the corresponding interrupt, if enabled. Otherwise it goes to polling mode on the flag.

Parameters
timeout_nsThe maximum time that will be waited.
Returns
True if the event is reached, false if the timeout expired.
Warning
In case cache is used, this method DOES NOT invalidate the cache lines. Cache invalidation must be handled by the user.

Definition at line 578 of file DMA.cpp.

◆ timedWaitForTransferComplete()

bool Boardcore::DMAStream::timedWaitForTransferComplete ( std::chrono::nanoseconds timeout_ns)

Wait for the transfer complete signal. The caller waits for the corresponding interrupt, if enabled. Otherwise it goes to polling mode on the flag. In case cache is used, this method invalidates the cache lines, so that the user can see the memory as is in ram.

Parameters
timeout_nsThe maximum time that will be waited.
Returns
True if the event is reached, false if the timeout expired.

Definition at line 587 of file DMA.cpp.

◆ waitForHalfTransfer()

void Boardcore::DMAStream::waitForHalfTransfer ( )

Wait for the half transfer complete signal. The caller waits for the corresponding interrupt, if enabled. Otherwise it goes to polling mode on the flag.

Warning
In case cache is used, this method DOES NOT invalidate the cache lines. Cache invalidation must be handled by the user.

Definition at line 556 of file DMA.cpp.

◆ waitForTransferComplete()

void Boardcore::DMAStream::waitForTransferComplete ( )

Wait for the transfer complete signal. The caller waits for the corresponding interrupt, if enabled. Otherwise it goes to polling mode on the flag. In case cache is used, this method invalidates the cache lines, so that the user can see the memory as is in ram.

Definition at line 565 of file DMA.cpp.


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