More work on 611x support. Documentation updates.
authorDavid Schleef <ds@schleef.org>
Sun, 17 Mar 2002 22:01:42 +0000 (22:01 +0000)
committerDavid Schleef <ds@schleef.org>
Sun, 17 Mar 2002 22:01:42 +0000 (22:01 +0000)
comedi/drivers/ni_atmio.c
comedi/drivers/ni_mio_common.c
comedi/drivers/ni_mio_cs.c
comedi/drivers/ni_pcimio.c

index 0da2920eebf6b6df768fe83095c0c0df8cddfe20..f4146ab6a286e056680de0d3488c2684485cc306 100644 (file)
@@ -26,17 +26,13 @@ Author: ds
 Devices: [National Instruments] AT-MIO-16E-1 (ni_atmio),
   AT-MIO-16E-2, AT-MIO-16E-10, AT-MIO-16DE-10, AT-MIO-64E-3,
   AT-MIO-16XE-50, AT-MIO-16XE-10, AT-AI-16XE-10
+Status: works
+Updated: Sat, 16 Mar 2002 17:34:48 -0800
 
 The isapnptools package is required to use this board.  Use isapnp to
 configure the I/O base for the board, and then pass the same value as
 a parameter in comedi_config.  A sample isapnp.conf file is included
-in the etc/ directory.
-
-Assuming that the NI spec is correct, the driver should correctly
-identify every board in the series.  Each channel should have the
-appropriate parameters, i.e., input/output ranges, number of bits,
-etc.  If the driver fails to recognize your card or does not have
-the correct parameters, please contact me.
+in the etc/ directory of Comedilib.
 
 Comedilib includes a utility to autocalibrate these boards.  The
 boards seem to boot into a state where the all calibration DACs
@@ -45,6 +41,9 @@ is terrible.  Calibration at boot is strongly encouraged.
 
 External triggering is supported for some events.  The channel index
 (scan_begin_arg, etc.) maps to PFI0 - PFI9.
+
+Some of the more esoteric triggering possibilities of these boards
+are not supported.
 */
 /*
        The real guts of the driver is in ni_mio_common.c, which is included
@@ -246,6 +245,8 @@ static int ni_irqpin[]={-1,-1,-1,0,1,2,-1,3,-1,-1,4,5,6,-1,-1,7};
 
 /* How we access registers */
 
+#define ni_writel(a,b)         (outl((a),(b)+dev->iobase))
+#define ni_readl(a)            (inl((a)+dev->iobase))
 #define ni_writew(a,b)         (outw((a),(b)+dev->iobase))
 #define ni_readw(a)            (inw((a)+dev->iobase))
 #define ni_writeb(a,b)         (outb((a),(b)+dev->iobase))
index 60b1bbbbbf039e1ae68b7d223f01e81c8af5b0f6..5ea85611c1cc9cb951ca8ef6c017807cbb77d319 100644 (file)
@@ -711,10 +711,59 @@ static void ni_handle_fifo_dregs(comedi_device *dev)
        int i,n;
        int j;
        unsigned int mask;
+       unsigned int dl;
 
        mask=(1<<boardtype.adbits)-1;
        j=s->async->cur_chan;
        data=s->async->data+s->async->buf_int_ptr;
+       if(boardtype.reg_611x){
+       while(1){
+               n=(s->async->data_len-s->async->buf_int_ptr)/sizeof(sampl_t);
+               for(i=0;i<n;i++){
+                       if(win_in(AI_Status_1_Register)&AI_FIFO_Empty_St){
+                               /* Check if there's a single sample stuck in the FIFO */
+                               if(ni_readb(Status_611x)&0x80){
+                                       dl=ni_readl(ADC_FIFO_Data_611x);
+                                       *data = (dl&0xffff) + devpriv->ai_xorlist[j];
+                                       j++;
+                                       if(j>=s->async->cmd.chanlist_len){
+                                               j=0;
+                                       }
+                                       data++;
+                                       s->async->buf_int_ptr+=sizeof(sampl_t);
+                                       s->async->buf_int_count+=sizeof(sampl_t);
+                               }
+                               s->async->cur_chan=j;
+                               return;
+                       }
+                       dl=ni_readl(ADC_FIFO_Data_611x);
+
+                       /* This may get the hi/lo data in the wrong order */
+                       *data = (dl>>16) + devpriv->ai_xorlist[j];
+                       j++;
+                       if(j>=s->async->cmd.chanlist_len){
+                               j=0;
+                               //s->events |= COMEDI_CB_EOS;
+                       }
+                       data++;
+                       s->async->buf_int_ptr+=sizeof(sampl_t);
+                       s->async->buf_int_count+=sizeof(sampl_t);
+
+                       *data = (dl&0xffff) + devpriv->ai_xorlist[j];
+                       j++;
+                       if(j>=s->async->cmd.chanlist_len){
+                               j=0;
+                               //s->events |= COMEDI_CB_EOS;
+                       }
+                       data++;
+                       s->async->buf_int_ptr+=sizeof(sampl_t);
+                       s->async->buf_int_count+=sizeof(sampl_t);
+               }
+               s->async->buf_int_ptr=0;
+               data=s->async->data;
+               s->async->events |= COMEDI_CB_EOBUF;
+       }
+       }else{
        while(1){
                n=(s->async->data_len-s->async->buf_int_ptr)/sizeof(sampl_t);
                for(i=0;i<n;i++){
@@ -738,6 +787,7 @@ static void ni_handle_fifo_dregs(comedi_device *dev)
                data=s->async->data;
                s->async->events |= COMEDI_CB_EOBUF;
        }
+       }
 }
 
 #ifdef PCIDMA
