
PCI CD and PCI CDa
Document Number: 008-00965-06 EDT Public Revision: I December 2004
Template: edt.dot
Page 13
EdtDev *edt_p = edt_open_channel("pcd", 1, 2) ;
char buf[1024] ;
int numbytes, outfd = open("outfile", 1) ;
/*
* Because read()s are noncontinuous, unless is there hardware
* handshaking there will be gaps in the data between each read().
*/
while ((numbytes = edt_read(edt_p, buf, 1024)) > 0)
write(outfd, buf, numbytes) ;
edt_close(edt_p) ;
}
You can use ring buffer mode for real-time data capture using a small number of buffers (usually four
of 1 MB) configured in a round-robin data FIFO. During capture, the application must be able to
transfer or process the data before data acquisition wraps around and overwrites the buffer currently
being processed.
The example below shows real-time data capture using ring buffers, although it includes no error
checking. In this example, process_data(bufptr) must execute in the same amount of time it
takes DMA to fill a single buffer or faster.
#include "edtinc.h"
main()
{
EdtDev *edt_p = edt_open("pcd", 0) ;
/* Configure four 1 MB buffers:
* one for DMA
* one for the second DMA register on most EDT boards
* one for "process_data(bufptr)" to work on
* one to keep DMA away from "process_data()"
*/
edt_configure_ring_buffers(edt_p, 1*1024*1024, 4, EDT_READ, NULL) ;
edt_start_buffers(edt_p, 4) ; /* start 4 buffers */
for (;;)
{
char *bufptr ;
/* Wait for each buffer to complete, then process it.
* The driver continues DMA concurrently with processing.
*/
bufptr = edt_wait_for_buffers(edt_p, 1) ;
process_data(bufptr) ;
edt_start_buffers(edt_p, 1) ;
}
}
Check compiler options in the EDT-provided make files.
Comentarios a estos manuales