From: Frank Mori Hess Date: Tue, 21 Oct 2008 20:43:45 +0000 (+0000) Subject: Clairified meanings of fifo status bits, and added FIXME comment. X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=32b103ba022b5d17c6eec10e42c759451680434b;p=comedi.git Clairified meanings of fifo status bits, and added FIXME comment. --- diff --git a/comedi/drivers/rtd520.c b/comedi/drivers/rtd520.c index 3a90a214..20d6128c 100644 --- a/comedi/drivers/rtd520.c +++ b/comedi/drivers/rtd520.c @@ -99,6 +99,13 @@ Configuration options: Digital-IO and Analog-Out only support instruction mode. +FIXME: This driver needs to be fixed to probe the fifo lengths, instead of +relying on the user to pass the appropriate board_name to comedi config. +Then the driver can simply accept the driver name as the board type +and figure out the rest on its own. The fifo sizes can be probed by +clearing the fifo, then doing software-driven conversions one at a time +until the fifo-half-empty status flag clears. + */ #include @@ -1253,7 +1260,7 @@ static int rtd_ai_rinsn(comedi_device * dev, for (ii = 0; ii < RTD_ADC_TIMEOUT; ++ii) { stat = RtdFifoStatus(dev); - if (stat & FS_ADC_EMPTY) /* 1 -> not empty */ + if (stat & FS_ADC_NOT_EMPTY) /* 1 -> not empty */ break; WAIT_QUIETLY; } @@ -1296,7 +1303,7 @@ static int ai_read_n(comedi_device * dev, comedi_subdevice * s, int count) continue; } #if 0 - if (0 == (RtdFifoStatus(dev) & FS_ADC_EMPTY)) { /* DEBUG */ + if (0 == (RtdFifoStatus(dev) & FS_ADC_NOT_EMPTY)) { /* DEBUG */ DPRINTK("comedi: READ OOPS on %d of %d\n", ii + 1, count); break; @@ -1324,7 +1331,7 @@ static int ai_read_n(comedi_device * dev, comedi_subdevice * s, int count) */ static int ai_read_dregs(comedi_device * dev, comedi_subdevice * s) { - while (RtdFifoStatus(dev) & FS_ADC_EMPTY) { /* 1 -> not empty */ + while (RtdFifoStatus(dev) & FS_ADC_NOT_EMPTY) { /* 1 -> not empty */ sampl_t sample; s16 d = RtdAdcFifoGet(dev); /* get 2s comp value */ @@ -1486,7 +1493,7 @@ static irqreturn_t rtd_interrupt(int irq, /* interrupt number (ignored) */ fifoStatus = RtdFifoStatus(dev); /* check for FIFO full, this automatically halts the ADC! */ - if (!(fifoStatus & FS_ADC_FULL)) { /* 0 -> full */ + if (!(fifoStatus & FS_ADC_NOT_FULL)) { /* 0 -> full */ DPRINTK("rtd520: FIFO full! fifo_status=0x%x\n", (fifoStatus ^ 0x6666) & 0x7777); /* should be all 0s */ goto abortTransfer; } @@ -1547,7 +1554,7 @@ static irqreturn_t rtd_interrupt(int irq, /* interrupt number (ignored) */ } else if (devpriv->transCount > 0) { /* read often */ /*DPRINTK("rtd520: Sample int, reading %d fifo_status 0x%x\n", devpriv->transCount, (fifoStatus ^ 0x6666) & 0x7777); */ - if (fifoStatus & FS_ADC_EMPTY) { /* 1 -> not empty */ + if (fifoStatus & FS_ADC_NOT_EMPTY) { /* 1 -> not empty */ if (ai_read_n(dev, s, devpriv->transCount) < 0) { DPRINTK("rtd520: comedi read buffer overflow (N) with %ld to go!\n", devpriv->aiCount); goto abortTransfer; @@ -2149,8 +2156,8 @@ static int rtd_ao_winsn(comedi_device * dev, for (ii = 0; ii < RTD_DAC_TIMEOUT; ++ii) { stat = RtdFifoStatus(dev); /* 1 -> not empty */ - if (stat & ((0 == chan) ? FS_DAC1_EMPTY : - FS_DAC2_EMPTY)) + if (stat & ((0 == chan) ? FS_DAC1_NOT_EMPTY : + FS_DAC2_NOT_EMPTY)) break; WAIT_QUIETLY; } diff --git a/comedi/drivers/rtd520.h b/comedi/drivers/rtd520.h index 78c90a26..0eb50b8e 100644 --- a/comedi/drivers/rtd520.h +++ b/comedi/drivers/rtd520.h @@ -1,7 +1,7 @@ /* comedi/drivers/rtd520.h Comedi driver defines for Real Time Devices (RTD) PCI4520/DM7520 - + COMEDI - Linux Control and Measurement Device Interface Copyright (C) 2001 David A. Schleef @@ -27,7 +27,7 @@ /* LAS0 Runtime Area - Local Address Space 0 Offset Read Function Write Function + Local Address Space 0 Offset Read Function Write Function */ #define LAS0_SPARE_00 0x0000 // - - #define LAS0_SPARE_04 0x0004 // - - @@ -47,7 +47,7 @@ #define LAS0_SPARE_3C 0x003C // - - /* - LAS0 Runtime Area Timer/Counter,Dig.IO + LAS0 Runtime Area Timer/Counter,Dig.IO Name Local Address Function */ #define LAS0_PCLK 0x0040 // Pacer Clock value (24bit) Pacer Clock load (24bit) @@ -156,18 +156,18 @@ ======================================================================*/ // FIFO Status Word Bits (RtdFifoStatus) -#define FS_DAC1_EMPTY 0x0001 // D0 - DAC1 FIFO not empty -#define FS_DAC1_HEMPTY 0x0002 // D1 - DAC1 FIFO not half empty -#define FS_DAC1_FULL 0x0004 // D2 - DAC1 FIFO not full -#define FS_DAC2_EMPTY 0x0010 // D4 - DAC2 FIFO not empty -#define FS_DAC2_HEMPTY 0x0020 // D5 - DAC2 FIFO not half empty -#define FS_DAC2_FULL 0x0040 // D6 - DAC2 FIFO not full -#define FS_ADC_EMPTY 0x0100 // D8 - ADC FIFO not empty -#define FS_ADC_HEMPTY 0x0200 // D9 - ADC FIFO not half empty -#define FS_ADC_FULL 0x0400 // D10 - ADC FIFO not full -#define FS_DIN_EMPTY 0x1000 // D12 - DIN FIFO not empty -#define FS_DIN_HEMPTY 0x2000 // D13 - DIN FIFO not half empty -#define FS_DIN_FULL 0x4000 // D14 - DIN FIFO not full +#define FS_DAC1_NOT_EMPTY 0x0001 // D0 - DAC1 FIFO not empty +#define FS_DAC1_HEMPTY 0x0002 // D1 - DAC1 FIFO half empty +#define FS_DAC1_NOT_FULL 0x0004 // D2 - DAC1 FIFO not full +#define FS_DAC2_NOT_EMPTY 0x0010 // D4 - DAC2 FIFO not empty +#define FS_DAC2_HEMPTY 0x0020 // D5 - DAC2 FIFO half empty +#define FS_DAC2_NOT_FULL 0x0040 // D6 - DAC2 FIFO not full +#define FS_ADC_NOT_EMPTY 0x0100 // D8 - ADC FIFO not empty +#define FS_ADC_HEMPTY 0x0200 // D9 - ADC FIFO half empty +#define FS_ADC_NOT_FULL 0x0400 // D10 - ADC FIFO not full +#define FS_DIN_NOT_EMPTY 0x1000 // D12 - DIN FIFO not empty +#define FS_DIN_HEMPTY 0x2000 // D13 - DIN FIFO half empty +#define FS_DIN_NOT_FULL 0x4000 // D14 - DIN FIFO not full // Timer Status Word Bits (GetTimerStatus) #define TS_PCLK_GATE 0x0001