@@ -787,10 +837,6 @@ static void ni_ai_setup_MITE_dma(comedi_device *dev,comedi_cmd *cmd)
        mite->dir = COMEDI_INPUT;
        mite_prep_dma(mite);
 
-       /*tell the STC to use DMA0 for AI.
-       Select the MITE DMA channel to use, 0x01=A*/
-       ni_writeb(0x01,AI_AO_Select);
-
        /*start the MITE*/
        mite_dma_arm(mite);
 }
@@ -892,17 +938,29 @@ static int ni_ai_insn_read(comedi_device *dev,comedi_subdevice *s,comedi_insn *i
        signbits=devpriv->ai_xorlist[0];
        for(n=0;n<insn->n;n++){
                win_out(1,AI_Command_1_Register);
-               for(i=0;i<NI_TIMEOUT;i++){
-                       if(!(win_in(AI_Status_1_Register)&AI_FIFO_Empty_St))
-                               break;
+               if(boardtype.reg_611x){
+                       /* The 611x has screwy 32-bit FIFOs. */
+                       for(i=0;i<NI_TIMEOUT;i++){
+                               if(ni_readb(Status_611x)&0x80)
+                                       break;
+                       }
+               }else{
+                       for(i=0;i<NI_TIMEOUT;i++){
+                               if(!(win_in(AI_Status_1_Register)&AI_FIFO_Empty_St))
+                                       break;
+                       }
                }
                if(i==NI_TIMEOUT){
                        rt_printk("ni_E: timeout 2\n");
                        win_restore(wsave);
                        return -ETIME;
                }
-               d = ni_readw(ADC_FIFO_Data_Register)+signbits;
-               data[n] = d;
+               if(boardtype.reg_611x){
+                       d = ni_readl(ADC_FIFO_Data_611x)&0xffff;
+               }else{
+                       d = ni_readw(ADC_FIFO_Data_Register);
+               }
+               data[n] = d + signbits;
        }
        win_restore(wsave);
        return insn->n;
@@ -2141,6 +2199,11 @@ static int ni_E_init(comedi_device *dev,comedi_devconfig *it)
                 );
         }
 
+       /* DMA setup */
+       /* tell the STC to use DMA0 for AI, DMA1 for AO */
+       ni_writeb(0x21,AI_AO_Select);
+
+       /* PFI setup */
        pfi_setup(dev);
 
        printk("\n");
index 7ebd2fd9a2f0452ad173340fe93e25e5a139c8b6..6fe943fd64e38434a35e6462be0efe5a0f0a730a 100644 (file)
@@ -158,6 +158,8 @@ static ni_board ni_boards[]={
 
 /* How we access registers */
 
+#define ni_writel(a,b)         (outl((a),(b)+dev->iobase))
+#define ni_readl(a)            (inl((a)+dev->iobase))
 #define ni_writew(a,b)         (outw((a),(b)+dev->iobase))
 #define ni_readw(a)            (inw((a)+dev->iobase))
 #define ni_writeb(a,b)         (outb((a),(b)+dev->iobase))
index 210634192f0c156052ec59f00c16b813d71d5896..07db3c84432c4f53d7dfc8cd695812b202146d9f 100644 (file)
 Driver: ni_pcimio.o
 Description: National Instruments PCI-MIO-E series (all boards)
 Author: ds
-Status: mainly limited by Comedi infrastructure
+Status: works
 Devices: [National Instruments] PCI-MIO-16XE-50 (ni_pcimio),
   PCI-MIO-16XE-10, PXI-6030E, PCI-MIO-16E-1, PCI-MIO-16E-4, PCI-6040E,
   PXI-6040E, PCI-6031E, PCI-6032E, PCI-6033E, PCI-6071E, PCI-6023E,
   PCI-6024E, PCI-6025E, PXI-6025E, PCI-6034E, PCI-6035E, PCI-6052E,
   PCI-6110E, PCI-6111E, PCI-6711, PCI-6713, PXI-6071E, PXI-6070E,
   PXI-6052E, PCI-6036E, PCI-6731, PCI-6733
+Updated: Sat, 16 Mar 2002 17:34:48 -0800
 
 These boards are almost identical to the AT-MIO E series, except that
-they use the PCI bus instead of ISA (i.e., AT).  See the notes above for
-ni_atmio.o for additional information about these boards.
+they use the PCI bus instead of ISA (i.e., AT).  See the notes for
+the ni_atmio.o driver for additional information about these boards.
 
 Autocalibration is supported on many of the devices, using the
 calibration utility in Comedilib.
@@ -49,10 +50,13 @@ PCI IDs are not known for PCI-6731 and PCI-6733.  Digital I/O may not
 work on 673x.
 
 Information (number of channels, bits, etc.) for some devices may be
-incorrect.
+incorrect.  Please check this and submit a bug if there are problems
+for your device.
 
 Bugs:
- - Driver doesn't stop correctly when DMA is enabled.
+ - When DMA is enabled, COMEDI_EV_SCAN_END and COMEDI_EV_CONVERT do
+   not work correctly.
+ - There are reported problems with the 61xx and 67xx boards.
 
 */
 /*
@@ -584,6 +588,8 @@ COMEDI_INITCLEANUP(driver_pcimio);
 
 /* How we access registers */
 
+#define ni_writel(a,b)         (writel((a),dev->iobase+(b)))
+#define ni_readl(a)            (readl(dev->iobase+(a)))
 #define ni_writew(a,b)         (writew((a),dev->iobase+(b)))
 #define ni_readw(a)            (readw(dev->iobase+(a)))
 #define ni_writeb(a,b)         (writeb((a),dev->iobase+(b)))