DMA Library API
danger
this is a legacy library and thus not supported by Toradex anymore. We recommend that you use the new libraries for all Toradex modules. Please see the Toradex CE Libraries and Code Samples for up-to-date information.
Library for DMA handling, including channel allocation and DMA transfer control.
Data Structures
struct DMA_GLOBALS Memory mapped DMA Globals structure - sorted by DMA channel. More...Macros | |
#define | DMA_VER_MAJ 1 |
#define | DMA_VER_MIN 3 |
#define | DMA_VER_BUILD 1 |
#define | DMA_MAX_CHAN 32 |
number of available DMA channels More... | |
#define | DMA_USAGE_LEN 32 |
maximum string length for a descriptive text (DMA channel usage) More... | |
#define | DMA_SHARED_FILENAME (TEXT("ColibriDmaGlobals")) |
Memory mapped filename used by the DMALib for interprocess sharing of DMA data structures. More... | |
#define | PERIPH_SSP1RX (13) |
#define | PERIPH_SSP1TX (14) |
#define | PERIPH_SSP2RX (15) |
#define | PERIPH_SSP2TX (16) |
#define | PERIPH_SSP3RX (66) |
#define | PERIPH_SSP3TX (67) |
#define | PERIPH_SSP4RX (71) |
#define | PERIPH_SSP4TX (72) |
#define | PERIPH_CIF1 (68) |
#define | PERIPH_CIF2 (69) |
#define | PERIPH_CIF3 (70) |
#define | DCMD_INCSRCADDR (1 << 31) |
Source Address Increment. More... | |
#define | DCMD_INCTRGADDR (1 << 30) |
Target Address Increment. More... | |
#define | DCMD_FLOWSRC (1 << 29) |
Source Flow Control. More... | |
#define | DCMD_FLOWTRG (1 << 28) |
Target Flow Control. More... | |
#define | DCMD_CIF_DMA (1 << 27) |
Create a PXA3xx CIF descriptor. More... | |
#define | DCMD_CMPEN (1 << 25) |
Descriptor Compare Enable. More... | |
#define | DCMD_ADDRMODE (1 << 23) |
Addressing Mode. More... | |
#define | DCMD_STARTIRQEN (1 << 22) |
Start Interrupt Enable. More... | |
#define | DCMD_ENDIRQEN (1 << 21) |
End Interrupt Enable. More... | |
#define | DCMD_FLYBYS (1 << 20) |
Fly-By Source (PXA270 only) More... | |
#define | DCMD_FLYBYT (1 << 19) |
Fly-By Target (PXA270 only) More... | |
#define | DCMD_BSIZE8 (1 << 16) |
#define | DCMD_BSIZE16 (2 << 16) |
#define | DCMD_BSIZE32 (3 << 16) |
#define | DCMD_BWIDTH8 (1 << 14) |
#define | DCMD_BWIDTH16 (2 << 14) |
#define | DCMD_BWIDTH32 (3 << 14) |
#define | DCMD_LENGTH 0x01fff |
Length of Transfer in Bytes (MASK) More... | |
#define | DCSR_RUN (1 << 31) |
Run Bit (read / write) More... | |
#define | DCSR_NODESC (1 << 30) |
No-Descriptor Fetch (read / write) More... | |
#define | DCSR_STOPIRQEN (1 << 29) |
Stop Interrupt Enable (when the descriptor is done) (read / write) More... | |
#define | DCSR_EORIRQEN (1 << 28) |
End-of-Receive Interrupt Enable. More... | |
#define | DCSR_EORJMPENT (1 << 27) |
Jump to next Descriptor on End-of-Receive. More... | |
#define | DCSR_EORSTOPEN (1 << 26) |
Stop Channel on End-of-Receive. More... | |
#define | DCSR_SETCMPST (1 << 25) |
Set Descriptor Compare Status. More... | |
#define | DCSR_CLRCMPST (1 << 24) |
Clear Descriptor Compare Status. More... | |
#define | DCSR_CMPST (1 << 10) |
Descriptor Compare Status. More... | |
#define | DCSR_EORINT (1 << 9) |
End of Receive. More... | |
#define | DCSR_REQPEND (1 << 8) |
Request Pending (read-only) More... | |
#define | DCSR_RASINTR (1 << 4) |
Request after Channel Stops. More... | |
#define | DCSR_STOPINTR (1 << 3) |
Stop State (read-only) More... | |
#define | DCSR_ENDINTR (1 << 2) |
End Interrupt (read / write) More... | |
#define | DCSR_STARTINTR (1 << 1) |
Start Interrupt (read / write) More... | |
#define | DCSR_BUSERRINTR (1 << 0) |
Bus Error Interrupt (read / write) More... | |
#define | DRCMR_MAPVLD (1 << 7) |
Valid Channel mapped. More... | |
#define | DDADR_STOP (1 << 0) |
Functions | |
void | DMAGetLibVersion (DWORD *pVerMaj, DWORD *pVerMin, DWORD *pBuild) |
Initialisation. More... | |
void | DMAInit (void) |
Initializes the DMA Library. More... | |
void | DMADeInit (void) |
De-Initializes the DMA Library. More... | |
DWORD | DMAAllocChannel (DWORD periph) |
DMA Channel Management. More... | |
DWORD | DMAAllocChannelEx (DWORD periph, DWORD priority) |
void | DMAReleaseChannel (DWORD chan) |
void | DMAReleaseDevice (DWORD periph) |
void | DMASetChannelUsage (DWORD chan, CHAR *szChanUsage, DWORD cBytes) |
DWORD | DMAGetChannelUsage (DWORD chan, CHAR *szChanUsage, DWORD cBytes) |
DMA Preparation | |
BOOL | DMACreateTransferDescriptors (DWORD sadr, DWORD tadr, DWORD len, DWORD flags, BOOL loop, MEM_T *pMem) |
BOOL | DMADestroyTransferDescriptors (MEM_T *pMem) |
BOOL | DMAAllocBuffer (MEM_T *pMem, DWORD size) |
BOOL | DMAFreeBuffer (MEM_T *pMem) |
DMA Real Time Control | |
DWORD | DMAStartTransferEx (DWORD chan, MEM_T *pMem, DWORD flags, BOOL block) |
void | DMAStartShortTransfer (DWORD chan, DWORD sadr, DWORD tadr, DWORD len, DWORD cmd, DWORD csr) |
DWORD | DMAStartShortTransferEx (DWORD chan, DWORD sadr, DWORD tadr, DWORD len, DWORD cmd, DWORD csr, BOOL block) |
void | _DMAStartTransfer (DWORD chan, MEM_T *pMem, DWORD flags) |
void | DMAWaitTransferEnd (DWORD chan) |
void | DMAStopTransfer (DWORD chan) |
BOOL | DMAGetTrgSrcAdd (DWORD chan, DWORD *dtadr, DWORD *dsadr) |
Get current Target and Source address. . More... | |
DWORD | DMAGetLen (DWORD chan) |
Macro Definition Documentation
#define DCMD_ADDRMODE (1 << 23) |
Addressing Mode.
#define DCMD_BSIZE16 (2 << 16) |
#define DCMD_BSIZE32 (3 << 16) |
#define DCMD_BSIZE8 (1 << 16) |
#define DCMD_BWIDTH16 (2 << 14) |
#define DCMD_BWIDTH32 (3 << 14) |
#define DCMD_BWIDTH8 (1 << 14) |
#define DCMD_CIF_DMA (1 << 27) |
Create a PXA3xx CIF descriptor.
#define DCMD_CMPEN (1 << 25) |
Descriptor Compare Enable.
#define DCMD_ENDIRQEN (1 << 21) |
End Interrupt Enable.
#define DCMD_FLOWSRC (1 << 29) |
Source Flow Control.
#define DCMD_FLOWTRG (1 << 28) |
Target Flow Control.
#define DCMD_FLYBYS (1 << 20) |
Fly-By Source (PXA270 only)
#define DCMD_FLYBYT (1 << 19) |
Fly-By Target (PXA270 only)
#define DCMD_INCSRCADDR (1 << 31) |
Source Address Increment.
#define DCMD_INCTRGADDR (1 << 30) |
Target Address Increment.
#define DCMD_LENGTH 0x01fff |
Length of Transfer in Bytes (MASK)
#define DCMD_STARTIRQEN (1 << 22) |
Start Interrupt Enable.
#define DCSR_BUSERRINTR (1 << 0) |
Bus Error Interrupt (read / write)
#define DCSR_CLRCMPST (1 << 24) |
Clear Descriptor Compare Status.
#define DCSR_CMPST (1 << 10) |
Descriptor Compare Status.
#define DCSR_ENDINTR (1 << 2) |
End Interrupt (read / write)
#define DCSR_EORINT (1 << 9) |
End of Receive.
#define DCSR_EORIRQEN (1 << 28) |
End-of-Receive Interrupt Enable.
#define DCSR_EORJMPENT (1 << 27) |
Jump to next Descriptor on End-of-Receive.
#define DCSR_EORSTOPEN (1 << 26) |
Stop Channel on End-of-Receive.
#define DCSR_NODESC (1 << 30) |
No-Descriptor Fetch (read / write)
#define DCSR_RASINTR (1 << 4) |
Request after Channel Stops.
#define DCSR_REQPEND (1 << 8) |
Request Pending (read-only)
#define DCSR_RUN (1 << 31) |
Run Bit (read / write)
#define DCSR_SETCMPST (1 << 25) |
Set Descriptor Compare Status.
#define DCSR_STARTINTR (1 << 1) |
Start Interrupt (read / write)
#define DCSR_STOPINTR (1 << 3) |
Stop State (read-only)
#define DCSR_STOPIRQEN (1 << 29) |
Stop Interrupt Enable (when the descriptor is done) (read / write)
#define DDADR_STOP (1 << 0) |
#define DMA_MAX_CHAN 32 |
number of available DMA channels
#define DMA_SHARED_FILENAME (TEXT("ColibriDmaGlobals")) |
Memory mapped filename used by the DMALib for interprocess sharing of DMA data structures.
#define DMA_USAGE_LEN 32 |
maximum string length for a descriptive text (DMA channel usage)
#define DMA_VER_BUILD 1 |
#define DMA_VER_MAJ 1 |
#define DMA_VER_MIN 3 |
#define DRCMR_MAPVLD (1 << 7) |
Valid Channel mapped.
#define PERIPH_CIF1 (68) |
#define PERIPH_CIF2 (69) |
#define PERIPH_CIF3 (70) |
#define PERIPH_SSP1RX (13) |
#define PERIPH_SSP1TX (14) |
#define PERIPH_SSP2RX (15) |
#define PERIPH_SSP2TX (16) |
#define PERIPH_SSP3RX (66) |
#define PERIPH_SSP3TX (67) |
#define PERIPH_SSP4RX (71) |
#define PERIPH_SSP4TX (72) |
Enumeration Type Documentation
enum DMA_CHANNEL_PRIORITY |
enum DMA_PERIPH_ID |
DMA peripheral device DRCMR IDs.
Function Documentation
void _DMAStartTransfer | ( | DWORD | chan, |
MEM_T * | pMem, | ||
DWORD | flags | ||
) |
Start a DMA transfer which was previously setup using DMACreateTransferDescriptors().
Needed to be renamed because in Wince 6.0 we have a naming conflict with a CEDDK function!!
Needed to be renamed because in Wince 6.0 we have a naming conflict with a CEDDK function!!
- Parameters
[in] chan DMA channel number [in] pMem Physical and virtual address of the descriptor [in] flags Flags for the DMA Control/Status Register
BOOL DMAAllocBuffer | ( | MEM_T * | pMem, |
DWORD | size | ||
) |
Allocate physical memory that can be used as source or target for DMA transfers.
- Parameters
[out] pMem Physical and virual address of the allocated memory [in] size Required memory size in bytes
- Return values
TRUE Success FALSE Error occured
DWORD DMAAllocChannel | ( | DWORD | periph | ) |
DMA Channel Management.
Searches for a free channel and allocates it.
Searches for a free channel and allocates it.
- Parameters
[in] periph DMA peripheral device DRCMR ID
- Return values
-1 No free channel found. >=0 Allocated DMA channel number
- Deprecated:
- Obsolete fuction!
DWORD DMAAllocChannelEx | ( | DWORD | periph, |
DWORD | priority | ||
) |
Searches for a free channel with specific priority and allocates it.
- Parameters
[in] periph DMA peripheral device DRCMR ID [in] priority Requested Priority. See DMA_CHANNEL_PRIORITY
- Return values
-1 No free channel found for the requested priority. >=0 Allocated DMA channel number.
BOOL DMACreateTransferDescriptors | ( | DWORD | sadr, |
DWORD | tadr, | ||
DWORD | len, | ||
DWORD | flags, | ||
BOOL | loop, | ||
MEM_T * | pMem | ||
) |
Create DMA Transfer descriptor.
NOTE: TransferDescriptors in RAM are only required for transfers of 8kB or more.
NOTE: TransferDescriptors in RAM are only required for transfers of 8kB or more.
- Parameters
[in] sadr Source address [in] tadr Target address [in] len Length of Transfer in Bytes, see also DMA Command Registers [in] flags Flags for the DMA Command Registers [in] loop TRUE: DMA descriptor chain is a loop [out] pMem Physical and virtual address of the descriptor
- Return values
TRUE Success FALSE Error occured
void DMADeInit | ( | void | ) |
De-Initializes the DMA Library.
BOOL DMADestroyTransferDescriptors | ( | MEM_T * | pMem | ) |
Release memory reserved for the transfer descriptor.
NOTE: TransferDescriptors in RAM are only required for transfers of 8kB or more.
NOTE: TransferDescriptors in RAM are only required for transfers of 8kB or more.
- Parameters
[in,out] pMem Physical and virtual address of the descriptor
- Return values
TRUE Success FALSE Error occured
BOOL DMAFreeBuffer | ( | MEM_T * | pMem | ) |
Free the physical memory that was allocated by DMAAllocBuffer()
- Parameters
[in,out] pMem Physical and virtual address of the allocated memory
- Return values
TRUE Success FALSE Error occured
DWORD DMAGetChannelUsage | ( | DWORD | chan, |
CHAR * | szChanUsage, | ||
DWORD | cBytes | ||
) |
Get the descriptive text for what a DMA channel is used for.
- Parameters
[in] chan DMA channel number [out] szChanUsage Descriptive Text (Zero-terminated ASCII string) [in] cBytes Maximum allowed String Length in Bytes
- Return values
DWORD Actually returned string length.
DWORD DMAGetLen | ( | DWORD | chan | ) |
Get number of bytes already transferred.
- Parameters
[in] chan DMA channel number
- Return values
DWORD Number of bytes already transferred.
void DMAGetLibVersion | ( | DWORD * | pVerMaj, |
DWORD * | pVerMin, | ||
DWORD * | pBuild | ||
) |
Initialisation.
Returns the library Version.
Returns the library Version.
- Parameters
[out] pVerMaj Returns the major version number. Set this parameter to NULL if not required. [out] pVerMin Returns the minor version number. Set this parameter to NULL if not required. [out] pBuild Returns the build number. Set this parameter to NULL if not required.
BOOL DMAGetTrgSrcAdd | ( | DWORD | chan, |
DWORD * | dtadr, | ||
DWORD * | dsadr | ||
) |
Get current Target and Source address.
.
.
- Parameters
[in] chan DMA channel number [out] dtadr Target address [out] dsadr Source address
- Return values
TRUE Success FALSE Error occured
void DMAInit | ( | void | ) |
Initializes the DMA Library.
void DMAReleaseChannel | ( | DWORD | chan | ) |
Release/free DMA Channel
- Parameters
[in] chan DMA channel number. Remarks: ATTENTION! Parameter changed to channel number.
Used to be peripheral device ID which is inappropriate.
See new Function: DMAReleaseDevice.
void DMAReleaseDevice | ( | DWORD | periph | ) |
Releases Device allocated DMA Channel.
- Parameters
[in] periph DMA peripheral device DRCMR ID
void DMASetChannelUsage | ( | DWORD | chan, |
CHAR * | szChanUsage, | ||
DWORD | cBytes | ||
) |
Set a descriptive text for what a DMA channel is used for.
- Parameters
[in] chan DMA channel number [in] szChanUsage Descriptive Text (Zero-terminated ASCII string) [in] cBytes String Length in Bytes
void DMAStartShortTransfer | ( | DWORD | chan, |
DWORD | sadr, | ||
DWORD | tadr, | ||
DWORD | len, | ||
DWORD | cmd, | ||
DWORD | csr | ||
) |
Start DMA transfer non descriptor mode.
NOTE: This can only be used for transfers < 8kB
NOTE: This can only be used for transfers < 8kB
- Parameters
[in] chan DMA channel number [in] sadr Source address [in] tadr Target address [in] len Length of Transfer in bytes (max. 8191) [in] cmd Flags for the DMA Command Registers [in] csr Flags for the DMA Control/Status Register
DWORD DMAStartShortTransferEx | ( | DWORD | chan, |
DWORD | sadr, | ||
DWORD | tadr, | ||
DWORD | len, | ||
DWORD | cmd, | ||
DWORD | csr, | ||
BOOL | block | ||
) |
Start DMA transfer non-descriptor mode.
NOTE: This can only be used for transfers < 8Kb
NOTE: This can only be used for transfers < 8Kb
- Parameters
[in] chan DMA channel number [in] sadr Source address [in] tadr Target address [in] len Length of Transfer in bytes (max. 8191) [in] cmd Flags for the DMA Command Registers [in] csr Flags for the DMA Control/Status Register [in] block TRUE: function returns after DMA is finished
FALSE: function returns immediately
- Return values
TRUE Success FALSE Timeout detected
DWORD DMAStartTransferEx | ( | DWORD | chan, |
MEM_T * | pMem, | ||
DWORD | flags, | ||
BOOL | block | ||
) |
Start a DMA transfer which was previously setup using DMACreateTransferDescriptors().
- Parameters
[in] chan DMA channel number [in] pMem Physical and virtual address of the descriptor [in] flags Flags for the DMA Command Registers [in] block TRUE=function returns after DMA is finished
FALSE= function returns immediately
- Return values
TRUE Success FALSE Timeout detected
void DMAStopTransfer | ( | DWORD | chan | ) |
Early stop DMA transfer
- Parameters
[in] chan DMA channel number
void DMAWaitTransferEnd | ( | DWORD | chan | ) |
Wait until DMA transfer is finished
- Parameters
[in] chan DMA channel number