MITE DMA data is now unsigned short instead of twos complement. Also fixed
authorTim Ousley <tim.ousley@ni.com>
Fri, 18 May 2001 19:25:15 +0000 (19:25 +0000)
committerTim Ousley <tim.ousley@ni.com>
Fri, 18 May 2001 19:25:15 +0000 (19:25 +0000)
bug where the ISR would try to poll the STC fifo instead of letting the MITE
retrieve the data.

comedi/drivers/mite.c
comedi/drivers/ni_mio_common.c

index cd1b498d3f25bfb34124cdd4d4f341f1f0d3c73b..2173b55059c746cdab970859c1c89aceeecb6e95 100644 (file)
@@ -469,11 +469,11 @@ void mite_setregs(struct mite_struct *mite,unsigned long ll_start,int chan,int d
 
 int mite_bytes_transferred(struct mite_struct *mite, int chan)
 {
-       int bytes;
+       int DAR, FCR;
        
-       bytes = readl(mite->mite_io_addr+MITE_DAR+CHAN_OFFSET(chan));
-       bytes -= readl(mite->mite_io_addr+MITE_FCR+CHAN_OFFSET(chan)) & 0x000000FF;
-       return bytes;
+       DAR = readl(mite->mite_io_addr+MITE_DAR+CHAN_OFFSET(chan));
+       FCR = readl(mite->mite_io_addr+MITE_FCR+CHAN_OFFSET(chan)) & 0x000000FF;
+       return DAR-FCR;
 }
 
 int mite_dma_tcr(struct mite_struct *mite)
index c5966f71ad4d597abbe02b981b362e9a3ce7ad7a..84570d74d7f2d3f7a4c9f6cf0db3db9597a2010d 100644 (file)
@@ -232,6 +232,7 @@ static void handle_b_interrupt(comedi_device *dev,unsigned short status);
 /*status must be long because the CHSR is 32 bits and the high bits
 are important to us */
 static void mite_handle_interrupt(comedi_device *dev,unsigned long status);
+void ni_munge(comedi_device *dev,comedi_subdevice *s,sampl_t *start, sampl_t *stop);
 #endif
 
 /* ni_set_bits( ) allows different parts of the ni_mio_common driver to 
@@ -330,15 +331,30 @@ static void mite_handle_interrupt(comedi_device *dev,unsigned long m_status)
        comedi_event(dev,s,COMEDI_CB_BLOCK);
 
        MDPRINTK("mite_handle_interrupt\n");
-       MDPRINTK("MITE generated an int!!\n");
        writel(CHOR_CLRLC, devpriv->mite->mite_io_addr+MITE_CHOR+CHAN_OFFSET(0));
+#if 0
+       //Don't munge the data, just update the user's status variables
        s->async->buf_int_count=mite_bytes_transferred(devpriv->mite, 0);
        s->async->buf_int_ptr= s->async->buf_int_count % s->async->prealloc_bufsz;     
+#else
+       //Munge the ADC data to change its format from twos complement to unsigned int
+       //This is slow but makes it more compatible with other cards
+       { 
+       unsigned int raw_ptr;
+       s->async->buf_int_count = mite_bytes_transferred(devpriv->mite, 0);
+       raw_ptr = s->async->buf_int_count % s->async->prealloc_bufsz;
+       if(s->async->buf_int_ptr > raw_ptr) {
+               ni_munge(dev,s,s->async->buf_int_ptr+s->async->prealloc_buf, 
+                       s->async->prealloc_buf+s->async->prealloc_bufsz);
+               s->async->buf_int_ptr = 0;
+       }
+       ni_munge(dev,s,s->async->buf_int_ptr+s->async->prealloc_buf, 
+               raw_ptr+s->async->prealloc_buf);
+       s->async->buf_int_ptr = raw_ptr;
+       }
+#endif
        MDPRINTK("CHSR is 0x%08lx, count is %d\n",m_status,s->async->buf_int_count);
        if(m_status&CHSR_DONE){
-#ifdef DEBUG_MITE
-               mite_dump_regs(devpriv->mite);
-#endif  
                writel(CHOR_CLRDONE, devpriv->mite->mite_io_addr+MITE_CHOR+CHAN_OFFSET(0));
                //printk("buf_int_count is %d, buf_int_ptr is %d\n",
                //              s->async->buf_int_count,s->async->buf_int_ptr);
@@ -346,8 +362,9 @@ static void mite_handle_interrupt(comedi_device *dev,unsigned long m_status)
        }       
        MDPRINTK("exit mite_handle_interrupt\n");
        return; 
-}       
-#endif
+}      
+
+#endif //PCIDMA
 
 static void handle_a_interrupt(comedi_device *dev,unsigned short status)
 {
@@ -420,9 +437,11 @@ static void handle_a_interrupt(comedi_device *dev,unsigned short status)
                        ack|=AI_START1_Interrupt_Ack;
                }
        }
+#ifndef PCIDMA
        if(status&AI_FIFO_Half_Full_St){
                ni_handle_fifo_half_full(dev);
        }
+#endif //PCIDMA
        if(devpriv->aimode==AIMODE_SCAN && status&AI_STOP_St){
                ni_handle_fifo_dregs(dev);
 
@@ -538,6 +557,24 @@ static void ni_ai_fifo_read(comedi_device *dev,comedi_subdevice *s,
 }
 
 #ifdef PCIDMA
+void ni_munge(comedi_device *dev,comedi_subdevice *s,sampl_t *start, sampl_t *stop)
+{
+       comedi_async *async = s->async;
+       int j;
+       sampl_t *i;
+       unsigned int mask;
+
+       mask=(1<<boardtype.adbits)-1;
+       j=async->cur_chan;
+       for(i=start;i<stop;i++){
+               *i ^=devpriv->ai_xorlist[j];
+               *i &=mask;
+               j++;
+               j %= async->cur_chanlist_len;
+       }
+       async->cur_chan=j;
+}
+
 static void ni_handle_block_dma(comedi_device *dev)
 {
        MDPRINTK("ni_handle_block_dma\n");