Nios® II Software Developer Handbook

ID 683525
Date 8/28/2023
Public
Document Table of Contents

8.7.5.2. DMA Receive Channel

Example 7–3. alt_dma_rxchan Structure

typedef alt_dma_rxchan_dev_s alt_dma_rxchan;
struct alt_dma_rxchan_dev_s
{
alt_llist list;
const char* name;
alt_u32 depth;
int (*prepare) (alt_dma_rxchan dma,
void* data,
alt_u32 len,
alt_rxchan_done* done,
void* handle);
int (*ioctl) (alt_dma_rxchan dma, int req, void* arg);
};

The prepare() function must be defined. If the ioctl field is set to null, calls to alt_dma_rxchan_ioctl() return -ENOTTY for this device.

After creating an instance of the alt_dma_rxchan structure, you must register the device driver with the HAL system to make it available by calling the following function:

int alt_dma_rxchan_reg (alt_dma_rxchan_dev* dev)

The input argument dev is the device to register. The return value is zero on success, or negative if the device cannot be registered.

Table 38.  Fields in the alt_dma_rxchan Structure
Field Function
llist This function is for internal use and must always be set to the value ALT_LLIST_ENTRY.
name The name that refers to this channel in calls to alt_dma_rxchan_open(). name is the name of the device as defined in system.h.
depth The total number of receive requests that can be outstanding at any given time.
prepare A pointer to a function that is called as a result of a call to the application API function alt_dma_rxchan_prepare(). This function posts a receive request to the DMA device. The parameters passed to alt_dma_rxchan_prepare() are passed directly to prepare(). For a description of parameters and return values, refer to the "HAL API Reference" section.
ioctl This is a function that provides device specific I/O control. Refer to sys/alt_dma_dev.h for a list of the generic options that a device might wish to support.