Download presentation
Presentation is loading. Please wait.
Published byShannon Osborne Modified over 9 years ago
1
DMA Driver APIs DMA State Diagram Loading Driver and Opening Channel DMA Channel Attributes Loading Data to a Channel Unloading Data from a Channel
2
DMA Driver State Diagram Idle Enabled Disabled dmaLoadDriver() dmaOpenChannel() dmaDisableChannel() dmaEnableChannel() dmaCloseChannel() dmaLoadChannel() dmaUnloadChannel()
3
Loading DMA Driver prototype: int dmaLoadDriver(void) Returns 0 always.
4
Opening a DMA Channel prototype: int dmaOpenChannel( int *channel_ID, int channel_type, unsigned int option_flags, int ring_size, dmaReleaseType release_rtn) example: rc = dmaOpenChannel ( &channel_id, DMA_FIFO_1_TX, (DMA_MEM_TO_MEM_MODE | DMA_DADDR_INCR | DMA_SADDR_INCR), 64, releaseFunction); Returns Error Code
5
dmaOpenChannel Return Codes Possible Return Values for dmaOpenChannel() DMA_SUCCESS DMA_DRIVER_UNLOADED DMA_INVALID_FLAG DMA_CHANNEL_INUSE DMA_INVALID_RING_SIZE DMA_CALLBACK_UNDEFINED MA_INVALID_STATE DMA_SYSTEM_ERROR DMA_CHANNEL_UNSUPPORTED
6
Channel ID prototype: int dmaOpenChannel( int *channel_ID, int channel_type, unsigned int option_flags, int ring_size, dmaReleaseType (release_rtn) Handle for opened channel, used in various DMA APIs.
7
Channel Type prototype: int dmaOpenChannel( int *channel_ID, int channel_type, unsigned int option_flags, int ring_size, dmaReleaseType release_rtn) Peripheral FIFO DMA Memory “Fly-By Write” Peripheral FIFO DMA Memory “Fly-By Read” DMA_FIFO_1_TX (Channel 4) DMA_FIFO_1_RX (Channel 3)
8
Option Flags DMA Operation Mode –DMA_MEM_TO_MEM Burst Transfer Size –DMA_8_BYTE_BURST –DMA_16_BYTE_BURST Channel Request Source –DMA_EXTERNAL_REQ Source Address Increment –DMA_SRC_INCR Destination Address Increment –DMA_DADDR_INC DMA Transaction Operand Size –DMA_8_BIT –DMA_16_BIT These Flags Configure the DMA Channel Control Registers prototype: int dmaOpenChannel( int *channel_ID, int channel_type, unsigned int option_flags, int ring_size, dmaReleaseType release_rtn)
9
option_flags: DMA_Operation Mode Peripheral FIFO Memory Peripheral FIFO Memory Default Setting “Fly-By” Memory DMA Memory DMA_MEM_TO_MEM DMA OR
10
option_flags : Burst Transfer Size BCLK TA* Default Setting DMA_8_BYTE_BURST DMA_16_BYTE_BURST 1 Long Word (4 Bytes) 2 Long Words (8 Bytes) 4 Long Words (16 Bytes)
11
option_flags : Channel Request Source Net+ARM DREQ* DACK* DONE* Peripheral DMA_EXTERNAL_REQ Net+ARM DREQ* DACK* DONE* Peripheral Default Setting Internal Fly-By peripheral* OR Mem-to-Mem under software control *Note: Internal Fly-By hardwired to ENI RX and ENI TX
12
option_flags : Address Increment Applies to Memory-to-Memory DMA only. Source Memory Destination Memory Source Range Destination Range DMA_DADDR_INC DMA_SRC_INCR Source Memory Destination Memory Destination Range DMA_DADDR_INC Default Setting Source Location *Note: It never makes sense to NOT increment the destination address DMA
13
option_flags : DMA Transaction Operand Size 8-bit Peripheral FIFO Memory 16-bit Peripheral FIFO Memory DMA_8_BIT DMA_16_BIT 32-bit Peripheral FIFO Memory Default Setting DMA
14
DMA Channel Ring Size prototype: int dmaOpenChannel( int *channel_ID, int channel_type, unsigned int option_flags, int ring_size, dmaReleaseType release_rtn) Ring Size = Number of Buffer Descriptors: Max 64 for Mem-to-Mem Max 128 for Fly-By
15
DMA Channel ring_size DMA Channel Buffer Descriptor Pointer System Memory Buffer Descriptor Ring Area (CONTIGUOUS) dmaOpenChannel() allocates BD ring area from heap, based on int ring_size.
16
Release Callback prototype: void (*dmaReleaseType) (int channel_ID, dmaMessageType *request_msg) Enabled dmaLoadChannel() The defined callback will be called when the dmaLoadChannel() request has completed, with input parameters channel_ID and *request_msg. prototype: int dmaOpenChannel( int *channel_ID, int channel_type, unsigned int option_flags, int ring_size, dmaReleaseType release_rtn)
17
Loading a Channel Loading a channel configures the previously allocated Buffer Descriptors. prototype: int dmaLoadChannel( int channel_ID, dmaMessageType request_msg) typedef struct dmaMessageStruct { struct dmaMessageStruct*next; void*src_addr; void*dst_addr; longlength; longstatus; longerror_value; longreserved[4]; } dmaMessageType;
18
Fly-By Read Loading Memory Destination Area Peripheral FIFO Set up enough dmaMessageType’s to accommodate all expected data. *next Address of next dmaMessageType if more than 32Kbytes needed. *src_addr Not Used *dst_addr Start of Destination (incrementing) length Up to 32Kbytes
19
Fly-By Write Loading Memory Source Data Area Peripheral FIFO Set up enough dmaMessageType’s to accommodate outgoing data. *next Address of next dmaMessageType if more than 32Kbytes needed. *src_addr Start of Data Buffer (incrementing) *dst_addr Not Used length Up to 32Kbytes
20
Memory to Memory Loading Memory Source Data Area Memory Set up enough dmaMessageType’s to accommodate outgoing data. *next Address of next dmaMessageType if more than 32Kbytes needed. *src_addr Start of Source Data Buffer (incrementing) *dst_addr Start of Destination Buffer (incrementing) length Up to 32Kbytes Destination
21
UnLoading a Channel UnLoading a channel is called to remove a processed request from the DMA’s queue when no release callback is supplied. prototype: int dmaUnloadChannel( int channel_ID, dmaMessageType *request_msg, int wait_time) DMA Channel Buffer Descriptor Pointer System Memory Buffer Descriptors Used Unused Used Unused Unload Note: Each request_msg uses one buffer descriptor.
22
Request Processing - no Release Callback dmaLoadChannel() DMA Channel Request Queue DMA ISR DMA Channel Release Queue* dmaUnloadChannel() * Not built when a release callback is provided fills emptied by fills emptied by
23
DMA API SUmmary Load the driver - dmaLoadDriver Open a channel - dmaOpenChannel –Set channel ID, type, options, buffer ring size, release callback Load the channel –Flyby – source or destination address –Memory to memory – both source and dest Unload the channel if no release callback supplied
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.