NAME

dmada - direct memory access digital-to-analog conversion (DMA D/A)

SYNOPSIS

#include <dmada_p.h>
#include <stdio_p.h>
#include <signal_p.h>

FD dopen (path) ,br char *path;

int dclose (fildes)
FD fildes;

int dwrite (fildes, dval)
FD fildes;

int dwrite (fildes, dval)
FD fildes;
unsigned dval;

dda_start (fidles)
FD fildes;

dda_done (fildes)
FD fildes;

extern int ddafull;

DESCRIPTION

This interface controls the Data Translation DT2771, a high speed, 2 channel, 12-bit digital to analog converter with DMA capabilities.

dopen initializes the DMA D/A by clearing the device registers: control/status, data buffer, DMA word count, and DMA address. It also returns a file descriptor to be used to control, read, and close the device. path points to a string "/dev/dda X " X being a number between 1 and n where n is the number of DMA D/A devices configured in the system.

dclose clears the device registers and returns 0.

dwrite outputs a single value dval. The output channel is specified by the most significant bit (bit 15) of the value. If clear, the first channel is used, if set, the second channel is used.

dioctl sets and inspects values in the device registers. It is primarily used to set up control for converting values under DMA control. When the argument cmd is SETP, then the values specified in the structure da_ctl pointed to by the argument arg are used to control the device. When the argument cmd is GETP, then the current values of the device registers are returned in the structure. This structure is defined in dmada_p.h:

struct da_ctl{
  unsigned  da_flags;
  int       da_nsamp;
  unsigned  *da_bufa;
  unsigned  *da_bufb;
};
The da_flags fields contain bits correspoinding to the control/status register. The symbolic values that are defined in dmada_p.h are:
DDA_DONE	0000200		done flag (R)
DAD_IENABLE	0000100		enable interrupt on done (R/W)
DAD_ERR		0000220		error flag (R)
DAD_SINGLE	0000004		single channel DMA (R/W)
DAD_DMMA	0000002		DMA  enable (R/W)
The done flag is set at the end of a DMA operation, or a single write operation. The enable flag, when set, causes a hardware interrupt to be generated whenever the done bit is set.

The error flag is set whenever non-existent memory is addressed during a DMA operation.

The single channel flag, when set, causes the device to use single channel mode when performing under DMA control. This means that values are output to the channel indicated by bit 15 of each output word. When this flag is clear, the device operates in point plot mode. Bit 15 is ignored and values are alternately sent to the first channel and the second channel.

The da_nsamp field specifies the number of values to output in single channel mode or the number of pairs to output in point plot mode.

The da_bufa field specifies the starting address of the data buffer. For double buffering operations, da_bufb specifies the starting address of a second buffer.

dda_start is a macro for starting a DMA operation and is invoked after setting up the device with dioctl.

dda_done is a macro for checking the status of a DMA operation. A non-zero value is returned when the operation is complete.

If the done interrupt is enabled, the device will interrupt at the end of an operation and will send the software signal SIGDDA along with the file descriptor and the address of the buffer just output. The user may choose to ignore the signal or may provide a signal routine to catch it to do some special processing. In either case, signal must be called after calling dioctl but before calling dda_start.

The external variable ddafull, declared in dmada_p.h is provided for synchronizing double buffering. Each time the user program fills a buffer it must increment ddafull by one; each time the DMA A/D finishes outputting a buffer of samples, it decrements the variable.

FILES

/dev/ddaX path name for DMA D/A device X.

SEE ALSO

dmada(3U) , signal(2F) , dmaad(4F) , Engineering Specification for DT2771.

DIAGNOSTICS

If dopen is invoked with a path name not defined by the configuration, it returns -1. If invoked with illegal file descriptors, dclose, dwrite, and dioctl return -1. If given illegal control parameters, dioctl returns -1.