distortos  v0.7.0
object-oriented C++ RTOS for microcontrollers
distortos::chip::DmaChannel Class Reference

#include "distortos/chip/DmaChannel.hpp"

Collaboration diagram for distortos::chip::DmaChannel:
[legend]

Public Types

using Flags = DmaChannelFlags
 import DmaChannelFlags More...
 

Public Member Functions

constexpr DmaChannel (const DmaPeripheral &dmaPeripheral, const DmaChannelPeripheral &dmaChannelPeripheral)
 DmaChannel's constructor. More...
 
 ~DmaChannel ()
 DmaChannel's destructor. More...
 
void interruptHandler ()
 Interrupt handler. More...
 

Private Member Functions

size_t getTransactionsLeft () const
 
void release ()
 Releases low-level DMA channel driver. More...
 
int reserve (uint8_t request, DmaChannelFunctor &functor)
 Reserves low-level DMA channel driver for exclusive use. More...
 
void startTransfer (uintptr_t memoryAddress, uintptr_t peripheralAddress, size_t transactions, Flags flags) const
 Configures and starts asynchronous transfer. More...
 
void stopTransfer () const
 Stops transfer. More...
 

Private Attributes

const DmaPeripheraldmaPeripheral_
 reference to raw DMA peripheral More...
 
const DmaChannelPeripheraldmaChannelPeripheral_
 reference to raw DMA channel peripheral More...
 
DmaChannelFunctorfunctor_
 pointer to DmaChannelFunctor object associated with this one More...
 
uint8_t request_
 request identifier with which this object is associated More...
 

Friends

class DmaChannelHandle
 

Detailed Description

DmaChannel class is a low-level DMA channel driver for DMAv2 in STM32

Member Typedef Documentation

◆ Flags

import DmaChannelFlags

Constructor & Destructor Documentation

◆ DmaChannel()

constexpr distortos::chip::DmaChannel::DmaChannel ( const DmaPeripheral dmaPeripheral,
const DmaChannelPeripheral dmaChannelPeripheral 
)
inline

DmaChannel's constructor.

Parameters
[in]dmaPeripheralis a reference to raw DMA peripheral
[in]dmaChannelPeripheralis a reference to raw DMA channel peripheral

◆ ~DmaChannel()

distortos::chip::DmaChannel::~DmaChannel ( )
inline

DmaChannel's destructor.

Precondition
Driver is not reserved.

Member Function Documentation

◆ getTransactionsLeft()

size_t distortos::chip::DmaChannel::getTransactionsLeft ( ) const
private
Returns
number of transactions left
Here is the call graph for this function:
Here is the caller graph for this function:

◆ interruptHandler()

void distortos::chip::DmaChannel::interruptHandler ( )

Interrupt handler.

Note
this must not be called by user code
Precondition
Driver is reserved.
Here is the call graph for this function:

◆ release()

void distortos::chip::DmaChannel::release ( )
private

Releases low-level DMA channel driver.

Precondition
No transfer is in progress.
Postcondition
Driver is not reserved.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ reserve()

int distortos::chip::DmaChannel::reserve ( uint8_t  request,
DmaChannelFunctor functor 
)
private

Reserves low-level DMA channel driver for exclusive use.

Precondition
request is valid.
Parameters
[in]requestis the request identifier with which this object will be associated
[in]functoris a reference to DmaChannelFunctor object that will be notified about transfer-related events
Returns
0 on success, error code otherwise:
  • EBUSY - the driver is not released;
Here is the caller graph for this function:

◆ startTransfer()

void distortos::chip::DmaChannel::startTransfer ( uintptr_t  memoryAddress,
uintptr_t  peripheralAddress,
size_t  transactions,
Flags  flags 
) const
private

Configures and starts asynchronous transfer.

This function returns immediately. When the transfer is physically finished (either expected number of transactions were executed or an error was detected), one of DmaChannelFunctor functions will be executed.

Precondition
Driver is reserved.
memoryAddress and peripheralAddress and transactions and flags are valid.
Memory data size multiplied by memory burst size is less than or equal to 16.
No transfer is in progress.
Postcondition
Transfer is in progress.
Parameters
[in]memoryAddressis the memory address, must be divisible by configured memory data size multiplied by configured memory burst size
[in]peripheralAddressis the peripheral address, must be divisible by peripheral data size multiplied by configured peripheral burst size
[in]transactionsis the number of transactions, [1; 65535]
[in]flagsare configuration flags
Here is the call graph for this function:
Here is the caller graph for this function:

◆ stopTransfer()

void distortos::chip::DmaChannel::stopTransfer ( ) const
private

Stops transfer.

This function should be used after previous asynchronous transfer is finished to restore DMA channel to proper state. It may also be used to stop any ongoing asynchronous transfer.

Precondition
Driver is reserved.
Postcondition
No transfer is in progress.
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ dmaChannelPeripheral_

const DmaChannelPeripheral& distortos::chip::DmaChannel::dmaChannelPeripheral_
private

reference to raw DMA channel peripheral

◆ dmaPeripheral_

const DmaPeripheral& distortos::chip::DmaChannel::dmaPeripheral_
private

reference to raw DMA peripheral

◆ functor_

DmaChannelFunctor* distortos::chip::DmaChannel::functor_
private

pointer to DmaChannelFunctor object associated with this one

◆ request_

uint8_t distortos::chip::DmaChannel::request_
private

request identifier with which this object is associated


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