Specifications

DMA Transmit Channels
DMA transmit requests are queued using a DMA transmit device handle. To obtain a handle, use the
function alt_dma_txchan_open(). This function takes a single argument, the name of a device to use, as
defined in system.h.
Example 6–12. Obtaining a File Handle for a DMA Transmit Device dma_0
#include <stddef.h>
#include "sys/alt_dma.h"
int main (void)
{
alt_dma_txchan tx;
tx = alt_dma_txchan_open ("/dev/dma_0");
if (tx == NULL)
{
/* Error */
}
else
{
/* Success */
}
return 0;
}
You can use this handle to post a transmit request using alt_dma_txchan_send(). The prototype is:
typedef void (alt_txchan_done)(void* handle);
int alt_dma_txchan_send (alt_dma_txchan dma,
const void* from,
alt_u32 length,
alt_txchan_done* done,
void* handle);
Calling alt_dma_txchan_send() posts a transmit request to channel dma. Argument length specifies the
number of bytes of data to transmit, and argument from specifies the source address. The function returns
before the full DMA transaction completes. The return value indicates whether the request is successfully
queued. A negative return value indicates that the request failed. When the transaction completes, the
user-supplied function done is called with argument handle to provide notification.
Two additional functions are provided for manipulating DMA transmit channels:
alt_dma_txchan_space(), and alt_dma_txchan_ioctl(). The alt_dma_txchan_space() function
returns the number of additional transmit requests that can be queued to the device. The
alt_dma_txchan_ioctl()function performs device-specific manipulation of the transmit device.
Note:
If you are using the Avalon Memory-Mapped
®
(Avalon-MM
®
) DMA device to transmit to
hardware (not memory-to-memory transfer), call the alt_dma_txchan_ioctl()function with the
request argument set to ALT_DMA_TX_ONLY_ON.
For more information, refer to the HAL API Reference chapter of the Nios II Software Developer’s
Handbook.
Related Information
HAL API Reference on page 14-1
DMA Receive Channels
DMA receive channels operate similarly to DMA transmit channels. Software can obtain a handle for a
DMA receive channel using the alt_dma_rxchan_open() function. You can then use the
6-24
DMA Transmit Channels
NII5V2
2015.05.14
Altera Corporation
Developing Programs Using the Hardware Abstraction Layer
Send Feedback