added rx fifo overrun detection
authorFrank Mori Hess <fmhess@speakeasy.net>
Thu, 20 Feb 2003 00:31:16 +0000 (00:31 +0000)
committerFrank Mori Hess <fmhess@speakeasy.net>
Thu, 20 Feb 2003 00:31:16 +0000 (00:31 +0000)
comedi/drivers/gsc_hpdi.c

index 4c91799fecebe232c20f1248a9ca5387de47a99e..e2d32080b746fbeac3fceb23c3bd2c6027311f5b 100644 (file)
@@ -180,9 +180,9 @@ enum board_status_bits
        RX_NOT_FULL_BIT = 0x8000,
        BOARD_JUMPER0_INSTALLED_BIT = 0x10000,
        BOARD_JUMPER1_INSTALLED_BIT = 0x20000,
-       TX_OVERRUN_BIT = 0x2000000,
-       RX_UNDERRUN_BIT = 0x4000000,
-       RX_OVERRUN_BIT = 0x8000000,
+       TX_OVERRUN_BIT = 0x200000,
+       RX_UNDERRUN_BIT = 0x400000,
+       RX_OVERRUN_BIT = 0x800000,
 };
 
 uint32_t almost_full_bits( unsigned int num_words )
@@ -831,10 +831,12 @@ static int di_cmd(comedi_device *dev,comedi_subdevice *s)
        else
                priv(dev)->dio_count = 1;
 
-       writel( 0, priv(dev)->hpdi_iobase + INTERRUPT_CONTROL_REG );    
+       // clear over/under run status flags
+       writel( RX_UNDERRUN_BIT | RX_OVERRUN_BIT, priv(dev)->hpdi_iobase + BOARD_STATUS_REG );
+       // enable interrupts
+       writel( intr_bit( RX_FULL_INTR ), priv(dev)->hpdi_iobase + INTERRUPT_CONTROL_REG );
 
        DEBUG_PRINT( "hpdi: starting rx\n");
-
        hpdi_writel( dev, RX_ENABLE_BIT, BOARD_CONTROL_REG );
 
        return 0;
@@ -950,6 +952,18 @@ static void handle_interrupt(int irq, void *d, struct pt_regs *regs)
                DEBUG_PRINT(" cleared local doorbell bits 0x%x\n", plx_bits);
        }
 
+       if( hpdi_board_status & RX_OVERRUN_BIT )
+       {
+               comedi_error(dev, "rx fifo overrun");
+               async->events |= COMEDI_CB_EOA | COMEDI_CB_ERROR;
+       }
+
+       if( hpdi_board_status & RX_UNDERRUN_BIT )
+       {
+               comedi_error(dev, "rx fifo underrun");
+               async->events |= COMEDI_CB_EOA | COMEDI_CB_ERROR;
+       }
+
        if( priv(dev)->dio_count == 0 )
                async->events |= COMEDI_CB_EOA;