Check in update from ADDI. Seems to compile.
authorDavid Schleef <ds@schleef.org>
Thu, 6 Oct 2005 17:20:59 +0000 (17:20 +0000)
committerDavid Schleef <ds@schleef.org>
Thu, 6 Oct 2005 17:20:59 +0000 (17:20 +0000)
52 files changed:
comedi/drivers/addi-data/APCI1710_82x54.c
comedi/drivers/addi-data/APCI1710_82x54.h
comedi/drivers/addi-data/APCI1710_Chrono.c
comedi/drivers/addi-data/APCI1710_Chrono.h
comedi/drivers/addi-data/APCI1710_Dig_io.c
comedi/drivers/addi-data/APCI1710_Dig_io.h
comedi/drivers/addi-data/APCI1710_INCCPT.c
comedi/drivers/addi-data/APCI1710_INCCPT.h
comedi/drivers/addi-data/APCI1710_Inp_cpt.c
comedi/drivers/addi-data/APCI1710_Inp_cpt.h
comedi/drivers/addi-data/APCI1710_Pwm.c
comedi/drivers/addi-data/APCI1710_Pwm.h
comedi/drivers/addi-data/APCI1710_Ssi.c
comedi/drivers/addi-data/APCI1710_Ssi.h
comedi/drivers/addi-data/APCI1710_Tor.c
comedi/drivers/addi-data/APCI1710_Tor.h
comedi/drivers/addi-data/APCI1710_Ttl.c
comedi/drivers/addi-data/APCI1710_Ttl.h
comedi/drivers/addi-data/addi_amcc_S5920.c [new file with mode: 0755]
comedi/drivers/addi-data/addi_amcc_S5920.h [new file with mode: 0755]
comedi/drivers/addi-data/addi_amcc_s5933.h
comedi/drivers/addi-data/addi_common.c
comedi/drivers/addi-data/addi_common.h
comedi/drivers/addi-data/addi_eeprom.c
comedi/drivers/addi-data/hwdrv_APCI1710.c
comedi/drivers/addi-data/hwdrv_APCI1710.h
comedi/drivers/addi-data/hwdrv_apci035.c
comedi/drivers/addi-data/hwdrv_apci035.h
comedi/drivers/addi-data/hwdrv_apci1032.c
comedi/drivers/addi-data/hwdrv_apci1032.h
comedi/drivers/addi-data/hwdrv_apci1500.c
comedi/drivers/addi-data/hwdrv_apci1500.h
comedi/drivers/addi-data/hwdrv_apci1516.c
comedi/drivers/addi-data/hwdrv_apci1516.h
comedi/drivers/addi-data/hwdrv_apci1564.c
comedi/drivers/addi-data/hwdrv_apci1564.h
comedi/drivers/addi-data/hwdrv_apci16xx.c [new file with mode: 0755]
comedi/drivers/addi-data/hwdrv_apci16xx.h [new file with mode: 0755]
comedi/drivers/addi-data/hwdrv_apci2016.c
comedi/drivers/addi-data/hwdrv_apci2016.h
comedi/drivers/addi-data/hwdrv_apci2032.c
comedi/drivers/addi-data/hwdrv_apci2032.h
comedi/drivers/addi-data/hwdrv_apci2200.c
comedi/drivers/addi-data/hwdrv_apci2200.h
comedi/drivers/addi-data/hwdrv_apci3120.c
comedi/drivers/addi-data/hwdrv_apci3120.h
comedi/drivers/addi-data/hwdrv_apci3200.c
comedi/drivers/addi-data/hwdrv_apci3200.h
comedi/drivers/addi-data/hwdrv_apci3501.c
comedi/drivers/addi-data/hwdrv_apci3501.h
comedi/drivers/addi-data/hwdrv_apci3xxx.c [new file with mode: 0755]
comedi/drivers/addi-data/hwdrv_apci3xxx.h [new file with mode: 0755]

index 6cbe9eff40a1bb6a05bd4bf2cb1835e05063c944..bf0137833e055df0dbbd0a82af6ed9c3d76667a6 100644 (file)
-/*\r
-  +-----------------------------------------------------------------------+\r
-  | (C) ADDI-DATA GmbH          Dieselstraße 3       D-77833 Ottersweier  |\r
-  +-----------------------------------------------------------------------+\r
-  | Tel : +49 (0) 7223/9493-0     | email    : info@addi-data.com         |\r
-  | Fax : +49 (0) 7223/9493-92    | Internet : http://www.addi-data.com   |\r
-  +-----------------------------------------------------------------------+\r
-  | Project   : API APCI1710      |     Compiler   : BORLANDC/MICROSOFT C |\r
-  | Module name : 82X54.C         |     Version    : 3.1     / 6.0        |\r
-  +-------------------------------+---------------------------------------+\r
-  | Author    : S.WEBER           |     Date       : 29.06.98             |\r
-  +-----------------------------------------------------------------------+\r
-  | Description :   APCI-1710 82X54 timer module                          |\r
-  |                                                                       |\r
-  |                                                                       |\r
-  +-----------------------------------------------------------------------+\r
-  |                             UPDATES                                   |\r
-  +-----------------------------------------------------------------------+\r
-  |   Date   |   Author  |          Description of updates                |\r
-  +----------+-----------+------------------------------------------------+\r
-  | 29/06/98 | S. Weber  | Digital input / output implementation          |\r
-  |----------|-----------|------------------------------------------------|\r
-  | 08/05/00 | Guinot C  | - 0400/0228 All Function in RING 0             |\r
-  |          |           |   available                                    |\r
-  +-----------------------------------------------------------------------+\r
-  |          |           |                                                |\r
-  |          |           |                                                |\r
-  +-----------------------------------------------------------------------+\r
-*/\r
-\r
-/*\r
-+----------------------------------------------------------------------------+\r
-|                               Included files                               |\r
-+----------------------------------------------------------------------------+\r
-*/\r
-\r
-\r
-#include "APCI1710_82x54.h"\r
-\r
-/*\r
-+----------------------------------------------------------------------------+\r
-| Function Name     : _INT_     i_APCI1710_InitTimer                         |\r
-|                               (BYTE_   b_BoardHandle,                      |\r
-|                                BYTE_   b_ModulNbr,                         |\r
-|                                BYTE_   b_TimerNbr,                         |\r
-|                                BYTE_   b_TimerMode,                        |\r
-|                                ULONG_ ul_ReloadValue,                      |\r
-|                                BYTE_   b_InputClockSelection,              |\r
-|                                BYTE_   b_InputClockLevel,                  |\r
-|                                BYTE_   b_OutputLevel,                      |\r
-|                                BYTE_   b_HardwareGateLevel)\r
-INT i_InsnConfig_InitTimer(comedi_device *dev,comedi_subdevice *s,\r
-       comedi_insn *insn,lsampl_t *data)\r
-|      \r
-+----------------------------------------------------------------------------+\r
-| Task              : Configure the Timer (b_TimerNbr) operating mode        |\r
-|                     (b_TimerMode) from selected module (b_ModulNbr).       |\r
-|                     You must calling this function be for you call any     |\r
-|                     other function witch access of the timer.              |\r
-|                                                                            |\r
-|                                                                            |\r
-|                       Timer mode description table                         |\r
-|                                                                            |\r
-|+--------+-----------------------------+--------------+--------------------+|\r
-||Selected+      Mode description       +u_ReloadValue | Hardware gate input||\r
-||  mode  |                             |  description |      action        ||\r
-|+--------+-----------------------------+--------------+--------------------+|\r
-||        |Mode 0 is typically used     |              |                    ||\r
-||        |for event counting. After    |              |                    ||\r
-||        |the initialisation, OUT      |              |                    ||\r
-||        |is initially low, and        |              |                    ||\r
-||   0    |will remain low until the    |Start counting|   Hardware gate    ||\r
-||        |counter reaches zero.        |   value      |                    ||\r
-||        |OUT then goes high and       |              |                    ||\r
-||        |remains high until a new     |              |                    ||\r
-||        |count is written. See        |              |                    ||\r
-||        |"i_APCI1710_WriteTimerValue" |              |                    ||\r
-||        |function.                    |              |                    ||\r
-|+--------+-----------------------------+--------------+--------------------+|\r
-||        |Mode 1 is similar to mode 0  |              |                    ||\r
-||        |except for the gate input    |              |                    ||\r
-||   1    |action. The gate input is not|Start counting|  Hardware trigger  ||\r
-||        |used for enabled or disabled |   value      |                    ||\r
-||        |the timer.                   |              |                    ||\r
-||        |The gate input is used for   |              |                    ||\r
-||        |triggered the timer.         |              |                    ||\r
-|+--------+-----------------------------+--------------+--------------------+|\r
-||        |This mode functions like a   |              |                    ||\r
-||        |divide-by-ul_ReloadValue     |              |                    ||\r
-||        |counter. It is typically used|              |                    ||\r
-||        |to generate a real time clock|              |                    ||\r
-||        |interrupt. OUT will initially|              |                    ||\r
-||   2    |be high after the            |   Division   |  Hardware gate     ||\r
-||        |initialisation. When the     |    factor    |                    ||\r
-||        |initial count has decremented|              |                    ||\r
-||        |to 1, OUT goes low for one   |              |                    ||\r
-||        |CLK pule. OUT then goes high |              |                    ||\r
-||        |again, the counter reloads   |              |                    ||\r
-||        |the initial count            |              |                    ||\r
-||        |(ul_ReloadValue) and the     |              |                    ||\r
-||        |process is repeated.         |              |                    ||\r
-||        |This action can generated a  |              |                    ||\r
-||        |interrupt. See function      |              |                    ||\r
-||        |"i_APCI1710_SetBoardInt-     |              |                    ||\r
-||        |RoutineX"                    |              |                    ||\r
-||        |and "i_APCI1710_EnableTimer" |              |                    ||\r
-|+--------+-----------------------------+--------------+--------------------+|\r
-||        |Mode 3 is typically used for |              |                    ||\r
-||        |baud rate generation. This   |              |                    ||\r
-||        |mode is similar to mode 2    |              |                    ||\r
-||        |except for the duty cycle of |              |                    ||\r
-||   3    |OUT. OUT will initially be   |  Division    |   Hardware gate    ||\r
-||        |high after the initialisation|   factor     |                    ||\r
-||        |When half the initial count  |              |                    ||\r
-||        |(ul_ReloadValue) has expired,|              |                    ||\r
-||        |OUT goes low for the         |              |                    ||\r
-||        |remainder of the count. The  |              |                    ||\r
-||        |mode is periodic; the        |              |                    ||\r
-||        |sequence above is repeated   |              |                    ||\r
-||        |indefinitely.                |              |                    ||\r
-|+--------+-----------------------------+--------------+--------------------+|\r
-||        |OUT will be initially high   |              |                    ||\r
-||        |after the initialisation.    |              |                    ||\r
-||        |When the initial count       |              |                    ||\r
-||   4    |expires OUT will go low for  |Start counting|  Hardware gate     ||\r
-||        |one CLK pulse and then go    |    value     |                    ||\r
-||        |high again.                  |              |                    ||\r
-||        |The counting sequences is    |              |                    ||\r
-||        |triggered by writing a new   |              |                    ||\r
-||        |value. See                   |              |                    ||\r
-||        |"i_APCI1710_WriteTimerValue" |              |                    ||\r
-||        |function. If a new count is  |              |                    ||\r
-||        |written during counting,     |              |                    ||\r
-||        |it will be loaded on the     |              |                    ||\r
-||        |next CLK pulse               |              |                    ||\r
-|+--------+-----------------------------+--------------+--------------------+|\r
-||        |Mode 5 is similar to mode 4  |              |                    ||\r
-||        |except for the gate input    |              |                    ||\r
-||        |action. The gate input is not|              |                    ||\r
-||   5    |used for enabled or disabled |Start counting|  Hardware trigger  ||\r
-||        |the timer. The gate input is |    value     |                    ||\r
-||        |used for triggered the timer.|              |                    ||\r
-|+--------+-----------------------------+--------------+--------------------+|\r
-|                                                                            |\r
-|                                                                            |\r
-|                                                                            |\r
-|                      Input clock selection table                           |\r
-|                                                                            |\r
-|  +--------------------------------+------------------------------------+   |\r
-|  |       b_InputClockSelection    |           Description              |   |\r
-|  |           parameter            |                                    |   |\r
-|  +--------------------------------+------------------------------------+   |\r
-|  |    APCI1710_PCI_BUS_CLOCK      | For the timer input clock, the PCI |   |\r
-|  |                                | bus clock / 4 is used. This PCI bus|   |\r
-|  |                                | clock can be 30MHz or 33MHz. For   |   |\r
-|  |                                | Timer 0 only this selection are    |   |\r
-|  |                                | available.                         |   |\r
-|  +--------------------------------+------------------------------------+   |\r
-|  | APCI1710_ FRONT_CONNECTOR_INPUT| Of the front connector you have the|   |\r
-|  |                                | possibility to inject a input clock|   |\r
-|  |                                | for Timer 1 or Timer 2. The source |   |\r
-|  |                                | from this clock can eat the output |   |\r
-|  |                                | clock from Timer 0 or any other    |   |\r
-|  |                                | clock source.                      |   |\r
-|  +--------------------------------+------------------------------------+   |\r
-|                                                                            |\r
-+----------------------------------------------------------------------------+\r
-| Input Parameters  : BYTE_   b_BoardHandle        : Handle of board         |\r
-|                                                    APCI-1710               |\r
-|                     BYTE_   b_ModulNbr           : Module number to        |\r
-|                                                    configure (0 to 3)      |\r
-|                     BYTE_   b_TimerNbr           : Timer number to         |\r
-|                                                    configure (0 to 2)      |\r
-|                     BYTE_   b_TimerMode          : Timer mode selection    |\r
-|                                                    (0 to 5)                |\r
-|                                                    0: Interrupt on terminal|\r
-|                                                       count                |\r
-|                                                    1: Hardware             |\r
-|                                                       retriggerable one-   |\r
-|                                                       shot                 |\r
-|                                                    2: Rate generator       |\r
-|                                                    3: Square wave mode     |\r
-|                                                    4: Software triggered   |\r
-|                                                       strobe               |\r
-|                                                    5: Hardware triggered   |\r
-|                                                       strobe               |\r
-|                                                       See timer mode       |\r
-|                                                       description table.   |\r
-|                     ULONG_ ul_ReloadValue         : Start counting value   |\r
-|                                                     or division factor     |\r
-|                                                     See timer mode         |\r
-|                                                     description table.     |\r
-|                     BYTE_   b_InputClockSelection : Selection from input   |\r
-|                                                     timer clock.           |\r
-|                                                     See input clock        |\r
-|                                                     selection table.       |\r
-|                     BYTE_   b_InputClockLevel     : Selection from input   |\r
-|                                                     clock level.           |\r
-|                                                     0 : Low active         |\r
-|                                                         (Input inverted)   |\r
-|                                                     1 : High active        |\r
-|                     BYTE_   b_OutputLevel,        : Selection from output  |\r
-|                                                     clock level.           |\r
-|                                                     0 : Low active         |\r
-|                                                     1 : High active        |\r
-|                                                         (Output inverted)  |\r
-|                     BYTE_   b_HardwareGateLevel   : Selection from         |\r
-|                                                     hardware gate level.   |\r
-|                                                     0 : Low active         |\r
-|                                                         (Input inverted)   |\r
-|                                                     1 : High active        |\r
-|                                                     If you will not used   |\r
-|                                                     the hardware gate set  |\r
-|                                                     this value to 0.       \r
-|b_ModulNbr        = (BYTE) CR_AREF(insn->chanspec);\r
-       b_TimerNbr                = (BYTE) CR_CHAN(insn->chanspec);\r
-       b_TimerMode               = (BYTE) data[0];\r
-       ul_ReloadValue    = (ULONG) data[1];\r
-       b_InputClockSelection   =(BYTE) data[2];\r
-       b_InputClockLevel               =(BYTE) data[3];\r
-       b_OutputLevel                   =(BYTE) data[4];\r
-       b_HardwareGateLevel             =(BYTE) data[5];\r
-+----------------------------------------------------------------------------+\r
-| Output Parameters : -                                                      |\r
-+----------------------------------------------------------------------------+\r
-| Return Value      : 0: No error                                            |\r
-|                    -1: The handle parameter of the board is wrong          |\r
-|                    -2: Module selection wrong                              |\r
-|                    -3: Timer selection wrong                               |\r
-|                    -4: The module is not a TIMER module                    |\r
-|                    -5: Timer mode selection is wrong                       |\r
-|                    -6: Input timer clock selection is wrong                |\r
-|                    -7: Selection from input clock level is wrong           |\r
-|                    -8: Selection from output clock level is wrong          |\r
-|                    -9: Selection from hardware gate level is wrong         |\r
-+----------------------------------------------------------------------------+\r
-*/\r
-\r
-
-INT i_APCI1710_InsnConfigInitTimer(comedi_device *dev,comedi_subdevice *s,\r
-       comedi_insn *insn,lsampl_t *data)\r
-       {\r
-\r
-       INT i_ReturnValue = 0;  \r
-       BYTE   b_ModulNbr;\r
-       BYTE   b_TimerNbr;\r
-       BYTE   b_TimerMode;\r
-       ULONG  ul_ReloadValue;\r
-       BYTE   b_InputClockSelection;\r
-       BYTE   b_InputClockLevel;\r
-       BYTE   b_OutputLevel;\r
-       BYTE   b_HardwareGateLevel;\r
-\r
-       i_ReturnValue=insn->n;\r
-       b_ModulNbr        = (BYTE) CR_AREF(insn->chanspec);\r
-       b_TimerNbr                = (BYTE) CR_CHAN(insn->chanspec);\r
-       b_TimerMode               = (BYTE) data[0];\r
-       ul_ReloadValue    = (ULONG) data[1];\r
-       b_InputClockSelection   =(BYTE) data[2];\r
-       b_InputClockLevel               =(BYTE) data[3];\r
-       b_OutputLevel                   =(BYTE) data[4];\r
-       b_HardwareGateLevel             =(BYTE) data[5];\r
-\r
-       /**************************/\r
-       /* Test the module number */\r
-       /**************************/\r
-\r       
-       if (b_ModulNbr < 4)\r
-          {\r
-          /***********************/\r
-          /* Test if 82X54 timer */\r
-          /***********************/\r
-\r
-          if ((devpriv->s_BoardInfos.\r
-               dw_MolduleConfiguration [b_ModulNbr] & 0xFFFF0000UL) == APCI1710_82X54_TIMER)\r
-             {\r
-             /*************************/\r
-             /* Test the timer number */\r
-             /*************************/\r
-\r
-             if ((b_TimerNbr >= 0) && (b_TimerNbr <= 2))\r
-                {\r
-                /***********************/\r
-                /* Test the timer mode */\r
-                /***********************/\r
-\r
-                if ((b_TimerMode >= 0) && (b_TimerMode <= 5))\r
-                   {\r
-                   /*********************************/\r
-                   /* Test te imput clock selection */\r
-                   /*********************************/\r
-\r
-                   if (((b_TimerNbr == 0) && (b_InputClockSelection == 0)) ||\r
-                       ((b_TimerNbr != 0) && ((b_InputClockSelection == 0) || (b_InputClockSelection == 1))))\r
-                      {\r
-                      /****************************************/\r
-                      /* Test the input clock level selection */\r
-                      /****************************************/\r
-\r
-                      if ((b_InputClockLevel == 0) || (b_InputClockLevel == 1))\r
-                         {\r
-                         /*****************************************/\r
-                         /* Test the output clock level selection */\r
-                         /*****************************************/\r
-\r
-                         if ((b_OutputLevel == 0) || (b_OutputLevel == 1))\r
-                            {\r
-                            /******************************************/\r
-                            /* Test the hardware gate level selection */\r
-                            /******************************************/\r
-\r
-                            if ((b_HardwareGateLevel == 0) || (b_HardwareGateLevel == 1))\r
-                               {\r
-                               /*********************/\r
-                               /* Initialisation OK */\r
-                               /*********************/\r
-\r
-                               devpriv->s_ModuleInfo [b_ModulNbr].\r
-                               s_82X54ModuleInfo.\r
-                               s_82X54TimerInfo  [b_TimerNbr].\r
-                               b_82X54Init = 1;\r
-\r
-                               /**********************************/\r
-                               /* Save the input clock selection */\r
-                               /**********************************/\r
-                               devpriv->s_ModuleInfo [b_ModulNbr].\r
-                               s_82X54ModuleInfo.\r
-                               s_82X54TimerInfo  [b_TimerNbr].\r
-                               b_InputClockSelection = b_InputClockSelection;\r
-\r
-                               /******************************/\r
-                               /* Save the input clock level */\r
-                               /******************************/\r
-                               devpriv->s_ModuleInfo [b_ModulNbr].\r
-                               s_82X54ModuleInfo.\r
-                               s_82X54TimerInfo  [b_TimerNbr].\r
-                               b_InputClockLevel = ~b_InputClockLevel & 1;\r
-\r
-                               /*************************/\r
-                               /* Save the output level */\r
-                               /*************************/\r
-\r
-                               devpriv->s_ModuleInfo [b_ModulNbr].\r
-                               s_82X54ModuleInfo.\r
-                               s_82X54TimerInfo  [b_TimerNbr].\r
-                               b_OutputLevel = ~b_OutputLevel & 1;\r
-\r
-                               /***********************/\r
-                               /* Save the gate level */\r
-                               /***********************/\r
-\r
-                               devpriv->s_ModuleInfo [b_ModulNbr].\r
-                               s_82X54ModuleInfo.\r
-                               s_82X54TimerInfo  [b_TimerNbr].\r
-                               b_HardwareGateLevel = b_HardwareGateLevel;\r
-\r
-                               /****************************************************/\r
-                               /* Set the configuration word and disable the timer */\r
-                               /****************************************************/\r
-                               devpriv->s_ModuleInfo [b_ModulNbr].\r
-                               s_82X54ModuleInfo.\r
-                               s_82X54TimerInfo  [b_TimerNbr].\r
-                               dw_ConfigurationWord = (DWORD) (((b_HardwareGateLevel         << 0) & 0x1) |\r
-                                                               ((b_InputClockLevel           << 1) & 0x2) |\r
-                                                               (((~b_OutputLevel       & 1)  << 2) & 0x4) |\r
-                                                               ((b_InputClockSelection       << 4) & 0x10));\r
-\r
-                               
-                               outl(devpriv->s_ModuleInfo [b_ModulNbr].\r
-                                       s_82X54ModuleInfo.s_82X54TimerInfo  [b_TimerNbr].\r
-                                       dw_ConfigurationWord, devpriv->s_BoardInfos.\r
-                                       ui_Address + 32 + (b_TimerNbr * 4) + (64 * b_ModulNbr));\r
-\r
-                               /******************************/\r
-                               /* Initialise the 82X54 Timer */\r
-                               /******************************/\r
-\r
-                               
-                               outl((DWORD) b_TimerMode,devpriv->s_BoardInfos.\r
-                                       ui_Address + 16 + (b_TimerNbr * 4) + (64 * b_ModulNbr));\r
-\r
-                               /**************************/\r
-                               /* Write the reload value */\r
-                               /**************************/\r
-\r
+/**
+@verbatim
+
+Copyright (C) 2004,2005  ADDI-DATA GmbH for the source code of this module. 
+        
+        ADDI-DATA GmbH 
+        Dieselstrasse 3 
+        D-77833 Ottersweier 
+        Tel: +19(0)7223/9493-0 
+        Fax: +49(0)7223/9493-92 
+        http://www.addi-data-com 
+        info@addi-data.com 
+
+This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+You shoud also find the complete GPL in the COPYING file accompanying this source code.
+
+@endverbatim
+*/
+/*
+    
+  +-----------------------------------------------------------------------+
+  | (C) ADDI-DATA GmbH          Dieselstraße 3       D-77833 Ottersweier  |
+  +-----------------------------------------------------------------------+
+  | Tel : +49 (0) 7223/9493-0     | email    : info@addi-data.com         |
+  | Fax : +49 (0) 7223/9493-92    | Internet : http://www.addi-data.com   |
+  +-----------------------------------------------------------------------+
+  | Project     : API APCI1710    | Compiler : gcc                        |
+  | Module name : 82X54.C         | Version  : 2.96                       |
+  +-------------------------------+---------------------------------------+
+  | Project manager: Eric Stolz   | Date     :  02/12/2002                |
+  +-----------------------------------------------------------------------+
+  | Description :   APCI-1710 82X54 timer module                          |
+  |                                                                       |
+  |                                                                       |
+  +-----------------------------------------------------------------------+
+  |                             UPDATES                                   |
+  +-----------------------------------------------------------------------+
+  |   Date   |   Author  |          Description of updates                |
+  +----------+-----------+------------------------------------------------+
+  | 29/06/98 | S. Weber  | Digital input / output implementation          |
+  |----------|-----------|------------------------------------------------|
+  | 08/05/00 | Guinot C  | - 0400/0228 All Function in RING 0             |
+  |          |           |   available                                    |
+  +-----------------------------------------------------------------------+
+  | 27.10.03 | J. Krauth |  Add the possibility to use a 40 Mhz quartz    |
+  |          |           |                                                |
+  +-----------------------------------------------------------------------+
+*/
+
+/*
++----------------------------------------------------------------------------+
+|                               Included files                               |
++----------------------------------------------------------------------------+
+*/
+
+
+#include "APCI1710_82x54.h"
+
+/*
++----------------------------------------------------------------------------+
+| Function Name     : _INT_     i_APCI1710_InitTimer                         |
+|                               (BYTE_   b_BoardHandle,                      |
+|                                BYTE_   b_ModulNbr,                         |
+|                                BYTE_   b_TimerNbr,                         |
+|                                BYTE_   b_TimerMode,                        |
+|                                ULONG_ ul_ReloadValue,                      |
+|                                BYTE_   b_InputClockSelection,              |
+|                                BYTE_   b_InputClockLevel,                  |
+|                                BYTE_   b_OutputLevel,                      |
+|                                BYTE_   b_HardwareGateLevel)
+INT i_InsnConfig_InitTimer(comedi_device *dev,comedi_subdevice *s,
+       comedi_insn *insn,lsampl_t *data)
+|      
++----------------------------------------------------------------------------+
+| Task              : Configure the Timer (b_TimerNbr) operating mode        |
+|                     (b_TimerMode) from selected module (b_ModulNbr).       |
+|                     You must calling this function be for you call any     |
+|                     other function witch access of the timer.              |
+|                                                                            |
+|                                                                            |
+|                       Timer mode description table                         |
+|                                                                            |
+|+--------+-----------------------------+--------------+--------------------+|
+||Selected+      Mode description       +u_ReloadValue | Hardware gate input||
+||  mode  |                             |  description |      action        ||
+|+--------+-----------------------------+--------------+--------------------+|
+||        |Mode 0 is typically used     |              |                    ||
+||        |for event counting. After    |              |                    ||
+||        |the initialisation, OUT      |              |                    ||
+||        |is initially low, and        |              |                    ||
+||   0    |will remain low until the    |Start counting|   Hardware gate    ||
+||        |counter reaches zero.        |   value      |                    ||
+||        |OUT then goes high and       |              |                    ||
+||        |remains high until a new     |              |                    ||
+||        |count is written. See        |              |                    ||
+||        |"i_APCI1710_WriteTimerValue" |              |                    ||
+||        |function.                    |              |                    ||
+|+--------+-----------------------------+--------------+--------------------+|
+||        |Mode 1 is similar to mode 0  |              |                    ||
+||        |except for the gate input    |              |                    ||
+||   1    |action. The gate input is not|Start counting|  Hardware trigger  ||
+||        |used for enabled or disabled |   value      |                    ||
+||        |the timer.                   |              |                    ||
+||        |The gate input is used for   |              |                    ||
+||        |triggered the timer.         |              |                    ||
+|+--------+-----------------------------+--------------+--------------------+|
+||        |This mode functions like a   |              |                    ||
+||        |divide-by-ul_ReloadValue     |              |                    ||
+||        |counter. It is typically used|              |                    ||
+||        |to generate a real time clock|              |                    ||
+||        |interrupt. OUT will initially|              |                    ||
+||   2    |be high after the            |   Division   |  Hardware gate     ||
+||        |initialisation. When the     |    factor    |                    ||
+||        |initial count has decremented|              |                    ||
+||        |to 1, OUT goes low for one   |              |                    ||
+||        |CLK pule. OUT then goes high |              |                    ||
+||        |again, the counter reloads   |              |                    ||
+||        |the initial count            |              |                    ||
+||        |(ul_ReloadValue) and the     |              |                    ||
+||        |process is repeated.         |              |                    ||
+||        |This action can generated a  |              |                    ||
+||        |interrupt. See function      |              |                    ||
+||        |"i_APCI1710_SetBoardInt-     |              |                    ||
+||        |RoutineX"                    |              |                    ||
+||        |and "i_APCI1710_EnableTimer" |              |                    ||
+|+--------+-----------------------------+--------------+--------------------+|
+||        |Mode 3 is typically used for |              |                    ||
+||        |baud rate generation. This   |              |                    ||
+||        |mode is similar to mode 2    |              |                    ||
+||        |except for the duty cycle of |              |                    ||
+||   3    |OUT. OUT will initially be   |  Division    |   Hardware gate    ||
+||        |high after the initialisation|   factor     |                    ||
+||        |When half the initial count  |              |                    ||
+||        |(ul_ReloadValue) has expired,|              |                    ||
+||        |OUT goes low for the         |              |                    ||
+||        |remainder of the count. The  |              |                    ||
+||        |mode is periodic; the        |              |                    ||
+||        |sequence above is repeated   |              |                    ||
+||        |indefinitely.                |              |                    ||
+|+--------+-----------------------------+--------------+--------------------+|
+||        |OUT will be initially high   |              |                    ||
+||        |after the initialisation.    |              |                    ||
+||        |When the initial count       |              |                    ||
+||   4    |expires OUT will go low for  |Start counting|  Hardware gate     ||
+||        |one CLK pulse and then go    |    value     |                    ||
+||        |high again.                  |              |                    ||
+||        |The counting sequences is    |              |                    ||
+||        |triggered by writing a new   |              |                    ||
+||        |value. See                   |              |                    ||
+||        |"i_APCI1710_WriteTimerValue" |              |                    ||
+||        |function. If a new count is  |              |                    ||
+||        |written during counting,     |              |                    ||
+||        |it will be loaded on the     |              |                    ||
+||        |next CLK pulse               |              |                    ||
+|+--------+-----------------------------+--------------+--------------------+|
+||        |Mode 5 is similar to mode 4  |              |                    ||
+||        |except for the gate input    |              |                    ||
+||        |action. The gate input is not|              |                    ||
+||   5    |used for enabled or disabled |Start counting|  Hardware trigger  ||
+||        |the timer. The gate input is |    value     |                    ||
+||        |used for triggered the timer.|              |                    ||
+|+--------+-----------------------------+--------------+--------------------+|
+|                                                                            |
+|                                                                            |
+|                                                                            |
+|                      Input clock selection table                           |
+|                                                                            |
+|  +--------------------------------+------------------------------------+   |
+|  |       b_InputClockSelection    |           Description              |   |
+|  |           parameter            |                                    |   |
+|  +--------------------------------+------------------------------------+   |
+|  |    APCI1710_PCI_BUS_CLOCK      | For the timer input clock, the PCI |   |
+|  |                                | bus clock / 4 is used. This PCI bus|   |
+|  |                                | clock can be 30MHz or 33MHz. For   |   |
+|  |                                | Timer 0 only this selection are    |   |
+|  |                                | available.                         |   |
+|  +--------------------------------+------------------------------------+   |
+|  | APCI1710_ FRONT_CONNECTOR_INPUT| Of the front connector you have the|   |
+|  |                                | possibility to inject a input clock|   |
+|  |                                | for Timer 1 or Timer 2. The source |   |
+|  |                                | from this clock can eat the output |   |
+|  |                                | clock from Timer 0 or any other    |   |
+|  |                                | clock source.                      |   |
+|  +--------------------------------+------------------------------------+   |
+|                                                                            |
++----------------------------------------------------------------------------+
+| Input Parameters  : BYTE_   b_BoardHandle        : Handle of board         |
+|                                                    APCI-1710               |
+|                     BYTE_   b_ModulNbr           : Module number to        |
+|                                                    configure (0 to 3)      |
+|                     BYTE_   b_TimerNbr           : Timer number to         |
+|                                                    configure (0 to 2)      |
+|                     BYTE_   b_TimerMode          : Timer mode selection    |
+|                                                    (0 to 5)                |
+|                                                    0: Interrupt on terminal|
+|                                                       count                |
+|                                                    1: Hardware             |
+|                                                       retriggerable one-   |
+|                                                       shot                 |
+|                                                    2: Rate generator       |
+|                                                    3: Square wave mode     |
+|                                                    4: Software triggered   |
+|                                                       strobe               |
+|                                                    5: Hardware triggered   |
+|                                                       strobe               |
+|                                                       See timer mode       |
+|                                                       description table.   |
+|                     ULONG_ ul_ReloadValue         : Start counting value   |
+|                                                     or division factor     |
+|                                                     See timer mode         |
+|                                                     description table.     |
+|                     BYTE_   b_InputClockSelection : Selection from input   |
+|                                                     timer clock.           |
+|                                                     See input clock        |
+|                                                     selection table.       |
+|                     BYTE_   b_InputClockLevel     : Selection from input   |
+|                                                     clock level.           |
+|                                                     0 : Low active         |
+|                                                         (Input inverted)   |
+|                                                     1 : High active        |
+|                     BYTE_   b_OutputLevel,        : Selection from output  |
+|                                                     clock level.           |
+|                                                     0 : Low active         |
+|                                                     1 : High active        |
+|                                                         (Output inverted)  |
+|                     BYTE_   b_HardwareGateLevel   : Selection from         |
+|                                                     hardware gate level.   |
+|                                                     0 : Low active         |
+|                                                         (Input inverted)   |
+|                                                     1 : High active        |
+|                                                     If you will not used   |
+|                                                     the hardware gate set  |
+|                                                     this value to 0.       
+|b_ModulNbr        = (BYTE) CR_AREF(insn->chanspec);
+       b_TimerNbr                = (BYTE) CR_CHAN(insn->chanspec);
+       b_TimerMode               = (BYTE) data[0];
+       ul_ReloadValue    = (ULONG) data[1];
+       b_InputClockSelection   =(BYTE) data[2];
+       b_InputClockLevel               =(BYTE) data[3];
+       b_OutputLevel                   =(BYTE) data[4];
+       b_HardwareGateLevel             =(BYTE) data[5];
++----------------------------------------------------------------------------+
+| Output Parameters : -                                                      |
++----------------------------------------------------------------------------+
+| Return Value      : 0: No error                                            |
+|                    -1: The handle parameter of the board is wrong          |
+|                    -2: Module selection wrong                              |
+|                    -3: Timer selection wrong                               |
+|                    -4: The module is not a TIMER module                    |
+|                    -5: Timer mode selection is wrong                       |
+|                    -6: Input timer clock selection is wrong                |
+|                    -7: Selection from input clock level is wrong           |
+|                    -8: Selection from output clock level is wrong          |
+|                    -9: Selection from hardware gate level is wrong         |
++----------------------------------------------------------------------------+
+*/
+
+
+INT i_APCI1710_InsnConfigInitTimer(comedi_device *dev,comedi_subdevice *s,
+       comedi_insn *insn,lsampl_t *data)
+       {
+
+       INT i_ReturnValue = 0;  
+       BYTE   b_ModulNbr;
+       BYTE   b_TimerNbr;
+       BYTE   b_TimerMode;
+       ULONG  ul_ReloadValue;
+       BYTE   b_InputClockSelection;
+       BYTE   b_InputClockLevel;
+       BYTE   b_OutputLevel;
+       BYTE   b_HardwareGateLevel;
+
+        //BEGIN JK 27.10.2003 : Add the possibility to use a 40 Mhz quartz
+       DWORD dw_Test = 0;
+       //END JK 27.10.2003 : Add the possibility to use a 40 Mhz quartz
+
+       i_ReturnValue=insn->n;
+       b_ModulNbr        = (BYTE) CR_AREF(insn->chanspec);
+       b_TimerNbr                = (BYTE) CR_CHAN(insn->chanspec);
+       b_TimerMode               = (BYTE) data[0];
+       ul_ReloadValue    = (ULONG) data[1];
+       b_InputClockSelection   =(BYTE) data[2];
+       b_InputClockLevel               =(BYTE) data[3];
+       b_OutputLevel                   =(BYTE) data[4];
+       b_HardwareGateLevel             =(BYTE) data[5];
+       
+
+       /**************************/
+       /* Test the module number */
+       /**************************/
+
+       
+       if (b_ModulNbr < 4)
+          {
+          /***********************/
+          /* Test if 82X54 timer */
+          /***********************/
+
+          if ((devpriv->s_BoardInfos.
+               dw_MolduleConfiguration [b_ModulNbr] & 0xFFFF0000UL) == APCI1710_82X54_TIMER)
+             {
+             /*************************/
+             /* Test the timer number */
+             /*************************/
+
+             if (b_TimerNbr <= 2)
+                {
+                /***********************/
+                /* Test the timer mode */
+                /***********************/
+
+                if (b_TimerMode <= 5)
+                   {
+                    //BEGIN JK 27.10.2003 : Add the possibility to use a 40 Mhz quartz
+                   /*********************************/
+                   /* Test te imput clock selection */
+                   /*********************************/
+                    /*
+                   if (((b_TimerNbr == 0) && (b_InputClockSelection == 0)) ||
+                       ((b_TimerNbr != 0) && ((b_InputClockSelection == 0) || (b_InputClockSelection == 1))))
+                    */
+
+                   if (((b_TimerNbr == 0) && (b_InputClockSelection == APCI1710_PCI_BUS_CLOCK)) ||
+                       ((b_TimerNbr == 0) && (b_InputClockSelection == APCI1710_10MHZ)) ||
+                       ((b_TimerNbr != 0) && ((b_InputClockSelection == APCI1710_PCI_BUS_CLOCK)
+                                           || (b_InputClockSelection == APCI1710_FRONT_CONNECTOR_INPUT)
+                                           || (b_InputClockSelection == APCI1710_10MHZ))))
+                    //END JK 27.10.2003 : Add the possibility to use a 40 Mhz quartz
+                      {
+                       //BEGIN JK 27.10.2003 : Add the possibility to use a 40 Mhz quartz
+                      if (((b_InputClockSelection == APCI1710_10MHZ) &&
+                           ((devpriv->s_BoardInfos.dw_MolduleConfiguration [b_ModulNbr] & 0x0000FFFFUL) >= 0x3131)) ||
+                         (b_InputClockSelection != APCI1710_10MHZ))
+                         {
+                          //END JK 27.10.2003 : Add the possibility to use a 40 Mhz quartz
+                         /****************************************/
+                         /* Test the input clock level selection */
+                         /****************************************/
+
+                         if ((b_InputClockLevel == 0) || (b_InputClockLevel == 1))
+                            {
+                            /*****************************************/
+                            /* Test the output clock level selection */
+                            /*****************************************/
+
+                            if ((b_OutputLevel == 0) || (b_OutputLevel == 1))
+                               {
+                               /******************************************/
+                               /* Test the hardware gate level selection */
+                               /******************************************/
+
+                               if ((b_HardwareGateLevel == 0) || (b_HardwareGateLevel == 1))
+                                  {
+                                   //BEGIN JK 27.10.03 : Add the possibility to use a 40 Mhz quartz
+                                  /*****************************************************/
+                                  /* Test if version > 1.1 and clock selection = 10MHz */
+                                   /*****************************************************/
+
+                                  if ((b_InputClockSelection == APCI1710_10MHZ) &&
+                                      ((devpriv->s_BoardInfos.dw_MolduleConfiguration [b_ModulNbr] & 0x0000FFFFUL) > 0x3131))
+                                     {
+                                     /*********************************/
+                                     /* Test if 40MHz quartz on board */
+                                     /*********************************/
+
+                                      dw_Test = inl (devpriv->s_BoardInfos.ui_Address + (16 + (b_TimerNbr * 4) + (64 * b_ModulNbr)));
+
+                                     dw_Test = (dw_Test >> 16) & 1;
+                                     }
+                                  else
+                                     {
+                                     dw_Test = 1;
+                                     }
+
+                                  /************************/
+                                  /* Test if detection OK */
+                                  /************************/
+
+                                  if (dw_Test == 1)
+                                     {
+                                      //END JK 27.10.03 : Add the possibility to use a 40 Mhz quartz
+                                     /*********************/
+                                     /* Initialisation OK */
+                                     /*********************/
+      
+                                     devpriv->s_ModuleInfo [b_ModulNbr].
+                                     s_82X54ModuleInfo.
+                                     s_82X54TimerInfo  [b_TimerNbr].
+                                     b_82X54Init = 1;
+      
+                                     /**********************************/
+                                     /* Save the input clock selection */
+                                     /**********************************/
+                                     devpriv->s_ModuleInfo [b_ModulNbr].
+                                     s_82X54ModuleInfo.
+                                     s_82X54TimerInfo  [b_TimerNbr].
+                                     b_InputClockSelection = b_InputClockSelection;
+      
+                                     /******************************/
+                                     /* Save the input clock level */
+                                     /******************************/
+                                     devpriv->s_ModuleInfo [b_ModulNbr].
+                                     s_82X54ModuleInfo.
+                                     s_82X54TimerInfo  [b_TimerNbr].
+                                     b_InputClockLevel = ~b_InputClockLevel & 1;
+      
+                                     /*************************/
+                                     /* Save the output level */
+                                     /*************************/
+      
+                                     devpriv->s_ModuleInfo [b_ModulNbr].
+                                     s_82X54ModuleInfo.
+                                     s_82X54TimerInfo  [b_TimerNbr].
+                                     b_OutputLevel = ~b_OutputLevel & 1;
+      
+                                     /***********************/
+                                     /* Save the gate level */
+                                     /***********************/
+      
+                                     devpriv->s_ModuleInfo [b_ModulNbr].
+                                     s_82X54ModuleInfo.
+                                     s_82X54TimerInfo  [b_TimerNbr].
+                                     b_HardwareGateLevel = b_HardwareGateLevel;
+      
+                                     /****************************************************/
+                                     /* Set the configuration word and disable the timer */
+                                     /****************************************************/
+                                      //BEGIN JK 27.10.03 : Add the possibility to use a 40 Mhz quartz
+                                      /*
+                                     devpriv->s_ModuleInfo [b_ModulNbr].
+                                     s_82X54ModuleInfo.
+                                     s_82X54TimerInfo  [b_TimerNbr].
+                                     dw_ConfigurationWord = (DWORD) (((b_HardwareGateLevel         << 0) & 0x1) |
+                                                                     ((b_InputClockLevel           << 1) & 0x2) |
+                                                                     (((~b_OutputLevel       & 1)  << 2) & 0x4) |
+                                                                     ((b_InputClockSelection       << 4) & 0x10));
+                                      */
+                                     /**************************/
+                                     /* Test if 10MHz selected */
+                                     /**************************/
+
+                                     if (b_InputClockSelection == APCI1710_10MHZ)
+                                        {
+                                        b_InputClockSelection = 2;
+                                        }
+
+                                     devpriv->s_ModuleInfo [b_ModulNbr].
+                                     s_82X54ModuleInfo.
+                                     s_82X54TimerInfo  [b_TimerNbr].
+                                     dw_ConfigurationWord = (DWORD) (((b_HardwareGateLevel         << 0) & 0x1) |
+                                                                     ((b_InputClockLevel           << 1) & 0x2) |
+                                                                     (((~b_OutputLevel       & 1)  << 2) & 0x4) |
+                                                                     ((b_InputClockSelection       << 4) & 0x30));
+                                      //END JK 27.10.03 : Add the possibility to use a 40 Mhz quartz                           
+                                     outl(devpriv->s_ModuleInfo [b_ModulNbr].
+                                             s_82X54ModuleInfo.s_82X54TimerInfo  [b_TimerNbr].
+                                             dw_ConfigurationWord, devpriv->s_BoardInfos.
+                                             ui_Address + 32 + (b_TimerNbr * 4) + (64 * b_ModulNbr));
+
+                                     /******************************/
+                                     /* Initialise the 82X54 Timer */
+                                     /******************************/
+
                                
-                                outl(ul_ReloadValue,devpriv->s_BoardInfos.\r
-                                       ui_Address + 0 + (b_TimerNbr * 4) + (64 * b_ModulNbr));\r
-\r
-                               } // if ((b_HardwareGateLevel == 0) || (b_HardwareGateLevel == 1))\r
-                            else\r
-                               {\r
-                               /***********************************************/\r
-                               /* Selection from hardware gate level is wrong */\r
-                               /***********************************************/\r
-\r                       DPRINTK("Selection from hardware gate level is wrong\n");
-                               i_ReturnValue = -9;\r
-                               } // if ((b_HardwareGateLevel == 0) || (b_HardwareGateLevel == 1))\r
-                            } // if ((b_OutputLevel == 0) || (b_OutputLevel == 1))\r
-                         else\r
-                            {\r
-                            /**********************************************/\r
-                            /* Selection from output clock level is wrong */\r
-                            /**********************************************/\r
-\r                        DPRINTK("Selection from output clock level is wrong\n");
-                            i_ReturnValue = -8;\r
-                            } // if ((b_OutputLevel == 0) || (b_OutputLevel == 1))\r
-                         } // if ((b_InputClockLevel == 0) || (b_InputClockLevel == 1))\r
-                      else\r
-                         {\r
-                         /*********************************************/\r
-                         /* Selection from input clock level is wrong */\r
-                         /*********************************************/\r
-\r                     DPRINTK("Selection from input clock level is wrong\n");
-                         i_ReturnValue = -7;\r
-                         } // if ((b_InputClockLevel == 0) || (b_InputClockLevel == 1))\r
-                      }\r
-                   else\r
-                      {\r
-                      /****************************************/\r
-                      /* Input timer clock selection is wrong */\r
-                      /****************************************/\r
-\r                              DPRINTK("Input timer clock selection is wrong\n");
-                      i_ReturnValue = -6;\r
-                      }\r
-                   } // if ((b_TimerMode >= 0) && (b_TimerMode <= 5))\r
-                else\r
-                   {\r
-                   /*********************************/\r
-                   /* Timer mode selection is wrong */\r
-                   /*********************************/\r
-\r                      DPRINTK("Timer mode selection is wrong\n");
-                   i_ReturnValue = -5;\r
-                   } // if ((b_TimerMode >= 0) && (b_TimerMode <= 5))\r
-                } // if ((b_TimerNbr >= 0) && (b_TimerNbr <= 2))\r
-             else\r
-                {\r
-                /*************************/\r
-                /* Timer selection wrong */\r
-                /*************************/\r
-\r               DPRINTK("Timer selection wrong\n");
-                i_ReturnValue = -3;\r
-                } // if ((b_TimerNbr >= 0) && (b_TimerNbr <= 2))\r
-             }\r
-          else\r
-             {\r
-             /************************************/\r
-             /* The module is not a TIMER module */\r
-             /************************************/\r
-\r             DPRINTK("The module is not a TIMER module\n");   
-             i_ReturnValue = -4;\r
-             }\r
-          }\r
-       else\r
-          {\r
-          /***********************/\r
-          /* Module number error */\r
-          /***********************/\r
-\r          DPRINTK("Module number error\n");
-          i_ReturnValue = -2;\r
-          }\r
-
-       return (i_ReturnValue);\r
-       }\r
-\r
-\r
-/*\r
-+----------------------------------------------------------------------------+\r
-| Function Name     : _INT_     i_APCI1710_EnableTimer                       |\r
-|                               (BYTE_ b_BoardHandle,                        |\r
-|                                BYTE_ b_ModulNbr,                           |\r
-|                                BYTE_ b_TimerNbr,                           |\r
-|                                BYTE_ b_InterruptEnable)    \r
-INT i_APCI1710_InsnWriteEnableDisableTimer(comedi_device *dev,comedi_subdevice *s,\r
-       comedi_insn *insn,lsampl_t *data)                |\r
-+----------------------------------------------------------------------------+\r
-| Task              : Enable OR Disable the Timer (b_TimerNbr) from selected module     |\r
-|                     (b_ModulNbr). You must calling the                     |\r
-|                     "i_APCI1710_InitTimer" function be for you call this   |\r
-|                     function. If you enable the timer interrupt, the timer |\r
-|                     generate a interrupt after the timer value reach       |\r
-|                     the zero. See function "i_APCI1710_SetBoardIntRoutineX"|\r
-+----------------------------------------------------------------------------+\r
-| Input Parameters  : BYTE_   b_BoardHandle     : Handle of board            |\r
-|                                                 APCI-1710                  |\r
-|                     BYTE_   b_ModulNbr        : Selected module number     |\r
-|                                                 (0 to 3)                   |\r
-|                     BYTE_   b_TimerNbr        : Timer number to enable     |\r
-|                                                 (0 to 2)                   |\r
-|                     BYTE_   b_InterruptEnable : Enable or disable the      |\r
-|                                                 timer interrupt.           |\r
-|                                                 APCI1710_ENABLE :          |\r
-|                                                 Enable the timer interrupt |\r
-|                                                 APCI1710_DISABLE :         |\r
-|                                                 Disable the timer interrupt|\r
-i_ReturnValue=insn->n;\r
-       b_ModulNbr        = (BYTE) CR_AREF(insn->chanspec);\r
-       b_TimerNbr                = (BYTE) CR_CHAN(insn->chanspec);\r
-       b_ActionType      = (BYTE) data[0]; // enable disable \r
-+----------------------------------------------------------------------------+\r
-| Output Parameters : -                                                      |\r
-+----------------------------------------------------------------------------+\r
-| Return Value      : 0: No error                                            |\r
-|                    -1: The handle parameter of the board is wrong          |\r
-|                    -2: Module selection wrong                              |\r
-|                    -3: Timer selection wrong                               |\r
-|                    -4: The module is not a TIMER module                    |\r
-|                    -5: Timer not initialised see function                  |\r
-|                        "i_APCI1710_InitTimer"                              |\r
-|                    -6: Interrupt parameter is wrong                        |\r
-|                    -7: Interrupt function not initialised.                 |\r
-|                        See function "i_APCI1710_SetBoardIntRoutineX"       |\r
-+----------------------------------------------------------------------------+\r
-*/\r
-\r
-INT i_APCI1710_InsnWriteEnableDisableTimer(comedi_device *dev,comedi_subdevice *s,\r
-       comedi_insn *insn,lsampl_t *data)\r
-       {\r
-       INT             i_ReturnValue = 0;\r
-       DWORD   dw_DummyRead;\r
-       BYTE    b_ModulNbr;\r
-       BYTE    b_TimerNbr;\r
-       BYTE    b_ActionType;\r
-       BYTE    b_InterruptEnable;\r
-\r
-       i_ReturnValue=insn->n;\r
-       b_ModulNbr        = (BYTE) CR_AREF(insn->chanspec);\r
-       b_TimerNbr                = (BYTE) CR_CHAN(insn->chanspec);\r
-       b_ActionType      = (BYTE) data[0]; // enable disable \r
-       /**************************/\r
-       /* Test the module number */\r
-       /**************************/\r
-\r
-       if (b_ModulNbr < 4)\r
-          {\r
-          /***********************/\r
-          /* Test if 82X54 timer */\r
-          /***********************/\r
-\r
-          if ((devpriv->s_BoardInfos.\r
-               dw_MolduleConfiguration [b_ModulNbr] & 0xFFFF0000UL) == APCI1710_82X54_TIMER)\r
-             {\r
-             /*************************/\r
-             /* Test the timer number */\r
-             /*************************/\r
-\r
-             if ((b_TimerNbr >= 0) && (b_TimerNbr <= 2))\r
-                {\r
-                /*****************************/\r
-                /* Test if timer initialised */\r
-                /*****************************/\r
-\r
-                if (devpriv->s_ModuleInfo [b_ModulNbr].\r
-                    s_82X54ModuleInfo.\r
-                    s_82X54TimerInfo  [b_TimerNbr].\r
-                    b_82X54Init == 1)\r
-                   {\r
-\r
-             switch(b_ActionType)\r
-             { \r
-                        case APCI1710_ENABLE:\r
-\r
-                        b_InterruptEnable = (BYTE) data[1];\r
-                   /********************************/\r
-                   /* Test the interrupt selection */\r
-                   /********************************/\r
-\r
-                   if ((b_InterruptEnable == APCI1710_ENABLE) || (b_InterruptEnable == APCI1710_DISABLE))\r
-                      {\r
-                      if (b_InterruptEnable == APCI1710_ENABLE)\r
-                         {\r
+                                     outl((DWORD) b_TimerMode,devpriv->s_BoardInfos.
+                                       ui_Address + 16 + (b_TimerNbr * 4) + (64 * b_ModulNbr));
+      
+                                     /**************************/
+                                     /* Write the reload value */
+                                     /**************************/
+      
+                               
+                                      outl(ul_ReloadValue,devpriv->s_BoardInfos.
+                                             ui_Address + 0 + (b_TimerNbr * 4) + (64 * b_ModulNbr));
+                                      //BEGIN JK 27.10.03 : Add the possibility to use a 40 Mhz quartz
+                                     } // if (dw_Test == 1)
+                                  else
+                                     {
+                                     /****************************************/
+                                     /* Input timer clock selection is wrong */
+                                     /****************************************/
+
+                                     i_ReturnValue = -6;
+                                     } // if (dw_Test == 1)
+                                   //END JK 27.10.03 : Add the possibility to use a 40 Mhz quartz
+                               } // if ((b_HardwareGateLevel == 0) || (b_HardwareGateLevel == 1))
+                            else
+                               {
+                               /***********************************************/
+                               /* Selection from hardware gate level is wrong */
+                               /***********************************************/
+
+                                DPRINTK("Selection from hardware gate level is wrong\n");
+                               i_ReturnValue = -9;
+                               } // if ((b_HardwareGateLevel == 0) || (b_HardwareGateLevel == 1))
+                            } // if ((b_OutputLevel == 0) || (b_OutputLevel == 1))
+                         else
+                            {
+                            /**********************************************/
+                            /* Selection from output clock level is wrong */
+                            /**********************************************/
+
+                             DPRINTK("Selection from output clock level is wrong\n");
+                            i_ReturnValue = -8;
+                            } // if ((b_OutputLevel == 0) || (b_OutputLevel == 1))
+                         } // if ((b_InputClockLevel == 0) || (b_InputClockLevel == 1))
+                      else
+                         {
+                         /*********************************************/
+                         /* Selection from input clock level is wrong */
+                         /*********************************************/
+
+                          DPRINTK("Selection from input clock level is wrong\n");
+                         i_ReturnValue = -7;
+                         } // if ((b_InputClockLevel == 0) || (b_InputClockLevel == 1))
+                      }
+                   else
+                      {
+                      /****************************************/
+                      /* Input timer clock selection is wrong */
+                      /****************************************/
+
+                       DPRINTK("Input timer clock selection is wrong\n");
+                      i_ReturnValue = -6;
+                      }
+                   }
+                else
+                   {
+                   /****************************************/
+                   /* Input timer clock selection is wrong */
+                   /****************************************/
+
+                    DPRINTK("Input timer clock selection is wrong\n");
+                   i_ReturnValue = -6;
+                   }
+                } // if ((b_TimerMode >= 0) && (b_TimerMode <= 5))
+              else
+                {
+                /*********************************/
+                /* Timer mode selection is wrong */
+                /*********************************/
+
+                 DPRINTK("Timer mode selection is wrong\n");
+                i_ReturnValue = -5;
+                } // if ((b_TimerMode >= 0) && (b_TimerMode <= 5))
+              } // if ((b_TimerNbr >= 0) && (b_TimerNbr <= 2))
+          else
+              {
+              /*************************/
+              /* Timer selection wrong */
+              /*************************/
+
+              DPRINTK("Timer selection wrong\n");
+              i_ReturnValue = -3;
+              } // if ((b_TimerNbr >= 0) && (b_TimerNbr <= 2))
+          }
+       else
+          {
+          /************************************/
+          /* The module is not a TIMER module */
+          /************************************/
+
+           DPRINTK("The module is not a TIMER module\n");   
+          i_ReturnValue = -4;
+          }
+       }
+       else
+          {
+          /***********************/
+          /* Module number error */
+          /***********************/
+
+          DPRINTK("Module number error\n");
+          i_ReturnValue = -2;
+          }
+
+       return (i_ReturnValue);
+       }
+
+
+/*
++----------------------------------------------------------------------------+
+| Function Name     : _INT_     i_APCI1710_EnableTimer                       |
+|                               (BYTE_ b_BoardHandle,                        |
+|                                BYTE_ b_ModulNbr,                           |
+|                                BYTE_ b_TimerNbr,                           |
+|                                BYTE_ b_InterruptEnable)    
+INT i_APCI1710_InsnWriteEnableDisableTimer(comedi_device *dev,comedi_subdevice *s,
+       comedi_insn *insn,lsampl_t *data)                |
++----------------------------------------------------------------------------+
+| Task              : Enable OR Disable the Timer (b_TimerNbr) from selected module     |
+|                     (b_ModulNbr). You must calling the                     |
+|                     "i_APCI1710_InitTimer" function be for you call this   |
+|                     function. If you enable the timer interrupt, the timer |
+|                     generate a interrupt after the timer value reach       |
+|                     the zero. See function "i_APCI1710_SetBoardIntRoutineX"|
++----------------------------------------------------------------------------+
+| Input Parameters  : BYTE_   b_BoardHandle     : Handle of board            |
+|                                                 APCI-1710                  |
+|                     BYTE_   b_ModulNbr        : Selected module number     |
+|                                                 (0 to 3)                   |
+|                     BYTE_   b_TimerNbr        : Timer number to enable     |
+|                                                 (0 to 2)                   |
+|                     BYTE_   b_InterruptEnable : Enable or disable the      |
+|                                                 timer interrupt.           |
+|                                                 APCI1710_ENABLE :          |
+|                                                 Enable the timer interrupt |
+|                                                 APCI1710_DISABLE :         |
+|                                                 Disable the timer interrupt|
+i_ReturnValue=insn->n;
+       b_ModulNbr        = (BYTE) CR_AREF(insn->chanspec);
+       b_TimerNbr                = (BYTE) CR_CHAN(insn->chanspec);
+       b_ActionType      = (BYTE) data[0]; // enable disable 
++----------------------------------------------------------------------------+
+| Output Parameters : -                                                      |
++----------------------------------------------------------------------------+
+| Return Value      : 0: No error                                            |
+|                    -1: The handle parameter of the board is wrong          |
+|                    -2: Module selection wrong                              |
+|                    -3: Timer selection wrong                               |
+|                    -4: The module is not a TIMER module                    |
+|                    -5: Timer not initialised see function                  |
+|                        "i_APCI1710_InitTimer"                              |
+|                    -6: Interrupt parameter is wrong                        |
+|                    -7: Interrupt function not initialised.                 |
+|                        See function "i_APCI1710_SetBoardIntRoutineX"       |
++----------------------------------------------------------------------------+
+*/
+
+INT i_APCI1710_InsnWriteEnableDisableTimer(comedi_device *dev,comedi_subdevice *s,
+       comedi_insn *insn,lsampl_t *data)
+       {
+       INT             i_ReturnValue = 0;
+       DWORD   dw_DummyRead;
+       BYTE    b_ModulNbr;
+       BYTE    b_TimerNbr;
+       BYTE    b_ActionType;
+       BYTE    b_InterruptEnable;
+
+       i_ReturnValue=insn->n;
+       b_ModulNbr        = (BYTE) CR_AREF(insn->chanspec);
+       b_TimerNbr                = (BYTE) CR_CHAN(insn->chanspec);
+       b_ActionType      = (BYTE) data[0]; // enable disable 
+       /**************************/
+       /* Test the module number */
+       /**************************/
+
+       if (b_ModulNbr < 4)
+          {
+          /***********************/
+          /* Test if 82X54 timer */
+          /***********************/
+
+          if ((devpriv->s_BoardInfos.
+               dw_MolduleConfiguration [b_ModulNbr] & 0xFFFF0000UL) == APCI1710_82X54_TIMER)
+             {
+             /*************************/
+             /* Test the timer number */
+             /*************************/
+
+             if (b_TimerNbr <= 2)
+                {
+                /*****************************/
+                /* Test if timer initialised */
+                /*****************************/
+
+                if (devpriv->s_ModuleInfo [b_ModulNbr].
+                    s_82X54ModuleInfo.
+                    s_82X54TimerInfo  [b_TimerNbr].
+                    b_82X54Init == 1)
+                   {
+
+             switch(b_ActionType)
+             { 
+                        case APCI1710_ENABLE:
+
+                        b_InterruptEnable = (BYTE) data[1];
+                   /********************************/
+                   /* Test the interrupt selection */
+                   /********************************/
+
+                   if ((b_InterruptEnable == APCI1710_ENABLE) || (b_InterruptEnable == APCI1710_DISABLE))
+                      {
+                      if (b_InterruptEnable == APCI1710_ENABLE)
+                         {
                          
-                            dw_DummyRead=inl(devpriv->s_BoardInfos.\r
-                                   ui_Address + 12 + (b_TimerNbr * 4) + (64 * b_ModulNbr));\r
-\r
-                            /************************/\r
-                            /* Enable the interrupt */\r
-                            /************************/\r
-\r
-                            devpriv->s_ModuleInfo [b_ModulNbr].\r
-                            s_82X54ModuleInfo.\r
-                            s_82X54TimerInfo  [b_TimerNbr].\r
-                            dw_ConfigurationWord = devpriv->s_ModuleInfo [b_ModulNbr].\r
-                                                   s_82X54ModuleInfo.\r
-                                                   s_82X54TimerInfo  [b_TimerNbr].\r
-                                                   dw_ConfigurationWord | 0x8;\r
-\r
-                            \r
-                                 outl(devpriv->s_ModuleInfo [b_ModulNbr].\r
-                                    s_82X54ModuleInfo.\r
-                                    s_82X54TimerInfo  [b_TimerNbr].\r
-                                    dw_ConfigurationWord,devpriv->s_BoardInfos.\r
+                            dw_DummyRead=inl(devpriv->s_BoardInfos.
+                                   ui_Address + 12 + (b_TimerNbr * 4) + (64 * b_ModulNbr));
+
+                            /************************/
+                            /* Enable the interrupt */
+                            /************************/
+
+                            devpriv->s_ModuleInfo [b_ModulNbr].
+                            s_82X54ModuleInfo.
+                            s_82X54TimerInfo  [b_TimerNbr].
+                            dw_ConfigurationWord = devpriv->s_ModuleInfo [b_ModulNbr].
+                                                   s_82X54ModuleInfo.
+                                                   s_82X54TimerInfo  [b_TimerNbr].
+                                                   dw_ConfigurationWord | 0x8;
+
+                            
+                                 outl(devpriv->s_ModuleInfo [b_ModulNbr].
+                                    s_82X54ModuleInfo.
+                                    s_82X54TimerInfo  [b_TimerNbr].
+                                    dw_ConfigurationWord,devpriv->s_BoardInfos.
                                     ui_Address + 32 + (b_TimerNbr * 4) + (64 * b_ModulNbr));
-                             devpriv->tsk_Current=current; // Save the current process task structure\r
-                          \r
+                             devpriv->tsk_Current=current; // Save the current process task structure
+                          
                           
-                         } // if (b_InterruptEnable == APCI1710_ENABLE)\r
-                      else\r
-                         {\r
-                         /*************************/\r
-                         /* Disable the interrupt */\r
-                         /*************************/\r
-\r
-                         devpriv->s_ModuleInfo [b_ModulNbr].\r
-                         s_82X54ModuleInfo.\r
-                         s_82X54TimerInfo  [b_TimerNbr].\r
-                         dw_ConfigurationWord = devpriv->s_ModuleInfo [b_ModulNbr].\r
-                                                s_82X54ModuleInfo.\r
-                                                s_82X54TimerInfo  [b_TimerNbr].\r
-                                                dw_ConfigurationWord & 0xF7;\r
-\r
-                         \r
-                         outl(devpriv->s_ModuleInfo [b_ModulNbr].\r
-                                 s_82X54ModuleInfo.\r
-                                 s_82X54TimerInfo  [b_TimerNbr].\r
-                                 dw_ConfigurationWord,devpriv->s_BoardInfos.\r
-                                 ui_Address + 32 + (b_TimerNbr * 4) + (64 * b_ModulNbr));\r
-\r
-                         /***************************/\r
-                         /* Save the interrupt flag */\r
-                         /***************************/\r
-\r
-                        devpriv->s_ModuleInfo [b_ModulNbr].\r
-                         s_82X54ModuleInfo.\r
-                         b_InterruptMask = devpriv->s_ModuleInfo [b_ModulNbr].\r
-                                           s_82X54ModuleInfo.\r
-                                               b_InterruptMask & (0xFF - (1 << b_TimerNbr));\r
-                         } // if (b_InterruptEnable == APCI1710_ENABLE)\r
-\r
-                      /***********************/\r
-                      /* Test if error occur */\r
-                      /***********************/\r
-\r
-                      if (i_ReturnValue >= 0)\r
-                         {\r
-                         /***************************/\r
-                         /* Save the interrupt flag */\r
-                         /***************************/\r
-\r
-                         devpriv->s_ModuleInfo [b_ModulNbr].\r
-                         s_82X54ModuleInfo.\r
-                         b_InterruptMask = devpriv->s_ModuleInfo [b_ModulNbr].\r
-                                           s_82X54ModuleInfo.\r
-                                           b_InterruptMask | ((1 & b_InterruptEnable) << b_TimerNbr);\r
-\r
-\r
-                         /********************/\r
-                         /* Enable the timer */\r
-                         /********************/\r
-\r
-                         \r
-                         outl(1,devpriv->s_BoardInfos.\r
-                                 ui_Address + 44 + (b_TimerNbr * 4) + (64 * b_ModulNbr));\r
-                         }\r
-                      }\r
-                   else\r
-                      {\r
-                      /********************************/\r
-                      /* Interrupt parameter is wrong */\r
-                      /********************************/\r
-\r                      DPRINTK("\n");
-                      i_ReturnValue = -6;\r
-                      }\r
-                          break;\r
-               case APCI1710_DISABLE:\r
-                       /***************************/\r
-                   /* Test the interrupt flag */\r
-                   /***************************/\r
-\r
-                   if (((devpriv->s_ModuleInfo [b_ModulNbr].\r
-                         s_82X54ModuleInfo.\r
-                         b_InterruptMask  >> b_TimerNbr) & 1) == 1)\r
-                      {\r
-                      /*************************/\r
-                      /* Disable the interrupt */\r
-                      /*************************/\r
-\r
-                      devpriv->s_ModuleInfo [b_ModulNbr].\r
-                      s_82X54ModuleInfo.\r
-                      s_82X54TimerInfo  [b_TimerNbr].\r
-                      dw_ConfigurationWord = devpriv->s_ModuleInfo [b_ModulNbr].\r
-                                             s_82X54ModuleInfo.\r
-                                             s_82X54TimerInfo  [b_TimerNbr].\r
-                                             dw_ConfigurationWord & 0xF7;\r
-\r
-                      \r
-                            outl(devpriv->s_ModuleInfo [b_ModulNbr].\r
-                              s_82X54ModuleInfo.\r
-                              s_82X54TimerInfo  [b_TimerNbr].\r
-                              dw_ConfigurationWord,devpriv->s_BoardInfos.\r
-                              ui_Address + 32 + (b_TimerNbr * 4) + (64 * b_ModulNbr));\r
-\r
-                      /***************************/\r
-                      /* Save the interrupt flag */\r
-                      /***************************/\r
-\r
-                      devpriv->s_ModuleInfo [b_ModulNbr].\r
-                      s_82X54ModuleInfo.\r
-                      b_InterruptMask = devpriv->s_ModuleInfo [b_ModulNbr].\r
-                                        s_82X54ModuleInfo.b_InterruptMask & (0xFF - (1 << b_TimerNbr));\r
-                      }\r
-\r
-                   /*********************/\r
-                   /* Disable the timer */\r
-                   /*********************/\r
-\r
+                         } // if (b_InterruptEnable == APCI1710_ENABLE)
+                      else
+                         {
+                         /*************************/
+                         /* Disable the interrupt */
+                         /*************************/
+
+                         devpriv->s_ModuleInfo [b_ModulNbr].
+                         s_82X54ModuleInfo.
+                         s_82X54TimerInfo  [b_TimerNbr].
+                         dw_ConfigurationWord = devpriv->s_ModuleInfo [b_ModulNbr].
+                                                s_82X54ModuleInfo.
+                                                s_82X54TimerInfo  [b_TimerNbr].
+                                                dw_ConfigurationWord & 0xF7;
+
+                         
+                         outl(devpriv->s_ModuleInfo [b_ModulNbr].
+                                 s_82X54ModuleInfo.
+                                 s_82X54TimerInfo  [b_TimerNbr].
+                                 dw_ConfigurationWord,devpriv->s_BoardInfos.
+                                 ui_Address + 32 + (b_TimerNbr * 4) + (64 * b_ModulNbr));
+
+                         /***************************/
+                         /* Save the interrupt flag */
+                         /***************************/
+
+                        devpriv->s_ModuleInfo [b_ModulNbr].
+                         s_82X54ModuleInfo.
+                         b_InterruptMask = devpriv->s_ModuleInfo [b_ModulNbr].
+                                           s_82X54ModuleInfo.
+                                               b_InterruptMask & (0xFF - (1 << b_TimerNbr));
+                         } // if (b_InterruptEnable == APCI1710_ENABLE)
+
+                      /***********************/
+                      /* Test if error occur */
+                      /***********************/
+
+                      if (i_ReturnValue >= 0)
+                         {
+                         /***************************/
+                         /* Save the interrupt flag */
+                         /***************************/
+
+                         devpriv->s_ModuleInfo [b_ModulNbr].
+                         s_82X54ModuleInfo.
+                         b_InterruptMask = devpriv->s_ModuleInfo [b_ModulNbr].
+                                           s_82X54ModuleInfo.
+                                           b_InterruptMask | ((1 & b_InterruptEnable) << b_TimerNbr);
+
+
+                         /********************/
+                         /* Enable the timer */
+                         /********************/
+
+                         
+                         outl(1,devpriv->s_BoardInfos.
+                                 ui_Address + 44 + (b_TimerNbr * 4) + (64 * b_ModulNbr));
+                         }
+                      }
+                   else
+                      {
+                      /********************************/
+                      /* Interrupt parameter is wrong */
+                      /********************************/
+
+                      DPRINTK("\n");
+                      i_ReturnValue = -6;
+                      }
+                          break;
+               case APCI1710_DISABLE:
+                       /***************************/
+                   /* Test the interrupt flag */
+                   /***************************/
+
+                   if (((devpriv->s_ModuleInfo [b_ModulNbr].
+                         s_82X54ModuleInfo.
+                         b_InterruptMask  >> b_TimerNbr) & 1) == 1)
+                      {
+                      /*************************/
+                      /* Disable the interrupt */
+                      /*************************/
+
+                      devpriv->s_ModuleInfo [b_ModulNbr].
+                      s_82X54ModuleInfo.
+                      s_82X54TimerInfo  [b_TimerNbr].
+                      dw_ConfigurationWord = devpriv->s_ModuleInfo [b_ModulNbr].
+                                             s_82X54ModuleInfo.
+                                             s_82X54TimerInfo  [b_TimerNbr].
+                                             dw_ConfigurationWord & 0xF7;
+
+                      
+                            outl(devpriv->s_ModuleInfo [b_ModulNbr].
+                              s_82X54ModuleInfo.
+                              s_82X54TimerInfo  [b_TimerNbr].
+                              dw_ConfigurationWord,devpriv->s_BoardInfos.
+                              ui_Address + 32 + (b_TimerNbr * 4) + (64 * b_ModulNbr));
+
+                      /***************************/
+                      /* Save the interrupt flag */
+                      /***************************/
+
+                      devpriv->s_ModuleInfo [b_ModulNbr].
+                      s_82X54ModuleInfo.
+                      b_InterruptMask = devpriv->s_ModuleInfo [b_ModulNbr].
+                                        s_82X54ModuleInfo.b_InterruptMask & (0xFF - (1 << b_TimerNbr));
+                      }
+
+                   /*********************/
+                   /* Disable the timer */
+                   /*********************/
+
                    
-                       outl(0,devpriv->s_BoardInfos.\r
-                           ui_Address + 44 + (b_TimerNbr * 4) + (64 * b_ModulNbr));\r
-                               break;    \r
-                        }// Switch end\r
-                   }\r
-                else\r
-                   {\r
-                   /**************************************/\r
-                   /* Timer not initialised see function */\r
-                   /**************************************/\r
-\r                      DPRINTK("Timer not initialised see function\n");
-                   i_ReturnValue = -5;\r
-                   }\r
-                }\r
-             else\r
-                {\r
-                /*************************/\r
-                /* Timer selection wrong */\r
-                /*************************/\r
-\r               DPRINTK("Timer selection wrong\n");
-                i_ReturnValue = -3;\r
-                } // if ((b_TimerNbr >= 0) && (b_TimerNbr <= 2))\r
-             }\r
-          else\r
-             {\r
-             /************************************/\r
-             /* The module is not a TIMER module */\r
-             /************************************/\r
-\r            DPRINTK("The module is not a TIMER module\n");
-             i_ReturnValue = -4;\r
-             }\r
-          }\r
-       else\r
-          {\r
-          /***********************/\r
-          /* Module number error */\r
-          /***********************/\r
-\r         DPRINTK("Module number error\n");
-          i_ReturnValue = -2;\r
-          }\r
-\r
-       return (i_ReturnValue);\r
-       }\r
-\r
-       \r
-/*\r
-+----------------------------------------------------------------------------+\r
-| Function Name     : _INT_     i_APCI1710_ReadAllTimerValue                 |\r
-|                                       (BYTE_     b_BoardHandle,            |\r
-|                                        BYTE_     b_ModulNbr,               |\r
-|                                        PULONG_ pul_TimerValueArray)\r
-INT i_APCI1710_InsnReadAllTimerValue(comedi_device *dev,comedi_subdevice *s,\r
-       comedi_insn *insn,lsampl_t *data)        |\r
-+----------------------------------------------------------------------------+\r
-| Task              : Return the all timer values from selected timer        |\r
-|                     module (b_ModulNbr).                                   |\r
-+----------------------------------------------------------------------------+\r
-| Input Parameters  : BYTE_   b_BoardHandle     : Handle of board            |\r
-|                                                 APCI-1710                  |\r
-|                     BYTE_   b_ModulNbr        : Selected module number     |\r
-|                                                 (0 to 3)                   |\r
-+----------------------------------------------------------------------------+\r
-| Output Parameters : PULONG_ pul_TimerValueArray : Timer value array.       |\r
-|                           Element 0 contain the timer 0 value.             |\r
-|                           Element 1 contain the timer 1 value.             |\r
-|                           Element 2 contain the timer 2 value.             |\r
-+----------------------------------------------------------------------------+\r
-| Return Value      : 0: No error                                            |\r
-|                    -1: The handle parameter of the board is wrong          |\r
-|                    -2: Module selection wrong                              |\r
-|                    -3: The module is not a TIMER module                    |\r
-|                    -4: Timer 0 not initialised see function                |\r
-|                        "i_APCI1710_InitTimer"                              |\r
-|                    -5: Timer 1 not initialised see function                |\r
-|                        "i_APCI1710_InitTimer"                              |\r
-|                    -6: Timer 2 not initialised see function                |\r
-|                        "i_APCI1710_InitTimer"                              |\r
-+----------------------------------------------------------------------------+\r
-*/\r
-\r
-INT i_APCI1710_InsnReadAllTimerValue(comedi_device *dev,comedi_subdevice *s,\r
-       comedi_insn *insn,lsampl_t *data)\r
-       {\r
-       INT i_ReturnValue = 0;\r
-       BYTE    b_ModulNbr,b_ReadType;\r
-       PULONG  pul_TimerValueArray;\r
-\r
-       b_ModulNbr=CR_AREF(insn->chanspec);\r
+                       outl(0,devpriv->s_BoardInfos.
+                           ui_Address + 44 + (b_TimerNbr * 4) + (64 * b_ModulNbr));
+                               break;    
+                        }// Switch end
+                   }
+                else
+                   {
+                   /**************************************/
+                   /* Timer not initialised see function */
+                   /**************************************/
+
+                       DPRINTK("Timer not initialised see function\n");
+                   i_ReturnValue = -5;
+                   }
+                }
+             else
+                {
+                /*************************/
+                /* Timer selection wrong */
+                /*************************/
+
+                DPRINTK("Timer selection wrong\n");
+                i_ReturnValue = -3;
+                } // if ((b_TimerNbr >= 0) && (b_TimerNbr <= 2))
+             }
+          else
+             {
+             /************************************/
+             /* The module is not a TIMER module */
+             /************************************/
+
+             DPRINTK("The module is not a TIMER module\n");
+             i_ReturnValue = -4;
+             }
+          }
+       else
+          {
+          /***********************/
+          /* Module number error */
+          /***********************/
+
+          DPRINTK("Module number error\n");
+          i_ReturnValue = -2;
+          }
+
+       return (i_ReturnValue);
+       }
+
+       
+/*
++----------------------------------------------------------------------------+
+| Function Name     : _INT_     i_APCI1710_ReadAllTimerValue                 |
+|                                       (BYTE_     b_BoardHandle,            |
+|                                        BYTE_     b_ModulNbr,               |
+|                                        PULONG_ pul_TimerValueArray)
+INT i_APCI1710_InsnReadAllTimerValue(comedi_device *dev,comedi_subdevice *s,
+       comedi_insn *insn,lsampl_t *data)        |
++----------------------------------------------------------------------------+
+| Task              : Return the all timer values from selected timer        |
+|                     module (b_ModulNbr).                                   |
++----------------------------------------------------------------------------+
+| Input Parameters  : BYTE_   b_BoardHandle     : Handle of board            |
+|                                                 APCI-1710                  |
+|                     BYTE_   b_ModulNbr        : Selected module number     |
+|                                                 (0 to 3)                   |
++----------------------------------------------------------------------------+
+| Output Parameters : PULONG_ pul_TimerValueArray : Timer value array.       |
+|                           Element 0 contain the timer 0 value.             |
+|                           Element 1 contain the timer 1 value.             |
+|                           Element 2 contain the timer 2 value.             |
++----------------------------------------------------------------------------+
+| Return Value      : 0: No error                                            |
+|                    -1: The handle parameter of the board is wrong          |
+|                    -2: Module selection wrong                              |
+|                    -3: The module is not a TIMER module                    |
+|                    -4: Timer 0 not initialised see function                |
+|                        "i_APCI1710_InitTimer"                              |
+|                    -5: Timer 1 not initialised see function                |
+|                        "i_APCI1710_InitTimer"                              |
+|                    -6: Timer 2 not initialised see function                |
+|                        "i_APCI1710_InitTimer"                              |
++----------------------------------------------------------------------------+
+*/
+
+INT i_APCI1710_InsnReadAllTimerValue(comedi_device *dev,comedi_subdevice *s,
+       comedi_insn *insn,lsampl_t *data)
+       {
+       INT i_ReturnValue = 0;
+       BYTE    b_ModulNbr,b_ReadType;
+       PULONG  pul_TimerValueArray;
+
+       b_ModulNbr=CR_AREF(insn->chanspec);
         b_ReadType=CR_CHAN(insn->chanspec);
-       pul_TimerValueArray=(PULONG) data;\r
-       i_ReturnValue=insn->n;\r
+       pul_TimerValueArray=(PULONG) data;
+       i_ReturnValue=insn->n;
         
         switch(b_ReadType)
         {
@@ -827,129 +951,137 @@ INT i_APCI1710_InsnReadAllTimerValue(comedi_device *dev,comedi_subdevice *s,
                                        ui_Read + 1) % APCI1710_SAVE_INTERRUPT;
 
          break;
-\r        
+
+        
          case APCI1710_TIMER_READALLTIMER:
-       /**************************/\r
-       /* Test the module number */\r
-       /**************************/\r       
-\r
-       if (b_ModulNbr < 4)\r
-          {\r
-          /***********************/\r
-          /* Test if 82X54 timer */\r
-          /***********************/\r
-\r
-          if ((devpriv->s_BoardInfos.\r
-               dw_MolduleConfiguration [b_ModulNbr] & 0xFFFF0000UL) == APCI1710_82X54_TIMER)\r
-             {\r
-             /********************************/\r
-             /* Test if timer 0 iniutialised */\r
-             /********************************/\r
-\r
-             if (devpriv->s_ModuleInfo [b_ModulNbr].\r
-                 s_82X54ModuleInfo.\r
-                 s_82X54TimerInfo  [0].\r
-                 b_82X54Init == 1)\r
-                {\r
-                /********************************/\r
-                /* Test if timer 1 iniutialised */\r
-                /********************************/\r
-\r
-                if (devpriv->s_ModuleInfo [b_ModulNbr].\r
-                    s_82X54ModuleInfo.\r
-                    s_82X54TimerInfo  [1].\r
-                    b_82X54Init == 1)\r
-                   {\r
-                   /********************************/\r
-                   /* Test if timer 2 iniutialised */\r
-                   /********************************/\r
-\r
-                   if (devpriv->s_ModuleInfo [b_ModulNbr].\r
-                       s_82X54ModuleInfo.\r
-                       s_82X54TimerInfo  [2].\r
-                       b_82X54Init == 1)\r
-                      {\r
-                      /*********************/\r
-                      /* Latch all counter */\r
-                      /*********************/\r
-\r
+       /**************************/
+       /* Test the module number */
+       /**************************/
+       
+
+       if (b_ModulNbr < 4)
+          {
+          /***********************/
+          /* Test if 82X54 timer */
+          /***********************/
+
+          if ((devpriv->s_BoardInfos.
+               dw_MolduleConfiguration [b_ModulNbr] & 0xFFFF0000UL) == APCI1710_82X54_TIMER)
+             {
+             /********************************/
+             /* Test if timer 0 iniutialised */
+             /********************************/
+
+             if (devpriv->s_ModuleInfo [b_ModulNbr].
+                 s_82X54ModuleInfo.
+                 s_82X54TimerInfo  [0].
+                 b_82X54Init == 1)
+                {
+                /********************************/
+                /* Test if timer 1 iniutialised */
+                /********************************/
+
+                if (devpriv->s_ModuleInfo [b_ModulNbr].
+                    s_82X54ModuleInfo.
+                    s_82X54TimerInfo  [1].
+                    b_82X54Init == 1)
+                   {
+                   /********************************/
+                   /* Test if timer 2 iniutialised */
+                   /********************************/
+
+                   if (devpriv->s_ModuleInfo [b_ModulNbr].
+                       s_82X54ModuleInfo.
+                       s_82X54TimerInfo  [2].
+                       b_82X54Init == 1)
+                      {
+                      /*********************/
+                      /* Latch all counter */
+                      /*********************/
+
                       
-                               outl(0x17,devpriv->s_BoardInfos.\r
-                              ui_Address + 12 + (64 * b_ModulNbr));\r
-\r
-                      /**************************/\r
-                      /* Read the timer 0 value */\r
-                      /**************************/\r
-\r
+                               outl(0x17,devpriv->s_BoardInfos.
+                              ui_Address + 12 + (64 * b_ModulNbr));
+
+                      /**************************/
+                      /* Read the timer 0 value */
+                      /**************************/
+
                       
-                               pul_TimerValueArray [0]=inl(devpriv->s_BoardInfos.\r
-                             ui_Address + 0 + (64 * b_ModulNbr));\r
-\r
-                      /**************************/\r
-                      /* Read the timer 1 value */\r
-                      /**************************/\r
-\r
+                               pul_TimerValueArray [0]=inl(devpriv->s_BoardInfos.
+                             ui_Address + 0 + (64 * b_ModulNbr));
+
+                      /**************************/
+                      /* Read the timer 1 value */
+                      /**************************/
+
                       
-                               pul_TimerValueArray [1]=inl(devpriv->s_BoardInfos.\r
-                             ui_Address + 4 + (64 * b_ModulNbr));\r
-\r
-                      /**************************/\r
-                      /* Read the timer 2 value */\r
-                      /**************************/\r
-\r
+                               pul_TimerValueArray [1]=inl(devpriv->s_BoardInfos.
+                             ui_Address + 4 + (64 * b_ModulNbr));
+
+                      /**************************/
+                      /* Read the timer 2 value */
+                      /**************************/
+
                       
-                               pul_TimerValueArray [2]=inl(devpriv->s_BoardInfos.\r
-                             ui_Address + 8 + (64 * b_ModulNbr));\r
-                      }\r
-                   else\r
-                      {\r
-                      /****************************************/\r
-                      /* Timer 2 not initialised see function */\r
-                      /****************************************/\r
-\r                      DPRINTK("Timer 2 not initialised see function\n");
-                      i_ReturnValue = -6;\r
-                      }\r
-                   }\r
-                else\r
-                   {\r
-                   /****************************************/\r
-                   /* Timer 1 not initialised see function */\r
-                   /****************************************/\r
-\r                      DPRINTK("Timer 1 not initialised see function\n");
-                   i_ReturnValue = -5;\r
-                   }\r
-                }\r
-             else\r
-                {\r
-                /****************************************/\r
-                /* Timer 0 not initialised see function */\r
-                /****************************************/\r
-\r               DPRINTK("Timer 0 not initialised see function\n");
-                i_ReturnValue = -4;\r
-                }\r
-             }\r
-          else\r
-             {\r
-             /************************************/\r
-             /* The module is not a TIMER module */\r
-             /************************************/\r
-\r            DPRINTK("The module is not a TIMER module\n");
-             i_ReturnValue = -3;\r
-             }\r
-          }\r
-       else\r
-          {\r
-          /***********************/\r
-          /* Module number error */\r
-          /***********************/\r
-\r         DPRINTK("Module number error\n");
-          i_ReturnValue = -2;\r
-          }\r
-\r       }// End of Switch
-       return (i_ReturnValue);\r
-       }\r
-\r
-\r
+                               pul_TimerValueArray [2]=inl(devpriv->s_BoardInfos.
+                             ui_Address + 8 + (64 * b_ModulNbr));
+                      }
+                   else
+                      {
+                      /****************************************/
+                      /* Timer 2 not initialised see function */
+                      /****************************************/
+
+                      DPRINTK("Timer 2 not initialised see function\n");
+                      i_ReturnValue = -6;
+                      }
+                   }
+                else
+                   {
+                   /****************************************/
+                   /* Timer 1 not initialised see function */
+                   /****************************************/
+
+                       DPRINTK("Timer 1 not initialised see function\n");
+                   i_ReturnValue = -5;
+                   }
+                }
+             else
+                {
+                /****************************************/
+                /* Timer 0 not initialised see function */
+                /****************************************/
+
+                DPRINTK("Timer 0 not initialised see function\n");
+                i_ReturnValue = -4;
+                }
+             }
+          else
+             {
+             /************************************/
+             /* The module is not a TIMER module */
+             /************************************/
+
+             DPRINTK("The module is not a TIMER module\n");
+             i_ReturnValue = -3;
+             }
+          }
+       else
+          {
+          /***********************/
+          /* Module number error */
+          /***********************/
+
+          DPRINTK("Module number error\n");
+          i_ReturnValue = -2;
+          }
+
+       }// End of Switch
+       return (i_ReturnValue);
+       }
+
+
 
 /*
 +----------------------------------------------------------------------------+
@@ -973,6 +1105,8 @@ comedi_insn *insn,lsampl_t *data)
        INT i_ReturnValue=0;
        b_BitsType=data[0];
 
+       printk ("\n82X54");
+       
        switch(b_BitsType)
        {
        case APCI1710_TIMER_READVALUE:
@@ -1068,7 +1202,7 @@ INT   i_APCI1710_ReadTimerValue       (comedi_device *dev,
              /* Test the timer number */
              /*************************/
 
-             if ((b_TimerNbr >= 0) && (b_TimerNbr <= 2))
+             if (b_TimerNbr <= 2)
                 {
                 /*****************************/
                 /* Test if timer initialised */
@@ -1196,7 +1330,7 @@ INT   i_APCI1710_GetTimerOutputLevel  (comedi_device *dev,
              /* Test the timer number */
              /*************************/
 
-             if ((b_TimerNbr >= 0) && (b_TimerNbr <= 2))
+             if (b_TimerNbr <= 2)
                 {
                 /*****************************/
                 /* Test if timer initialised */
@@ -1327,7 +1461,7 @@ INT   i_APCI1710_GetTimerProgressStatus       (comedi_device *dev,
              /* Test the timer number */
              /*************************/
 
-             if ((b_TimerNbr >= 0) && (b_TimerNbr <= 2))
+             if (b_TimerNbr <= 2)
                 {
                 /*****************************/
                 /* Test if timer initialised */
@@ -1456,7 +1590,7 @@ INT   i_APCI1710_GetTimerProgressStatus       (comedi_device *dev,
              /* Test the timer number */
              /*************************/
 
-             if ((b_TimerNbr >= 0) && (b_TimerNbr <= 2))
+             if (b_TimerNbr <= 2)
                 {
                 /*****************************/
                 /* Test if timer initialised */
@@ -1515,7 +1649,7 @@ INT   i_APCI1710_GetTimerProgressStatus       (comedi_device *dev,
        return (i_ReturnValue);
        }
 
-\r
-\r
-\r
-\r
+
+
+
+
index 4e958a5a7e1d4286715ba5c927c1f5224bceab69..6e4e2bdd8f14adc7d41ec02cea2ed32cb166531a 100644 (file)
@@ -1,39 +1,68 @@
-\r
-\r
-#define APCI1710_PCI_BUS_CLOCK                                         0\r
-#define APCI1710_FRONT_CONNECTOR_INPUT                         1\r
-#define APCI1710_TIMER_READVALUE                               0\r
-#define APCI1710_TIMER_GETOUTPUTLEVEL                  1\r
-#define APCI1710_TIMER_GETPROGRESSSTATUS               2\r
-#define APCI1710_TIMER_WRITEVALUE                              3\r
+/**
+@verbatim
+
+Copyright (C) 2004,2005  ADDI-DATA GmbH for the source code of this module. 
+        
+        ADDI-DATA GmbH 
+        Dieselstrasse 3 
+        D-77833 Ottersweier 
+        Tel: +19(0)7223/9493-0 
+        Fax: +49(0)7223/9493-92 
+        http://www.addi-data-com 
+        info@addi-data.com 
+
+This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+You shoud also find the complete GPL in the COPYING file accompanying this source code.
+
+@endverbatim
+*/
+   
+
+#define APCI1710_PCI_BUS_CLOCK                                         0
+#define APCI1710_FRONT_CONNECTOR_INPUT                         1
+#define APCI1710_TIMER_READVALUE                               0
+#define APCI1710_TIMER_GETOUTPUTLEVEL                  1
+#define APCI1710_TIMER_GETPROGRESSSTATUS               2
+#define APCI1710_TIMER_WRITEVALUE                              3
 
 #define APCI1710_TIMER_READINTERRUPT            1
 #define APCI1710_TIMER_READALLTIMER             2
 
-/*\r
-+----------------------------------------------------------------------------+\r
-|                       82X54 TIMER INISIALISATION FUNCTION                  |\r
-+----------------------------------------------------------------------------+\r
-*/\r
-\r
-\r
-\r
-INT i_APCI1710_InsnConfigInitTimer(comedi_device *dev,comedi_subdevice *s,\r
-       comedi_insn *insn,lsampl_t *data);\r
-\r
-
-\r
-INT i_APCI1710_InsnWriteEnableDisableTimer(comedi_device *dev,comedi_subdevice *s,\r
-       comedi_insn *insn,lsampl_t *data);\r
-/*\r
-+----------------------------------------------------------------------------+\r
-|                       82X54 READ FUNCTION                                  |\r
-+----------------------------------------------------------------------------+\r
-*/\r
-\r
-INT i_APCI1710_InsnReadAllTimerValue(comedi_device *dev,comedi_subdevice *s,\r
-       comedi_insn *insn,lsampl_t *data);\r
-\r
+// BEGIN JK 27.10.03 : Add the possibility to use a 40 Mhz quartz
+#ifndef APCI1710_10MHZ
+   #define APCI1710_10MHZ           10
+#endif
+// END JK 27.10.03 : Add the possibility to use a 40 Mhz quartz
+
+/*
++----------------------------------------------------------------------------+
+|                       82X54 TIMER INISIALISATION FUNCTION                  |
++----------------------------------------------------------------------------+
+*/
+
+
+
+INT i_APCI1710_InsnConfigInitTimer(comedi_device *dev,comedi_subdevice *s,
+       comedi_insn *insn,lsampl_t *data);
+
+
+
+INT i_APCI1710_InsnWriteEnableDisableTimer(comedi_device *dev,comedi_subdevice *s,
+       comedi_insn *insn,lsampl_t *data);
+/*
++----------------------------------------------------------------------------+
+|                       82X54 READ FUNCTION                                  |
++----------------------------------------------------------------------------+
+*/
+
+INT i_APCI1710_InsnReadAllTimerValue(comedi_device *dev,comedi_subdevice *s,
+       comedi_insn *insn,lsampl_t *data);
+
 
 INT    i_APCI1710_InsnBitsTimer(comedi_device *dev,comedi_subdevice *s,
 comedi_insn *insn,lsampl_t *data);
@@ -66,4 +95,4 @@ INT   i_APCI1710_GetTimerProgressStatus       (comedi_device *dev,
 INT   i_APCI1710_WriteTimerValue      (comedi_device *dev,
                                         BYTE   b_ModulNbr,
                                         BYTE   b_TimerNbr,
-                                        ULONG ul_WriteValue);
\ No newline at end of file
+                                        ULONG ul_WriteValue);
index 998f86a7c4425213c4999cea9c2b11cf3b936502..da805ae8819ca712673df099a73bef6811d94260 100644 (file)
@@ -1,14 +1,38 @@
+/**\r
+@verbatim\r
+\r
+Copyright (C) 2004,2005  ADDI-DATA GmbH for the source code of this module. \r
+        \r
+        ADDI-DATA GmbH \r
+        Dieselstrasse 3 \r
+        D-77833 Ottersweier \r
+        Tel: +19(0)7223/9493-0 \r
+        Fax: +49(0)7223/9493-92 \r
+        http://www.addi-data-com \r
+        info@addi-data.com \r
+\r
+This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.\r
+\r
+This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.\r
+\r
+You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+\r
+You shoud also find the complete GPL in the COPYING file accompanying this source code.\r
+\r
+@endverbatim\r
+*/\r
 /*\r
+    \r
   +-----------------------------------------------------------------------+\r
   | (C) ADDI-DATA GmbH          Dieselstraße 3       D-77833 Ottersweier  |\r
   +-----------------------------------------------------------------------+\r
   | Tel : +49 (0) 7223/9493-0     | email    : info@addi-data.com         |\r
   | Fax : +49 (0) 7223/9493-92    | Internet : http://www.addi-data.com   |\r
   +-----------------------------------------------------------------------+\r
-  | Project   : API APCI1710      |     Compiler   : BORLANDC/MICROSOFT C |\r
-  | Module name : CHRONO.C        |     Version    : 3.1     / 6.0        |\r
+  | Project     : API APCI1710    | Compiler : gcc                        |\r
+  | Module name : CHRONO.C        | Version  : 2.96                       |\r
   +-------------------------------+---------------------------------------+\r
-  | Author    : S.WEBER           |     Date       : 06.07.98             |\r
+  | Project manager: Eric Stolz   | Date     :  02/12/2002                |\r
   +-----------------------------------------------------------------------+\r
   | Description :   APCI-1710 chronometer module                          |\r
   |                                                                       |\r
@@ -45,7 +69,7 @@
 |                                        BYTE_     b_TimingUnit,             |\r
 |                                        ULONG_   ul_TimingInterval,         |\r
 |                                        PULONG_ pul_RealTimingInterval) \r
-
+\r
 +----------------------------------------------------------------------------+\r
 | Task              : Configure the chronometer operating mode (b_ChronoMode)|\r
 |                     from selected module (b_ModulNbr).                     |\r
 +----------------------------------------------------------------------------+\r
 */\r
 \r
-
+\r
 \r
 INT i_APCI1710_InsnConfigInitChrono(comedi_device *dev,comedi_subdevice *s,\r
        comedi_insn *insn,lsampl_t *data)\r
        {\r
-       INT    i_ReturnValue = 0;\r
-       ULONG ul_TimerValue,ul_TimingInterval,ul_RealTimingInterval;\r
-       double d_RealTimingInterval;\r
+       INT    i_ReturnValue        = 0;\r
+       ULONG ul_TimerValue         = 0;\r
+       ULONG ul_TimingInterval     = 0;\r
+       ULONG ul_RealTimingInterval = 0;\r
+       double d_RealTimingInterval = 0;\r
        DWORD dw_ModeArray [8] = {0x01, 0x05, 0x00, 0x04, 0x02, 0x0E, 0x0A, 0x06};\r
        BYTE   b_ModulNbr,b_ChronoMode,b_PCIInputClock,b_TimingUnit;\r
-\r       PULONG pul_RealTimingInterval;
-
+\r
        b_ModulNbr        = CR_AREF(insn->chanspec);\r
        b_ChronoMode      = (BYTE)  data[0];\r
        b_PCIInputClock   = (BYTE)  data[1];\r
@@ -143,7 +168,7 @@ INT i_APCI1710_InsnConfigInitChrono(comedi_device *dev,comedi_subdevice *s,
              /* Test the chronometer mode */\r
              /*****************************/\r
 \r
-             if (b_ChronoMode >= 0 && b_ChronoMode <= 7)\r
+             if (b_ChronoMode <= 7)\r
                 {\r
                 /**************************/\r
                 /* Test the PCI bus clock */\r
@@ -157,7 +182,7 @@ INT i_APCI1710_InsnConfigInitChrono(comedi_device *dev,comedi_subdevice *s,
                    /* Test the timing unity */\r
                    /*************************/\r
 \r
-                   if ((b_TimingUnit >= 0) && (b_TimingUnit <= 4))\r
+                   if (b_TimingUnit <= 4)\r
                       {\r
                       /**********************************/\r
                       /* Test the base timing selection */\r
@@ -183,18 +208,20 @@ INT i_APCI1710_InsnConfigInitChrono(comedi_device *dev,comedi_subdevice *s,
                          /* Test the board version */\r
                          /**************************/\r
 \r
-                         if ((b_PCIInputClock == APCI1710_40MHZ) && (devpriv->s_BoardInfos.\r
-                                                                     b_BoardVersion > 0) ||\r
+                         if (((b_PCIInputClock == APCI1710_40MHZ) && (devpriv->s_BoardInfos.\r
+                                                                     b_BoardVersion > 0)) ||\r
                              (b_PCIInputClock != APCI1710_40MHZ))\r
                             {\r
                             /************************/\r
                             /* Test the TOR version */\r
                             /************************/\r
 \r
-                            if ((b_PCIInputClock == APCI1710_40MHZ) && ((devpriv->s_BoardInfos.\r
-                                                                         dw_MolduleConfiguration [b_ModulNbr] & 0xFFFF) >= 0x3131) ||\r
+                            if (((b_PCIInputClock == APCI1710_40MHZ) && ((devpriv->s_BoardInfos.\r
+                                                                         dw_MolduleConfiguration [b_ModulNbr] & 0xFFFF) >= 0x3131)) ||\r
                                 (b_PCIInputClock != APCI1710_40MHZ))\r
                                {\r
+                               fpu_begin ();\r
+                               \r
                                /****************************************/\r
                                /* Calculate the timer 0 division fator */\r
                                /****************************************/\r
@@ -229,7 +256,7 @@ INT i_APCI1710_InsnConfigInitChrono(comedi_device *dev,comedi_subdevice *s,
                                           ul_RealTimingInterval = (ULONG) (ul_TimerValue / (0.001 * (double) b_PCIInputClock));\r
                                           d_RealTimingInterval = (double) ul_TimerValue / (0.001 * (double) b_PCIInputClock);\r
 \r
-                                          if ((double) ((double) ul_TimerValue / (0.001 * (double) b_PCIInputClock)) >= (double) ((double) *pul_RealTimingInterval + 0.5))\r
+                                          if ((double) ((double) ul_TimerValue / (0.001 * (double) b_PCIInputClock)) >= (double) ((double) ul_RealTimingInterval + 0.5))\r
                                              {\r
                                              ul_RealTimingInterval = ul_RealTimingInterval + 1;\r
                                              }\r
@@ -271,7 +298,7 @@ INT i_APCI1710_InsnConfigInitChrono(comedi_device *dev,comedi_subdevice *s,
                                           ul_RealTimingInterval = (ULONG) (ul_TimerValue / (1.0 * (double) b_PCIInputClock));\r
                                           d_RealTimingInterval = (double) ul_TimerValue / ((double) 1.0 * (double) b_PCIInputClock);\r
 \r
-                                          if ((double) ((double) ul_TimerValue / (1.0 * (double) b_PCIInputClock)) >= (double) ((double) *pul_RealTimingInterval + 0.5))\r
+                                          if ((double) ((double) ul_TimerValue / (1.0 * (double) b_PCIInputClock)) >= (double) ((double) ul_RealTimingInterval + 0.5))\r
                                              {\r
                                              ul_RealTimingInterval = ul_RealTimingInterval + 1;\r
                                              }\r
@@ -314,7 +341,7 @@ INT i_APCI1710_InsnConfigInitChrono(comedi_device *dev,comedi_subdevice *s,
                                           ul_RealTimingInterval = (ULONG) (ul_TimerValue / (1000.0 * (double) b_PCIInputClock));\r
                                           d_RealTimingInterval = (double) ul_TimerValue / (1000.0 * (double) b_PCIInputClock);\r
 \r
-                                          if ((double) ((double) ul_TimerValue / (1000.0 * (double) b_PCIInputClock)) >= (double) ((double) *pul_RealTimingInterval + 0.5))\r
+                                          if ((double) ((double) ul_TimerValue / (1000.0 * (double) b_PCIInputClock)) >= (double) ((double) ul_RealTimingInterval + 0.5))\r
                                              {\r
                                              ul_RealTimingInterval = ul_RealTimingInterval + 1;\r
                                              }\r
@@ -356,7 +383,7 @@ INT i_APCI1710_InsnConfigInitChrono(comedi_device *dev,comedi_subdevice *s,
                                           ul_RealTimingInterval = (ULONG) (ul_TimerValue / (1000000.0 * (double) b_PCIInputClock));\r
                                           d_RealTimingInterval = (double) ul_TimerValue / (1000000.0 * (double) b_PCIInputClock);\r
 \r
-                                          if ((double) ((double) ul_TimerValue / (1000000.0 * (double) b_PCIInputClock)) >= (double) ((double) *pul_RealTimingInterval + 0.5))\r
+                                          if ((double) ((double) ul_TimerValue / (1000000.0 * (double) b_PCIInputClock)) >= (double) ((double) ul_RealTimingInterval + 0.5))\r
                                              {\r
                                              ul_RealTimingInterval = ul_RealTimingInterval + 1;\r
                                              }\r
@@ -399,7 +426,7 @@ INT i_APCI1710_InsnConfigInitChrono(comedi_device *dev,comedi_subdevice *s,
                                           ul_RealTimingInterval = (ULONG) (ul_TimerValue / (1000000.0 * (double) b_PCIInputClock)) / 60;\r
                                           d_RealTimingInterval = ((double) ul_TimerValue / (0.001 * (double) b_PCIInputClock)) / 60.0;\r
 \r
-                                          if ((double) (((double) ul_TimerValue / (1000000.0 * (double) b_PCIInputClock)) / 60.0) >= (double) ((double) *pul_RealTimingInterval + 0.5))\r
+                                          if ((double) (((double) ul_TimerValue / (1000000.0 * (double) b_PCIInputClock)) / 60.0) >= (double) ((double) ul_RealTimingInterval + 0.5))\r
                                              {\r
                                              ul_RealTimingInterval = ul_RealTimingInterval + 1;\r
                                              }\r
@@ -415,6 +442,8 @@ INT i_APCI1710_InsnConfigInitChrono(comedi_device *dev,comedi_subdevice *s,
                                        break;\r
                                   }\r
 \r
+                               fpu_end ();\r
+                               \r
                                /****************************/\r
                                /* Save the PCI input clock */\r
                                /****************************/\r
@@ -468,7 +497,7 @@ INT i_APCI1710_InsnConfigInitChrono(comedi_device *dev,comedi_subdevice *s,
                                /* Write timer 0 value */\r
                                /***********************/\r
 \r
-                               
+                               \r
                                outl(ul_TimerValue,devpriv->s_BoardInfos.\r
                                        ui_Address + (64 * b_ModulNbr));\r
 \r
@@ -485,7 +514,8 @@ INT i_APCI1710_InsnConfigInitChrono(comedi_device *dev,comedi_subdevice *s,
                                /***********************************************/\r
                                /* TOR version error for 40MHz clock selection */\r
                                /***********************************************/\r
-\r                       DPRINTK("TOR version error for 40MHz clock selection\n");
+\r
+                       DPRINTK("TOR version error for 40MHz clock selection\n");\r
                                i_ReturnValue = -9;\r
                                }\r
                             }\r
@@ -494,7 +524,8 @@ INT i_APCI1710_InsnConfigInitChrono(comedi_device *dev,comedi_subdevice *s,
                             /**************************************************************/\r
                             /* You can not used the 40MHz clock selection wich this board */\r
                             /**************************************************************/\r
-\r                               DPRINTK("You can not used the 40MHz clock selection wich this board\n");
+\r
+                                DPRINTK("You can not used the 40MHz clock selection wich this board\n");\r
                             i_ReturnValue = -8;\r
                             }\r
                          }\r
@@ -503,7 +534,8 @@ INT i_APCI1710_InsnConfigInitChrono(comedi_device *dev,comedi_subdevice *s,
                          /**********************************/\r
                          /* Base timing selection is wrong */\r
                          /**********************************/\r
-\r                        DPRINTK("Base timing selection is wrong\n");
+\r
+                         DPRINTK("Base timing selection is wrong\n");\r
                          i_ReturnValue = -7;\r
                          }\r
                       } // if ((b_TimingUnit >= 0) && (b_TimingUnit <= 4))\r
@@ -512,7 +544,8 @@ INT i_APCI1710_InsnConfigInitChrono(comedi_device *dev,comedi_subdevice *s,
                       /***********************************/\r
                       /* Timing unity selection is wrong */\r
                       /***********************************/\r
-\r                         DPRINTK("Timing unity selection is wrong\n");
+\r
+                          DPRINTK("Timing unity selection is wrong\n");\r
                       i_ReturnValue = -6;\r
                       } // if ((b_TimingUnit >= 0) && (b_TimingUnit <= 4))\r
                    } // if ((b_PCIInputClock == APCI1710_30MHZ) || (b_PCIInputClock == APCI1710_33MHZ))\r
@@ -521,7 +554,8 @@ INT i_APCI1710_InsnConfigInitChrono(comedi_device *dev,comedi_subdevice *s,
                    /*****************************************/\r
                    /* The selected PCI input clock is wrong */\r
                    /*****************************************/\r
-\r                      DPRINTK("The selected PCI input clock is wrong\n");
+\r
+                       DPRINTK("The selected PCI input clock is wrong\n");\r
                    i_ReturnValue = -5;\r
                    } // if ((b_PCIInputClock == APCI1710_30MHZ) || (b_PCIInputClock == APCI1710_33MHZ))\r
                 } // if (b_ChronoMode >= 0 && b_ChronoMode <= 7)\r
@@ -530,7 +564,8 @@ INT i_APCI1710_InsnConfigInitChrono(comedi_device *dev,comedi_subdevice *s,
                 /***************************************/\r
                 /* Chronometer mode selection is wrong */\r
                 /***************************************/\r
-               \rDPRINTK("Chronometer mode selection is wrong\n");
+               \r
+DPRINTK("Chronometer mode selection is wrong\n");\r
                 i_ReturnValue = -4;\r
                 } // if (b_ChronoMode >= 0 && b_ChronoMode <= 7)\r
              }\r
@@ -539,7 +574,8 @@ INT i_APCI1710_InsnConfigInitChrono(comedi_device *dev,comedi_subdevice *s,
              /******************************************/\r
              /* The module is not a Chronometer module */\r
              /******************************************/\r
-\r            DPRINTK("The module is not a Chronometer module\n");
+\r
+             DPRINTK("The module is not a Chronometer module\n");\r
              i_ReturnValue = -3;\r
              }\r
           }\r
@@ -548,7 +584,8 @@ INT i_APCI1710_InsnConfigInitChrono(comedi_device *dev,comedi_subdevice *s,
           /***********************/\r
           /* Module number error */\r
           /***********************/\r
-\r          DPRINTK("Module number error\n");
+\r
+          DPRINTK("Module number error\n");\r
           i_ReturnValue = -2;\r
           }\r
        data[0] = ul_RealTimingInterval;\r
@@ -614,18 +651,19 @@ comedi_subdevice *s,comedi_insn *insn,lsampl_t *data)                                              |
                       -8: data[0] wrong input    |\r
 +----------------------------------------------------------------------------+\r
 */\r
-\r\r
+\r
+\r
 INT i_APCI1710_InsnWriteEnableDisableChrono(comedi_device *dev,comedi_subdevice *s,\r
        comedi_insn *insn,lsampl_t *data)\r
        {\r
        INT i_ReturnValue = 0;\r
        BYTE b_ModulNbr,b_CycleMode,b_InterruptEnable,b_Action;\r
        b_ModulNbr                      =       CR_AREF(insn->chanspec);\r
-        b_Action            =(BYTE) data[0];
+        b_Action            =(BYTE) data[0];\r
        b_CycleMode                     =(BYTE) data[1];\r
        b_InterruptEnable       =(BYTE) data[2];\r
        i_ReturnValue           =   insn->n;\r
-       
+       \r
 \r
        \r
        /**************************/\r
@@ -655,7 +693,7 @@ INT i_APCI1710_InsnWriteEnableDisableChrono(comedi_device *dev,comedi_subdevice
          {\r
  \r
                 case APCI1710_ENABLE :\r
-                            
+                            \r
                 /*********************************/\r
                 /* Test the cycle mode parameter */\r
                 /*********************************/\r
@@ -668,8 +706,8 @@ INT i_APCI1710_InsnWriteEnableDisableChrono(comedi_device *dev,comedi_subdevice
 \r
                    if ((b_InterruptEnable == APCI1710_ENABLE) || (b_InterruptEnable == APCI1710_DISABLE))\r
                       {\r
-                   
-       
+                   \r
+       \r
                          /***************************/\r
                          /* Save the interrupt flag */\r
                          /***************************/\r
@@ -709,14 +747,14 @@ INT i_APCI1710_InsnWriteEnableDisableChrono(comedi_device *dev,comedi_subdevice
                                 outl(devpriv->s_ModuleInfo [b_ModulNbr].\r
                                     s_ChronoModuleInfo.dw_ConfigReg, devpriv->s_BoardInfos.\r
                                     ui_Address + 32 + (64 * b_ModulNbr));\r
-                         devpriv->tsk_Current=current; // Save the current process task structure
+                         devpriv->tsk_Current=current; // Save the current process task structure\r
                             }\r
 \r
                          /***********************************/\r
                          /* Enable or disable the interrupt */\r
                          /* Enable the chronometer          */\r
                          /***********************************/\r
-           
+           \r
                          outl(devpriv->s_ModuleInfo [b_ModulNbr].\r
                                  s_ChronoModuleInfo.dw_ConfigReg,devpriv->s_BoardInfos.\r
                                  ui_Address + 16 + (64 * b_ModulNbr));\r
@@ -725,7 +763,7 @@ INT i_APCI1710_InsnWriteEnableDisableChrono(comedi_device *dev,comedi_subdevice
                          /* Clear status register */\r
                          /*************************/\r
 \r
-                        
+                        \r
                          outl(0,devpriv->s_BoardInfos.ui_Address + 36 + (64 * b_ModulNbr));\r
                          \r
                    } // if ((b_InterruptEnable == APCI1710_ENABLE) || (b_InterruptEnable == APCI1710_DISABLE))\r
@@ -734,7 +772,8 @@ INT i_APCI1710_InsnWriteEnableDisableChrono(comedi_device *dev,comedi_subdevice
                       /********************************/\r
                       /* Interrupt parameter is wrong */\r
                       /********************************/\r
-\r                         DPRINTK("Interrupt parameter is wrong\n");
+\r
+                          DPRINTK("Interrupt parameter is wrong\n");\r
                       i_ReturnValue = -6;\r
                       } // if ((b_InterruptEnable == APCI1710_ENABLE) || (b_InterruptEnable == APCI1710_DISABLE))\r
                    } // if ((b_CycleMode == APCI1710_SINGLE) || (b_CycleMode == APCI1710_CONTINUOUS))\r
@@ -743,7 +782,8 @@ INT i_APCI1710_InsnWriteEnableDisableChrono(comedi_device *dev,comedi_subdevice
                    /***********************************************/\r
                    /* Chronometer acquisition mode cycle is wrong */\r
                    /***********************************************/\r
-\r                      DPRINTK("Chronometer acquisition mode cycle is wrong\n");
+\r
+                       DPRINTK("Chronometer acquisition mode cycle is wrong\n");\r
                    i_ReturnValue = -5;\r
                    } // if ((b_CycleMode == APCI1710_SINGLE) || (b_CycleMode == APCI1710_CONTINUOUS))\r
                 break;\r
@@ -765,7 +805,7 @@ INT i_APCI1710_InsnWriteEnableDisableChrono(comedi_device *dev,comedi_subdevice
                 /* Disable the chronometer */\r
                 /***************************/\r
 \r
-                
+                \r
                 outl(devpriv->s_ModuleInfo [b_ModulNbr].\r
                         s_ChronoModuleInfo.dw_ConfigReg, devpriv->s_BoardInfos.\r
                         ui_Address + 16 + (64 * b_ModulNbr));\r
@@ -781,11 +821,11 @@ INT i_APCI1710_InsnWriteEnableDisableChrono(comedi_device *dev,comedi_subdevice
                    /* Clear status register */\r
                    /*************************/\r
 \r
-                  
+                  \r
                        outl(0,devpriv->s_BoardInfos.ui_Address + 36 + (64 * b_ModulNbr));\r
                    }\r
                    break;\r
-
+\r
                 default:\r
                          DPRINTK("Inputs wrong! Enable or Disable chrono\n");\r
                          i_ReturnValue = -8;\r
@@ -796,7 +836,557 @@ INT i_APCI1710_InsnWriteEnableDisableChrono(comedi_device *dev,comedi_subdevice
                 /*******************************/\r
                 /* Chronometer not initialised */\r
                 /*******************************/\r
-\r                DPRINTK("Chronometer not initialised\n");
+\r
+                DPRINTK("Chronometer not initialised\n");\r
+                i_ReturnValue = -4;\r
+                }\r
+             }\r
+          else\r
+             {\r
+             /******************************************/\r
+             /* The module is not a Chronometer module */\r
+             /******************************************/\r
+\r
+             DPRINTK("The module is not a Chronometer module\n");      \r
+             i_ReturnValue = -3;\r
+             }\r
+          }\r
+       else\r
+          {\r
+          /***********************/\r
+          /* Module number error */\r
+          /***********************/\r
+\r
+          DPRINTK("Module number error\n");\r
+          i_ReturnValue = -2;\r
+          }\r
+\r
+      \r
+       return (i_ReturnValue);\r
+       }\r
+\r
+\r
+\r
+\r
+/*\r
++----------------------------------------------------------------------------+\r
+| Function Name     :INT       i_APCI1710_InsnReadChrono(comedi_device *dev,comedi_subdevice *s,\r
+comedi_insn *insn,lsampl_t *data)                   |\r
++----------------------------------------------------------------------------+\r
+| Task              : Read  functions for Timer                                     |\r
++----------------------------------------------------------------------------+\r
+| Input Parameters  : \r
++----------------------------------------------------------------------------+\r
+| Output Parameters : -                                                      |\r
++----------------------------------------------------------------------------+\r
+| Return Value      : \r
++----------------------------------------------------------------------------+\r
+*/\r
+\r
+INT    i_APCI1710_InsnReadChrono(comedi_device *dev,comedi_subdevice *s,\r
+comedi_insn *insn,lsampl_t *data)\r
+{\r
+       BYTE b_ReadType;\r
+       INT  i_ReturnValue=insn->n;\r
+        \r
+       b_ReadType=CR_CHAN(insn->chanspec);\r
+\r
+       switch(b_ReadType)\r
+       {\r
+       case APCI1710_CHRONO_PROGRESS_STATUS:\r
+               i_ReturnValue=i_APCI1710_GetChronoProgressStatus  (dev,\r
+                                                (BYTE)    CR_AREF(insn->chanspec),\r
+                                                (PBYTE)  &data[0]);\r
+       break;\r
+\r
+       case APCI1710_CHRONO_READVALUE:\r
+               i_ReturnValue=i_APCI1710_ReadChronoValue      (dev,\r
+                                        (BYTE)    CR_AREF(insn->chanspec),\r
+                                        (UINT)    insn->unused[0],\r
+                                        (PBYTE)   &data[0],\r
+                                        (PULONG) &data[1]);\r
+       break;\r
+\r
+       case APCI1710_CHRONO_CONVERTVALUE:\r
+               i_ReturnValue=i_APCI1710_ConvertChronoValue     (dev,\r
+                                        (BYTE)    CR_AREF(insn->chanspec),\r
+                                        (ULONG)   insn->unused[0],\r
+                                        (PULONG)  &data[0],\r
+                                        (PBYTE)   &data[1],\r
+                                        (PBYTE)   &data[2],\r
+                                        (PUINT)  &data[3],\r
+                                        (PUINT)  &data[4],\r
+                                        (PUINT)  &data[5]);\r
+       break;\r
+        \r
+        case APCI1710_CHRONO_READINTERRUPT:\r
+                         printk("In Chrono Read Interrupt\n");\r
+\r
+                         data[0]=devpriv->s_InterruptParameters.\r
+                                                     s_FIFOInterruptParameters [devpriv->\r
+                                                                                s_InterruptParameters.\r
+                                                                                ui_Read].b_OldModuleMask;\r
+                         data[1]=devpriv->s_InterruptParameters.\r
+                                                     s_FIFOInterruptParameters [devpriv->\r
+                                                                                s_InterruptParameters.\r
+                                                                                ui_Read].ul_OldInterruptMask;\r
+                         data[2]=devpriv->s_InterruptParameters.\r
+                                                     s_FIFOInterruptParameters [devpriv->\r
+                                                                                s_InterruptParameters.\r
+                                                                                ui_Read].ul_OldCounterLatchValue;\r
+\r
+                            \r
+                            /**************************/\r
+                            /* Increment the read FIFO */\r
+                            /***************************/\r
+\r
+                            devpriv->\r
+                            s_InterruptParameters.\r
+                            ui_Read = (devpriv->\r
+                                       s_InterruptParameters.\r
+                                       ui_Read + 1) % APCI1710_SAVE_INTERRUPT;\r
+        break;\r
+    \r
+       default:\r
+               printk("ReadType Parameter wrong\n");\r
+       }\r
+\r
+       if(i_ReturnValue>=0) i_ReturnValue =insn->n;\r
+       return (i_ReturnValue); \r
+\r
+}\r
+\r
+\r
+\r
+/*\r
++----------------------------------------------------------------------------+\r
+| Function Name     : _INT_ i_APCI1710_GetChronoProgressStatus               |\r
+|                               (BYTE_    b_BoardHandle,                     |\r
+|                                BYTE_    b_ModulNbr,                        |\r
+|                                PBYTE_  pb_ChronoStatus)                    |\r
++----------------------------------------------------------------------------+\r
+| Task              : Return the chronometer status (pb_ChronoStatus) from   |\r
+|                     selected chronometer module (b_ModulNbr).              |\r
++----------------------------------------------------------------------------+\r
+| Input Parameters  : BYTE_ b_BoardHandle  : Handle of board APCI-1710       |\r
+|                     BYTE_ b_ModulNbr     : Selected module number (0 to 3) |\r
++----------------------------------------------------------------------------+\r
+| Output Parameters : PULONG_  pb_ChronoStatus : Return the chronometer      |\r
+|                                                status.                     |\r
+|                                                0 : Measurement not started.|\r
+|                                                    No start signal occur.  |\r
+|                                                1 : Measurement started.    |\r
+|                                                    A start signal occur.   |\r
+|                                                2 : Measurement stopped.    |\r
+|                                                    A stop signal occur.    |\r
+|                                                    The measurement is      |\r
+|                                                    terminate.              |\r
+|                                                3: A overflow occur. You    |\r
+|                                                   must change the base     |\r
+|                                                   timing witch the         |\r
+|                                                   function                 |\r
+|                                                   "i_APCI1710_InitChrono"  |\r
++----------------------------------------------------------------------------+\r
+| Return Value      :  0: No error                                           |\r
+|                     -1: The handle parameter of the board is wrong         |\r
+|                     -2: Module selection wrong                             |\r
+|                     -3: The module is not a Chronometer module             |\r
+|                     -4: Chronometer not initialised see function           |\r
+|                         "i_APCI1710_InitChrono"                            |\r
++----------------------------------------------------------------------------+\r
+*/\r
+\r
+INT   i_APCI1710_GetChronoProgressStatus      (comedi_device *dev,\r
+                                                BYTE    b_ModulNbr,\r
+                                                PBYTE  pb_ChronoStatus)\r
+       {\r
+       INT    i_ReturnValue = 0;\r
+       DWORD dw_Status;\r
+       \r
+       /**************************/\r
+       /* Test the module number */\r
+       /**************************/\r
+\r
+       if (b_ModulNbr < 4)\r
+          {\r
+          /***********************/\r
+          /* Test if chronometer */\r
+          /***********************/\r
+\r
+          if ((devpriv->\r
+               s_BoardInfos.\r
+               dw_MolduleConfiguration [b_ModulNbr] & 0xFFFF0000UL) == APCI1710_CHRONOMETER)\r
+             {\r
+             /***********************************/\r
+             /* Test if chronometer initialised */\r
+             /***********************************/\r
+\r
+             if (devpriv->\r
+                 s_ModuleInfo [b_ModulNbr].\r
+                 s_ChronoModuleInfo.\r
+                 b_ChronoInit == 1)\r
+                {\r
+               \r
+               dw_Status=inl(devpriv->s_BoardInfos.\r
+                       ui_Address + 8 + (64 * b_ModulNbr));\r
+\r
+                /********************/\r
+                /* Test if overflow */\r
+                /********************/\r
+\r
+                if ((dw_Status & 8) == 8)\r
+                   {\r
+                   /******************/\r
+                   /* Overflow occur */\r
+                   /******************/\r
+\r
+                   *pb_ChronoStatus = 3;\r
+                   } // if ((dw_Status & 8) == 8)\r
+                else\r
+                   {\r
+                   /*******************************/\r
+                   /* Test if measurement stopped */\r
+                   /*******************************/\r
+\r
+                   if ((dw_Status & 2) == 2)\r
+                      {\r
+                      /***********************/\r
+                      /* A stop signal occur */\r
+                      /***********************/\r
+\r
+                      *pb_ChronoStatus = 2;\r
+                      } // if ((dw_Status & 2) == 2)\r
+                   else\r
+                      {\r
+                      /*******************************/\r
+                      /* Test if measurement started */\r
+                      /*******************************/\r
+\r
+                      if ((dw_Status & 1) == 1)\r
+                         {\r
+                         /************************/\r
+                         /* A start signal occur */\r
+                         /************************/\r
+\r
+                         *pb_ChronoStatus = 1;\r
+                         } // if ((dw_Status & 1) == 1)\r
+                      else\r
+                         {\r
+                         /***************************/\r
+                         /* Measurement not started */\r
+                         /***************************/\r
+\r
+                         *pb_ChronoStatus = 0;\r
+                         } // if ((dw_Status & 1) == 1)\r
+                      } // if ((dw_Status & 2) == 2)\r
+                   } // if ((dw_Status & 8) == 8)\r
+                }\r
+             else\r
+                {\r
+                /*******************************/\r
+                /* Chronometer not initialised */\r
+                /*******************************/\r
+                DPRINTK("Chronometer not initialised\n");\r
+                i_ReturnValue = -4;\r
+                }\r
+             }\r
+          else\r
+             {\r
+             /******************************************/\r
+             /* The module is not a Chronometer module */\r
+             /******************************************/\r
+              DPRINTK("The module is not a Chronometer module\n");\r
+             i_ReturnValue = -3;\r
+             }\r
+          }\r
+       else\r
+          {\r
+          /***********************/\r
+          /* Module number error */\r
+          /***********************/\r
+          DPRINTK("Module number error\n");\r
+          i_ReturnValue = -2;\r
+          }\r
+\r
+       return (i_ReturnValue);\r
+       }\r
+\r
+\r
+/*\r
++----------------------------------------------------------------------------+\r
+| Function Name     : _INT_ i_APCI1710_ReadChronoValue                       |\r
+|                               (BYTE_     b_BoardHandle,                    |\r
+|                                BYTE_     b_ModulNbr,                       |\r
+|                                UINT_    ui_TimeOut,                        |\r
+|                                PBYTE_   pb_ChronoStatus,                   |\r
+|                                PULONG_ pul_ChronoValue)                    |\r
++----------------------------------------------------------------------------+\r
+| Task              : Return the chronometer status (pb_ChronoStatus) and the|\r
+|                     timing value (pul_ChronoValue) after a stop signal     |\r
+|                     occur from selected chronometer module (b_ModulNbr).   |\r
+|                     This function are only avaible if you have disabled    |\r
+|                     the interrupt functionality. See function              |\r
+|                     "i_APCI1710_EnableChrono" and the Interrupt mask       |\r
+|                     description chapter.                                   |\r
+|                     You can test the chronometer status witch the          |\r
+|                     "i_APCI1710_GetChronoProgressStatus" function.         |\r
+|                                                                            |\r
+|                     The returned value from pul_ChronoValue parameter is   |\r
+|                     not real measured timing.                              |\r
+|                     You must used the "i_APCI1710_ConvertChronoValue"      |\r
+|                     function or make this operation for calculate the      |\r
+|                     timing:                                                |\r
+|                                                                            |\r
+|                     Timing = pul_ChronoValue * pul_RealTimingInterval.     |\r
+|                                                                            |\r
+|                     pul_RealTimingInterval is the returned parameter from  |\r
+|                     "i_APCI1710_InitChrono" function and the time unity is |\r
+|                     the b_TimingUnit from "i_APCI1710_InitChrono" function|\r
++----------------------------------------------------------------------------+\r
+| Input Parameters  : BYTE_ b_BoardHandle  : Handle of board APCI-1710       |\r
+|                     BYTE_ b_ModulNbr     : Selected module number (0 to 3) |\r
++----------------------------------------------------------------------------+\r
+| Output Parameters : PULONG_  pb_ChronoStatus : Return the chronometer      |\r
+|                                                status.                     |\r
+|                                                0 : Measurement not started.|\r
+|                                                    No start signal occur.  |\r
+|                                                1 : Measurement started.    |\r
+|                                                    A start signal occur.   |\r
+|                                                2 : Measurement stopped.    |\r
+|                                                    A stop signal occur.    |\r
+|                                                    The measurement is      |\r
+|                                                    terminate.              |\r
+|                                                3: A overflow occur. You    |\r
+|                                                   must change the base     |\r
+|                                                   timing witch the         |\r
+|                                                   function                 |\r
+|                                                   "i_APCI1710_InitChrono"  |\r
+|                     PULONG  pul_ChronoValue  : Chronometer timing value.   |\r
++----------------------------------------------------------------------------+\r
+| Return Value      :  0: No error                                           |\r
+|                     -1: The handle parameter of the board is wrong         |\r
+|                     -2: Module selection wrong                             |\r
+|                     -3: The module is not a Chronometer module             |\r
+|                     -4: Chronometer not initialised see function           |\r
+|                         "i_APCI1710_InitChrono"                            |\r
+|                     -5: Timeout parameter is wrong (0 to 65535)            |\r
+|                     -6: Interrupt routine installed. You can not read      |\r
+|                         directly the chronometer measured timing.          |\r
++----------------------------------------------------------------------------+\r
+*/\r
+\r
+INT   i_APCI1710_ReadChronoValue      (comedi_device *dev,\r
+                                        BYTE     b_ModulNbr,\r
+                                        UINT    ui_TimeOut,\r
+                                        PBYTE   pb_ChronoStatus,\r
+                                        PULONG pul_ChronoValue)\r
+       {\r
+       INT    i_ReturnValue = 0;\r
+       DWORD dw_Status;\r
+       DWORD dw_TimeOut = 0;\r
+       \r
+\r
+       /**************************/\r
+       /* Test the module number */\r
+       /**************************/\r
+\r
+       if (b_ModulNbr < 4)\r
+          {\r
+          /***********************/\r
+          /* Test if chronometer */\r
+          /***********************/\r
+\r
+          if ((devpriv->\r
+               s_BoardInfos.\r
+               dw_MolduleConfiguration [b_ModulNbr] & 0xFFFF0000UL) == APCI1710_CHRONOMETER)\r
+             {\r
+             /***********************************/\r
+             /* Test if chronometer initialised */\r
+             /***********************************/\r
+\r
+             if (devpriv->\r
+                 s_ModuleInfo [b_ModulNbr].\r
+                 s_ChronoModuleInfo.\r
+                 b_ChronoInit == 1)\r
+                {\r
+                /*****************************/\r
+                /* Test the timout parameter */\r
+                /*****************************/\r
+\r
+                if ((ui_TimeOut >= 0) && (ui_TimeOut <= 65535UL))\r
+                   {\r
+                  \r
+                      for (;;)\r
+                         {\r
+                         /*******************/\r
+                         /* Read the status */\r
+                         /*******************/\r
+\r
+                        \r
+                               dw_Status=inl(devpriv->s_BoardInfos.\r
+                                ui_Address + 8 + (64 * b_ModulNbr));\r
+\r
+\r
+                         /********************/\r
+                         /* Test if overflow */\r
+                         /********************/\r
+\r
+                         if ((dw_Status & 8) == 8)\r
+                            {\r
+                            /******************/\r
+                            /* Overflow occur */\r
+                            /******************/\r
+\r
+                            *pb_ChronoStatus = 3;\r
+\r
+                            /***************************/\r
+                            /* Test if continuous mode */\r
+                            /***************************/\r
+\r
+                            if (devpriv->s_ModuleInfo [b_ModulNbr].\r
+                                s_ChronoModuleInfo.\r
+                                b_CycleMode == APCI1710_CONTINUOUS)\r
+                               {\r
+                               /*************************/\r
+                               /* Clear status register */\r
+                               /*************************/\r
+\r
+                               \r
+                                        outl(0,devpriv->s_BoardInfos.\r
+                                       ui_Address + 36 + (64 * b_ModulNbr));\r
+                               }\r
+\r
+                            break;\r
+                            } // if ((dw_Status & 8) == 8)\r
+                         else\r
+                            {\r
+                            /*******************************/\r
+                            /* Test if measurement stopped */\r
+                            /*******************************/\r
+\r
+                            if ((dw_Status & 2) == 2)\r
+                               {\r
+                               /***********************/\r
+                               /* A stop signal occur */\r
+                               /***********************/\r
+\r
+                               *pb_ChronoStatus = 2;\r
+\r
+                               /***************************/\r
+                               /* Test if continnous mode */\r
+                               /***************************/\r
+\r
+                               if (devpriv->\r
+                                   s_ModuleInfo [b_ModulNbr].\r
+                                   s_ChronoModuleInfo.\r
+                                   b_CycleMode == APCI1710_CONTINUOUS)\r
+                                  {\r
+                                  /*************************/\r
+                                  /* Clear status register */\r
+                                  /*************************/\r
+\r
+                                  \r
+                                       outl(0,devpriv->s_BoardInfos.\r
+                                          ui_Address + 36 + (64 * b_ModulNbr));\r
+                                  }\r
+                               break;\r
+                               } // if ((dw_Status & 2) == 2)\r
+                            else\r
+                               {\r
+                               /*******************************/\r
+                               /* Test if measurement started */\r
+                               /*******************************/\r
+\r
+                               if ((dw_Status & 1) == 1)\r
+                                  {\r
+                                  /************************/\r
+                                  /* A start signal occur */\r
+                                  /************************/\r
+\r
+                                  *pb_ChronoStatus = 1;\r
+                                  } // if ((dw_Status & 1) == 1)\r
+                               else\r
+                                  {\r
+                                  /***************************/\r
+                                  /* Measurement not started */\r
+                                  /***************************/\r
+\r
+                                  *pb_ChronoStatus = 0;\r
+                                  } // if ((dw_Status & 1) == 1)\r
+                               } // if ((dw_Status & 2) == 2)\r
+                            } // if ((dw_Status & 8) == 8)\r
+\r
+                         if (dw_TimeOut == ui_TimeOut)\r
+                            {\r
+                            /*****************/\r
+                            /* Timeout occur */\r
+                            /*****************/\r
+\r
+                            break;\r
+                            }\r
+                         else\r
+                            {\r
+                            /*************************/\r
+                            /* Increment the timeout */\r
+                            /*************************/\r
+\r
+                            dw_TimeOut = dw_TimeOut + 1;\r
+                                mdelay(1000);\r
+                           \r
+                               }\r
+                         } // for (;;)\r
+\r
+                      /*****************************/\r
+                      /* Test if stop signal occur */\r
+                      /*****************************/\r
+\r
+                      if (*pb_ChronoStatus == 2)\r
+                         {\r
+                         /**********************************/\r
+                         /* Read the measured timing value */\r
+                         /**********************************/\r
+\r
+                         \r
+                               *pul_ChronoValue= inl(devpriv->s_BoardInfos.\r
+                                ui_Address + 4 + (64 * b_ModulNbr));\r
+\r
+                         if (*pul_ChronoValue != 0)\r
+                            {\r
+                            *pul_ChronoValue = *pul_ChronoValue - 1;\r
+                            }\r
+                         }\r
+                      else\r
+                         {\r
+                         /*************************/\r
+                         /* Test if timeout occur */\r
+                         /*************************/\r
+\r
+                         if ((*pb_ChronoStatus != 3) && (dw_TimeOut == ui_TimeOut) && (ui_TimeOut != 0))\r
+                            {\r
+                            /*****************/\r
+                            /* Timeout occur */\r
+                            /*****************/\r
+\r
+                            *pb_ChronoStatus = 4;\r
+                            }\r
+                         }\r
+                    \r
+                   }\r
+                else\r
+                   {\r
+                   /******************************/\r
+                   /* Timeout parameter is wrong */\r
+                   /******************************/\r
+                    DPRINTK("Timeout parameter is wrong\n");\r
+                   i_ReturnValue = -5;\r
+                   }\r
+                }\r
+             else\r
+                {\r
+                /*******************************/\r
+                /* Chronometer not initialised */\r
+                /*******************************/\r
+                DPRINTK("Chronometer not initialised\n");\r
                 i_ReturnValue = -4;\r
                 }\r
              }\r
@@ -805,7 +1395,7 @@ INT i_APCI1710_InsnWriteEnableDisableChrono(comedi_device *dev,comedi_subdevice
              /******************************************/\r
              /* The module is not a Chronometer module */\r
              /******************************************/\r
-\r            DPRINTK("The module is not a Chronometer module\n");      
+             DPRINTK("The module is not a Chronometer module\n");      \r
              i_ReturnValue = -3;\r
              }\r
           }\r
@@ -814,744 +1404,200 @@ INT i_APCI1710_InsnWriteEnableDisableChrono(comedi_device *dev,comedi_subdevice
           /***********************/\r
           /* Module number error */\r
           /***********************/\r
-\r          DPRINTK("Module number error\n");
+          DPRINTK("Module number error\n");\r
           i_ReturnValue = -2;\r
           }\r
-\r      
+\r
        return (i_ReturnValue);\r
        }\r
 \r
+/*\r
++----------------------------------------------------------------------------+\r
+| Function Name     : _INT_ i_APCI1710_ConvertChronoValue                    |\r
+|                               (BYTE_     b_BoardHandle,                    |\r
+|                                BYTE_     b_ModulNbr,                       |\r
+|                                ULONG_   ul_ChronoValue,                    |\r
+|                                PULONG_ pul_Hour,                           |\r
+|                                PBYTE_   pb_Minute,                         |\r
+|                                PBYTE_   pb_Second,                         |\r
+|                                PUINT_  pui_MilliSecond,                    |\r
+|                                PUINT_  pui_MicroSecond,                    |\r
+|                                PUINT_  pui_NanoSecond)                     |\r
++----------------------------------------------------------------------------+\r
+| Task              : Convert the chronometer measured timing                |\r
+|                     (ul_ChronoValue) in to h, mn, s, ms, µs, ns.           |\r
++----------------------------------------------------------------------------+\r
+| Input Parameters  : BYTE_   b_BoardHandle : Handle of board APCI-1710      |\r
+|                     BYTE_   b_ModulNbr    : Selected module number (0 to 3)|\r
+|                     ULONG_ ul_ChronoValue : Measured chronometer timing    |\r
+|                                             value.                         |\r
+|                                             See"i_APCI1710_ReadChronoValue"|\r
++----------------------------------------------------------------------------+\r
+| Output Parameters : PULONG_   pul_Hour        : Chronometer timing hour    |\r
+|                     PBYTE_     pb_Minute      : Chronometer timing minute  |\r
+|                     PBYTE_     pb_Second      : Chronometer timing second  |\r
+|                     PUINT_    pui_MilliSecond  : Chronometer timing mini   |\r
+|                                                 second                     |\r
+|                     PUINT_    pui_MicroSecond : Chronometer timing micro   |\r
+|                                                 second                     |\r
+|                     PUINT_    pui_NanoSecond  : Chronometer timing nano    |\r
+|                                                 second                     |\r
++----------------------------------------------------------------------------+\r
+| Return Value      :  0: No error                                           |\r
+|                     -1: The handle parameter of the board is wrong         |\r
+|                     -2: Module selection wrong                             |\r
+|                     -3: The module is not a Chronometer module             |\r
+|                     -4: Chronometer not initialised see function           |\r
+|                         "i_APCI1710_InitChrono"                            |\r
++----------------------------------------------------------------------------+\r
+*/\r
+\r
+INT i_APCI1710_ConvertChronoValue     (comedi_device *dev,\r
+                                        BYTE     b_ModulNbr,\r
+                                        ULONG   ul_ChronoValue,\r
+                                        PULONG pul_Hour,\r
+                                        PBYTE   pb_Minute,\r
+                                        PBYTE   pb_Second,\r
+                                        PUINT  pui_MilliSecond,\r
+                                        PUINT  pui_MicroSecond,\r
+                                        PUINT  pui_NanoSecond)\r
+       {\r
+       INT    i_ReturnValue = 0;\r
+       double d_Hour;\r
+       double d_Minute;\r
+       double d_Second;\r
+       double d_MilliSecond;\r
+       double d_MicroSecond;\r
+       double d_NanoSecond;\r
+       \r
+       /**************************/\r
+       /* Test the module number */\r
+       /**************************/\r
+\r
+       if (b_ModulNbr < 4)\r
+          {\r
+          /***********************/\r
+          /* Test if chronometer */\r
+          /***********************/\r
+\r
+          if ((devpriv->\r
+               s_BoardInfos.\r
+               dw_MolduleConfiguration [b_ModulNbr] & 0xFFFF0000UL) == APCI1710_CHRONOMETER)\r
+             {\r
+             /***********************************/\r
+             /* Test if chronometer initialised */\r
+             /***********************************/\r
+\r
+             if (devpriv->\r
+                 s_ModuleInfo [b_ModulNbr].\r
+                 s_ChronoModuleInfo.\r
+                 b_ChronoInit == 1)\r
+                {\r
+                fpu_begin ();\r
+                \r
+                   d_Hour = (double) ul_ChronoValue * (double) devpriv->\r
+                                                               s_ModuleInfo [b_ModulNbr].\r
+                                                               s_ChronoModuleInfo.\r
+                                                               d_TimingInterval;\r
+\r
+                   switch (devpriv->\r
+                           s_ModuleInfo [b_ModulNbr].\r
+                           s_ChronoModuleInfo.\r
+                           b_TimingUnit)\r
+                      {\r
+                      case 0:\r
+                           d_Hour = d_Hour / (double) 1000.0;\r
+\r
+                      case 1:\r
+                           d_Hour = d_Hour / (double) 1000.0;\r
+\r
+                      case 2:\r
+                           d_Hour = d_Hour / (double) 1000.0;\r
+\r
+                      case 3:\r
+                           d_Hour = d_Hour / (double) 60.0;\r
+\r
+                      case 4:\r
+                           /**********************/\r
+                           /* Calculate the hour */\r
+                           /**********************/\r
 \r
+                           d_Hour    = d_Hour / (double) 60.0;\r
+                           *pul_Hour = (ULONG) d_Hour;\r
 \r
+                           /************************/\r
+                           /* Calculate the minute */\r
+                           /************************/\r
 \r
-/*
-+----------------------------------------------------------------------------+
-| Function Name     :INT       i_APCI1710_InsnReadChrono(comedi_device *dev,comedi_subdevice *s,
-comedi_insn *insn,lsampl_t *data)                   |
-+----------------------------------------------------------------------------+
-| Task              : Read  functions for Timer                                     |
-+----------------------------------------------------------------------------+
-| Input Parameters  : 
-+----------------------------------------------------------------------------+
-| Output Parameters : -                                                      |
-+----------------------------------------------------------------------------+
-| Return Value      : 
-+----------------------------------------------------------------------------+
-*/
-
-INT    i_APCI1710_InsnReadChrono(comedi_device *dev,comedi_subdevice *s,
-comedi_insn *insn,lsampl_t *data)
-{
-       BYTE b_ReadType;
-       INT  i_ReturnValue=insn->n;
-        
-       b_ReadType=CR_CHAN(insn->chanspec);
-
-       switch(b_ReadType)
-       {
-       case APCI1710_CHRONO_PROGRESS_STATUS:
-               i_ReturnValue=i_APCI1710_GetChronoProgressStatus  (dev,
-                                                (BYTE)    CR_AREF(insn->chanspec),
-                                                (PBYTE)  &data[0]);
-       break;
-
-       case APCI1710_CHRONO_READVALUE:
-               i_ReturnValue=i_APCI1710_ReadChronoValue      (dev,
-                                        (BYTE)    CR_AREF(insn->chanspec),
-                                        (UINT)    insn->unused[0],
-                                        (PBYTE)   &data[0],
-                                        (PULONG) &data[1]);
-       break;
-
-       case APCI1710_CHRONO_CONVERTVALUE:
-               i_ReturnValue=i_APCI1710_ConvertChronoValue     (dev,
-                                        (BYTE)    CR_AREF(insn->chanspec),
-                                        (ULONG)   insn->unused[0],
-                                        (PULONG)  &data[0],
-                                        (PBYTE)   &data[1],
-                                        (PBYTE)   &data[2],
-                                        (PUINT)  &data[3],
-                                        (PUINT)  &data[4],
-                                        (PUINT)  &data[5]);
-       break;
-        
-        case APCI1710_CHRONO_READINTERRUPT:
-                         printk("In Chrono Read Interrupt\n");
-
-                         data[0]=devpriv->s_InterruptParameters.
-                                                     s_FIFOInterruptParameters [devpriv->
-                                                                                s_InterruptParameters.
-                                                                                ui_Read].b_OldModuleMask;
-                         data[1]=devpriv->s_InterruptParameters.
-                                                     s_FIFOInterruptParameters [devpriv->
-                                                                                s_InterruptParameters.
-                                                                                ui_Read].ul_OldInterruptMask;
-                         data[2]=devpriv->s_InterruptParameters.
-                                                     s_FIFOInterruptParameters [devpriv->
-                                                                                s_InterruptParameters.
-                                                                                ui_Read].ul_OldCounterLatchValue;
-
-                            
-                            /**************************/
-                            /* Increment the read FIFO */
-                            /***************************/
-
-                            devpriv->
-                            s_InterruptParameters.
-                            ui_Read = (devpriv->
-                                       s_InterruptParameters.
-                                       ui_Read + 1) % APCI1710_SAVE_INTERRUPT;
-        break;
-    
-       default:
-               printk("ReadType Parameter wrong\n");
-       }
-
-       if(i_ReturnValue>=0) i_ReturnValue =insn->n;
-       return (i_ReturnValue); 
-
-}
-
-
-
-/*
-+----------------------------------------------------------------------------+
-| Function Name     : _INT_ i_APCI1710_GetChronoProgressStatus               |
-|                               (BYTE_    b_BoardHandle,                     |
-|                                BYTE_    b_ModulNbr,                        |
-|                                PBYTE_  pb_ChronoStatus)                    |
-+----------------------------------------------------------------------------+
-| Task              : Return the chronometer status (pb_ChronoStatus) from   |
-|                     selected chronometer module (b_ModulNbr).              |
-+----------------------------------------------------------------------------+
-| Input Parameters  : BYTE_ b_BoardHandle  : Handle of board APCI-1710       |
-|                     BYTE_ b_ModulNbr     : Selected module number (0 to 3) |
-+----------------------------------------------------------------------------+
-| Output Parameters : PULONG_  pb_ChronoStatus : Return the chronometer      |
-|                                                status.                     |
-|                                                0 : Measurement not started.|
-|                                                    No start signal occur.  |
-|                                                1 : Measurement started.    |
-|                                                    A start signal occur.   |
-|                                                2 : Measurement stopped.    |
-|                                                    A stop signal occur.    |
-|                                                    The measurement is      |
-|                                                    terminate.              |
-|                                                3: A overflow occur. You    |
-|                                                   must change the base     |
-|                                                   timing witch the         |
-|                                                   function                 |
-|                                                   "i_APCI1710_InitChrono"  |
-+----------------------------------------------------------------------------+
-| Return Value      :  0: No error                                           |
-|                     -1: The handle parameter of the board is wrong         |
-|                     -2: Module selection wrong                             |
-|                     -3: The module is not a Chronometer module             |
-|                     -4: Chronometer not initialised see function           |
-|                         "i_APCI1710_InitChrono"                            |
-+----------------------------------------------------------------------------+
-*/
-
-INT   i_APCI1710_GetChronoProgressStatus      (comedi_device *dev,
-                                                BYTE    b_ModulNbr,
-                                                PBYTE  pb_ChronoStatus)
-       {
-       INT    i_ReturnValue = 0;
-       DWORD dw_Status;
-       
-       /**************************/
-       /* Test the module number */
-       /**************************/
-
-       if (b_ModulNbr < 4)
-          {
-          /***********************/
-          /* Test if chronometer */
-          /***********************/
-
-          if ((devpriv->
-               s_BoardInfos.
-               dw_MolduleConfiguration [b_ModulNbr] & 0xFFFF0000UL) == APCI1710_CHRONOMETER)
-             {
-             /***********************************/
-             /* Test if chronometer initialised */
-             /***********************************/
-
-             if (devpriv->
-                 s_ModuleInfo [b_ModulNbr].
-                 s_ChronoModuleInfo.
-                 b_ChronoInit == 1)
-                {
-               
-               dw_Status=inl(devpriv->s_BoardInfos.
-                       ui_Address + 8 + (64 * b_ModulNbr));
-
-                /********************/
-                /* Test if overflow */
-                /********************/
-
-                if ((dw_Status & 8) == 8)
-                   {
-                   /******************/
-                   /* Overflow occur */
-                   /******************/
-
-                   *pb_ChronoStatus = 3;
-                   } // if ((dw_Status & 8) == 8)
-                else
-                   {
-                   /*******************************/
-                   /* Test if measurement stopped */
-                   /*******************************/
-
-                   if ((dw_Status & 2) == 2)
-                      {
-                      /***********************/
-                      /* A stop signal occur */
-                      /***********************/
-
-                      *pb_ChronoStatus = 2;
-                      } // if ((dw_Status & 2) == 2)
-                   else
-                      {
-                      /*******************************/
-                      /* Test if measurement started */
-                      /*******************************/
-
-                      if ((dw_Status & 1) == 1)
-                         {
-                         /************************/
-                         /* A start signal occur */
-                         /************************/
-
-                         *pb_ChronoStatus = 1;
-                         } // if ((dw_Status & 1) == 1)
-                      else
-                         {
-                         /***************************/
-                         /* Measurement not started */
-                         /***************************/
-
-                         *pb_ChronoStatus = 0;
-                         } // if ((dw_Status & 1) == 1)
-                      } // if ((dw_Status & 2) == 2)
-                   } // if ((dw_Status & 8) == 8)
-                }
-             else
-                {
-                /*******************************/
-                /* Chronometer not initialised */
-                /*******************************/
-                DPRINTK("Chronometer not initialised\n");
-                i_ReturnValue = -4;
-                }
-             }
-          else
-             {
-             /******************************************/
-             /* The module is not a Chronometer module */
-             /******************************************/
-              DPRINTK("The module is not a Chronometer module\n");
-             i_ReturnValue = -3;
-             }
-          }
-       else
-          {
-          /***********************/
-          /* Module number error */
-          /***********************/
-          DPRINTK("Module number error\n");
-          i_ReturnValue = -2;
-          }
-
-       return (i_ReturnValue);
-       }
-
-
-/*
-+----------------------------------------------------------------------------+
-| Function Name     : _INT_ i_APCI1710_ReadChronoValue                       |
-|                               (BYTE_     b_BoardHandle,                    |
-|                                BYTE_     b_ModulNbr,                       |
-|                                UINT_    ui_TimeOut,                        |
-|                                PBYTE_   pb_ChronoStatus,                   |
-|                                PULONG_ pul_ChronoValue)                    |
-+----------------------------------------------------------------------------+
-| Task              : Return the chronometer status (pb_ChronoStatus) and the|
-|                     timing value (pul_ChronoValue) after a stop signal     |
-|                     occur from selected chronometer module (b_ModulNbr).   |
-|                     This function are only avaible if you have disabled    |
-|                     the interrupt functionality. See function              |
-|                     "i_APCI1710_EnableChrono" and the Interrupt mask       |
-|                     description chapter.                                   |
-|                     You can test the chronometer status witch the          |
-|                     "i_APCI1710_GetChronoProgressStatus" function.         |
-|                                                                            |
-|                     The returned value from pul_ChronoValue parameter is   |
-|                     not real measured timing.                              |
-|                     You must used the "i_APCI1710_ConvertChronoValue"      |
-|                     function or make this operation for calculate the      |
-|                     timing:                                                |
-|                                                                            |
-|                     Timing = pul_ChronoValue * pul_RealTimingInterval.     |
-|                                                                            |
-|                     pul_RealTimingInterval is the returned parameter from  |
-|                     "i_APCI1710_InitChrono" function and the time unity is |
-|                     the b_TimingUnit from "i_APCI1710_InitChrono" function|
-+----------------------------------------------------------------------------+
-| Input Parameters  : BYTE_ b_BoardHandle  : Handle of board APCI-1710       |
-|                     BYTE_ b_ModulNbr     : Selected module number (0 to 3) |
-+----------------------------------------------------------------------------+
-| Output Parameters : PULONG_  pb_ChronoStatus : Return the chronometer      |
-|                                                status.                     |
-|                                                0 : Measurement not started.|
-|                                                    No start signal occur.  |
-|                                                1 : Measurement started.    |
-|                                                    A start signal occur.   |
-|                                                2 : Measurement stopped.    |
-|                                                    A stop signal occur.    |
-|                                                    The measurement is      |
-|                                                    terminate.              |
-|                                                3: A overflow occur. You    |
-|                                                   must change the base     |
-|                                                   timing witch the         |
-|                                                   function                 |
-|                                                   "i_APCI1710_InitChrono"  |
-|                     PULONG  pul_ChronoValue  : Chronometer timing value.   |
-+----------------------------------------------------------------------------+
-| Return Value      :  0: No error                                           |
-|                     -1: The handle parameter of the board is wrong         |
-|                     -2: Module selection wrong                             |
-|                     -3: The module is not a Chronometer module             |
-|                     -4: Chronometer not initialised see function           |
-|                         "i_APCI1710_InitChrono"                            |
-|                     -5: Timeout parameter is wrong (0 to 65535)            |
-|                     -6: Interrupt routine installed. You can not read      |
-|                         directly the chronometer measured timing.          |
-+----------------------------------------------------------------------------+
-*/
-
-INT   i_APCI1710_ReadChronoValue      (comedi_device *dev,
-                                        BYTE     b_ModulNbr,
-                                        UINT    ui_TimeOut,
-                                        PBYTE   pb_ChronoStatus,
-                                        PULONG pul_ChronoValue)
-       {
-       INT    i_ReturnValue = 0;
-       DWORD dw_Status;
-       DWORD dw_TimeOut = 0;
-       
-
-       /**************************/
-       /* Test the module number */
-       /**************************/
-
-       if (b_ModulNbr < 4)
-          {
-          /***********************/
-          /* Test if chronometer */
-          /***********************/
-
-          if ((devpriv->
-               s_BoardInfos.
-               dw_MolduleConfiguration [b_ModulNbr] & 0xFFFF0000UL) == APCI1710_CHRONOMETER)
-             {
-             /***********************************/
-             /* Test if chronometer initialised */
-             /***********************************/
-
-             if (devpriv->
-                 s_ModuleInfo [b_ModulNbr].
-                 s_ChronoModuleInfo.
-                 b_ChronoInit == 1)
-                {
-                /*****************************/
-                /* Test the timout parameter */
-                /*****************************/
-
-                if ((ui_TimeOut >= 0) && (ui_TimeOut <= 65535UL))
-                   {
-                  
-                      for (;;)
-                         {
-                         /*******************/
-                         /* Read the status */
-                         /*******************/
-
-                        
-                               dw_Status=inl(devpriv->s_BoardInfos.
-                                ui_Address + 8 + (64 * b_ModulNbr));
-
-
-                         /********************/
-                         /* Test if overflow */
-                         /********************/
-
-                         if ((dw_Status & 8) == 8)
-                            {
-                            /******************/
-                            /* Overflow occur */
-                            /******************/
-
-                            *pb_ChronoStatus = 3;
-
-                            /***************************/
-                            /* Test if continuous mode */
-                            /***************************/
-
-                            if (devpriv->s_ModuleInfo [b_ModulNbr].
-                                s_ChronoModuleInfo.
-                                b_CycleMode == APCI1710_CONTINUOUS)
-                               {
-                               /*************************/
-                               /* Clear status register */
-                               /*************************/
-
-                               
-                                        outl(0,devpriv->s_BoardInfos.
-                                       ui_Address + 36 + (64 * b_ModulNbr));
-                               }
-
-                            break;
-                            } // if ((dw_Status & 8) == 8)
-                         else
-                            {
-                            /*******************************/
-                            /* Test if measurement stopped */
-                            /*******************************/
-
-                            if ((dw_Status & 2) == 2)
-                               {
-                               /***********************/
-                               /* A stop signal occur */
-                               /***********************/
-
-                               *pb_ChronoStatus = 2;
-
-                               /***************************/
-                               /* Test if continnous mode */
-                               /***************************/
-
-                               if (devpriv->
-                                   s_ModuleInfo [b_ModulNbr].
-                                   s_ChronoModuleInfo.
-                                   b_CycleMode == APCI1710_CONTINUOUS)
-                                  {
-                                  /*************************/
-                                  /* Clear status register */
-                                  /*************************/
-
-                                  
-                                       outl(0,devpriv->s_BoardInfos.
-                                          ui_Address + 36 + (64 * b_ModulNbr));
-                                  }
-                               break;
-                               } // if ((dw_Status & 2) == 2)
-                            else
-                               {
-                               /*******************************/
-                               /* Test if measurement started */
-                               /*******************************/
-
-                               if ((dw_Status & 1) == 1)
-                                  {
-                                  /************************/
-                                  /* A start signal occur */
-                                  /************************/
-
-                                  *pb_ChronoStatus = 1;
-                                  } // if ((dw_Status & 1) == 1)
-                               else
-                                  {
-                                  /***************************/
-                                  /* Measurement not started */
-                                  /***************************/
-
-                                  *pb_ChronoStatus = 0;
-                                  } // if ((dw_Status & 1) == 1)
-                               } // if ((dw_Status & 2) == 2)
-                            } // if ((dw_Status & 8) == 8)
-
-                         if (dw_TimeOut == ui_TimeOut)
-                            {
-                            /*****************/
-                            /* Timeout occur */
-                            /*****************/
-
-                            break;
-                            }
-                         else
-                            {
-                            /*************************/
-                            /* Increment the timeout */
-                            /*************************/
-
-                            dw_TimeOut = dw_TimeOut + 1;
-                                mdelay(1000);
-                           
-                               }
-                         } // for (;;)
-
-                      /*****************************/
-                      /* Test if stop signal occur */
-                      /*****************************/
-
-                      if (*pb_ChronoStatus == 2)
-                         {
-                         /**********************************/
-                         /* Read the measured timing value */
-                         /**********************************/
-
-                         
-                               *pul_ChronoValue= inl(devpriv->s_BoardInfos.
-                                ui_Address + 4 + (64 * b_ModulNbr));
-
-                         if (*pul_ChronoValue != 0)
-                            {
-                            *pul_ChronoValue = *pul_ChronoValue - 1;
-                            }
-                         }
-                      else
-                         {
-                         /*************************/
-                         /* Test if timeout occur */
-                         /*************************/
-
-                         if ((*pb_ChronoStatus != 3) && (dw_TimeOut == ui_TimeOut) && (ui_TimeOut != 0))
-                            {
-                            /*****************/
-                            /* Timeout occur */
-                            /*****************/
-
-                            *pb_ChronoStatus = 4;
-                            }
-                         }
-                    
-                   }
-                else
-                   {
-                   /******************************/
-                   /* Timeout parameter is wrong */
-                   /******************************/
-                    DPRINTK("Timeout parameter is wrong\n");
-                   i_ReturnValue = -5;
-                   }
-                }
-             else
-                {
-                /*******************************/
-                /* Chronometer not initialised */
-                /*******************************/
-                DPRINTK("Chronometer not initialised\n");
-                i_ReturnValue = -4;
-                }
-             }
-          else
-             {
-             /******************************************/
-             /* The module is not a Chronometer module */
-             /******************************************/
-             DPRINTK("The module is not a Chronometer module\n");      
-             i_ReturnValue = -3;
-             }
-          }
-       else
-          {
-          /***********************/
-          /* Module number error */
-          /***********************/
-          DPRINTK("Module number error\n");
-          i_ReturnValue = -2;
-          }
-
-       return (i_ReturnValue);
-       }
-
-/*
-+----------------------------------------------------------------------------+
-| Function Name     : _INT_ i_APCI1710_ConvertChronoValue                    |
-|                               (BYTE_     b_BoardHandle,                    |
-|                                BYTE_     b_ModulNbr,                       |
-|                                ULONG_   ul_ChronoValue,                    |
-|                                PULONG_ pul_Hour,                           |
-|                                PBYTE_   pb_Minute,                         |
-|                                PBYTE_   pb_Second,                         |
-|                                PUINT_  pui_MilliSecond,                    |
-|                                PUINT_  pui_MicroSecond,                    |
-|                                PUINT_  pui_NanoSecond)                     |
-+----------------------------------------------------------------------------+
-| Task              : Convert the chronometer measured timing                |
-|                     (ul_ChronoValue) in to h, mn, s, ms, µs, ns.           |
-+----------------------------------------------------------------------------+
-| Input Parameters  : BYTE_   b_BoardHandle : Handle of board APCI-1710      |
-|                     BYTE_   b_ModulNbr    : Selected module number (0 to 3)|
-|                     ULONG_ ul_ChronoValue : Measured chronometer timing    |
-|                                             value.                         |
-|                                             See"i_APCI1710_ReadChronoValue"|
-+----------------------------------------------------------------------------+
-| Output Parameters : PULONG_   pul_Hour        : Chronometer timing hour    |
-|                     PBYTE_     pb_Minute      : Chronometer timing minute  |
-|                     PBYTE_     pb_Second      : Chronometer timing second  |
-|                     PUINT_    pui_MilliSecond  : Chronometer timing mini   |
-|                                                 second                     |
-|                     PUINT_    pui_MicroSecond : Chronometer timing micro   |
-|                                                 second                     |
-|                     PUINT_    pui_NanoSecond  : Chronometer timing nano    |
-|                                                 second                     |
-+----------------------------------------------------------------------------+
-| Return Value      :  0: No error                                           |
-|                     -1: The handle parameter of the board is wrong         |
-|                     -2: Module selection wrong                             |
-|                     -3: The module is not a Chronometer module             |
-|                     -4: Chronometer not initialised see function           |
-|                         "i_APCI1710_InitChrono"                            |
-+----------------------------------------------------------------------------+
-*/
-
-INT i_APCI1710_ConvertChronoValue     (comedi_device *dev,
-                                        BYTE     b_ModulNbr,
-                                        ULONG   ul_ChronoValue,
-                                        PULONG pul_Hour,
-                                        PBYTE   pb_Minute,
-                                        PBYTE   pb_Second,
-                                        PUINT  pui_MilliSecond,
-                                        PUINT  pui_MicroSecond,
-                                        PUINT  pui_NanoSecond)
-       {
-       INT    i_ReturnValue = 0;
-       double d_Hour;
-       double d_Minute;
-       double d_Second;
-       double d_MilliSecond;
-       double d_MicroSecond;
-       double d_NanoSecond;
-       
-       /**************************/
-       /* Test the module number */
-       /**************************/
-
-       if (b_ModulNbr < 4)
-          {
-          /***********************/
-          /* Test if chronometer */
-          /***********************/
-
-          if ((devpriv->
-               s_BoardInfos.
-               dw_MolduleConfiguration [b_ModulNbr] & 0xFFFF0000UL) == APCI1710_CHRONOMETER)
-             {
-             /***********************************/
-             /* Test if chronometer initialised */
-             /***********************************/
-
-             if (devpriv->
-                 s_ModuleInfo [b_ModulNbr].
-                 s_ChronoModuleInfo.
-                 b_ChronoInit == 1)
-                {
-                
-                   d_Hour = (double) ul_ChronoValue * (double) devpriv->
-                                                               s_ModuleInfo [b_ModulNbr].
-                                                               s_ChronoModuleInfo.
-                                                               d_TimingInterval;
-
-                   switch (devpriv->
-                           s_ModuleInfo [b_ModulNbr].
-                           s_ChronoModuleInfo.
-                           b_TimingUnit)
-                      {
-                      case 0:
-                           d_Hour = d_Hour / (double) 1000.0;
-
-                      case 1:
-                           d_Hour = d_Hour / (double) 1000.0;
-
-                      case 2:
-                           d_Hour = d_Hour / (double) 1000.0;
-
-                      case 3:
-                           d_Hour = d_Hour / (double) 60.0;
-
-                      case 4:
-                           /**********************/
-                           /* Calculate the hour */
-                           /**********************/
-
-                           d_Hour    = d_Hour / (double) 60.0;
-                           *pul_Hour = (ULONG) d_Hour;
-
-                           /************************/
-                           /* Calculate the minute */
-                           /************************/
-
-                           d_Minute   = d_Hour - *pul_Hour;
-                           d_Minute   = d_Minute * 60;
-                           *pb_Minute = (BYTE) d_Minute;
-
-                           /************************/
-                           /* Calculate the second */
-                           /************************/
-
-                           d_Second   = d_Minute - *pb_Minute;
-                           d_Second   = d_Second * 60;
-                           *pb_Second = (BYTE) d_Second;
-
-                           /*****************************/
-                           /* Calculate the mini second */
-                           /*****************************/
-
-                           d_MilliSecond    = d_Second - *pb_Second;
-                           d_MilliSecond    = d_MilliSecond * 1000;
-                           *pui_MilliSecond = (UINT) d_MilliSecond;
-
-                           /******************************/
-                           /* Calculate the micro second */
-                           /******************************/
-
-                           d_MicroSecond    = d_MilliSecond - *pui_MilliSecond;
-                           d_MicroSecond    = d_MicroSecond * 1000;
-                           *pui_MicroSecond = (UINT) d_MicroSecond;
-
-                           /******************************/
-                           /* Calculate the micro second */
-                           /******************************/
-
-                           d_NanoSecond    = d_MicroSecond - *pui_MicroSecond;
-                           d_NanoSecond    = d_NanoSecond * 1000;
-                           *pui_NanoSecond = (UINT) d_NanoSecond;
-                           break;
-                      }
-                   
-                }
-             else
-                {
-                /*******************************/
-                /* Chronometer not initialised */
-                /*******************************/
-                DPRINTK("Chronometer not initialised\n");
-                i_ReturnValue = -4;
-                }
-             }
-          else
-             {
-             /******************************************/
-             /* The module is not a Chronometer module */
-             /******************************************/
-             DPRINTK("The module is not a Chronometer module\n");      
-             i_ReturnValue = -3;
-             }
-          }
-       else
-          {
-          /***********************/
-          /* Module number error */
-          /***********************/
-          DPRINTK("Module number error\n");    
-          i_ReturnValue = -2;
-          }
-
-       return (i_ReturnValue);
-       }
+                           d_Minute   = d_Hour - *pul_Hour;\r
+                           d_Minute   = d_Minute * 60;\r
+                           *pb_Minute = (BYTE) d_Minute;\r
+\r
+                           /************************/\r
+                           /* Calculate the second */\r
+                           /************************/\r
+\r
+                           d_Second   = d_Minute - *pb_Minute;\r
+                           d_Second   = d_Second * 60;\r
+                           *pb_Second = (BYTE) d_Second;\r
+\r
+                           /*****************************/\r
+                           /* Calculate the mini second */\r
+                           /*****************************/\r
+\r
+                           d_MilliSecond    = d_Second - *pb_Second;\r
+                           d_MilliSecond    = d_MilliSecond * 1000;\r
+                           *pui_MilliSecond = (UINT) d_MilliSecond;\r
+\r
+                           /******************************/\r
+                           /* Calculate the micro second */\r
+                           /******************************/\r
+\r
+                           d_MicroSecond    = d_MilliSecond - *pui_MilliSecond;\r
+                           d_MicroSecond    = d_MicroSecond * 1000;\r
+                           *pui_MicroSecond = (UINT) d_MicroSecond;\r
+\r
+                           /******************************/\r
+                           /* Calculate the micro second */\r
+                           /******************************/\r
+\r
+                           d_NanoSecond    = d_MicroSecond - *pui_MicroSecond;\r
+                           d_NanoSecond    = d_NanoSecond * 1000;\r
+                           *pui_NanoSecond = (UINT) d_NanoSecond;\r
+                           break;\r
+                      }\r
+                   \r
+                fpu_end ();\r
+                }\r
+             else\r
+                {\r
+                /*******************************/\r
+                /* Chronometer not initialised */\r
+                /*******************************/\r
+                DPRINTK("Chronometer not initialised\n");\r
+                i_ReturnValue = -4;\r
+                }\r
+             }\r
+          else\r
+             {\r
+             /******************************************/\r
+             /* The module is not a Chronometer module */\r
+             /******************************************/\r
+             DPRINTK("The module is not a Chronometer module\n");      \r
+             i_ReturnValue = -3;\r
+             }\r
+          }\r
+       else\r
+          {\r
+          /***********************/\r
+          /* Module number error */\r
+          /***********************/\r
+          DPRINTK("Module number error\n");    \r
+          i_ReturnValue = -2;\r
+          }\r
+\r
+       return (i_ReturnValue);\r
+       }\r
 \r
 \r
 \r
@@ -1675,15 +1721,15 @@ INT i_APCI1710_ConvertChronoValue     (comedi_device *dev,
 |                         "i_APCI1710_InitChrono"                            |\r
 +----------------------------------------------------------------------------+\r
 */\r
-
+\r
 \r
 INT i_APCI1710_InsnBitsChronoDigitalIO(comedi_device *dev,comedi_subdevice *s,\r
        comedi_insn *insn,lsampl_t *data)\r
        {\r
        INT    i_ReturnValue = 0;\r
-       BYTE  b_ModulNbr,b_OutputChannel,b_InputChannel,b_IOType;
-       DWORD dw_Status;
-       PBYTE pb_ChannelStatus;
+       BYTE  b_ModulNbr,b_OutputChannel,b_InputChannel,b_IOType;\r
+       DWORD dw_Status;\r
+       PBYTE pb_ChannelStatus;\r
        PBYTE pb_PortValue;\r
        \r
        b_ModulNbr      = CR_AREF(insn->chanspec);\r
@@ -1691,7 +1737,7 @@ INT i_APCI1710_InsnBitsChronoDigitalIO(comedi_device *dev,comedi_subdevice *s,
        b_IOType   = (BYTE) data[0];\r
           \r
 \r
-       
+       \r
 \r
        /**************************/\r
        /* Test the module number */\r
@@ -1723,9 +1769,9 @@ INT i_APCI1710_InsnBitsChronoDigitalIO(comedi_device *dev,comedi_subdevice *s,
                 case APCI1710_CHRONO_SET_CHANNELOFF:\r
 \r
                b_OutputChannel = (BYTE) CR_CHAN(insn->chanspec);\r
-                         if ((b_OutputChannel >= 0) && (b_OutputChannel <= 2))\r
+                         if (b_OutputChannel <= 2)\r
                    {\r
-                   
+                   \r
              outl(0,devpriv->s_BoardInfos.ui_Address + 20 + (b_OutputChannel * 4) + (64 * b_ModulNbr));\r
                    } // if ((b_OutputChannel >= 0) && (b_OutputChannel <= 2))\r
                 else\r
@@ -1733,7 +1779,8 @@ INT i_APCI1710_InsnBitsChronoDigitalIO(comedi_device *dev,comedi_subdevice *s,
                    /****************************************/\r
                    /* The selected digital output is wrong */\r
                    /****************************************/\r
-\r                   DPRINTK("The selected digital output is wrong\n"); 
+\r
+                   DPRINTK("The selected digital output is wrong\n"); \r
                    i_ReturnValue = -4;\r
 \r
                    } // if ((b_OutputChannel >= 0) && (b_OutputChannel <= 2))\r
@@ -1743,9 +1790,9 @@ INT i_APCI1710_InsnBitsChronoDigitalIO(comedi_device *dev,comedi_subdevice *s,
                  case APCI1710_CHRONO_SET_CHANNELON:\r
 \r
                 b_OutputChannel = (BYTE) CR_CHAN(insn->chanspec);\r
-                if ((b_OutputChannel >= 0) && (b_OutputChannel <= 2))\r
+                if (b_OutputChannel <= 2)\r
                    {\r
-                   
+                   \r
                         outl(1,devpriv->s_BoardInfos.ui_Address + 20 + (b_OutputChannel * 4) + (64 * b_ModulNbr));\r
                    } // if ((b_OutputChannel >= 0) && (b_OutputChannel <= 2))\r
                 else\r
@@ -1753,7 +1800,8 @@ INT i_APCI1710_InsnBitsChronoDigitalIO(comedi_device *dev,comedi_subdevice *s,
                    /****************************************/\r
                    /* The selected digital output is wrong */\r
                    /****************************************/\r
-\r                      DPRINTK("The selected digital output is wrong\n");
+\r
+                       DPRINTK("The selected digital output is wrong\n");\r
                    i_ReturnValue = -4;\r
 \r
                    } // if ((b_OutputChannel >= 0) && (b_OutputChannel <= 2))\r
@@ -1767,7 +1815,7 @@ INT i_APCI1710_InsnBitsChronoDigitalIO(comedi_device *dev,comedi_subdevice *s,
                 pb_ChannelStatus = (PBYTE) &data[0];\r
                 b_InputChannel = (BYTE) CR_CHAN(insn->chanspec);\r
                 \r
-                if ((b_InputChannel >= 0) && (b_InputChannel <= 2))\r
+                if (b_InputChannel <= 2)\r
                    {\r
                    \r
                         dw_Status = inl(devpriv->s_BoardInfos.ui_Address + 12 + (64 * b_ModulNbr));\r
@@ -1779,7 +1827,8 @@ INT i_APCI1710_InsnBitsChronoDigitalIO(comedi_device *dev,comedi_subdevice *s,
                    /***************************************/\r
                    /* The selected digital input is wrong */\r
                    /***************************************/\r
-\r                      DPRINTK("The selected digital input is wrong\n");
+\r
+                       DPRINTK("The selected digital input is wrong\n");\r
                    i_ReturnValue = -4;\r
                    } // if ((b_InputChannel >= 0) && (b_InputChannel <= 2))\r
 \r
@@ -1789,7 +1838,7 @@ INT i_APCI1710_InsnBitsChronoDigitalIO(comedi_device *dev,comedi_subdevice *s,
 \r
                        pb_PortValue = (PBYTE) &data[0];\r
 \r
-                       
+                       \r
                        dw_Status = inl(devpriv->s_BoardInfos.ui_Address + 12 + (64 * b_ModulNbr));\r
 \r
                    *pb_PortValue = (BYTE) ((dw_Status & 0x7) ^ 7);\r
@@ -1801,7 +1850,8 @@ INT i_APCI1710_InsnBitsChronoDigitalIO(comedi_device *dev,comedi_subdevice *s,
                 /*******************************/\r
                 /* Chronometer not initialised */\r
                 /*******************************/\r
-\r               DPRINTK("Chronometer not initialised\n");      
+\r
+                DPRINTK("Chronometer not initialised\n");      \r
                 i_ReturnValue = -5;\r
                 }\r
              }\r
@@ -1810,7 +1860,8 @@ INT i_APCI1710_InsnBitsChronoDigitalIO(comedi_device *dev,comedi_subdevice *s,
              /******************************************/\r
              /* The module is not a Chronometer module */\r
              /******************************************/\r
-\r             DPRINTK("The module is not a Chronometer module\n");
+\r
+             DPRINTK("The module is not a Chronometer module\n");\r
              i_ReturnValue = -3;\r
              }\r
           }\r
@@ -1819,7 +1870,8 @@ INT i_APCI1710_InsnBitsChronoDigitalIO(comedi_device *dev,comedi_subdevice *s,
           /***********************/\r
           /* Module number error */\r
           /***********************/\r
-\r         DPRINTK("Module number error\n");
+\r
+          DPRINTK("Module number error\n");\r
           i_ReturnValue = -2;\r
           }\r
 \r
index 7d8833be3ae225766835e0b4deadba45ddd202c4..e284114d51fb9150689a9b20f0a0de3e62441148 100644 (file)
@@ -1,78 +1 @@
-\r\r
-\r
-\r
-#define APCI1710_30MHZ           30\r
-#define APCI1710_33MHZ           33\r
-#define APCI1710_40MHZ           40\r
-
-\r
-#define APCI1710_SINGLE     0\r
-#define APCI1710_CONTINUOUS 1\r
-\r
-\r
-#define APCI1710_CHRONO_PROGRESS_STATUS                0\r
-#define APCI1710_CHRONO_READVALUE                      1\r
-#define APCI1710_CHRONO_CONVERTVALUE           2\r
-#define APCI1710_CHRONO_READINTERRUPT       3
-\r
-#define APCI1710_CHRONO_SET_CHANNELON                  0\r
-#define APCI1710_CHRONO_SET_CHANNELOFF         1\r
-#define APCI1710_CHRONO_READ_CHANNEL           2\r
-#define APCI1710_CHRONO_READ_PORT                      3\r
-\r
-/*\r
-+----------------------------------------------------------------------------+\r
-|                  CHRONOMETER INISIALISATION FUNCTION   |\r
-+----------------------------------------------------------------------------+\r */\r
-\r
-INT i_APCI1710_InsnConfigInitChrono(comedi_device *dev,comedi_subdevice *s,\r
-       comedi_insn *insn,lsampl_t *data);\r
-\r
-INT i_APCI1710_InsnWriteEnableDisableChrono(comedi_device *dev,comedi_subdevice *s,\r
-       comedi_insn *insn,lsampl_t *data);\r
-\r
-\r
-/*\r
-+----------------------------------------------------------------------------+\r
-|                       CHRONOMETER READ FUNCTION                            |\r
-+----------------------------------------------------------------------------+\r
-*/\r
-
-INT    i_APCI1710_InsnReadChrono(comedi_device *dev,comedi_subdevice *s,
-comedi_insn *insn,lsampl_t *data);
-
-
-INT   i_APCI1710_GetChronoProgressStatus      (comedi_device *dev,
-                                                BYTE    b_ModulNbr,
-                                                PBYTE  pb_ChronoStatus);
-
-INT   i_APCI1710_ReadChronoValue      (comedi_device *dev,
-                                        BYTE     b_ModulNbr,
-                                        UINT    ui_TimeOut,
-                                        PBYTE   pb_ChronoStatus,
-                                        PULONG pul_ChronoValue);
-
-INT i_APCI1710_ConvertChronoValue     (comedi_device *dev,
-                                        BYTE     b_ModulNbr,
-                                        ULONG   ul_ChronoValue,
-                                        PULONG pul_Hour,
-                                        PBYTE   pb_Minute,
-                                        PBYTE   pb_Second,
-                                        PUINT  pui_MilliSecond,
-                                        PUINT  pui_MicroSecond,
-                                        PUINT  pui_NanoSecond);
-
-
-\r
-\r
-\r
-/*\r
-+----------------------------------------------------------------------------+\r
-|                       CHRONOMETER DIGITAL INPUT OUTPUT FUNCTION                  |\r
-+----------------------------------------------------------------------------+\r
-*/\r
-\r
-INT i_APCI1710_InsnBitsChronoDigitalIO(comedi_device *dev,comedi_subdevice *s,\r
-       comedi_insn *insn,lsampl_t *data);\r
-\r
-\r
+/**\r@verbatim\r\rCopyright (C) 2004,2005  ADDI-DATA GmbH for the source code of this module. \r        \r        ADDI-DATA GmbH \r        Dieselstrasse 3 \r        D-77833 Ottersweier \r        Tel: +19(0)7223/9493-0 \r        Fax: +49(0)7223/9493-92 \r        http://www.addi-data-com \r        info@addi-data.com \r\rThis program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.\r\rThis program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.\r\rYou should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r\rYou shoud also find the complete GPL in the COPYING file accompanying this source code.\r\r@endverbatim\r*/\r\r\r\r#define APCI1710_30MHZ           30\r#define APCI1710_33MHZ           33\r#define APCI1710_40MHZ           40\r\r\r#define APCI1710_SINGLE     0\r#define APCI1710_CONTINUOUS 1\r\r\r#define APCI1710_CHRONO_PROGRESS_STATUS           0\r#define APCI1710_CHRONO_READVALUE                     1\r#define APCI1710_CHRONO_CONVERTVALUE          2\r#define APCI1710_CHRONO_READINTERRUPT       3\r\r#define APCI1710_CHRONO_SET_CHANNELON                  0\r#define APCI1710_CHRONO_SET_CHANNELOFF                1\r#define APCI1710_CHRONO_READ_CHANNEL          2\r#define APCI1710_CHRONO_READ_PORT                     3\r\r/*\r+----------------------------------------------------------------------------+\r|                  CHRONOMETER INISIALISATION FUNCTION   |\r+----------------------------------------------------------------------------+\r */\r\rINT i_APCI1710_InsnConfigInitChrono(comedi_device *dev,comedi_subdevice *s,\r        comedi_insn *insn,lsampl_t *data);\r\rINT i_APCI1710_InsnWriteEnableDisableChrono(comedi_device *dev,comedi_subdevice *s,\r        comedi_insn *insn,lsampl_t *data);\r\r\r/*\r+----------------------------------------------------------------------------+\r|                       CHRONOMETER READ FUNCTION                            |\r+----------------------------------------------------------------------------+\r*/\r\rINT    i_APCI1710_InsnReadChrono(comedi_device *dev,comedi_subdevice *s,\rcomedi_insn *insn,lsampl_t *data);\r\r\rINT   i_APCI1710_GetChronoProgressStatus      (comedi_device *dev,\r                                               BYTE    b_ModulNbr,\r                                            PBYTE  pb_ChronoStatus);\r\rINT   i_APCI1710_ReadChronoValue      (comedi_device *dev,\r                                   BYTE     b_ModulNbr,\r                                   UINT    ui_TimeOut,\r                                    PBYTE   pb_ChronoStatus,\r                                       PULONG pul_ChronoValue);\r\rINT i_APCI1710_ConvertChronoValue     (comedi_device *dev,\r                                   BYTE     b_ModulNbr,\r                                   ULONG   ul_ChronoValue,\r                                        PULONG pul_Hour,\r                                       PBYTE   pb_Minute,\r                                     PBYTE   pb_Second,\r                                     PUINT  pui_MilliSecond,\r                                        PUINT  pui_MicroSecond,\r                                        PUINT  pui_NanoSecond);\r\r\r\r\r\r/*\r+----------------------------------------------------------------------------+\r|                       CHRONOMETER DIGITAL INPUT OUTPUT FUNCTION                  |\r+----------------------------------------------------------------------------+\r*/\r\rINT i_APCI1710_InsnBitsChronoDigitalIO(comedi_device *dev,comedi_subdevice *s,\r comedi_insn *insn,lsampl_t *data);\r\r\r
\ No newline at end of file
index c39d304b0c009f816654546310c71b25226b11d5..e7d1aac9cd79d822d3345e322410190a38ada759 100644 (file)
@@ -1,14 +1,38 @@
+/**\r
+@verbatim\r
+\r
+Copyright (C) 2004,2005  ADDI-DATA GmbH for the source code of this module. \r
+        \r
+        ADDI-DATA GmbH \r
+        Dieselstrasse 3 \r
+        D-77833 Ottersweier \r
+        Tel: +19(0)7223/9493-0 \r
+        Fax: +49(0)7223/9493-92 \r
+        http://www.addi-data-com \r
+        info@addi-data.com \r
+\r
+This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.\r
+\r
+This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.\r
+\r
+You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+\r
+You shoud also find the complete GPL in the COPYING file accompanying this source code.\r
+\r
+@endverbatim\r
+*/\r
 /*\r
+    \r
   +-----------------------------------------------------------------------+\r
   | (C) ADDI-DATA GmbH          Dieselstraße 3       D-77833 Ottersweier  |\r
   +-----------------------------------------------------------------------+\r
   | Tel : +49 (0) 7223/9493-0     | email    : info@addi-data.com         |\r
   | Fax : +49 (0) 7223/9493-92    | Internet : http://www.addi-data.com   |\r
   +-----------------------------------------------------------------------+\r
-  | Project   : API APCI1710      |     Compiler   : BORLANDC/MICROSOFT C |\r
-  | Module name : DIG_IO.C        |     Version    : 3.1     / 6.0        |\r
+  | Project     : API APCI1710    | Compiler : gcc                        |\r
+  | Module name : DIG_IO.C        | Version  : 2.96                       |\r
   +-------------------------------+---------------------------------------+\r
-  | Author    : S.WEBER           |     Date       : 16.06.98             |\r
+  | Project manager: Eric Stolz   | Date     :  02/12/2002                |\r
   +-----------------------------------------------------------------------+\r
   | Description :   APCI-1710 digital I/O module                          |\r
   |                                                                       |\r
@@ -79,19 +103,20 @@ Activates and deactivates the digital output memory.
 INT i_APCI1710_InsnConfigDigitalIO(comedi_device *dev,comedi_subdevice *s,\r
        comedi_insn *insn,lsampl_t *data)\r
     {\r
-       BYTE   b_ModulNbr,b_ChannelAMode,b_ChannelBMode ;
+       BYTE   b_ModulNbr,b_ChannelAMode,b_ChannelBMode ;\r
         BYTE   b_MemoryOnOff,b_ConfigType;\r
        INT    i_ReturnValue = 0;\r
        DWORD  dw_WriteConfig = 0;\r
-       
-       b_ModulNbr              =       (BYTE) CR_AREF(insn->chanspec);
-        b_ConfigType\r   =   (BYTE) data[0];// Memory or  Init
+       \r
+       b_ModulNbr              =       (BYTE) CR_AREF(insn->chanspec);\r
+        b_ConfigType\r
+   =   (BYTE) data[0];// Memory or  Init\r
        b_ChannelAMode  =       (BYTE) data[1];\r
        b_ChannelBMode  =       (BYTE) data[2];\r
-        b_MemoryOnOff   =      (BYTE) data[1]; // if memory operation 
+        b_MemoryOnOff   =      (BYTE) data[1]; // if memory operation \r
        i_ReturnValue   =   insn->n;\r
-
-  
+\r
+  \r
                /**************************/\r
                /* Test the module number */\r
                /**************************/\r
@@ -99,12 +124,12 @@ INT i_APCI1710_InsnConfigDigitalIO(comedi_device *dev,comedi_subdevice *s,
                if (b_ModulNbr >= 4)\r
                {\r
                        DPRINTK("Module Number invalid\n");\r
-                       i_ReturnValue = -2;
+                       i_ReturnValue = -2;\r
                     return i_ReturnValue;   \r
                }       \r
-            switch(b_ConfigType)
-              {
-               case APCI1710_DIGIO_MEMORYONOFF:        
+            switch(b_ConfigType)\r
+              {\r
+               case APCI1710_DIGIO_MEMORYONOFF:        \r
 \r
                if(b_MemoryOnOff) // If Memory ON\r
                {\r
@@ -133,10 +158,10 @@ INT i_APCI1710_InsnConfigDigitalIO(comedi_device *dev,comedi_subdevice *s,
                 s_DigitalIOInfo.\r
                 b_OutputMemoryEnabled = 0;     \r
                }\r
-               break;
-
-        case APCI1710_DIGIO_INIT:
-            
+               break;\r
+\r
+        case APCI1710_DIGIO_INIT:\r
+            \r
        /*******************************/\r
        /* Test if digital I/O counter */\r
        /*******************************/\r
@@ -218,8 +243,8 @@ INT i_APCI1710_InsnConfigDigitalIO(comedi_device *dev,comedi_subdevice *s,
        /******************************************/\r
                        DPRINTK("The module is not a digital I/O module\n");    \r
                        i_ReturnValue = -3;\r
-     }
-    } // end of Switch 
+     }\r
+    } // end of Switch \r
      printk("Return Value %d\n",i_ReturnValue);  \r
      return i_ReturnValue;\r
 }\r
@@ -285,11 +310,11 @@ INT i_APCI1710_InsnReadDigitalIOChlValue(comedi_device *dev,comedi_subdevice *s,
        INT    i_ReturnValue = 0;\r
        DWORD dw_StatusReg;\r
        BYTE    b_ModulNbr,b_InputChannel;\r
-        PBYTE  pb_ChannelStatus;
+        PBYTE  pb_ChannelStatus;\r
        b_ModulNbr              = (BYTE) CR_AREF(insn->chanspec);\r
-        b_InputChannel = (BYTE) CR_CHAN(insn->chanspec);
+        b_InputChannel = (BYTE) CR_CHAN(insn->chanspec);\r
         data[0]=0;\r
-        pb_ChannelStatus= (PBYTE) &data[0];
+        pb_ChannelStatus= (PBYTE) &data[0];\r
         i_ReturnValue = insn->n;\r
 \r
 \r
@@ -309,7 +334,7 @@ INT i_APCI1710_InsnReadDigitalIOChlValue(comedi_device *dev,comedi_subdevice *s,
              /* Test the digital imnput channel number */\r
              /******************************************/\r
 \r
-             if ((b_InputChannel >= 0) && (b_InputChannel <= 6))\r
+             if (b_InputChannel <= 6)\r
                 {\r
                 /**********************************************/\r
                 /* Test if the digital I/O module initialised */\r
@@ -378,7 +403,7 @@ INT i_APCI1710_InsnReadDigitalIOChlValue(comedi_device *dev,comedi_subdevice *s,
                            dw_StatusReg = inl(devpriv->s_BoardInfos.ui_Address + (64 * b_ModulNbr));\r
 \r
                       *pb_ChannelStatus = (BYTE) ((dw_StatusReg ^ 0x1C) >> b_InputChannel) & 1;\r
-                        
+                        \r
                       } // if (i_ReturnValue == 0)\r
                    }\r
                 else\r
@@ -470,13 +495,13 @@ INT i_APCI1710_InsnWriteDigitalIOChlOnOff(comedi_device *dev,comedi_subdevice *s
        comedi_insn *insn,lsampl_t *data)\r
        {\r
        INT    i_ReturnValue = 0;\r
-       DWORD dw_WriteValue;\r
+       DWORD dw_WriteValue  = 0;\r
        BYTE b_ModulNbr,b_OutputChannel;\r
        i_ReturnValue   =       insn->n; \r
        b_ModulNbr              =   CR_AREF(insn->chanspec);  \r
        b_OutputChannel =   CR_CHAN(insn->chanspec);  \r
        \r
-       
+       \r
 \r
        /**************************/\r
        /* Test the module number */\r
@@ -714,18 +739,21 @@ INT i_APCI1710_InsnBitsDigitalIOPortOnOff(comedi_device *dev,comedi_subdevice *s
        comedi_insn *insn,lsampl_t *data)\r
        {\r
        INT    i_ReturnValue = 0;\r
-       DWORD dw_WriteValue,dw_StatusReg;\r
-       BYTE b_ModulNbr,b_PortValue;
-        BYTE b_PortOperation,b_PortOnOFF;
-\r       PBYTE pb_PortValue;
-          
+       DWORD dw_WriteValue = 0;\r
+       DWORD dw_StatusReg;\r
+       BYTE b_ModulNbr,b_PortValue;\r
+        BYTE b_PortOperation,b_PortOnOFF;\r
+\r
+       PBYTE pb_PortValue;\r
+          \r
        b_ModulNbr              = (BYTE) CR_AREF(insn->chanspec);\r
-       b_PortOperation = (BYTE) data[0];// Input or output 
-       b_PortOnOFF             = (BYTE) data[1];// if output then On or Off
+       b_PortOperation = (BYTE) data[0];// Input or output \r
+       b_PortOnOFF             = (BYTE) data[1];// if output then On or Off\r
        b_PortValue             = (BYTE) data[2];// if out put then Value\r
        i_ReturnValue   = insn->n;\r
-        pb_PortValue    = (PBYTE) &data[0];\r// if input then read value
-       
+        pb_PortValue    = (PBYTE) &data[0];\r
+// if input then read value\r
+       \r
 \r
 \r
     switch(b_PortOperation)\r
@@ -763,7 +791,7 @@ INT i_APCI1710_InsnBitsDigitalIOPortOnOff(comedi_device *dev,comedi_subdevice *s
 \r
           dw_StatusReg=inl(devpriv->s_BoardInfos.ui_Address + (64 * b_ModulNbr));\r
                 *pb_PortValue = (BYTE) (dw_StatusReg ^ 0x1C);\r
-               
+               \r
                 }\r
              else\r
                 {\r
@@ -820,7 +848,7 @@ INT i_APCI1710_InsnBitsDigitalIOPortOnOff(comedi_device *dev,comedi_subdevice *s
                 /* Test the port value */\r
                 /***********************/\r
 \r
-                if ((b_PortValue >= 0) && (b_PortValue <= 7))\r
+                if (b_PortValue <= 7)\r
                    {\r
                    /***********************************/\r
                    /* Test the digital output channel */\r
index 59c79b5487f9be1ce1c65dd628b38394fc8b0a3c..78eef9b253bdc15acc3b90f55dbb7d9da4fcc54b 100644 (file)
@@ -1,4 +1,26 @@
+/**\r
+@verbatim\r
 \r
+Copyright (C) 2004,2005  ADDI-DATA GmbH for the source code of this module. \r
+        \r
+        ADDI-DATA GmbH \r
+        Dieselstrasse 3 \r
+        D-77833 Ottersweier \r
+        Tel: +19(0)7223/9493-0 \r
+        Fax: +49(0)7223/9493-92 \r
+        http://www.addi-data-com \r
+        info@addi-data.com \r
+\r
+This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.\r
+\r
+This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.\r
+\r
+You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+\r
+You shoud also find the complete GPL in the COPYING file accompanying this source code.\r
+\r
+@endverbatim\r
+*/\r
 \r
 \r
 #define                APCI1710_ON                             1                       // Digital  Output ON or OFF\r
@@ -8,7 +30,7 @@
 #define                APCI1710_INPUT                  0               // Digital I/O\r
 #define                APCI1710_OUTPUT                 1\r
 \r
-#define         APCI1710_DIGIO_MEMORYONOFF  0x10       //      
+#define         APCI1710_DIGIO_MEMORYONOFF  0x10       //      \r
 #define         APCI1710_DIGIO_INIT         0x11\r
 \r
 \r
index 5751bca5ec6c6c04f39c1be528f5c5e50ae70ab5..03211f0ef9b43f7e0c64e84655bb47f588a56c13 100644 (file)
@@ -1,14 +1,37 @@
-/*\r
+/**\r
+@verbatim\r
+\r
+Copyright (C) 2004,2005  ADDI-DATA GmbH for the source code of this module. \r
+        \r
+        ADDI-DATA GmbH \r
+        Dieselstrasse 3 \r
+        D-77833 Ottersweier \r
+        Tel: +19(0)7223/9493-0 \r
+        Fax: +49(0)7223/9493-92 \r
+        http://www.addi-data-com \r
+        info@addi-data.com \r
+\r
+This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.\r
+\r
+This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.\r
+\r
+You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+\r
+You shoud also find the complete GPL in the COPYING file accompanying this source code.\r
+\r
+@endverbatim\r
+*/\r
+/*    \r
   +-----------------------------------------------------------------------+\r
   | (C) ADDI-DATA GmbH          Dieselstraße 3       D-77833 Ottersweier  |\r
   +-----------------------------------------------------------------------+\r
   | Tel : +49 (0) 7223/9493-0     | email    : info@addi-data.com         |\r
   | Fax : +49 (0) 7223/9493-92    | Internet : http://www.addi-data.com   |\r
   +-----------------------------------------------------------------------+\r
-  | Project   : API APCI1710      |     Compiler   : BORLANDC/MICROSOFT C |\r
-  | Module name : INC_CPT.C       |     Version    : 3.1     / 6.0        |\r
+  | Project     : API APCI1710    | Compiler : gcc                        |\r
+  | Module name : INC_CPT.C       | Version  : 2.96                       |\r
   +-------------------------------+---------------------------------------+\r
-  | Author    : S.WEBER           |     Date       : 08.01.98             |\r
+  | Project manager: Eric Stolz   | Date     :  02/12/2002                |\r
   +-----------------------------------------------------------------------+\r
   | Description :   APCI-1710 incremental counter module                  |\r
   |                                                                       |\r
@@ -60,7 +83,10 @@ comedi_insn *insn,lsampl_t *data)
        UINT  ui_ConfigType; \r
        INT    i_ReturnValue = 0;\r
        ui_ConfigType=CR_CHAN(insn->chanspec);\r
-\r       devpriv->tsk_Current=current; // Save the current process task structure
+       \r
+       printk ("\nINC_CPT");\r
+\r
+       devpriv->tsk_Current=current; // Save the current process task structure\r
        switch(ui_ConfigType)\r
        {\r
        case    APCI1710_INCCPT_INITCOUNTER     :                               \r
@@ -367,7 +393,8 @@ INT   i_APCI1710_InitCounter (comedi_device *dev,
                             /*********************************************************/\r
                             /* The selected second counter operating option is wrong */\r
                             /*********************************************************/\r
-\r                        DPRINTK("The selected second counter operating option is wrong\n");
+\r
+                        DPRINTK("The selected second counter operating option is wrong\n");\r
                             i_ReturnValue = -7;\r
                             }\r
                          }\r
@@ -376,7 +403,8 @@ INT   i_APCI1710_InitCounter (comedi_device *dev,
                          /*******************************************************/\r
                          /* The selected second counter operating mode is wrong */\r
                          /*******************************************************/\r
-\r                        DPRINTK("The selected second counter operating mode is wrong\n");
+\r
+                         DPRINTK("The selected second counter operating mode is wrong\n");\r
                          i_ReturnValue = -6;\r
                          }\r
                       }\r
@@ -386,7 +414,8 @@ INT   i_APCI1710_InitCounter (comedi_device *dev,
                    /********************************************************/\r
                    /* The selected first counter operating option is wrong */\r
                    /********************************************************/\r
-\r                   DPRINTK("The selected first counter operating option is wrong\n");
+\r
+                   DPRINTK("The selected first counter operating option is wrong\n");\r
                    i_ReturnValue = -5;\r
                    }\r
                 }\r
@@ -404,7 +433,8 @@ INT   i_APCI1710_InitCounter (comedi_device *dev,
              /***************************************/\r
              /* The selected counter range is wrong */\r
              /***************************************/\r
-\r             DPRINTK("The selected counter range is wrong\n");
+\r
+             DPRINTK("The selected counter range is wrong\n");\r
              i_ReturnValue = -3;\r
              }\r
 \r
@@ -466,7 +496,7 @@ INT   i_APCI1710_InitCounter (comedi_device *dev,
              /* Write the configuration */\r
              /***************************/\r
 \r
-          
+          \r
                  outl(devpriv->s_ModuleInfo [b_ModulNbr].\r
                      s_SiemensCounterInfo.\r
                      s_ModeRegister.\r
@@ -487,7 +517,8 @@ INT   i_APCI1710_InitCounter (comedi_device *dev,
           /**************************************/\r
           /* The module is not a counter module */\r
           /**************************************/\r
-\r          DPRINTK("The module is not a counter module\n");
+\r
+          DPRINTK("The module is not a counter module\n");\r
           i_ReturnValue = -2;\r
           }\r
 \r
@@ -576,7 +607,7 @@ INT  i_APCI1710_CounterAutoTest  (comedi_device *dev,PBYTE   pb_TestStatus)
                 /* Start the test */\r
                 /******************/\r
 \r
-                
+                \r
                        outl(3,devpriv->s_BoardInfos.\r
                         ui_Address + 16 + (64 * b_ModulCpt));\r
 \r
@@ -584,7 +615,7 @@ INT  i_APCI1710_CounterAutoTest  (comedi_device *dev,PBYTE   pb_TestStatus)
                 /* Tatch the counter */\r
                 /*********************/\r
 \r
-                
+                \r
                        outl(1,devpriv->s_BoardInfos.\r
                         ui_Address + (64 * b_ModulCpt));\r
 \r
@@ -592,7 +623,7 @@ INT  i_APCI1710_CounterAutoTest  (comedi_device *dev,PBYTE   pb_TestStatus)
                 /* Read the latch value */\r
                 /************************/\r
 \r
-               
+               \r
                        dw_LathchValue=inl(devpriv->s_BoardInfos.\r
                        ui_Address + 4 + (64 * b_ModulCpt));\r
 \r
@@ -618,7 +649,8 @@ INT  i_APCI1710_CounterAutoTest  (comedi_device *dev,PBYTE   pb_TestStatus)
           /***************************/\r
           /* No counter module found */\r
           /***************************/\r
-\r          DPRINTK("No counter module found\n");
+\r
+          DPRINTK("No counter module found\n");\r
           i_ReturnValue = -2;\r
           }\r
 \r
@@ -1003,7 +1035,8 @@ INT   i_APCI1710_InitIndex    (comedi_device *dev,
                       /************************************/\r
                       /* The auto mode parameter is wrong */\r
                       /************************************/\r
-\r                         DPRINTK("The auto mode parameter is wrong\n");
+\r
+                          DPRINTK("The auto mode parameter is wrong\n");\r
                       i_ReturnValue = -6;\r
                       }\r
                    }\r
@@ -1012,7 +1045,8 @@ INT   i_APCI1710_InitIndex    (comedi_device *dev,
                    /***********************************************/\r
                    /* The index operating mode parameter is wrong */\r
                    /***********************************************/\r
-\r                  DPRINTK("The index operating mode parameter is wrong\n");
+\r
+                   DPRINTK("The index operating mode parameter is wrong\n");\r
                    i_ReturnValue = -5;\r
                    }\r
                 }\r
@@ -1021,7 +1055,8 @@ INT   i_APCI1710_InitIndex    (comedi_device *dev,
                 /*******************************************/\r
                 /* The reference action parameter is wrong */\r
                 /*******************************************/\r
-\r               DPRINTK("The reference action parameter is wrong\n");
+\r
+                DPRINTK("The reference action parameter is wrong\n");\r
                 i_ReturnValue = -4;\r
                 }\r
              }\r
@@ -1031,7 +1066,8 @@ INT   i_APCI1710_InitIndex    (comedi_device *dev,
              /* Counter not initialised see function */\r
              /* "i_APCI1710_InitCounter"             */\r
              /****************************************/\r
-\r            DPRINTK("Counter not initialised\n");     
+\r
+             DPRINTK("Counter not initialised\n");     \r
              i_ReturnValue = -3;\r
              }\r
           }\r
@@ -1040,7 +1076,8 @@ INT   i_APCI1710_InitIndex    (comedi_device *dev,
           /*************************************************/\r
           /* The selected module number parameter is wrong */\r
           /*************************************************/\r
-\r         DPRINTK("The selected module number parameter is wrong\n");
+\r
+          DPRINTK("The selected module number parameter is wrong\n");\r
           i_ReturnValue = -2;\r
           }\r
 \r
@@ -1143,7 +1180,7 @@ INT   i_APCI1710_InitReference        (comedi_device *dev,
                                      b_ModeRegister2 & APCI1710_REFERENCE_LOW;\r
                    }\r
 \r
-                
+                \r
                 outl(devpriv->s_ModuleInfo [b_ModulNbr].\r
                         s_SiemensCounterInfo.\r
                         s_ModeRegister.\r
@@ -1162,7 +1199,8 @@ INT   i_APCI1710_InitReference        (comedi_device *dev,
                 /**************************************/\r
                 /* Reference level parameter is wrong */\r
                 /**************************************/\r
-\r               DPRINTK("Reference level parameter is wrong\n");
+\r
+                DPRINTK("Reference level parameter is wrong\n");\r
                 i_ReturnValue = -4;\r
                 }\r
              }\r
@@ -1172,7 +1210,8 @@ INT   i_APCI1710_InitReference        (comedi_device *dev,
              /* Counter not initialised see function */\r
              /* "i_APCI1710_InitCounter"             */\r
              /****************************************/\r
-\r            DPRINTK("Counter not initialised\n");     
+\r
+             DPRINTK("Counter not initialised\n");     \r
              i_ReturnValue = -3;\r
              }\r
           }\r
@@ -1181,7 +1220,8 @@ INT   i_APCI1710_InitReference        (comedi_device *dev,
           /*************************************************/\r
           /* The selected module number parameter is wrong */\r
           /*************************************************/\r
-\r         DPRINTK("The selected module number parameter is wrong\n");  
+\r
+          DPRINTK("The selected module number parameter is wrong\n");  \r
           i_ReturnValue = -2;\r
           }\r
 \r
@@ -1287,7 +1327,8 @@ INT       i_APCI1710_InitExternalStrobe   (comedi_device *dev,
                    /********************************************/\r
                    /* External strobe level parameter is wrong */\r
                    /********************************************/\r
-\r                      DPRINTK("External strobe level parameter is wrong\n");
+\r
+                       DPRINTK("External strobe level parameter is wrong\n");\r
                    i_ReturnValue = -5;\r
                    }\r
                 } // if (b_ExternalStrobe == 0 || b_ExternalStrobe == 1)\r
@@ -1296,7 +1337,8 @@ INT       i_APCI1710_InitExternalStrobe   (comedi_device *dev,
                 /**************************************/\r
                 /* External strobe selection is wrong */\r
                 /**************************************/\r
-\r               DPRINTK("External strobe selection is wrong\n");
+\r
+                DPRINTK("External strobe selection is wrong\n");\r
                 i_ReturnValue = -4;\r
                 } // if (b_ExternalStrobe == 0 || b_ExternalStrobe == 1)\r
              }\r
@@ -1306,7 +1348,8 @@ INT       i_APCI1710_InitExternalStrobe   (comedi_device *dev,
              /* Counter not initialised see function */\r
              /* "i_APCI1710_InitCounter"             */\r
              /****************************************/\r
-\r            DPRINTK("Counter not initialised\n");     
+\r
+             DPRINTK("Counter not initialised\n");     \r
              i_ReturnValue = -3;\r
              }\r
           }\r
@@ -1315,7 +1358,8 @@ INT       i_APCI1710_InitExternalStrobe   (comedi_device *dev,
           /*************************************************/\r
           /* The selected module number parameter is wrong */\r
           /*************************************************/\r
-\r         DPRINTK("The selected module number parameter is wrong\n");  
+\r
+          DPRINTK("The selected module number parameter is wrong\n");  \r
           i_ReturnValue = -2;\r
           }\r
 \r
@@ -1388,7 +1432,8 @@ INT   i_APCI1710_InitCompareLogic     (comedi_device *dev,
              /* Counter not initialised see function */\r
              /* "i_APCI1710_InitCounter"             */\r
              /****************************************/\r
-\r            DPRINTK("Counter not initialised\n");     
+\r
+             DPRINTK("Counter not initialised\n");     \r
              i_ReturnValue = -3;\r
              }\r
           }\r
@@ -1397,7 +1442,8 @@ INT   i_APCI1710_InitCompareLogic     (comedi_device *dev,
           /*************************************************/\r
           /* The selected module number parameter is wrong */\r
           /*************************************************/\r
-\r         DPRINTK("The selected module number parameter is wrong\n");  
+\r
+          DPRINTK("The selected module number parameter is wrong\n");  \r
           i_ReturnValue = -2;\r
           }\r
 \r
@@ -1463,7 +1509,7 @@ INT       i_APCI1710_InitFrequencyMeasurement     (comedi_device *dev,
                                                 PULONG      pul_RealTimingInterval)\r
        {\r
        INT    i_ReturnValue = 0;\r
-       ULONG ul_TimerValue;\r
+       ULONG ul_TimerValue  = 0;\r
        double d_RealTimingInterval;\r
        DWORD dw_Status      = 0;\r
        \r
@@ -1495,7 +1541,7 @@ INT       i_APCI1710_InitFrequencyMeasurement     (comedi_device *dev,
                 /* Test the timing unit */\r
                 /************************/\r
 \r
-                if ((b_TimingUnity >= 0) && (b_TimingUnity <= 2))\r
+                if (b_TimingUnity <= 2)\r
                    {\r
                    /**********************************/\r
                    /* Test the base timing selection */\r
@@ -1545,7 +1591,8 @@ INT       i_APCI1710_InitFrequencyMeasurement     (comedi_device *dev,
                                /*****************************/\r
                                /* 40MHz quartz not on board */\r
                                /*****************************/\r
-\r                              DPRINTK("40MHz quartz not on board\n");
+\r
+                               DPRINTK("40MHz quartz not on board\n");\r
                                i_ReturnValue = -7;\r
                                }\r
                             }\r
@@ -1572,7 +1619,7 @@ INT       i_APCI1710_InitFrequencyMeasurement     (comedi_device *dev,
                          if ((devpriv->s_BoardInfos.\r
                               dw_MolduleConfiguration [b_ModulNbr] & 0xFFFF) >= 0x3131)\r
                             {\r
-                           
+                           \r
                                /**********************/\r
                                /* Test if 40MHz used */\r
                                /**********************/\r
@@ -1614,12 +1661,13 @@ INT     i_APCI1710_InitFrequencyMeasurement     (comedi_device *dev,
                                                     b_ModeRegister4 & APCI1710_DISABLE_40MHZ_FREQUENCY;\r
 \r
                                   } // if (b_PCIInputClock == APCI1710_40MHZ)\r
-                           
+                           \r
 \r
                             /********************************/\r
                             /* Calculate the division fator */\r
                             /********************************/\r
 \r
+                            fpu_begin ();\r
                             switch (b_TimingUnity)\r
                                {\r
                                /******/\r
@@ -1664,7 +1712,8 @@ INT       i_APCI1710_InitFrequencyMeasurement     (comedi_device *dev,
                                /* æs */\r
                                /******/\r
 \r
-                               case 1:\r                                
+                               case 1:\r
+                               \r
                                     \r
                                        /******************/\r
                                        /* Timer 0 factor */\r
@@ -1703,7 +1752,8 @@ INT       i_APCI1710_InitFrequencyMeasurement     (comedi_device *dev,
                                /* ms */\r
                                /******/\r
 \r
-                               case 2:\r                                
+                               case 2:\r
+                               \r
                                     \r
                                        /******************/\r
                                        /* Timer 0 factor */\r
@@ -1738,6 +1788,7 @@ INT       i_APCI1710_InitFrequencyMeasurement     (comedi_device *dev,
                                     break;\r
                                }\r
 \r
+                            fpu_end ();\r
                             /*************************/\r
                             /* Write the timer value */\r
                             /*************************/\r
@@ -1761,7 +1812,8 @@ INT       i_APCI1710_InitFrequencyMeasurement     (comedi_device *dev,
                             /***************************/\r
                             /* Counter not initialised */\r
                             /***************************/\r
-\r                        DPRINTK("Counter not initialised\n");  
+\r
+                        DPRINTK("Counter not initialised\n");  \r
                             i_ReturnValue = -3;\r
                             }\r
                          } // if (i_ReturnValue == 0)\r
@@ -1771,7 +1823,8 @@ INT       i_APCI1710_InitFrequencyMeasurement     (comedi_device *dev,
                       /**********************************/\r
                       /* Base timing selection is wrong */\r
                       /**********************************/\r
-\r                         DPRINTK("Base timing selection is wrong\n");  
+\r
+                          DPRINTK("Base timing selection is wrong\n");  \r
                       i_ReturnValue = -6;\r
                       }\r
                    }\r
@@ -1780,7 +1833,8 @@ INT       i_APCI1710_InitFrequencyMeasurement     (comedi_device *dev,
                    /***********************************/\r
                    /* Timing unity selection is wrong */\r
                    /***********************************/\r
-\r                      DPRINTK("Timing unity selection is wrong\n");
+\r
+                       DPRINTK("Timing unity selection is wrong\n");\r
                    i_ReturnValue = -5;\r
                    }\r
                 }\r
@@ -1789,7 +1843,8 @@ INT       i_APCI1710_InitFrequencyMeasurement     (comedi_device *dev,
                 /*****************************************/\r
                 /* The selected PCI input clock is wrong */\r
                 /*****************************************/\r
-\r               DPRINTK("The selected PCI input clock is wrong\n");    
+\r
+                DPRINTK("The selected PCI input clock is wrong\n");    \r
                 i_ReturnValue = -4;\r
                 }\r
              }\r
@@ -1799,7 +1854,8 @@ INT       i_APCI1710_InitFrequencyMeasurement     (comedi_device *dev,
              /* Counter not initialised see function */\r
              /* "i_APCI1710_InitCounter"             */\r
              /****************************************/\r
-\r            DPRINTK("Counter not initialised\n");     
+\r
+             DPRINTK("Counter not initialised\n");     \r
              i_ReturnValue = -3;\r
              }\r
           }\r
@@ -1808,7 +1864,8 @@ INT       i_APCI1710_InitFrequencyMeasurement     (comedi_device *dev,
           /*************************************************/\r
           /* The selected module number parameter is wrong */\r
           /*************************************************/\r
-\r         DPRINTK("The selected module number parameter is wrong\n");  
+\r
+          DPRINTK("The selected module number parameter is wrong\n");  \r
           i_ReturnValue = -2;\r
           }\r
 \r
@@ -1842,7 +1899,7 @@ comedi_insn *insn,lsampl_t *data)
        UINT ui_BitsType;\r
        INT i_ReturnValue=0;\r
        ui_BitsType=CR_CHAN(insn->chanspec);\r
-       devpriv->tsk_Current=current; // Save the current process task structure
+       devpriv->tsk_Current=current; // Save the current process task structure\r
 \r
        switch(ui_BitsType)\r
        {\r
@@ -1951,7 +2008,8 @@ INT   i_APCI1710_ClearCounterValue    (comedi_device *dev,
              /* Counter not initialised see function */\r
              /* "i_APCI1710_InitCounter"             */\r
              /****************************************/\r
-\r            DPRINTK("Counter not initialised\n");             
+\r
+             DPRINTK("Counter not initialised\n");             \r
              i_ReturnValue = -3;\r
              }\r
           }\r
@@ -1960,7 +2018,8 @@ INT   i_APCI1710_ClearCounterValue    (comedi_device *dev,
           /*************************************************/\r
           /* The selected module number parameter is wrong */\r
           /*************************************************/\r
-\r         DPRINTK("The selected module number parameter is wrong\n");                  
+\r
+          DPRINTK("The selected module number parameter is wrong\n");                  \r
           i_ReturnValue = -2;\r
           }\r
 \r
@@ -2029,7 +2088,8 @@ INT   i_APCI1710_ClearAllCounterValue (comedi_device *dev)
           /***************************/\r
           /* No counter module found */\r
           /***************************/\r
-\r         DPRINTK("No counter module found\n");        
+\r
+          DPRINTK("No counter module found\n");        \r
           i_ReturnValue = -2;\r
           }\r
 \r
@@ -2187,7 +2247,7 @@ INT       i_APCI1710_SetInputFilter       (comedi_device *dev,
                          /* Test if 40MHz quartz on board */\r
                          /*********************************/\r
 \r
-                        
+                        \r
                        dw_Status=      inl(devpriv->s_BoardInfos.\r
                                 ui_Address + 36 + (64 * b_ModulNbr));\r
 \r
@@ -2200,7 +2260,8 @@ INT       i_APCI1710_SetInputFilter       (comedi_device *dev,
                             /*****************************/\r
                             /* 40MHz quartz not on board */\r
                             /*****************************/\r
-\r                        DPRINTK("40MHz quartz not on board\n"); 
+\r
+                        DPRINTK("40MHz quartz not on board\n"); \r
                             i_ReturnValue = -6;\r
                             }\r
                          } // if (b_PCIInputClock == APCI1710_40MHZ)\r
@@ -2297,7 +2358,8 @@ INT       i_APCI1710_SetInputFilter       (comedi_device *dev,
                       /**************************************/\r
                       /* The selected filter value is wrong */\r
                       /**************************************/\r
-\r                         DPRINTK("The selected filter value is wrong\n");      
+\r
+                          DPRINTK("The selected filter value is wrong\n");      \r
                       i_ReturnValue = -5;\r
                       } // if (b_Filter < 16)\r
                    } // if ((b_PCIInputClock == APCI1710_30MHZ) || (b_PCIInputClock == APCI1710_33MHZ) || (b_PCIInputClock == APCI1710_40MHZ))\r
@@ -2306,7 +2368,8 @@ INT       i_APCI1710_SetInputFilter       (comedi_device *dev,
                    /*****************************************/\r
                    /* The selected PCI input clock is wrong */\r
                    /*****************************************/\r
-\r                      DPRINTK("The selected PCI input clock is wrong\n");
+\r
+                       DPRINTK("The selected PCI input clock is wrong\n");\r
                    i_ReturnValue = 4;\r
                    } // if ((b_PCIInputClock == APCI1710_30MHZ) || (b_PCIInputClock == APCI1710_33MHZ) || (b_PCIInputClock == APCI1710_40MHZ))\r
                 }\r
@@ -2315,7 +2378,8 @@ INT       i_APCI1710_SetInputFilter       (comedi_device *dev,
                 /**************************************/\r
                 /* The module is not a counter module */\r
                 /**************************************/\r
-\r               DPRINTK("The module is not a counter module\n");
+\r
+                DPRINTK("The module is not a counter module\n");\r
                 i_ReturnValue = -3;\r
                 }\r
              }\r
@@ -2324,7 +2388,8 @@ INT       i_APCI1710_SetInputFilter       (comedi_device *dev,
              /**************************************/\r
              /* The module is not a counter module */\r
              /**************************************/\r
-\r            DPRINTK("The module is not a counter module\n");  
+\r
+             DPRINTK("The module is not a counter module\n");  \r
              i_ReturnValue = -3;\r
              }\r
           }\r
@@ -2333,7 +2398,8 @@ INT       i_APCI1710_SetInputFilter       (comedi_device *dev,
           /*************************************************/\r
           /* The selected module number parameter is wrong */\r
           /*************************************************/\r
-\r         DPRINTK("The selected module number parameter is wrong\n");  
+\r
+          DPRINTK("The selected module number parameter is wrong\n");  \r
           i_ReturnValue = -2;\r
           }\r
 \r
@@ -2409,7 +2475,8 @@ INT   i_APCI1710_LatchCounter (comedi_device *dev,
                 /**************************************************/\r
                 /* The selected latch register parameter is wrong */\r
                 /**************************************************/\r
-\r               DPRINTK("The selected latch register parameter is wrong\n");
+\r
+                DPRINTK("The selected latch register parameter is wrong\n");\r
                 i_ReturnValue = -4;\r
                 }\r
              }\r
@@ -2419,7 +2486,8 @@ INT   i_APCI1710_LatchCounter (comedi_device *dev,
              /* Counter not initialised see function */\r
              /* "i_APCI1710_InitCounter"             */\r
              /****************************************/\r
-\r            DPRINTK("Counter not initialised\n");     
+\r
+             DPRINTK("Counter not initialised\n");     \r
              i_ReturnValue = -3;\r
              }\r
           }\r
@@ -2428,7 +2496,8 @@ INT   i_APCI1710_LatchCounter (comedi_device *dev,
           /*************************************************/\r
           /* The selected module number parameter is wrong */\r
           /*************************************************/\r
-\r         DPRINTK("The selected module number parameter is wrong\n");  
+\r
+          DPRINTK("The selected module number parameter is wrong\n");  \r
           i_ReturnValue = -2;\r
           }\r
 \r
@@ -2553,7 +2622,8 @@ INT       i_APCI1710_SetIndexAndReferenceSource   (comedi_device *dev,
                    /*********************************/\r
                    /* The source selection is wrong */\r
                     /*********************************/\r
-\r                   DPRINTK("The source selection is wrong\n");
+\r
+                   DPRINTK("The source selection is wrong\n");\r
                    i_ReturnValue = -4;\r
                    } // if (b_SourceSelection == APCI1710_SOURCE_0 ||b_SourceSelection == APCI1710_SOURCE_1)\r
                 }\r
@@ -2562,7 +2632,8 @@ INT       i_APCI1710_SetIndexAndReferenceSource   (comedi_device *dev,
                 /**************************************/\r
                 /* The module is not a counter module */\r
                 /**************************************/\r
-\r               DPRINTK("The module is not a counter module\n");       
+\r
+                DPRINTK("The module is not a counter module\n");       \r
                 i_ReturnValue = -3;\r
                 }\r
              }\r
@@ -2571,7 +2642,8 @@ INT       i_APCI1710_SetIndexAndReferenceSource   (comedi_device *dev,
              /**************************************/\r
              /* The module is not a counter module */\r
              /**************************************/\r
-\r            DPRINTK("The module is not a counter module\n");  
+\r
+             DPRINTK("The module is not a counter module\n");  \r
              i_ReturnValue = -3;\r
              }\r
           }\r
@@ -2580,7 +2652,8 @@ INT       i_APCI1710_SetIndexAndReferenceSource   (comedi_device *dev,
           /***************************************/\r
           /* The selected module number is wrong */\r
           /***************************************/\r
-\r         DPRINTK("The selected module number is wrong\n");    
+\r
+          DPRINTK("The selected module number is wrong\n");    \r
           i_ReturnValue = -2;\r
           }\r
 \r
@@ -2659,7 +2732,8 @@ INT       i_APCI1710_SetDigitalChlOn (comedi_device *dev,
              /* Counter not initialised see function */\r
              /* "i_APCI1710_InitCounter"             */\r
              /****************************************/\r
-\r             DPRINTK("Counter not initialised\n");
+\r
+             DPRINTK("Counter not initialised\n");\r
              i_ReturnValue = -3;\r
              }\r
           }\r
@@ -2668,7 +2742,8 @@ INT       i_APCI1710_SetDigitalChlOn (comedi_device *dev,
           /*************************************************/\r
           /* The selected module number parameter is wrong */\r
           /*************************************************/\r
-\r         DPRINTK("The selected module number parameter is wrong\n");  
+\r
+          DPRINTK("The selected module number parameter is wrong\n");  \r
           i_ReturnValue = -2;\r
           }\r
 \r
@@ -2747,7 +2822,8 @@ INT       i_APCI1710_SetDigitalChlOff (comedi_device *dev,
              /* Counter not initialised see function */\r
              /* "i_APCI1710_InitCounter"             */\r
              /****************************************/\r
-\r            DPRINTK("Counter not initialised\n");     
+\r
+             DPRINTK("Counter not initialised\n");     \r
              i_ReturnValue = -3;\r
              }\r
           }\r
@@ -2756,7 +2832,8 @@ INT       i_APCI1710_SetDigitalChlOff (comedi_device *dev,
           /*************************************************/\r
           /* The selected module number parameter is wrong */\r
           /*************************************************/\r
-\r         DPRINTK("The selected module number parameter is wrong\n");  
+\r
+          DPRINTK("The selected module number parameter is wrong\n");  \r
           i_ReturnValue = -2;\r
           }\r
 \r
@@ -2790,7 +2867,7 @@ comedi_insn *insn,lsampl_t *data)
        INT i_ReturnValue=0;\r
         \r
        ui_WriteType=CR_CHAN(insn->chanspec);\r
-       devpriv->tsk_Current=current; // Save the current process task structure
+       devpriv->tsk_Current=current; // Save the current process task structure\r
 \r
        switch(ui_WriteType)\r
        {\r
@@ -2936,7 +3013,8 @@ INT  i_APCI1710_EnableLatchInterrupt (comedi_device *dev,
              /* Counter not initialised see function */\r
              /* "i_APCI1710_InitCounter"             */\r
              /****************************************/\r
-\r            DPRINTK("Counter not initialised\n");     
+\r
+             DPRINTK("Counter not initialised\n");     \r
              i_ReturnValue = -3;\r
              }\r
           }\r
@@ -2945,7 +3023,8 @@ INT  i_APCI1710_EnableLatchInterrupt (comedi_device *dev,
           /*************************************************/\r
           /* The selected module number parameter is wrong */\r
           /*************************************************/\r
-\r         DPRINTK("The selected module number parameter is wrong\n");
+\r
+          DPRINTK("The selected module number parameter is wrong\n");\r
           i_ReturnValue = -2;\r
           }\r
 \r
@@ -3035,7 +3114,8 @@ INT   i_APCI1710_DisableLatchInterrupt        (comedi_device *dev,
              /* Counter not initialised see function */\r
              /* "i_APCI1710_InitCounter"             */\r
              /****************************************/\r
-\r            DPRINTK("Counter not initialised\n");     
+\r
+             DPRINTK("Counter not initialised\n");     \r
              i_ReturnValue = -3;\r
              }\r
           }\r
@@ -3044,7 +3124,8 @@ INT   i_APCI1710_DisableLatchInterrupt        (comedi_device *dev,
           /*************************************************/\r
           /* The selected module number parameter is wrong */\r
           /*************************************************/\r
-\r         DPRINTK("The selected module number parameter is wrong\n");  
+\r
+          DPRINTK("The selected module number parameter is wrong\n");  \r
           i_ReturnValue = -2;\r
           }\r
 \r
@@ -3123,7 +3204,8 @@ INT   i_APCI1710_Write16BitCounterValue       (comedi_device *dev,
                 /**************************************************/\r
                 /* The selected 16-Bit counter parameter is wrong */\r
                 /**************************************************/\r
-\r               DPRINTK("The selected 16-Bit counter parameter is wrong\n");
+\r
+                DPRINTK("The selected 16-Bit counter parameter is wrong\n");\r
                 i_ReturnValue = -4;\r
                 }\r
              }\r
@@ -3133,7 +3215,8 @@ INT   i_APCI1710_Write16BitCounterValue       (comedi_device *dev,
              /* Counter not initialised see function */\r
              /* "i_APCI1710_InitCounter"             */\r
              /****************************************/\r
-\r            DPRINTK("Counter not initialised\n");     
+\r
+             DPRINTK("Counter not initialised\n");     \r
              i_ReturnValue = -3;\r
              }\r
           }\r
@@ -3142,7 +3225,8 @@ INT   i_APCI1710_Write16BitCounterValue       (comedi_device *dev,
           /*************************************************/\r
           /* The selected module number parameter is wrong */\r
           /*************************************************/\r
-\r         DPRINTK("The selected module number parameter is wrong\n");
+\r
+          DPRINTK("The selected module number parameter is wrong\n");\r
           i_ReturnValue = -2;\r
           }\r
 \r
@@ -3210,7 +3294,8 @@ INT   i_APCI1710_Write32BitCounterValue       (comedi_device *dev,
              /* Counter not initialised see function */\r
              /* "i_APCI1710_InitCounter"             */\r
              /****************************************/\r
-\r            DPRINTK("Counter not initialised\n");     
+\r
+             DPRINTK("Counter not initialised\n");     \r
              i_ReturnValue = -3;\r
              }\r
           }\r
@@ -3219,7 +3304,8 @@ INT   i_APCI1710_Write32BitCounterValue       (comedi_device *dev,
           /*************************************************/\r
           /* The selected module number parameter is wrong */\r
           /*************************************************/\r
-\r         DPRINTK("The selected module number parameter is wrong\n");  
+\r
+          DPRINTK("The selected module number parameter is wrong\n");  \r
           i_ReturnValue = -2;\r
           }\r
 \r
@@ -3310,7 +3396,8 @@ INT   i_APCI1710_EnableIndex  (comedi_device *dev,
                 /*************************************************************/\r
                 /* Index not initialised see function "i_APCI1710_InitIndex" */\r
                 /*************************************************************/\r
-\r               DPRINTK("Index not initialised \n");
+\r
+                DPRINTK("Index not initialised \n");\r
                 i_ReturnValue = -4;\r
                 }\r
              }\r
@@ -3320,7 +3407,8 @@ INT   i_APCI1710_EnableIndex  (comedi_device *dev,
              /* Counter not initialised see function */\r
              /* "i_APCI1710_InitCounter"             */\r
              /****************************************/\r
-\r            DPRINTK("Counter not initialised\n");     
+\r
+             DPRINTK("Counter not initialised\n");     \r
              i_ReturnValue = -3;\r
              }\r
           }\r
@@ -3329,7 +3417,8 @@ INT   i_APCI1710_EnableIndex  (comedi_device *dev,
           /*************************************************/\r
           /* The selected module number parameter is wrong */\r
           /*************************************************/\r
-\r         DPRINTK("The selected module number parameter is wrong\n");
+\r
+          DPRINTK("The selected module number parameter is wrong\n");\r
           i_ReturnValue = -2;\r
           }\r
 \r
@@ -3414,7 +3503,8 @@ INT  i_APCI1710_DisableIndex (comedi_device *dev,
                 /*************************************************************/\r
                 /* Index not initialised see function "i_APCI1710_InitIndex" */\r
                 /*************************************************************/\r
-\r               DPRINTK("Index not initialised  \n");
+\r
+                DPRINTK("Index not initialised  \n");\r
                 i_ReturnValue = -4;\r
                 }\r
              }\r
@@ -3424,7 +3514,8 @@ INT  i_APCI1710_DisableIndex (comedi_device *dev,
              /* Counter not initialised see function */\r
              /* "i_APCI1710_InitCounter"             */\r
              /****************************************/\r
-\r            DPRINTK("Counter not initialised\n");     
+\r
+             DPRINTK("Counter not initialised\n");     \r
              i_ReturnValue = -3;\r
              }\r
           }\r
@@ -3433,7 +3524,8 @@ INT  i_APCI1710_DisableIndex (comedi_device *dev,
           /*************************************************/\r
           /* The selected module number parameter is wrong */\r
           /*************************************************/\r
-\r         DPRINTK("The selected module number parameter is wrong\n");  
+\r
+          DPRINTK("The selected module number parameter is wrong\n");  \r
           i_ReturnValue = -2;\r
           }\r
 \r
@@ -3528,7 +3620,8 @@ INT   i_APCI1710_EnableCompareLogic   (comedi_device *dev,
                 /*********************************/\r
                 /* Compare logic not initialised */\r
                 /*********************************/\r
-\r               DPRINTK("Compare logic not initialised\n");
+\r
+                DPRINTK("Compare logic not initialised\n");\r
                 i_ReturnValue = -4;\r
                 }\r
              }\r
@@ -3538,7 +3631,8 @@ INT   i_APCI1710_EnableCompareLogic   (comedi_device *dev,
              /* Counter not initialised see function */\r
              /* "i_APCI1710_InitCounter"             */\r
              /****************************************/\r
-\r            DPRINTK("Counter not initialised\n");     
+\r
+             DPRINTK("Counter not initialised\n");     \r
              i_ReturnValue = -3;\r
              }\r
           }\r
@@ -3547,7 +3641,8 @@ INT   i_APCI1710_EnableCompareLogic   (comedi_device *dev,
           /*************************************************/\r
           /* The selected module number parameter is wrong */\r
           /*************************************************/\r
-\r         DPRINTK("The selected module number parameter is wrong\n");
+\r
+          DPRINTK("The selected module number parameter is wrong\n");\r
           i_ReturnValue = -2;\r
           }\r
 \r
@@ -3636,7 +3731,8 @@ INT   i_APCI1710_DisableCompareLogic  (comedi_device *dev,
                 /*********************************/\r
                 /* Compare logic not initialised */\r
                 /*********************************/\r
-\r               DPRINTK("Compare logic not initialised\n");
+\r
+                DPRINTK("Compare logic not initialised\n");\r
                 i_ReturnValue = -4;\r
                 }\r
              }\r
@@ -3646,7 +3742,8 @@ INT   i_APCI1710_DisableCompareLogic  (comedi_device *dev,
              /* Counter not initialised see function */\r
              /* "i_APCI1710_InitCounter"             */\r
              /****************************************/\r
-\r            DPRINTK("Counter not initialised\n");     
+\r
+             DPRINTK("Counter not initialised\n");     \r
              i_ReturnValue = -3;\r
              }\r
           }\r
@@ -3655,7 +3752,8 @@ INT   i_APCI1710_DisableCompareLogic  (comedi_device *dev,
           /*************************************************/\r
           /* The selected module number parameter is wrong */\r
           /*************************************************/\r
-\r         DPRINTK("The selected module number parameter is wrong\n");
+\r
+          DPRINTK("The selected module number parameter is wrong\n");\r
           i_ReturnValue = -2;\r
           }\r
 \r
@@ -3790,7 +3888,8 @@ INT       i_APCI1710_EnableFrequencyMeasurement   (comedi_device *dev,
                    /********************************/\r
                    /* Interrupt parameter is wrong */\r
                    /********************************/\r
-\r                  DPRINTK("Interrupt parameter is wrong\n");
+\r
+                   DPRINTK("Interrupt parameter is wrong\n");\r
                    i_ReturnValue = -5;\r
                    }\r
                 }\r
@@ -3799,7 +3898,8 @@ INT       i_APCI1710_EnableFrequencyMeasurement   (comedi_device *dev,
                 /***********************************************/\r
                 /* Frequency measurement logic not initialised */\r
                 /***********************************************/\r
-\r               DPRINTK("Frequency measurement logic not initialised\n");
+\r
+                DPRINTK("Frequency measurement logic not initialised\n");\r
                 i_ReturnValue = -4;\r
                 }\r
              }\r
@@ -3809,7 +3909,8 @@ INT       i_APCI1710_EnableFrequencyMeasurement   (comedi_device *dev,
              /* Counter not initialised see function */\r
              /* "i_APCI1710_InitCounter"             */\r
              /****************************************/\r
-\r            DPRINTK("Counter not initialised\n");     
+\r
+             DPRINTK("Counter not initialised\n");     \r
              i_ReturnValue = -3;\r
              }\r
           }\r
@@ -3818,7 +3919,8 @@ INT       i_APCI1710_EnableFrequencyMeasurement   (comedi_device *dev,
           /*************************************************/\r
           /* The selected module number parameter is wrong */\r
           /*************************************************/\r
-\r          DPRINTK("The selected module number parameter is wrong\n"); 
+\r
+          DPRINTK("The selected module number parameter is wrong\n"); \r
           i_ReturnValue = -2;\r
           }\r
 \r
@@ -3924,7 +4026,8 @@ INT       i_APCI1710_DisableFrequencyMeasurement  (comedi_device *dev,
                 /***********************************************/\r
                 /* Frequency measurement logic not initialised */\r
                 /***********************************************/\r
-\r               DPRINTK("Frequency measurement logic not initialised\n");
+\r
+                DPRINTK("Frequency measurement logic not initialised\n");\r
                 i_ReturnValue = -4;\r
                 }\r
              }\r
@@ -3934,7 +4037,8 @@ INT       i_APCI1710_DisableFrequencyMeasurement  (comedi_device *dev,
              /* Counter not initialised see function */\r
              /* "i_APCI1710_InitCounter"             */\r
              /****************************************/\r
-\r            DPRINTK("Counter not initialised\n");     
+\r
+             DPRINTK("Counter not initialised\n");     \r
              i_ReturnValue = -3;\r
              }\r
           }\r
@@ -3943,7 +4047,8 @@ INT       i_APCI1710_DisableFrequencyMeasurement  (comedi_device *dev,
           /*************************************************/\r
           /* The selected module number parameter is wrong */\r
           /*************************************************/\r
-\r         DPRINTK("The selected module number parameter is wrong\n");  
+\r
+          DPRINTK("The selected module number parameter is wrong\n");  \r
           i_ReturnValue = -2;\r
           }\r
 \r
@@ -3977,10 +4082,11 @@ INT     i_APCI1710_InsnReadINCCPT(comedi_device *dev,comedi_subdevice *s,
 comedi_insn *insn,lsampl_t *data)\r
 {\r
        UINT ui_ReadType;\r
-       INT  i_ReturnValue=0;
+       INT  i_ReturnValue=0;\r
         \r
        ui_ReadType=CR_CHAN(insn->chanspec);\r
-\r       devpriv->tsk_Current=current; // Save the current process task structure
+\r
+       devpriv->tsk_Current=current; // Save the current process task structure\r
        switch(ui_ReadType)\r
        {\r
        case APCI1710_INCCPT_READLATCHREGISTERSTATUS:\r
@@ -3995,7 +4101,7 @@ comedi_insn *insn,lsampl_t *data)
                                                 (BYTE)   CR_AREF(insn->chanspec),\r
                                                 (BYTE)   CR_RANGE(insn->chanspec),\r
                                                 (PULONG) &data[0]);\r
-                printk("Latch Register Value %d\n",data[0]);
+                printk("Latch Register Value %d\n",data[0]);\r
        break;\r
 \r
        case APCI1710_INCCPT_READ16BITCOUNTERVALUE:\r
@@ -4045,8 +4151,8 @@ comedi_insn *insn,lsampl_t *data)
        case APCI1710_INCCPT_GETUDSTATUS:\r
                i_ReturnValue=i_APCI1710_GetUDStatus  (dev,\r
                                 (BYTE)   CR_AREF(insn->chanspec),\r
-                                (PBYTE) &data[0]);
-       
+                                (PBYTE) &data[0]);\r
+       \r
        break;\r
     \r
        case APCI1710_INCCPT_GETINTERRUPTUDLATCHEDSTATUS:\r
@@ -4062,33 +4168,33 @@ comedi_insn *insn,lsampl_t *data)
                                 (PBYTE)  &data[1],\r
                                 (PULONG) &data[2]);\r
        break;\r
-         
-        case APCI1710_INCCPT_READINTERRUPT:
-               data[0]=devpriv->s_InterruptParameters.
-                                                     s_FIFOInterruptParameters [devpriv->
-                                                                                s_InterruptParameters.
-                                                                                ui_Read].b_OldModuleMask;
-               data[1]=devpriv->s_InterruptParameters.
-                                                     s_FIFOInterruptParameters [devpriv->
-                                                                                s_InterruptParameters.
-                                                                                ui_Read].ul_OldInterruptMask;
-               data[2]=devpriv->s_InterruptParameters.
-                                                     s_FIFOInterruptParameters [devpriv->
-                                                                                s_InterruptParameters.
-                                                                                ui_Read].ul_OldCounterLatchValue;
-
-                            
-               /**************************/
-               /* Increment the read FIFO */
-               /***************************/
-
-               devpriv->
-               s_InterruptParameters.
-               ui_Read = (devpriv->s_InterruptParameters.
-                                       ui_Read + 1) % APCI1710_SAVE_INTERRUPT;
-         
-               break;                      
+         \r
+        case APCI1710_INCCPT_READINTERRUPT:\r
+               data[0]=devpriv->s_InterruptParameters.\r
+                                                     s_FIFOInterruptParameters [devpriv->\r
+                                                                                s_InterruptParameters.\r
+                                                                                ui_Read].b_OldModuleMask;\r
+               data[1]=devpriv->s_InterruptParameters.\r
+                                                     s_FIFOInterruptParameters [devpriv->\r
+                                                                                s_InterruptParameters.\r
+                                                                                ui_Read].ul_OldInterruptMask;\r
+               data[2]=devpriv->s_InterruptParameters.\r
+                                                     s_FIFOInterruptParameters [devpriv->\r
+                                                                                s_InterruptParameters.\r
+                                                                                ui_Read].ul_OldCounterLatchValue;\r
+\r
+                            \r
+               /**************************/\r
+               /* Increment the read FIFO */\r
+               /***************************/\r
+\r
+               devpriv->\r
+               s_InterruptParameters.\r
+               ui_Read = (devpriv->s_InterruptParameters.\r
+                                       ui_Read + 1) % APCI1710_SAVE_INTERRUPT;\r
\r
+         \r
+               break;                      \r
     \r
        default:\r
                printk("ReadType Parameter wrong\n");\r
@@ -4175,7 +4281,8 @@ INT   i_APCI1710_ReadLatchRegisterStatus      (comedi_device *dev,
                 /**************************************************/\r
                 /* The selected latch register parameter is wrong */\r
                 /**************************************************/\r
-\r                DPRINTK("The selected latch register parameter is wrong\n");
+\r
+                DPRINTK("The selected latch register parameter is wrong\n");\r
                 i_ReturnValue = -4;\r
                 }\r
              }\r
@@ -4185,7 +4292,8 @@ INT   i_APCI1710_ReadLatchRegisterStatus      (comedi_device *dev,
              /* Counter not initialised see function */\r
              /* "i_APCI1710_InitCounter"             */\r
              /****************************************/\r
-\r            DPRINTK("Counter not initialised\n");
+\r
+             DPRINTK("Counter not initialised\n");\r
              i_ReturnValue = -3;\r
              }\r
           }\r
@@ -4194,7 +4302,8 @@ INT   i_APCI1710_ReadLatchRegisterStatus      (comedi_device *dev,
           /*************************************************/\r
           /* The selected module number parameter is wrong */\r
           /*************************************************/\r
-\r         DPRINTK("The selected module number parameter is wrong\n");  
+\r
+          DPRINTK("The selected module number parameter is wrong\n");  \r
           i_ReturnValue = -2;\r
           }\r
 \r
@@ -4262,15 +4371,16 @@ INT   i_APCI1710_ReadLatchRegisterValue       (comedi_device *dev,
              if (b_LatchReg < 2)\r
                 {\r
                        *pul_LatchValue=inl(devpriv->s_BoardInfos.\r
-                       ui_Address + ((b_LatchReg + 1) * 4) + (64 * b_ModulNbr));
-                    
+                       ui_Address + ((b_LatchReg + 1) * 4) + (64 * b_ModulNbr));\r
+                    \r
                 }\r
              else\r
                 {\r
                 /**************************************************/\r
                 /* The selected latch register parameter is wrong */\r
                 /**************************************************/\r
-\r               DPRINTK("The selected latch register parameter is wrong\n");
+\r
+                DPRINTK("The selected latch register parameter is wrong\n");\r
                 i_ReturnValue = -4;\r
                 }\r
              }\r
@@ -4280,7 +4390,8 @@ INT   i_APCI1710_ReadLatchRegisterValue       (comedi_device *dev,
              /* Counter not initialised see function */\r
              /* "i_APCI1710_InitCounter"             */\r
              /****************************************/\r
-\r            DPRINTK("Counter not initialised\n");     
+\r
+             DPRINTK("Counter not initialised\n");     \r
              i_ReturnValue = -3;\r
              }\r
           }\r
@@ -4289,7 +4400,8 @@ INT   i_APCI1710_ReadLatchRegisterValue       (comedi_device *dev,
           /*************************************************/\r
           /* The selected module number parameter is wrong */\r
           /*************************************************/\r
-\r         DPRINTK("The selected module number parameter is wrong\n");  
+\r
+          DPRINTK("The selected module number parameter is wrong\n");  \r
           i_ReturnValue = -2;\r
           }\r
 \r
@@ -4377,7 +4489,8 @@ INT   i_APCI1710_Read16BitCounterValue        (comedi_device *dev,
                 /**************************************************/\r
                 /* The selected 16-Bit counter parameter is wrong */\r
                 /**************************************************/\r
-\r               DPRINTK("The selected 16-Bit counter parameter is wrong\n");
+\r
+                DPRINTK("The selected 16-Bit counter parameter is wrong\n");\r
                 i_ReturnValue = -4;\r
                 }\r
              }\r
@@ -4387,7 +4500,8 @@ INT   i_APCI1710_Read16BitCounterValue        (comedi_device *dev,
              /* Counter not initialised see function */\r
              /* "i_APCI1710_InitCounter"             */\r
              /****************************************/\r
-\r            DPRINTK("Counter not initialised\n");     
+\r
+             DPRINTK("Counter not initialised\n");     \r
              i_ReturnValue = -3;\r
              }\r
           }\r
@@ -4396,7 +4510,8 @@ INT   i_APCI1710_Read16BitCounterValue        (comedi_device *dev,
           /*************************************************/\r
           /* The selected module number parameter is wrong */\r
           /*************************************************/\r
-\r         DPRINTK("The selected module number parameter is wrong\n");
+\r
+          DPRINTK("The selected module number parameter is wrong\n");\r
           i_ReturnValue = -2;\r
           }\r
 \r
@@ -4471,7 +4586,8 @@ INT   i_APCI1710_Read32BitCounterValue        (comedi_device *dev,
              /* Counter not initialised see function */\r
              /* "i_APCI1710_InitCounter"             */\r
              /****************************************/\r
-\r            DPRINTK("Counter not initialised\n");
+\r
+             DPRINTK("Counter not initialised\n");\r
              i_ReturnValue = -3;\r
              }\r
           }\r
@@ -4480,7 +4596,8 @@ INT   i_APCI1710_Read32BitCounterValue        (comedi_device *dev,
           /*************************************************/\r
           /* The selected module number parameter is wrong */\r
           /*************************************************/\r
-\r         DPRINTK("The selected module number parameter is wrong\n");  
+\r
+          DPRINTK("The selected module number parameter is wrong\n");  \r
           i_ReturnValue = -2;\r
           }\r
 \r
@@ -4556,7 +4673,8 @@ INT   i_APCI1710_GetIndexStatus      (comedi_device *dev,
                 /*************************************************************/\r
                 /* Index not initialised see function "i_APCI1710_InitIndex" */\r
                 /*************************************************************/\r
-\r               DPRINTK("Index not initialised\n");
+\r
+                DPRINTK("Index not initialised\n");\r
                 i_ReturnValue = -4;\r
                 }\r
              }\r
@@ -4566,7 +4684,8 @@ INT   i_APCI1710_GetIndexStatus      (comedi_device *dev,
              /* Counter not initialised see function */\r
              /* "i_APCI1710_InitCounter"             */\r
              /****************************************/\r
-\r            DPRINTK("Counter not initialised\n");     
+\r
+             DPRINTK("Counter not initialised\n");     \r
              i_ReturnValue = -3;\r
              }\r
           }\r
@@ -4575,7 +4694,8 @@ INT   i_APCI1710_GetIndexStatus      (comedi_device *dev,
           /*************************************************/\r
           /* The selected module number parameter is wrong */\r
           /*************************************************/\r
-\r         DPRINTK("The selected module number parameter is wrong\n");  
+\r
+          DPRINTK("The selected module number parameter is wrong\n");  \r
           i_ReturnValue = -2;\r
           }\r
 \r
@@ -4651,7 +4771,8 @@ INT   i_APCI1710_GetReferenceStatus      (comedi_device *dev,
                 /*********************************************************************/\r
                 /* Reference not initialised see function "i_APCI1710_InitReference" */\r
                 /*********************************************************************/\r
-\r               DPRINTK("Reference not initialised\n");
+\r
+                DPRINTK("Reference not initialised\n");\r
                 i_ReturnValue = -4;\r
                 }\r
              }\r
@@ -4661,7 +4782,8 @@ INT   i_APCI1710_GetReferenceStatus      (comedi_device *dev,
              /* Counter not initialised see function */\r
              /* "i_APCI1710_InitCounter"             */\r
              /****************************************/\r
-\r            DPRINTK("Counter not initialised\n");     
+\r
+             DPRINTK("Counter not initialised\n");     \r
              i_ReturnValue = -3;\r
              }\r
           }\r
@@ -4670,7 +4792,8 @@ INT   i_APCI1710_GetReferenceStatus      (comedi_device *dev,
           /*************************************************/\r
           /* The selected module number parameter is wrong */\r
           /*************************************************/\r
-\r         DPRINTK("The selected module number parameter is wrong\n");
+\r
+          DPRINTK("The selected module number parameter is wrong\n");\r
           i_ReturnValue = -2;\r
           }\r
 \r
@@ -4738,7 +4861,8 @@ INT   i_APCI1710_GetUASStatus (comedi_device *dev,
              /* Counter not initialised see function */\r
              /* "i_APCI1710_InitCounter"             */\r
              /****************************************/\r
-\r            DPRINTK("Counter not initialised\n");     
+\r
+             DPRINTK("Counter not initialised\n");     \r
              i_ReturnValue = -3;\r
              }\r
           }\r
@@ -4747,8 +4871,10 @@ INT   i_APCI1710_GetUASStatus (comedi_device *dev,
           /*************************************************/\r
           /* The selected module number parameter is wrong */\r
           /*************************************************/\r
-\r         DPRINTK("The selected module number parameter is wrong\n");  
-          i_ReturnValue = -2;\r 
+\r
+          DPRINTK("The selected module number parameter is wrong\n");  \r
+          i_ReturnValue = -2;\r
+       \r
           }\r
 \r
        return (i_ReturnValue);\r
@@ -4806,7 +4932,8 @@ INT   i_APCI1710_GetCBStatus  (comedi_device *dev,
                        dw_StatusReg=inl(devpriv->s_BoardInfos.\r
                      ui_Address + 16 + (64 * b_ModulNbr));\r
 \r
-             *pb_CBStatus = (BYTE) (dw_StatusReg & 1);\r                              
+             *pb_CBStatus = (BYTE) (dw_StatusReg & 1);\r
+                             \r
              }\r
           else\r
              {\r
@@ -4814,7 +4941,8 @@ INT   i_APCI1710_GetCBStatus  (comedi_device *dev,
              /* Counter not initialised see function */\r
              /* "i_APCI1710_InitCounter"             */\r
              /****************************************/\r
-\r            DPRINTK("Counter not initialised\n");     
+\r
+             DPRINTK("Counter not initialised\n");     \r
              i_ReturnValue = -3;\r
              }\r
           }\r
@@ -4823,7 +4951,8 @@ INT   i_APCI1710_GetCBStatus  (comedi_device *dev,
           /*************************************************/\r
           /* The selected module number parameter is wrong */\r
           /*************************************************/\r
-\r         DPRINTK("The selected module number parameter is wrong\n");  
+\r
+          DPRINTK("The selected module number parameter is wrong\n");  \r
           i_ReturnValue = -2;\r
           }\r
 \r
@@ -4877,7 +5006,8 @@ INT       i_APCI1710_Get16BitCBStatus     (comedi_device *dev,
        INT    i_ReturnValue = 0;\r
        DWORD dw_StatusReg   = 0;\r
        \r
-\r       
+\r
+       \r
        /**************************/\r
        /* Test the module number */\r
        /**************************/\r
@@ -4934,7 +5064,8 @@ INT       i_APCI1710_Get16BitCBStatus     (comedi_device *dev,
                 /* Counter not initialised to 2*16-bit mode */\r
                 /* "i_APCI1710_InitCounter"                 */\r
                 /********************************************/\r
-\r               DPRINTK("Counter not initialised\n");
+\r
+                DPRINTK("Counter not initialised\n");\r
                 i_ReturnValue = -4;\r
                 } // if ((ps_APCI1710Variable->s_Board [b_BoardHandle].s_ModuleInfo [b_ModulNbr].s_SiemensCounterInfo.s_ModeRegister.s_ByteModeRegister.b_ModeRegister1 & 0x10) == 0x10)\r
              } // if (ps_APCI1710Variable->s_Board [b_BoardHandle].s_ModuleInfo [b_ModulNbr].s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1)\r
@@ -4944,7 +5075,8 @@ INT       i_APCI1710_Get16BitCBStatus     (comedi_device *dev,
              /* Counter not initialised see function */\r
              /* "i_APCI1710_InitCounter"             */\r
              /****************************************/\r
-\r            DPRINTK("Counter not initialised\n");             
+\r
+             DPRINTK("Counter not initialised\n");             \r
              i_ReturnValue = -3;\r
              } // if (ps_APCI1710Variable->s_Board [b_BoardHandle].s_ModuleInfo [b_ModulNbr].s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1)\r
           } // if (b_ModulNbr < 4)\r
@@ -4953,7 +5085,8 @@ INT       i_APCI1710_Get16BitCBStatus     (comedi_device *dev,
           /*************************************************/\r
           /* The selected module number parameter is wrong */\r
           /*************************************************/\r
-\r         DPRINTK("The selected module number parameter is wrong\n");
+\r
+          DPRINTK("The selected module number parameter is wrong\n");\r
           i_ReturnValue = -2;\r
           } // if (b_ModulNbr < 4)\r
 \r
@@ -5016,7 +5149,7 @@ INT   i_APCI1710_GetUDStatus  (comedi_device *dev,
                      ui_Address + 24 + (64 * b_ModulNbr));\r
 \r
              *pb_UDStatus = (BYTE) ((dw_StatusReg >> 2) & 1);\r
-               
+               \r
              }\r
           else\r
              {\r
@@ -5024,7 +5157,8 @@ INT   i_APCI1710_GetUDStatus  (comedi_device *dev,
              /* Counter not initialised see function */\r
              /* "i_APCI1710_InitCounter"             */\r
              /****************************************/\r
-\r            DPRINTK("Counter not initialised\n");     
+\r
+             DPRINTK("Counter not initialised\n");     \r
              i_ReturnValue = -3;\r
              }\r
           }\r
@@ -5033,7 +5167,8 @@ INT   i_APCI1710_GetUDStatus  (comedi_device *dev,
           /*************************************************/\r
           /* The selected module number parameter is wrong */\r
           /*************************************************/\r
-\r         DPRINTK("The selected module number parameter is wrong\n");  
+\r
+          DPRINTK("The selected module number parameter is wrong\n");  \r
           i_ReturnValue = -2;\r
           }\r
 \r
@@ -5130,7 +5265,8 @@ INT   i_APCI1710_GetInterruptUDLatchedStatus  (comedi_device *dev,
              /* Counter not initialised see function */\r
              /* "i_APCI1710_InitCounter"             */\r
              /****************************************/\r
-\r            DPRINTK("Counter not initialised\n");     
+\r
+             DPRINTK("Counter not initialised\n");     \r
              i_ReturnValue = -3;\r
              }\r
           }\r
@@ -5139,7 +5275,8 @@ INT   i_APCI1710_GetInterruptUDLatchedStatus  (comedi_device *dev,
           /*************************************************/\r
           /* The selected module number parameter is wrong */\r
           /*************************************************/\r
-\r         DPRINTK("The selected module number parameter is wrong\n");  
+\r
+          DPRINTK("The selected module number parameter is wrong\n");  \r
           i_ReturnValue = -2;\r
           }\r
 \r
@@ -5258,7 +5395,8 @@ INT       i_APCI1710_ReadFrequencyMeasurement (comedi_device *dev,
                       /******************/\r
 \r
                           *pul_ReadValue=inl(devpriv->s_BoardInfos.\r
-                             ui_Address + 28 + (64 * b_ModulNbr));\r                                                 
+                             ui_Address + 28 + (64 * b_ModulNbr));\r
+                                                    \r
 \r
                       if (*pb_UDStatus == 0)\r
                          {\r
@@ -5349,7 +5487,8 @@ INT       i_APCI1710_ReadFrequencyMeasurement (comedi_device *dev,
                 /***********************************************/\r
                 /* Frequency measurement logic not initialised */\r
                 /***********************************************/\r
-\r               DPRINTK("Frequency measurement logic not initialised\n");
+\r
+                DPRINTK("Frequency measurement logic not initialised\n");\r
                 i_ReturnValue = -4;\r
                 }\r
              }\r
@@ -5359,7 +5498,8 @@ INT       i_APCI1710_ReadFrequencyMeasurement (comedi_device *dev,
              /* Counter not initialised see function */\r
              /* "i_APCI1710_InitCounter"             */\r
              /****************************************/\r
-\r            DPRINTK("Counter not initialised\n");     
+\r
+             DPRINTK("Counter not initialised\n");     \r
              i_ReturnValue = -3;\r
              }\r
           }\r
@@ -5368,7 +5508,8 @@ INT       i_APCI1710_ReadFrequencyMeasurement (comedi_device *dev,
           /*************************************************/\r
           /* The selected module number parameter is wrong */\r
           /*************************************************/\r
-\r         DPRINTK("The selected module number parameter is wrong\n");
+\r
+          DPRINTK("The selected module number parameter is wrong\n");\r
           i_ReturnValue = -2;\r
           }\r
 \r
index 5f3bb095dd2153bffcced3a1e0aa08e96a171b7b..9824970dac0beb2790d1bd03a2fbde0fe4062461 100644 (file)
@@ -1,6 +1,28 @@
+/**\r
+@verbatim\r
+\r
+Copyright (C) 2004,2005  ADDI-DATA GmbH for the source code of this module. \r
+        \r
+        ADDI-DATA GmbH \r
+        Dieselstrasse 3 \r
+        D-77833 Ottersweier \r
+        Tel: +19(0)7223/9493-0 \r
+        Fax: +49(0)7223/9493-92 \r
+        http://www.addi-data-com \r
+        info@addi-data.com \r
+\r
+This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.\r
+\r
+This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.\r
+\r
+You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+\r
+You shoud also find the complete GPL in the COPYING file accompanying this source code.\r
+\r
+@endverbatim\r
+*/\r
 \r
 \r
-
 #define APCI1710_16BIT_COUNTER                         0x10\r
 #define APCI1710_32BIT_COUNTER                         0x0\r
 #define APCI1710_QUADRUPLE_MODE                        0x0\r
 #define APCI1710_REFERENCE_HIGH                0x40\r
 #define APCI1710_REFERENCE_LOW                 (~APCI1710_REFERENCE_HIGH)\r
 \r
-
+\r
    #define APCI1710_TOR_GATE_LOW               0x40\r
    #define APCI1710_TOR_GATE_HIGH              (~APCI1710_TOR_GATE_LOW)\r
-
+\r
 \r
 //     INSN CONFIG \r
 #define        APCI1710_INCCPT_INITCOUNTER                                                     100\r
 #define APCI1710_INCCPT_GETUDSTATUS                                                    209\r
 #define APCI1710_INCCPT_GETINTERRUPTUDLATCHEDSTATUS                    210\r
 #define APCI1710_INCCPT_READFREQUENCYMEASUREMENT                       211\r
-#define APCI1710_INCCPT_READINTERRUPT                       212
+#define APCI1710_INCCPT_READINTERRUPT                       212\r
 \r
 //INSN BITS\r
 #define APCI1710_INCCPT_CLEARCOUNTERVALUE                                      300\r
index bd27ada5415cfb22eea09445e852bd865fe330b2..77733e83aefd03dfff91bea36657e056da598ce4 100644 (file)
@@ -1,14 +1,38 @@
+/**\r
+@verbatim\r
+\r
+Copyright (C) 2004,2005  ADDI-DATA GmbH for the source code of this module. \r
+        \r
+        ADDI-DATA GmbH \r
+        Dieselstrasse 3 \r
+        D-77833 Ottersweier \r
+        Tel: +19(0)7223/9493-0 \r
+        Fax: +49(0)7223/9493-92 \r
+        http://www.addi-data-com \r
+        info@addi-data.com \r
+\r
+This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.\r
+\r
+This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.\r
+\r
+You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+\r
+You shoud also find the complete GPL in the COPYING file accompanying this source code.\r
+\r
+@endverbatim\r
+*/\r
 /*\r
+    \r
   +-----------------------------------------------------------------------+\r
   | (C) ADDI-DATA GmbH          Dieselstraße 3       D-77833 Ottersweier  |\r
   +-----------------------------------------------------------------------+\r
   | Tel : +49 (0) 7223/9493-0     | email    : info@addi-data.com         |\r
   | Fax : +49 (0) 7223/9493-92    | Internet : http://www.addi-data.com   |\r
   +-----------------------------------------------------------------------+\r
-  | Project   : API APCI1710      |     Compiler   : BORLANDC/MICROSOFT C |\r
-  | Module name : INP_CPT.C       |     Version    : 3.1     / 6.0        |\r
+  | Project     : API APCI1710    | Compiler : gcc                        |\r
+  | Module name : Inp_CPT.C       | Version  : 2.96                       |\r
   +-------------------------------+---------------------------------------+\r
-  | Author    : S.WEBER           |     Date       : 27.08.98             |\r
+  | Project manager: Eric Stolz   | Date     :  02/12/2002                |\r
   +-----------------------------------------------------------------------+\r
   | Description :   APCI-1710 pulse encoder module                        |\r
   |                                                                       |\r
@@ -116,14 +140,15 @@ INT  i_APCI1710_InsnConfigInitPulseEncoder(comedi_device *dev,comedi_subdevice *
        b_InputLevelSelection   =(BYTE)  data[1];\r
        b_TriggerOutputAction   =(BYTE)  data[2];\r
        ul_StartValue                   =(ULONG) data[3];\r
-\r       i_ReturnValue           =insn->n;
+\r
+       i_ReturnValue           =insn->n;\r
        \r
 \r
        /***********************************/\r
        /* Test the selected module number */\r
        /***********************************/\r
 \r
-       if (b_ModulNbr >= 0 && b_ModulNbr <= 3)\r
+       if (b_ModulNbr <= 3)\r
           {\r
           /*************************/\r
           /* Test if pulse encoder */\r
@@ -136,7 +161,7 @@ INT  i_APCI1710_InsnConfigInitPulseEncoder(comedi_device *dev,comedi_subdevice *
              /* Test the selected pulse encoder number */\r
              /******************************************/\r
 \r
-             if (b_PulseEncoderNbr >= 0 && b_PulseEncoderNbr <= 3)\r
+             if (b_PulseEncoderNbr <= 3)\r
                 {\r
                 /************************/\r
                 /* Test the input level */\r
@@ -148,7 +173,7 @@ INT  i_APCI1710_InsnConfigInitPulseEncoder(comedi_device *dev,comedi_subdevice *
                    /* Test the ouput TRIGGER action selection */\r
                    /*******************************************/\r
 \r
-                   if ((b_TriggerOutputAction >= 0 && b_TriggerOutputAction <= 2) || (b_PulseEncoderNbr > 0))\r
+                   if ((b_TriggerOutputAction <= 2) || (b_PulseEncoderNbr > 0))\r
                       {\r
                       if (ul_StartValue > 1)\r
                          {\r
@@ -232,7 +257,8 @@ INT  i_APCI1710_InsnConfigInitPulseEncoder(comedi_device *dev,comedi_subdevice *
                          /**************************************/\r
                          /* Pulse encoder start value is wrong */\r
                          /**************************************/\r
-\r                        DPRINTK("Pulse encoder start value is wrong\n");
+\r
+                         DPRINTK("Pulse encoder start value is wrong\n");\r
                          i_ReturnValue = -6;\r
                          }\r
                       }\r
@@ -241,7 +267,8 @@ INT  i_APCI1710_InsnConfigInitPulseEncoder(comedi_device *dev,comedi_subdevice *
                       /****************************************************/\r
                       /* Digital TRIGGER output action selection is wrong */\r
                       /****************************************************/\r
-\r                         DPRINTK("Digital TRIGGER output action selection is wrong\n");       
+\r
+                          DPRINTK("Digital TRIGGER output action selection is wrong\n");       \r
                       i_ReturnValue = -5;\r
                       }\r
                    }\r
@@ -250,7 +277,8 @@ INT  i_APCI1710_InsnConfigInitPulseEncoder(comedi_device *dev,comedi_subdevice *
                    /**********************************/\r
                    /* Input level selection is wrong */\r
                    /**********************************/\r
-\r                  DPRINTK("Input level selection is wrong\n");
+\r
+                   DPRINTK("Input level selection is wrong\n");\r
                    i_ReturnValue = -4;\r
                    }\r
                 }\r
@@ -259,7 +287,8 @@ INT  i_APCI1710_InsnConfigInitPulseEncoder(comedi_device *dev,comedi_subdevice *
                 /************************************/\r
                 /* Pulse encoder selection is wrong */\r
                 /************************************/\r
-\r               DPRINTK("Pulse encoder selection is wrong\n");
+\r
+                DPRINTK("Pulse encoder selection is wrong\n");\r
                 i_ReturnValue = -3;\r
                 }\r
              }\r
@@ -268,7 +297,8 @@ INT  i_APCI1710_InsnConfigInitPulseEncoder(comedi_device *dev,comedi_subdevice *
              /********************************************/\r
              /* The module is not a pulse encoder module */\r
              /********************************************/\r
-\r            DPRINTK("The module is not a pulse encoder module\n");    
+\r
+             DPRINTK("The module is not a pulse encoder module\n");    \r
              i_ReturnValue = -2;\r
              }\r
           }\r
@@ -277,7 +307,8 @@ INT  i_APCI1710_InsnConfigInitPulseEncoder(comedi_device *dev,comedi_subdevice *
           /********************************************/\r
           /* The module is not a pulse encoder module */\r
           /********************************************/\r
-\r         DPRINTK("The module is not a pulse encoder module\n");       
+\r
+          DPRINTK("The module is not a pulse encoder module\n");       \r
           i_ReturnValue = -2;\r
           }\r
 \r
@@ -350,7 +381,7 @@ INT  i_APCI1710_InsnConfigInitPulseEncoder(comedi_device *dev,comedi_subdevice *
 +----------------------------------------------------------------------------+\r
 */\r
 \r
-
+\r
  INT i_APCI1710_InsnWriteEnableDisablePulseEncoder(comedi_device *dev,comedi_subdevice *s,\r
        comedi_insn *insn,lsampl_t *data)\r
        {\r
@@ -368,18 +399,19 @@ INT  i_APCI1710_InsnConfigInitPulseEncoder(comedi_device *dev,comedi_subdevice *
        b_CycleSelection        =(BYTE) data[2];\r
        b_InterruptHandling     =(BYTE) data[3];\r
 \r
-\r       
+\r
+       \r
        /***********************************/\r
        /* Test the selected module number */\r
        /***********************************/\r
 \r
-       if (b_ModulNbr >= 0 && b_ModulNbr <= 3)\r
+       if (b_ModulNbr <= 3)\r
           {\r
           /******************************************/\r
           /* Test the selected pulse encoder number */\r
           /******************************************/\r
 \r
-          if (b_PulseEncoderNbr >= 0 && b_PulseEncoderNbr <= 3)\r
+          if (b_PulseEncoderNbr <= 3)\r
              {\r
              /*************************************/\r
              /* Test if pulse encoder initialised */\r
@@ -434,9 +466,9 @@ INT  i_APCI1710_InsnConfigInitPulseEncoder(comedi_device *dev,comedi_subdevice *
                             dw_SetRegister = devpriv->s_ModuleInfo [b_ModulNbr].\r
                                              s_PulseEncoderModuleInfo.\r
                                              dw_SetRegister | (1UL << b_PulseEncoderNbr);\r
-                               devpriv->tsk_Current=current; // Save the current process task structure
+                               devpriv->tsk_Current=current; // Save the current process task structure\r
 \r
-                          
+                          \r
                          }\r
 \r
                       if (i_ReturnValue>=0)\r
@@ -445,7 +477,7 @@ INT  i_APCI1710_InsnConfigInitPulseEncoder(comedi_device *dev,comedi_subdevice *
                          /* Enable or disable the interrupt */\r
                          /***********************************/\r
 \r
-                         
+                         \r
                                outl(devpriv->s_ModuleInfo [b_ModulNbr].\r
                                  s_PulseEncoderModuleInfo.\r
                                  dw_SetRegister,devpriv->s_BoardInfos.\r
@@ -475,7 +507,7 @@ INT  i_APCI1710_InsnConfigInitPulseEncoder(comedi_device *dev,comedi_subdevice *
                          /* Enable the pulse encoder */\r
                          /****************************/\r
 \r
-                         
+                         \r
                          outl(devpriv->s_ModuleInfo [b_ModulNbr].\r
                                  s_PulseEncoderModuleInfo.\r
                                  dw_ControlRegister,devpriv->s_BoardInfos.\r
@@ -487,7 +519,8 @@ INT  i_APCI1710_InsnConfigInitPulseEncoder(comedi_device *dev,comedi_subdevice *
                       /************************************/\r
                       /* Interrupt handling mode is wrong */\r
                       /************************************/\r
-\r                         DPRINTK("Interrupt handling mode is wrong\n");
+\r
+                          DPRINTK("Interrupt handling mode is wrong\n");\r
                       i_ReturnValue = -6;\r
                       }\r
                    }\r
@@ -496,7 +529,8 @@ INT  i_APCI1710_InsnConfigInitPulseEncoder(comedi_device *dev,comedi_subdevice *
                    /*********************************/\r
                    /* Cycle selection mode is wrong */\r
                    /*********************************/\r
-\r                      DPRINTK("Cycle selection mode is wrong\n");
+\r
+                       DPRINTK("Cycle selection mode is wrong\n");\r
                    i_ReturnValue = -5;\r
                    }\r
                 break;\r
@@ -527,7 +561,8 @@ INT  i_APCI1710_InsnConfigInitPulseEncoder(comedi_device *dev,comedi_subdevice *
                 /*********************************/\r
                 /* Pulse encoder not initialised */\r
                 /*********************************/\r
-\r               DPRINTK("Pulse encoder not initialised\n");
+\r
+                DPRINTK("Pulse encoder not initialised\n");\r
                 i_ReturnValue = -4;\r
                 }\r
              }\r
@@ -536,7 +571,8 @@ INT  i_APCI1710_InsnConfigInitPulseEncoder(comedi_device *dev,comedi_subdevice *
              /************************************/\r
              /* Pulse encoder selection is wrong */\r
              /************************************/\r
-\r            DPRINTK("Pulse encoder selection is wrong\n");    
+\r
+             DPRINTK("Pulse encoder selection is wrong\n");    \r
              i_ReturnValue = -3;\r
              }\r
           }\r
@@ -545,7 +581,8 @@ INT  i_APCI1710_InsnConfigInitPulseEncoder(comedi_device *dev,comedi_subdevice *
           /*****************************/\r
           /* Module selection is wrong */\r
           /*****************************/\r
-\r         DPRINTK("Module selection is wrong\n");      
+\r
+          DPRINTK("Module selection is wrong\n");      \r
           i_ReturnValue = -2;\r
           }\r
 \r
@@ -617,10 +654,10 @@ INT   i_APCI1710_InsnBitsReadWritePulseEncoder(comedi_device *dev,comedi_subdevi
        PULONG pul_ReadValue;\r
        ULONG ul_WriteValue ; \r
                              \r
-       i_ReturnValue=insn->n;
-       b_ModulNbr              =(BYTE) CR_AREF(insn->chanspec);
+       i_ReturnValue=insn->n;\r
+       b_ModulNbr              =(BYTE) CR_AREF(insn->chanspec);\r
        b_Type                  =(BYTE)   data[0] ;\r
-       b_PulseEncoderNbr=(BYTE) data[1];
+       b_PulseEncoderNbr=(BYTE) data[1];\r
        pb_Status               =(PBYTE) &data[0];\r
        pul_ReadValue   =(PULONG) &data[1];\r
     \r
@@ -628,13 +665,13 @@ INT   i_APCI1710_InsnBitsReadWritePulseEncoder(comedi_device *dev,comedi_subdevi
        /* Test the selected module number */\r
        /***********************************/\r
 \r
-       if (b_ModulNbr >= 0 && b_ModulNbr <= 3)\r
+       if (b_ModulNbr <= 3)\r
           {\r
           /******************************************/\r
           /* Test the selected pulse encoder number */\r
           /******************************************/\r
 \r
-          if (b_PulseEncoderNbr >= 0 && b_PulseEncoderNbr <= 3)\r
+          if (b_PulseEncoderNbr <= 3)\r
              {\r
              /*************************************/\r
              /* Test if pulse encoder initialised */\r
@@ -653,7 +690,7 @@ INT   i_APCI1710_InsnBitsReadWritePulseEncoder(comedi_device *dev,comedi_subdevi
                 /* Read the status register */\r
                 /****************************/\r
 \r
-               
+               \r
                        dw_StatusRegister=inl(devpriv->s_BoardInfos.\r
                        ui_Address + 16 + (64 * b_ModulNbr));\r
 \r
@@ -677,7 +714,7 @@ INT   i_APCI1710_InsnBitsReadWritePulseEncoder(comedi_device *dev,comedi_subdevi
                 /******************/\r
                 /* Read the value */\r
                 /******************/\r
-                
+                \r
 \r
                *pul_ReadValue=inl(devpriv->s_BoardInfos.\r
                        ui_Address + (4 * b_PulseEncoderNbr) + (64 * b_ModulNbr));\r
@@ -689,7 +726,7 @@ INT   i_APCI1710_InsnBitsReadWritePulseEncoder(comedi_device *dev,comedi_subdevi
                        /* Write the value */\r
                        /*******************/\r
 \r
-                       
+                       \r
                        outl(ul_WriteValue,devpriv->s_BoardInfos.\r
                         ui_Address + (4 * b_PulseEncoderNbr) + (64 * b_ModulNbr));\r
 \r
@@ -700,7 +737,8 @@ INT   i_APCI1710_InsnBitsReadWritePulseEncoder(comedi_device *dev,comedi_subdevi
                 /*********************************/\r
                 /* Pulse encoder not initialised */\r
                 /*********************************/\r
-\r               DPRINTK("Pulse encoder not initialised\n");
+\r
+                DPRINTK("Pulse encoder not initialised\n");\r
                 i_ReturnValue = -4;\r
                 }\r
              }\r
@@ -709,7 +747,8 @@ INT   i_APCI1710_InsnBitsReadWritePulseEncoder(comedi_device *dev,comedi_subdevi
              /************************************/\r
              /* Pulse encoder selection is wrong */\r
              /************************************/\r
-\r            DPRINTK("Pulse encoder selection is wrong\n");            
+\r
+             DPRINTK("Pulse encoder selection is wrong\n");            \r
              i_ReturnValue = -3;\r
              }\r
           }\r
@@ -718,43 +757,44 @@ INT   i_APCI1710_InsnBitsReadWritePulseEncoder(comedi_device *dev,comedi_subdevi
           /*****************************/\r
           /* Module selection is wrong */\r
           /*****************************/\r
-\r         DPRINTK("Module selection is wrong\n");
+\r
+          DPRINTK("Module selection is wrong\n");\r
           i_ReturnValue = -2;\r
           }\r
 \r
        return (i_ReturnValue);\r
        }\r
 \r
-
-INT   i_APCI1710_InsnReadInterruptPulseEncoder(comedi_device *dev,comedi_subdevice *s,
-       comedi_insn *insn,lsampl_t *data)
-{
-
-       data[0] = devpriv->s_InterruptParameters.
-                                                     s_FIFOInterruptParameters [devpriv->
-                                                                                s_InterruptParameters.
-                                                                                ui_Read].b_OldModuleMask;
-        data[1] = devpriv->s_InterruptParameters.
-                                                     s_FIFOInterruptParameters [devpriv->
-                                                                                s_InterruptParameters.
-                                                                                ui_Read].ul_OldInterruptMask;
-        data[2] = devpriv->s_InterruptParameters.
-                                                     s_FIFOInterruptParameters [devpriv->
-                                                                                s_InterruptParameters.
-                                                                                ui_Read].ul_OldCounterLatchValue;
-
-                            
-       /***************************/
-       /* Increment the read FIFO */
-       /***************************/
-
-       devpriv->s_InterruptParameters.
-       ui_Read = (devpriv->
-       s_InterruptParameters.ui_Read + 1) % APCI1710_SAVE_INTERRUPT;
-
-        return insn->n;
-
-
-}
-
+\r
+INT   i_APCI1710_InsnReadInterruptPulseEncoder(comedi_device *dev,comedi_subdevice *s,\r
+       comedi_insn *insn,lsampl_t *data)\r
+{\r
+\r
+       data[0] = devpriv->s_InterruptParameters.\r
+                                                     s_FIFOInterruptParameters [devpriv->\r
+                                                                                s_InterruptParameters.\r
+                                                                                ui_Read].b_OldModuleMask;\r
+        data[1] = devpriv->s_InterruptParameters.\r
+                                                     s_FIFOInterruptParameters [devpriv->\r
+                                                                                s_InterruptParameters.\r
+                                                                                ui_Read].ul_OldInterruptMask;\r
+        data[2] = devpriv->s_InterruptParameters.\r
+                                                     s_FIFOInterruptParameters [devpriv->\r
+                                                                                s_InterruptParameters.\r
+                                                                                ui_Read].ul_OldCounterLatchValue;\r
+\r
+                            \r
+       /***************************/\r
+       /* Increment the read FIFO */\r
+       /***************************/\r
+\r
+       devpriv->s_InterruptParameters.\r
+       ui_Read = (devpriv->\r
+       s_InterruptParameters.ui_Read + 1) % APCI1710_SAVE_INTERRUPT;\r
+\r
+        return insn->n;\r
+\r
+\r
+}\r
+\r
 \r
index 7265a7242e956ac980b8a206f76f4b57425a9064..aa95b7d35b2fa51b26366753d1590f02124b0263 100644 (file)
@@ -1,38 +1 @@
-\r\r
-\r
-\r
-   #define APCI1710_SINGLE     0\r
-   #define APCI1710_CONTINUOUS 1\r
-
-\r
-#define APCI1710_PULSEENCODER_READ             0   \r
-#define APCI1710_PULSEENCODER_WRITE            1\r
-\r
-\r
-INT  i_APCI1710_InsnConfigInitPulseEncoder(comedi_device *dev,comedi_subdevice *s,\r
-       comedi_insn *insn,lsampl_t *data);\r
-\r
-\r
-\r
-\r
-INT i_APCI1710_InsnWriteEnableDisablePulseEncoder(comedi_device *dev,comedi_subdevice *s,\r
-       comedi_insn *insn,lsampl_t *data);\r
-/*\r
-+----------------------------------------------------------------------------+\r
-|                       READ PULSE ENCODER FUNCTIONS                         |\r
-+----------------------------------------------------------------------------+\r
-*/\r
-\r
-INT   i_APCI1710_InsnReadInterruptPulseEncoder(comedi_device *dev,comedi_subdevice *s,
-       comedi_insn *insn,lsampl_t *data);
-
-/*\r
-+----------------------------------------------------------------------------+\r
-|                       WRITE PULSE ENCODER FUNCTIONS                        |\r
-+----------------------------------------------------------------------------+\r
-*/\r
-
- INT   i_APCI1710_InsnBitsReadWritePulseEncoder(comedi_device *dev,comedi_subdevice *s,\r
-       comedi_insn *insn,lsampl_t *data);
-
-
+/**\r@verbatim\r\rCopyright (C) 2004,2005  ADDI-DATA GmbH for the source code of this module. \r        \r        ADDI-DATA GmbH \r        Dieselstrasse 3 \r        D-77833 Ottersweier \r        Tel: +19(0)7223/9493-0 \r        Fax: +49(0)7223/9493-92 \r        http://www.addi-data-com \r        info@addi-data.com \r\rThis program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.\r\rThis program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.\r\rYou should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r\rYou shoud also find the complete GPL in the COPYING file accompanying this source code.\r\r@endverbatim\r*/\r\r\r\r   #define APCI1710_SINGLE     0\r   #define APCI1710_CONTINUOUS 1\r\r\r#define APCI1710_PULSEENCODER_READ                0   \r#define APCI1710_PULSEENCODER_WRITE                1\r\r\rINT  i_APCI1710_InsnConfigInitPulseEncoder(comedi_device *dev,comedi_subdevice *s,\r comedi_insn *insn,lsampl_t *data);\r\r\r\r\rINT i_APCI1710_InsnWriteEnableDisablePulseEncoder(comedi_device *dev,comedi_subdevice *s,\r       comedi_insn *insn,lsampl_t *data);\r/*\r+----------------------------------------------------------------------------+\r|                       READ PULSE ENCODER FUNCTIONS                         |\r+----------------------------------------------------------------------------+\r*/\r\rINT   i_APCI1710_InsnReadInterruptPulseEncoder(comedi_device *dev,comedi_subdevice *s,\r  comedi_insn *insn,lsampl_t *data);\r\r/*\r+----------------------------------------------------------------------------+\r|                       WRITE PULSE ENCODER FUNCTIONS                        |\r+----------------------------------------------------------------------------+\r*/\r\r INT   i_APCI1710_InsnBitsReadWritePulseEncoder(comedi_device *dev,comedi_subdevice *s,\r        comedi_insn *insn,lsampl_t *data);\r\r\r
\ No newline at end of file
index 588dc35f97732a5e2337eed83a8a1c825fcafe0b..2423717aaa4f85e93f3c79b9cfe628f10a0e986c 100644 (file)
@@ -1,18 +1,38 @@
-
-
-
-
+/**\r
+@verbatim\r
+\r
+Copyright (C) 2004,2005  ADDI-DATA GmbH for the source code of this module. \r
+        \r
+        ADDI-DATA GmbH \r
+        Dieselstrasse 3 \r
+        D-77833 Ottersweier \r
+        Tel: +19(0)7223/9493-0 \r
+        Fax: +49(0)7223/9493-92 \r
+        http://www.addi-data-com \r
+        info@addi-data.com \r
+\r
+This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.\r
+\r
+This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.\r
+\r
+You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+\r
+You shoud also find the complete GPL in the COPYING file accompanying this source code.\r
+\r
+@endverbatim\r
+*/\r
 /*\r
+    \r
   +-----------------------------------------------------------------------+\r
   | (C) ADDI-DATA GmbH          Dieselstraße 3       D-77833 Ottersweier  |\r
   +-----------------------------------------------------------------------+\r
   | Tel : +49 (0) 7223/9493-0     | email    : info@addi-data.com         |\r
   | Fax : +49 (0) 7223/9493-92    | Internet : http://www.addi-data.com   |\r
   +-----------------------------------------------------------------------+\r
-  | Project   : API APCI1710      |     Compiler   : BORLANDC/MICROSOFT C |\r
-  | Module name : PWM.C           |     Version    : 3.1     / 6.0        |\r
+  | Project     : API APCI1710    | Compiler : gcc                        |\r
+  | Module name : PWM.C           | Version  : 2.96                       |\r
   +-------------------------------+---------------------------------------+\r
-  | Author    : S.WEBER           |     Date       : 22.01.99             |\r
+  | Project manager: Eric Stolz   | Date     :  02/12/2002                |\r
   +-----------------------------------------------------------------------+\r
   | Description :   APCI-1710 Wulse wide modulation module                |\r
   |                                                                       |\r
 \r
 /*\r
 +----------------------------------------------------------------------------+\r
-|                               Included files                               |\r
+|                               Included files                               |\r
++----------------------------------------------------------------------------+\r
+*/\r
+\r
+\r
+#include "APCI1710_Pwm.h"\r
+\r
+\r
+\r
+/*\r
++----------------------------------------------------------------------------+\r
+| Function Name     :INT i_APCI1710_InsnConfigPWM(comedi_device *dev,\r
+comedi_subdevice *s,comedi_insn *insn,lsampl_t *data)                        |\r
++----------------------------------------------------------------------------+\r
+| Task              : Pwm Init and Get Pwm Initialisation                    |\r
++----------------------------------------------------------------------------+\r
+| Input Parameters  : \r
++----------------------------------------------------------------------------+\r
+| Output Parameters : -                                                      |\r
++----------------------------------------------------------------------------+\r
+| Return Value      : \r
++----------------------------------------------------------------------------+\r
+*/\r
+\r
+INT    i_APCI1710_InsnConfigPWM(comedi_device *dev,comedi_subdevice *s,\r
+comedi_insn *insn,lsampl_t *data)\r
+{\r
+       BYTE b_ConfigType;\r
+       INT i_ReturnValue=0;\r
+        b_ConfigType=CR_CHAN(insn->chanspec);\r
+       \r
+\r
+       switch(b_ConfigType)\r
+       {\r
+       case APCI1710_PWM_INIT :\r
+               i_ReturnValue=i_APCI1710_InitPWM      (dev,\r
+                                (BYTE)CR_AREF(insn->chanspec), //  b_ModulNbr\r
+                                (BYTE) data[0],   //b_PWM\r
+                                (BYTE) data[1],   // b_ClockSelection\r
+                                (BYTE) data[2],   // b_TimingUnit\r
+                                (ULONG)data[3],   //ul_LowTiming\r
+                                (ULONG)data[4],   //ul_HighTiming\r
+                                (PULONG)&data[0], //pul_RealLowTiming\r
+                                (PULONG)&data[1] //pul_RealHighTiming\r
+                          );\r
+               break;\r
+\r
+       case APCI1710_PWM_GETINITDATA :\r
+               i_ReturnValue=i_APCI1710_GetPWMInitialisation (dev,\r
+                                        (BYTE)CR_AREF(insn->chanspec), // b_ModulNbr\r
+                                        (BYTE) data[0],   //b_PWM\r
+                                        (PBYTE)&data[0],    //pb_TimingUnit\r
+                                        (PULONG)&data[1], //pul_LowTiming\r
+                                        (PULONG)&data[2], //pul_HighTiming\r
+                                        (PBYTE) &data[3],  // pb_StartLevel\r
+                                        (PBYTE) &data[4], // pb_StopMode\r
+                                        (PBYTE) &data[5], // pb_StopLevel\r
+                                        (PBYTE) &data[6], // pb_ExternGate\r
+                                        (PBYTE) &data[7], // pb_InterruptEnable\r
+                                        (PBYTE) &data[8]  // pb_Enable\r
+                              );\r
+               break;\r
+\r
+       default:\r
+               printk(" Config Parameter Wrong\n");\r
+       }\r
+\r
+       if(i_ReturnValue>=0) i_ReturnValue =insn->n;\r
+       return (i_ReturnValue);\r
+}\r
+\r
+\r
+\r
+/*\r
++----------------------------------------------------------------------------+\r
+| Function Name     : _INT_ i_APCI1710_InitPWM                               |\r
+|                                       (BYTE_     b_BoardHandle,            |\r
+|                                        BYTE_     b_ModulNbr,               |\r
+|                                        BYTE_     b_PWM,                    |\r
+|                                        BYTE_     b_ClockSelection,         |\r
+|                                        BYTE_     b_TimingUnit,             |\r
+|                                        ULONG_   ul_LowTiming,              |\r
+|                                        ULONG_   ul_HighTiming,             |\r
+|                                        PULONG_ pul_RealLowTiming,          |\r
+|                                        PULONG_ pul_RealHighTiming)         |\r
++----------------------------------------------------------------------------+\r
+| Task              : Configure the selected PWM (b_PWM) from selected module|\r
+|                     (b_ModulNbr). The ul_LowTiming, ul_HighTiming and      |\r
+|                     ul_TimingUnit determine the low/high timing base for   |\r
+|                     the period. pul_RealLowTiming, pul_RealHighTiming      |\r
+|                     return the real timing value.                          |\r
+|                     You must calling this function be for you call any     |\r
+|                     other function witch access of the PWM.                |\r
++----------------------------------------------------------------------------+\r
+| Input Parameters  : BYTE_     b_BoardHandle    : Handle of board APCI-1710 |\r
+|                     BYTE_     b_ModulNbr       : Module number to configure|\r
+|                                                  (0 to 3)                  |\r
+|                     BYTE_     b_PWM            : Selected PWM (0 or 1).    |\r
+|                     BYTE_     b_ClockSelection : Selection from PCI bus    |\r
+|                                                  clock                     |\r
+|                                                   - APCI1710_30MHZ :       |\r
+|                                                     The PC have a 30 MHz   |\r
+|                                                     PCI bus clock          |\r
+|                                                   - APCI1710_33MHZ :       |\r
+|                                                     The PC have a 33 MHz   |\r
+|                                                     PCI bus clock          |\r
+|                                                   - APCI1710_40MHZ         |\r
+|                                                     The APCI-1710 have a   |\r
+|                                                     integrated 40Mhz       |\r
+|                                                     quartz.                |\r
+|                     BYTE_     b_TimingUnit     : Base timing Unit (0 to 4) |\r
+|                                                       0 : ns               |\r
+|                                                       1 : æs               |\r
+|                                                       2 : ms               |\r
+|                                                       3 : s                |\r
+|                                                       4 : mn               |\r
+|                     ULONG_    ul_LowTiming     : Low base timing value.    |\r
+|                     ULONG_    ul_HighTiming    : High base timing value.   |\r
++----------------------------------------------------------------------------+\r
+| Output Parameters : PULONG_  pul_RealLowTiming  : Real low base timing     |\r
+|                                                   value.                   |\r
+|                     PULONG_  pul_RealHighTiming : Real high base timing    |\r
+|                                                   value.                   |\r
++----------------------------------------------------------------------------+\r
+| Return Value      : 0: No error                                            |\r
+|                    -1: The handle parameter of the board is wrong          |\r
+|                    -2: Module selection wrong                              |\r
+|                    -3: The module is not a PWM module                      |\r
+|                    -4: PWM selection is wrong                              |\r
+|                    -5: The selected input clock is wrong                   |\r
+|                    -6: Timing Unit selection is wrong                      |\r
+|                    -7: Low base timing selection is wrong                  |\r
+|                    -8: High base timing selection is wrong                 |\r
+|                    -9: You can not used the 40MHz clock selection with     |\r
+|                        this board                                          |\r
++----------------------------------------------------------------------------+\r
+*/\r
+\r
+INT   i_APCI1710_InitPWM      (comedi_device *dev,\r
+                                BYTE     b_ModulNbr,\r
+                                BYTE    b_PWM,\r
+                                BYTE     b_ClockSelection,\r
+                                BYTE     b_TimingUnit,\r
+                                ULONG   ul_LowTiming,\r
+                                ULONG   ul_HighTiming,\r
+                                PULONG pul_RealLowTiming,\r
+                                PULONG pul_RealHighTiming)\r
+       {\r
+       INT    i_ReturnValue = 0;\r
+       ULONG ul_LowTimerValue = 0;\r
+       ULONG ul_HighTimerValue = 0;\r
+       DWORD dw_Command;\r
+       double d_RealLowTiming = 0;\r
+       double d_RealHighTiming = 0;\r
+       \r
+\r
+       /**************************/\r
+       /* Test the module number */\r
+       /**************************/\r
+\r
+       if (b_ModulNbr < 4)\r
+          {\r
+          /***************/\r
+          /* Test if PWM */\r
+          /***************/\r
+\r
+          if ((devpriv->\r
+               s_BoardInfos.\r
+               dw_MolduleConfiguration [b_ModulNbr] & 0xFFFF0000UL) == APCI1710_PWM)\r
+             {\r
+             /**************************/\r
+             /* Test the PWM selection */\r
+             /**************************/\r
+\r
+             if (b_PWM <= 1)\r
+                {\r
+                /******************/\r
+                /* Test the clock */\r
+                /******************/\r
+\r
+                if ((b_ClockSelection == APCI1710_30MHZ) ||\r
+                    (b_ClockSelection == APCI1710_33MHZ) ||\r
+                    (b_ClockSelection == APCI1710_40MHZ))\r
+                   {\r
+                   /************************/\r
+                   /* Test the timing unit */\r
+                   /************************/\r
+\r
+                   if (b_TimingUnit <= 4)\r
+                      {\r
+                      /*********************************/\r
+                      /* Test the low timing selection */\r
+                      /*********************************/\r
+\r
+                      if (((b_ClockSelection == APCI1710_30MHZ) && (b_TimingUnit == 0) && (ul_LowTiming >= 266) && (ul_LowTiming <= 0xFFFFFFFFUL)) ||\r
+                          ((b_ClockSelection == APCI1710_30MHZ) && (b_TimingUnit == 1) && (ul_LowTiming >= 1)   && (ul_LowTiming <= 571230650UL))  ||\r
+                          ((b_ClockSelection == APCI1710_30MHZ) && (b_TimingUnit == 2) && (ul_LowTiming >= 1)   && (ul_LowTiming <= 571230UL))     ||\r
+                          ((b_ClockSelection == APCI1710_30MHZ) && (b_TimingUnit == 3) && (ul_LowTiming >= 1)   && (ul_LowTiming <= 571UL))        ||\r
+                          ((b_ClockSelection == APCI1710_30MHZ) && (b_TimingUnit == 4) && (ul_LowTiming >= 1)   && (ul_LowTiming <= 9UL))          ||\r
+                          ((b_ClockSelection == APCI1710_33MHZ) && (b_TimingUnit == 0) && (ul_LowTiming >= 242) && (ul_LowTiming <= 0xFFFFFFFFUL)) ||\r
+                          ((b_ClockSelection == APCI1710_33MHZ) && (b_TimingUnit == 1) && (ul_LowTiming >= 1)   && (ul_LowTiming <= 519691043UL))  ||\r
+                          ((b_ClockSelection == APCI1710_33MHZ) && (b_TimingUnit == 2) && (ul_LowTiming >= 1)   && (ul_LowTiming <= 519691UL))     ||\r
+                          ((b_ClockSelection == APCI1710_33MHZ) && (b_TimingUnit == 3) && (ul_LowTiming >= 1)   && (ul_LowTiming <= 520UL))        ||\r
+                          ((b_ClockSelection == APCI1710_33MHZ) && (b_TimingUnit == 4) && (ul_LowTiming >= 1)   && (ul_LowTiming <= 8UL))          ||\r
+                          ((b_ClockSelection == APCI1710_40MHZ) && (b_TimingUnit == 0) && (ul_LowTiming >= 200) && (ul_LowTiming <= 0xFFFFFFFFUL)) ||\r
+                          ((b_ClockSelection == APCI1710_40MHZ) && (b_TimingUnit == 1) && (ul_LowTiming >= 1)   && (ul_LowTiming <= 429496729UL))  ||\r
+                          ((b_ClockSelection == APCI1710_40MHZ) && (b_TimingUnit == 2) && (ul_LowTiming >= 1)   && (ul_LowTiming <= 429496UL))     ||\r
+                          ((b_ClockSelection == APCI1710_40MHZ) && (b_TimingUnit == 3) && (ul_LowTiming >= 1)   && (ul_LowTiming <= 429UL))        ||\r
+                          ((b_ClockSelection == APCI1710_40MHZ) && (b_TimingUnit == 4) && (ul_LowTiming >= 1)   && (ul_LowTiming <= 7UL)))\r
+                         {\r
+                         /**********************************/\r
+                         /* Test the High timing selection */\r
+                         /**********************************/\r
+\r
+                         if (((b_ClockSelection == APCI1710_30MHZ) && (b_TimingUnit == 0) && (ul_HighTiming >= 266) && (ul_HighTiming <= 0xFFFFFFFFUL)) ||\r
+                             ((b_ClockSelection == APCI1710_30MHZ) && (b_TimingUnit == 1) && (ul_HighTiming >= 1)   && (ul_HighTiming <= 571230650UL))  ||\r
+                             ((b_ClockSelection == APCI1710_30MHZ) && (b_TimingUnit == 2) && (ul_HighTiming >= 1)   && (ul_HighTiming <= 571230UL))     ||\r
+                             ((b_ClockSelection == APCI1710_30MHZ) && (b_TimingUnit == 3) && (ul_HighTiming >= 1)   && (ul_HighTiming <= 571UL))        ||\r
+                             ((b_ClockSelection == APCI1710_30MHZ) && (b_TimingUnit == 4) && (ul_HighTiming >= 1)   && (ul_HighTiming <= 9UL))          ||\r
+                             ((b_ClockSelection == APCI1710_33MHZ) && (b_TimingUnit == 0) && (ul_HighTiming >= 242) && (ul_HighTiming <= 0xFFFFFFFFUL)) ||\r
+                             ((b_ClockSelection == APCI1710_33MHZ) && (b_TimingUnit == 1) && (ul_HighTiming >= 1)   && (ul_HighTiming <= 519691043UL))  ||\r
+                             ((b_ClockSelection == APCI1710_33MHZ) && (b_TimingUnit == 2) && (ul_HighTiming >= 1)   && (ul_HighTiming <= 519691UL))     ||\r
+                             ((b_ClockSelection == APCI1710_33MHZ) && (b_TimingUnit == 3) && (ul_HighTiming >= 1)   && (ul_HighTiming <= 520UL))        ||\r
+                             ((b_ClockSelection == APCI1710_33MHZ) && (b_TimingUnit == 4) && (ul_HighTiming >= 1)   && (ul_HighTiming <= 8UL))          ||\r
+                             ((b_ClockSelection == APCI1710_40MHZ) && (b_TimingUnit == 0) && (ul_HighTiming >= 200) && (ul_HighTiming <= 0xFFFFFFFFUL)) ||\r
+                             ((b_ClockSelection == APCI1710_40MHZ) && (b_TimingUnit == 1) && (ul_HighTiming >= 1)   && (ul_HighTiming <= 429496729UL))  ||\r
+                             ((b_ClockSelection == APCI1710_40MHZ) && (b_TimingUnit == 2) && (ul_HighTiming >= 1)   && (ul_HighTiming <= 429496UL))     ||\r
+                             ((b_ClockSelection == APCI1710_40MHZ) && (b_TimingUnit == 3) && (ul_HighTiming >= 1)   && (ul_HighTiming <= 429UL))        ||\r
+                             ((b_ClockSelection == APCI1710_40MHZ) && (b_TimingUnit == 4) && (ul_HighTiming >= 1)   && (ul_HighTiming <= 7UL)))\r
+                            {\r
+                            /**************************/\r
+                            /* Test the board version */\r
+                            /**************************/\r
+\r
+                            if (((b_ClockSelection == APCI1710_40MHZ) && (devpriv->\r
+                                                                          s_BoardInfos.\r
+                                                                          b_BoardVersion > 0)) ||\r
+                                (b_ClockSelection != APCI1710_40MHZ))\r
+                               {\r
+\r
+                               /************************************/\r
+                               /* Calculate the low division fator */\r
+                               /************************************/\r
+\r
+                               fpu_begin ();\r
+                               \r
+                               switch (b_TimingUnit)\r
+                                  {\r
+                                  /******/\r
+                                  /* ns */\r
+                                  /******/\r
+\r
+                                  case 0:\r
+                                       \r
+                                          /******************/\r
+                                          /* Timer 0 factor */\r
+                                          /******************/\r
+\r
+                                          ul_LowTimerValue = (ULONG) (ul_LowTiming * (0.00025 * b_ClockSelection));\r
+\r
+                                          /*******************/\r
+                                          /* Round the value */\r
+                                          /*******************/\r
+\r
+                                          if ((double) ((double) ul_LowTiming * (0.00025 * (double) b_ClockSelection)) >= ((double) ((double) ul_LowTimerValue + 0.5)))\r
+                                             {\r
+                                             ul_LowTimerValue = ul_LowTimerValue + 1;\r
+                                             }\r
+\r
+                                          /*****************************/\r
+                                          /* Calculate the real timing */\r
+                                          /*****************************/\r
+\r
+                                          *pul_RealLowTiming = (ULONG) (ul_LowTimerValue / (0.00025 * (double) b_ClockSelection));\r
+                                          d_RealLowTiming = (double) ul_LowTimerValue / (0.00025 * (double) b_ClockSelection);\r
+\r
+                                          if ((double) ((double) ul_LowTimerValue / (0.00025 * (double) b_ClockSelection)) >= (double) ((double) *pul_RealLowTiming + 0.5))\r
+                                             {\r
+                                             *pul_RealLowTiming = *pul_RealLowTiming + 1;\r
+                                             }\r
+\r
+                                          ul_LowTiming     = ul_LowTiming - 1;\r
+                                          ul_LowTimerValue = ul_LowTimerValue - 2;\r
+\r
+                                          if (b_ClockSelection != APCI1710_40MHZ)\r
+                                             {\r
+                                             ul_LowTimerValue = (ULONG) ((double) (ul_LowTimerValue) * 1.007752288);\r
+                                             }\r
+                                       \r
+\r
+                                       break;\r
+\r
+                                  /******/\r
+                                  /* æs */\r
+                                  /******/\r
+\r
+                                  case 1:\r
+                                       \r
+                                          /******************/\r
+                                          /* Timer 0 factor */\r
+                                          /******************/\r
+\r
+                                          ul_LowTimerValue = (ULONG) (ul_LowTiming * (0.25 * b_ClockSelection));\r
+\r
+                                          /*******************/\r
+                                          /* Round the value */\r
+                                          /*******************/\r
+\r
+                                          if ((double) ((double) ul_LowTiming * (0.25 * (double) b_ClockSelection)) >= ((double) ((double) ul_LowTimerValue + 0.5)))\r
+                                             {\r
+                                             ul_LowTimerValue = ul_LowTimerValue + 1;\r
+                                             }\r
+\r
+                                          /*****************************/\r
+                                          /* Calculate the real timing */\r
+                                          /*****************************/\r
+\r
+                                          *pul_RealLowTiming = (ULONG) (ul_LowTimerValue / (0.25 * (double) b_ClockSelection));\r
+                                          d_RealLowTiming    = (double) ul_LowTimerValue / ((double) 0.25 * (double) b_ClockSelection);\r
+\r
+                                          if ((double) ((double) ul_LowTimerValue / (0.25 * (double) b_ClockSelection)) >= (double) ((double) *pul_RealLowTiming + 0.5))\r
+                                             {\r
+                                             *pul_RealLowTiming = *pul_RealLowTiming + 1;\r
+                                             }\r
+\r
+                                          ul_LowTiming     = ul_LowTiming - 1;\r
+                                          ul_LowTimerValue = ul_LowTimerValue - 2;\r
+\r
+                                          if (b_ClockSelection != APCI1710_40MHZ)\r
+                                             {\r
+                                             ul_LowTimerValue = (ULONG) ((double) (ul_LowTimerValue) * 1.007752288);\r
+                                             }\r
+                                       \r
+\r
+                                       break;\r
+\r
+                                  /******/\r
+                                  /* ms */\r
+                                  /******/\r
+\r
+                                  case 2:\r
+                                       \r
+                                          /******************/\r
+                                          /* Timer 0 factor */\r
+                                          /******************/\r
+\r
+                                          ul_LowTimerValue = ul_LowTiming * (250.0 * b_ClockSelection);\r
+\r
+                                          /*******************/\r
+                                          /* Round the value */\r
+                                          /*******************/\r
+\r
+                                          if ((double) ((double) ul_LowTiming * (250.0 * (double) b_ClockSelection)) >= ((double) ((double) ul_LowTimerValue + 0.5)))\r
+                                             {\r
+                                             ul_LowTimerValue = ul_LowTimerValue + 1;\r
+                                             }\r
+\r
+                                          /*****************************/\r
+                                          /* Calculate the real timing */\r
+                                          /*****************************/\r
+\r
+                                          *pul_RealLowTiming = (ULONG) (ul_LowTimerValue / (250.0 * (double) b_ClockSelection));\r
+                                          d_RealLowTiming    = (double) ul_LowTimerValue / (250.0 * (double) b_ClockSelection);\r
+\r
+                                          if ((double) ((double) ul_LowTimerValue / (250.0 * (double) b_ClockSelection)) >= (double) ((double) *pul_RealLowTiming + 0.5))\r
+                                             {\r
+                                             *pul_RealLowTiming = *pul_RealLowTiming + 1;\r
+                                             }\r
+\r
+                                          ul_LowTiming     = ul_LowTiming - 1;\r
+                                          ul_LowTimerValue = ul_LowTimerValue - 2;\r
+\r
+                                          if (b_ClockSelection != APCI1710_40MHZ)\r
+                                             {\r
+                                             ul_LowTimerValue = (ULONG) ((double) (ul_LowTimerValue) * 1.007752288);\r
+                                             }\r
+                                       \r
+                                       break;\r
+\r
+                                  /*****/\r
+                                  /* s */\r
+                                  /*****/\r
+\r
+                                  case 3:\r
+                                          /******************/\r
+                                          /* Timer 0 factor */\r
+                                          /******************/\r
+\r
+                                          ul_LowTimerValue = (ULONG) (ul_LowTiming * (250000.0 * b_ClockSelection));\r
+\r
+                                          /*******************/\r
+                                          /* Round the value */\r
+                                          /*******************/\r
+\r
+                                          if ((double) ((double) ul_LowTiming * (250000.0 * (double) b_ClockSelection)) >= ((double) ((double) ul_LowTimerValue + 0.5)))\r
+                                             {\r
+                                             ul_LowTimerValue = ul_LowTimerValue + 1;\r
+                                             }\r
+\r
+                                          /*****************************/\r
+                                          /* Calculate the real timing */\r
+                                          /*****************************/\r
+\r
+                                          *pul_RealLowTiming = (ULONG) (ul_LowTimerValue / (250000.0 * (double) b_ClockSelection));\r
+                                          d_RealLowTiming    = (double) ul_LowTimerValue / (250000.0 * (double) b_ClockSelection);\r
+\r
+                                          if ((double) ((double) ul_LowTimerValue / (250000.0 * (double) b_ClockSelection)) >= (double) ((double) *pul_RealLowTiming + 0.5))\r
+                                             {\r
+                                             *pul_RealLowTiming = *pul_RealLowTiming + 1;\r
+                                             }\r
+\r
+                                          ul_LowTiming     = ul_LowTiming - 1;\r
+                                          ul_LowTimerValue = ul_LowTimerValue - 2;\r
+\r
+                                          if (b_ClockSelection != APCI1710_40MHZ)\r
+                                             {\r
+                                             ul_LowTimerValue = (ULONG) ((double) (ul_LowTimerValue) * 1.007752288);\r
+                                             }\r
+                                       \r
+\r
+                                       break;\r
+\r
+                                  /******/\r
+                                  /* mn */\r
+                                  /******/\r
+\r
+                                  case 4:\r
+                                       \r
+                                          /******************/\r
+                                          /* Timer 0 factor */\r
+                                          /******************/\r
+\r
+                                          ul_LowTimerValue = (ULONG) ((ul_LowTiming * 60) * (250000.0 * b_ClockSelection));\r
+\r
+                                          /*******************/\r
+                                          /* Round the value */\r
+                                          /*******************/\r
+\r
+                                          if ((double) ((double) (ul_LowTiming * 60.0) * (250000.0 * (double) b_ClockSelection)) >= ((double) ((double) ul_LowTimerValue + 0.5)))\r
+                                             {\r
+                                             ul_LowTimerValue = ul_LowTimerValue + 1;\r
+                                             }\r
+\r
+                                          /*****************************/\r
+                                          /* Calculate the real timing */\r
+                                          /*****************************/\r
+\r
+                                          *pul_RealLowTiming = (ULONG) (ul_LowTimerValue / (250000.0 * (double) b_ClockSelection)) / 60;\r
+                                          d_RealLowTiming    = ((double) ul_LowTimerValue / (250000.0 * (double) b_ClockSelection)) / 60.0;\r
+\r
+                                          if ((double) (((double) ul_LowTimerValue / (250000.0 * (double) b_ClockSelection)) / 60.0) >= (double) ((double) *pul_RealLowTiming + 0.5))\r
+                                             {\r
+                                             *pul_RealLowTiming = *pul_RealLowTiming + 1;\r
+                                             }\r
+\r
+                                          ul_LowTiming     = ul_LowTiming - 1;\r
+                                          ul_LowTimerValue = ul_LowTimerValue - 2;\r
+\r
+                                          if (b_ClockSelection != APCI1710_40MHZ)\r
+                                             {\r
+                                             ul_LowTimerValue = (ULONG) ((double) (ul_LowTimerValue) * 1.007752288);\r
+                                             }\r
+                                       \r
+                                       break;\r
+                                  }\r
+\r
+                               /*************************************/\r
+                               /* Calculate the high division fator */\r
+                               /*************************************/\r
+\r
+                               switch (b_TimingUnit)\r
+                                  {\r
+                                  /******/\r
+                                  /* ns */\r
+                                  /******/\r
+\r
+                                  case 0:\r
+                                       \r
+                                          /******************/\r
+                                          /* Timer 0 factor */\r
+                                          /******************/\r
+\r
+                                          ul_HighTimerValue = (ULONG) (ul_HighTiming * (0.00025 * b_ClockSelection));\r
+\r
+                                          /*******************/\r
+                                          /* Round the value */\r
+                                          /*******************/\r
+\r
+                                          if ((double) ((double) ul_HighTiming * (0.00025 * (double) b_ClockSelection)) >= ((double) ((double) ul_HighTimerValue + 0.5)))\r
+                                             {\r
+                                             ul_HighTimerValue = ul_HighTimerValue + 1;\r
+                                             }\r
+\r
+                                          /*****************************/\r
+                                          /* Calculate the real timing */\r
+                                          /*****************************/\r
+\r
+                                          *pul_RealHighTiming = (ULONG) (ul_HighTimerValue / (0.00025 * (double) b_ClockSelection));\r
+                                          d_RealHighTiming    = (double) ul_HighTimerValue / (0.00025 * (double) b_ClockSelection);\r
+\r
+                                          if ((double) ((double) ul_HighTimerValue / (0.00025 * (double) b_ClockSelection)) >= (double) ((double) *pul_RealHighTiming + 0.5))\r
+                                             {\r
+                                             *pul_RealHighTiming = *pul_RealHighTiming + 1;\r
+                                             }\r
+\r
+                                          ul_HighTiming     = ul_HighTiming - 1;\r
+                                          ul_HighTimerValue = ul_HighTimerValue - 2;\r
+\r
+                                          if (b_ClockSelection != APCI1710_40MHZ)\r
+                                             {\r
+                                             ul_HighTimerValue = (ULONG) ((double) (ul_HighTimerValue) * 1.007752288);\r
+                                             }\r
+                                       \r
+\r
+                                       break;\r
+\r
+                                  /******/\r
+                                  /* æs */\r
+                                  /******/\r
+\r
+                                  case 1:\r
+                                       \r
+                                          /******************/\r
+                                          /* Timer 0 factor */\r
+                                          /******************/\r
+\r
+                                          ul_HighTimerValue = (ULONG) (ul_HighTiming * (0.25 * b_ClockSelection));\r
+\r
+                                          /*******************/\r
+                                          /* Round the value */\r
+                                          /*******************/\r
+\r
+                                          if ((double) ((double) ul_HighTiming * (0.25 * (double) b_ClockSelection)) >= ((double) ((double) ul_HighTimerValue + 0.5)))\r
+                                             {\r
+                                             ul_HighTimerValue = ul_HighTimerValue + 1;\r
+                                             }\r
+\r
+                                          /*****************************/\r
+                                          /* Calculate the real timing */\r
+                                          /*****************************/\r
+\r
+                                          *pul_RealHighTiming = (ULONG) (ul_HighTimerValue / (0.25 * (double) b_ClockSelection));\r
+                                          d_RealHighTiming    = (double) ul_HighTimerValue / ((double) 0.25 * (double) b_ClockSelection);\r
+\r
+                                          if ((double) ((double) ul_HighTimerValue / (0.25 * (double) b_ClockSelection)) >= (double) ((double) *pul_RealHighTiming + 0.5))\r
+                                             {\r
+                                             *pul_RealHighTiming = *pul_RealHighTiming + 1;\r
+                                             }\r
+\r
+                                          ul_HighTiming     = ul_HighTiming - 1;\r
+                                          ul_HighTimerValue = ul_HighTimerValue - 2;\r
+\r
+                                          if (b_ClockSelection != APCI1710_40MHZ)\r
+                                             {\r
+                                             ul_HighTimerValue = (ULONG) ((double) (ul_HighTimerValue) * 1.007752288);\r
+                                             }\r
+                                       \r
+\r
+                                       break;\r
+\r
+                                  /******/\r
+                                  /* ms */\r
+                                  /******/\r
+\r
+                                  case 2:\r
+                                       \r
+                                          /******************/\r
+                                          /* Timer 0 factor */\r
+                                          /******************/\r
+\r
+                                          ul_HighTimerValue = ul_HighTiming * (250.0 * b_ClockSelection);\r
+\r
+                                          /*******************/\r
+                                          /* Round the value */\r
+                                          /*******************/\r
+\r
+                                          if ((double) ((double) ul_HighTiming * (250.0 * (double) b_ClockSelection)) >= ((double) ((double) ul_HighTimerValue + 0.5)))\r
+                                             {\r
+                                             ul_HighTimerValue = ul_HighTimerValue + 1;\r
+                                             }\r
+\r
+                                          /*****************************/\r
+                                          /* Calculate the real timing */\r
+                                          /*****************************/\r
+\r
+                                          *pul_RealHighTiming = (ULONG) (ul_HighTimerValue / (250.0 * (double) b_ClockSelection));\r
+                                          d_RealHighTiming    = (double) ul_HighTimerValue / (250.0 * (double) b_ClockSelection);\r
+\r
+                                          if ((double) ((double) ul_HighTimerValue / (250.0 * (double) b_ClockSelection)) >= (double) ((double) *pul_RealHighTiming + 0.5))\r
+                                             {\r
+                                             *pul_RealHighTiming = *pul_RealHighTiming + 1;\r
+                                             }\r
+\r
+                                          ul_HighTiming     = ul_HighTiming - 1;\r
+                                          ul_HighTimerValue = ul_HighTimerValue - 2;\r
+\r
+                                          if (b_ClockSelection != APCI1710_40MHZ)\r
+                                             {\r
+                                             ul_HighTimerValue = (ULONG) ((double) (ul_HighTimerValue) * 1.007752288);\r
+                                             }\r
+                                       \r
+\r
+                                       break;\r
+\r
+                                  /*****/\r
+                                  /* s */\r
+                                  /*****/\r
+\r
+                                  case 3:\r
+                                       \r
+                                          /******************/\r
+                                          /* Timer 0 factor */\r
+                                          /******************/\r
+\r
+                                          ul_HighTimerValue = (ULONG) (ul_HighTiming * (250000.0 * b_ClockSelection));\r
+\r
+                                          /*******************/\r
+                                          /* Round the value */\r
+                                          /*******************/\r
+\r
+                                          if ((double) ((double) ul_HighTiming * (250000.0 * (double) b_ClockSelection)) >= ((double) ((double) ul_HighTimerValue + 0.5)))\r
+                                             {\r
+                                             ul_HighTimerValue = ul_HighTimerValue + 1;\r
+                                             }\r
+\r
+                                          /*****************************/\r
+                                          /* Calculate the real timing */\r
+                                          /*****************************/\r
+\r
+                                          *pul_RealHighTiming = (ULONG) (ul_HighTimerValue / (250000.0 * (double) b_ClockSelection));\r
+                                          d_RealHighTiming    = (double) ul_HighTimerValue / (250000.0 * (double) b_ClockSelection);\r
+\r
+                                          if ((double) ((double) ul_HighTimerValue / (250000.0 * (double) b_ClockSelection)) >= (double) ((double) *pul_RealHighTiming + 0.5))\r
+                                             {\r
+                                             *pul_RealHighTiming = *pul_RealHighTiming + 1;\r
+                                             }\r
+\r
+                                          ul_HighTiming     = ul_HighTiming - 1;\r
+                                          ul_HighTimerValue = ul_HighTimerValue - 2;\r
+\r
+                                          if (b_ClockSelection != APCI1710_40MHZ)\r
+                                             {\r
+                                             ul_HighTimerValue = (ULONG) ((double) (ul_HighTimerValue) * 1.007752288);\r
+                                             }\r
+                                       \r
+\r
+                                       break;\r
+\r
+                                  /******/\r
+                                  /* mn */\r
+                                  /******/\r
+\r
+                                  case 4:\r
+                                       \r
+                                          /******************/\r
+                                          /* Timer 0 factor */\r
+                                          /******************/\r
+\r
+                                          ul_HighTimerValue = (ULONG) ((ul_HighTiming * 60) * (250000.0 * b_ClockSelection));\r
+\r
+                                          /*******************/\r
+                                          /* Round the value */\r
+                                          /*******************/\r
+\r
+                                          if ((double) ((double) (ul_HighTiming * 60.0) * (250000.0 * (double) b_ClockSelection)) >= ((double) ((double) ul_HighTimerValue + 0.5)))\r
+                                             {\r
+                                             ul_HighTimerValue = ul_HighTimerValue + 1;\r
+                                             }\r
+\r
+                                          /*****************************/\r
+                                          /* Calculate the real timing */\r
+                                          /*****************************/\r
+\r
+                                          *pul_RealHighTiming = (ULONG) (ul_HighTimerValue / (250000.0 * (double) b_ClockSelection)) / 60;\r
+                                          d_RealHighTiming    = ((double) ul_HighTimerValue / (250000.0 * (double) b_ClockSelection)) / 60.0;\r
+\r
+                                          if ((double) (((double) ul_HighTimerValue / (250000.0 * (double) b_ClockSelection)) / 60.0) >= (double) ((double) *pul_RealHighTiming + 0.5))\r
+                                             {\r
+                                             *pul_RealHighTiming = *pul_RealHighTiming + 1;\r
+                                             }\r
+\r
+                                          ul_HighTiming     = ul_HighTiming - 1;\r
+                                          ul_HighTimerValue = ul_HighTimerValue - 2;\r
+\r
+                                          if (b_ClockSelection != APCI1710_40MHZ)\r
+                                             {\r
+                                             ul_HighTimerValue = (ULONG) ((double) (ul_HighTimerValue) * 1.007752288);\r
+                                             }\r
+                                       \r
+                                       break;\r
+                                  }\r
+\r
+                               fpu_end ();\r
+                               /****************************/\r
+                               /* Save the clock selection */\r
+                               /****************************/\r
+\r
+                               devpriv->\r
+                               s_ModuleInfo [b_ModulNbr].\r
+                               s_PWMModuleInfo.\r
+                               b_ClockSelection = b_ClockSelection;\r
+\r
+                               /************************/\r
+                               /* Save the timing unit */\r
+                               /************************/\r
+\r
+                               devpriv->\r
+                               s_ModuleInfo [b_ModulNbr].\r
+                               s_PWMModuleInfo.\r
+                               s_PWMInfo [b_PWM].\r
+                               b_TimingUnit = b_TimingUnit;\r
+\r
+                               /****************************/\r
+                               /* Save the low base timing */\r
+                               /****************************/\r
+\r
+                               devpriv->\r
+                               s_ModuleInfo [b_ModulNbr].\r
+                               s_PWMModuleInfo.\r
+                               s_PWMInfo [b_PWM].\r
+                               d_LowTiming = d_RealLowTiming;\r
+\r
+                               devpriv->\r
+                               s_ModuleInfo [b_ModulNbr].\r
+                               s_PWMModuleInfo.\r
+                               s_PWMInfo [b_PWM].\r
+                               ul_RealLowTiming = *pul_RealLowTiming;\r
+\r
+                               /****************************/\r
+                               /* Save the high base timing */\r
+                               /****************************/\r
+\r
+                               devpriv->\r
+                               s_ModuleInfo [b_ModulNbr].\r
+                               s_PWMModuleInfo.\r
+                               s_PWMInfo [b_PWM].\r
+                               d_HighTiming = d_RealHighTiming;\r
+\r
+                               devpriv->\r
+                               s_ModuleInfo [b_ModulNbr].\r
+                               s_PWMModuleInfo.\r
+                               s_PWMInfo [b_PWM].\r
+                               ul_RealHighTiming = *pul_RealHighTiming;\r
+\r
+                               /************************/\r
+                               /* Write the low timing */\r
+                               /************************/\r
+\r
+                         outl(ul_LowTimerValue,devpriv->s_BoardInfos.\r
+                                       ui_Address + 0 + (20 * b_PWM) + (64 * b_ModulNbr));\r
+\r
+                               /*************************/\r
+                               /* Write the high timing */\r
+                               /*************************/\r
+\r
+                        outl(ul_HighTimerValue,devpriv->s_BoardInfos.\r
+                                       ui_Address + 4 + (20 * b_PWM) + (64 * b_ModulNbr));\r
+\r
+                               /***************************/\r
+                               /* Set the clock selection */\r
+                               /***************************/\r
+\r
+                         dw_Command=inl(devpriv->s_BoardInfos.\r
+                                      ui_Address + 8 + (20 * b_PWM) + (64 * b_ModulNbr));\r
+\r
+                               dw_Command = dw_Command & 0x7F;\r
+\r
+                               if (b_ClockSelection == APCI1710_40MHZ)\r
+                                  {\r
+                                  dw_Command = dw_Command | 0x80;\r
+                                  }\r
+\r
+                               /***************************/\r
+                               /* Set the clock selection */\r
+                               /***************************/\r
+\r
+                                 outl(dw_Command,devpriv->s_BoardInfos.\r
+                                       ui_Address + 8 + (20 * b_PWM) + (64 * b_ModulNbr));\r
+\r
+                               /*************/\r
+                               /* PWM init. */\r
+                               /*************/\r
+                               devpriv->\r
+                               s_ModuleInfo [b_ModulNbr].\r
+                               s_PWMModuleInfo.\r
+                               s_PWMInfo [b_PWM].\r
+                               b_PWMInit = 1;\r
+                               }\r
+                            else\r
+                               {\r
+                               /***************************************************/\r
+                               /* You can not used the 40MHz clock selection with */\r
+                               /* this board                                      */\r
+                               /***************************************************/\r
+                        DPRINTK("You can not used the 40MHz clock selection with this board\n");\r
+                               i_ReturnValue = -9;\r
+                               }\r
+                            }\r
+                         else\r
+                            {\r
+                            /***************************************/\r
+                            /* High base timing selection is wrong */\r
+                            /***************************************/\r
+                                DPRINTK("High base timing selection is wrong\n");\r
+                            i_ReturnValue = -8;\r
+                            }\r
+                         }\r
+                      else\r
+                         {\r
+                         /**************************************/\r
+                         /* Low base timing selection is wrong */\r
+                         /**************************************/\r
+                         DPRINTK("Low base timing selection is wrong\n");\r
+                         i_ReturnValue = -7;\r
+                         }\r
+                      } // if ((b_TimingUnit >= 0) && (b_TimingUnit <= 4))\r
+                   else\r
+                      {\r
+                      /**********************************/\r
+                      /* Timing unit selection is wrong */\r
+                      /**********************************/\r
+                          DPRINTK("Timing unit selection is wrong\n");\r
+                      i_ReturnValue = -6;\r
+                      } // if ((b_TimingUnit >= 0) && (b_TimingUnit <= 4))\r
+                   } // if ((b_ClockSelection == APCI1710_30MHZ) || (b_ClockSelection == APCI1710_33MHZ) || (b_ClockSelection == APCI1710_40MHZ))\r
+                else\r
+                   {\r
+                   /*******************************/\r
+                   /* The selected clock is wrong */\r
+                   /*******************************/\r
+                       DPRINTK("The selected clock is wrong\n"); \r
+                   i_ReturnValue = -5;\r
+                   } // if ((b_ClockSelection == APCI1710_30MHZ) || (b_ClockSelection == APCI1710_33MHZ) || (b_ClockSelection == APCI1710_40MHZ))\r
+                } // if (b_PWM >= 0 && b_PWM <= 1)\r
+             else\r
+                {\r
+                /******************************/\r
+                /* Tor PWM selection is wrong */\r
+                /******************************/\r
+                DPRINTK("Tor PWM selection is wrong\n");       \r
+                i_ReturnValue = -4;\r
+                } // if (b_PWM >= 0 && b_PWM <= 1)\r
+             }\r
+          else\r
+             {\r
+             /**********************************/\r
+             /* The module is not a PWM module */\r
+             /**********************************/\r
+             DPRINTK("The module is not a PWM module\n");      \r
+             i_ReturnValue = -3;\r
+             }\r
+          }\r
+       else\r
+          {\r
+          /***********************/\r
+          /* Module number error */\r
+          /***********************/\r
+          DPRINTK("Module number error\n");    \r
+          i_ReturnValue = -2;\r
+          }\r
+\r
+       return (i_ReturnValue);\r
+       }\r
+\r
+\r
+\r
+/*\r
++----------------------------------------------------------------------------+\r
+| Function Name     : _INT_ i_APCI1710_GetPWMInitialisation                  |\r
+|                                       (BYTE_     b_BoardHandle,            |\r
+|                                        BYTE_     b_ModulNbr,               |\r
+|                                        BYTE_     b_PWM,                    |\r
+|                                        PBYTE_   pb_TimingUnit,             |\r
+|                                        PULONG_ pul_LowTiming,              |\r
+|                                        PULONG_ pul_HighTiming,             |\r
+|                                        PBYTE_   pb_StartLevel,             |\r
+|                                        PBYTE_   pb_StopMode,               |\r
+|                                        PBYTE_   pb_StopLevel,              |\r
+|                                        PBYTE_   pb_ExternGate,             |\r
+|                                        PBYTE_   pb_InterruptEnable,        |\r
+|                                        PBYTE_   pb_Enable)                 |\r
++----------------------------------------------------------------------------+\r
+| Task              : Return the PWM (b_PWM) initialisation from selected    |\r
+|                     module (b_ModulNbr). You must calling the              |\r
+|                     "i_APCI1710_InitPWM" function be for you call this     |\r
+|                     function.                                              |\r
++----------------------------------------------------------------------------+\r
+| Input Parameters  : BYTE_ b_BoardHandle : Handle of board APCI-1710        |\r
+|                     BYTE_ b_ModulNbr    : Selected module number (0 to 3)  |\r
+|                     BYTE_ b_PWM         : Selected PWM (0 or 1)            |\r
++----------------------------------------------------------------------------+\r
+| Output Parameters : PBYTE_  pb_TimingUnit      : Base timing Unit (0 to 4) |\r
+|                                                       0 : ns               |\r
+|                                                       1 : æs               |\r
+|                                                       2 : ms               |\r
+|                                                       3 : s                |\r
+|                                                       4 : mn               |\r
+|                     PULONG_ pul_LowTiming      : Low base timing value.    |\r
+|                     PULONG_ pul_HighTiming     : High base timing value.   |\r
+|                     PBYTE_  pb_StartLevel      : Start period level        |\r
+|                                                  selection                 |\r
+|                                                       0 : The period start |\r
+|                                                           with a low level |\r
+|                                                       1 : The period start |\r
+|                                                           with a high level|\r
+|                     PBYTE_  pb_StopMode        : Stop mode selection       |\r
+|                                                  0 : The PWM is stopped    |\r
+|                                                      directly after the    |\r
+|                                                     "i_APCI1710_DisablePWM"|\r
+|                                                      function and break the|\r
+|                                                      last period           |\r
+|                                                  1 : After the             |\r
+|                                                     "i_APCI1710_DisablePWM"|\r
+|                                                      function the PWM is   |\r
+|                                                      stopped at the end    |\r
+|                                                      from last period cycle|\r
+|                     PBYTE_  pb_StopLevel        : Stop PWM level selection |\r
+|                                                    0 : The output signal   |\r
+|                                                        keep the level after|\r
+|                                                        the                 |\r
+|                                                     "i_APCI1710_DisablePWM"|\r
+|                                                        function            |\r
+|                                                    1 : The output signal is|\r
+|                                                        set to low after the|\r
+|                                                     "i_APCI1710_DisablePWM"|\r
+|                                                        function            |\r
+|                                                    2 : The output signal is|\r
+|                                                        set to high after   |\r
+|                                                        the                 |\r
+|                                                     "i_APCI1710_DisablePWM"|\r
+|                                                        function            |\r
+|                     PBYTE_  pb_ExternGate      : Extern gate action        |\r
+|                                                  selection                 |\r
+|                                                   0 : Extern gate signal   |\r
+|                                                       not used.            |\r
+|                                                   1 : Extern gate signal   |\r
+|                                                       used.                |\r
+|                     PBYTE_  pb_InterruptEnable : Enable or disable the PWM |\r
+|                                                  interrupt.                |\r
+|                                                  - APCI1710_ENABLE :       |\r
+|                                                    Enable the PWM interrupt|\r
+|                                                    A interrupt occur after |\r
+|                                                    each period             |\r
+|                                                  - APCI1710_DISABLE :      |\r
+|                                                    Disable the PWM         |\r
+|                                                    interrupt               |\r
+|                     PBYTE_  pb_Enable          : Indicate if the PWM is    |\r
+|                                                  enabled or no             |\r
+|                                                       0 : PWM not enabled  |\r
+|                                                       1 : PWM enabled      |\r
++----------------------------------------------------------------------------+\r
+| Return Value      :  0: No error                                           |\r
+|                     -1: The handle parameter of the board is wrong         |\r
+|                     -2: Module selection wrong                             |\r
+|                     -3: The module is not a PWM module                     |\r
+|                     -4: PWM selection is wrong                             |\r
+|                     -5: PWM not initialised see function                   |\r
+|                         "i_APCI1710_InitPWM"                               |\r
++----------------------------------------------------------------------------+\r
+*/\r
+\r
+INT  i_APCI1710_GetPWMInitialisation (comedi_device *dev,\r
+                                        BYTE     b_ModulNbr,\r
+                                        BYTE     b_PWM,\r
+                                        PBYTE   pb_TimingUnit,\r
+                                        PULONG pul_LowTiming,\r
+                                        PULONG pul_HighTiming,\r
+                                        PBYTE   pb_StartLevel,\r
+                                        PBYTE   pb_StopMode,\r
+                                        PBYTE   pb_StopLevel,\r
+                                        PBYTE   pb_ExternGate,\r
+                                        PBYTE   pb_InterruptEnable,\r
+                                        PBYTE   pb_Enable)\r
+       {\r
+       INT    i_ReturnValue = 0;\r
+       DWORD dw_Status;\r
+       DWORD dw_Command;\r
+\r
+               \r
+       \r
+       /**************************/\r
+       /* Test the module number */\r
+       /**************************/\r
+\r
+       if (b_ModulNbr < 4)\r
+          {\r
+          /***************/\r
+          /* Test if PWM */\r
+          /***************/\r
+\r
+          if ((devpriv->\r
+               s_BoardInfos.\r
+               dw_MolduleConfiguration [b_ModulNbr] & 0xFFFF0000UL) == APCI1710_PWM)\r
+             {\r
+             /**************************/\r
+             /* Test the PWM selection */\r
+             /**************************/\r
+\r
+             if (b_PWM <= 1)\r
+                {\r
+                /***************************/\r
+                /* Test if PWM initialised */\r
+                /***************************/\r
+\r
+                  dw_Status=inl(devpriv->s_BoardInfos.\r
+                       ui_Address + 12 + (20 * b_PWM) + (64 * b_ModulNbr));\r
+\r
+                if (dw_Status & 0x10)\r
+                   {\r
+                   /***********************/\r
+                   /* Read the low timing */\r
+                   /***********************/\r
+\r
+                       *pul_LowTiming = inl(devpriv->s_BoardInfos.\r
+                          ui_Address + 0 + (20 * b_PWM) + (64 * b_ModulNbr));\r
+\r
+                   /************************/\r
+                   /* Read the high timing */\r
+                   /************************/\r
+\r
+                     *pul_HighTiming= inl(devpriv->s_BoardInfos.\r
+                          ui_Address + 4 + (20 * b_PWM) + (64 * b_ModulNbr));\r
+\r
+                   /********************/\r
+                   /* Read the command */\r
+                   /********************/\r
+\r
+                     dw_Command = inl(devpriv->s_BoardInfos.\r
+                          ui_Address + 8 + (20 * b_PWM) + (64 * b_ModulNbr));\r
+\r
+                   *pb_StartLevel      = (BYTE) ((dw_Command >> 5) & 1);\r
+                   *pb_StopMode        = (BYTE) ((dw_Command >> 0) & 1);\r
+                   *pb_StopLevel       = (BYTE) ((dw_Command >> 1) & 1);\r
+                   *pb_ExternGate      = (BYTE) ((dw_Command >> 4) & 1);\r
+                   *pb_InterruptEnable = (BYTE) ((dw_Command >> 3) & 1);\r
+\r
+                   if (*pb_StopLevel)\r
+                      {\r
+                      *pb_StopLevel = *pb_StopLevel + (BYTE) ((dw_Command >> 2) & 1);\r
+                      }\r
+\r
+                   /********************/\r
+                   /* Read the command */\r
+                   /********************/\r
+\r
+                     dw_Command=inl(devpriv->s_BoardInfos.\r
+                          ui_Address + 8 + (20 * b_PWM) + (64 * b_ModulNbr));\r
+\r
+                   *pb_Enable = (BYTE) ((dw_Command >> 0) & 1);\r
+\r
+                   *pb_TimingUnit = devpriv->\r
+                                    s_ModuleInfo [b_ModulNbr].\r
+                                    s_PWMModuleInfo.\r
+                                    s_PWMInfo [b_PWM].\r
+                                    b_TimingUnit;\r
+                   } // if (dw_Status & 0x10)\r
+                else\r
+                   {\r
+                   /***********************/\r
+                   /* PWM not initialised */\r
+                   /***********************/\r
+                    DPRINTK("PWM not initialised\n");\r
+                   i_ReturnValue = -5;\r
+                   } // if (dw_Status & 0x10)\r
+                } // if (b_PWM >= 0 && b_PWM <= 1)\r
+             else\r
+                {\r
+                /******************************/\r
+                /* Tor PWM selection is wrong */\r
+                /******************************/\r
+                DPRINTK("Tor PWM selection is wrong\n");\r
+                i_ReturnValue = -4;\r
+                } // if (b_PWM >= 0 && b_PWM <= 1)\r
+             }\r
+          else\r
+             {\r
+             /**********************************/\r
+             /* The module is not a PWM module */\r
+             /**********************************/\r
+             DPRINTK("The module is not a PWM module\n");      \r
+             i_ReturnValue = -3;\r
+             }\r
+          }\r
+       else\r
+          {\r
+          /***********************/\r
+          /* Module number error */\r
+          /***********************/\r
+          DPRINTK("Module number error\n");\r
+          i_ReturnValue = -2;\r
+          }\r
+\r
+       return (i_ReturnValue);\r
+       }\r
+\r
+\r
+\r
+\r
+\r
+/*\r
++----------------------------------------------------------------------------+\r
+| Function Name     :INT i_APCI1710_InsnWritePWM(comedi_device *dev,\r
+comedi_subdevice *s,comedi_insn *insn,lsampl_t *data)                        |\r
++----------------------------------------------------------------------------+\r
+| Task              : Pwm Enable Disable and Set New Timing                  |\r
++----------------------------------------------------------------------------+\r
+| Input Parameters  : \r
++----------------------------------------------------------------------------+\r
+| Output Parameters : -                                                      |\r
++----------------------------------------------------------------------------+\r
+| Return Value      : \r
++----------------------------------------------------------------------------+\r
+*/\r
+\r
+INT    i_APCI1710_InsnWritePWM(comedi_device *dev,comedi_subdevice *s,\r
+comedi_insn *insn,lsampl_t *data)\r
+{\r
+       BYTE b_WriteType;\r
+       INT i_ReturnValue=0;\r
+    b_WriteType=CR_CHAN(insn->chanspec);\r
+\r
+    \r
+       switch(b_WriteType)\r
+       {\r
+       case APCI1710_PWM_ENABLE :\r
+               i_ReturnValue=i_APCI1710_EnablePWM    (dev,\r
+                                (BYTE)  CR_AREF(insn->chanspec),\r
+                                (BYTE)  data[0],\r
+                                (BYTE)  data[1],\r
+                                (BYTE)  data[2],\r
+                                (BYTE)  data[3],\r
+                                (BYTE)  data[4],\r
+                                (BYTE)  data[5]);\r
+               break;\r
+\r
+       case APCI1710_PWM_DISABLE :\r
+               i_ReturnValue=i_APCI1710_DisablePWM   (dev,\r
+                                (BYTE)  CR_AREF(insn->chanspec),\r
+                                (BYTE)  data[0]);\r
+               break;\r
+\r
+       case APCI1710_PWM_NEWTIMING:\r
+               i_ReturnValue=i_APCI1710_SetNewPWMTiming        (dev,\r
+                                        (BYTE)  CR_AREF(insn->chanspec),\r
+                                        (BYTE)  data[0],\r
+                                        (BYTE)    data[1],\r
+                                        (ULONG)   data[2],\r
+                                        (ULONG)   data[3]);\r
+               break;\r
+\r
+       \r
+       default:\r
+               printk("Write Config Parameter Wrong\n");\r
+       }\r
+\r
+       if(i_ReturnValue>=0) i_ReturnValue =insn->n;\r
+       return (i_ReturnValue);\r
+}\r
+\r
+\r
+\r
+\r
+\r
+/*\r
++----------------------------------------------------------------------------+\r
+| Function Name     : _INT_     i_APCI1710_EnablePWM                         |\r
+|                                       (BYTE_  b_BoardHandle,               |\r
+|                                        BYTE_  b_ModulNbr,                  |\r
+|                                        BYTE_  b_PWM,                       |\r
+|                                        BYTE_  b_StartLevel,                |\r
+|                                        BYTE_  b_StopMode,                  |\r
+|                                        BYTE_  b_StopLevel,                 |\r
+|                                        BYTE_  b_ExternGate,                |\r
+|                                        BYTE_  b_InterruptEnable)           |\r
++----------------------------------------------------------------------------+\r
+| Task              : Enable the selected PWM (b_PWM) from selected module   |\r
+|                     (b_ModulNbr). You must calling the "i_APCI1710_InitPWM"|\r
+|                     function be for you call this function.                |\r
+|                     If you enable the PWM interrupt, the PWM generate a    |\r
+|                     interrupt after each period.                           |\r
+|                     See function "i_APCI1710_SetBoardIntRoutineX" and the  |\r
+|                     Interrupt mask description chapter.                    |\r
++----------------------------------------------------------------------------+\r
+| Input Parameters  : BYTE_ b_BoardHandle     : Handle of board APCI-1710    |\r
+|                     BYTE_ b_ModulNbr        : Selected module number       |\r
+|                                               (0 to 3)                     |\r
+|                     BYTE_ b_PWM             : Selected PWM (0 or 1)        |\r
+|                     BYTE_ b_StartLevel      : Start period level selection |\r
+|                                                0 : The period start with a |\r
+|                                                    low level               |\r
+|                                                1 : The period start with a |\r
+|                                                    high level              |\r
+|                     BYTE_ b_StopMode        : Stop mode selection          |\r
+|                                                0 : The PWM is stopped      |\r
+|                                                    directly after the      |\r
+|                                                    "i_APCI1710_DisablePWM" |\r
+|                                                    function and break the  |\r
+|                                                    last period             |\r
+|                                                1 : After the               |\r
+|                                                    "i_APCI1710_DisablePWM" |\r
+|                                                     function the PWM is    |\r
+|                                                     stopped at the end from|\r
+|                                                     last period cycle.     |\r
+|                     BYTE_ b_StopLevel       : Stop PWM level selection     |\r
+|                                                0 : The output signal keep  |\r
+|                                                    the level after the     |\r
+|                                                    "i_APCI1710_DisablePWM" |\r
+|                                                    function                |\r
+|                                                1 : The output signal is set|\r
+|                                                    to low after the        |\r
+|                                                    "i_APCI1710_DisablePWM" |\r
+|                                                    function                |\r
+|                                                2 : The output signal is set|\r
+|                                                    to high after the       |\r
+|                                                    "i_APCI1710_DisablePWM" |\r
+|                                                    function                |\r
+|                     BYTE_ b_ExternGate      : Extern gate action selection |\r
+|                                                0 : Extern gate signal not  |\r
+|                                                    used.                   |\r
+|                                                1 : Extern gate signal used.|\r
+|                     BYTE_ b_InterruptEnable : Enable or disable the PWM    |\r
+|                                               interrupt.                   |\r
+|                                               - APCI1710_ENABLE :          |\r
+|                                                 Enable the PWM interrupt   |\r
+|                                                 A interrupt occur after    |\r
+|                                                 each period                |\r
+|                                               - APCI1710_DISABLE :         |\r
+|                                                 Disable the PWM interrupt  |\r
++----------------------------------------------------------------------------+\r
+| Output Parameters : -                                                      |\r
++----------------------------------------------------------------------------+\r
+| Return Value      : 0:  No error                                           |\r
+|                    -1:  The handle parameter of the board is wrong         |\r
+|                    -2:  Module selection wrong                             |\r
+|                    -3:  The module is not a PWM module                     |\r
+|                    -4:  PWM selection is wrong                             |\r
+|                    -5:  PWM not initialised see function                   |\r
+|                         "i_APCI1710_InitPWM"                               |\r
+|                    -6:  PWM start level selection is wrong                 |\r
+|                    -7:  PWM stop mode selection is wrong                   |\r
+|                    -8:  PWM stop level selection is wrong                  |\r
+|                    -9:  Extern gate signal selection is wrong              |\r
+|                    -10: Interrupt parameter is wrong                       |\r
+|                    -11: Interrupt function not initialised.                |\r
+|                         See function "i_APCI1710_SetBoardIntRoutineX"      |\r
++----------------------------------------------------------------------------+\r
+*/\r
+\r
+INT   i_APCI1710_EnablePWM    (comedi_device *dev,\r
+                                BYTE  b_ModulNbr,\r
+                                BYTE  b_PWM,\r
+                                BYTE  b_StartLevel,\r
+                                BYTE  b_StopMode,\r
+                                BYTE  b_StopLevel,\r
+                                BYTE  b_ExternGate,\r
+                                BYTE  b_InterruptEnable)\r
+       {\r
+       INT    i_ReturnValue = 0;\r
+       DWORD dw_Status;\r
+       DWORD dw_Command;\r
+\r
+               \r
+        devpriv->tsk_Current=current; // Save the current process task structure\r
+       /**************************/\r
+       /* Test the module number */\r
+       /**************************/\r
+\r
+       if (b_ModulNbr < 4)\r
+          {\r
+          /***************/\r
+          /* Test if PWM */\r
+          /***************/\r
+\r
+          if ((devpriv->\r
+               s_BoardInfos.\r
+               dw_MolduleConfiguration [b_ModulNbr] & 0xFFFF0000UL) == APCI1710_PWM)\r
+             {\r
+             /**************************/\r
+             /* Test the PWM selection */\r
+             /**************************/\r
+\r
+             if (b_PWM <= 1)\r
+                {\r
+                /***************************/\r
+                /* Test if PWM initialised */\r
+                /***************************/\r
+\r
+                dw_Status=      inl(devpriv->s_BoardInfos.\r
+                       ui_Address + 12 + (20 * b_PWM) + (64 * b_ModulNbr));\r
+\r
+                if (dw_Status & 0x10)\r
+                   {\r
+                   /**********************************/\r
+                   /* Test the start level selection */\r
+                   /**********************************/\r
+\r
+                   if (b_StartLevel <= 1)\r
+                      {\r
+                      /**********************/\r
+                      /* Test the stop mode */\r
+                      /**********************/\r
+\r
+                      if (b_StopMode <= 1)\r
+                         {\r
+                         /***********************/\r
+                         /* Test the stop level */\r
+                         /***********************/\r
+\r
+                         if (b_StopLevel <= 2)\r
+                            {\r
+                            /*****************************/\r
+                            /* Test the extern gate mode */\r
+                            /*****************************/\r
+\r
+                            if (b_ExternGate <= 1)\r
+                               {\r
+                               /*****************************/\r
+                               /* Test the interrupt action */\r
+                               /*****************************/\r
+\r
+                               if (b_InterruptEnable == APCI1710_ENABLE || b_InterruptEnable == APCI1710_DISABLE)\r
+                                  {\r
+                                  /******************************************/\r
+                                  /* Test if interrupt function initialised */\r
+                                  /******************************************/\r
+\r
+                                     /********************/\r
+                                     /* Read the command */\r
+                                     /********************/\r
+\r
+                                           dw_Command=inl(devpriv->s_BoardInfos.\r
+                                            ui_Address + 8 + (20 * b_PWM) + (64 * b_ModulNbr));\r
+\r
+                                     dw_Command = dw_Command & 0x80;\r
+\r
+                                     /********************/\r
+                                     /* Make the command */\r
+                                     /********************/\r
+\r
+                                     dw_Command = dw_Command | b_StopMode | (b_InterruptEnable << 3) | (b_ExternGate << 4) | (b_StartLevel << 5);\r
+\r
+                                     if (b_StopLevel & 3)\r
+                                        {\r
+                                        dw_Command = dw_Command | 2;\r
+\r
+                                        if (b_StopLevel & 2)\r
+                                           {\r
+                                           dw_Command = dw_Command | 4;\r
+                                           }\r
+                                        }\r
+\r
+\r
+                                     devpriv->\r
+                                     s_ModuleInfo [b_ModulNbr].\r
+                                     s_PWMModuleInfo.\r
+                                     s_PWMInfo [b_PWM].\r
+                                     b_InterruptEnable = b_InterruptEnable;\r
+\r
+                                     /*******************/\r
+                                     /* Set the command */\r
+                                     /*******************/\r
+\r
+                                         outl(dw_Command,devpriv->s_BoardInfos.\r
+                                             ui_Address + 8 + (20 * b_PWM) + (64 * b_ModulNbr));\r
+\r
+                                     /******************/\r
+                                     /* Enable the PWM */\r
+                                     /******************/\r
+                                         outl(1,devpriv->s_BoardInfos.\r
+                                             ui_Address + 12 + (20 * b_PWM) + (64 * b_ModulNbr));\r
+                                  } // if (b_InterruptEnable == APCI1710_ENABLE || b_InterruptEnable == APCI1710_DISABLE)\r
+                               else\r
+                                  {\r
+                                  /********************************/\r
+                                  /* Interrupt parameter is wrong */\r
+                                  /********************************/\r
+                           DPRINTK("Interrupt parameter is wrong\n");\r
+                                  i_ReturnValue = -10;\r
+                                  } // if (b_InterruptEnable == APCI1710_ENABLE || b_InterruptEnable == APCI1710_DISABLE)\r
+                               } // if (b_ExternGate >= 0 && b_ExternGate <= 1)\r
+                            else\r
+                               {\r
+                               /*****************************************/\r
+                               /* Extern gate signal selection is wrong */\r
+                               /*****************************************/\r
+                               DPRINTK("Extern gate signal selection is wrong\n");\r
+                               i_ReturnValue = -9;\r
+                               } // if (b_ExternGate >= 0 && b_ExternGate <= 1)\r
+                            } // if (b_StopLevel >= 0 && b_StopLevel <= 2)\r
+                         else\r
+                            {\r
+                            /*************************************/\r
+                            /* PWM stop level selection is wrong */\r
+                            /*************************************/\r
+                                DPRINTK("PWM stop level selection is wrong\n");\r
+                            i_ReturnValue = -8;\r
+                            } // if (b_StopLevel >= 0 && b_StopLevel <= 2)\r
+                         } // if (b_StopMode >= 0 && b_StopMode <= 1)\r
+                      else\r
+                         {\r
+                         /************************************/\r
+                         /* PWM stop mode selection is wrong */\r
+                         /************************************/\r
+                         DPRINTK("PWM stop mode selection is wrong\n");        \r
+                         i_ReturnValue = -7;\r
+                         } // if (b_StopMode >= 0 && b_StopMode <= 1)\r
+                      } // if (b_StartLevel >= 0 && b_StartLevel <= 1)\r
+                   else\r
+                      {\r
+                      /**************************************/\r
+                      /* PWM start level selection is wrong */\r
+                      /**************************************/\r
+                          DPRINTK("PWM start level selection is wrong\n");       \r
+                      i_ReturnValue = -6;\r
+                      } // if (b_StartLevel >= 0 && b_StartLevel <= 1)\r
+                   } // if (dw_Status & 0x10)\r
+                else\r
+                   {\r
+                   /***********************/\r
+                   /* PWM not initialised */\r
+                   /***********************/\r
+                       DPRINTK("PWM not initialised\n");\r
+                   i_ReturnValue = -5;\r
+                   } // if (dw_Status & 0x10)\r
+                } // if (b_PWM >= 0 && b_PWM <= 1)\r
+             else\r
+                {\r
+                /******************************/\r
+                /* Tor PWM selection is wrong */\r
+                /******************************/\r
+                DPRINTK("Tor PWM selection is wrong\n");\r
+                i_ReturnValue = -4;\r
+                } // if (b_PWM >= 0 && b_PWM <= 1)\r
+             }\r
+          else\r
+             {\r
+             /**********************************/\r
+             /* The module is not a PWM module */\r
+             /**********************************/\r
+             DPRINTK("The module is not a PWM module\n");      \r
+             i_ReturnValue = -3;\r
+             }\r
+          }\r
+       else\r
+          {\r
+          /***********************/\r
+          /* Module number error */\r
+          /***********************/\r
+          DPRINTK("Module number error\n");    \r
+          i_ReturnValue = -2;\r
+          }\r
+\r
+       return (i_ReturnValue);\r
+       }\r
+\r
+/*\r
++----------------------------------------------------------------------------+\r
+| Function Name     : _INT_ i_APCI1710_DisablePWM (BYTE_  b_BoardHandle,     |\r
+|                                                  BYTE_  b_ModulNbr,        |\r
+|                                                  BYTE_  b_PWM)             |\r
++----------------------------------------------------------------------------+\r
+| Task              : Disable the selected PWM (b_PWM) from selected module  |\r
+|                     (b_ModulNbr). The output signal level depend of the    |\r
+|                     initialisation by the "i_APCI1710_EnablePWM".          |\r
+|                     See the b_StartLevel, b_StopMode and b_StopLevel       |\r
+|                     parameters from this function.                         |\r
++----------------------------------------------------------------------------+\r
+| Input Parameters  :BYTE_ b_BoardHandle : Handle of board APCI-1710         |\r
+|                    BYTE_ b_ModulNbr    : Selected module number (0 to 3)   |\r
+|                    BYTE_ b_PWM         : Selected PWM (0 or 1)             |\r
++----------------------------------------------------------------------------+\r
+| Output Parameters : -                                                      |\r
++----------------------------------------------------------------------------+\r
+| Return Value      :  0: No error                                           |\r
+|                     -1: The handle parameter of the board is wrong         |\r
+|                     -2: Module selection wrong                             |\r
+|                     -3: The module is not a PWM module                     |\r
+|                     -4: PWM selection is wrong                             |\r
+|                     -5: PWM not initialised see function                   |\r
+|                         "i_APCI1710_InitPWM"                               |\r
+|                     -6: PWM not enabled see function                       |\r
+|                         "i_APCI1710_EnablePWM"                             |\r
++----------------------------------------------------------------------------+\r
+*/\r
+\r
+INT   i_APCI1710_DisablePWM   (comedi_device *dev,\r
+                                BYTE  b_ModulNbr,\r
+                                BYTE  b_PWM)\r
+       {\r
+       INT    i_ReturnValue = 0;\r
+       DWORD dw_Status;\r
+\r
+       /**************************/\r
+       /* Test the module number */\r
+       /**************************/\r
+\r
+       if (b_ModulNbr < 4)\r
+          {\r
+          /***************/\r
+          /* Test if PWM */\r
+          /***************/\r
+\r
+          if ((devpriv->s_BoardInfos.\r
+               dw_MolduleConfiguration [b_ModulNbr] & 0xFFFF0000UL) == APCI1710_PWM)\r
+             {\r
+             /**************************/\r
+             /* Test the PWM selection */\r
+             /**************************/\r
+\r
+             if (b_PWM <= 1)\r
+                {\r
+                /***************************/\r
+                /* Test if PWM initialised */\r
+                /***************************/\r
+\r
+           dw_Status=inl(devpriv->s_BoardInfos.\r
+                       ui_Address + 12 + (20 * b_PWM) + (64 * b_ModulNbr));\r
+\r
+                if (dw_Status & 0x10)\r
+                   {\r
+                   /***********************/\r
+                   /* Test if PWM enabled */\r
+                   /***********************/\r
+\r
+                   if (dw_Status & 0x1)\r
+                      {\r
+                      /*******************/\r
+                      /* Disable the PWM */\r
+                      /*******************/\r
+                               outl(0,devpriv->s_BoardInfos.\r
+                              ui_Address + 12 + (20 * b_PWM) + (64 * b_ModulNbr));\r
+                      } // if (dw_Status & 0x1)\r
+                   else\r
+                      {\r
+                      /*******************/\r
+                      /* PWM not enabled */\r
+                      /*******************/\r
+                          DPRINTK("PWM not enabled\n");        \r
+                      i_ReturnValue = -6;\r
+                      } // if (dw_Status & 0x1)\r
+                   } // if (dw_Status & 0x10)\r
+                else\r
+                   {\r
+                   /***********************/\r
+                   /* PWM not initialised */\r
+                   /***********************/\r
+                       DPRINTK(" PWM not initialised\n");\r
+                   i_ReturnValue = -5;\r
+                   } // if (dw_Status & 0x10)\r
+                } // if (b_PWM >= 0 && b_PWM <= 1)\r
+             else\r
+                {\r
+                /******************************/\r
+                /* Tor PWM selection is wrong */\r
+                /******************************/\r
+                DPRINTK("Tor PWM selection is wrong\n");       \r
+                i_ReturnValue = -4;\r
+                } // if (b_PWM >= 0 && b_PWM <= 1)\r
+             }\r
+          else\r
+             {\r
+             /**********************************/\r
+             /* The module is not a PWM module */\r
+             /**********************************/\r
+             DPRINTK("The module is not a PWM module\n");      \r
+             i_ReturnValue = -3;\r
+             }\r
+          }\r
+       else\r
+          {\r
+          /***********************/\r
+          /* Module number error */\r
+          /***********************/\r
+          DPRINTK("Module number error\n");\r
+          i_ReturnValue = -2;\r
+          }\r
+\r
+       return (i_ReturnValue);\r
+       }\r
+\r
+/*\r
++----------------------------------------------------------------------------+\r
+| Function Name     : _INT_ i_APCI1710_SetNewPWMTiming                       |\r
+|                                       (BYTE_     b_BoardHandle,            |\r
+|                                        BYTE_     b_ModulNbr,               |\r
+|                                        BYTE_     b_PWM,                    |\r
+|                                        BYTE_     b_ClockSelection,         |\r
+|                                        BYTE_     b_TimingUnit,             |\r
+|                                        ULONG_   ul_LowTiming,              |\r
+|                                        ULONG_   ul_HighTiming)             |\r
++----------------------------------------------------------------------------+\r
+| Task              : Set a new timing. The ul_LowTiming, ul_HighTiming and  |\r
+|                     ul_TimingUnit determine the low/high timing base for   |\r
+|                     the period.                                            |\r
++----------------------------------------------------------------------------+\r
+| Input Parameters  : BYTE_     b_BoardHandle    : Handle of board APCI-1710 |\r
+|                     BYTE_     b_ModulNbr       : Module number to configure|\r
+|                                                  (0 to 3)                  |\r
+|                     BYTE_     b_PWM            : Selected PWM (0 or 1).    |\r
+|                     BYTE_     b_TimingUnit     : Base timing Unit (0 to 4) |\r
+|                                                       0 : ns               |\r
+|                                                       1 : æs               |\r
+|                                                       2 : ms               |\r
+|                                                       3 : s                |\r
+|                                                       4 : mn               |\r
+|                     ULONG_    ul_LowTiming     : Low base timing value.    |\r
+|                     ULONG_    ul_HighTiming    : High base timing value.   |\r
++----------------------------------------------------------------------------+\r
+| Output Parameters : -                                                      |\r
++----------------------------------------------------------------------------+\r
+| Return Value      : 0: No error                                            |\r
+|                    -1: The handle parameter of the board is wrong          |\r
+|                    -2: Module selection wrong                              |\r
+|                    -3: The module is not a PWM module                      |\r
+|                    -4: PWM selection is wrong                              |\r
+|                    -5: PWM not initialised                                 |\r
+|                    -6: Timing Unit selection is wrong                      |\r
+|                    -7: Low base timing selection is wrong                  |\r
+|                    -8: High base timing selection is wrong                 |\r
 +----------------------------------------------------------------------------+\r
 */\r
 \r
+INT   i_APCI1710_SetNewPWMTiming       (comedi_device *dev,\r
+                                        BYTE     b_ModulNbr,\r
+                                        BYTE     b_PWM,\r
+                                        BYTE     b_TimingUnit,\r
+                                        ULONG   ul_LowTiming,\r
+                                        ULONG   ul_HighTiming)\r
+       {\r
+       BYTE   b_ClockSelection;\r
+       INT    i_ReturnValue = 0;\r
+       ULONG ul_LowTimerValue = 0;\r
+       ULONG ul_HighTimerValue = 0;\r
+       ULONG ul_RealLowTiming = 0;\r
+       ULONG ul_RealHighTiming = 0;\r
+       DWORD dw_Status;\r
+       DWORD dw_Command;\r
+       double d_RealLowTiming = 0;\r
+       double d_RealHighTiming = 0;\r
+       \r
+\r
+       /**************************/\r
+       /* Test the module number */\r
+       /**************************/\r
+\r
+       if (b_ModulNbr < 4)\r
+          {\r
+          /***************/\r
+          /* Test if PWM */\r
+          /***************/\r
+\r
+          if ((devpriv->s_BoardInfos.\r
+               dw_MolduleConfiguration [b_ModulNbr] & 0xFFFF0000UL) == APCI1710_PWM)\r
+             {\r
+             /**************************/\r
+             /* Test the PWM selection */\r
+             /**************************/\r
+\r
+             if (b_PWM <= 1)\r
+                {\r
+                /***************************/\r
+                /* Test if PWM initialised */\r
+                /***************************/\r
+\r
+                       dw_Status=inl(devpriv->s_BoardInfos.\r
+                       ui_Address + 12 + (20 * b_PWM) + (64 * b_ModulNbr));\r
+\r
+                if (dw_Status & 0x10)\r
+                   {\r
+                   b_ClockSelection = devpriv->\r
+                                      s_ModuleInfo [b_ModulNbr].\r
+                                      s_PWMModuleInfo.\r
+                                      b_ClockSelection;\r
+\r
+                   /************************/\r
+                   /* Test the timing unit */\r
+                   /************************/\r
+\r
+                   if (b_TimingUnit <= 4)\r
+                      {\r
+                      /*********************************/\r
+                      /* Test the low timing selection */\r
+                      /*********************************/\r
+\r
+                      if (((b_ClockSelection == APCI1710_30MHZ) && (b_TimingUnit == 0) && (ul_LowTiming >= 266) && (ul_LowTiming <= 0xFFFFFFFFUL)) ||\r
+                          ((b_ClockSelection == APCI1710_30MHZ) && (b_TimingUnit == 1) && (ul_LowTiming >= 1)   && (ul_LowTiming <= 571230650UL))  ||\r
+                          ((b_ClockSelection == APCI1710_30MHZ) && (b_TimingUnit == 2) && (ul_LowTiming >= 1)   && (ul_LowTiming <= 571230UL))     ||\r
+                          ((b_ClockSelection == APCI1710_30MHZ) && (b_TimingUnit == 3) && (ul_LowTiming >= 1)   && (ul_LowTiming <= 571UL))        ||\r
+                          ((b_ClockSelection == APCI1710_30MHZ) && (b_TimingUnit == 4) && (ul_LowTiming >= 1)   && (ul_LowTiming <= 9UL))          ||\r
+                          ((b_ClockSelection == APCI1710_33MHZ) && (b_TimingUnit == 0) && (ul_LowTiming >= 242) && (ul_LowTiming <= 0xFFFFFFFFUL)) ||\r
+                          ((b_ClockSelection == APCI1710_33MHZ) && (b_TimingUnit == 1) && (ul_LowTiming >= 1)   && (ul_LowTiming <= 519691043UL))  ||\r
+                          ((b_ClockSelection == APCI1710_33MHZ) && (b_TimingUnit == 2) && (ul_LowTiming >= 1)   && (ul_LowTiming <= 519691UL))     ||\r
+                          ((b_ClockSelection == APCI1710_33MHZ) && (b_TimingUnit == 3) && (ul_LowTiming >= 1)   && (ul_LowTiming <= 520UL))        ||\r
+                          ((b_ClockSelection == APCI1710_33MHZ) && (b_TimingUnit == 4) && (ul_LowTiming >= 1)   && (ul_LowTiming <= 8UL))          ||\r
+                          ((b_ClockSelection == APCI1710_40MHZ) && (b_TimingUnit == 0) && (ul_LowTiming >= 200) && (ul_LowTiming <= 0xFFFFFFFFUL)) ||\r
+                          ((b_ClockSelection == APCI1710_40MHZ) && (b_TimingUnit == 1) && (ul_LowTiming >= 1)   && (ul_LowTiming <= 429496729UL))  ||\r
+                          ((b_ClockSelection == APCI1710_40MHZ) && (b_TimingUnit == 2) && (ul_LowTiming >= 1)   && (ul_LowTiming <= 429496UL))     ||\r
+                          ((b_ClockSelection == APCI1710_40MHZ) && (b_TimingUnit == 3) && (ul_LowTiming >= 1)   && (ul_LowTiming <= 429UL))        ||\r
+                          ((b_ClockSelection == APCI1710_40MHZ) && (b_TimingUnit == 4) && (ul_LowTiming >= 1)   && (ul_LowTiming <= 7UL)))\r
+                         {\r
+                         /**********************************/\r
+                         /* Test the High timing selection */\r
+                         /**********************************/\r
+\r
+                         if (((b_ClockSelection == APCI1710_30MHZ) && (b_TimingUnit == 0) && (ul_HighTiming >= 266) && (ul_HighTiming <= 0xFFFFFFFFUL)) ||\r
+                             ((b_ClockSelection == APCI1710_30MHZ) && (b_TimingUnit == 1) && (ul_HighTiming >= 1)   && (ul_HighTiming <= 571230650UL))  ||\r
+                             ((b_ClockSelection == APCI1710_30MHZ) && (b_TimingUnit == 2) && (ul_HighTiming >= 1)   && (ul_HighTiming <= 571230UL))     ||\r
+                             ((b_ClockSelection == APCI1710_30MHZ) && (b_TimingUnit == 3) && (ul_HighTiming >= 1)   && (ul_HighTiming <= 571UL))        ||\r
+                             ((b_ClockSelection == APCI1710_30MHZ) && (b_TimingUnit == 4) && (ul_HighTiming >= 1)   && (ul_HighTiming <= 9UL))          ||\r
+                             ((b_ClockSelection == APCI1710_33MHZ) && (b_TimingUnit == 0) && (ul_HighTiming >= 242) && (ul_HighTiming <= 0xFFFFFFFFUL)) ||\r
+                             ((b_ClockSelection == APCI1710_33MHZ) && (b_TimingUnit == 1) && (ul_HighTiming >= 1)   && (ul_HighTiming <= 519691043UL))  ||\r
+                             ((b_ClockSelection == APCI1710_33MHZ) && (b_TimingUnit == 2) && (ul_HighTiming >= 1)   && (ul_HighTiming <= 519691UL))     ||\r
+                             ((b_ClockSelection == APCI1710_33MHZ) && (b_TimingUnit == 3) && (ul_HighTiming >= 1)   && (ul_HighTiming <= 520UL))        ||\r
+                             ((b_ClockSelection == APCI1710_33MHZ) && (b_TimingUnit == 4) && (ul_HighTiming >= 1)   && (ul_HighTiming <= 8UL))          ||\r
+                             ((b_ClockSelection == APCI1710_40MHZ) && (b_TimingUnit == 0) && (ul_HighTiming >= 200) && (ul_HighTiming <= 0xFFFFFFFFUL)) ||\r
+                             ((b_ClockSelection == APCI1710_40MHZ) && (b_TimingUnit == 1) && (ul_HighTiming >= 1)   && (ul_HighTiming <= 429496729UL))  ||\r
+                             ((b_ClockSelection == APCI1710_40MHZ) && (b_TimingUnit == 2) && (ul_HighTiming >= 1)   && (ul_HighTiming <= 429496UL))     ||\r
+                             ((b_ClockSelection == APCI1710_40MHZ) && (b_TimingUnit == 3) && (ul_HighTiming >= 1)   && (ul_HighTiming <= 429UL))        ||\r
+                             ((b_ClockSelection == APCI1710_40MHZ) && (b_TimingUnit == 4) && (ul_HighTiming >= 1)   && (ul_HighTiming <= 7UL)))\r
+                            {\r
+                            /************************************/\r
+                            /* Calculate the low division fator */\r
+                            /************************************/\r
+\r
+                            fpu_begin ();\r
+                            switch (b_TimingUnit)\r
+                               {\r
+                               /******/\r
+                               /* ns */\r
+                               /******/\r
+\r
+                               case 0:\r
+                                    \r
+                                       /******************/\r
+                                       /* Timer 0 factor */\r
+                                       /******************/\r
+\r
+                                       ul_LowTimerValue = (ULONG) (ul_LowTiming * (0.00025 * b_ClockSelection));\r
+\r
+                                       /*******************/\r
+                                       /* Round the value */\r
+                                       /*******************/\r
+\r
+                                       if ((double) ((double) ul_LowTiming * (0.00025 * (double) b_ClockSelection)) >= ((double) ((double) ul_LowTimerValue + 0.5)))\r
+                                          {\r
+                                          ul_LowTimerValue = ul_LowTimerValue + 1;\r
+                                          }\r
+\r
+                                       /*****************************/\r
+                                       /* Calculate the real timing */\r
+                                       /*****************************/\r
+\r
+                                       ul_RealLowTiming = (ULONG) (ul_LowTimerValue / (0.00025 * (double) b_ClockSelection));\r
+                                       d_RealLowTiming = (double) ul_LowTimerValue / (0.00025 * (double) b_ClockSelection);\r
+\r
+                                       if ((double) ((double) ul_LowTimerValue / (0.00025 * (double) b_ClockSelection)) >= (double) ((double) ul_RealLowTiming + 0.5))\r
+                                          {\r
+                                          ul_RealLowTiming = ul_RealLowTiming + 1;\r
+                                          }\r
+\r
+                                       ul_LowTiming     = ul_LowTiming - 1;\r
+                                       ul_LowTimerValue = ul_LowTimerValue - 2;\r
+\r
+                                       if (b_ClockSelection != APCI1710_40MHZ)\r
+                                          {\r
+                                          ul_LowTimerValue = (ULONG) ((double) (ul_LowTimerValue) * 1.007752288);\r
+                                          }\r
+                                   \r
+\r
+                                    break;\r
+\r
+                               /******/\r
+                               /* æs */\r
+                               /******/\r
+\r
+                               case 1:\r
+                                   \r
+                                       /******************/\r
+                                       /* Timer 0 factor */\r
+                                       /******************/\r
+\r
+                                       ul_LowTimerValue = (ULONG) (ul_LowTiming * (0.25 * b_ClockSelection));\r
+\r
+                                       /*******************/\r
+                                       /* Round the value */\r
+                                       /*******************/\r
+\r
+                                       if ((double) ((double) ul_LowTiming * (0.25 * (double) b_ClockSelection)) >= ((double) ((double) ul_LowTimerValue + 0.5)))\r
+                                          {\r
+                                          ul_LowTimerValue = ul_LowTimerValue + 1;\r
+                                          }\r
+\r
+                                       /*****************************/\r
+                                       /* Calculate the real timing */\r
+                                       /*****************************/\r
+\r
+                                       ul_RealLowTiming = (ULONG) (ul_LowTimerValue / (0.25 * (double) b_ClockSelection));\r
+                                       d_RealLowTiming    = (double) ul_LowTimerValue / ((double) 0.25 * (double) b_ClockSelection);\r
+\r
+                                       if ((double) ((double) ul_LowTimerValue / (0.25 * (double) b_ClockSelection)) >= (double) ((double) ul_RealLowTiming + 0.5))\r
+                                          {\r
+                                          ul_RealLowTiming = ul_RealLowTiming + 1;\r
+                                          }\r
+\r
+                                       ul_LowTiming     = ul_LowTiming - 1;\r
+                                       ul_LowTimerValue = ul_LowTimerValue - 2;\r
+\r
+                                       if (b_ClockSelection != APCI1710_40MHZ)\r
+                                          {\r
+                                          ul_LowTimerValue = (ULONG) ((double) (ul_LowTimerValue) * 1.007752288);\r
+                                          }\r
+                                   \r
+                                    break;\r
+\r
+                               /******/\r
+                               /* ms */\r
+                               /******/\r
+\r
+                               case 2:\r
+                                    \r
+                                       /******************/\r
+                                       /* Timer 0 factor */\r
+                                       /******************/\r
+\r
+                                       ul_LowTimerValue = ul_LowTiming * (250.0 * b_ClockSelection);\r
+\r
+                                       /*******************/\r
+                                       /* Round the value */\r
+                                       /*******************/\r
+\r
+                                       if ((double) ((double) ul_LowTiming * (250.0 * (double) b_ClockSelection)) >= ((double) ((double) ul_LowTimerValue + 0.5)))\r
+                                          {\r
+                                          ul_LowTimerValue = ul_LowTimerValue + 1;\r
+                                          }\r
+\r
+                                       /*****************************/\r
+                                       /* Calculate the real timing */\r
+                                       /*****************************/\r
+\r
+                                       ul_RealLowTiming = (ULONG) (ul_LowTimerValue / (250.0 * (double) b_ClockSelection));\r
+                                       d_RealLowTiming    = (double) ul_LowTimerValue / (250.0 * (double) b_ClockSelection);\r
+\r
+                                       if ((double) ((double) ul_LowTimerValue / (250.0 * (double) b_ClockSelection)) >= (double) ((double) ul_RealLowTiming + 0.5))\r
+                                          {\r
+                                          ul_RealLowTiming = ul_RealLowTiming + 1;\r
+                                          }\r
+\r
+                                       ul_LowTiming     = ul_LowTiming - 1;\r
+                                       ul_LowTimerValue = ul_LowTimerValue - 2;\r
+\r
+                                       if (b_ClockSelection != APCI1710_40MHZ)\r
+                                          {\r
+                                          ul_LowTimerValue = (ULONG) ((double) (ul_LowTimerValue) * 1.007752288);\r
+                                          }\r
+                                    \r
+                                    break;\r
+\r
+                               /*****/\r
+                               /* s */\r
+                               /*****/\r
+\r
+                               case 3:\r
+                                    \r
+                                       /******************/\r
+                                       /* Timer 0 factor */\r
+                                       /******************/\r
+\r
+                                       ul_LowTimerValue = (ULONG) (ul_LowTiming * (250000.0 * b_ClockSelection));\r
+\r
+                                       /*******************/\r
+                                       /* Round the value */\r
+                                       /*******************/\r
+\r
+                                       if ((double) ((double) ul_LowTiming * (250000.0 * (double) b_ClockSelection)) >= ((double) ((double) ul_LowTimerValue + 0.5)))\r
+                                          {\r
+                                          ul_LowTimerValue = ul_LowTimerValue + 1;\r
+                                          }\r
+\r
+                                       /*****************************/\r
+                                       /* Calculate the real timing */\r
+                                       /*****************************/\r
+\r
+                                       ul_RealLowTiming = (ULONG) (ul_LowTimerValue / (250000.0 * (double) b_ClockSelection));\r
+                                       d_RealLowTiming    = (double) ul_LowTimerValue / (250000.0 * (double) b_ClockSelection);\r
+\r
+                                       if ((double) ((double) ul_LowTimerValue / (250000.0 * (double) b_ClockSelection)) >= (double) ((double) ul_RealLowTiming + 0.5))\r
+                                          {\r
+                                          ul_RealLowTiming = ul_RealLowTiming + 1;\r
+                                          }\r
+\r
+                                       ul_LowTiming     = ul_LowTiming - 1;\r
+                                       ul_LowTimerValue = ul_LowTimerValue - 2;\r
+\r
+                                       if (b_ClockSelection != APCI1710_40MHZ)\r
+                                          {\r
+                                          ul_LowTimerValue = (ULONG) ((double) (ul_LowTimerValue) * 1.007752288);\r
+                                          }\r
+                                   \r
+                                    break;\r
+\r
+                               /******/\r
+                               /* mn */\r
+                               /******/\r
+\r
+                               case 4:\r
+                                    \r
+                                       /******************/\r
+                                       /* Timer 0 factor */\r
+                                       /******************/\r
+\r
+                                       ul_LowTimerValue = (ULONG) ((ul_LowTiming * 60) * (250000.0 * b_ClockSelection));\r
+\r
+                                       /*******************/\r
+                                       /* Round the value */\r
+                                       /*******************/\r
+\r
+                                       if ((double) ((double) (ul_LowTiming * 60.0) * (250000.0 * (double) b_ClockSelection)) >= ((double) ((double) ul_LowTimerValue + 0.5)))\r
+                                          {\r
+                                          ul_LowTimerValue = ul_LowTimerValue + 1;\r
+                                          }\r
+\r
+                                       /*****************************/\r
+                                       /* Calculate the real timing */\r
+                                       /*****************************/\r
+\r
+                                       ul_RealLowTiming = (ULONG) (ul_LowTimerValue / (250000.0 * (double) b_ClockSelection)) / 60;\r
+                                       d_RealLowTiming    = ((double) ul_LowTimerValue / (250000.0 * (double) b_ClockSelection)) / 60.0;\r
+\r
+                                       if ((double) (((double) ul_LowTimerValue / (250000.0 * (double) b_ClockSelection)) / 60.0) >= (double) ((double) ul_RealLowTiming + 0.5))\r
+                                          {\r
+                                          ul_RealLowTiming = ul_RealLowTiming + 1;\r
+                                          }\r
+\r
+                                       ul_LowTiming     = ul_LowTiming - 1;\r
+                                       ul_LowTimerValue = ul_LowTimerValue - 2;\r
+\r
+                                       if (b_ClockSelection != APCI1710_40MHZ)\r
+                                          {\r
+                                          ul_LowTimerValue = (ULONG) ((double) (ul_LowTimerValue) * 1.007752288);\r
+                                          }\r
+                                    \r
+                                    break;\r
+                               }\r
+\r
+                            /*************************************/\r
+                            /* Calculate the high division fator */\r
+                            /*************************************/\r
+\r
+                            switch (b_TimingUnit)\r
+                               {\r
+                               /******/\r
+                               /* ns */\r
+                               /******/\r
+\r
+                               case 0:\r
+                                   \r
+                                       /******************/\r
+                                       /* Timer 0 factor */\r
+                                       /******************/\r
+\r
+                                       ul_HighTimerValue = (ULONG) (ul_HighTiming * (0.00025 * b_ClockSelection));\r
+\r
+                                       /*******************/\r
+                                       /* Round the value */\r
+                                       /*******************/\r
+\r
+                                       if ((double) ((double) ul_HighTiming * (0.00025 * (double) b_ClockSelection)) >= ((double) ((double) ul_HighTimerValue + 0.5)))\r
+                                          {\r
+                                          ul_HighTimerValue = ul_HighTimerValue + 1;\r
+                                          }\r
+\r
+                                       /*****************************/\r
+                                       /* Calculate the real timing */\r
+                                       /*****************************/\r
+\r
+                                       ul_RealHighTiming = (ULONG) (ul_HighTimerValue / (0.00025 * (double) b_ClockSelection));\r
+                                       d_RealHighTiming    = (double) ul_HighTimerValue / (0.00025 * (double) b_ClockSelection);\r
+\r
+                                       if ((double) ((double) ul_HighTimerValue / (0.00025 * (double) b_ClockSelection)) >= (double) ((double) ul_RealHighTiming + 0.5))\r
+                                          {\r
+                                          ul_RealHighTiming = ul_RealHighTiming + 1;\r
+                                          }\r
+\r
+                                       ul_HighTiming     = ul_HighTiming - 1;\r
+                                       ul_HighTimerValue = ul_HighTimerValue - 2;\r
+\r
+                                       if (b_ClockSelection != APCI1710_40MHZ)\r
+                                          {\r
+                                          ul_HighTimerValue = (ULONG) ((double) (ul_HighTimerValue) * 1.007752288);\r
+                                          }\r
+                                    \r
+\r
+                                    break;\r
+\r
+                               /******/\r
+                               /* æs */\r
+                               /******/\r
+\r
+                               case 1:\r
+                                    \r
+                                       /******************/\r
+                                       /* Timer 0 factor */\r
+                                       /******************/\r
+\r
+                                       ul_HighTimerValue = (ULONG) (ul_HighTiming * (0.25 * b_ClockSelection));\r
+\r
+                                       /*******************/\r
+                                       /* Round the value */\r
+                                       /*******************/\r
+\r
+                                       if ((double) ((double) ul_HighTiming * (0.25 * (double) b_ClockSelection)) >= ((double) ((double) ul_HighTimerValue + 0.5)))\r
+                                          {\r
+                                          ul_HighTimerValue = ul_HighTimerValue + 1;\r
+                                          }\r
+\r
+                                       /*****************************/\r
+                                       /* Calculate the real timing */\r
+                                       /*****************************/\r
+\r
+                                       ul_RealHighTiming = (ULONG) (ul_HighTimerValue / (0.25 * (double) b_ClockSelection));\r
+                                       d_RealHighTiming    = (double) ul_HighTimerValue / ((double) 0.25 * (double) b_ClockSelection);\r
+\r
+                                       if ((double) ((double) ul_HighTimerValue / (0.25 * (double) b_ClockSelection)) >= (double) ((double) ul_RealHighTiming + 0.5))\r
+                                          {\r
+                                          ul_RealHighTiming = ul_RealHighTiming + 1;\r
+                                          }\r
+\r
+                                       ul_HighTiming     = ul_HighTiming - 1;\r
+                                       ul_HighTimerValue = ul_HighTimerValue - 2;\r
+\r
+                                       if (b_ClockSelection != APCI1710_40MHZ)\r
+                                          {\r
+                                          ul_HighTimerValue = (ULONG) ((double) (ul_HighTimerValue) * 1.007752288);\r
+                                          }\r
+                                   \r
+                                    break;\r
+\r
+                               /******/\r
+                               /* ms */\r
+                               /******/\r
+\r
+                               case 2:\r
+                                    \r
+                                       /******************/\r
+                                       /* Timer 0 factor */\r
+                                       /******************/\r
+\r
+                                       ul_HighTimerValue = ul_HighTiming * (250.0 * b_ClockSelection);\r
+\r
+                                       /*******************/\r
+                                       /* Round the value */\r
+                                       /*******************/\r
+\r
+                                       if ((double) ((double) ul_HighTiming * (250.0 * (double) b_ClockSelection)) >= ((double) ((double) ul_HighTimerValue + 0.5)))\r
+                                          {\r
+                                          ul_HighTimerValue = ul_HighTimerValue + 1;\r
+                                          }\r
+\r
+                                       /*****************************/\r
+                                       /* Calculate the real timing */\r
+                                       /*****************************/\r
+\r
+                                       ul_RealHighTiming = (ULONG) (ul_HighTimerValue / (250.0 * (double) b_ClockSelection));\r
+                                       d_RealHighTiming    = (double) ul_HighTimerValue / (250.0 * (double) b_ClockSelection);\r
+\r
+                                       if ((double) ((double) ul_HighTimerValue / (250.0 * (double) b_ClockSelection)) >= (double) ((double) ul_RealHighTiming + 0.5))\r
+                                          {\r
+                                          ul_RealHighTiming = ul_RealHighTiming + 1;\r
+                                          }\r
+\r
+                                       ul_HighTiming     = ul_HighTiming - 1;\r
+                                       ul_HighTimerValue = ul_HighTimerValue - 2;\r
+\r
+                                       if (b_ClockSelection != APCI1710_40MHZ)\r
+                                          {\r
+                                          ul_HighTimerValue = (ULONG) ((double) (ul_HighTimerValue) * 1.007752288);\r
+                                          }\r
+                                  \r
+                                    break;\r
+\r
+                               /*****/\r
+                               /* s */\r
+                               /*****/\r
+\r
+                               case 3:\r
+                                   \r
+                                       /******************/\r
+                                       /* Timer 0 factor */\r
+                                       /******************/\r
+\r
+                                       ul_HighTimerValue = (ULONG) (ul_HighTiming * (250000.0 * b_ClockSelection));\r
+\r
+                                       /*******************/\r
+                                       /* Round the value */\r
+                                       /*******************/\r
+\r
+                                       if ((double) ((double) ul_HighTiming * (250000.0 * (double) b_ClockSelection)) >= ((double) ((double) ul_HighTimerValue + 0.5)))\r
+                                          {\r
+                                          ul_HighTimerValue = ul_HighTimerValue + 1;\r
+                                          }\r
+\r
+                                       /*****************************/\r
+                                       /* Calculate the real timing */\r
+                                       /*****************************/\r
+\r
+                                       ul_RealHighTiming = (ULONG) (ul_HighTimerValue / (250000.0 * (double) b_ClockSelection));\r
+                                       d_RealHighTiming    = (double) ul_HighTimerValue / (250000.0 * (double) b_ClockSelection);\r
+\r
+                                       if ((double) ((double) ul_HighTimerValue / (250000.0 * (double) b_ClockSelection)) >= (double) ((double) ul_RealHighTiming + 0.5))\r
+                                          {\r
+                                          ul_RealHighTiming = ul_RealHighTiming + 1;\r
+                                          }\r
+\r
+                                       ul_HighTiming     = ul_HighTiming - 1;\r
+                                       ul_HighTimerValue = ul_HighTimerValue - 2;\r
+\r
+                                       if (b_ClockSelection != APCI1710_40MHZ)\r
+                                          {\r
+                                          ul_HighTimerValue = (ULONG) ((double) (ul_HighTimerValue) * 1.007752288);\r
+                                          }\r
+                                   \r
+                                    break;\r
+\r
+                               /******/\r
+                               /* mn */\r
+                               /******/\r
+\r
+                               case 4:\r
+                                   \r
+                                       /******************/\r
+                                       /* Timer 0 factor */\r
+                                       /******************/\r
+\r
+                                       ul_HighTimerValue = (ULONG) ((ul_HighTiming * 60) * (250000.0 * b_ClockSelection));\r
+\r
+                                       /*******************/\r
+                                       /* Round the value */\r
+                                       /*******************/\r
+\r
+                                       if ((double) ((double) (ul_HighTiming * 60.0) * (250000.0 * (double) b_ClockSelection)) >= ((double) ((double) ul_HighTimerValue + 0.5)))\r
+                                          {\r
+                                          ul_HighTimerValue = ul_HighTimerValue + 1;\r
+                                          }\r
+\r
+                                       /*****************************/\r
+                                       /* Calculate the real timing */\r
+                                       /*****************************/\r
+\r
+                                       ul_RealHighTiming = (ULONG) (ul_HighTimerValue / (250000.0 * (double) b_ClockSelection)) / 60;\r
+                                       d_RealHighTiming    = ((double) ul_HighTimerValue / (250000.0 * (double) b_ClockSelection)) / 60.0;\r
+\r
+                                       if ((double) (((double) ul_HighTimerValue / (250000.0 * (double) b_ClockSelection)) / 60.0) >= (double) ((double) ul_RealHighTiming + 0.5))\r
+                                          {\r
+                                          ul_RealHighTiming = ul_RealHighTiming + 1;\r
+                                          }\r
+\r
+                                       ul_HighTiming     = ul_HighTiming - 1;\r
+                                       ul_HighTimerValue = ul_HighTimerValue - 2;\r
+\r
+                                       if (b_ClockSelection != APCI1710_40MHZ)\r
+                                          {\r
+                                          ul_HighTimerValue = (ULONG) ((double) (ul_HighTimerValue) * 1.007752288);\r
+                                          }\r
+                                    \r
+                                    break;\r
+                               }\r
+                               \r
+                            fpu_end ();\r
+                            \r
+                            /************************/\r
+                            /* Save the timing unit */\r
+                            /************************/\r
+\r
+                            devpriv->\r
+                            s_ModuleInfo [b_ModulNbr].\r
+                            s_PWMModuleInfo.\r
+                            s_PWMInfo [b_PWM].\r
+                            b_TimingUnit = b_TimingUnit;\r
+\r
+                            /****************************/\r
+                            /* Save the low base timing */\r
+                            /****************************/\r
+\r
+                            devpriv->\r
+                            s_ModuleInfo [b_ModulNbr].\r
+                            s_PWMModuleInfo.\r
+                            s_PWMInfo [b_PWM].\r
+                            d_LowTiming = d_RealLowTiming;\r
+\r
+                            devpriv->\r
+                            s_ModuleInfo [b_ModulNbr].\r
+                            s_PWMModuleInfo.\r
+                            s_PWMInfo [b_PWM].\r
+                            ul_RealLowTiming = ul_RealLowTiming;\r
+\r
+                            /****************************/\r
+                            /* Save the high base timing */\r
+                            /****************************/\r
+\r
+                            devpriv->\r
+                            s_ModuleInfo [b_ModulNbr].\r
+                            s_PWMModuleInfo.\r
+                            s_PWMInfo [b_PWM].\r
+                            d_HighTiming = d_RealHighTiming;\r
+\r
+                            devpriv->\r
+                            s_ModuleInfo [b_ModulNbr].\r
+                            s_PWMModuleInfo.\r
+                            s_PWMInfo [b_PWM].\r
+                            ul_RealHighTiming = ul_RealHighTiming;\r
+\r
+                            /************************/\r
+                            /* Write the low timing */\r
+                            /************************/\r
+\r
+                                outl(ul_LowTimerValue,devpriv->s_BoardInfos.\r
+                                    ui_Address + 0 + (20 * b_PWM) + (64 * b_ModulNbr));\r
+\r
+                            /*************************/\r
+                            /* Write the high timing */\r
+                            /*************************/\r
+\r
+                                outl(ul_HighTimerValue,devpriv->s_BoardInfos.\r
+                                    ui_Address + 4 + (20 * b_PWM) + (64 * b_ModulNbr));\r
+\r
+                            /***************************/\r
+                            /* Set the clock selection */\r
+                            /***************************/\r
+\r
+                                dw_Command=inl(devpriv->s_BoardInfos.\r
+                                   ui_Address + 8 + (20 * b_PWM) + (64 * b_ModulNbr));\r
+\r
+                            dw_Command = dw_Command & 0x7F;\r
+\r
+                            if (b_ClockSelection == APCI1710_40MHZ)\r
+                               {\r
+                               dw_Command = dw_Command | 0x80;\r
+                               }\r
+\r
+                            /***************************/\r
+                            /* Set the clock selection */\r
+                            /***************************/\r
+\r
+                                outl(dw_Command,devpriv->s_BoardInfos.\r
+                                    ui_Address + 8 + (20 * b_PWM) + (64 * b_ModulNbr));\r
+                            }\r
+                         else\r
+                            {\r
+                            /***************************************/\r
+                            /* High base timing selection is wrong */\r
+                            /***************************************/\r
+                         DPRINTK("High base timing selection is wrong\n");\r
+                            i_ReturnValue = -8;\r
+                            }\r
+                         }\r
+                      else\r
+                         {\r
+                         /**************************************/\r
+                         /* Low base timing selection is wrong */\r
+                         /**************************************/\r
+                         DPRINTK("Low base timing selection is wrong\n");\r
+                         i_ReturnValue = -7;\r
+                         }\r
+                      } // if ((b_TimingUnit >= 0) && (b_TimingUnit <= 4))\r
+                   else\r
+                      {\r
+                      /**********************************/\r
+                      /* Timing unit selection is wrong */\r
+                      /**********************************/\r
+                          DPRINTK("Timing unit selection is wrong\n"); \r
+                      i_ReturnValue = -6;\r
+                      } // if ((b_TimingUnit >= 0) && (b_TimingUnit <= 4))\r
+                   } // if (dw_Status & 0x10)\r
+                else\r
+                   {\r
+                   /***********************/\r
+                   /* PWM not initialised */\r
+                   /***********************/\r
+                       DPRINTK("PWM not initialised\n");       \r
+                   i_ReturnValue = -5;\r
+                   } // if (dw_Status & 0x10)\r
+                } // if (b_PWM >= 0 && b_PWM <= 1)\r
+             else\r
+                {\r
+                /******************************/\r
+                /* Tor PWM selection is wrong */\r
+                /******************************/\r
+                DPRINTK("Tor PWM selection is wrong\n");\r
+                i_ReturnValue = -4;\r
+                } // if (b_PWM >= 0 && b_PWM <= 1)\r
+             }\r
+          else\r
+             {\r
+             /**********************************/\r
+             /* The module is not a PWM module */\r
+             /**********************************/\r
+             DPRINTK("The module is not a PWM module\n");      \r
+             i_ReturnValue = -3;\r
+             }\r
+          }\r
+       else\r
+          {\r
+          /***********************/\r
+          /* Module number error */\r
+          /***********************/\r
+          DPRINTK("Module number error\n");    \r
+          i_ReturnValue = -2;\r
+          }\r
+\r
+       return (i_ReturnValue);\r
+       }\r
 \r
-#include "APCI1710_Pwm.h"\r
 \r
-
-
-/*
-+----------------------------------------------------------------------------+
-| Function Name     :INT i_APCI1710_InsnConfigPWM(comedi_device *dev,
-comedi_subdevice *s,comedi_insn *insn,lsampl_t *data)                        |
-+----------------------------------------------------------------------------+
-| Task              : Pwm Init and Get Pwm Initialisation                    |
-+----------------------------------------------------------------------------+
-| Input Parameters  : 
-+----------------------------------------------------------------------------+
-| Output Parameters : -                                                      |
-+----------------------------------------------------------------------------+
-| Return Value      : 
-+----------------------------------------------------------------------------+
-*/
-
-INT    i_APCI1710_InsnConfigPWM(comedi_device *dev,comedi_subdevice *s,
-comedi_insn *insn,lsampl_t *data)
-{
-       BYTE b_ConfigType;
-       INT i_ReturnValue=0;
-        b_ConfigType=CR_CHAN(insn->chanspec);
-
-       switch(b_ConfigType)
-       {
-       case APCI1710_PWM_INIT :
-               i_ReturnValue=i_APCI1710_InitPWM      (dev,
-                                (BYTE)CR_AREF(insn->chanspec), //  b_ModulNbr
-                                (BYTE) data[0],   //b_PWM
-                                (BYTE) data[1],   // b_ClockSelection
-                                (BYTE) data[2],   // b_TimingUnit
-                                (ULONG)data[3],   //ul_LowTiming
-                                (ULONG)data[4],   //ul_HighTiming
-                                (PULONG)&data[0], //pul_RealLowTiming
-                                (PULONG)&data[1] //pul_RealHighTiming
-                          );
-               break;
-
-       case APCI1710_PWM_GETINITDATA :
-               i_ReturnValue=i_APCI1710_GetPWMInitialisation (dev,
-                                        (BYTE)CR_AREF(insn->chanspec), // b_ModulNbr
-                                        (BYTE) data[0],   //b_PWM
-                                        (PBYTE)&data[0],    //pb_TimingUnit
-                                        (PULONG)&data[1], //pul_LowTiming
-                                        (PULONG)&data[2], //pul_HighTiming
-                                        (PBYTE) &data[3],  // pb_StartLevel
-                                        (PBYTE) &data[4], // pb_StopMode
-                                        (PBYTE) &data[5], // pb_StopLevel
-                                        (PBYTE) &data[6], // pb_ExternGate
-                                        (PBYTE) &data[7], // pb_InterruptEnable
-                                        (PBYTE) &data[8]  // pb_Enable
-                              );
-               break;
-
-       default:
-               printk(" Config Parameter Wrong\n");
-       }
-
-       if(i_ReturnValue>=0) i_ReturnValue =insn->n;
-       return (i_ReturnValue);
-}
-
-
-
-/*
-+----------------------------------------------------------------------------+
-| Function Name     : _INT_ i_APCI1710_InitPWM                               |
-|                                       (BYTE_     b_BoardHandle,            |
-|                                        BYTE_     b_ModulNbr,               |
-|                                        BYTE_     b_PWM,                    |
-|                                        BYTE_     b_ClockSelection,         |
-|                                        BYTE_     b_TimingUnit,             |
-|                                        ULONG_   ul_LowTiming,              |
-|                                        ULONG_   ul_HighTiming,             |
-|                                        PULONG_ pul_RealLowTiming,          |
-|                                        PULONG_ pul_RealHighTiming)         |
-+----------------------------------------------------------------------------+
-| Task              : Configure the selected PWM (b_PWM) from selected module|
-|                     (b_ModulNbr). The ul_LowTiming, ul_HighTiming and      |
-|                     ul_TimingUnit determine the low/high timing base for   |
-|                     the period. pul_RealLowTiming, pul_RealHighTiming      |
-|                     return the real timing value.                          |
-|                     You must calling this function be for you call any     |
-|                     other function witch access of the PWM.                |
-+----------------------------------------------------------------------------+
-| Input Parameters  : BYTE_     b_BoardHandle    : Handle of board APCI-1710 |
-|                     BYTE_     b_ModulNbr       : Module number to configure|
-|                                                  (0 to 3)                  |
-|                     BYTE_     b_PWM            : Selected PWM (0 or 1).    |
-|                     BYTE_     b_ClockSelection : Selection from PCI bus    |
-|                                                  clock                     |
-|                                                   - APCI1710_30MHZ :       |
-|                                                     The PC have a 30 MHz   |
-|                                                     PCI bus clock          |
-|                                                   - APCI1710_33MHZ :       |
-|                                                     The PC have a 33 MHz   |
-|                                                     PCI bus clock          |
-|                                                   - APCI1710_40MHZ         |
-|                                                     The APCI-1710 have a   |
-|                                                     integrated 40Mhz       |
-|                                                     quartz.                |
-|                     BYTE_     b_TimingUnit     : Base timing Unit (0 to 4) |
-|                                                       0 : ns               |
-|                                                       1 : æs               |
-|                                                       2 : ms               |
-|                                                       3 : s                |
-|                                                       4 : mn               |
-|                     ULONG_    ul_LowTiming     : Low base timing value.    |
-|                     ULONG_    ul_HighTiming    : High base timing value.   |
-+----------------------------------------------------------------------------+
-| Output Parameters : PULONG_  pul_RealLowTiming  : Real low base timing     |
-|                                                   value.                   |
-|                     PULONG_  pul_RealHighTiming : Real high base timing    |
-|                                                   value.                   |
-+----------------------------------------------------------------------------+
-| Return Value      : 0: No error                                            |
-|                    -1: The handle parameter of the board is wrong          |
-|                    -2: Module selection wrong                              |
-|                    -3: The module is not a PWM module                      |
-|                    -4: PWM selection is wrong                              |
-|                    -5: The selected input clock is wrong                   |
-|                    -6: Timing Unit selection is wrong                      |
-|                    -7: Low base timing selection is wrong                  |
-|                    -8: High base timing selection is wrong                 |
-|                    -9: You can not used the 40MHz clock selection with     |
-|                        this board                                          |
-+----------------------------------------------------------------------------+
-*/
-
-INT   i_APCI1710_InitPWM      (comedi_device *dev,
-                                BYTE     b_ModulNbr,
-                                BYTE    b_PWM,
-                                BYTE     b_ClockSelection,
-                                BYTE     b_TimingUnit,
-                                ULONG   ul_LowTiming,
-                                ULONG   ul_HighTiming,
-                                PULONG pul_RealLowTiming,
-                                PULONG pul_RealHighTiming)
-       {
-       INT    i_ReturnValue = 0;
-       ULONG ul_LowTimerValue;
-       ULONG ul_HighTimerValue;
-       DWORD dw_Command;
-       double d_RealLowTiming;
-       double d_RealHighTiming;
-       
-
-
-       /**************************/
-       /* Test the module number */
-       /**************************/
-
-       if (b_ModulNbr < 4)
-          {
-          /***************/
-          /* Test if PWM */
-          /***************/
-
-          if ((devpriv->
-               s_BoardInfos.
-               dw_MolduleConfiguration [b_ModulNbr] & 0xFFFF0000UL) == APCI1710_PWM)
-             {
-             /**************************/
-             /* Test the PWM selection */
-             /**************************/
-
-             if (b_PWM >= 0 && b_PWM <= 1)
-                {
-                /******************/
-                /* Test the clock */
-                /******************/
-
-                if ((b_ClockSelection == APCI1710_30MHZ) ||
-                    (b_ClockSelection == APCI1710_33MHZ) ||
-                    (b_ClockSelection == APCI1710_40MHZ))
-                   {
-                   /************************/
-                   /* Test the timing unit */
-                   /************************/
-
-                   if ((b_TimingUnit >= 0) && (b_TimingUnit <= 4))
-                      {
-                      /*********************************/
-                      /* Test the low timing selection */
-                      /*********************************/
-
-                      if (((b_ClockSelection == APCI1710_30MHZ) && (b_TimingUnit == 0) && (ul_LowTiming >= 266) && (ul_LowTiming <= 0xFFFFFFFFUL)) ||
-                          ((b_ClockSelection == APCI1710_30MHZ) && (b_TimingUnit == 1) && (ul_LowTiming >= 1)   && (ul_LowTiming <= 571230650UL))  ||
-                          ((b_ClockSelection == APCI1710_30MHZ) && (b_TimingUnit == 2) && (ul_LowTiming >= 1)   && (ul_LowTiming <= 571230UL))     ||
-                          ((b_ClockSelection == APCI1710_30MHZ) && (b_TimingUnit == 3) && (ul_LowTiming >= 1)   && (ul_LowTiming <= 571UL))        ||
-                          ((b_ClockSelection == APCI1710_30MHZ) && (b_TimingUnit == 4) && (ul_LowTiming >= 1)   && (ul_LowTiming <= 9UL))          ||
-                          ((b_ClockSelection == APCI1710_33MHZ) && (b_TimingUnit == 0) && (ul_LowTiming >= 242) && (ul_LowTiming <= 0xFFFFFFFFUL)) ||
-                          ((b_ClockSelection == APCI1710_33MHZ) && (b_TimingUnit == 1) && (ul_LowTiming >= 1)   && (ul_LowTiming <= 519691043UL))  ||
-                          ((b_ClockSelection == APCI1710_33MHZ) && (b_TimingUnit == 2) && (ul_LowTiming >= 1)   && (ul_LowTiming <= 519691UL))     ||
-                          ((b_ClockSelection == APCI1710_33MHZ) && (b_TimingUnit == 3) && (ul_LowTiming >= 1)   && (ul_LowTiming <= 520UL))        ||
-                          ((b_ClockSelection == APCI1710_33MHZ) && (b_TimingUnit == 4) && (ul_LowTiming >= 1)   && (ul_LowTiming <= 8UL))          ||
-                          ((b_ClockSelection == APCI1710_40MHZ) && (b_TimingUnit == 0) && (ul_LowTiming >= 200) && (ul_LowTiming <= 0xFFFFFFFFUL)) ||
-                          ((b_ClockSelection == APCI1710_40MHZ) && (b_TimingUnit == 1) && (ul_LowTiming >= 1)   && (ul_LowTiming <= 429496729UL))  ||
-                          ((b_ClockSelection == APCI1710_40MHZ) && (b_TimingUnit == 2) && (ul_LowTiming >= 1)   && (ul_LowTiming <= 429496UL))     ||
-                          ((b_ClockSelection == APCI1710_40MHZ) && (b_TimingUnit == 3) && (ul_LowTiming >= 1)   && (ul_LowTiming <= 429UL))        ||
-                          ((b_ClockSelection == APCI1710_40MHZ) && (b_TimingUnit == 4) && (ul_LowTiming >= 1)   && (ul_LowTiming <= 7UL)))
-                         {
-                         /**********************************/
-                         /* Test the High timing selection */
-                         /**********************************/
-
-                         if (((b_ClockSelection == APCI1710_30MHZ) && (b_TimingUnit == 0) && (ul_HighTiming >= 266) && (ul_HighTiming <= 0xFFFFFFFFUL)) ||
-                             ((b_ClockSelection == APCI1710_30MHZ) && (b_TimingUnit == 1) && (ul_HighTiming >= 1)   && (ul_HighTiming <= 571230650UL))  ||
-                             ((b_ClockSelection == APCI1710_30MHZ) && (b_TimingUnit == 2) && (ul_HighTiming >= 1)   && (ul_HighTiming <= 571230UL))     ||
-                             ((b_ClockSelection == APCI1710_30MHZ) && (b_TimingUnit == 3) && (ul_HighTiming >= 1)   && (ul_HighTiming <= 571UL))        ||
-                             ((b_ClockSelection == APCI1710_30MHZ) && (b_TimingUnit == 4) && (ul_HighTiming >= 1)   && (ul_HighTiming <= 9UL))          ||
-                             ((b_ClockSelection == APCI1710_33MHZ) && (b_TimingUnit == 0) && (ul_HighTiming >= 242) && (ul_HighTiming <= 0xFFFFFFFFUL)) ||
-                             ((b_ClockSelection == APCI1710_33MHZ) && (b_TimingUnit == 1) && (ul_HighTiming >= 1)   && (ul_HighTiming <= 519691043UL))  ||
-                             ((b_ClockSelection == APCI1710_33MHZ) && (b_TimingUnit == 2) && (ul_HighTiming >= 1)   && (ul_HighTiming <= 519691UL))     ||
-                             ((b_ClockSelection == APCI1710_33MHZ) && (b_TimingUnit == 3) && (ul_HighTiming >= 1)   && (ul_HighTiming <= 520UL))        ||
-                             ((b_ClockSelection == APCI1710_33MHZ) && (b_TimingUnit == 4) && (ul_HighTiming >= 1)   && (ul_HighTiming <= 8UL))          ||
-                             ((b_ClockSelection == APCI1710_40MHZ) && (b_TimingUnit == 0) && (ul_HighTiming >= 200) && (ul_HighTiming <= 0xFFFFFFFFUL)) ||
-                             ((b_ClockSelection == APCI1710_40MHZ) && (b_TimingUnit == 1) && (ul_HighTiming >= 1)   && (ul_HighTiming <= 429496729UL))  ||
-                             ((b_ClockSelection == APCI1710_40MHZ) && (b_TimingUnit == 2) && (ul_HighTiming >= 1)   && (ul_HighTiming <= 429496UL))     ||
-                             ((b_ClockSelection == APCI1710_40MHZ) && (b_TimingUnit == 3) && (ul_HighTiming >= 1)   && (ul_HighTiming <= 429UL))        ||
-                             ((b_ClockSelection == APCI1710_40MHZ) && (b_TimingUnit == 4) && (ul_HighTiming >= 1)   && (ul_HighTiming <= 7UL)))
-                            {
-                            /**************************/
-                            /* Test the board version */
-                            /**************************/
-
-                            if ((b_ClockSelection == APCI1710_40MHZ) && (devpriv->
-                                                                         s_BoardInfos.
-                                                                         b_BoardVersion > 0) ||
-                                (b_ClockSelection != APCI1710_40MHZ))
-                               {
-
-                               /************************************/
-                               /* Calculate the low division fator */
-                               /************************************/
-
-                               switch (b_TimingUnit)
-                                  {
-                                  /******/
-                                  /* ns */
-                                  /******/
-
-                                  case 0:
-                                       
-                                          /******************/
-                                          /* Timer 0 factor */
-                                          /******************/
-
-                                          ul_LowTimerValue = (ULONG) (ul_LowTiming * (0.00025 * b_ClockSelection));
-
-                                          /*******************/
-                                          /* Round the value */
-                                          /*******************/
-
-                                          if ((double) ((double) ul_LowTiming * (0.00025 * (double) b_ClockSelection)) >= ((double) ((double) ul_LowTimerValue + 0.5)))
-                                             {
-                                             ul_LowTimerValue = ul_LowTimerValue + 1;
-                                             }
-
-                                          /*****************************/
-                                          /* Calculate the real timing */
-                                          /*****************************/
-
-                                          *pul_RealLowTiming = (ULONG) (ul_LowTimerValue / (0.00025 * (double) b_ClockSelection));
-                                          d_RealLowTiming = (double) ul_LowTimerValue / (0.00025 * (double) b_ClockSelection);
-
-                                          if ((double) ((double) ul_LowTimerValue / (0.00025 * (double) b_ClockSelection)) >= (double) ((double) *pul_RealLowTiming + 0.5))
-                                             {
-                                             *pul_RealLowTiming = *pul_RealLowTiming + 1;
-                                             }
-
-                                          ul_LowTiming     = ul_LowTiming - 1;
-                                          ul_LowTimerValue = ul_LowTimerValue - 2;
-
-                                          if (b_ClockSelection != APCI1710_40MHZ)
-                                             {
-                                             ul_LowTimerValue = (ULONG) ((double) (ul_LowTimerValue) * 1.007752288);
-                                             }
-                                       
-
-                                       break;
-
-                                  /******/
-                                  /* æs */
-                                  /******/
-
-                                  case 1:
-                                       
-                                          /******************/
-                                          /* Timer 0 factor */
-                                          /******************/
-
-                                          ul_LowTimerValue = (ULONG) (ul_LowTiming * (0.25 * b_ClockSelection));
-
-                                          /*******************/
-                                          /* Round the value */
-                                          /*******************/
-
-                                          if ((double) ((double) ul_LowTiming * (0.25 * (double) b_ClockSelection)) >= ((double) ((double) ul_LowTimerValue + 0.5)))
-                                             {
-                                             ul_LowTimerValue = ul_LowTimerValue + 1;
-                                             }
-
-                                          /*****************************/
-                                          /* Calculate the real timing */
-                                          /*****************************/
-
-                                          *pul_RealLowTiming = (ULONG) (ul_LowTimerValue / (0.25 * (double) b_ClockSelection));
-                                          d_RealLowTiming    = (double) ul_LowTimerValue / ((double) 0.25 * (double) b_ClockSelection);
-
-                                          if ((double) ((double) ul_LowTimerValue / (0.25 * (double) b_ClockSelection)) >= (double) ((double) *pul_RealLowTiming + 0.5))
-                                             {
-                                             *pul_RealLowTiming = *pul_RealLowTiming + 1;
-                                             }
-
-                                          ul_LowTiming     = ul_LowTiming - 1;
-                                          ul_LowTimerValue = ul_LowTimerValue - 2;
-
-                                          if (b_ClockSelection != APCI1710_40MHZ)
-                                             {
-                                             ul_LowTimerValue = (ULONG) ((double) (ul_LowTimerValue) * 1.007752288);
-                                             }
-                                       
-
-                                       break;
-
-                                  /******/
-                                  /* ms */
-                                  /******/
-
-                                  case 2:
-                                       
-                                          /******************/
-                                          /* Timer 0 factor */
-                                          /******************/
-
-                                          ul_LowTimerValue = ul_LowTiming * (250.0 * b_ClockSelection);
-
-                                          /*******************/
-                                          /* Round the value */
-                                          /*******************/
-
-                                          if ((double) ((double) ul_LowTiming * (250.0 * (double) b_ClockSelection)) >= ((double) ((double) ul_LowTimerValue + 0.5)))
-                                             {
-                                             ul_LowTimerValue = ul_LowTimerValue + 1;
-                                             }
-
-                                          /*****************************/
-                                          /* Calculate the real timing */
-                                          /*****************************/
-
-                                          *pul_RealLowTiming = (ULONG) (ul_LowTimerValue / (250.0 * (double) b_ClockSelection));
-                                          d_RealLowTiming    = (double) ul_LowTimerValue / (250.0 * (double) b_ClockSelection);
-
-                                          if ((double) ((double) ul_LowTimerValue / (250.0 * (double) b_ClockSelection)) >= (double) ((double) *pul_RealLowTiming + 0.5))
-                                             {
-                                             *pul_RealLowTiming = *pul_RealLowTiming + 1;
-                                             }
-
-                                          ul_LowTiming     = ul_LowTiming - 1;
-                                          ul_LowTimerValue = ul_LowTimerValue - 2;
-
-                                          if (b_ClockSelection != APCI1710_40MHZ)
-                                             {
-                                             ul_LowTimerValue = (ULONG) ((double) (ul_LowTimerValue) * 1.007752288);
-                                             }
-                                       
-                                       break;
-
-                                  /*****/
-                                  /* s */
-                                  /*****/
-
-                                  case 3:
-                                          /******************/
-                                          /* Timer 0 factor */
-                                          /******************/
-
-                                          ul_LowTimerValue = (ULONG) (ul_LowTiming * (250000.0 * b_ClockSelection));
-
-                                          /*******************/
-                                          /* Round the value */
-                                          /*******************/
-
-                                          if ((double) ((double) ul_LowTiming * (250000.0 * (double) b_ClockSelection)) >= ((double) ((double) ul_LowTimerValue + 0.5)))
-                                             {
-                                             ul_LowTimerValue = ul_LowTimerValue + 1;
-                                             }
-
-                                          /*****************************/
-                                          /* Calculate the real timing */
-                                          /*****************************/
-
-                                          *pul_RealLowTiming = (ULONG) (ul_LowTimerValue / (250000.0 * (double) b_ClockSelection));
-                                          d_RealLowTiming    = (double) ul_LowTimerValue / (250000.0 * (double) b_ClockSelection);
-
-                                          if ((double) ((double) ul_LowTimerValue / (250000.0 * (double) b_ClockSelection)) >= (double) ((double) *pul_RealLowTiming + 0.5))
-                                             {
-                                             *pul_RealLowTiming = *pul_RealLowTiming + 1;
-                                             }
-
-                                          ul_LowTiming     = ul_LowTiming - 1;
-                                          ul_LowTimerValue = ul_LowTimerValue - 2;
-
-                                          if (b_ClockSelection != APCI1710_40MHZ)
-                                             {
-                                             ul_LowTimerValue = (ULONG) ((double) (ul_LowTimerValue) * 1.007752288);
-                                             }
-                                       
-
-                                       break;
-
-                                  /******/
-                                  /* mn */
-                                  /******/
-
-                                  case 4:
-                                       
-                                          /******************/
-                                          /* Timer 0 factor */
-                                          /******************/
-
-                                          ul_LowTimerValue = (ULONG) ((ul_LowTiming * 60) * (250000.0 * b_ClockSelection));
-
-                                          /*******************/
-                                          /* Round the value */
-                                          /*******************/
-
-                                          if ((double) ((double) (ul_LowTiming * 60.0) * (250000.0 * (double) b_ClockSelection)) >= ((double) ((double) ul_LowTimerValue + 0.5)))
-                                             {
-                                             ul_LowTimerValue = ul_LowTimerValue + 1;
-                                             }
-
-                                          /*****************************/
-                                          /* Calculate the real timing */
-                                          /*****************************/
-
-                                          *pul_RealLowTiming = (ULONG) (ul_LowTimerValue / (250000.0 * (double) b_ClockSelection)) / 60;
-                                          d_RealLowTiming    = ((double) ul_LowTimerValue / (250000.0 * (double) b_ClockSelection)) / 60.0;
-
-                                          if ((double) (((double) ul_LowTimerValue / (250000.0 * (double) b_ClockSelection)) / 60.0) >= (double) ((double) *pul_RealLowTiming + 0.5))
-                                             {
-                                             *pul_RealLowTiming = *pul_RealLowTiming + 1;
-                                             }
-
-                                          ul_LowTiming     = ul_LowTiming - 1;
-                                          ul_LowTimerValue = ul_LowTimerValue - 2;
-
-                                          if (b_ClockSelection != APCI1710_40MHZ)
-                                             {
-                                             ul_LowTimerValue = (ULONG) ((double) (ul_LowTimerValue) * 1.007752288);
-                                             }
-                                       
-                                       break;
-                                  }
-
-                               /*************************************/
-                               /* Calculate the high division fator */
-                               /*************************************/
-
-                               switch (b_TimingUnit)
-                                  {
-                                  /******/
-                                  /* ns */
-                                  /******/
-
-                                  case 0:
-                                       
-                                          /******************/
-                                          /* Timer 0 factor */
-                                          /******************/
-
-                                          ul_HighTimerValue = (ULONG) (ul_HighTiming * (0.00025 * b_ClockSelection));
-
-                                          /*******************/
-                                          /* Round the value */
-                                          /*******************/
-
-                                          if ((double) ((double) ul_HighTiming * (0.00025 * (double) b_ClockSelection)) >= ((double) ((double) ul_HighTimerValue + 0.5)))
-                                             {
-                                             ul_HighTimerValue = ul_HighTimerValue + 1;
-                                             }
-
-                                          /*****************************/
-                                          /* Calculate the real timing */
-                                          /*****************************/
-
-                                          *pul_RealHighTiming = (ULONG) (ul_HighTimerValue / (0.00025 * (double) b_ClockSelection));
-                                          d_RealHighTiming    = (double) ul_HighTimerValue / (0.00025 * (double) b_ClockSelection);
-
-                                          if ((double) ((double) ul_HighTimerValue / (0.00025 * (double) b_ClockSelection)) >= (double) ((double) *pul_RealHighTiming + 0.5))
-                                             {
-                                             *pul_RealHighTiming = *pul_RealHighTiming + 1;
-                                             }
-
-                                          ul_HighTiming     = ul_HighTiming - 1;
-                                          ul_HighTimerValue = ul_HighTimerValue - 2;
-
-                                          if (b_ClockSelection != APCI1710_40MHZ)
-                                             {
-                                             ul_HighTimerValue = (ULONG) ((double) (ul_HighTimerValue) * 1.007752288);
-                                             }
-                                       
-
-                                       break;
-
-                                  /******/
-                                  /* æs */
-                                  /******/
-
-                                  case 1:
-                                       
-                                          /******************/
-                                          /* Timer 0 factor */
-                                          /******************/
-
-                                          ul_HighTimerValue = (ULONG) (ul_HighTiming * (0.25 * b_ClockSelection));
-
-                                          /*******************/
-                                          /* Round the value */
-                                          /*******************/
-
-                                          if ((double) ((double) ul_HighTiming * (0.25 * (double) b_ClockSelection)) >= ((double) ((double) ul_HighTimerValue + 0.5)))
-                                             {
-                                             ul_HighTimerValue = ul_HighTimerValue + 1;
-                                             }
-
-                                          /*****************************/
-                                          /* Calculate the real timing */
-                                          /*****************************/
-
-                                          *pul_RealHighTiming = (ULONG) (ul_HighTimerValue / (0.25 * (double) b_ClockSelection));
-                                          d_RealHighTiming    = (double) ul_HighTimerValue / ((double) 0.25 * (double) b_ClockSelection);
-
-                                          if ((double) ((double) ul_HighTimerValue / (0.25 * (double) b_ClockSelection)) >= (double) ((double) *pul_RealHighTiming + 0.5))
-                                             {
-                                             *pul_RealHighTiming = *pul_RealHighTiming + 1;
-                                             }
-
-                                          ul_HighTiming     = ul_HighTiming - 1;
-                                          ul_HighTimerValue = ul_HighTimerValue - 2;
-
-                                          if (b_ClockSelection != APCI1710_40MHZ)
-                                             {
-                                             ul_HighTimerValue = (ULONG) ((double) (ul_HighTimerValue) * 1.007752288);
-                                             }
-                                       
-
-                                       break;
-
-                                  /******/
-                                  /* ms */
-                                  /******/
-
-                                  case 2:
-                                       
-                                          /******************/
-                                          /* Timer 0 factor */
-                                          /******************/
-
-                                          ul_HighTimerValue = ul_HighTiming * (250.0 * b_ClockSelection);
-
-                                          /*******************/
-                                          /* Round the value */
-                                          /*******************/
-
-                                          if ((double) ((double) ul_HighTiming * (250.0 * (double) b_ClockSelection)) >= ((double) ((double) ul_HighTimerValue + 0.5)))
-                                             {
-                                             ul_HighTimerValue = ul_HighTimerValue + 1;
-                                             }
-
-                                          /*****************************/
-                                          /* Calculate the real timing */
-                                          /*****************************/
-
-                                          *pul_RealHighTiming = (ULONG) (ul_HighTimerValue / (250.0 * (double) b_ClockSelection));
-                                          d_RealHighTiming    = (double) ul_HighTimerValue / (250.0 * (double) b_ClockSelection);
-
-                                          if ((double) ((double) ul_HighTimerValue / (250.0 * (double) b_ClockSelection)) >= (double) ((double) *pul_RealHighTiming + 0.5))
-                                             {
-                                             *pul_RealHighTiming = *pul_RealHighTiming + 1;
-                                             }
-
-                                          ul_HighTiming     = ul_HighTiming - 1;
-                                          ul_HighTimerValue = ul_HighTimerValue - 2;
-
-                                          if (b_ClockSelection != APCI1710_40MHZ)
-                                             {
-                                             ul_HighTimerValue = (ULONG) ((double) (ul_HighTimerValue) * 1.007752288);
-                                             }
-                                       
-
-                                       break;
-
-                                  /*****/
-                                  /* s */
-                                  /*****/
-
-                                  case 3:
-                                       
-                                          /******************/
-                                          /* Timer 0 factor */
-                                          /******************/
-
-                                          ul_HighTimerValue = (ULONG) (ul_HighTiming * (250000.0 * b_ClockSelection));
-
-                                          /*******************/
-                                          /* Round the value */
-                                          /*******************/
-
-                                          if ((double) ((double) ul_HighTiming * (250000.0 * (double) b_ClockSelection)) >= ((double) ((double) ul_HighTimerValue + 0.5)))
-                                             {
-                                             ul_HighTimerValue = ul_HighTimerValue + 1;
-                                             }
-
-                                          /*****************************/
-                                          /* Calculate the real timing */
-                                          /*****************************/
-
-                                          *pul_RealHighTiming = (ULONG) (ul_HighTimerValue / (250000.0 * (double) b_ClockSelection));
-                                          d_RealHighTiming    = (double) ul_HighTimerValue / (250000.0 * (double) b_ClockSelection);
-
-                                          if ((double) ((double) ul_HighTimerValue / (250000.0 * (double) b_ClockSelection)) >= (double) ((double) *pul_RealHighTiming + 0.5))
-                                             {
-                                             *pul_RealHighTiming = *pul_RealHighTiming + 1;
-                                             }
-
-                                          ul_HighTiming     = ul_HighTiming - 1;
-                                          ul_HighTimerValue = ul_HighTimerValue - 2;
-
-                                          if (b_ClockSelection != APCI1710_40MHZ)
-                                             {
-                                             ul_HighTimerValue = (ULONG) ((double) (ul_HighTimerValue) * 1.007752288);
-                                             }
-                                       
-
-                                       break;
-
-                                  /******/
-                                  /* mn */
-                                  /******/
-
-                                  case 4:
-                                       
-                                          /******************/
-                                          /* Timer 0 factor */
-                                          /******************/
-
-                                          ul_HighTimerValue = (ULONG) ((ul_HighTiming * 60) * (250000.0 * b_ClockSelection));
-
-                                          /*******************/
-                                          /* Round the value */
-                                          /*******************/
-
-                                          if ((double) ((double) (ul_HighTiming * 60.0) * (250000.0 * (double) b_ClockSelection)) >= ((double) ((double) ul_HighTimerValue + 0.5)))
-                                             {
-                                             ul_HighTimerValue = ul_HighTimerValue + 1;
-                                             }
-
-                                          /*****************************/
-                                          /* Calculate the real timing */
-                                          /*****************************/
-
-                                          *pul_RealHighTiming = (ULONG) (ul_HighTimerValue / (250000.0 * (double) b_ClockSelection)) / 60;
-                                          d_RealHighTiming    = ((double) ul_HighTimerValue / (250000.0 * (double) b_ClockSelection)) / 60.0;
-
-                                          if ((double) (((double) ul_HighTimerValue / (250000.0 * (double) b_ClockSelection)) / 60.0) >= (double) ((double) *pul_RealHighTiming + 0.5))
-                                             {
-                                             *pul_RealHighTiming = *pul_RealHighTiming + 1;
-                                             }
-
-                                          ul_HighTiming     = ul_HighTiming - 1;
-                                          ul_HighTimerValue = ul_HighTimerValue - 2;
-
-                                          if (b_ClockSelection != APCI1710_40MHZ)
-                                             {
-                                             ul_HighTimerValue = (ULONG) ((double) (ul_HighTimerValue) * 1.007752288);
-                                             }
-                                       
-                                       break;
-                                  }
-
-                               /****************************/
-                               /* Save the clock selection */
-                               /****************************/
-
-                               devpriv->
-                               s_ModuleInfo [b_ModulNbr].
-                               s_PWMModuleInfo.
-                               b_ClockSelection = b_ClockSelection;
-
-                               /************************/
-                               /* Save the timing unit */
-                               /************************/
-
-                               devpriv->
-                               s_ModuleInfo [b_ModulNbr].
-                               s_PWMModuleInfo.
-                               s_PWMInfo [b_PWM].
-                               b_TimingUnit = b_TimingUnit;
-
-                               /****************************/
-                               /* Save the low base timing */
-                               /****************************/
-
-                               devpriv->
-                               s_ModuleInfo [b_ModulNbr].
-                               s_PWMModuleInfo.
-                               s_PWMInfo [b_PWM].
-                               d_LowTiming = d_RealLowTiming;
-
-                               devpriv->
-                               s_ModuleInfo [b_ModulNbr].
-                               s_PWMModuleInfo.
-                               s_PWMInfo [b_PWM].
-                               ul_RealLowTiming = *pul_RealLowTiming;
-
-                               /****************************/
-                               /* Save the high base timing */
-                               /****************************/
-
-                               devpriv->
-                               s_ModuleInfo [b_ModulNbr].
-                               s_PWMModuleInfo.
-                               s_PWMInfo [b_PWM].
-                               d_HighTiming = d_RealHighTiming;
-
-                               devpriv->
-                               s_ModuleInfo [b_ModulNbr].
-                               s_PWMModuleInfo.
-                               s_PWMInfo [b_PWM].
-                               ul_RealHighTiming = *pul_RealHighTiming;
-
-                               /************************/
-                               /* Write the low timing */
-                               /************************/
-
-                         outl(ul_LowTimerValue,devpriv->s_BoardInfos.
-                                       ui_Address + 0 + (20 * b_PWM) + (64 * b_ModulNbr));
-
-                               /*************************/
-                               /* Write the high timing */
-                               /*************************/
-
-                        outl(ul_HighTimerValue,devpriv->s_BoardInfos.
-                                       ui_Address + 4 + (20 * b_PWM) + (64 * b_ModulNbr));
-
-                               /***************************/
-                               /* Set the clock selection */
-                               /***************************/
-
-                         dw_Command=inl(devpriv->s_BoardInfos.
-                                      ui_Address + 8 + (20 * b_PWM) + (64 * b_ModulNbr));
-
-                               dw_Command = dw_Command & 0x7F;
-
-                               if (b_ClockSelection == APCI1710_40MHZ)
-                                  {
-                                  dw_Command = dw_Command | 0x80;
-                                  }
-
-                               /***************************/
-                               /* Set the clock selection */
-                               /***************************/
-
-                                 outl(dw_Command,devpriv->s_BoardInfos.
-                                       ui_Address + 8 + (20 * b_PWM) + (64 * b_ModulNbr));
-
-                               /*************/
-                               /* PWM init. */
-                               /*************/
-                               devpriv->
-                               s_ModuleInfo [b_ModulNbr].
-                               s_PWMModuleInfo.
-                               s_PWMInfo [b_PWM].
-                               b_PWMInit = 1;
-                               }
-                            else
-                               {
-                               /***************************************************/
-                               /* You can not used the 40MHz clock selection with */
-                               /* this board                                      */
-                               /***************************************************/
-                        DPRINTK("You can not used the 40MHz clock selection with this board\n");
-                               i_ReturnValue = -9;
-                               }
-                            }
-                         else
-                            {
-                            /***************************************/
-                            /* High base timing selection is wrong */
-                            /***************************************/
-                                DPRINTK("High base timing selection is wrong\n");
-                            i_ReturnValue = -8;
-                            }
-                         }
-                      else
-                         {
-                         /**************************************/
-                         /* Low base timing selection is wrong */
-                         /**************************************/
-                         DPRINTK("Low base timing selection is wrong\n");
-                         i_ReturnValue = -7;
-                         }
-                      } // if ((b_TimingUnit >= 0) && (b_TimingUnit <= 4))
-                   else
-                      {
-                      /**********************************/
-                      /* Timing unit selection is wrong */
-                      /**********************************/
-                          DPRINTK("Timing unit selection is wrong\n");
-                      i_ReturnValue = -6;
-                      } // if ((b_TimingUnit >= 0) && (b_TimingUnit <= 4))
-                   } // if ((b_ClockSelection == APCI1710_30MHZ) || (b_ClockSelection == APCI1710_33MHZ) || (b_ClockSelection == APCI1710_40MHZ))
-                else
-                   {
-                   /*******************************/
-                   /* The selected clock is wrong */
-                   /*******************************/
-                       DPRINTK("The selected clock is wrong\n"); 
-                   i_ReturnValue = -5;
-                   } // if ((b_ClockSelection == APCI1710_30MHZ) || (b_ClockSelection == APCI1710_33MHZ) || (b_ClockSelection == APCI1710_40MHZ))
-                } // if (b_PWM >= 0 && b_PWM <= 1)
-             else
-                {
-                /******************************/
-                /* Tor PWM selection is wrong */
-                /******************************/
-                DPRINTK("Tor PWM selection is wrong\n");       
-                i_ReturnValue = -4;
-                } // if (b_PWM >= 0 && b_PWM <= 1)
-             }
-          else
-             {
-             /**********************************/
-             /* The module is not a PWM module */
-             /**********************************/
-             DPRINTK("The module is not a PWM module\n");      
-             i_ReturnValue = -3;
-             }
-          }
-       else
-          {
-          /***********************/
-          /* Module number error */
-          /***********************/
-          DPRINTK("Module number error\n");    
-          i_ReturnValue = -2;
-          }
-
-       return (i_ReturnValue);
-       }
-
-
-
-/*
-+----------------------------------------------------------------------------+
-| Function Name     : _INT_ i_APCI1710_GetPWMInitialisation                  |
-|                                       (BYTE_     b_BoardHandle,            |
-|                                        BYTE_     b_ModulNbr,               |
-|                                        BYTE_     b_PWM,                    |
-|                                        PBYTE_   pb_TimingUnit,             |
-|                                        PULONG_ pul_LowTiming,              |
-|                                        PULONG_ pul_HighTiming,             |
-|                                        PBYTE_   pb_StartLevel,             |
-|                                        PBYTE_   pb_StopMode,               |
-|                                        PBYTE_   pb_StopLevel,              |
-|                                        PBYTE_   pb_ExternGate,             |
-|                                        PBYTE_   pb_InterruptEnable,        |
-|                                        PBYTE_   pb_Enable)                 |
-+----------------------------------------------------------------------------+
-| Task              : Return the PWM (b_PWM) initialisation from selected    |
-|                     module (b_ModulNbr). You must calling the              |
-|                     "i_APCI1710_InitPWM" function be for you call this     |
-|                     function.                                              |
-+----------------------------------------------------------------------------+
-| Input Parameters  : BYTE_ b_BoardHandle : Handle of board APCI-1710        |
-|                     BYTE_ b_ModulNbr    : Selected module number (0 to 3)  |
-|                     BYTE_ b_PWM         : Selected PWM (0 or 1)            |
-+----------------------------------------------------------------------------+
-| Output Parameters : PBYTE_  pb_TimingUnit      : Base timing Unit (0 to 4) |
-|                                                       0 : ns               |
-|                                                       1 : æs               |
-|                                                       2 : ms               |
-|                                                       3 : s                |
-|                                                       4 : mn               |
-|                     PULONG_ pul_LowTiming      : Low base timing value.    |
-|                     PULONG_ pul_HighTiming     : High base timing value.   |
-|                     PBYTE_  pb_StartLevel      : Start period level        |
-|                                                  selection                 |
-|                                                       0 : The period start |
-|                                                           with a low level |
-|                                                       1 : The period start |
-|                                                           with a high level|
-|                     PBYTE_  pb_StopMode        : Stop mode selection       |
-|                                                  0 : The PWM is stopped    |
-|                                                      directly after the    |
-|                                                     "i_APCI1710_DisablePWM"|
-|                                                      function and break the|
-|                                                      last period           |
-|                                                  1 : After the             |
-|                                                     "i_APCI1710_DisablePWM"|
-|                                                      function the PWM is   |
-|                                                      stopped at the end    |
-|                                                      from last period cycle|
-|                     PBYTE_  pb_StopLevel        : Stop PWM level selection |
-|                                                    0 : The output signal   |
-|                                                        keep the level after|
-|                                                        the                 |
-|                                                     "i_APCI1710_DisablePWM"|
-|                                                        function            |
-|                                                    1 : The output signal is|
-|                                                        set to low after the|
-|                                                     "i_APCI1710_DisablePWM"|
-|                                                        function            |
-|                                                    2 : The output signal is|
-|                                                        set to high after   |
-|                                                        the                 |
-|                                                     "i_APCI1710_DisablePWM"|
-|                                                        function            |
-|                     PBYTE_  pb_ExternGate      : Extern gate action        |
-|                                                  selection                 |
-|                                                   0 : Extern gate signal   |
-|                                                       not used.            |
-|                                                   1 : Extern gate signal   |
-|                                                       used.                |
-|                     PBYTE_  pb_InterruptEnable : Enable or disable the PWM |
-|                                                  interrupt.                |
-|                                                  - APCI1710_ENABLE :       |
-|                                                    Enable the PWM interrupt|
-|                                                    A interrupt occur after |
-|                                                    each period             |
-|                                                  - APCI1710_DISABLE :      |
-|                                                    Disable the PWM         |
-|                                                    interrupt               |
-|                     PBYTE_  pb_Enable          : Indicate if the PWM is    |
-|                                                  enabled or no             |
-|                                                       0 : PWM not enabled  |
-|                                                       1 : PWM enabled      |
-+----------------------------------------------------------------------------+
-| Return Value      :  0: No error                                           |
-|                     -1: The handle parameter of the board is wrong         |
-|                     -2: Module selection wrong                             |
-|                     -3: The module is not a PWM module                     |
-|                     -4: PWM selection is wrong                             |
-|                     -5: PWM not initialised see function                   |
-|                         "i_APCI1710_InitPWM"                               |
-+----------------------------------------------------------------------------+
-*/
-
-INT  i_APCI1710_GetPWMInitialisation (comedi_device *dev,
-                                        BYTE     b_ModulNbr,
-                                        BYTE     b_PWM,
-                                        PBYTE   pb_TimingUnit,
-                                        PULONG pul_LowTiming,
-                                        PULONG pul_HighTiming,
-                                        PBYTE   pb_StartLevel,
-                                        PBYTE   pb_StopMode,
-                                        PBYTE   pb_StopLevel,
-                                        PBYTE   pb_ExternGate,
-                                        PBYTE   pb_InterruptEnable,
-                                        PBYTE   pb_Enable)
-       {
-       INT    i_ReturnValue = 0;
-       DWORD dw_Status;
-       DWORD dw_Command;
-       
-       
-       /**************************/
-       /* Test the module number */
-       /**************************/
-
-       if (b_ModulNbr < 4)
-          {
-          /***************/
-          /* Test if PWM */
-          /***************/
-
-          if ((devpriv->
-               s_BoardInfos.
-               dw_MolduleConfiguration [b_ModulNbr] & 0xFFFF0000UL) == APCI1710_PWM)
-             {
-             /**************************/
-             /* Test the PWM selection */
-             /**************************/
-
-             if (b_PWM >= 0 && b_PWM <= 1)
-                {
-                /***************************/
-                /* Test if PWM initialised */
-                /***************************/
-
-                  dw_Status=inl(devpriv->s_BoardInfos.
-                       ui_Address + 12 + (20 * b_PWM) + (64 * b_ModulNbr));
-
-                if (dw_Status & 0x10)
-                   {
-                   /***********************/
-                   /* Read the low timing */
-                   /***********************/
-
-                       *pul_LowTiming = inl(devpriv->s_BoardInfos.
-                          ui_Address + 0 + (20 * b_PWM) + (64 * b_ModulNbr));
-
-                   /************************/
-                   /* Read the high timing */
-                   /************************/
-
-                     *pul_HighTiming= inl(devpriv->s_BoardInfos.
-                          ui_Address + 4 + (20 * b_PWM) + (64 * b_ModulNbr));
-
-                   /********************/
-                   /* Read the command */
-                   /********************/
-
-                     dw_Command = inl(devpriv->s_BoardInfos.
-                          ui_Address + 8 + (20 * b_PWM) + (64 * b_ModulNbr));
-
-                   *pb_StartLevel      = (BYTE) ((dw_Command >> 5) & 1);
-                   *pb_StopMode        = (BYTE) ((dw_Command >> 0) & 1);
-                   *pb_StopLevel       = (BYTE) ((dw_Command >> 1) & 1);
-                   *pb_ExternGate      = (BYTE) ((dw_Command >> 4) & 1);
-                   *pb_InterruptEnable = (BYTE) ((dw_Command >> 3) & 1);
-
-                   if (*pb_StopLevel)
-                      {
-                      *pb_StopLevel = *pb_StopLevel + (BYTE) ((dw_Command >> 2) & 1);
-                      }
-
-                   /********************/
-                   /* Read the command */
-                   /********************/
-
-                     dw_Command=inl(devpriv->s_BoardInfos.
-                          ui_Address + 8 + (20 * b_PWM) + (64 * b_ModulNbr));
-
-                   *pb_Enable = (BYTE) ((dw_Command >> 0) & 1);
-
-                   *pb_TimingUnit = devpriv->
-                                    s_ModuleInfo [b_ModulNbr].
-                                    s_PWMModuleInfo.
-                                    s_PWMInfo [b_PWM].
-                                    b_TimingUnit;
-                   } // if (dw_Status & 0x10)
-                else
-                   {
-                   /***********************/
-                   /* PWM not initialised */
-                   /***********************/
-                    DPRINTK("PWM not initialised\n");
-                   i_ReturnValue = -5;
-                   } // if (dw_Status & 0x10)
-                } // if (b_PWM >= 0 && b_PWM <= 1)
-             else
-                {
-                /******************************/
-                /* Tor PWM selection is wrong */
-                /******************************/
-                DPRINTK("Tor PWM selection is wrong\n");
-                i_ReturnValue = -4;
-                } // if (b_PWM >= 0 && b_PWM <= 1)
-             }
-          else
-             {
-             /**********************************/
-             /* The module is not a PWM module */
-             /**********************************/
-             DPRINTK("The module is not a PWM module\n");      
-             i_ReturnValue = -3;
-             }
-          }
-       else
-          {
-          /***********************/
-          /* Module number error */
-          /***********************/
-          DPRINTK("Module number error\n");
-          i_ReturnValue = -2;
-          }
-
-       return (i_ReturnValue);
-       }
-\r
-\r
-\r
-
-
-/*
-+----------------------------------------------------------------------------+
-| Function Name     :INT i_APCI1710_InsnWritePWM(comedi_device *dev,
-comedi_subdevice *s,comedi_insn *insn,lsampl_t *data)                        |
-+----------------------------------------------------------------------------+
-| Task              : Pwm Enable Disable and Set New Timing                  |
-+----------------------------------------------------------------------------+
-| Input Parameters  : 
-+----------------------------------------------------------------------------+
-| Output Parameters : -                                                      |
-+----------------------------------------------------------------------------+
-| Return Value      : 
-+----------------------------------------------------------------------------+
-*/
-
-INT    i_APCI1710_InsnWritePWM(comedi_device *dev,comedi_subdevice *s,
-comedi_insn *insn,lsampl_t *data)
-{
-       BYTE b_WriteType;
-       INT i_ReturnValue=0;
-    b_WriteType=CR_CHAN(insn->chanspec);
-
-       switch(b_WriteType)
-       {
-       case APCI1710_PWM_ENABLE :
-               i_ReturnValue=i_APCI1710_EnablePWM    (dev,
-                                (BYTE)  CR_AREF(insn->chanspec),
-                                (BYTE)  data[0],
-                                (BYTE)  data[1],
-                                (BYTE)  data[2],
-                                (BYTE)  data[3],
-                                (BYTE)  data[4],
-                                (BYTE)  data[5]);
-               break;
-
-       case APCI1710_PWM_DISABLE :
-               i_ReturnValue=i_APCI1710_DisablePWM   (dev,
-                                (BYTE)  CR_AREF(insn->chanspec),
-                                (BYTE)  data[0]);
-               break;
-
-       case APCI1710_PWM_NEWTIMING:
-               i_ReturnValue=i_APCI1710_SetNewPWMTiming        (dev,
-                                        (BYTE)  CR_AREF(insn->chanspec),
-                                        (BYTE)  data[0],
-                                        (BYTE)    data[1],
-                                        (ULONG)   data[2],
-                                        (ULONG)   data[3]);
-               break;
-
-       
-       default:
-               printk("Write Config Parameter Wrong\n");
-       }
-
-       if(i_ReturnValue>=0) i_ReturnValue =insn->n;
-       return (i_ReturnValue);
-}
-
-
-
-
-
-/*
-+----------------------------------------------------------------------------+
-| Function Name     : _INT_     i_APCI1710_EnablePWM                         |
-|                                       (BYTE_  b_BoardHandle,               |
-|                                        BYTE_  b_ModulNbr,                  |
-|                                        BYTE_  b_PWM,                       |
-|                                        BYTE_  b_StartLevel,                |
-|                                        BYTE_  b_StopMode,                  |
-|                                        BYTE_  b_StopLevel,                 |
-|                                        BYTE_  b_ExternGate,                |
-|                                        BYTE_  b_InterruptEnable)           |
-+----------------------------------------------------------------------------+
-| Task              : Enable the selected PWM (b_PWM) from selected module   |
-|                     (b_ModulNbr). You must calling the "i_APCI1710_InitPWM"|
-|                     function be for you call this function.                |
-|                     If you enable the PWM interrupt, the PWM generate a    |
-|                     interrupt after each period.                           |
-|                     See function "i_APCI1710_SetBoardIntRoutineX" and the  |
-|                     Interrupt mask description chapter.                    |
-+----------------------------------------------------------------------------+
-| Input Parameters  : BYTE_ b_BoardHandle     : Handle of board APCI-1710    |
-|                     BYTE_ b_ModulNbr        : Selected module number       |
-|                                               (0 to 3)                     |
-|                     BYTE_ b_PWM             : Selected PWM (0 or 1)        |
-|                     BYTE_ b_StartLevel      : Start period level selection |
-|                                                0 : The period start with a |
-|                                                    low level               |
-|                                                1 : The period start with a |
-|                                                    high level              |
-|                     BYTE_ b_StopMode        : Stop mode selection          |
-|                                                0 : The PWM is stopped      |
-|                                                    directly after the      |
-|                                                    "i_APCI1710_DisablePWM" |
-|                                                    function and break the  |
-|                                                    last period             |
-|                                                1 : After the               |
-|                                                    "i_APCI1710_DisablePWM" |
-|                                                     function the PWM is    |
-|                                                     stopped at the end from|
-|                                                     last period cycle.     |
-|                     BYTE_ b_StopLevel       : Stop PWM level selection     |
-|                                                0 : The output signal keep  |
-|                                                    the level after the     |
-|                                                    "i_APCI1710_DisablePWM" |
-|                                                    function                |
-|                                                1 : The output signal is set|
-|                                                    to low after the        |
-|                                                    "i_APCI1710_DisablePWM" |
-|                                                    function                |
-|                                                2 : The output signal is set|
-|                                                    to high after the       |
-|                                                    "i_APCI1710_DisablePWM" |
-|                                                    function                |
-|                     BYTE_ b_ExternGate      : Extern gate action selection |
-|                                                0 : Extern gate signal not  |
-|                                                    used.                   |
-|                                                1 : Extern gate signal used.|
-|                     BYTE_ b_InterruptEnable : Enable or disable the PWM    |
-|                                               interrupt.                   |
-|                                               - APCI1710_ENABLE :          |
-|                                                 Enable the PWM interrupt   |
-|                                                 A interrupt occur after    |
-|                                                 each period                |
-|                                               - APCI1710_DISABLE :         |
-|                                                 Disable the PWM interrupt  |
-+----------------------------------------------------------------------------+
-| Output Parameters : -                                                      |
-+----------------------------------------------------------------------------+
-| Return Value      : 0:  No error                                           |
-|                    -1:  The handle parameter of the board is wrong         |
-|                    -2:  Module selection wrong                             |
-|                    -3:  The module is not a PWM module                     |
-|                    -4:  PWM selection is wrong                             |
-|                    -5:  PWM not initialised see function                   |
-|                         "i_APCI1710_InitPWM"                               |
-|                    -6:  PWM start level selection is wrong                 |
-|                    -7:  PWM stop mode selection is wrong                   |
-|                    -8:  PWM stop level selection is wrong                  |
-|                    -9:  Extern gate signal selection is wrong              |
-|                    -10: Interrupt parameter is wrong                       |
-|                    -11: Interrupt function not initialised.                |
-|                         See function "i_APCI1710_SetBoardIntRoutineX"      |
-+----------------------------------------------------------------------------+
-*/
-
-INT   i_APCI1710_EnablePWM    (comedi_device *dev,
-                                BYTE  b_ModulNbr,
-                                BYTE  b_PWM,
-                                BYTE  b_StartLevel,
-                                BYTE  b_StopMode,
-                                BYTE  b_StopLevel,
-                                BYTE  b_ExternGate,
-                                BYTE  b_InterruptEnable)
-       {
-       INT    i_ReturnValue = 0;
-       DWORD dw_Status;
-       DWORD dw_Command;
-       
-        devpriv->tsk_Current=current; // Save the current process task structure
-       /**************************/
-       /* Test the module number */
-       /**************************/
-
-       if (b_ModulNbr < 4)
-          {
-          /***************/
-          /* Test if PWM */
-          /***************/
-
-          if ((devpriv->
-               s_BoardInfos.
-               dw_MolduleConfiguration [b_ModulNbr] & 0xFFFF0000UL) == APCI1710_PWM)
-             {
-             /**************************/
-             /* Test the PWM selection */
-             /**************************/
-
-             if (b_PWM >= 0 && b_PWM <= 1)
-                {
-                /***************************/
-                /* Test if PWM initialised */
-                /***************************/
-
-                dw_Status=      inl(devpriv->s_BoardInfos.
-                       ui_Address + 12 + (20 * b_PWM) + (64 * b_ModulNbr));
-
-                if (dw_Status & 0x10)
-                   {
-                   /**********************************/
-                   /* Test the start level selection */
-                   /**********************************/
-
-                   if (b_StartLevel >= 0 && b_StartLevel <= 1)
-                      {
-                      /**********************/
-                      /* Test the stop mode */
-                      /**********************/
-
-                      if (b_StopMode >= 0 && b_StopMode <= 1)
-                         {
-                         /***********************/
-                         /* Test the stop level */
-                         /***********************/
-
-                         if (b_StopLevel >= 0 && b_StopLevel <= 2)
-                            {
-                            /*****************************/
-                            /* Test the extern gate mode */
-                            /*****************************/
-
-                            if (b_ExternGate >= 0 && b_ExternGate <= 1)
-                               {
-                               /*****************************/
-                               /* Test the interrupt action */
-                               /*****************************/
-
-                               if (b_InterruptEnable == APCI1710_ENABLE || b_InterruptEnable == APCI1710_DISABLE)
-                                  {
-                                  /******************************************/
-                                  /* Test if interrupt function initialised */
-                                  /******************************************/
-
-                                     /********************/
-                                     /* Read the command */
-                                     /********************/
-
-                                           dw_Command=inl(devpriv->s_BoardInfos.
-                                            ui_Address + 8 + (20 * b_PWM) + (64 * b_ModulNbr));
-
-                                     dw_Command = dw_Command & 0x80;
-
-                                     /********************/
-                                     /* Make the command */
-                                     /********************/
-
-                                     dw_Command = dw_Command | b_StopMode | (b_InterruptEnable << 3) | (b_ExternGate << 4) | (b_StartLevel << 5);
-
-                                     if (b_StopLevel & 3)
-                                        {
-                                        dw_Command = dw_Command | 2;
-
-                                        if (b_StopLevel & 2)
-                                           {
-                                           dw_Command = dw_Command | 4;
-                                           }
-                                        }
-
-
-                                     devpriv->
-                                     s_ModuleInfo [b_ModulNbr].
-                                     s_PWMModuleInfo.
-                                     s_PWMInfo [b_PWM].
-                                     b_InterruptEnable = b_InterruptEnable;
-
-                                     /*******************/
-                                     /* Set the command */
-                                     /*******************/
-
-                                         outl(dw_Command,devpriv->s_BoardInfos.
-                                             ui_Address + 8 + (20 * b_PWM) + (64 * b_ModulNbr));
-
-                                     /******************/
-                                     /* Enable the PWM */
-                                     /******************/
-                                         outl(1,devpriv->s_BoardInfos.
-                                             ui_Address + 12 + (20 * b_PWM) + (64 * b_ModulNbr));
-                                  } // if (b_InterruptEnable == APCI1710_ENABLE || b_InterruptEnable == APCI1710_DISABLE)
-                               else
-                                  {
-                                  /********************************/
-                                  /* Interrupt parameter is wrong */
-                                  /********************************/
-                           DPRINTK("Interrupt parameter is wrong\n");
-                                  i_ReturnValue = -10;
-                                  } // if (b_InterruptEnable == APCI1710_ENABLE || b_InterruptEnable == APCI1710_DISABLE)
-                               } // if (b_ExternGate >= 0 && b_ExternGate <= 1)
-                            else
-                               {
-                               /*****************************************/
-                               /* Extern gate signal selection is wrong */
-                               /*****************************************/
-                               DPRINTK("Extern gate signal selection is wrong\n");
-                               i_ReturnValue = -9;
-                               } // if (b_ExternGate >= 0 && b_ExternGate <= 1)
-                            } // if (b_StopLevel >= 0 && b_StopLevel <= 2)
-                         else
-                            {
-                            /*************************************/
-                            /* PWM stop level selection is wrong */
-                            /*************************************/
-                                DPRINTK("PWM stop level selection is wrong\n");
-                            i_ReturnValue = -8;
-                            } // if (b_StopLevel >= 0 && b_StopLevel <= 2)
-                         } // if (b_StopMode >= 0 && b_StopMode <= 1)
-                      else
-                         {
-                         /************************************/
-                         /* PWM stop mode selection is wrong */
-                         /************************************/
-                         DPRINTK("PWM stop mode selection is wrong\n");        
-                         i_ReturnValue = -7;
-                         } // if (b_StopMode >= 0 && b_StopMode <= 1)
-                      } // if (b_StartLevel >= 0 && b_StartLevel <= 1)
-                   else
-                      {
-                      /**************************************/
-                      /* PWM start level selection is wrong */
-                      /**************************************/
-                          DPRINTK("PWM start level selection is wrong\n");       
-                      i_ReturnValue = -6;
-                      } // if (b_StartLevel >= 0 && b_StartLevel <= 1)
-                   } // if (dw_Status & 0x10)
-                else
-                   {
-                   /***********************/
-                   /* PWM not initialised */
-                   /***********************/
-                       DPRINTK("PWM not initialised\n");
-                   i_ReturnValue = -5;
-                   } // if (dw_Status & 0x10)
-                } // if (b_PWM >= 0 && b_PWM <= 1)
-             else
-                {
-                /******************************/
-                /* Tor PWM selection is wrong */
-                /******************************/
-                DPRINTK("Tor PWM selection is wrong\n");
-                i_ReturnValue = -4;
-                } // if (b_PWM >= 0 && b_PWM <= 1)
-             }
-          else
-             {
-             /**********************************/
-             /* The module is not a PWM module */
-             /**********************************/
-             DPRINTK("The module is not a PWM module\n");      
-             i_ReturnValue = -3;
-             }
-          }
-       else
-          {
-          /***********************/
-          /* Module number error */
-          /***********************/
-          DPRINTK("Module number error\n");    
-          i_ReturnValue = -2;
-          }
-
-       return (i_ReturnValue);
-       }
-
-/*
-+----------------------------------------------------------------------------+
-| Function Name     : _INT_ i_APCI1710_DisablePWM (BYTE_  b_BoardHandle,     |
-|                                                  BYTE_  b_ModulNbr,        |
-|                                                  BYTE_  b_PWM)             |
-+----------------------------------------------------------------------------+
-| Task              : Disable the selected PWM (b_PWM) from selected module  |
-|                     (b_ModulNbr). The output signal level depend of the    |
-|                     initialisation by the "i_APCI1710_EnablePWM".          |
-|                     See the b_StartLevel, b_StopMode and b_StopLevel       |
-|                     parameters from this function.                         |
-+----------------------------------------------------------------------------+
-| Input Parameters  :BYTE_ b_BoardHandle : Handle of board APCI-1710         |
-|                    BYTE_ b_ModulNbr    : Selected module number (0 to 3)   |
-|                    BYTE_ b_PWM         : Selected PWM (0 or 1)             |
-+----------------------------------------------------------------------------+
-| Output Parameters : -                                                      |
-+----------------------------------------------------------------------------+
-| Return Value      :  0: No error                                           |
-|                     -1: The handle parameter of the board is wrong         |
-|                     -2: Module selection wrong                             |
-|                     -3: The module is not a PWM module                     |
-|                     -4: PWM selection is wrong                             |
-|                     -5: PWM not initialised see function                   |
-|                         "i_APCI1710_InitPWM"                               |
-|                     -6: PWM not enabled see function                       |
-|                         "i_APCI1710_EnablePWM"                             |
-+----------------------------------------------------------------------------+
-*/
-
-INT   i_APCI1710_DisablePWM   (comedi_device *dev,
-                                BYTE  b_ModulNbr,
-                                BYTE  b_PWM)
-       {
-       INT    i_ReturnValue = 0;
-       DWORD dw_Status;
-       
-       /**************************/
-       /* Test the module number */
-       /**************************/
-
-       if (b_ModulNbr < 4)
-          {
-          /***************/
-          /* Test if PWM */
-          /***************/
-
-          if ((devpriv->s_BoardInfos.
-               dw_MolduleConfiguration [b_ModulNbr] & 0xFFFF0000UL) == APCI1710_PWM)
-             {
-             /**************************/
-             /* Test the PWM selection */
-             /**************************/
-
-             if (b_PWM >= 0 && b_PWM <= 1)
-                {
-                /***************************/
-                /* Test if PWM initialised */
-                /***************************/
-
-           dw_Status=inl(devpriv->s_BoardInfos.
-                       ui_Address + 12 + (20 * b_PWM) + (64 * b_ModulNbr));
-
-                if (dw_Status & 0x10)
-                   {
-                   /***********************/
-                   /* Test if PWM enabled */
-                   /***********************/
-
-                   if (dw_Status & 0x1)
-                      {
-                      /*******************/
-                      /* Disable the PWM */
-                      /*******************/
-                               outl(0,devpriv->s_BoardInfos.
-                              ui_Address + 12 + (20 * b_PWM) + (64 * b_ModulNbr));
-                      } // if (dw_Status & 0x1)
-                   else
-                      {
-                      /*******************/
-                      /* PWM not enabled */
-                      /*******************/
-                          DPRINTK("PWM not enabled\n");        
-                      i_ReturnValue = -6;
-                      } // if (dw_Status & 0x1)
-                   } // if (dw_Status & 0x10)
-                else
-                   {
-                   /***********************/
-                   /* PWM not initialised */
-                   /***********************/
-                       DPRINTK(" PWM not initialised\n");
-                   i_ReturnValue = -5;
-                   } // if (dw_Status & 0x10)
-                } // if (b_PWM >= 0 && b_PWM <= 1)
-             else
-                {
-                /******************************/
-                /* Tor PWM selection is wrong */
-                /******************************/
-                DPRINTK("Tor PWM selection is wrong\n");       
-                i_ReturnValue = -4;
-                } // if (b_PWM >= 0 && b_PWM <= 1)
-             }
-          else
-             {
-             /**********************************/
-             /* The module is not a PWM module */
-             /**********************************/
-             DPRINTK("The module is not a PWM module\n");      
-             i_ReturnValue = -3;
-             }
-          }
-       else
-          {
-          /***********************/
-          /* Module number error */
-          /***********************/
-          DPRINTK("Module number error\n");
-          i_ReturnValue = -2;
-          }
-
-       return (i_ReturnValue);
-       }
-
-/*
-+----------------------------------------------------------------------------+
-| Function Name     : _INT_ i_APCI1710_SetNewPWMTiming                       |
-|                                       (BYTE_     b_BoardHandle,            |
-|                                        BYTE_     b_ModulNbr,               |
-|                                        BYTE_     b_PWM,                    |
-|                                        BYTE_     b_ClockSelection,         |
-|                                        BYTE_     b_TimingUnit,             |
-|                                        ULONG_   ul_LowTiming,              |
-|                                        ULONG_   ul_HighTiming)             |
-+----------------------------------------------------------------------------+
-| Task              : Set a new timing. The ul_LowTiming, ul_HighTiming and  |
-|                     ul_TimingUnit determine the low/high timing base for   |
-|                     the period.                                            |
-+----------------------------------------------------------------------------+
-| Input Parameters  : BYTE_     b_BoardHandle    : Handle of board APCI-1710 |
-|                     BYTE_     b_ModulNbr       : Module number to configure|
-|                                                  (0 to 3)                  |
-|                     BYTE_     b_PWM            : Selected PWM (0 or 1).    |
-|                     BYTE_     b_TimingUnit     : Base timing Unit (0 to 4) |
-|                                                       0 : ns               |
-|                                                       1 : æs               |
-|                                                       2 : ms               |
-|                                                       3 : s                |
-|                                                       4 : mn               |
-|                     ULONG_    ul_LowTiming     : Low base timing value.    |
-|                     ULONG_    ul_HighTiming    : High base timing value.   |
-+----------------------------------------------------------------------------+
-| Output Parameters : -                                                      |
-+----------------------------------------------------------------------------+
-| Return Value      : 0: No error                                            |
-|                    -1: The handle parameter of the board is wrong          |
-|                    -2: Module selection wrong                              |
-|                    -3: The module is not a PWM module                      |
-|                    -4: PWM selection is wrong                              |
-|                    -5: PWM not initialised                                 |
-|                    -6: Timing Unit selection is wrong                      |
-|                    -7: Low base timing selection is wrong                  |
-|                    -8: High base timing selection is wrong                 |
-+----------------------------------------------------------------------------+
-*/
-
-INT   i_APCI1710_SetNewPWMTiming       (comedi_device *dev,
-                                        BYTE     b_ModulNbr,
-                                        BYTE     b_PWM,
-                                        BYTE     b_TimingUnit,
-                                        ULONG   ul_LowTiming,
-                                        ULONG   ul_HighTiming)
-       {
-       BYTE   b_ClockSelection;
-       INT    i_ReturnValue = 0;
-       ULONG ul_LowTimerValue;
-       ULONG ul_HighTimerValue;
-       ULONG ul_RealLowTiming;
-       ULONG ul_RealHighTiming;
-       DWORD dw_Status;
-       DWORD dw_Command;
-       double d_RealLowTiming;
-       double d_RealHighTiming;
-       
-
-
-       /**************************/
-       /* Test the module number */
-       /**************************/
-
-       if (b_ModulNbr < 4)
-          {
-          /***************/
-          /* Test if PWM */
-          /***************/
-
-          if ((devpriv->s_BoardInfos.
-               dw_MolduleConfiguration [b_ModulNbr] & 0xFFFF0000UL) == APCI1710_PWM)
-             {
-             /**************************/
-             /* Test the PWM selection */
-             /**************************/
-
-             if (b_PWM >= 0 && b_PWM <= 1)
-                {
-                /***************************/
-                /* Test if PWM initialised */
-                /***************************/
-
-                       dw_Status=inl(devpriv->s_BoardInfos.
-                       ui_Address + 12 + (20 * b_PWM) + (64 * b_ModulNbr));
-
-                if (dw_Status & 0x10)
-                   {
-                   b_ClockSelection = devpriv->
-                                      s_ModuleInfo [b_ModulNbr].
-                                      s_PWMModuleInfo.
-                                      b_ClockSelection;
-
-                   /************************/
-                   /* Test the timing unit */
-                   /************************/
-
-                   if ((b_TimingUnit >= 0) && (b_TimingUnit <= 4))
-                      {
-                      /*********************************/
-                      /* Test the low timing selection */
-                      /*********************************/
-
-                      if (((b_ClockSelection == APCI1710_30MHZ) && (b_TimingUnit == 0) && (ul_LowTiming >= 266) && (ul_LowTiming <= 0xFFFFFFFFUL)) ||
-                          ((b_ClockSelection == APCI1710_30MHZ) && (b_TimingUnit == 1) && (ul_LowTiming >= 1)   && (ul_LowTiming <= 571230650UL))  ||
-                          ((b_ClockSelection == APCI1710_30MHZ) && (b_TimingUnit == 2) && (ul_LowTiming >= 1)   && (ul_LowTiming <= 571230UL))     ||
-                          ((b_ClockSelection == APCI1710_30MHZ) && (b_TimingUnit == 3) && (ul_LowTiming >= 1)   && (ul_LowTiming <= 571UL))        ||
-                          ((b_ClockSelection == APCI1710_30MHZ) && (b_TimingUnit == 4) && (ul_LowTiming >= 1)   && (ul_LowTiming <= 9UL))          ||
-                          ((b_ClockSelection == APCI1710_33MHZ) && (b_TimingUnit == 0) && (ul_LowTiming >= 242) && (ul_LowTiming <= 0xFFFFFFFFUL)) ||
-                          ((b_ClockSelection == APCI1710_33MHZ) && (b_TimingUnit == 1) && (ul_LowTiming >= 1)   && (ul_LowTiming <= 519691043UL))  ||
-                          ((b_ClockSelection == APCI1710_33MHZ) && (b_TimingUnit == 2) && (ul_LowTiming >= 1)   && (ul_LowTiming <= 519691UL))     ||
-                          ((b_ClockSelection == APCI1710_33MHZ) && (b_TimingUnit == 3) && (ul_LowTiming >= 1)   && (ul_LowTiming <= 520UL))        ||
-                          ((b_ClockSelection == APCI1710_33MHZ) && (b_TimingUnit == 4) && (ul_LowTiming >= 1)   && (ul_LowTiming <= 8UL))          ||
-                          ((b_ClockSelection == APCI1710_40MHZ) && (b_TimingUnit == 0) && (ul_LowTiming >= 200) && (ul_LowTiming <= 0xFFFFFFFFUL)) ||
-                          ((b_ClockSelection == APCI1710_40MHZ) && (b_TimingUnit == 1) && (ul_LowTiming >= 1)   && (ul_LowTiming <= 429496729UL))  ||
-                          ((b_ClockSelection == APCI1710_40MHZ) && (b_TimingUnit == 2) && (ul_LowTiming >= 1)   && (ul_LowTiming <= 429496UL))     ||
-                          ((b_ClockSelection == APCI1710_40MHZ) && (b_TimingUnit == 3) && (ul_LowTiming >= 1)   && (ul_LowTiming <= 429UL))        ||
-                          ((b_ClockSelection == APCI1710_40MHZ) && (b_TimingUnit == 4) && (ul_LowTiming >= 1)   && (ul_LowTiming <= 7UL)))
-                         {
-                         /**********************************/
-                         /* Test the High timing selection */
-                         /**********************************/
-
-                         if (((b_ClockSelection == APCI1710_30MHZ) && (b_TimingUnit == 0) && (ul_HighTiming >= 266) && (ul_HighTiming <= 0xFFFFFFFFUL)) ||
-                             ((b_ClockSelection == APCI1710_30MHZ) && (b_TimingUnit == 1) && (ul_HighTiming >= 1)   && (ul_HighTiming <= 571230650UL))  ||
-                             ((b_ClockSelection == APCI1710_30MHZ) && (b_TimingUnit == 2) && (ul_HighTiming >= 1)   && (ul_HighTiming <= 571230UL))     ||
-                             ((b_ClockSelection == APCI1710_30MHZ) && (b_TimingUnit == 3) && (ul_HighTiming >= 1)   && (ul_HighTiming <= 571UL))        ||
-                             ((b_ClockSelection == APCI1710_30MHZ) && (b_TimingUnit == 4) && (ul_HighTiming >= 1)   && (ul_HighTiming <= 9UL))          ||
-                             ((b_ClockSelection == APCI1710_33MHZ) && (b_TimingUnit == 0) && (ul_HighTiming >= 242) && (ul_HighTiming <= 0xFFFFFFFFUL)) ||
-                             ((b_ClockSelection == APCI1710_33MHZ) && (b_TimingUnit == 1) && (ul_HighTiming >= 1)   && (ul_HighTiming <= 519691043UL))  ||
-                             ((b_ClockSelection == APCI1710_33MHZ) && (b_TimingUnit == 2) && (ul_HighTiming >= 1)   && (ul_HighTiming <= 519691UL))     ||
-                             ((b_ClockSelection == APCI1710_33MHZ) && (b_TimingUnit == 3) && (ul_HighTiming >= 1)   && (ul_HighTiming <= 520UL))        ||
-                             ((b_ClockSelection == APCI1710_33MHZ) && (b_TimingUnit == 4) && (ul_HighTiming >= 1)   && (ul_HighTiming <= 8UL))          ||
-                             ((b_ClockSelection == APCI1710_40MHZ) && (b_TimingUnit == 0) && (ul_HighTiming >= 200) && (ul_HighTiming <= 0xFFFFFFFFUL)) ||
-                             ((b_ClockSelection == APCI1710_40MHZ) && (b_TimingUnit == 1) && (ul_HighTiming >= 1)   && (ul_HighTiming <= 429496729UL))  ||
-                             ((b_ClockSelection == APCI1710_40MHZ) && (b_TimingUnit == 2) && (ul_HighTiming >= 1)   && (ul_HighTiming <= 429496UL))     ||
-                             ((b_ClockSelection == APCI1710_40MHZ) && (b_TimingUnit == 3) && (ul_HighTiming >= 1)   && (ul_HighTiming <= 429UL))        ||
-                             ((b_ClockSelection == APCI1710_40MHZ) && (b_TimingUnit == 4) && (ul_HighTiming >= 1)   && (ul_HighTiming <= 7UL)))
-                            {
-                            /************************************/
-                            /* Calculate the low division fator */
-                            /************************************/
-
-                            switch (b_TimingUnit)
-                               {
-                               /******/
-                               /* ns */
-                               /******/
-
-                               case 0:
-                                    
-                                       /******************/
-                                       /* Timer 0 factor */
-                                       /******************/
-
-                                       ul_LowTimerValue = (ULONG) (ul_LowTiming * (0.00025 * b_ClockSelection));
-
-                                       /*******************/
-                                       /* Round the value */
-                                       /*******************/
-
-                                       if ((double) ((double) ul_LowTiming * (0.00025 * (double) b_ClockSelection)) >= ((double) ((double) ul_LowTimerValue + 0.5)))
-                                          {
-                                          ul_LowTimerValue = ul_LowTimerValue + 1;
-                                          }
-
-                                       /*****************************/
-                                       /* Calculate the real timing */
-                                       /*****************************/
-
-                                       ul_RealLowTiming = (ULONG) (ul_LowTimerValue / (0.00025 * (double) b_ClockSelection));
-                                       d_RealLowTiming = (double) ul_LowTimerValue / (0.00025 * (double) b_ClockSelection);
-
-                                       if ((double) ((double) ul_LowTimerValue / (0.00025 * (double) b_ClockSelection)) >= (double) ((double) ul_RealLowTiming + 0.5))
-                                          {
-                                          ul_RealLowTiming = ul_RealLowTiming + 1;
-                                          }
-
-                                       ul_LowTiming     = ul_LowTiming - 1;
-                                       ul_LowTimerValue = ul_LowTimerValue - 2;
-
-                                       if (b_ClockSelection != APCI1710_40MHZ)
-                                          {
-                                          ul_LowTimerValue = (ULONG) ((double) (ul_LowTimerValue) * 1.007752288);
-                                          }
-                                   
-
-                                    break;
-
-                               /******/
-                               /* æs */
-                               /******/
-
-                               case 1:
-                                   
-                                       /******************/
-                                       /* Timer 0 factor */
-                                       /******************/
-
-                                       ul_LowTimerValue = (ULONG) (ul_LowTiming * (0.25 * b_ClockSelection));
-
-                                       /*******************/
-                                       /* Round the value */
-                                       /*******************/
-
-                                       if ((double) ((double) ul_LowTiming * (0.25 * (double) b_ClockSelection)) >= ((double) ((double) ul_LowTimerValue + 0.5)))
-                                          {
-                                          ul_LowTimerValue = ul_LowTimerValue + 1;
-                                          }
-
-                                       /*****************************/
-                                       /* Calculate the real timing */
-                                       /*****************************/
-
-                                       ul_RealLowTiming = (ULONG) (ul_LowTimerValue / (0.25 * (double) b_ClockSelection));
-                                       d_RealLowTiming    = (double) ul_LowTimerValue / ((double) 0.25 * (double) b_ClockSelection);
-
-                                       if ((double) ((double) ul_LowTimerValue / (0.25 * (double) b_ClockSelection)) >= (double) ((double) ul_RealLowTiming + 0.5))
-                                          {
-                                          ul_RealLowTiming = ul_RealLowTiming + 1;
-                                          }
-
-                                       ul_LowTiming     = ul_LowTiming - 1;
-                                       ul_LowTimerValue = ul_LowTimerValue - 2;
-
-                                       if (b_ClockSelection != APCI1710_40MHZ)
-                                          {
-                                          ul_LowTimerValue = (ULONG) ((double) (ul_LowTimerValue) * 1.007752288);
-                                          }
-                                   
-                                    break;
-
-                               /******/
-                               /* ms */
-                               /******/
-
-                               case 2:
-                                    
-                                       /******************/
-                                       /* Timer 0 factor */
-                                       /******************/
-
-                                       ul_LowTimerValue = ul_LowTiming * (250.0 * b_ClockSelection);
-
-                                       /*******************/
-                                       /* Round the value */
-                                       /*******************/
-
-                                       if ((double) ((double) ul_LowTiming * (250.0 * (double) b_ClockSelection)) >= ((double) ((double) ul_LowTimerValue + 0.5)))
-                                          {
-                                          ul_LowTimerValue = ul_LowTimerValue + 1;
-                                          }
-
-                                       /*****************************/
-                                       /* Calculate the real timing */
-                                       /*****************************/
-
-                                       ul_RealLowTiming = (ULONG) (ul_LowTimerValue / (250.0 * (double) b_ClockSelection));
-                                       d_RealLowTiming    = (double) ul_LowTimerValue / (250.0 * (double) b_ClockSelection);
-
-                                       if ((double) ((double) ul_LowTimerValue / (250.0 * (double) b_ClockSelection)) >= (double) ((double) ul_RealLowTiming + 0.5))
-                                          {
-                                          ul_RealLowTiming = ul_RealLowTiming + 1;
-                                          }
-
-                                       ul_LowTiming     = ul_LowTiming - 1;
-                                       ul_LowTimerValue = ul_LowTimerValue - 2;
-
-                                       if (b_ClockSelection != APCI1710_40MHZ)
-                                          {
-                                          ul_LowTimerValue = (ULONG) ((double) (ul_LowTimerValue) * 1.007752288);
-                                          }
-                                    
-                                    break;
-
-                               /*****/
-                               /* s */
-                               /*****/
-
-                               case 3:
-                                    
-                                       /******************/
-                                       /* Timer 0 factor */
-                                       /******************/
-
-                                       ul_LowTimerValue = (ULONG) (ul_LowTiming * (250000.0 * b_ClockSelection));
-
-                                       /*******************/
-                                       /* Round the value */
-                                       /*******************/
-
-                                       if ((double) ((double) ul_LowTiming * (250000.0 * (double) b_ClockSelection)) >= ((double) ((double) ul_LowTimerValue + 0.5)))
-                                          {
-                                          ul_LowTimerValue = ul_LowTimerValue + 1;
-                                          }
-
-                                       /*****************************/
-                                       /* Calculate the real timing */
-                                       /*****************************/
-
-                                       ul_RealLowTiming = (ULONG) (ul_LowTimerValue / (250000.0 * (double) b_ClockSelection));
-                                       d_RealLowTiming    = (double) ul_LowTimerValue / (250000.0 * (double) b_ClockSelection);
-
-                                       if ((double) ((double) ul_LowTimerValue / (250000.0 * (double) b_ClockSelection)) >= (double) ((double) ul_RealLowTiming + 0.5))
-                                          {
-                                          ul_RealLowTiming = ul_RealLowTiming + 1;
-                                          }
-
-                                       ul_LowTiming     = ul_LowTiming - 1;
-                                       ul_LowTimerValue = ul_LowTimerValue - 2;
-
-                                       if (b_ClockSelection != APCI1710_40MHZ)
-                                          {
-                                          ul_LowTimerValue = (ULONG) ((double) (ul_LowTimerValue) * 1.007752288);
-                                          }
-                                   
-                                    break;
-
-                               /******/
-                               /* mn */
-                               /******/
-
-                               case 4:
-                                    
-                                       /******************/
-                                       /* Timer 0 factor */
-                                       /******************/
-
-                                       ul_LowTimerValue = (ULONG) ((ul_LowTiming * 60) * (250000.0 * b_ClockSelection));
-
-                                       /*******************/
-                                       /* Round the value */
-                                       /*******************/
-
-                                       if ((double) ((double) (ul_LowTiming * 60.0) * (250000.0 * (double) b_ClockSelection)) >= ((double) ((double) ul_LowTimerValue + 0.5)))
-                                          {
-                                          ul_LowTimerValue = ul_LowTimerValue + 1;
-                                          }
-
-                                       /*****************************/
-                                       /* Calculate the real timing */
-                                       /*****************************/
-
-                                       ul_RealLowTiming = (ULONG) (ul_LowTimerValue / (250000.0 * (double) b_ClockSelection)) / 60;
-                                       d_RealLowTiming    = ((double) ul_LowTimerValue / (250000.0 * (double) b_ClockSelection)) / 60.0;
-
-                                       if ((double) (((double) ul_LowTimerValue / (250000.0 * (double) b_ClockSelection)) / 60.0) >= (double) ((double) ul_RealLowTiming + 0.5))
-                                          {
-                                          ul_RealLowTiming = ul_RealLowTiming + 1;
-                                          }
-
-                                       ul_LowTiming     = ul_LowTiming - 1;
-                                       ul_LowTimerValue = ul_LowTimerValue - 2;
-
-                                       if (b_ClockSelection != APCI1710_40MHZ)
-                                          {
-                                          ul_LowTimerValue = (ULONG) ((double) (ul_LowTimerValue) * 1.007752288);
-                                          }
-                                    
-                                    break;
-                               }
-
-                            /*************************************/
-                            /* Calculate the high division fator */
-                            /*************************************/
-
-                            switch (b_TimingUnit)
-                               {
-                               /******/
-                               /* ns */
-                               /******/
-
-                               case 0:
-                                   
-                                       /******************/
-                                       /* Timer 0 factor */
-                                       /******************/
-
-                                       ul_HighTimerValue = (ULONG) (ul_HighTiming * (0.00025 * b_ClockSelection));
-
-                                       /*******************/
-                                       /* Round the value */
-                                       /*******************/
-
-                                       if ((double) ((double) ul_HighTiming * (0.00025 * (double) b_ClockSelection)) >= ((double) ((double) ul_HighTimerValue + 0.5)))
-                                          {
-                                          ul_HighTimerValue = ul_HighTimerValue + 1;
-                                          }
-
-                                       /*****************************/
-                                       /* Calculate the real timing */
-                                       /*****************************/
-
-                                       ul_RealHighTiming = (ULONG) (ul_HighTimerValue / (0.00025 * (double) b_ClockSelection));
-                                       d_RealHighTiming    = (double) ul_HighTimerValue / (0.00025 * (double) b_ClockSelection);
-
-                                       if ((double) ((double) ul_HighTimerValue / (0.00025 * (double) b_ClockSelection)) >= (double) ((double) ul_RealHighTiming + 0.5))
-                                          {
-                                          ul_RealHighTiming = ul_RealHighTiming + 1;
-                                          }
-
-                                       ul_HighTiming     = ul_HighTiming - 1;
-                                       ul_HighTimerValue = ul_HighTimerValue - 2;
-
-                                       if (b_ClockSelection != APCI1710_40MHZ)
-                                          {
-                                          ul_HighTimerValue = (ULONG) ((double) (ul_HighTimerValue) * 1.007752288);
-                                          }
-                                    
-
-                                    break;
-
-                               /******/
-                               /* æs */
-                               /******/
-
-                               case 1:
-                                    
-                                       /******************/
-                                       /* Timer 0 factor */
-                                       /******************/
-
-                                       ul_HighTimerValue = (ULONG) (ul_HighTiming * (0.25 * b_ClockSelection));
-
-                                       /*******************/
-                                       /* Round the value */
-                                       /*******************/
-
-                                       if ((double) ((double) ul_HighTiming * (0.25 * (double) b_ClockSelection)) >= ((double) ((double) ul_HighTimerValue + 0.5)))
-                                          {
-                                          ul_HighTimerValue = ul_HighTimerValue + 1;
-                                          }
-
-                                       /*****************************/
-                                       /* Calculate the real timing */
-                                       /*****************************/
-
-                                       ul_RealHighTiming = (ULONG) (ul_HighTimerValue / (0.25 * (double) b_ClockSelection));
-                                       d_RealHighTiming    = (double) ul_HighTimerValue / ((double) 0.25 * (double) b_ClockSelection);
-
-                                       if ((double) ((double) ul_HighTimerValue / (0.25 * (double) b_ClockSelection)) >= (double) ((double) ul_RealHighTiming + 0.5))
-                                          {
-                                          ul_RealHighTiming = ul_RealHighTiming + 1;
-                                          }
-
-                                       ul_HighTiming     = ul_HighTiming - 1;
-                                       ul_HighTimerValue = ul_HighTimerValue - 2;
-
-                                       if (b_ClockSelection != APCI1710_40MHZ)
-                                          {
-                                          ul_HighTimerValue = (ULONG) ((double) (ul_HighTimerValue) * 1.007752288);
-                                          }
-                                   
-                                    break;
-
-                               /******/
-                               /* ms */
-                               /******/
-
-                               case 2:
-                                    
-                                       /******************/
-                                       /* Timer 0 factor */
-                                       /******************/
-
-                                       ul_HighTimerValue = ul_HighTiming * (250.0 * b_ClockSelection);
-
-                                       /*******************/
-                                       /* Round the value */
-                                       /*******************/
-
-                                       if ((double) ((double) ul_HighTiming * (250.0 * (double) b_ClockSelection)) >= ((double) ((double) ul_HighTimerValue + 0.5)))
-                                          {
-                                          ul_HighTimerValue = ul_HighTimerValue + 1;
-                                          }
-
-                                       /*****************************/
-                                       /* Calculate the real timing */
-                                       /*****************************/
-
-                                       ul_RealHighTiming = (ULONG) (ul_HighTimerValue / (250.0 * (double) b_ClockSelection));
-                                       d_RealHighTiming    = (double) ul_HighTimerValue / (250.0 * (double) b_ClockSelection);
-
-                                       if ((double) ((double) ul_HighTimerValue / (250.0 * (double) b_ClockSelection)) >= (double) ((double) ul_RealHighTiming + 0.5))
-                                          {
-                                          ul_RealHighTiming = ul_RealHighTiming + 1;
-                                          }
-
-                                       ul_HighTiming     = ul_HighTiming - 1;
-                                       ul_HighTimerValue = ul_HighTimerValue - 2;
-
-                                       if (b_ClockSelection != APCI1710_40MHZ)
-                                          {
-                                          ul_HighTimerValue = (ULONG) ((double) (ul_HighTimerValue) * 1.007752288);
-                                          }
-                                  
-                                    break;
-
-                               /*****/
-                               /* s */
-                               /*****/
-
-                               case 3:
-                                   
-                                       /******************/
-                                       /* Timer 0 factor */
-                                       /******************/
-
-                                       ul_HighTimerValue = (ULONG) (ul_HighTiming * (250000.0 * b_ClockSelection));
-
-                                       /*******************/
-                                       /* Round the value */
-                                       /*******************/
-
-                                       if ((double) ((double) ul_HighTiming * (250000.0 * (double) b_ClockSelection)) >= ((double) ((double) ul_HighTimerValue + 0.5)))
-                                          {
-                                          ul_HighTimerValue = ul_HighTimerValue + 1;
-                                          }
-
-                                       /*****************************/
-                                       /* Calculate the real timing */
-                                       /*****************************/
-
-                                       ul_RealHighTiming = (ULONG) (ul_HighTimerValue / (250000.0 * (double) b_ClockSelection));
-                                       d_RealHighTiming    = (double) ul_HighTimerValue / (250000.0 * (double) b_ClockSelection);
-
-                                       if ((double) ((double) ul_HighTimerValue / (250000.0 * (double) b_ClockSelection)) >= (double) ((double) ul_RealHighTiming + 0.5))
-                                          {
-                                          ul_RealHighTiming = ul_RealHighTiming + 1;
-                                          }
-
-                                       ul_HighTiming     = ul_HighTiming - 1;
-                                       ul_HighTimerValue = ul_HighTimerValue - 2;
-
-                                       if (b_ClockSelection != APCI1710_40MHZ)
-                                          {
-                                          ul_HighTimerValue = (ULONG) ((double) (ul_HighTimerValue) * 1.007752288);
-                                          }
-                                   
-                                    break;
-
-                               /******/
-                               /* mn */
-                               /******/
-
-                               case 4:
-                                   
-                                       /******************/
-                                       /* Timer 0 factor */
-                                       /******************/
-
-                                       ul_HighTimerValue = (ULONG) ((ul_HighTiming * 60) * (250000.0 * b_ClockSelection));
-
-                                       /*******************/
-                                       /* Round the value */
-                                       /*******************/
-
-                                       if ((double) ((double) (ul_HighTiming * 60.0) * (250000.0 * (double) b_ClockSelection)) >= ((double) ((double) ul_HighTimerValue + 0.5)))
-                                          {
-                                          ul_HighTimerValue = ul_HighTimerValue + 1;
-                                          }
-
-                                       /*****************************/
-                                       /* Calculate the real timing */
-                                       /*****************************/
-
-                                       ul_RealHighTiming = (ULONG) (ul_HighTimerValue / (250000.0 * (double) b_ClockSelection)) / 60;
-                                       d_RealHighTiming    = ((double) ul_HighTimerValue / (250000.0 * (double) b_ClockSelection)) / 60.0;
-
-                                       if ((double) (((double) ul_HighTimerValue / (250000.0 * (double) b_ClockSelection)) / 60.0) >= (double) ((double) ul_RealHighTiming + 0.5))
-                                          {
-                                          ul_RealHighTiming = ul_RealHighTiming + 1;
-                                          }
-
-                                       ul_HighTiming     = ul_HighTiming - 1;
-                                       ul_HighTimerValue = ul_HighTimerValue - 2;
-
-                                       if (b_ClockSelection != APCI1710_40MHZ)
-                                          {
-                                          ul_HighTimerValue = (ULONG) ((double) (ul_HighTimerValue) * 1.007752288);
-                                          }
-                                    
-                                    break;
-                               }
-                            /************************/
-                            /* Save the timing unit */
-                            /************************/
-
-                            devpriv->
-                            s_ModuleInfo [b_ModulNbr].
-                            s_PWMModuleInfo.
-                            s_PWMInfo [b_PWM].
-                            b_TimingUnit = b_TimingUnit;
-
-                            /****************************/
-                            /* Save the low base timing */
-                            /****************************/
-
-                            devpriv->
-                            s_ModuleInfo [b_ModulNbr].
-                            s_PWMModuleInfo.
-                            s_PWMInfo [b_PWM].
-                            d_LowTiming = d_RealLowTiming;
-
-                            devpriv->
-                            s_ModuleInfo [b_ModulNbr].
-                            s_PWMModuleInfo.
-                            s_PWMInfo [b_PWM].
-                            ul_RealLowTiming = ul_RealLowTiming;
-
-                            /****************************/
-                            /* Save the high base timing */
-                            /****************************/
-
-                            devpriv->
-                            s_ModuleInfo [b_ModulNbr].
-                            s_PWMModuleInfo.
-                            s_PWMInfo [b_PWM].
-                            d_HighTiming = d_RealHighTiming;
-
-                            devpriv->
-                            s_ModuleInfo [b_ModulNbr].
-                            s_PWMModuleInfo.
-                            s_PWMInfo [b_PWM].
-                            ul_RealHighTiming = ul_RealHighTiming;
-
-                            /************************/
-                            /* Write the low timing */
-                            /************************/
-
-                                outl(ul_LowTimerValue,devpriv->s_BoardInfos.
-                                    ui_Address + 0 + (20 * b_PWM) + (64 * b_ModulNbr));
-
-                            /*************************/
-                            /* Write the high timing */
-                            /*************************/
-
-                                outl(ul_HighTimerValue,devpriv->s_BoardInfos.
-                                    ui_Address + 4 + (20 * b_PWM) + (64 * b_ModulNbr));
-
-                            /***************************/
-                            /* Set the clock selection */
-                            /***************************/
-
-                                dw_Command=inl(devpriv->s_BoardInfos.
-                                   ui_Address + 8 + (20 * b_PWM) + (64 * b_ModulNbr));
-
-                            dw_Command = dw_Command & 0x7F;
-
-                            if (b_ClockSelection == APCI1710_40MHZ)
-                               {
-                               dw_Command = dw_Command | 0x80;
-                               }
-
-                            /***************************/
-                            /* Set the clock selection */
-                            /***************************/
-
-                                outl(dw_Command,devpriv->s_BoardInfos.
-                                    ui_Address + 8 + (20 * b_PWM) + (64 * b_ModulNbr));
-                            }
-                         else
-                            {
-                            /***************************************/
-                            /* High base timing selection is wrong */
-                            /***************************************/
-                         DPRINTK("High base timing selection is wrong\n");
-                            i_ReturnValue = -8;
-                            }
-                         }
-                      else
-                         {
-                         /**************************************/
-                         /* Low base timing selection is wrong */
-                         /**************************************/
-                         DPRINTK("Low base timing selection is wrong\n");
-                         i_ReturnValue = -7;
-                         }
-                      } // if ((b_TimingUnit >= 0) && (b_TimingUnit <= 4))
-                   else
-                      {
-                      /**********************************/
-                      /* Timing unit selection is wrong */
-                      /**********************************/
-                          DPRINTK("Timing unit selection is wrong\n"); 
-                      i_ReturnValue = -6;
-                      } // if ((b_TimingUnit >= 0) && (b_TimingUnit <= 4))
-                   } // if (dw_Status & 0x10)
-                else
-                   {
-                   /***********************/
-                   /* PWM not initialised */
-                   /***********************/
-                       DPRINTK("PWM not initialised\n");       
-                   i_ReturnValue = -5;
-                   } // if (dw_Status & 0x10)
-                } // if (b_PWM >= 0 && b_PWM <= 1)
-             else
-                {
-                /******************************/
-                /* Tor PWM selection is wrong */
-                /******************************/
-                DPRINTK("Tor PWM selection is wrong\n");
-                i_ReturnValue = -4;
-                } // if (b_PWM >= 0 && b_PWM <= 1)
-             }
-          else
-             {
-             /**********************************/
-             /* The module is not a PWM module */
-             /**********************************/
-             DPRINTK("The module is not a PWM module\n");      
-             i_ReturnValue = -3;
-             }
-          }
-       else
-          {
-          /***********************/
-          /* Module number error */
-          /***********************/
-          DPRINTK("Module number error\n");    
-          i_ReturnValue = -2;
-          }
-
-       return (i_ReturnValue);
-       }
-
-
 \r
 \r
 \r
@@ -2416,7 +2445,7 @@ INT i_APCI1710_InsnReadGetPWMStatus(comedi_device *dev,comedi_subdevice *s,
              /* Test the PWM selection */\r
              /**************************/\r
 \r
-             if (b_PWM >= 0 && b_PWM <= 1)\r
+             if (b_PWM <= 1)\r
                 {\r
                 /***************************/\r
                 /* Test if PWM initialised */\r
@@ -2441,7 +2470,8 @@ INT i_APCI1710_InsnReadGetPWMStatus(comedi_device *dev,comedi_subdevice *s,
                       /*******************/\r
                       /* PWM not enabled */\r
                       /*******************/\r
-\r                      DPRINTK("PWM not enabled \n");
+\r
+                      DPRINTK("PWM not enabled \n");\r
                       i_ReturnValue = -6;\r
                       } // if (dw_Status & 0x1)\r
                    } // if (dw_Status & 0x10)\r
@@ -2450,7 +2480,8 @@ INT i_APCI1710_InsnReadGetPWMStatus(comedi_device *dev,comedi_subdevice *s,
                    /***********************/\r
                    /* PWM not initialised */\r
                    /***********************/\r
-\r                      DPRINTK("PWM not initialised\n");
+\r
+                       DPRINTK("PWM not initialised\n");\r
                    i_ReturnValue = -5;\r
                    } // if (dw_Status & 0x10)\r
                 } // if (b_PWM >= 0 && b_PWM <= 1)\r
@@ -2459,7 +2490,8 @@ INT i_APCI1710_InsnReadGetPWMStatus(comedi_device *dev,comedi_subdevice *s,
                 /******************************/\r
                 /* Tor PWM selection is wrong */\r
                 /******************************/\r
-\r               DPRINTK("Tor PWM selection is wrong\n");
+\r
+                DPRINTK("Tor PWM selection is wrong\n");\r
                 i_ReturnValue = -4;\r
                 } // if (b_PWM >= 0 && b_PWM <= 1)\r
              }\r
@@ -2468,7 +2500,8 @@ INT i_APCI1710_InsnReadGetPWMStatus(comedi_device *dev,comedi_subdevice *s,
              /**********************************/\r
              /* The module is not a PWM module */\r
              /**********************************/\r
-\r             DPRINTK("The module is not a PWM module\n");
+\r
+             DPRINTK("The module is not a PWM module\n");\r
              i_ReturnValue = -3;\r
              }\r
           }\r
@@ -2477,41 +2510,43 @@ INT i_APCI1710_InsnReadGetPWMStatus(comedi_device *dev,comedi_subdevice *s,
           /***********************/\r
           /* Module number error */\r
           /***********************/\r
-\r          DPRINTK("Module number error\n");
+\r
+          DPRINTK("Module number error\n");\r
           i_ReturnValue = -2;\r
           }\r
 \r
        return (i_ReturnValue);\r
        }\r
 \r
-
-INT i_APCI1710_InsnBitsReadPWMInterrupt(comedi_device *dev,comedi_subdevice *s,
-       comedi_insn *insn,lsampl_t *data)
-{
-                               data[0]=devpriv->s_InterruptParameters.
-                                                     s_FIFOInterruptParameters [devpriv->
-                                                                                s_InterruptParameters.
-                                                                                ui_Read].b_OldModuleMask;
-                         data[1]=devpriv->s_InterruptParameters.
-                                                     s_FIFOInterruptParameters [devpriv->
-                                                                                s_InterruptParameters.
-                                                                                ui_Read].ul_OldInterruptMask;
-                         data[2]=devpriv->s_InterruptParameters.
-                                                     s_FIFOInterruptParameters [devpriv->
-                                                                                s_InterruptParameters.
-                                                                                ui_Read].ul_OldCounterLatchValue;
-
-                            
-                            /**************************/
-                            /* Increment the read FIFO */
-                            /***************************/
-
-                            devpriv->
-                            s_InterruptParameters.
-                            ui_Read = (devpriv->
-                                       s_InterruptParameters.
-                                       ui_Read + 1) % APCI1710_SAVE_INTERRUPT;
-
-                               return insn->n;
-
-}
+\r
+INT i_APCI1710_InsnBitsReadPWMInterrupt(comedi_device *dev,comedi_subdevice *s,\r
+       comedi_insn *insn,lsampl_t *data)\r
+\r
+{\r
+                               data[0]=devpriv->s_InterruptParameters.\r
+                                                     s_FIFOInterruptParameters [devpriv->\r
+                                                                                s_InterruptParameters.\r
+                                                                                ui_Read].b_OldModuleMask;\r
+                         data[1]=devpriv->s_InterruptParameters.\r
+                                                     s_FIFOInterruptParameters [devpriv->\r
+                                                                                s_InterruptParameters.\r
+                                                                                ui_Read].ul_OldInterruptMask;\r
+                         data[2]=devpriv->s_InterruptParameters.\r
+                                                     s_FIFOInterruptParameters [devpriv->\r
+                                                                                s_InterruptParameters.\r
+                                                                                ui_Read].ul_OldCounterLatchValue;\r
+\r
+                            \r
+                            /**************************/\r
+                            /* Increment the read FIFO */\r
+                            /***************************/\r
+\r
+                            devpriv->\r
+                            s_InterruptParameters.\r
+                            ui_Read = (devpriv->\r
+                                       s_InterruptParameters.\r
+                                       ui_Read + 1) % APCI1710_SAVE_INTERRUPT;\r
+\r
+                               return insn->n;\r
+\r
+}\r
index f6e265bcb719cb0d27559afcfc8058d68bdd7873..e5f67e1918efea2a51a1e6b4a6d48efcd253e15b 100644 (file)
@@ -1,12 +1,35 @@
+/**\r
+@verbatim\r
+\r
+Copyright (C) 2004,2005  ADDI-DATA GmbH for the source code of this module. \r
+        \r
+        ADDI-DATA GmbH \r
+        Dieselstrasse 3 \r
+        D-77833 Ottersweier \r
+        Tel: +19(0)7223/9493-0 \r
+        Fax: +49(0)7223/9493-92 \r
+        http://www.addi-data-com \r
+        info@addi-data.com \r
+\r
+This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.\r
+\r
+This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.\r
+\r
+You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+\r
+You shoud also find the complete GPL in the COPYING file accompanying this source code.\r
+\r
+@endverbatim\r
+*/\r
+\r
+\r
 \r
 \r
-
 \r
-
    #define APCI1710_30MHZ           30\r
    #define APCI1710_33MHZ           33\r
    #define APCI1710_40MHZ           40\r
-
+\r
 \r
 #define APCI1710_PWM_INIT                      0\r
 #define APCI1710_PWM_GETINITDATA       1\r
 #define APCI1710_PWM_DISABLE        0\r
 #define APCI1710_PWM_ENABLE                    1\r
 #define APCI1710_PWM_NEWTIMING      2 \r
-
-
-\r
-
-INT    i_APCI1710_InsnConfigPWM(comedi_device *dev,comedi_subdevice *s,
-comedi_insn *insn,lsampl_t *data);
-
-INT   i_APCI1710_InitPWM      (comedi_device *dev,
-                                BYTE     b_ModulNbr,
-                                BYTE    b_PWM,
-                                BYTE     b_ClockSelection,
-                                BYTE     b_TimingUnit,
-                                ULONG   ul_LowTiming,
-                                ULONG   ul_HighTiming,
-                                PULONG pul_RealLowTiming,
-                                PULONG pul_RealHighTiming);
-
-INT  i_APCI1710_GetPWMInitialisation (comedi_device *dev,
-                                        BYTE     b_ModulNbr,
-                                        BYTE     b_PWM,
-                                        PBYTE   pb_TimingUnit,
-                                        PULONG pul_LowTiming,
-                                        PULONG pul_HighTiming,
-                                        PBYTE   pb_StartLevel,
-                                        PBYTE   pb_StopMode,
-                                        PBYTE   pb_StopLevel,
-                                        PBYTE   pb_ExternGate,
-                                        PBYTE   pb_InterruptEnable,
-                                        PBYTE   pb_Enable);
-
-
-
-
-INT    i_APCI1710_InsnWritePWM(comedi_device *dev,comedi_subdevice *s,
-comedi_insn *insn,lsampl_t *data);
-
-INT i_APCI1710_EnablePWM    (comedi_device *dev,
-                                BYTE  b_ModulNbr,
-                                BYTE  b_PWM,
-                                BYTE  b_StartLevel,
-                                BYTE  b_StopMode,
-                                BYTE  b_StopLevel,
-                                BYTE  b_ExternGate,
-                                BYTE  b_InterruptEnable);
-
-INT i_APCI1710_SetNewPWMTiming (comedi_device *dev,
-                                        BYTE     b_ModulNbr,
-                                        BYTE     b_PWM,
-                                        BYTE     b_TimingUnit,
-                                        ULONG   ul_LowTiming,
-                                        ULONG   ul_HighTiming);
-
-INT i_APCI1710_DisablePWM   (comedi_device *dev,
-                                BYTE  b_ModulNbr,
-                                BYTE  b_PWM);
+\r
+\r
+\r
+\r
+INT    i_APCI1710_InsnConfigPWM(comedi_device *dev,comedi_subdevice *s,\r
+comedi_insn *insn,lsampl_t *data);\r
+\r
+INT   i_APCI1710_InitPWM      (comedi_device *dev,\r
+                                BYTE     b_ModulNbr,\r
+                                BYTE    b_PWM,\r
+                                BYTE     b_ClockSelection,\r
+                                BYTE     b_TimingUnit,\r
+                                ULONG   ul_LowTiming,\r
+                                ULONG   ul_HighTiming,\r
+                                PULONG pul_RealLowTiming,\r
+                                PULONG pul_RealHighTiming);\r
+\r
+INT  i_APCI1710_GetPWMInitialisation (comedi_device *dev,\r
+                                        BYTE     b_ModulNbr,\r
+                                        BYTE     b_PWM,\r
+                                        PBYTE   pb_TimingUnit,\r
+                                        PULONG pul_LowTiming,\r
+                                        PULONG pul_HighTiming,\r
+                                        PBYTE   pb_StartLevel,\r
+                                        PBYTE   pb_StopMode,\r
+                                        PBYTE   pb_StopLevel,\r
+                                        PBYTE   pb_ExternGate,\r
+                                        PBYTE   pb_InterruptEnable,\r
+                                        PBYTE   pb_Enable);\r
+\r
+\r
+\r
+\r
+INT    i_APCI1710_InsnWritePWM(comedi_device *dev,comedi_subdevice *s,\r
+comedi_insn *insn,lsampl_t *data);\r
+\r
+INT i_APCI1710_EnablePWM    (comedi_device *dev,\r
+                                BYTE  b_ModulNbr,\r
+                                BYTE  b_PWM,\r
+                                BYTE  b_StartLevel,\r
+                                BYTE  b_StopMode,\r
+                                BYTE  b_StopLevel,\r
+                                BYTE  b_ExternGate,\r
+                                BYTE  b_InterruptEnable);\r
+\r
+INT i_APCI1710_SetNewPWMTiming (comedi_device *dev,\r
+                                        BYTE     b_ModulNbr,\r
+                                        BYTE     b_PWM,\r
+                                        BYTE     b_TimingUnit,\r
+                                        ULONG   ul_LowTiming,\r
+                                        ULONG   ul_HighTiming);\r
+\r
+INT i_APCI1710_DisablePWM   (comedi_device *dev,\r
+                                BYTE  b_ModulNbr,\r
+                                BYTE  b_PWM);\r
 \r
 INT i_APCI1710_InsnReadGetPWMStatus(comedi_device *dev,comedi_subdevice *s,\r
        comedi_insn *insn,lsampl_t *data);\r
-
-INT i_APCI1710_InsnBitsReadPWMInterrupt(comedi_device *dev,comedi_subdevice *s,
-       comedi_insn *insn,lsampl_t *data);
+\r
+INT i_APCI1710_InsnBitsReadPWMInterrupt(comedi_device *dev,comedi_subdevice *s,\r
+       comedi_insn *insn,lsampl_t *data);\r
 \r
index 99282f7248d269a272c1618bddda32992a910b83..8c60541818428c9f2232060357cf1442a1c2475f 100644 (file)
@@ -1,14 +1,38 @@
+/**\r
+@verbatim\r
+\r
+Copyright (C) 2004,2005  ADDI-DATA GmbH for the source code of this module. \r
+        \r
+        ADDI-DATA GmbH \r
+        Dieselstrasse 3 \r
+        D-77833 Ottersweier \r
+        Tel: +19(0)7223/9493-0 \r
+        Fax: +49(0)7223/9493-92 \r
+        http://www.addi-data-com \r
+        info@addi-data.com \r
+\r
+This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.\r
+\r
+This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.\r
+\r
+You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+\r
+You shoud also find the complete GPL in the COPYING file accompanying this source code.\r
+\r
+@endverbatim\r
+*/\r
 /*\r
+    \r
   +-----------------------------------------------------------------------+\r
   | (C) ADDI-DATA GmbH          Dieselstraße 3       D-77833 Ottersweier  |\r
   +-----------------------------------------------------------------------+\r
   | Tel : +49 (0) 7223/9493-0     | email    : info@addi-data.com         |\r
   | Fax : +49 (0) 7223/9493-92    | Internet : http://www.addi-data.com   |\r
   +-----------------------------------------------------------------------+\r
-  | Project   : API APCI1710      |     Compiler   : BORLANDC/MICROSOFT C |\r
-  | Module name : SSI.C           |     Version    : 3.1     / 6.0        |\r
+  | Project     : API APCI1710    | Compiler : gcc                        |\r
+  | Module name : SSI.C           | Version  : 2.96                       |\r
   +-------------------------------+---------------------------------------+\r
-  | Author    : S.WEBER           |     Date       : 14.01.98             |\r
+  | Project manager: Eric Stolz   | Date     :  02/12/2002                |\r
   +-----------------------------------------------------------------------+\r
   | Description :   APCI-1710 SSI counter module                          |\r
   |                                                                       |\r
 |                    -9: The selected SSI counting mode parameter is wrong   |\r
 +----------------------------------------------------------------------------+\r
 */\r
-
+\r
 \r
 INT   i_APCI1710_InsnConfigInitSSI(comedi_device *dev,comedi_subdevice *s,\r
        comedi_insn *insn,lsampl_t *data)\r
@@ -206,12 +230,12 @@ INT   i_APCI1710_InsnConfigInitSSI(comedi_device *dev,comedi_subdevice *s,
 \r
                                   if (b_SSICountingMode == APCI1710_BINARY_MODE)\r
                                      {\r
-                                   
+                                   \r
                                        outl(b_SSIProfile + 1,devpriv->s_BoardInfos.ui_Address + 4 + (64 * b_ModulNbr));\r
                                      }\r
                                   else\r
                                      {\r
-                                               
+                                               \r
                                           outl(b_SSIProfile,devpriv->s_BoardInfos.ui_Address + 4 + (64 * b_ModulNbr));\r
                                      }\r
 \r
@@ -242,7 +266,8 @@ INT   i_APCI1710_InsnConfigInitSSI(comedi_device *dev,comedi_subdevice *s,
                                   /*****************************************************/\r
                                   /* The selected SSI counting mode parameter is wrong */\r
                                   /*****************************************************/\r
-\r                          DPRINTK("The selected SSI counting mode parameter is wrong\n");
+\r
+                          DPRINTK("The selected SSI counting mode parameter is wrong\n");\r
                                   i_ReturnValue = -9;\r
                                   }\r
                                }\r
@@ -251,7 +276,8 @@ INT   i_APCI1710_InsnConfigInitSSI(comedi_device *dev,comedi_subdevice *s,
                                /******************************************/\r
                                /* The selected SSI output clock is wrong */\r
                                /******************************************/\r
-\r                              DPRINTK("The selected SSI output clock is wrong\n");
+\r
+                               DPRINTK("The selected SSI output clock is wrong\n");\r
                                i_ReturnValue = -8;\r
                                }\r
                             }\r
@@ -260,7 +286,8 @@ INT   i_APCI1710_InsnConfigInitSSI(comedi_device *dev,comedi_subdevice *s,
                             /*****************************************/\r
                             /* The selected PCI input clock is wrong */\r
                             /*****************************************/\r
-\r                               DPRINTK("The selected PCI input clock is wrong\n");
+\r
+                                DPRINTK("The selected PCI input clock is wrong\n");\r
                             i_ReturnValue = -7;\r
                             }\r
                          }\r
@@ -269,7 +296,8 @@ INT   i_APCI1710_InsnConfigInitSSI(comedi_device *dev,comedi_subdevice *s,
                          /********************************************/\r
                          /* The selected SSI profile length is wrong */\r
                          /********************************************/\r
-\r                        DPRINTK("The selected SSI profile length is wrong\n");        
+\r
+                         DPRINTK("The selected SSI profile length is wrong\n");        \r
                          i_ReturnValue = -4;\r
                          }\r
                       }\r
@@ -278,7 +306,8 @@ INT   i_APCI1710_InsnConfigInitSSI(comedi_device *dev,comedi_subdevice *s,
                       /******************************************************/\r
                       /* The selected SSI turn counter data length is wrong */\r
                       /******************************************************/\r
-\r                         DPRINTK("The selected SSI turn counter data length is wrong\n");     
+\r
+                          DPRINTK("The selected SSI turn counter data length is wrong\n");     \r
                       i_ReturnValue = -6;\r
                       }\r
                    }\r
@@ -287,7 +316,8 @@ INT   i_APCI1710_InsnConfigInitSSI(comedi_device *dev,comedi_subdevice *s,
                    /**************************************************/\r
                    /* The selected SSI position data length is wrong */\r
                    /**************************************************/\r
-\r                      DPRINTK("The selected SSI position data length is wrong\n");
+\r
+                       DPRINTK("The selected SSI position data length is wrong\n");\r
                    i_ReturnValue = -5;\r
                    }\r
                 }\r
@@ -296,7 +326,8 @@ INT   i_APCI1710_InsnConfigInitSSI(comedi_device *dev,comedi_subdevice *s,
                 /********************************************/\r
                 /* The selected SSI profile length is wrong */\r
                 /********************************************/\r
-\r               DPRINTK("The selected SSI profile length is wrong\n");
+\r
+                DPRINTK("The selected SSI profile length is wrong\n");\r
                 i_ReturnValue = -4;\r
                 }\r
              }\r
@@ -305,7 +336,8 @@ INT   i_APCI1710_InsnConfigInitSSI(comedi_device *dev,comedi_subdevice *s,
              /**********************************/\r
              /* The module is not a SSI module */\r
              /**********************************/\r
-\r            DPRINTK("The module is not a SSI module\n");      
+\r
+             DPRINTK("The module is not a SSI module\n");      \r
              i_ReturnValue = -3;\r
              }\r
           }\r
@@ -314,7 +346,8 @@ INT   i_APCI1710_InsnConfigInitSSI(comedi_device *dev,comedi_subdevice *s,
           /***********************/\r
           /* Module number error */\r
           /***********************/\r
-\r         DPRINTK("Module number error\n");
+\r
+          DPRINTK("Module number error\n");\r
           i_ReturnValue = -2;\r
           }\r
 \r
@@ -387,15 +420,17 @@ pul_Position      =       (PULONG) &data[0];
        BYTE  b_ReadType;\r
        PULONG pul_Position;\r
        PULONG pul_TurnCpt;\r
-       PULONG pul_Position1;
-       PULONG pul_TurnCpt1;
-
+       PULONG pul_Position1;\r
+       PULONG pul_TurnCpt1;\r
+\r
 \r
        i_ReturnValue   =       insn->n;         \r
-       pul_Position1   =       (PULONG) &data[0];\r// For Read1
-       pul_TurnCpt1    =       (PULONG) &data[1];\r// For Read all
-               pul_Position    =       (PULONG) &data[0];//0-2
-       pul_TurnCpt     =       (PULONG) &data[3];//3-5
+       pul_Position1   =       (PULONG) &data[0];\r
+// For Read1\r
+       pul_TurnCpt1    =       (PULONG) &data[1];\r
+// For Read all\r
+               pul_Position    =       (PULONG) &data[0];//0-2\r
+       pul_TurnCpt     =       (PULONG) &data[3];//3-5\r
        b_ModulNbr              =   (BYTE) CR_AREF(insn->chanspec);\r
        b_SelectedSSI   =       (BYTE) CR_CHAN(insn->chanspec);\r
        b_ReadType              =       (BYTE) CR_RANGE(insn->chanspec);\r
@@ -435,7 +470,8 @@ pul_Position        =       (PULONG) &data[0];
                    /************************/\r
                    /* Start the conversion */\r
                    /************************/\r
-\r\r
+\r
+\r
                        outl(0,devpriv->s_BoardInfos.ui_Address + 8 + (64 * b_ModulNbr));\r
                        \r
 \r
@@ -452,7 +488,7 @@ pul_Position        =       (PULONG) &data[0];
                    /******************************/\r
                    /* Read the SSI counter value */\r
                    /******************************/\r
-               
+               \r
                        dw_CounterValue = inl(devpriv->s_BoardInfos.ui_Address + 4 + (b_SelectedSSI * 4) + (64 * b_ModulNbr));\r
 \r
                    b_Length = devpriv->s_ModuleInfo [b_ModulNbr].s_SSICounterInfo.b_SSIProfile / 2;\r
@@ -498,7 +534,8 @@ pul_Position        =       (PULONG) &data[0];
                    /*****************************/\r
                    /* The selected SSI is wrong */\r
                    /*****************************/\r
-\r                   DPRINTK("The selected SSI is wrong\n");
+\r
+                   DPRINTK("The selected SSI is wrong\n");\r
                    i_ReturnValue = -5;\r
                    }\r
                break;\r
@@ -525,7 +562,7 @@ pul_Position        =       (PULONG) &data[0];
                 /************************/\r
                 /* Start the conversion */\r
                 /************************/\r
-               
+               \r
                 outl(0,devpriv->s_BoardInfos.ui_Address + 8 + (64 * b_ModulNbr));\r
 \r
                 do\r
@@ -582,7 +619,8 @@ pul_Position        =       (PULONG) &data[0];
                 /***********************/\r
                 /* SSI not initialised */\r
                 /***********************/\r
-\r                DPRINTK("SSI not initialised\n");
+\r
+                DPRINTK("SSI not initialised\n");\r
                 i_ReturnValue = -4;\r
                 }\r
              }\r
@@ -591,8 +629,10 @@ pul_Position       =       (PULONG) &data[0];
              /**********************************/\r
              /* The module is not a SSI module */\r
              /**********************************/\r
-\r             DPRINTK("The module is not a SSI module\n");
-             i_ReturnValue = -3;\r 
+\r
+             DPRINTK("The module is not a SSI module\n");\r
+             i_ReturnValue = -3;\r
\r
              }\r
           }\r
        else\r
@@ -600,7 +640,8 @@ pul_Position        =       (PULONG) &data[0];
           /***********************/\r
           /* Module number error */\r
           /***********************/\r
-\r         DPRINTK("Module number error\n");    
+\r
+          DPRINTK("Module number error\n");    \r
           i_ReturnValue = -2;\r
           }\r
 \r
@@ -658,7 +699,7 @@ lsampl_t *data)
        DWORD   dw_StatusReg;\r
        BYTE    b_ModulNbr;\r
        BYTE    b_InputChannel;\r
-       PBYTE   pb_ChannelStatus;
+       PBYTE   pb_ChannelStatus;\r
         PBYTE   pb_InputStatus;\r
        BYTE    b_IOType;\r
        i_ReturnValue = insn->n;\r
@@ -685,7 +726,7 @@ lsampl_t *data)
                                        /* Set the digital output ON */\r
                                        /*****************************/\r
 \r
-                                       
+                                       \r
                    outl(1,devpriv->s_BoardInfos.ui_Address + 16 + (64 * b_ModulNbr));\r
                               break ;\r
 \r
@@ -694,7 +735,7 @@ lsampl_t *data)
                                        /* Set the digital output OFF */\r
                                        /******************************/\r
 \r
-                               
+                               \r
                                   outl(0,devpriv->s_BoardInfos.ui_Address + 16 + (64 * b_ModulNbr));\r
                               break ;\r
                   \r
@@ -708,7 +749,7 @@ lsampl_t *data)
                                        b_InputChannel = (BYTE) CR_CHAN(insn->chanspec);\r
                                        pb_ChannelStatus = (PBYTE) &data[0];\r
 \r
-                                       if ((b_InputChannel >= 0) && (b_InputChannel <= 2))\r
+                                       if (b_InputChannel <= 2)\r
                                        {\r
                                        /**************************/\r
                                        /* Read all digital input */\r
@@ -723,7 +764,8 @@ lsampl_t *data)
                                        /********************************/\r
                                        /* Selected digital input error */\r
                                        /********************************/\r
-\r                           DPRINTK("Selected digital input error\n");
+\r
+                           DPRINTK("Selected digital input error\n");\r
                                        i_ReturnValue = -4;\r
                                        }\r
                                        break;\r
@@ -741,7 +783,7 @@ lsampl_t *data)
 \r
                        default :\r
                                        printk("IO type wrong\n");\r
-
+\r
                 } //switch end\r
              }\r
           else\r
@@ -749,7 +791,8 @@ lsampl_t *data)
              /**********************************/\r
              /* The module is not a SSI module */\r
              /**********************************/\r
-\r            DPRINTK("The module is not a SSI module\n");      
+\r
+             DPRINTK("The module is not a SSI module\n");      \r
              i_ReturnValue = -3;\r
              }\r
           }\r
@@ -758,7 +801,8 @@ lsampl_t *data)
           /***********************/\r
           /* Module number error */\r
           /***********************/\r
-\r         DPRINTK("Module number error\n");
+\r
+          DPRINTK("Module number error\n");\r
           i_ReturnValue = -2;\r
           }\r
 \r
index 918558dd9fddcd8775f857456ea7deebd48e81f8..f5cf48432ee56ccb06054a7b1903cf1e396fb999 100644 (file)
@@ -1,11 +1,33 @@
+/**\r
+@verbatim\r
+\r
+Copyright (C) 2004,2005  ADDI-DATA GmbH for the source code of this module. \r
+        \r
+        ADDI-DATA GmbH \r
+        Dieselstrasse 3 \r
+        D-77833 Ottersweier \r
+        Tel: +19(0)7223/9493-0 \r
+        Fax: +49(0)7223/9493-92 \r
+        http://www.addi-data-com \r
+        info@addi-data.com \r
+\r
+This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.\r
+\r
+This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.\r
+\r
+You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+\r
+You shoud also find the complete GPL in the COPYING file accompanying this source code.\r
+\r
+@endverbatim\r
+*/\r
 \r
-
 \r
 \r
 #define APCI1710_30MHZ           30\r
 #define APCI1710_33MHZ           33\r
 #define APCI1710_40MHZ           40\r
-
+\r
 \r
 #define APCI1710_BINARY_MODE     0x1\r
 #define APCI1710_GRAY_MODE       0x0\r
 INT   i_APCI1710_InsnConfigInitSSI(comedi_device *dev,comedi_subdevice *s,\r
        comedi_insn *insn,lsampl_t *data);\r
 \r
-
+\r
 INT i_APCI1710_InsnReadSSIValue(comedi_device *dev,comedi_subdevice *s,\r
        comedi_insn *insn,lsampl_t *data);\r
 \r
-
+\r
 \r
 INT    i_APCI1710_InsnBitsSSIDigitalIO(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,\r
 lsampl_t *data);\r
 \r
-
+\r
 \r
index bc06967ba2d18833d0e179857241a4177c761d4e..dbebeeefa3f4a61c96909e9bde3be602bd02d161 100644 (file)
@@ -1,14 +1,38 @@
+/**\r
+@verbatim\r
+\r
+Copyright (C) 2004,2005  ADDI-DATA GmbH for the source code of this module. \r
+        \r
+        ADDI-DATA GmbH \r
+        Dieselstrasse 3 \r
+        D-77833 Ottersweier \r
+        Tel: +19(0)7223/9493-0 \r
+        Fax: +49(0)7223/9493-92 \r
+        http://www.addi-data-com \r
+        info@addi-data.com \r
+\r
+This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.\r
+\r
+This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.\r
+\r
+You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+\r
+You shoud also find the complete GPL in the COPYING file accompanying this source code.\r
+\r
+@endverbatim\r
+*/\r
 /*\r
+    \r
   +-----------------------------------------------------------------------+\r
   | (C) ADDI-DATA GmbH          Dieselstraße 3       D-77833 Ottersweier  |\r
   +-----------------------------------------------------------------------+\r
   | Tel : +49 (0) 7223/9493-0     | email    : info@addi-data.com         |\r
   | Fax : +49 (0) 7223/9493-92    | Internet : http://www.addi-data.com   |\r
   +-----------------------------------------------------------------------+\r
-  | Project   : API APCI1710      |     Compiler   : BORLANDC/MICROSOFT C |\r
-  | Module name : TOR.C           |     Version    : 3.1     / 6.0        |\r
+  | Project     : API APCI1710    | Compiler : gcc                        |\r
+  | Module name : TOR.C           | Version  : 2.96                       |\r
   +-------------------------------+---------------------------------------+\r
-  | Author    : S.WEBER           |     Date       : 14.12.98             |\r
+  | Project manager: Eric Stolz   | Date     :  02/12/2002                |\r
   +-----------------------------------------------------------------------+\r
   | Description :   APCI-1710 tor counter module                          |\r
   |                                                                       |\r
 +----------------------------------------------------------------------------+\r
 */\r
 \r
-
+\r
 \r
 INT   i_APCI1710_InsnConfigInitTorCounter(comedi_device *dev,comedi_subdevice *s,\r
        comedi_insn *insn,lsampl_t *data)\r
        {\r
        INT    i_ReturnValue = 0;\r
-       ULONG ul_TimerValue;\r
+       ULONG ul_TimerValue  = 0;\r
        DWORD dw_Command;\r
-       double d_RealTimingInterval;\r
+       double d_RealTimingInterval = 0;\r
        BYTE     b_ModulNbr;\r
        BYTE     b_TorCounter;\r
        BYTE     b_PCIInputClock;\r
        BYTE     b_TimingUnit;\r
        ULONG    ul_TimingInterval;\r
-       ULONG   ul_RealTimingInterval;\r
+       ULONG   ul_RealTimingInterval = 0;\r
 \r
        i_ReturnValue                   =   insn->n;\r
        b_ModulNbr                              =   (BYTE)  CR_AREF(insn->chanspec);\r
@@ -133,7 +157,7 @@ INT   i_APCI1710_InsnConfigInitTorCounter(comedi_device *dev,comedi_subdevice *s
        b_PCIInputClock                 =       (BYTE)  data[1];\r
        b_TimingUnit                    =       (BYTE)  data[2];\r
        ul_TimingInterval               =       (ULONG) data[3];\r
-       printk("INPUT clock %d\n",b_PCIInputClock);
+       printk("INPUT clock %d\n",b_PCIInputClock);\r
        \r
                /**************************/\r
                /* Test the module number */\r
@@ -152,7 +176,7 @@ INT   i_APCI1710_InsnConfigInitTorCounter(comedi_device *dev,comedi_subdevice *s
              /* Test the tor counter selection */\r
              /**********************************/\r
 \r
-             if (b_TorCounter >= 0 && b_TorCounter <= 1)\r
+             if (b_TorCounter <= 1)\r
                 {\r
                 /**************************/\r
                 /* Test the PCI bus clock */\r
@@ -167,7 +191,7 @@ INT   i_APCI1710_InsnConfigInitTorCounter(comedi_device *dev,comedi_subdevice *s
                    /* Test the timing unit */\r
                    /************************/\r
 \r
-                   if (((b_TimingUnit >= 0) && (b_TimingUnit <= 4)) || (b_PCIInputClock == APCI1710_GATE_INPUT))\r
+                   if ((b_TimingUnit <= 4) || (b_PCIInputClock == APCI1710_GATE_INPUT))\r
                       {\r
                       /**********************************/\r
                       /* Test the base timing selection */\r
@@ -194,18 +218,18 @@ INT   i_APCI1710_InsnConfigInitTorCounter(comedi_device *dev,comedi_subdevice *s
                                /* Test the board version */\r
                                /**************************/\r
 \r
-                         if ((b_PCIInputClock == APCI1710_40MHZ) && (devpriv->s_BoardInfos.\r
-                                                                     b_BoardVersion > 0) ||\r
+                         if (((b_PCIInputClock == APCI1710_40MHZ) && (devpriv->s_BoardInfos.\r
+                                                                     b_BoardVersion > 0)) ||\r
                              (b_PCIInputClock != APCI1710_40MHZ))\r
                             {\r
                             /************************/\r
                             /* Test the TOR version */\r
                             /************************/\r
 \r
-                            if ((b_PCIInputClock == APCI1710_40MHZ) && ((devpriv->s_BoardInfos.\r
-                                                                         dw_MolduleConfiguration [b_ModulNbr] & 0xFFFF) >= 0x3131) ||\r
-                                (b_PCIInputClock == APCI1710_GATE_INPUT) && ((devpriv->s_BoardInfos.\r
-                                                                              dw_MolduleConfiguration [b_ModulNbr] & 0xFFFF) >= 0x3132) ||\r
+                            if (((b_PCIInputClock == APCI1710_40MHZ) && ((devpriv->s_BoardInfos.\r
+                                                                         dw_MolduleConfiguration [b_ModulNbr] & 0xFFFF) >= 0x3131)) ||\r
+                                ((b_PCIInputClock == APCI1710_GATE_INPUT) && ((devpriv->s_BoardInfos.\r
+                                                                              dw_MolduleConfiguration [b_ModulNbr] & 0xFFFF) >= 0x3132)) ||\r
                                 (b_PCIInputClock == APCI1710_30MHZ) ||\r
                                 (b_PCIInputClock == APCI1710_33MHZ))\r
                                {\r
@@ -215,6 +239,7 @@ INT   i_APCI1710_InsnConfigInitTorCounter(comedi_device *dev,comedi_subdevice *s
 \r
                                if (b_PCIInputClock != APCI1710_GATE_INPUT)\r
                                   {\r
+                                  fpu_begin ();\r
                                   /****************************************/\r
                                   /* Calculate the timer 0 division fator */\r
                                   /****************************************/\r
@@ -440,6 +465,8 @@ INT   i_APCI1710_InsnConfigInitTorCounter(comedi_device *dev,comedi_subdevice *s
                                           \r
                                           break;\r
                                      }\r
+                                     \r
+                                  fpu_end ();\r
                                   } // if (b_PCIInputClock != APCI1710_GATE_INPUT)\r
                                else\r
                                   {\r
@@ -483,7 +510,7 @@ INT   i_APCI1710_InsnConfigInitTorCounter(comedi_device *dev,comedi_subdevice *s
                                /* Get the command */\r
                                /*******************/\r
 \r
-                               
+                               \r
                                dw_Command = inl(devpriv->s_BoardInfos.ui_Address + 4 + (16 * b_TorCounter) + (64 * b_ModulNbr));\r
 \r
                                dw_Command = (dw_Command >> 4) & 0xF;\r
@@ -548,7 +575,8 @@ INT   i_APCI1710_InsnConfigInitTorCounter(comedi_device *dev,comedi_subdevice *s
                                /***********************************************/\r
                                /* TOR version error for 40MHz clock selection */\r
                                /***********************************************/\r
-\r                       DPRINTK("TOR version error for 40MHz clock selection\n");
+\r
+                       DPRINTK("TOR version error for 40MHz clock selection\n");\r
                                i_ReturnValue = -9;\r
                                }\r
                             }\r
@@ -557,7 +585,8 @@ INT   i_APCI1710_InsnConfigInitTorCounter(comedi_device *dev,comedi_subdevice *s
                             /**************************************************************/\r
                             /* You can not used the 40MHz clock selection wich this board */\r
                             /**************************************************************/\r
-\r                               DPRINTK("You can not used the 40MHz clock selection wich this board\n");
+\r
+                                DPRINTK("You can not used the 40MHz clock selection wich this board\n");\r
                             i_ReturnValue = -8;\r
                             }\r
                          }\r
@@ -566,7 +595,8 @@ INT   i_APCI1710_InsnConfigInitTorCounter(comedi_device *dev,comedi_subdevice *s
                          /**********************************/\r
                          /* Base timing selection is wrong */\r
                          /**********************************/\r
-\r                        DPRINTK("Base timing selection is wrong\n");
+\r
+                         DPRINTK("Base timing selection is wrong\n");\r
                          i_ReturnValue = -7;\r
                          }\r
                       } // if ((b_TimingUnit >= 0) && (b_TimingUnit <= 4))\r
@@ -575,7 +605,8 @@ INT   i_APCI1710_InsnConfigInitTorCounter(comedi_device *dev,comedi_subdevice *s
                       /**********************************/\r
                       /* Timing unit selection is wrong */\r
                       /**********************************/\r
-\r                         DPRINTK("Timing unit selection is wrong\n");          
+\r
+                          DPRINTK("Timing unit selection is wrong\n");          \r
                       i_ReturnValue = -6;\r
                       } // if ((b_TimingUnit >= 0) && (b_TimingUnit <= 4))\r
                    } // if ((b_PCIInputClock == APCI1710_30MHZ) || (b_PCIInputClock == APCI1710_33MHZ))\r
@@ -584,7 +615,8 @@ INT   i_APCI1710_InsnConfigInitTorCounter(comedi_device *dev,comedi_subdevice *s
                    /*****************************************/\r
                    /* The selected PCI input clock is wrong */\r
                    /*****************************************/\r
-\r                      DPRINTK("The selected PCI input clock is wrong\n");
+\r
+                       DPRINTK("The selected PCI input clock is wrong\n");\r
                    i_ReturnValue = -5;\r
                    } // if ((b_PCIInputClock == APCI1710_30MHZ) || (b_PCIInputClock == APCI1710_33MHZ))\r
                 } // if (b_TorCounterMode >= 0 && b_TorCounterMode <= 7)\r
@@ -593,7 +625,8 @@ INT   i_APCI1710_InsnConfigInitTorCounter(comedi_device *dev,comedi_subdevice *s
                 /**********************************/\r
                 /* Tor Counter selection is wrong */\r
                 /**********************************/\r
-\r               DPRINTK("Tor Counter selection is wrong\n");
+\r
+                DPRINTK("Tor Counter selection is wrong\n");\r
                 i_ReturnValue = -4;\r
                 } // if (b_TorCounterMode >= 0 && b_TorCounterMode <= 7)\r
              }\r
@@ -602,7 +635,8 @@ INT   i_APCI1710_InsnConfigInitTorCounter(comedi_device *dev,comedi_subdevice *s
              /******************************************/\r
              /* The module is not a tor counter module */\r
              /******************************************/\r
-\r            DPRINTK("The module is not a tor counter module\n");              
+\r
+             DPRINTK("The module is not a tor counter module\n");              \r
              i_ReturnValue = -3;\r
              }\r
           }\r
@@ -611,7 +645,8 @@ INT   i_APCI1710_InsnConfigInitTorCounter(comedi_device *dev,comedi_subdevice *s
           /***********************/\r
           /* Module number error */\r
           /***********************/\r
-\r          DPRINTK("Module number error\n");
+\r
+          DPRINTK("Module number error\n");\r
           i_ReturnValue = -2;\r
           }\r
     data[0] = (UINT) ul_RealTimingInterval;\r
@@ -748,7 +783,7 @@ INT   i_APCI1710_InsnConfigInitTorCounter(comedi_device *dev,comedi_subdevice *s
 */\r
 \r
 \r
-
+\r
 INT  i_APCI1710_InsnWriteEnableDisableTorCounter (comedi_device *dev,comedi_subdevice *s,\r
        comedi_insn *insn,lsampl_t *data)\r
        {\r
@@ -789,7 +824,7 @@ INT  i_APCI1710_InsnWriteEnableDisableTorCounter (comedi_device *dev,comedi_subd
              /* Test the tor counter selection */\r
              /**********************************/\r
 \r
-             if (b_TorCounter >= 0 && b_TorCounter <= 1)\r
+             if (b_TorCounter <= 1)\r
                 {\r
           switch(b_Action)// Enable or Disable\r
                  {\r
@@ -798,7 +833,7 @@ INT  i_APCI1710_InsnWriteEnableDisableTorCounter (comedi_device *dev,comedi_subd
                 /* Test if tor counter initialised */\r
                 /***********************************/\r
 \r
-               
+               \r
 \r
                dw_Status =inl(devpriv->s_BoardInfos.ui_Address + 8 + (16 * b_TorCounter) + (64 * b_ModulNbr));\r
 \r
@@ -833,8 +868,8 @@ INT  i_APCI1710_InsnWriteEnableDisableTorCounter (comedi_device *dev,comedi_subd
                             if ((b_InterruptEnable == APCI1710_ENABLE) || (b_InterruptEnable == APCI1710_DISABLE))\r
                                {\r
 \r
-                               
-                               
+                               \r
+                               \r
                                   /***************************/\r
                                   /* Save the interrupt mode */\r
                                   /***************************/\r
@@ -848,7 +883,7 @@ INT  i_APCI1710_InsnWriteEnableDisableTorCounter (comedi_device *dev,comedi_subd
                                   /* Get the command */\r
                                   /*******************/\r
 \r
-                                 
+                                 \r
                                   dw_ConfigReg = inl(devpriv->s_BoardInfos.ui_Address + 4 + (16 * b_TorCounter) + (64 * b_ModulNbr));\r
 \r
                                   dw_ConfigReg = (dw_ConfigReg >> 4) & 0x30;\r
@@ -928,25 +963,26 @@ INT  i_APCI1710_InsnWriteEnableDisableTorCounter (comedi_device *dev,comedi_subd
                                   /* Set the commando */\r
                                   /********************/\r
 \r
-
+\r
                                        outl(dw_ConfigReg,devpriv->s_BoardInfos.\r
                                                ui_Address + 4 + (16 * b_TorCounter) + (64 * b_ModulNbr));\r
 \r
                                   /****************/\r
                                   /* Set the gate */\r
                                   /****************/\r
-                               
+                               \r
 \r
                                        outl(1,devpriv->s_BoardInfos.\r
                                           ui_Address + 8 + (16 * b_TorCounter) + (64 * b_ModulNbr));\r
-                                  
+                                  \r
                                } // if ((b_InterruptEnable == APCI1710_ENABLE) || (b_InterruptEnable == APCI1710_DISABLE))\r
                             else\r
                                {\r
                                /********************************/\r
                                /* Interrupt parameter is wrong */\r
                                /********************************/\r
-\r                              DPRINTK("Interrupt parameter is wrong\n");
+\r
+                               DPRINTK("Interrupt parameter is wrong\n");\r
                                i_ReturnValue = -9;\r
                                } // if ((b_InterruptEnable == APCI1710_ENABLE) || (b_InterruptEnable == APCI1710_DISABLE))\r
                             } // if ((b_CycleMode == APCI1710_SINGLE) || (b_CycleMode == APCI1710_CONTINUOUS))\r
@@ -955,7 +991,8 @@ INT  i_APCI1710_InsnWriteEnableDisableTorCounter (comedi_device *dev,comedi_subd
                             /***********************************************/\r
                             /* Tor counter acquisition mode cycle is wrong */\r
                             /***********************************************/\r
-\r                               DPRINTK("Tor counter acquisition mode cycle is wrong\n");
+\r
+                                DPRINTK("Tor counter acquisition mode cycle is wrong\n");\r
                             i_ReturnValue = -8;\r
                             } // if ((b_CycleMode == APCI1710_SINGLE) || (b_CycleMode == APCI1710_CONTINUOUS))\r
                          } // if (b_ExternGate >= 0 && b_ExternGate <= 1)\r
@@ -964,7 +1001,8 @@ INT  i_APCI1710_InsnWriteEnableDisableTorCounter (comedi_device *dev,comedi_subd
                          /***********************************/\r
                          /* Extern gate input mode is wrong */\r
                          /***********************************/\r
-\r                        DPRINTK("Extern gate input mode is wrong\n");
+\r
+                         DPRINTK("Extern gate input mode is wrong\n");\r
                          i_ReturnValue = -7;\r
                          } // if (b_ExternGate >= 0 && b_ExternGate <= 1)\r
                       } // if (b_InputMode >= 0 && b_InputMode <= 1)\r
@@ -973,7 +1011,8 @@ INT  i_APCI1710_InsnWriteEnableDisableTorCounter (comedi_device *dev,comedi_subd
                       /***************************************/\r
                       /* Tor input signal selection is wrong */\r
                       /***************************************/\r
-\r                         DPRINTK("Tor input signal selection is wrong\n");
+\r
+                          DPRINTK("Tor input signal selection is wrong\n");\r
                       i_ReturnValue = -6;\r
                       }\r
                    }\r
@@ -982,7 +1021,8 @@ INT  i_APCI1710_InsnWriteEnableDisableTorCounter (comedi_device *dev,comedi_subd
                    /*******************************/\r
                    /* Tor counter not initialised */\r
                    /*******************************/\r
-\r                      DPRINTK("Tor counter not initialised\n");
+\r
+                       DPRINTK("Tor counter not initialised\n");\r
                    i_ReturnValue = -5;\r
                    }\r
                 break;\r
@@ -991,7 +1031,7 @@ INT  i_APCI1710_InsnWriteEnableDisableTorCounter (comedi_device *dev,comedi_subd
                         /***********************************/\r
                 /* Test if tor counter initialised */\r
                 /***********************************/\r
-               
+               \r
                        dw_Status = inl(devpriv->s_BoardInfos.\r
                        ui_Address + 8 + (16 * b_TorCounter) + (64 * b_ModulNbr));\r
 \r
@@ -1027,7 +1067,8 @@ INT  i_APCI1710_InsnWriteEnableDisableTorCounter (comedi_device *dev,comedi_subd
                       /***************************/\r
                       /* Tor counter not enabled */\r
                       /***************************/\r
-\r                              DPRINTK("Tor counter not enabled \n");
+\r
+                               DPRINTK("Tor counter not enabled \n");\r
                       i_ReturnValue = -6;\r
                       } // if (dw_Status & 0x1)\r
                    } // if (dw_Status & 0x10)\r
@@ -1036,29 +1077,32 @@ INT  i_APCI1710_InsnWriteEnableDisableTorCounter (comedi_device *dev,comedi_subd
                    /*******************************/\r
                    /* Tor counter not initialised */\r
                    /*******************************/\r
-\r                      DPRINTK("Tor counter not initialised\n");       
+\r
+                       DPRINTK("Tor counter not initialised\n");       \r
                    i_ReturnValue = -5;\r
                    } // // if (dw_Status & 0x10)\r
                 \r
 \r
 \r
                 } // switch\r
-               } // if (b_TorCounter >= 0 && b_TorCounter <= 1)\r
+               } // if (b_TorCounter <= 1)\r
              else\r
                 {\r
                 /**********************************/\r
                 /* Tor counter selection is wrong */\r
                 /**********************************/\r
-\r                DPRINTK("Tor counter selection is wrong\n");  
+\r
+                DPRINTK("Tor counter selection is wrong\n");   \r
                 i_ReturnValue = -4;\r
-                } // if (b_TorCounter >= 0 && b_TorCounter <= 1)\r
+                } // if (b_TorCounter <= 1)\r
              }\r
           else\r
              {\r
              /******************************************/\r
              /* The module is not a tor counter module */\r
              /******************************************/\r
-\r            DPRINTK("The module is not a tor counter module \n");     
+\r
+             DPRINTK("The module is not a tor counter module \n");     \r
              i_ReturnValue = -3;\r
              }\r
           }\r
@@ -1067,7 +1111,8 @@ INT  i_APCI1710_InsnWriteEnableDisableTorCounter (comedi_device *dev,comedi_subd
           /***********************/\r
           /* Module number error */\r
           /***********************/\r
-\r         DPRINTK("Module number error \n");   
+\r
+          DPRINTK("Module number error \n");   \r
           i_ReturnValue = -2;\r
           }\r
 \r
@@ -1158,7 +1203,7 @@ INT  i_APCI1710_InsnWriteEnableDisableTorCounter (comedi_device *dev,comedi_subd
 |                         "i_APCI1710_InitTorCounter"                        |\r
 +----------------------------------------------------------------------------+\r
 */\r
-
+\r
 \r
 INT i_APCI1710_InsnReadGetTorCounterInitialisation(comedi_device *dev,comedi_subdevice *s,\r
        comedi_insn *insn,lsampl_t *data)\r
@@ -1204,7 +1249,7 @@ INT i_APCI1710_InsnReadGetTorCounterInitialisation(comedi_device *dev,comedi_sub
              /* Test the tor counter selection */\r
              /**********************************/\r
 \r
-             if (b_TorCounter >= 0 && b_TorCounter <= 1)\r
+             if (b_TorCounter <= 1)\r
                 {\r
           \r
                  \r
@@ -1212,7 +1257,7 @@ INT i_APCI1710_InsnReadGetTorCounterInitialisation(comedi_device *dev,comedi_sub
                 /* Test if tor counter initialised */\r
                 /***********************************/\r
 \r
-               
+               \r
                        dw_Status = inl(devpriv->s_BoardInfos.\r
                        ui_Address + 8 + (16 * b_TorCounter) + (64 * b_ModulNbr));\r
 \r
@@ -1225,7 +1270,7 @@ INT i_APCI1710_InsnReadGetTorCounterInitialisation(comedi_device *dev,comedi_sub
                    /* Get the commando */\r
                    /********************/\r
 \r
-               
+               \r
                         dw_Status=inl(devpriv->s_BoardInfos.\r
                           ui_Address + 4 + (16 * b_TorCounter) + (64 * b_ModulNbr));\r
 \r
@@ -1303,26 +1348,29 @@ INT i_APCI1710_InsnReadGetTorCounterInitialisation(comedi_device *dev,comedi_sub
                    /*******************************/\r
                    /* Tor counter not initialised */\r
                    /*******************************/\r
-\r                      DPRINTK("Tor counter not initialised\n");
+\r
+                       DPRINTK("Tor counter not initialised\n");\r
                    i_ReturnValue = -5;\r
                    }\r
                   \r
-                } // if (b_TorCounter >= 0 && b_TorCounter <= 1)\r
+                } // if (b_TorCounter <= 1)\r
              else\r
                 {\r
                 /**********************************/\r
                 /* Tor counter selection is wrong */\r
                 /**********************************/\r
-\r               DPRINTK("Tor counter selection is wrong \n");
+\r
+                DPRINTK("Tor counter selection is wrong \n");\r
                 i_ReturnValue = -4;\r
-                } // if (b_TorCounter >= 0 && b_TorCounter <= 1)\r
+                } // if (b_TorCounter <= 1)\r
              }\r
           else\r
              {\r
              /******************************************/\r
              /* The module is not a tor counter module */\r
              /******************************************/\r
-\r             DPRINTK("The module is not a tor counter module\n");
+\r
+             DPRINTK("The module is not a tor counter module\n");\r
              i_ReturnValue = -3;\r
              }\r
           }\r
@@ -1331,7 +1379,8 @@ INT i_APCI1710_InsnReadGetTorCounterInitialisation(comedi_device *dev,comedi_sub
           /***********************/\r
           /* Module number error */\r
           /***********************/\r
-\r          DPRINTK("Module number error\n");
+\r
+          DPRINTK("Module number error\n");\r
           i_ReturnValue = -2;\r
           }\r
 \r
@@ -1411,7 +1460,7 @@ INT i_APCI1710_InsnBitsGetTorCounterProgressStatusAndValue(comedi_device *dev,co
 \r
        BYTE    b_ModulNbr;\r
        BYTE    b_TorCounter;\r
-       BYTE    b_ReadType;
+       BYTE    b_ReadType;\r
        UINT    ui_TimeOut;\r
        PBYTE   pb_TorCounterStatus;\r
        PULONG  pul_TorCounterValue;\r
@@ -1427,37 +1476,37 @@ INT i_APCI1710_InsnBitsGetTorCounterProgressStatusAndValue(comedi_device *dev,co
        /**************************/\r
        /* Test the module number */\r
        /**************************/\r
-
-
-        if(b_ReadType==APCI1710_TOR_READINTERRUPT)
-        {
-         
-                       data[0]=devpriv->s_InterruptParameters.
-                                                     s_FIFOInterruptParameters [devpriv->
-                                                                                s_InterruptParameters.
-                                                                                ui_Read].b_OldModuleMask;
-                       data[1]=devpriv->s_InterruptParameters.
-                                                     s_FIFOInterruptParameters [devpriv->
-                                                                                s_InterruptParameters.
-                                                                                ui_Read].ul_OldInterruptMask;
-                       data[2]=devpriv->s_InterruptParameters.
-                                                     s_FIFOInterruptParameters [devpriv->
-                                                                                s_InterruptParameters.
-                                                                                ui_Read].ul_OldCounterLatchValue;
-
-                            
-                          /**************************/
-                          /* Increment the read FIFO */
-                          /***************************/
-
-                          devpriv->
-                          s_InterruptParameters.
-                          ui_Read = (devpriv->
-                          s_InterruptParameters.
-                          ui_Read + 1) % APCI1710_SAVE_INTERRUPT;
-         return insn->n;
-        } 
+\r
+\r
+        if(b_ReadType==APCI1710_TOR_READINTERRUPT)\r
+        {\r
+         \r
+                       data[0]=devpriv->s_InterruptParameters.\r
+                                                     s_FIFOInterruptParameters [devpriv->\r
+                                                                                s_InterruptParameters.\r
+                                                                                ui_Read].b_OldModuleMask;\r
+                       data[1]=devpriv->s_InterruptParameters.\r
+                                                     s_FIFOInterruptParameters [devpriv->\r
+                                                                                s_InterruptParameters.\r
+                                                                                ui_Read].ul_OldInterruptMask;\r
+                       data[2]=devpriv->s_InterruptParameters.\r
+                                                     s_FIFOInterruptParameters [devpriv->\r
+                                                                                s_InterruptParameters.\r
+                                                                                ui_Read].ul_OldCounterLatchValue;\r
+\r
+                            \r
+                          /**************************/\r
+                          /* Increment the read FIFO */\r
+                          /***************************/\r
+\r
+                          devpriv->\r
+                          s_InterruptParameters.\r
+                          ui_Read = (devpriv->\r
+                          s_InterruptParameters.\r
+                          ui_Read + 1) % APCI1710_SAVE_INTERRUPT;\r
\r
+         return insn->n;\r
+        } \r
 \r
        if (b_ModulNbr < 4)\r
           {\r
@@ -1472,14 +1521,14 @@ INT i_APCI1710_InsnBitsGetTorCounterProgressStatusAndValue(comedi_device *dev,co
              /* Test the tor counter selection */\r
              /**********************************/\r
 \r
-             if (b_TorCounter >= 0 && b_TorCounter <= 1)\r
+             if (b_TorCounter <= 1)\r
                 {\r
                 /***********************************/\r
                 /* Test if tor counter initialised */\r
                 /***********************************/\r
 \r
                \r
-
+\r
                        dw_Status=inl(devpriv->s_BoardInfos.\r
                        ui_Address + 8 + (16 * b_TorCounter) + (64 * b_ModulNbr));\r
 \r
@@ -1498,7 +1547,7 @@ INT i_APCI1710_InsnBitsGetTorCounterProgressStatusAndValue(comedi_device *dev,co
                   \r
                                switch(b_ReadType)\r
                                {\r
-
+\r
                                case APCI1710_TOR_GETPROGRESSSTATUS:\r
                        /*******************/\r
                       /* Read the status */\r
@@ -1566,7 +1615,7 @@ INT i_APCI1710_InsnBitsGetTorCounterProgressStatusAndValue(comedi_device *dev,co
                             /*******************/\r
                             /* Read the status */\r
                             /*******************/\r
-                               
+                               \r
                                dw_Status=inl(devpriv->s_BoardInfos.\r
                                    ui_Address + 4 + (16 * b_TorCounter) + (64 * b_ModulNbr));\r
                             /********************/\r
@@ -1607,7 +1656,8 @@ INT i_APCI1710_InsnBitsGetTorCounterProgressStatusAndValue(comedi_device *dev,co
                                   /******************/\r
                                   /* Read the value */\r
                                   /******************/\r
-\r\r
+\r
+\r
                                     *pul_TorCounterValue=inl(devpriv->s_BoardInfos.\r
                                          ui_Address + 0 + (16 * b_TorCounter) + (64 * b_ModulNbr));\r
 \r
@@ -1676,12 +1726,13 @@ INT i_APCI1710_InsnBitsGetTorCounterProgressStatusAndValue(comedi_device *dev,co
                          /******************************/\r
                          /* Timeout parameter is wrong */\r
                          /******************************/\r
-\r                     DPRINTK("Timeout parameter is wrong\n");
+\r
+                     DPRINTK("Timeout parameter is wrong\n");\r
                          i_ReturnValue = -7;\r
                          }\r
                           break;\r
-
-           
+\r
+           \r
              default:\r
                                 printk("Inputs wrong\n");\r
                        } // switch end\r
@@ -1691,7 +1742,8 @@ INT i_APCI1710_InsnBitsGetTorCounterProgressStatusAndValue(comedi_device *dev,co
                       /***************************/\r
                       /* Tor counter not enabled */\r
                       /***************************/\r
-\r                         DPRINTK("Tor counter not enabled\n");
+\r
+                          DPRINTK("Tor counter not enabled\n");\r
                       i_ReturnValue = -6;\r
                       } // if (dw_Status & 0x1)\r
                    }\r
@@ -1700,25 +1752,28 @@ INT i_APCI1710_InsnBitsGetTorCounterProgressStatusAndValue(comedi_device *dev,co
                    /*******************************/\r
                    /* Tor counter not initialised */\r
                    /*******************************/\r
-\r                      DPRINTK("Tor counter not initialised\n");
+\r
+                       DPRINTK("Tor counter not initialised\n");\r
                    i_ReturnValue = -5;\r
                    }\r
-                } // if (b_TorCounter >= 0 && b_TorCounter <= 1)\r
+                } // if (b_TorCounter <= 1)\r
              else\r
                 {\r
                 /**********************************/\r
                 /* Tor counter selection is wrong */\r
                 /**********************************/\r
-\r                DPRINTK("Tor counter selection is wrong\n");
+\r
+                 DPRINTK("Tor counter selection is wrong\n");\r
                 i_ReturnValue = -4;\r
-                } // if (b_TorCounter >= 0 && b_TorCounter <= 1)\r
+                } // if (b_TorCounter <= 1)\r
              }\r
           else\r
              {\r
              /******************************************/\r
              /* The module is not a tor counter module */\r
              /******************************************/\r
-\r             DPRINTK("The module is not a tor counter module\n");     
+\r
+              DPRINTK("The module is not a tor counter module\n");     \r
              i_ReturnValue = -3;\r
              }\r
           }\r
@@ -1727,10 +1782,12 @@ INT i_APCI1710_InsnBitsGetTorCounterProgressStatusAndValue(comedi_device *dev,co
           /***********************/\r
           /* Module number error */\r
           /***********************/\r
-\r          DPRINTK("Module number error\n");   
+\r
+           DPRINTK("Module number error\n");   \r
           i_ReturnValue = -2;\r
           }\r
-\r       
+\r
+       \r
        return (i_ReturnValue);\r
        }\r
 \r
index b29d22c10d24a51c860038718864e3cfa3f0ce2f..5a29214f013ee98f8417eb82a4ccf9af3eb33096 100644 (file)
@@ -1,26 +1,50 @@
+/**\r
+@verbatim\r
+\r
+Copyright (C) 2004,2005  ADDI-DATA GmbH for the source code of this module. \r
+        \r
+        ADDI-DATA GmbH \r
+        Dieselstrasse 3 \r
+        D-77833 Ottersweier \r
+        Tel: +19(0)7223/9493-0 \r
+        Fax: +49(0)7223/9493-92 \r
+        http://www.addi-data-com \r
+        info@addi-data.com \r
+\r
+This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.\r
+\r
+This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.\r
+\r
+You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+\r
+You shoud also find the complete GPL in the COPYING file accompanying this source code.\r
+\r
+@endverbatim\r
+*/\r
+\r
+\r
 \r
 \r
-\r\r
    #define APCI1710_30MHZ           30\r
    #define APCI1710_33MHZ           33\r
    #define APCI1710_40MHZ           40\r
-
 \r
-
+\r
+\r
    #define APCI1710_GATE_INPUT 10\r
-
+\r
 \r
 #define APCI1710_TOR_SIMPLE_MODE    2\r
 #define APCI1710_TOR_DOUBLE_MODE    3\r
 #define APCI1710_TOR_QUADRUPLE_MODE 4\r
 \r
-
+\r
 #define APCI1710_SINGLE     0\r
 #define APCI1710_CONTINUOUS 1\r
-
+\r
 \r
 #define APCI1710_TOR_GETPROGRESSSTATUS 0\r
-#define APCI1710_TOR_GETCOUNTERVALUE   1
+#define APCI1710_TOR_GETCOUNTERVALUE   1\r
 #define APCI1710_TOR_READINTERRUPT      2\r
 \r
 \r
 INT   i_APCI1710_InsnConfigInitTorCounter(comedi_device *dev,comedi_subdevice *s,\r
        comedi_insn *insn,lsampl_t *data);\r
 \r
-
+\r
 \r
 \r
 \r
 \r
 INT  i_APCI1710_InsnWriteEnableDisableTorCounter (comedi_device *dev,comedi_subdevice *s,\r
        comedi_insn *insn,lsampl_t *data);\r
-
+\r
 \r
 INT i_APCI1710_InsnReadGetTorCounterInitialisation(comedi_device *dev,comedi_subdevice *s,\r
        comedi_insn *insn,lsampl_t *data);\r
@@ -50,7 +74,7 @@ INT i_APCI1710_InsnReadGetTorCounterInitialisation(comedi_device *dev,comedi_sub
 +----------------------------------------------------------------------------+\r
 */\r
 \r
-
+\r
 \r
 INT i_APCI1710_InsnBitsGetTorCounterProgressStatusAndValue(comedi_device *dev,comedi_subdevice *s,\r
        comedi_insn *insn,lsampl_t *data);\r
index 1307e61ae1eb47903a4c3d508f25be778b3e0827..af98adb80ef209279c8d9f68c72122ebc1bddfc7 100644 (file)
@@ -1,17 +1,38 @@
-
-
-
+/**\r
+@verbatim\r
+\r
+Copyright (C) 2004,2005  ADDI-DATA GmbH for the source code of this module. \r
+        \r
+        ADDI-DATA GmbH \r
+        Dieselstrasse 3 \r
+        D-77833 Ottersweier \r
+        Tel: +19(0)7223/9493-0 \r
+        Fax: +49(0)7223/9493-92 \r
+        http://www.addi-data-com \r
+        info@addi-data.com \r
+\r
+This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.\r
+\r
+This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.\r
+\r
+You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+\r
+You shoud also find the complete GPL in the COPYING file accompanying this source code.\r
+\r
+@endverbatim\r
+*/\r
 /*\r
+    \r
   +-----------------------------------------------------------------------+\r
   | (C) ADDI-DATA GmbH          Dieselstraße 3       D-77833 Ottersweier  |\r
   +-----------------------------------------------------------------------+\r
   | Tel : +49 (0) 7223/9493-0     | email    : info@addi-data.com         |\r
   | Fax : +49 (0) 7223/9493-92    | Internet : http://www.addi-data.com   |\r
   +-----------------------------------------------------------------------+\r
-  | Project   : API APCI1710      |     Compiler   : BORLANDC/MICROSOFT C |\r
-  | Module name : TTL.C           |     Version    : 3.1     / 6.0        |\r
+  | Project     : API APCI1710    | Compiler : gcc                        |\r
+  | Module name : TTL.C           | Version  : 2.96                       |\r
   +-------------------------------+---------------------------------------+\r
-  | Author    : S.WEBER           |     Date       : 04.06.98             |\r
+  | Project manager: Eric Stolz   | Date     :  02/12/2002                |\r
   +-----------------------------------------------------------------------+\r
   | Description :   APCI-1710 TTL I/O module                              |\r
   |                                                                       |\r
@@ -151,7 +172,7 @@ INT   i_APCI1710_InsnConfigInitTTLIO(comedi_device *dev,comedi_subdevice *s,
              /*************************/\r
              /* Set the configuration */\r
              /*************************/\r
-                       
+                       \r
                  outl(0x8,devpriv->s_BoardInfos.ui_Address + 20 + (64 * b_ModulNbr));\r
                        break;\r
 \r
@@ -234,7 +255,7 @@ INT   i_APCI1710_InsnConfigInitTTLIO(comedi_device *dev,comedi_subdevice *s,
                             /* Set the configuration */\r
                             /*************************/\r
 \r
-                            
+                            \r
                                 outl((b_PortAMode << 0) |\r
                                          (b_PortBMode << 1) |\r
                                          (b_PortCMode << 2) |\r
@@ -246,7 +267,8 @@ INT   i_APCI1710_InsnConfigInitTTLIO(comedi_device *dev,comedi_subdevice *s,
                             /**********************************/\r
                             /* Port D mode selection is wrong */\r
                             /**********************************/\r
-\r                        DPRINTK("Port D mode selection is wrong\n");
+\r
+                        DPRINTK("Port D mode selection is wrong\n");\r
                             i_ReturnValue = -8;\r
                             }\r
                          }\r
@@ -255,7 +277,8 @@ INT   i_APCI1710_InsnConfigInitTTLIO(comedi_device *dev,comedi_subdevice *s,
                          /**********************************/\r
                          /* Port C mode selection is wrong */\r
                          /**********************************/\r
-\r                        DPRINTK("Port C mode selection is wrong\n");
+\r
+                         DPRINTK("Port C mode selection is wrong\n");\r
                          i_ReturnValue = -7;\r
                          }\r
                       }\r
@@ -264,7 +287,8 @@ INT   i_APCI1710_InsnConfigInitTTLIO(comedi_device *dev,comedi_subdevice *s,
                       /**********************************/\r
                       /* Port B mode selection is wrong */\r
                       /**********************************/\r
-\r                         DPRINTK("Port B mode selection is wrong\n");
+\r
+                          DPRINTK("Port B mode selection is wrong\n");\r
                       i_ReturnValue = -6;\r
                       }\r
                    }\r
@@ -273,7 +297,8 @@ INT   i_APCI1710_InsnConfigInitTTLIO(comedi_device *dev,comedi_subdevice *s,
                    /**********************************/\r
                    /* Port A mode selection is wrong */\r
                    /**********************************/\r
-\r                      DPRINTK("Port A mode selection is wrong\n");
+\r
+                       DPRINTK("Port A mode selection is wrong\n");\r
                    i_ReturnValue = -5;\r
                    }\r
                 }\r
@@ -282,11 +307,13 @@ INT   i_APCI1710_InsnConfigInitTTLIO(comedi_device *dev,comedi_subdevice *s,
                 /*******************************************/\r
                 /* Function not available for this version */\r
                 /*******************************************/\r
-\r               DPRINTK("Function not available for this version\n");
+\r
+                DPRINTK("Function not available for this version\n");\r
                 i_ReturnValue = -4;\r
                 }\r
                  break;\r
-\r                DPRINTK("\n");
+\r
+                 DPRINTK("\n");\r
                  default:\r
                          printk("Bad Config Type\n");\r
                  }// switch end\r
@@ -296,7 +323,8 @@ INT   i_APCI1710_InsnConfigInitTTLIO(comedi_device *dev,comedi_subdevice *s,
              /**********************************/\r
              /* The module is not a TTL module */\r
              /**********************************/\r
-\r            DPRINTK("The module is not a TTL module\n");
+\r
+             DPRINTK("The module is not a TTL module\n");\r
              i_ReturnValue = -3;\r
              }\r
           }\r
@@ -305,7 +333,8 @@ INT   i_APCI1710_InsnConfigInitTTLIO(comedi_device *dev,comedi_subdevice *s,
           /***********************/\r
           /* Module number error */\r
           /***********************/\r
-\r          DPRINTK("Module number error\n");
+\r
+          DPRINTK("Module number error\n");\r
           i_ReturnValue = -2;\r
           }\r
 \r
@@ -335,7 +364,7 @@ INT   i_APCI1710_InsnConfigInitTTLIO(comedi_device *dev,comedi_subdevice *s,
 | Task              : Read the status from digital input port                |\r
 |                     (b_SelectedPort) from selected TTL module (b_ModulNbr) |\r
 +----------------------------------------------------------------------------+ \r
-
+\r
 +----------------------------------------------------------------------------+\r
 | Input Parameters  : BYTE_ b_BoardHandle         : Handle of board APCI-1710|\r
 |                     BYTE_ b_ModulNbr            : Module number to         |\r
@@ -389,7 +418,7 @@ INT  i_APCI1710_InsnBitsReadTTLIO(comedi_device *dev,comedi_subdevice *s,
        BYTE    b_ReadType;\r
        PBYTE   pb_ChannelStatus;\r
        PBYTE  pb_PortValue;\r
-       
+       \r
                \r
        i_ReturnValue = insn->n;\r
        b_ReadType        = (BYTE) data[0];\r
@@ -422,17 +451,17 @@ INT  i_APCI1710_InsnBitsReadTTLIO(comedi_device *dev,comedi_subdevice *s,
              /* Test the TTL I/O port number */\r
              /********************************/\r
 \r
-             if ((((b_SelectedPort >= 0) && (b_SelectedPort <= 2)) && ((devpriv->s_BoardInfos.\r
-                                                                        dw_MolduleConfiguration [b_ModulNbr] & 0xFFFF) == 0x3130)) ||\r
-                 (((b_SelectedPort >= 0) && (b_SelectedPort <= 3)) && ((devpriv->s_BoardInfos.\r
-                                                                        dw_MolduleConfiguration [b_ModulNbr] & 0xFFFF) >= 0x3230)))\r
+             if (((b_SelectedPort <= 2) && ((devpriv->s_BoardInfos.\r
+                                             dw_MolduleConfiguration [b_ModulNbr] & 0xFFFF) == 0x3130)) ||\r
+                 ((b_SelectedPort <= 3) && ((devpriv->s_BoardInfos.\r
+                                            dw_MolduleConfiguration [b_ModulNbr] & 0xFFFF) >= 0x3230)))\r
                 {\r
                 /******************************************/\r
                 /* Test the digital imnput channel number */\r
                 /******************************************/\r
 \r
-                if ((((b_InputChannel >= 0) && (b_InputChannel <= 7)) && (b_SelectedPort < 3)) ||\r
-                    (((b_InputChannel >= 0) && (b_InputChannel <= 1)) && (b_SelectedPort == 3)))\r
+                if (((b_InputChannel <= 7) && (b_SelectedPort < 3)) ||\r
+                    ((b_InputChannel <= 1) && (b_SelectedPort == 3)))\r
                    {\r
                    /******************************************/\r
                    /* Test if the TTL I/O module initialised */\r
@@ -457,10 +486,10 @@ INT  i_APCI1710_InsnBitsReadTTLIO(comedi_device *dev,comedi_subdevice *s,
                          /**************************/\r
                          /* Read all digital input */\r
                          /**************************/\r
-                       
+                       \r
                                dw_StatusReg = inl(devpriv->s_BoardInfos.ui_Address + (64 * b_ModulNbr));\r
 \r
-                         *pb_ChannelStatus = (BYTE) ((dw_StatusReg >> (8 * b_SelectedPort)) >>
+                         *pb_ChannelStatus = (BYTE) ((dw_StatusReg >> (8 * b_SelectedPort)) >>\r
  b_InputChannel) & 1;\r
                          }\r
                       else\r
@@ -468,7 +497,8 @@ INT  i_APCI1710_InsnBitsReadTTLIO(comedi_device *dev,comedi_subdevice *s,
                          /*******************************/\r
                          /* Selected TTL I/O port error */\r
                          /*******************************/\r
-\r                        DPRINTK("Selected TTL I/O port error\n");
+\r
+                         DPRINTK("Selected TTL I/O port error\n");\r
                          i_ReturnValue = -4;\r
                          }\r
                       }\r
@@ -477,7 +507,8 @@ INT  i_APCI1710_InsnBitsReadTTLIO(comedi_device *dev,comedi_subdevice *s,
                       /***************************/\r
                       /* TTL I/O not initialised */\r
                       /***************************/\r
-\r                         DPRINTK("TTL I/O not initialised\n");        
+\r
+                          DPRINTK("TTL I/O not initialised\n");        \r
                       i_ReturnValue = -6;\r
                       }\r
                    }\r
@@ -486,7 +517,8 @@ INT  i_APCI1710_InsnBitsReadTTLIO(comedi_device *dev,comedi_subdevice *s,
                    /********************************/\r
                    /* Selected digital input error */\r
                    /********************************/\r
-\r                      DPRINTK("Selected digital input error\n");
+\r
+                       DPRINTK("Selected digital input error\n");\r
                    i_ReturnValue = -5;\r
                    }\r
                 }\r
@@ -495,7 +527,8 @@ INT  i_APCI1710_InsnBitsReadTTLIO(comedi_device *dev,comedi_subdevice *s,
                 /*******************************/\r
                 /* Selected TTL I/O port error */\r
                 /*******************************/\r
-\r                DPRINTK("Selected TTL I/O port error\n");
+\r
+                DPRINTK("Selected TTL I/O port error\n");\r
                 i_ReturnValue = -4;\r
                 }\r
                  break;\r
@@ -506,10 +539,10 @@ INT  i_APCI1710_InsnBitsReadTTLIO(comedi_device *dev,comedi_subdevice *s,
                          /* Test the TTL I/O port number */\r
                          /********************************/\r
 \r
-             if ((((b_SelectedPort >= 0) && (b_SelectedPort <= 2)) && ((devpriv->s_BoardInfos.\r
-                                                                        dw_MolduleConfiguration [b_ModulNbr] & 0xFFFF) == 0x3130)) ||\r
-                 (((b_SelectedPort >= 0) && (b_SelectedPort <= 3)) && ((devpriv->s_BoardInfos.\r
-                                                                        dw_MolduleConfiguration [b_ModulNbr] & 0xFFFF) >= 0x3230)))\r
+             if (((b_SelectedPort <= 2) && ((devpriv->s_BoardInfos.\r
+                                             dw_MolduleConfiguration [b_ModulNbr] & 0xFFFF) == 0x3130)) ||\r
+                 ((b_SelectedPort <= 3) && ((devpriv->s_BoardInfos.\r
+                                             dw_MolduleConfiguration [b_ModulNbr] & 0xFFFF) >= 0x3230)))\r
                 {\r
                 /******************************************/\r
                 /* Test if the TTL I/O module initialised */\r
@@ -534,7 +567,7 @@ INT  i_APCI1710_InsnBitsReadTTLIO(comedi_device *dev,comedi_subdevice *s,
                       /**************************/\r
                       /* Read all digital input */\r
                       /**************************/\r
-                               
+                               \r
                                dw_StatusReg=inl(devpriv->s_BoardInfos.ui_Address + (64 * b_ModulNbr));\r
 \r
                       *pb_PortValue = (BYTE) ((dw_StatusReg >> (8 * b_SelectedPort)) & 0xFF);\r
@@ -544,7 +577,8 @@ INT  i_APCI1710_InsnBitsReadTTLIO(comedi_device *dev,comedi_subdevice *s,
                       /*******************************/\r
                       /* Selected TTL I/O port error */\r
                       /*******************************/\r
-\r                      DPRINTK("Selected TTL I/O port error\n");
+\r
+                      DPRINTK("Selected TTL I/O port error\n");\r
                       i_ReturnValue = -4;\r
                       }\r
                    }\r
@@ -553,7 +587,8 @@ INT  i_APCI1710_InsnBitsReadTTLIO(comedi_device *dev,comedi_subdevice *s,
                    /***************************/\r
                    /* TTL I/O not initialised */\r
                    /***************************/\r
-\r                      DPRINTK("TTL I/O not initialised\n");
+\r
+                       DPRINTK("TTL I/O not initialised\n");\r
                    i_ReturnValue = -5;\r
                    }\r
                 }\r
@@ -562,7 +597,8 @@ INT  i_APCI1710_InsnBitsReadTTLIO(comedi_device *dev,comedi_subdevice *s,
                 /*******************************/\r
                 /* Selected TTL I/O port error */\r
                 /*******************************/\r
-\r               DPRINTK("Selected TTL I/O port error\n");      
+\r
+                DPRINTK("Selected TTL I/O port error\n");      \r
                 i_ReturnValue = -4;\r
                 }\r
                  break;\r
@@ -577,7 +613,8 @@ INT  i_APCI1710_InsnBitsReadTTLIO(comedi_device *dev,comedi_subdevice *s,
              /**********************************/\r
              /* The module is not a TTL module */\r
              /**********************************/\r
-\r            DPRINTK("The module is not a TTL module\n");      
+\r
+             DPRINTK("The module is not a TTL module\n");      \r
              i_ReturnValue = -3;\r
              }\r
           }\r
@@ -586,7 +623,8 @@ INT  i_APCI1710_InsnBitsReadTTLIO(comedi_device *dev,comedi_subdevice *s,
           /***********************/\r
           /* Module number error */\r
           /***********************/\r
-\r         DPRINTK("Module number error\n");    
+\r
+          DPRINTK("Module number error\n");    \r
           i_ReturnValue = -2;\r
           }\r
 \r
@@ -594,160 +632,160 @@ INT  i_APCI1710_InsnBitsReadTTLIO(comedi_device *dev,comedi_subdevice *s,
        }\r
 \r
 \r
-
-/*
-+----------------------------------------------------------------------------+
-| Function Name     : INT i_APCI1710_InsnReadTTLIOAllPortValue(comedi_device 
-*dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data)              |
-+----------------------------------------------------------------------------+
-| Task              : Read the status from all digital input ports           |
-|                     (port A, port B and port C) from selected TTL          |
-|                    module (b_ModulNbr)                                    |
-+----------------------------------------------------------------------------+
-| Input Parameters  : BYTE_ b_BoardHandle         : Handle of board APCI-1710|
-|                     BYTE_ b_ModulNbr            : Module number to         |
-|                                                   configure (0 to 3)       |
-+----------------------------------------------------------------------------+
-| Output Parameters : PULONG_  pul_PortValue      : Digital TTL inputs port  |
-|                                                   status                   |
-+----------------------------------------------------------------------------+
-| Return Value      : 0: No error                                            |
-|                    -1: The handle parameter of the board is wrong          |
-|                    -2: The module parameter is wrong                       |
-|                    -3: The module is not a TTL module                      |
-|                    -4: TTL I/O not initialised                             |
-+----------------------------------------------------------------------------+
-*/
-
-INT i_APCI1710_InsnReadTTLIOAllPortValue(comedi_device *dev,comedi_subdevice *s,
-comedi_insn *insn,lsampl_t *data)
-       {
-       INT    i_ReturnValue = 0;
-       DWORD dw_StatusReg;
-       BYTE    b_ModulNbr;
-        PULONG pul_PortValue;
-      
-        b_ModulNbr=(BYTE) CR_AREF(insn->chanspec); 
-        i_ReturnValue=insn->n;
-        pul_PortValue=(PULONG) &data[0]; 
-
-       /**************************/
-       /* Test the module number */
-       /**************************/
-
-       if (b_ModulNbr < 4)
-          {
-          /**************************/
-          /* Test if TTL I/O module */
-          /**************************/
-
-          if ((devpriv->s_BoardInfos.
-               dw_MolduleConfiguration [b_ModulNbr] & 0xFFFF0000UL) == APCI1710_TTL_IO)
-             {
-             /******************************************/
-             /* Test if the TTL I/O module initialised */
-             /******************************************/
-
-             if (devpriv->
-                 s_ModuleInfo [b_ModulNbr].
-                 s_TTLIOInfo.
-                 b_TTLInit == 1)
-                {
-                /**************************/
-                /* Read all digital input */
-                /**************************/
-
-
-                       dw_StatusReg=inl(devpriv->s_BoardInfos.
-                       ui_Address + (64 * b_ModulNbr));
-
-                /**********************/
-                /* Test if TTL Rev1.0 */
-                /**********************/
-
-                if ((devpriv->s_BoardInfos.
-                     dw_MolduleConfiguration [b_ModulNbr] & 0xFFFF) == 0x3130)
-                   {
-                   *pul_PortValue = dw_StatusReg & 0xFFFFFFUL;
-                   }
-                else
-                   {
-                   /**************************************/
-                   /* Test if port A not used for output */
-                   /**************************************/
-
-                   if (devpriv->s_ModuleInfo [b_ModulNbr].
-                       s_TTLIOInfo.b_PortConfiguration [0] == 1)
-                      {
-                      *pul_PortValue = dw_StatusReg & 0x3FFFF00UL;
-                      }
-
-                   /**************************************/
-                   /* Test if port B not used for output */
-                   /**************************************/
-
-                   if (devpriv->
-                       s_ModuleInfo [b_ModulNbr].
-                       s_TTLIOInfo.
-                       b_PortConfiguration [1] == 1)
-                      {
-                      *pul_PortValue = dw_StatusReg & 0x3FF00FFUL;
-                      }
-
-                   /**************************************/
-                   /* Test if port C not used for output */
-                   /**************************************/
-
-                   if (devpriv->
-                       s_ModuleInfo [b_ModulNbr].
-                       s_TTLIOInfo.
-                       b_PortConfiguration [2] == 1)
-                      {
-                      *pul_PortValue = dw_StatusReg & 0x300FFFFUL;
-                      }
-
-                   /**************************************/
-                   /* Test if port D not used for output */
-                   /**************************************/
-
-                   if (devpriv->
-                       s_ModuleInfo [b_ModulNbr].
-                       s_TTLIOInfo.
-                       b_PortConfiguration [3] == 1)
-                      {
-                      *pul_PortValue = dw_StatusReg & 0xFFFFFFUL;
-                      }
-                   }
-                }
-             else
-                {
-                /***************************/
-                /* TTL I/O not initialised */
-                /***************************/
-                DPRINTK("TTL I/O not initialised\n");
-                i_ReturnValue = -5;
-                }
-             }
-          else
-             {
-             /**********************************/
-             /* The module is not a TTL module */
-             /**********************************/
-             DPRINTK("The module is not a TTL module\n");      
-             i_ReturnValue = -3;
-             }
-          }
-       else
-          {
-          /***********************/
-          /* Module number error */
-          /***********************/
-          DPRINTK("Module number error\n");
-          i_ReturnValue = -2;
-          }
-
-       return (i_ReturnValue);
-       }
+\r
+/*\r
++----------------------------------------------------------------------------+\r
+| Function Name     : INT i_APCI1710_InsnReadTTLIOAllPortValue(comedi_device \r
+*dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data)              |\r
++----------------------------------------------------------------------------+\r
+| Task              : Read the status from all digital input ports           |\r
+|                     (port A, port B and port C) from selected TTL          |\r
+|                    module (b_ModulNbr)                                    |\r
++----------------------------------------------------------------------------+\r
+| Input Parameters  : BYTE_ b_BoardHandle         : Handle of board APCI-1710|\r
+|                     BYTE_ b_ModulNbr            : Module number to         |\r
+|                                                   configure (0 to 3)       |\r
++----------------------------------------------------------------------------+\r
+| Output Parameters : PULONG_  pul_PortValue      : Digital TTL inputs port  |\r
+|                                                   status                   |\r
++----------------------------------------------------------------------------+\r
+| Return Value      : 0: No error                                            |\r
+|                    -1: The handle parameter of the board is wrong          |\r
+|                    -2: The module parameter is wrong                       |\r
+|                    -3: The module is not a TTL module                      |\r
+|                    -4: TTL I/O not initialised                             |\r
++----------------------------------------------------------------------------+\r
+*/\r
+\r
+INT i_APCI1710_InsnReadTTLIOAllPortValue(comedi_device *dev,comedi_subdevice *s,\r
+comedi_insn *insn,lsampl_t *data)\r
+       {\r
+       INT    i_ReturnValue = 0;\r
+       DWORD dw_StatusReg;\r
+       BYTE    b_ModulNbr;\r
+        PULONG pul_PortValue;\r
+      \r
+        b_ModulNbr=(BYTE) CR_AREF(insn->chanspec); \r
+        i_ReturnValue=insn->n;\r
+        pul_PortValue=(PULONG) &data[0]; \r
+\r
+       /**************************/\r
+       /* Test the module number */\r
+       /**************************/\r
+\r
+       if (b_ModulNbr < 4)\r
+          {\r
+          /**************************/\r
+          /* Test if TTL I/O module */\r
+          /**************************/\r
+\r
+          if ((devpriv->s_BoardInfos.\r
+               dw_MolduleConfiguration [b_ModulNbr] & 0xFFFF0000UL) == APCI1710_TTL_IO)\r
+             {\r
+             /******************************************/\r
+             /* Test if the TTL I/O module initialised */\r
+             /******************************************/\r
+\r
+             if (devpriv->\r
+                 s_ModuleInfo [b_ModulNbr].\r
+                 s_TTLIOInfo.\r
+                 b_TTLInit == 1)\r
+                {\r
+                /**************************/\r
+                /* Read all digital input */\r
+                /**************************/\r
+\r
+\r
+                       dw_StatusReg=inl(devpriv->s_BoardInfos.\r
+                       ui_Address + (64 * b_ModulNbr));\r
+\r
+                /**********************/\r
+                /* Test if TTL Rev1.0 */\r
+                /**********************/\r
+\r
+                if ((devpriv->s_BoardInfos.\r
+                     dw_MolduleConfiguration [b_ModulNbr] & 0xFFFF) == 0x3130)\r
+                   {\r
+                   *pul_PortValue = dw_StatusReg & 0xFFFFFFUL;\r
+                   }\r
+                else\r
+                   {\r
+                   /**************************************/\r
+                   /* Test if port A not used for output */\r
+                   /**************************************/\r
+\r
+                   if (devpriv->s_ModuleInfo [b_ModulNbr].\r
+                       s_TTLIOInfo.b_PortConfiguration [0] == 1)\r
+                      {\r
+                      *pul_PortValue = dw_StatusReg & 0x3FFFF00UL;\r
+                      }\r
+\r
+                   /**************************************/\r
+                   /* Test if port B not used for output */\r
+                   /**************************************/\r
+\r
+                   if (devpriv->\r
+                       s_ModuleInfo [b_ModulNbr].\r
+                       s_TTLIOInfo.\r
+                       b_PortConfiguration [1] == 1)\r
+                      {\r
+                      *pul_PortValue = dw_StatusReg & 0x3FF00FFUL;\r
+                      }\r
+\r
+                   /**************************************/\r
+                   /* Test if port C not used for output */\r
+                   /**************************************/\r
+\r
+                   if (devpriv->\r
+                       s_ModuleInfo [b_ModulNbr].\r
+                       s_TTLIOInfo.\r
+                       b_PortConfiguration [2] == 1)\r
+                      {\r
+                      *pul_PortValue = dw_StatusReg & 0x300FFFFUL;\r
+                      }\r
+\r
+                   /**************************************/\r
+                   /* Test if port D not used for output */\r
+                   /**************************************/\r
+\r
+                   if (devpriv->\r
+                       s_ModuleInfo [b_ModulNbr].\r
+                       s_TTLIOInfo.\r
+                       b_PortConfiguration [3] == 1)\r
+                      {\r
+                      *pul_PortValue = dw_StatusReg & 0xFFFFFFUL;\r
+                      }\r
+                   }\r
+                }\r
+             else\r
+                {\r
+                /***************************/\r
+                /* TTL I/O not initialised */\r
+                /***************************/\r
+                DPRINTK("TTL I/O not initialised\n");\r
+                i_ReturnValue = -5;\r
+                }\r
+             }\r
+          else\r
+             {\r
+             /**********************************/\r
+             /* The module is not a TTL module */\r
+             /**********************************/\r
+             DPRINTK("The module is not a TTL module\n");      \r
+             i_ReturnValue = -3;\r
+             }\r
+          }\r
+       else\r
+          {\r
+          /***********************/\r
+          /* Module number error */\r
+          /***********************/\r
+          DPRINTK("Module number error\n");\r
+          i_ReturnValue = -2;\r
+          }\r
+\r
+       return (i_ReturnValue);\r
+       }\r
 \r
 /*\r
 +----------------------------------------------------------------------------+\r
@@ -793,7 +831,7 @@ INT i_APCI1710_InsnWriteSetTTLIOChlOnOff(comedi_device *dev,comedi_subdevice *s,
 |                        " i_APCI1710_InitTTLIO"\r
 +----------------------------------------------------------------------------+\r
 */\r
-
+\r
 INT i_APCI1710_InsnWriteSetTTLIOChlOnOff(comedi_device *dev,comedi_subdevice *s,\r
        comedi_insn *insn,lsampl_t *data)\r
        {\r
@@ -833,16 +871,16 @@ INT i_APCI1710_InsnWriteSetTTLIOChlOnOff(comedi_device *dev,comedi_subdevice *s,
                 /* Test the TTL I/O channel number */\r
                 /***********************************/\r
 \r
-                if ((((b_OutputChannel >= 0) && (b_OutputChannel <= 1)) && ((devpriv->s_BoardInfos.\r
-                                                                             dw_MolduleConfiguration [b_ModulNbr] & 0xFFFF) == 0x3130)) ||\r
-                    (((b_OutputChannel >= 0) && (b_OutputChannel <= 25)) && ((devpriv->s_BoardInfos.\r
-                                                                              dw_MolduleConfiguration [b_ModulNbr] & 0xFFFF) >= 0x3230)))\r
+                if (((b_OutputChannel <= 1) && ((devpriv->s_BoardInfos.\r
+                                                dw_MolduleConfiguration [b_ModulNbr] & 0xFFFF) == 0x3130)) ||\r
+                    ((b_OutputChannel <= 25) && ((devpriv->s_BoardInfos.\r
+                                                 dw_MolduleConfiguration [b_ModulNbr] & 0xFFFF) >= 0x3230)))\r
                    {\r
                    /****************************************************/\r
                    /* Test if the selected channel is a output channel */\r
                    /****************************************************/\r
 \r
-                   if (((b_OutputChannel >= 0) && (b_OutputChannel <= 1) && (devpriv->\r
+                   if (((b_OutputChannel <= 1) && (devpriv->\r
                        s_ModuleInfo [b_ModulNbr].\r
                                                                              s_TTLIOInfo.\r
                                                                              b_PortConfiguration [3] == 1)) ||\r
@@ -862,7 +900,7 @@ INT i_APCI1710_InsnWriteSetTTLIOChlOnOff(comedi_device *dev,comedi_subdevice *s,
 \r
                       if (b_OutputChannel == 0)\r
                          {\r
-
+\r
                 outl(ui_State,devpriv->s_BoardInfos.\r
                                  ui_Address + (64 * b_ModulNbr));\r
                          }\r
@@ -886,7 +924,7 @@ INT i_APCI1710_InsnWriteSetTTLIOChlOnOff(comedi_device *dev,comedi_subdevice *s,
                             /* Read all channel */\r
                             /********************/\r
 \r
-                           
+                           \r
                                        dw_StatusReg =inl(devpriv->s_BoardInfos.\r
                                    ui_Address + (64 * b_ModulNbr));\r
                  if(ui_State) // ON\r
@@ -915,7 +953,8 @@ INT i_APCI1710_InsnWriteSetTTLIOChlOnOff(comedi_device *dev,comedi_subdevice *s,
                       /************************************/\r
                       /* The selected TTL output is wrong */\r
                       /************************************/\r
-\r                         DPRINTK(" The selected TTL output is wrong\n");      
+\r
+                          DPRINTK(" The selected TTL output is wrong\n");      \r
                       i_ReturnValue = -4;\r
                       }\r
                    }\r
@@ -924,7 +963,8 @@ INT i_APCI1710_InsnWriteSetTTLIOChlOnOff(comedi_device *dev,comedi_subdevice *s,
                    /************************************/\r
                    /* The selected TTL output is wrong */\r
                    /************************************/\r
-\r                      DPRINTK("The selected TTL output is wrong\n");  
+\r
+                       DPRINTK("The selected TTL output is wrong\n");  \r
                    i_ReturnValue = -4;\r
                    }\r
                 }\r
@@ -933,7 +973,8 @@ INT i_APCI1710_InsnWriteSetTTLIOChlOnOff(comedi_device *dev,comedi_subdevice *s,
                 /***************************/\r
                 /* TTL I/O not initialised */\r
                 /***************************/\r
-\r               DPRINTK("TTL I/O not initialised\n");  
+\r
+                DPRINTK("TTL I/O not initialised\n");  \r
                 i_ReturnValue = -5;\r
                 }\r
              }\r
@@ -942,7 +983,8 @@ INT i_APCI1710_InsnWriteSetTTLIOChlOnOff(comedi_device *dev,comedi_subdevice *s,
              /**************************************/\r
              /* The module is not a TTL I/O module */\r
              /**************************************/\r
-\r            DPRINTK("The module is not a TTL I/O module\n");          
+\r
+             DPRINTK("The module is not a TTL I/O module\n");          \r
              i_ReturnValue = -3;\r
              }\r
           }\r
@@ -951,7 +993,8 @@ INT i_APCI1710_InsnWriteSetTTLIOChlOnOff(comedi_device *dev,comedi_subdevice *s,
           /***********************/\r
           /* Module number error */\r
           /***********************/\r
-\r         DPRINTK("Module number error\n");    
+\r
+          DPRINTK("Module number error\n");    \r
           i_ReturnValue = -2;\r
           }\r
 \r
index f7ecfc0f87258137a42700e738acbcfe4f4265b1..25403ece6e160cce2e24a6a41981cbeade02d793 100644 (file)
@@ -1,6 +1,29 @@
+/**\r
+@verbatim\r
+\r
+Copyright (C) 2004,2005  ADDI-DATA GmbH for the source code of this module. \r
+        \r
+        ADDI-DATA GmbH \r
+        Dieselstrasse 3 \r
+        D-77833 Ottersweier \r
+        Tel: +19(0)7223/9493-0 \r
+        Fax: +49(0)7223/9493-92 \r
+        http://www.addi-data-com \r
+        info@addi-data.com \r
+\r
+This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.\r
+\r
+This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.\r
+\r
+You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+\r
+You shoud also find the complete GPL in the COPYING file accompanying this source code.\r
+\r
+@endverbatim\r
+*/\r
+\r
 \r
 \r
-
 \r
 #define APCI1710_TTL_INIT                      0\r
 #define APCI1710_TTL_INITDIRECTION  1\r
@@ -8,7 +31,7 @@
 \r
 #define APCI1710_TTL_READCHANNEL       0\r
 #define APCI1710_TTL_READPORT          1\r
-
+\r
 \r
 /*\r
 +----------------------------------------------------------------------------+\r
 |                       TTL INPUT FUNCTION                                   |\r
 +----------------------------------------------------------------------------+\r
 */\r
-
+\r
        INT  i_APCI1710_InsnBitsReadTTLIO(comedi_device *dev,comedi_subdevice *s,\r
        comedi_insn *insn,lsampl_t *data);\r
-       INT i_APCI1710_InsnReadTTLIOAllPortValue(comedi_device *dev,comedi_subdevice *s,
-       comedi_insn *insn,lsampl_t *data);
+       INT i_APCI1710_InsnReadTTLIOAllPortValue(comedi_device *dev,comedi_subdevice *s,\r
+       comedi_insn *insn,lsampl_t *data);\r
 /*\r
 +----------------------------------------------------------------------------+\r
 |                            TTL OUTPUT FUNCTIONS                            |\r
diff --git a/comedi/drivers/addi-data/addi_amcc_S5920.c b/comedi/drivers/addi-data/addi_amcc_S5920.c
new file mode 100755 (executable)
index 0000000..305a39f
--- /dev/null
@@ -0,0 +1,185 @@
+/**\r
+@verbatim\r
+\r
+Copyright (C) 2004,2005  ADDI-DATA GmbH for the source code of this module. \r
+        \r
+        ADDI-DATA GmbH \r
+        Dieselstrasse 3 \r
+        D-77833 Ottersweier \r
+        Tel: +19(0)7223/9493-0 \r
+        Fax: +49(0)7223/9493-92 \r
+        http://www.addi-data-com \r
+        info@addi-data.com \r
+\r
+This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.\r
+\r
+This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.\r
+\r
+You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+\r
+You shoud also find the complete GPL in the COPYING file accompanying this source code.\r
+\r
+@endverbatim\r
+*/\r
+/*    \r
+  +-----------------------------------------------------------------------+\r
+  | (C) ADDI-DATA GmbH          Dieselstraße 3       D-77833 Ottersweier  |\r
+  +-----------------------------------------------------------------------+\r
+  | Tel : +49 (0) 7223/9493-0     | email    : info@addi-data.com         |\r
+  | Fax : +49 (0) 7223/9493-92    | Internet : http://www.addi-data.com   |\r
+  +-------------------------------+---------------------------------------+\r
+  | Project : ADDI HEADER READ WRITER |     Compiler   : Visual C++       |\r
+  | Module name : S5920.cpp           |     Version    : 6.0              |\r
+  +-------------------------------+---------------------------------------+\r
+  | Author : E. LIBS                      Date : 02/05/2002               |\r
+  +-----------------------------------------------------------------------+\r
+  | Description   : DLL with the S5920 PCI Controller functions           |\r
+  +-----------------------------------------------------------------------+     \r
+  |                             UPDATE'S                                  |\r
+  +-----------------------------------------------------------------------+\r
+  |   Date   |   Author  |          Description of updates                |\r
+  +----------+-----------+------------------------------------------------+\r
+  | 28/08/02 | LIBS Eric | Add return codes each time a function of the   |\r
+  |          |           | Addi Library is called                         |\r
+  +-----------------------------------------------------------------------+\r
+  | 31/07/03 | KRAUTH J. | Changes for the MSX-Box                        |\r
+  +-----------------------------------------------------------------------+\r
+*/\r
+\r
+\r
+#include "addi_amcc_S5920.h"\r
+\r
+/*+----------------------------------------------------------------------------+*/\r
+/*| Function   Name   : INT i_AddiHeaderRW_ReadEeprom                          |*/\r
+/*|                               (INT    i_NbOfWordsToRead,                   |*/ \r
+/*|                                DWORD dw_PCIBoardEepromAddress,             |*/\r
+/*|                                WORD   w_EepromStartAddress,                |*/\r
+/*|                                PWORD pw_DataRead)                          |*/\r
+/*+----------------------------------------------------------------------------+*/\r
+/*| Task              : Read word from the 5920 eeprom.                        |*/\r
+/*+----------------------------------------------------------------------------+*/\r
+/*| Input Parameters  : INT    i_NbOfWordsToRead : Nbr. of word to read        |*/ \r
+/*|                     DWORD dw_PCIBoardEepromAddress : Address of the eeprom |*/\r
+/*|                     WORD   w_EepromStartAddress : Eeprom strat address     |*/\r
+/*+----------------------------------------------------------------------------+*/\r
+/*| Output Parameters : PWORD pw_DataRead : Read data                          |*/                                                     \r
+/*+----------------------------------------------------------------------------+*/\r
+/*| Return Value      : -                                                      |*/\r
+/*+----------------------------------------------------------------------------+*/\r
+\r
+INT i_AddiHeaderRW_ReadEeprom (INT    i_NbOfWordsToRead,\r
+                               DWORD dw_PCIBoardEepromAddress,\r
+                               WORD   w_EepromStartAddress,\r
+                               PWORD pw_DataRead)\r
+{\r
+   DWORD dw_eeprom_busy=0;    \r
+   INT i_Counter=0;    \r
+   INT i_WordCounter;\r
+   INT i;\r
+   BYTE pb_ReadByte[1];\r
+   BYTE b_ReadLowByte = 0;\r
+   BYTE b_ReadHighByte = 0;\r
+   BYTE b_SelectedAddressLow = 0;\r
+   BYTE b_SelectedAddressHigh = 0;\r
+   WORD w_ReadWord = 0;\r
+   \r
+   for (i_WordCounter = 0;i_WordCounter<i_NbOfWordsToRead;i_WordCounter++)\r
+      {\r
+      do\r
+         {                           \r
+         dw_eeprom_busy = inl (dw_PCIBoardEepromAddress + AMCC_OP_REG_MCSR);\r
+         dw_eeprom_busy=dw_eeprom_busy & EEPROM_BUSY;\r
+         }\r
+      while (dw_eeprom_busy==EEPROM_BUSY);\r
+\r
+      for(i_Counter=0;i_Counter<2;i_Counter++)\r
+        {\r
+        b_SelectedAddressLow=(w_EepromStartAddress+i_Counter) % 256; //Read the low 8 bit part\r
+        b_SelectedAddressHigh=(w_EepromStartAddress+i_Counter)/256;  //Read the high 8 bit part\r
+\r
+        //Select the load low address mode\r
+       outb (NVCMD_LOAD_LOW, dw_PCIBoardEepromAddress+AMCC_OP_REG_MCSR+3);\r
+\r
+        //Wait on busy\r
+        do\r
+        {\r
+            dw_eeprom_busy = inl (dw_PCIBoardEepromAddress + AMCC_OP_REG_MCSR);\r
+            dw_eeprom_busy=dw_eeprom_busy & EEPROM_BUSY;\r
+        }\r
+        while(dw_eeprom_busy==EEPROM_BUSY);\r
+\r
+        //Load the low address\r
+        outb(b_SelectedAddressLow, dw_PCIBoardEepromAddress+AMCC_OP_REG_MCSR+2);\r
+\r
+        //Wait on busy\r
+        do\r
+        {\r
+             dw_eeprom_busy = inl (dw_PCIBoardEepromAddress + AMCC_OP_REG_MCSR);\r
+             dw_eeprom_busy=dw_eeprom_busy & EEPROM_BUSY;\r
+        }\r
+        while(dw_eeprom_busy== EEPROM_BUSY);\r
+\r
+        //Select the load high address mode\r
+        outb(NVCMD_LOAD_HIGH, dw_PCIBoardEepromAddress+AMCC_OP_REG_MCSR+3);\r
+\r
+        //Wait on busy\r
+        do\r
+        {\r
+            dw_eeprom_busy = inl (dw_PCIBoardEepromAddress + AMCC_OP_REG_MCSR);\r
+            dw_eeprom_busy=dw_eeprom_busy & EEPROM_BUSY;\r
+        }\r
+        while(dw_eeprom_busy== EEPROM_BUSY);\r
+\r
+        //Load the high address\r
+        outb (b_SelectedAddressHigh, dw_PCIBoardEepromAddress+AMCC_OP_REG_MCSR+2);\r
+\r
+        //Wait on busy\r
+        do\r
+        {\r
+            dw_eeprom_busy = inl (dw_PCIBoardEepromAddress + AMCC_OP_REG_MCSR);\r
+            dw_eeprom_busy=dw_eeprom_busy & EEPROM_BUSY;\r
+        }\r
+        while(dw_eeprom_busy== EEPROM_BUSY);\r
+\r
+        //Select the READ mode\r
+        outb (NVCMD_BEGIN_READ, dw_PCIBoardEepromAddress+AMCC_OP_REG_MCSR+3);\r
+\r
+        //Wait on busy\r
+        do\r
+        {\r
+            dw_eeprom_busy = inl (dw_PCIBoardEepromAddress + AMCC_OP_REG_MCSR);\r
+            dw_eeprom_busy=dw_eeprom_busy & EEPROM_BUSY;\r
+        }\r
+        while(dw_eeprom_busy== EEPROM_BUSY);\r
+\r
+        //Read data into the EEPROM\r
+        *pb_ReadByte = inb (dw_PCIBoardEepromAddress+AMCC_OP_REG_MCSR+2);\r
+\r
+        //Wait on busy\r
+        do\r
+        {\r
+            dw_eeprom_busy = inl (dw_PCIBoardEepromAddress + AMCC_OP_REG_MCSR);\r
+            dw_eeprom_busy=dw_eeprom_busy & EEPROM_BUSY;\r
+        }\r
+        while(dw_eeprom_busy== EEPROM_BUSY);\r
+\r
+        //Select the upper address part\r
+        if(i_Counter==0)\r
+        {   b_ReadLowByte=pb_ReadByte[0];\r
+        }else\r
+        {   b_ReadHighByte=pb_ReadByte[0];\r
+        }\r
+                \r
+        //Sleep\r
+        for (i=0; i < 10000; i++);\r
+   \r
+    }\r
+    w_ReadWord=(b_ReadLowByte|( ( (unsigned short) b_ReadHighByte) *256) );\r
+      \r
+    pw_DataRead[i_WordCounter]=w_ReadWord;\r
+\r
+    w_EepromStartAddress +=2; // to read the next word    \r
+\r
+   } // for (...) i_NbOfWordsToRead\r
+   return (0);\r
+}
\ No newline at end of file
diff --git a/comedi/drivers/addi-data/addi_amcc_S5920.h b/comedi/drivers/addi-data/addi_amcc_S5920.h
new file mode 100755 (executable)
index 0000000..d341c06
--- /dev/null
@@ -0,0 +1,63 @@
+/**\r
+@verbatim\r
+\r
+Copyright (C) 2004,2005  ADDI-DATA GmbH for the source code of this module. \r
+        \r
+        ADDI-DATA GmbH \r
+        Dieselstrasse 3 \r
+        D-77833 Ottersweier \r
+        Tel: +19(0)7223/9493-0 \r
+        Fax: +49(0)7223/9493-92 \r
+        http://www.addi-data-com \r
+        info@addi-data.com \r
+\r
+This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.\r
+\r
+This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.\r
+\r
+You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+\r
+You shoud also find the complete GPL in the COPYING file accompanying this source code.\r
+\r
+@endverbatim\r
+*/\r
+/*\r
+#define VOID           void\r
+#define INT            int\r
+#define UINT           unsigned int\r
+#define SHORT          short\r
+#define USHORT         unsigned short\r
+#define CHAR           char\r
+#define BYTE           unsigned char\r
+#define WORD           unsigned int\r
+#define LONG           long\r
+#define ULONG          unsigned long\r
+#define DWORD          unsigned long\r
+#define DOUBLE         double\r
+#define PINT           int *\r
+#define PUINT          unsigned int *\r
+#define PSHORT         short *\r
+#define PUSHORT        unsigned short *\r
+#define PCHAR          char *\r
+#define PBYTE          unsigned char *\r
+#define PWORD          unsigned int *\r
+#define PLONG          long *\r
+#define PULONG         unsigned long *\r
+#define PDWORD         unsigned long *\r
+#define PDOUBLE        double *\r
+*/\r
+\r
+#define AMCC_OP_REG_MCSR         0x3c\r
+#define EEPROM_BUSY   0x80000000\r
+#define NVCMD_LOAD_LOW  (0x4 << 5 ) // nvRam load low command\r
+#define NVCMD_LOAD_HIGH (0x5 << 5 ) // nvRam load high command\r
+#define NVCMD_BEGIN_READ (0x7 << 5 ) // nvRam begin read command\r
+#define NVCMD_BEGIN_WRITE  (0x6 << 5)  //EEPROM begin write command\r
+\r
+INT i_AddiHeaderRW_ReadEeprom ( INT i_NbOfWordsToRead,\r
+                               DWORD dw_PCIBoardEepromAddress,\r
+                               WORD w_EepromStartAddress,\r
+                               PWORD pw_DataRead);\r
+\r
+\r
+\r
index 76b6af22573915cb6fae1049bca5862a16b0dfb7..585fce7187321a3f269abcc39c2c9c49016d64b0 100644 (file)
@@ -1,7 +1,28 @@
+/**
+@verbatim
 
-//addi_amcc_s5933.h  
+Copyright (C) 2004,2005  ADDI-DATA GmbH for the source code of this module. 
+        
+        ADDI-DATA GmbH 
+        Dieselstrasse 3 
+        D-77833 Ottersweier 
+        Tel: +19(0)7223/9493-0 
+        Fax: +49(0)7223/9493-92 
+        http://www.addi-data-com 
+        info@addi-data.com 
 
+This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+You shoud also find the complete GPL in the COPYING file accompanying this source code.
+
+@endverbatim
+*/
 /*
+    
   +-----------------------------------------------------------------------+
   | (C) ADDI-DATA GmbH          Dieselstrasse 3      D-77833 Ottersweier  |
   +-----------------------------------------------------------------------+
@@ -234,14 +255,14 @@ void v_pci_card_list_init(unsigned short pci_vendor, char display);
 void v_pci_card_list_cleanup(unsigned short pci_vendor);
 struct pcilst_struct *ptr_find_free_pci_card_by_device(unsigned short vendor_id, unsigned short device_id);
 int i_find_free_pci_card_by_position(unsigned short vendor_id, unsigned short device_id, unsigned short pci_bus, unsigned short pci_slot, struct pcilst_struct **card);
-struct pcilst_struct *ptr_select_and_alloc_pci_card(unsigned short vendor_id, unsigned short device_id, unsigned short pci_bus, unsigned short pci_slot);
+struct pcilst_struct *ptr_select_and_alloc_pci_card(unsigned short vendor_id, unsigned short device_id, unsigned short pci_bus, unsigned short pci_slot, int i_Master);
 
-int i_pci_card_alloc(struct pcilst_struct *amcc);
+int pci_card_alloc(struct pcilst_struct *amcc, int master);
 int i_pci_card_free(struct pcilst_struct *amcc);
 void v_pci_card_list_display(void);
 int i_pci_card_data(struct pcilst_struct *amcc,
        unsigned char *pci_bus, unsigned char *pci_slot, unsigned char *pci_func,
-       unsigned short *io_addr, unsigned short *irq, unsigned short *master);
+       unsigned long *io_addr, unsigned short *irq, unsigned short *master);
 
 /****************************************************************************/
 
@@ -257,6 +278,10 @@ void v_pci_card_list_init(unsigned short pci_vendor, char display)
        
 #if LINUX_VERSION_CODE < 0x020300
        for(pcidev=pci_devices;pcidev;pcidev=pcidev->next){
+#elif LINUX_VERSION_CODE >= 0x020600
+       for(pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, NULL); 
+           pcidev != NULL ; 
+           pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pcidev)) {
 #else
        pci_for_each_dev(pcidev){
 #endif           
@@ -357,12 +382,17 @@ int i_find_free_pci_card_by_position(unsigned short vendor_id, unsigned short de
 
 /****************************************************************************/
 /* mark card as used */
-int i_pci_card_alloc(struct pcilst_struct *amcc)
+int pci_card_alloc(struct pcilst_struct *amcc, int master)
 {
        if (!amcc) return -1;
 
        if (amcc->used) return 1;
+#if LINUX_VERSION_CODE >= 0x020600
+       if (pci_enable_device(amcc->pcidev)) return -1;
+       if (master) pci_set_master(amcc->pcidev);
+#endif
        amcc->used=1;
+
        return 0;
 }
 
@@ -399,7 +429,7 @@ void v_pci_card_list_display(void)
 /* return all card information for driver */
 int i_pci_card_data(struct pcilst_struct *amcc,
        unsigned char *pci_bus, unsigned char *pci_slot, unsigned char *pci_func,
-       unsigned short *io_addr, unsigned short *irq, unsigned short *master)
+       unsigned long *io_addr, unsigned short *irq, unsigned short *master)
 {
        int     i;
        
@@ -416,7 +446,7 @@ int i_pci_card_data(struct pcilst_struct *amcc,
 
 /****************************************************************************/
 /* select and alloc card */
-struct pcilst_struct *ptr_select_and_alloc_pci_card(unsigned short vendor_id, unsigned short device_id, unsigned short pci_bus, unsigned short pci_slot)
+struct pcilst_struct *ptr_select_and_alloc_pci_card(unsigned short vendor_id, unsigned short device_id, unsigned short pci_bus, unsigned short pci_slot, int i_Master)
 {
        struct pcilst_struct *card;
        
@@ -437,9 +467,11 @@ struct pcilst_struct *ptr_select_and_alloc_pci_card(unsigned short vendor_id, un
        }
 
 
-       if (i_pci_card_alloc(card)!=0) {
+       if (pci_card_alloc(card, i_Master)!=0) {
                rt_printk(" - Can't allocate card!\n");
                return NULL;
+       
+       
        }
 
        return card;
index d1ebfa7fc3b7de68255f268af0a4fa252dd23986..874667748a619a6111410ceda620e576d660906d 100644 (file)
@@ -1,72 +1,60 @@
+/**
+@verbatim
 
+Copyright (C) 2004,2005  ADDI-DATA GmbH for the source code of this module. 
+        
+        ADDI-DATA GmbH 
+        Dieselstrasse 3 
+        D-77833 Ottersweier 
+        Tel: +19(0)7223/9493-0 
+        Fax: +49(0)7223/9493-92 
+        http://www.addi-data-com 
+        info@addi-data.com 
 
+This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
 
+This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
 
-/***************************************************
-      Generic Driver  For ADDI  APCI CARDs
-
-           
-       
-       CONFIG OPTIONS  
-                               option[0] - PCI bus number - if bus number and slot number are 0, 
-                                                                                then driver search for first unused card
-                               option[1] - PCI slot number 
-                                                       
-                       option[2]= 0    DMA ENABLE
-                                = 1    DMA DISABLE   
-
- ******************************************************************/
-
-/*======================================================================
-                       Authors                         Email ID
-                 Santosh Raktawan              santosh.raktawan@tatainfotech.com
-                 Sarath Chandran K R   sarath.chandran@tatainfotech.com        
-========================================================================*/
-
-
+You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 
+You shoud also find the complete GPL in the COPYING file accompanying this source code.
 
+@endverbatim
+*/
 /*
+    
   +-----------------------------------------------------------------------+
   | (C) ADDI-DATA GmbH          Dieselstrasse 3      D-77833 Ottersweier  |
   +-----------------------------------------------------------------------+
   | Tel : +49 (0) 7223/9493-0     | email    : info@addi-data.com         |
   | Fax : +49 (0) 7223/9493-92    | Internet : http://www.addi-data.com   |
   +-----------------------------------------------------------------------+
-  | Project   : ADDI DATA         | Compiler : GCC                                   |
+  | Project   : ADDI DATA         | Compiler : GCC                       |
   | Modulname : addi_common.c     | Version  : 2.96                       |
   +-------------------------------+---------------------------------------+
-  | Author    :           | Date     :                                                   |
+  | Author    :           | Date     :                                   |
   +-----------------------------------------------------------------------+
   | Description : ADDI COMMON Main Module                                 |
   +-----------------------------------------------------------------------+
-  |                             UPDATE'S                                  |
-  +-----------------------------------------------------------------------+
-  |   Date   |   Author  |          Description of updates                |
-  +----------+-----------+------------------------------------------------+
-  |          |                          |                                                                                                |
-  |          |           |                                                                                               |
-  |          |           |                                                           |
-  |          |           |                                                                                               |
-  |          |           |                                                                   |
-  +----------+-----------+------------------------------------------------+
-  |         |                   |                                                                        |
-  |          |           |                                                                                               |
-  |          |           |                                                                               |
+  | CONFIG OPTIONS                                                        |
+  |    option[0] - PCI bus number - if bus number and slot number are 0, |
+  |                             then driver search for first unused card |
+  |    option[1] - PCI slot number                                       |
+  |                                                                      |
+  |    option[2] = 0  - DMA ENABLE                                       |
+  |               = 1  - DMA DISABLE                                      |
   +----------+-----------+------------------------------------------------+
 */
 
 
 
 
-
-
  
 #include<linux/kernel.h>
 #include<linux/module.h>
 #include<linux/sched.h>
 #include<linux/mm.h>
-#include<linux/malloc.h>
+#include<linux/slab.h>
 #include<linux/errno.h>
 #include<linux/ioport.h>
 #include<linux/delay.h>
 #include<linux/pci.h>
 #include<linux/comedidev.h>
 #include<asm/io.h>
+#include<asm/i387.h>
+#include "../comedi_fc.h"
 
 #include "addi_common.h"
 #include "addi_amcc_s5933.h"
-//#include "addi_eeprom.c"
+
+//Update-0.7.57->0.7.68MODULE_AUTHOR("ADDI-DATA GmbH <info@addi-data.com>");
+//Update-0.7.57->0.7.68MODULE_DESCRIPTION("Comedi ADDI-DATA module");
+//Update-0.7.57->0.7.68MODULE_LICENSE("GPL");
 
 #define devpriv ((addi_private *)dev->private)
 #define this_board ((boardtype *)dev->board_ptr)
 
+//BYTE b_SaveFPUReg [94];
+
+void   fpu_begin (void)
+       {
+       //asm ("fstenv b_SaveFPUReg");
+       kernel_fpu_begin ();
+       }
+
+void   fpu_end (void)
+       {
+       // asm ("frstor b_SaveFPUReg");
+       kernel_fpu_end ();
+       }
 
 #include "addi_eeprom.c"
 #include "hwdrv_apci3120.c"
 #include "hwdrv_apci035.c"
 #include "hwdrv_apci3200.c" 
 #include "hwdrv_APCI1710.c"
+#include "hwdrv_apci16xx.c"
+#include "hwdrv_apci3xxx.c"
+
 
 static boardtype boardtypes[] =
 {
-               {"apci3120", APCI3120_BOARD_VENDOR_ID, 0x818D,
-               AMCC_OP_REG_SIZE, APCI3120_ADDRESS_RANGE,8,0,
-                ADDIDATA_NO_EEPROM,NULL,
-                16, 8, 16, 8, 0xffff, 0x3fff,
-               &range_apci3120_ai, &range_apci3120_ao,
-               4,4,0x0f,1,1,10000,100000,
+               {"apci3120", 
+               APCI3120_BOARD_VENDOR_ID,
+               0x818D,
+               AMCC_OP_REG_SIZE,
+               APCI3120_ADDRESS_RANGE,
+               8,
+               0,
+                ADDIDATA_NO_EEPROM,
+               NULL,
+                16, 
+               8, 
+               16, 
+               8, 
+               0xffff, 
+               0x3fff,
+               &range_apci3120_ai, 
+               &range_apci3120_ao,
+               4,
+               4,
+               0x0f,
+               0,
+               NULL,
+               1,
+               1,
+               1,
+               10000,
+               100000,
                 v_APCI3120_Interrupt,
                 i_APCI3120_Reset,
                 i_APCI3120_InsnConfigAnalogInput,
@@ -130,14 +160,40 @@ static boardtype boardtypes[] =
                i_APCI3120_InsnConfigTimer,
                i_APCI3120_InsnWriteTimer,
                i_APCI3120_InsnReadTimer,
-                NULL
+                NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL
                },
     
-                {"apci1032",APCI1032_BOARD_VENDOR_ID,0x1003,
-                4,APCI1032_ADDRESS_RANGE,0,0,
-                ADDIDATA_EEPROM,ADDIDATA_93C76, 
-               0,0,0,0,0,0,0,0,
-                32,0,0,0,0,0,0,
+                {"apci1032",
+               APCI1032_BOARD_VENDOR_ID,
+               0x1003,
+                4,
+               APCI1032_ADDRESS_RANGE,
+               0,
+               0,
+                ADDIDATA_EEPROM,
+               ADDIDATA_93C76, 
+               0,
+               0,
+               0,
+               0,
+               0,
+               0,
+               0,
+               0,
+                32,
+               0,
+               0,
+               0,
+               NULL,
+               0,
+               0,
+               0,
+               0,
+               0,
                 v_APCI1032_Interrupt,           
                 i_APCI1032_Reset,
                 NULL,
@@ -161,13 +217,40 @@ static boardtype boardtypes[] =
                 NULL,
                 NULL,
                 NULL,
-                NULL
+                NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL
                 },
-                {"apci1516",APCI1516_BOARD_VENDOR_ID,0x1001,
-               128,APCI1516_ADDRESS_RANGE,32,0,
-                ADDIDATA_EEPROM,ADDIDATA_S5920,
-                0,0,0,0,0,0,NULL,NULL,8,
-                8,0,0,1,0,0,
+               
+                {"apci1516",
+               APCI1516_BOARD_VENDOR_ID,
+               0x1001,
+               128,
+               APCI1516_ADDRESS_RANGE,
+               32,
+               0,
+                ADDIDATA_EEPROM,
+               ADDIDATA_S5920,
+                0,
+               0,
+               0,
+               0,
+               0,
+               0,
+               NULL,
+               NULL,
+               8,
+                8,
+               0,
+               0,
+               NULL,
+               0,
+               1,
+               0,
+               0,
+               0,
                 NULL,           
                 i_APCI1516_Reset,
                 NULL,NULL,
@@ -190,18 +273,44 @@ static boardtype boardtypes[] =
                 i_APCI1516_ConfigWatchdog,
                 i_APCI1516_StartStopWriteWatchdog,
                 i_APCI1516_ReadWatchdog,
-                NULL
+                NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL
                 },
 
-                {"apci2016",APCI2016_BOARD_VENDOR_ID,0x1002,
-                128,APCI2016_ADDRESS_RANGE,32,0,
-               ADDIDATA_EEPROM,ADDIDATA_S5920,
-               0,0,0,0,0,0,
-                NULL,NULL,
-                0,16,0,0,1,0,0,
-                NULL,           
+                {"apci2016",
+               APCI2016_BOARD_VENDOR_ID,
+               0x1002,
+                128,
+               APCI2016_ADDRESS_RANGE,
+               32,
+               0,
+               ADDIDATA_EEPROM,
+               ADDIDATA_S5920,
+               0,
+               0,
+               0,
+               0,
+               0,
+               0,
+                NULL,
+               NULL,
+                0,
+               16,
+               0,
+               0,
+               NULL,
+               0,
+               1,
+               0,
+               0,
+               0,
+                NULL, 
                 i_APCI2016_Reset,
-                NULL,NULL,
+                NULL,
+               NULL,
                 NULL,
                 NULL,
                 NULL,
@@ -221,15 +330,40 @@ static boardtype boardtypes[] =
                 i_APCI2016_ConfigWatchdog,
                 i_APCI2016_StartStopWriteWatchdog,
                 i_APCI2016_ReadWatchdog,
-                NULL
+                NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL
                 },
  
-                {"apci2032", APCI2032_BOARD_VENDOR_ID, 0x1004,
-               4,APCI2032_ADDRESS_RANGE,0,0,
-               ADDIDATA_EEPROM,ADDIDATA_93C76,
-               0, 0, 0, 0, 0, 0,
-               NULL, NULL,
-               0,32,0xffffffff,0,1,0,0,
+                {"apci2032", 
+               APCI2032_BOARD_VENDOR_ID, 
+               0x1004,
+               4,
+               APCI2032_ADDRESS_RANGE,
+               0,
+               0,
+               ADDIDATA_EEPROM,
+               ADDIDATA_93C76,
+               0, 
+               0, 
+               0, 
+               0, 
+               0, 
+               0,
+               NULL, 
+               NULL,
+               0,
+               32,
+               0xffffffff,
+               0,
+               NULL,
+               0,
+               1,
+               0,
+               0,
+               0,
                 v_APCI2032_Interrupt,                          
                 i_APCI2032_Reset,
                 NULL,NULL,                                        
@@ -252,13 +386,40 @@ static boardtype boardtypes[] =
                 i_APCI2032_ConfigWatchdog,         
                i_APCI2032_StartStopWriteWatchdog, 
                i_APCI2032_ReadWatchdog,
-                NULL           
+                NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL
                 },
-                {"apci2200",APCI2200_BOARD_VENDOR_ID,0x1005,
-               4,APCI2200_ADDRESS_RANGE,0,0,
-                ADDIDATA_EEPROM,ADDIDATA_93C76,
-                0,0,0,0,0,0,NULL,NULL,8,
-                16,0,0,1,0,0,
+               
+                {"apci2200",
+               APCI2200_BOARD_VENDOR_ID,
+               0x1005,
+               4,
+               APCI2200_ADDRESS_RANGE,
+               0,
+               0,
+                ADDIDATA_EEPROM,
+               ADDIDATA_93C76,
+                0,
+               0,
+               0,
+               0,
+               0,
+               0,
+               NULL,
+               NULL,
+               8,
+                16,
+               0,
+               0,
+               NULL,
+               0,
+               1,
+               0,
+               0,
+               0,
                 NULL,           
                 i_APCI2200_Reset,
                 NULL,NULL,
@@ -281,17 +442,44 @@ static boardtype boardtypes[] =
                 i_APCI2200_ConfigWatchdog,
                 i_APCI2200_StartStopWriteWatchdog,
                 i_APCI2200_ReadWatchdog,
-                NULL 
+                NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL
                 },
-                {"apci1564",APCI1564_BOARD_VENDOR_ID,0x1006,
-                128,APCI1564_ADDRESS_RANGE,0,0,
-                ADDIDATA_EEPROM,ADDIDATA_93C76,
-               0,0,0,0,0,0,
-                NULL,NULL,
-                32,32,0xffffffff,0,1,0,0,
+               
+                {"apci1564",
+               APCI1564_BOARD_VENDOR_ID,
+               0x1006,
+                128,
+               APCI1564_ADDRESS_RANGE,
+               0,
+               0,
+                ADDIDATA_EEPROM,
+               ADDIDATA_93C76,
+               0,
+               0,
+               0,
+               0,
+               0,
+               0,
+                NULL,
+               NULL,
+                32,
+               32,
+               0xffffffff,
+               0,
+               NULL,
+               0,
+               1,
+               0,
+               0,
+               0,
                 v_APCI1564_Interrupt,           
                 i_APCI1564_Reset,
-                NULL,NULL, 
+                NULL,
+               NULL, 
                 NULL,
                 NULL,
                 NULL,
@@ -311,17 +499,44 @@ static boardtype boardtypes[] =
                 i_APCI1564_ConfigTimerCounterWatchdog,
                 i_APCI1564_StartStopWriteTimerCounterWatchdog,
                 i_APCI1564_ReadTimerCounterWatchdog,
-                NULL
+                NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL
                 },
-                {"apci1500", APCI1500_BOARD_VENDOR_ID, 0x80fc,
-               128,APCI1500_ADDRESS_RANGE,4,0,
-                ADDIDATA_NO_EEPROM,NULL,
-               0, 0, 0, 0, 0, 0,
-               NULL, NULL,
-               16,16,0xffff,0,1,0,0,
+               
+                {"apci1500", 
+               APCI1500_BOARD_VENDOR_ID, 
+               0x80fc,
+               128,
+               APCI1500_ADDRESS_RANGE,
+               4,
+               0,
+                ADDIDATA_NO_EEPROM,
+               NULL,
+               0, 
+               0, 
+               0, 
+               0, 
+               0, 
+               0,
+               NULL, 
+               NULL,
+               16,
+               16,
+               0xffff,
+               0,
+               NULL,
+               0,
+               1,
+               0,
+               0,
+               0,
                 v_APCI1500_Interrupt,                          
                 i_APCI1500_Reset, 
-                NULL,NULL,                                       
+                NULL,
+               NULL,                                       
                NULL,                                          
                 NULL,                                         
                NULL,                                           
@@ -341,21 +556,47 @@ static boardtype boardtypes[] =
                 i_APCI1500_ConfigCounterTimerWatchdog,         
                i_APCI1500_StartStopTriggerTimerCounterWatchdog, 
                 i_APCI1500_ReadInterruptMask,
-               i_APCI1500_ReadCounterTimerWatchdog 
+               i_APCI1500_ReadCounterTimerWatchdog,
+               NULL,
+               NULL,
+               NULL,
+               NULL
                 },
                 
 
-               {"apci3001", APCI3120_BOARD_VENDOR_ID, 0x828D,
-               AMCC_OP_REG_SIZE, APCI3120_ADDRESS_RANGE,8,0,
-                ADDIDATA_NO_EEPROM,NULL,
-                16, 8, 16, 0, 0xfff, 0,
-               &range_apci3120_ai, NULL,
-               4,4,0x0f,1,1,10000,100000,
+               {"apci3001", 
+               APCI3120_BOARD_VENDOR_ID, 
+               0x828D,
+               AMCC_OP_REG_SIZE, 
+               APCI3120_ADDRESS_RANGE,
+               8,
+               0,
+                ADDIDATA_NO_EEPROM,
+               NULL,
+                16, 
+               8, 
+               16, 
+               0, 
+               0xfff, 
+               0,
+               &range_apci3120_ai, 
+               NULL,
+               4,
+               4,
+               0x0f,
+               0,
+               NULL,
+               1,
+               1,
+               1,
+               10000,
+               100000,
                 v_APCI3120_Interrupt,
                 i_APCI3120_Reset,
                 i_APCI3120_InsnConfigAnalogInput,
                i_APCI3120_InsnReadAnalogInput,
-                NULL,NULL,
+                NULL,
+               NULL,
                 i_APCI3120_CommandTestAnalogInput,
                i_APCI3120_CommandAnalogInput,
                 i_APCI3120_StopCyclicAcquisition,
@@ -373,14 +614,40 @@ static boardtype boardtypes[] =
                i_APCI3120_InsnConfigTimer,
                i_APCI3120_InsnWriteTimer,
                i_APCI3120_InsnReadTimer,
-                NULL
+                NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL
                },
-                {"apci3501", APCI3501_BOARD_VENDOR_ID, 0x3001,
-               64,APCI3501_ADDRESS_RANGE,0,0,
-                ADDIDATA_EEPROM,ADDIDATA_S5933,
-                0, 0, 0, 8, 0,16383,
-               NULL,&range_apci3501_ao,
-               2,2,0x3,0,1,0,0,
+               
+                {"apci3501", 
+               APCI3501_BOARD_VENDOR_ID, 
+               0x3001,
+               64,
+               APCI3501_ADDRESS_RANGE,
+               0,
+               0,
+                ADDIDATA_EEPROM,
+               ADDIDATA_S5933,
+                0, 
+               0, 
+               0,
+               8, 
+               0,
+               16383,
+               NULL,
+               &range_apci3501_ao,
+               2,
+               2,
+               0x3,
+               0,
+               NULL,
+               0,
+               1,
+               0,
+               0,
+               0,
                 v_APCI3501_Interrupt,                         
                 i_APCI3501_Reset,
                 NULL,NULL,                                        
@@ -403,18 +670,46 @@ static boardtype boardtypes[] =
                 i_APCI3501_ConfigTimerCounterWatchdog,         
                i_APCI3501_StartStopWriteTimerCounterWatchdog, 
                i_APCI3501_ReadTimerCounterWatchdog,
-                NULL           
+                NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL
                 },
-                {"apci035", APCI035_BOARD_VENDOR_ID, 0x0300,
-               127,APCI035_ADDRESS_RANGE ,0,0,1,ADDIDATA_S5920,
-               16,8,16,0, 0xff, 0,
-               &range_apci035_ai, NULL,
-               0,0,0,0,1,10000,100000,
+               
+                {"apci035", 
+               APCI035_BOARD_VENDOR_ID, 
+               0x0300,
+               127,
+               APCI035_ADDRESS_RANGE ,
+               0,
+               0,
+               1,
+               ADDIDATA_S5920,
+               16,
+               8,
+               16,
+               0, 
+               0xff, 
+               0,
+               &range_apci035_ai, 
+               NULL,
+               0,
+               0,
+               0,
+               0,
+               NULL,
+               0,
+               1,
+               0,
+               10000,
+               100000,
                 v_APCI035_Interrupt,
                 i_APCI035_Reset, 
                 i_APCI035_ConfigAnalogInput,
                i_APCI035_ReadAnalogInput ,
-                NULL,NULL,
+                NULL,
+               NULL,
                 NULL,
                 NULL,
                 NULL,
@@ -432,13 +727,40 @@ static boardtype boardtypes[] =
                i_APCI035_ConfigTimerWatchdog,
                i_APCI035_StartStopWriteTimerWatchdog,
                i_APCI035_ReadTimerWatchdog,
-                NULL
+                NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL
                },
-                {"apci3200", APCI3200_BOARD_VENDOR_ID, 0x3000,
-               128,256,4,4,ADDIDATA_EEPROM,ADDIDATA_S5920,
-               16,8,16,0, 0x3ffff, 0,
-               &range_apci3200_ai, NULL,
-               4,4,0,0,0,10000,100000,
+               
+                {"apci3200", 
+               APCI3200_BOARD_VENDOR_ID, 
+               0x3000,
+               128,
+               256,
+               4,
+               4,
+               ADDIDATA_EEPROM,
+               ADDIDATA_S5920,
+               16,
+               8,
+               16,
+               0, 
+               0x3ffff, 
+               0,
+               &range_apci3200_ai, 
+               NULL,
+               4,
+               4,
+               0,
+               0,
+               NULL,
+               0,
+               0,
+               0,
+               10000,
+               100000,
                 v_APCI3200_Interrupt,
                 i_APCI3200_Reset,    
                 i_APCI3200_ConfigAnalogInput,
@@ -462,15 +784,97 @@ static boardtype boardtypes[] =
                NULL,
                NULL,
                NULL,
-                NULL  
+                NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL
                },
-
+               
+               //Begin JK 20.10.2004: APCI-3300 integration
+                {"apci3300", 
+               APCI3200_BOARD_VENDOR_ID, 
+               0x3007,
+               128,
+               256,
+               4,
+               4,
+               ADDIDATA_EEPROM,
+               ADDIDATA_S5920,
+               0,
+               8,
+               8,
+               0, 
+               0x3ffff, 
+               0,
+               &range_apci3300_ai, 
+               NULL,
+               4,
+               4,
+               0,
+               0,
+               NULL,
+               0,
+               0,
+               0,
+               10000,
+               100000,
+                v_APCI3200_Interrupt,
+                i_APCI3200_Reset,    
+                i_APCI3200_ConfigAnalogInput,
+               i_APCI3200_ReadAnalogInput ,
+                i_APCI3200_InsnWriteReleaseAnalogInput,
+                i_APCI3200_InsnBits_AnalogInput_Test,
+                i_APCI3200_CommandTestAnalogInput,
+               i_APCI3200_CommandAnalogInput,
+                i_APCI3200_StopCyclicAcquisition,
+                NULL,
+               NULL,
+                NULL,
+                NULL,
+               NULL,
+                NULL,
+                i_APCI3200_ReadDigitalInput,
+               i_APCI3200_ConfigDigitalOutput,
+                i_APCI3200_WriteDigitalOutput,
+                i_APCI3200_ReadDigitalOutput,
+                NULL,
+               NULL,
+               NULL,
+               NULL,
+                NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL
+               },
+               
+               //End JK 20.10.2004: APCI-3300 integration                              
                {"apci1710",APCI1710_BOARD_VENDOR_ID,APCI1710_BOARD_DEVICE_ID,
-               128,8,256,0,
-                ADDIDATA_NO_EEPROM,NULL,
-                0, 0, 0, 0, 0, 0,
-               NULL, NULL,
-               0,0,0,0,0,0,0,
+               128,
+               8,
+               256,
+               0,
+                ADDIDATA_NO_EEPROM,
+               NULL,
+                0, 
+               0, 
+               0, 
+               0, 
+               0, 
+               0,
+               NULL, 
+               NULL,
+               0,
+               0,
+               0,
+               0,
+               NULL,
+               0,
+               0,
+               0,
+               0,
+               0,
                 v_APCI1710_Interrupt,           
                 i_APCI1710_Reset,
                 NULL,
@@ -494,23 +898,1561 @@ static boardtype boardtypes[] =
                NULL,
                NULL,
                NULL,
-                NULL
-               }
-                
-};
+                NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL
+               },
+               
+                {"apci1648", 
+                0x15B8,
+                0x1009,
+               128,
+               0,
+               0,
+               0,
+                ADDIDATA_NO_EEPROM,
+                NULL,
+               0, 
+               0, 
+               0, 
+               0, 
+               0, 
+               0,
+               NULL,
+               NULL,
+               0,
+               0,
+               0,
+               48,
+               &range_apci16xx_ttl,
+               0,
+               0,
+               0,
+               0,
+               0,
+                NULL,
+                i_APCI16XX_Reset,
+                NULL,
+                NULL,                                       
+               NULL,                                          
+                NULL,                                         
+               NULL,                                           
+                NULL,                                          
+                NULL,                                          
+               NULL,                                         
+                NULL,                                          
+               NULL,
+               NULL,
+                NULL,
+                NULL,
+                NULL,
+                NULL,
+               NULL,
+                NULL,
+                NULL, 
+                NULL,
+               NULL,
+                NULL,
+                NULL,
+               i_APCI16XX_InsnConfigInitTTLIO,
+               i_APCI16XX_InsnBitsReadTTLIO,
+               i_APCI16XX_InsnReadTTLIOAllPortValue,
+               i_APCI16XX_InsnBitsWriteTTLIO
+                },
 
-#define n_boardtypes (sizeof(boardtypes)/sizeof(boardtype))
 
-comedi_driver driver_addi ={
-               driver_name:    "addi_common",
-               module:         THIS_MODULE,
-               attach:         i_ADDI_Attach,
-               detach:         i_ADDI_Detach, 
-               num_names:      n_boardtypes,
-               board_name:     boardtypes,
-               offset:         sizeof(boardtype),
-       };
+                {"apci1696", 
+                0x15B8,
+                0x100A,
+               128,
+               0,
+               0,
+               0,
+                ADDIDATA_NO_EEPROM,
+                NULL,
+               0, 
+               0, 
+               0, 
+               0, 
+               0, 
+               0,
+               NULL,
+               NULL,
+               0,
+               0,
+               0,
+               96,
+               &range_apci16xx_ttl,
+               0,
+               0,
+               0,
+               0,
+               0,
+                NULL,
+                i_APCI16XX_Reset,
+                NULL,
+                NULL,                                       
+               NULL,                                          
+                NULL,                                         
+               NULL,                                           
+                NULL,                                          
+                NULL,                                          
+               NULL,                                         
+                NULL,                                          
+               NULL,
+               NULL,
+                NULL,
+                NULL,
+                NULL,
+                NULL,
+               NULL,
+                NULL,
+                NULL, 
+                NULL,
+               NULL,
+                NULL,
+                NULL,
+               i_APCI16XX_InsnConfigInitTTLIO,
+               i_APCI16XX_InsnBitsReadTTLIO,
+               i_APCI16XX_InsnReadTTLIOAllPortValue,
+               i_APCI16XX_InsnBitsWriteTTLIO
+                },
 
+               {"apci3000-16", 
+               0x15B8,
+               0x3010,
+               256,
+               256,
+               256,
+               256,
+               ADDIDATA_NO_EEPROM,
+               ADDIDATA_9054,
+               16, 
+               8, 
+               16, 
+               0, 
+               4095, 
+               0,
+               &range_apci3XXX_ai, 
+               NULL,
+               0,
+               0,
+               0,
+               24,
+               &range_apci3XXX_ttl,
+               0,
+               0,
+               6,
+               10000,
+               0,
+               v_APCI3XXX_Interrupt,
+               i_APCI3XXX_Reset,
+               i_APCI3XXX_InsnConfigAnalogInput,
+               i_APCI3XXX_InsnReadAnalogInput,                                       
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               i_APCI3XXX_InsnConfigInitTTLIO,
+               i_APCI3XXX_InsnBitsTTLIO,
+               i_APCI3XXX_InsnReadTTLIO,
+               i_APCI3XXX_InsnWriteTTLIO
+               },
+                
+               {"apci3000-8", 
+               0x15B8,
+               0x300F,
+               256,
+               256,
+               256,
+               256,
+               ADDIDATA_NO_EEPROM,
+               ADDIDATA_9054,
+               8, 
+               4, 
+               8, 
+               0, 
+               4095, 
+               0,
+               &range_apci3XXX_ai, 
+               NULL,
+               0,
+               0,
+               0,
+               24,
+               &range_apci3XXX_ttl,
+               0,
+               0,
+               6,
+               10000,
+               0,
+               v_APCI3XXX_Interrupt,
+               i_APCI3XXX_Reset,
+               i_APCI3XXX_InsnConfigAnalogInput,
+               i_APCI3XXX_InsnReadAnalogInput,                                       
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               i_APCI3XXX_InsnConfigInitTTLIO,
+               i_APCI3XXX_InsnBitsTTLIO,
+               i_APCI3XXX_InsnReadTTLIO,
+               i_APCI3XXX_InsnWriteTTLIO
+               },
+
+               {"apci3000-4", 
+               0x15B8,
+               0x300E,
+               256,
+               256,
+               256,
+               256,
+               ADDIDATA_NO_EEPROM,
+               ADDIDATA_9054,
+               4, 
+               2, 
+               4, 
+               0, 
+               4095, 
+               0,
+               &range_apci3XXX_ai, 
+               NULL,
+               0,
+               0,
+               0,
+               24,
+               &range_apci3XXX_ttl,
+               0,
+               0,
+               6,
+               10000,
+               0,
+               v_APCI3XXX_Interrupt,
+               i_APCI3XXX_Reset,
+               i_APCI3XXX_InsnConfigAnalogInput,
+               i_APCI3XXX_InsnReadAnalogInput,                                       
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               i_APCI3XXX_InsnConfigInitTTLIO,
+               i_APCI3XXX_InsnBitsTTLIO,
+               i_APCI3XXX_InsnReadTTLIO,
+               i_APCI3XXX_InsnWriteTTLIO
+               },
+
+               {"apci3006-16", 
+               0x15B8,
+               0x3013,
+               256,
+               256,
+               256,
+               256,
+               ADDIDATA_NO_EEPROM,
+               ADDIDATA_9054,
+               16, 
+               8, 
+               16, 
+               0, 
+               65535, 
+               0,
+               &range_apci3XXX_ai, 
+               NULL,
+               0,
+               0,
+               0,
+               24,
+               &range_apci3XXX_ttl,
+               0,
+               0,
+               6,
+               10000,
+               0,
+               v_APCI3XXX_Interrupt,
+               i_APCI3XXX_Reset,
+               i_APCI3XXX_InsnConfigAnalogInput,
+               i_APCI3XXX_InsnReadAnalogInput,                                       
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               i_APCI3XXX_InsnConfigInitTTLIO,
+               i_APCI3XXX_InsnBitsTTLIO,
+               i_APCI3XXX_InsnReadTTLIO,
+               i_APCI3XXX_InsnWriteTTLIO
+               },
+                
+               {"apci3006-8", 
+               0x15B8,
+               0x3014,
+               256,
+               256,
+               256,
+               256,
+               ADDIDATA_NO_EEPROM,
+               ADDIDATA_9054,
+               8, 
+               4, 
+               8, 
+               0, 
+               65535, 
+               0,
+               &range_apci3XXX_ai, 
+               NULL,
+               0,
+               0,
+               0,
+               24,
+               &range_apci3XXX_ttl,
+               0,
+               0,
+               6,
+               10000,
+               0,
+               v_APCI3XXX_Interrupt,
+               i_APCI3XXX_Reset,
+               i_APCI3XXX_InsnConfigAnalogInput,
+               i_APCI3XXX_InsnReadAnalogInput,                                       
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               i_APCI3XXX_InsnConfigInitTTLIO,
+               i_APCI3XXX_InsnBitsTTLIO,
+               i_APCI3XXX_InsnReadTTLIO,
+               i_APCI3XXX_InsnWriteTTLIO
+               },
+
+               {"apci3006-4", 
+               0x15B8,
+               0x3015,
+               256,
+               256,
+               256,
+               256,
+               ADDIDATA_NO_EEPROM,
+               ADDIDATA_9054,
+               4, 
+               2, 
+               4, 
+               0, 
+               65535, 
+               0,
+               &range_apci3XXX_ai, 
+               NULL,
+               0,
+               0,
+               0,
+               24,
+               &range_apci3XXX_ttl,
+               0,
+               0,
+               6,
+               10000,
+               0,
+               v_APCI3XXX_Interrupt,
+               i_APCI3XXX_Reset,
+               i_APCI3XXX_InsnConfigAnalogInput,
+               i_APCI3XXX_InsnReadAnalogInput,                                       
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               i_APCI3XXX_InsnConfigInitTTLIO,
+               i_APCI3XXX_InsnBitsTTLIO,
+               i_APCI3XXX_InsnReadTTLIO,
+               i_APCI3XXX_InsnWriteTTLIO
+               },
+
+               {"apci3010-16", 
+               0x15B8,
+               0x3016,
+               256,
+               256,
+               256,
+               256,
+               ADDIDATA_NO_EEPROM,
+               ADDIDATA_9054,
+               16, 
+               8, 
+               16, 
+               0, 
+               4095, 
+               0,
+               &range_apci3XXX_ai, 
+               NULL,
+               4,
+               4,
+               0xF,
+               24,
+               &range_apci3XXX_ttl,
+               0,
+               0,
+               6,
+               5000,
+               0,
+               v_APCI3XXX_Interrupt,
+               i_APCI3XXX_Reset,
+               i_APCI3XXX_InsnConfigAnalogInput,
+               i_APCI3XXX_InsnReadAnalogInput,                                       
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               i_APCI3XXX_InsnReadDigitalInput,
+               NULL,
+               i_APCI3XXX_InsnBitsDigitalInput,
+               NULL,
+               i_APCI3XXX_InsnWriteDigitalOutput,
+               i_APCI3XXX_InsnBitsDigitalOutput,
+               i_APCI3XXX_InsnReadDigitalOutput,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               i_APCI3XXX_InsnConfigInitTTLIO,
+               i_APCI3XXX_InsnBitsTTLIO,
+               i_APCI3XXX_InsnReadTTLIO,
+               i_APCI3XXX_InsnWriteTTLIO
+               },
+                
+               {"apci3010-8", 
+               0x15B8,
+               0x3017,
+               256,
+               256,
+               256,
+               256,
+               ADDIDATA_NO_EEPROM,
+               ADDIDATA_9054,
+               8, 
+               4, 
+               8, 
+               0, 
+               4095, 
+               0,
+               &range_apci3XXX_ai, 
+               NULL,
+               4,
+               4,
+               0xF,
+               24,
+               &range_apci3XXX_ttl,
+               0,
+               0,
+               6,
+               5000,
+               0,
+               v_APCI3XXX_Interrupt,
+               i_APCI3XXX_Reset,
+               i_APCI3XXX_InsnConfigAnalogInput,
+               i_APCI3XXX_InsnReadAnalogInput,                                       
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               i_APCI3XXX_InsnReadDigitalInput,
+               NULL,
+               i_APCI3XXX_InsnBitsDigitalInput,
+               NULL,
+               i_APCI3XXX_InsnWriteDigitalOutput,
+               i_APCI3XXX_InsnBitsDigitalOutput,
+               i_APCI3XXX_InsnReadDigitalOutput,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               i_APCI3XXX_InsnConfigInitTTLIO,
+               i_APCI3XXX_InsnBitsTTLIO,
+               i_APCI3XXX_InsnReadTTLIO,
+               i_APCI3XXX_InsnWriteTTLIO
+               },
+
+               {"apci3010-4", 
+               0x15B8,
+               0x3018,
+               256,
+               256,
+               256,
+               256,
+               ADDIDATA_NO_EEPROM,
+               ADDIDATA_9054,
+               4, 
+               2, 
+               4, 
+               0, 
+               4095, 
+               0,
+               &range_apci3XXX_ai, 
+               NULL,
+               4,
+               4,
+               0xF,
+               24,
+               &range_apci3XXX_ttl,
+               0,
+               0,
+               6,
+               5000,
+               0,
+               v_APCI3XXX_Interrupt,
+               i_APCI3XXX_Reset,
+               i_APCI3XXX_InsnConfigAnalogInput,
+               i_APCI3XXX_InsnReadAnalogInput,                                       
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               i_APCI3XXX_InsnReadDigitalInput,
+               NULL,
+               i_APCI3XXX_InsnBitsDigitalInput,
+               NULL,
+               i_APCI3XXX_InsnWriteDigitalOutput,
+               i_APCI3XXX_InsnBitsDigitalOutput,
+               i_APCI3XXX_InsnReadDigitalOutput,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               i_APCI3XXX_InsnConfigInitTTLIO,
+               i_APCI3XXX_InsnBitsTTLIO,
+               i_APCI3XXX_InsnReadTTLIO,
+               i_APCI3XXX_InsnWriteTTLIO
+               },
+
+               {"apci3016-16", 
+               0x15B8,
+               0x3019,
+               256,
+               256,
+               256,
+               256,
+               ADDIDATA_NO_EEPROM,
+               ADDIDATA_9054,
+               16, 
+               8, 
+               16, 
+               0, 
+               65535, 
+               0,
+               &range_apci3XXX_ai, 
+               NULL,
+               4,
+               4,
+               0xF,
+               24,
+               &range_apci3XXX_ttl,
+               0,
+               0,
+               6,
+               5000,
+               0,
+               v_APCI3XXX_Interrupt,
+               i_APCI3XXX_Reset,
+               i_APCI3XXX_InsnConfigAnalogInput,
+               i_APCI3XXX_InsnReadAnalogInput,                                       
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               i_APCI3XXX_InsnReadDigitalInput,
+               NULL,
+               i_APCI3XXX_InsnBitsDigitalInput,
+               NULL,
+               i_APCI3XXX_InsnWriteDigitalOutput,
+               i_APCI3XXX_InsnBitsDigitalOutput,
+               i_APCI3XXX_InsnReadDigitalOutput,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               i_APCI3XXX_InsnConfigInitTTLIO,
+               i_APCI3XXX_InsnBitsTTLIO,
+               i_APCI3XXX_InsnReadTTLIO,
+               i_APCI3XXX_InsnWriteTTLIO
+               },
+
+               {"apci3016-8", 
+               0x15B8,
+               0x301A,
+               256,
+               256,
+               256,
+               256,
+               ADDIDATA_NO_EEPROM,
+               ADDIDATA_9054,
+               8, 
+               4, 
+               8, 
+               0, 
+               65535, 
+               0,
+               &range_apci3XXX_ai, 
+               NULL,
+               4,
+               4,
+               0xF,
+               24,
+               &range_apci3XXX_ttl,
+               0,
+               0,
+               6,
+               5000,
+               0,
+               v_APCI3XXX_Interrupt,
+               i_APCI3XXX_Reset,
+               i_APCI3XXX_InsnConfigAnalogInput,
+               i_APCI3XXX_InsnReadAnalogInput,                                       
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               i_APCI3XXX_InsnReadDigitalInput,
+               NULL,
+               i_APCI3XXX_InsnBitsDigitalInput,
+               NULL,
+               i_APCI3XXX_InsnWriteDigitalOutput,
+               i_APCI3XXX_InsnBitsDigitalOutput,
+               i_APCI3XXX_InsnReadDigitalOutput,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               i_APCI3XXX_InsnConfigInitTTLIO,
+               i_APCI3XXX_InsnBitsTTLIO,
+               i_APCI3XXX_InsnReadTTLIO,
+               i_APCI3XXX_InsnWriteTTLIO
+               },
+
+               {"apci3016-4", 
+               0x15B8,
+               0x301B,
+               256,
+               256,
+               256,
+               256,
+               ADDIDATA_NO_EEPROM,
+               ADDIDATA_9054,
+               4, 
+               2, 
+               4, 
+               0, 
+               65535, 
+               0,
+               &range_apci3XXX_ai, 
+               NULL,
+               4,
+               4,
+               0xF,
+               24,
+               &range_apci3XXX_ttl,
+               0,
+               0,
+               6,
+               5000,
+               0,
+               v_APCI3XXX_Interrupt,
+               i_APCI3XXX_Reset,
+               i_APCI3XXX_InsnConfigAnalogInput,
+               i_APCI3XXX_InsnReadAnalogInput,                                       
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               i_APCI3XXX_InsnReadDigitalInput,
+               NULL,
+               i_APCI3XXX_InsnBitsDigitalInput,
+               NULL,
+               i_APCI3XXX_InsnWriteDigitalOutput,
+               i_APCI3XXX_InsnBitsDigitalOutput,
+               i_APCI3XXX_InsnReadDigitalOutput,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               i_APCI3XXX_InsnConfigInitTTLIO,
+               i_APCI3XXX_InsnBitsTTLIO,
+               i_APCI3XXX_InsnReadTTLIO,
+               i_APCI3XXX_InsnWriteTTLIO
+               },
+
+               {"apci3100-16-4", 
+               0x15B8,
+               0x301C,
+               256,
+               256,
+               256,
+               256,
+               ADDIDATA_NO_EEPROM,
+               ADDIDATA_9054,
+               16, 
+               8, 
+               16, 
+               4, 
+               4095, 
+               4095,
+               &range_apci3XXX_ai, 
+               &range_apci3XXX_ao,
+               4,
+               4,
+               0xF,
+               24,
+               &range_apci3XXX_ttl,
+               0,
+               0,
+               6,
+               10000,
+               0,
+               v_APCI3XXX_Interrupt,
+               i_APCI3XXX_Reset,
+               i_APCI3XXX_InsnConfigAnalogInput,
+               i_APCI3XXX_InsnReadAnalogInput,                                       
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               i_APCI3XXX_InsnWriteAnalogOutput,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               i_APCI3XXX_InsnConfigInitTTLIO,
+               i_APCI3XXX_InsnBitsTTLIO,
+               i_APCI3XXX_InsnReadTTLIO,
+               i_APCI3XXX_InsnWriteTTLIO
+               },
+
+               {"apci3100-8-4", 
+               0x15B8,
+               0x301D,
+               256,
+               256,
+               256,
+               256,
+               ADDIDATA_NO_EEPROM,
+               ADDIDATA_9054,
+               8, 
+               4, 
+               8, 
+               4, 
+               4095, 
+               4095,
+               &range_apci3XXX_ai, 
+               &range_apci3XXX_ao,
+               4,
+               4,
+               0xF,
+               24,
+               &range_apci3XXX_ttl,
+               0,
+               0,
+               6,
+               10000,
+               0,
+               v_APCI3XXX_Interrupt,
+               i_APCI3XXX_Reset,
+               i_APCI3XXX_InsnConfigAnalogInput,
+               i_APCI3XXX_InsnReadAnalogInput,                                       
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               i_APCI3XXX_InsnWriteAnalogOutput,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               i_APCI3XXX_InsnConfigInitTTLIO,
+               i_APCI3XXX_InsnBitsTTLIO,
+               i_APCI3XXX_InsnReadTTLIO,
+               i_APCI3XXX_InsnWriteTTLIO
+               },
+
+               {"apci3106-16-4", 
+               0x15B8,
+               0x301E,
+               256,
+               256,
+               256,
+               256,
+               ADDIDATA_NO_EEPROM,
+               ADDIDATA_9054,
+               16, 
+               8, 
+               16, 
+               4, 
+               65535, 
+               4095,
+               &range_apci3XXX_ai, 
+               &range_apci3XXX_ao,
+               4,
+               4,
+               0xF,
+               24,
+               &range_apci3XXX_ttl,
+               0,
+               0,
+               6,
+               10000,
+               0,
+               v_APCI3XXX_Interrupt,
+               i_APCI3XXX_Reset,
+               i_APCI3XXX_InsnConfigAnalogInput,
+               i_APCI3XXX_InsnReadAnalogInput,                                       
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               i_APCI3XXX_InsnWriteAnalogOutput,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               i_APCI3XXX_InsnConfigInitTTLIO,
+               i_APCI3XXX_InsnBitsTTLIO,
+               i_APCI3XXX_InsnReadTTLIO,
+               i_APCI3XXX_InsnWriteTTLIO
+               },
+
+               {"apci3106-8-4", 
+               0x15B8,
+               0x301F,
+               256,
+               256,
+               256,
+               256,
+               ADDIDATA_NO_EEPROM,
+               ADDIDATA_9054,
+               8, 
+               4, 
+               8, 
+               4, 
+               65535, 
+               4095,
+               &range_apci3XXX_ai, 
+               &range_apci3XXX_ao,
+               4,
+               4,
+               0xF,
+               24,
+               &range_apci3XXX_ttl,
+               0,
+               0,
+               6,
+               10000,
+               0,
+               v_APCI3XXX_Interrupt,
+               i_APCI3XXX_Reset,
+               i_APCI3XXX_InsnConfigAnalogInput,
+               i_APCI3XXX_InsnReadAnalogInput,                                       
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               i_APCI3XXX_InsnWriteAnalogOutput,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               i_APCI3XXX_InsnConfigInitTTLIO,
+               i_APCI3XXX_InsnBitsTTLIO,
+               i_APCI3XXX_InsnReadTTLIO,
+               i_APCI3XXX_InsnWriteTTLIO
+               },
+
+               {"apci3110-16-4", 
+               0x15B8,
+               0x3020,
+               256,
+               256,
+               256,
+               256,
+               ADDIDATA_NO_EEPROM,
+               ADDIDATA_9054,
+               16, 
+               8, 
+               16, 
+               4, 
+               4095, 
+               4095,
+               &range_apci3XXX_ai, 
+               &range_apci3XXX_ao,
+               4,
+               4,
+               0xF,
+               24,
+               &range_apci3XXX_ttl,
+               0,
+               0,
+               6,
+               5000,
+               0,
+               v_APCI3XXX_Interrupt,
+               i_APCI3XXX_Reset,
+               i_APCI3XXX_InsnConfigAnalogInput,
+               i_APCI3XXX_InsnReadAnalogInput,                                       
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               i_APCI3XXX_InsnWriteAnalogOutput,
+               NULL,
+               NULL,
+               i_APCI3XXX_InsnReadDigitalInput,
+               NULL,
+               i_APCI3XXX_InsnBitsDigitalInput,
+               NULL,
+               i_APCI3XXX_InsnWriteDigitalOutput,
+               i_APCI3XXX_InsnBitsDigitalOutput,
+               i_APCI3XXX_InsnReadDigitalOutput,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               i_APCI3XXX_InsnConfigInitTTLIO,
+               i_APCI3XXX_InsnBitsTTLIO,
+               i_APCI3XXX_InsnReadTTLIO,
+               i_APCI3XXX_InsnWriteTTLIO
+               },
+
+               {"apci3110-8-4", 
+               0x15B8,
+               0x3021,
+               256,
+               256,
+               256,
+               256,
+               ADDIDATA_NO_EEPROM,
+               ADDIDATA_9054,
+               8, 
+               4, 
+               8, 
+               4, 
+               4095, 
+               4095,
+               &range_apci3XXX_ai, 
+               &range_apci3XXX_ao,
+               4,
+               4,
+               0xF,
+               24,
+               &range_apci3XXX_ttl,
+               0,
+               0,
+               6,
+               5000,
+               0,
+               v_APCI3XXX_Interrupt,
+               i_APCI3XXX_Reset,
+               i_APCI3XXX_InsnConfigAnalogInput,
+               i_APCI3XXX_InsnReadAnalogInput,                                       
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               i_APCI3XXX_InsnWriteAnalogOutput,
+               NULL,
+               NULL,
+               i_APCI3XXX_InsnReadDigitalInput,
+               NULL,
+               i_APCI3XXX_InsnBitsDigitalInput,
+               NULL,
+               i_APCI3XXX_InsnWriteDigitalOutput,
+               i_APCI3XXX_InsnBitsDigitalOutput,
+               i_APCI3XXX_InsnReadDigitalOutput,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               i_APCI3XXX_InsnConfigInitTTLIO,
+               i_APCI3XXX_InsnBitsTTLIO,
+               i_APCI3XXX_InsnReadTTLIO,
+               i_APCI3XXX_InsnWriteTTLIO
+               },
+
+               {"apci3116-16-4", 
+               0x15B8,
+               0x3022,
+               256,
+               256,
+               256,
+               256,
+               ADDIDATA_NO_EEPROM,
+               ADDIDATA_9054,
+               16, 
+               8, 
+               16, 
+               4, 
+               65535, 
+               4095,
+               &range_apci3XXX_ai, 
+               &range_apci3XXX_ao,
+               4,
+               4,
+               0xF,
+               24,
+               &range_apci3XXX_ttl,
+               0,
+               0,
+               6,
+               5000,
+               0,
+               v_APCI3XXX_Interrupt,
+               i_APCI3XXX_Reset,
+               i_APCI3XXX_InsnConfigAnalogInput,
+               i_APCI3XXX_InsnReadAnalogInput,                                       
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               i_APCI3XXX_InsnWriteAnalogOutput,
+               NULL,
+               NULL,
+               i_APCI3XXX_InsnReadDigitalInput,
+               NULL,
+               i_APCI3XXX_InsnBitsDigitalInput,
+               NULL,
+               i_APCI3XXX_InsnWriteDigitalOutput,
+               i_APCI3XXX_InsnBitsDigitalOutput,
+               i_APCI3XXX_InsnReadDigitalOutput,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               i_APCI3XXX_InsnConfigInitTTLIO,
+               i_APCI3XXX_InsnBitsTTLIO,
+               i_APCI3XXX_InsnReadTTLIO,
+               i_APCI3XXX_InsnWriteTTLIO
+               },
+
+               {"apci3116-8-4", 
+               0x15B8,
+               0x3023,
+               256,
+               256,
+               256,
+               256,
+               ADDIDATA_NO_EEPROM,
+               ADDIDATA_9054,
+               8, 
+               4, 
+               8, 
+               4, 
+               65535, 
+               4095,
+               &range_apci3XXX_ai, 
+               &range_apci3XXX_ao,
+               4,
+               4,
+               0xF,
+               24,
+               &range_apci3XXX_ttl,
+               0,
+               0,
+               6,
+               5000,
+               0,
+               v_APCI3XXX_Interrupt,
+               i_APCI3XXX_Reset,
+               i_APCI3XXX_InsnConfigAnalogInput,
+               i_APCI3XXX_InsnReadAnalogInput,                                       
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               i_APCI3XXX_InsnWriteAnalogOutput,
+               NULL,
+               NULL,
+               i_APCI3XXX_InsnReadDigitalInput,
+               NULL,
+               i_APCI3XXX_InsnBitsDigitalInput,
+               NULL,
+               i_APCI3XXX_InsnWriteDigitalOutput,
+               i_APCI3XXX_InsnBitsDigitalOutput,
+               i_APCI3XXX_InsnReadDigitalOutput,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               i_APCI3XXX_InsnConfigInitTTLIO,
+               i_APCI3XXX_InsnBitsTTLIO,
+               i_APCI3XXX_InsnReadTTLIO,
+               i_APCI3XXX_InsnWriteTTLIO
+               },
+
+               {"apci3003", 
+               0x15B8,
+               0x300B,
+               256,
+               256,
+               256,
+               256,
+               ADDIDATA_NO_EEPROM,
+               ADDIDATA_9054,
+               0, 
+               4, 
+               4, 
+               0, 
+               65535, 
+               0,
+               &range_apci3XXX_ai, 
+               NULL,
+               4,
+               4,
+               0xF,
+               0,
+               NULL,
+               0,
+               0,
+               7,
+               2500,
+               0,
+               v_APCI3XXX_Interrupt,
+               i_APCI3XXX_Reset,
+               i_APCI3XXX_InsnConfigAnalogInput,
+               i_APCI3XXX_InsnReadAnalogInput,                                       
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               i_APCI3XXX_InsnReadDigitalInput,
+               NULL,
+               i_APCI3XXX_InsnBitsDigitalInput,
+               NULL,
+               i_APCI3XXX_InsnWriteDigitalOutput,
+               i_APCI3XXX_InsnBitsDigitalOutput,
+               i_APCI3XXX_InsnReadDigitalOutput,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL
+               },
+
+               {"apci3002-16", 
+               0x15B8,
+               0x3002,
+               256,
+               256,
+               256,
+               256,
+               ADDIDATA_NO_EEPROM,
+               ADDIDATA_9054,
+               0, 
+               16, 
+               16, 
+               0, 
+               65535, 
+               0,
+               &range_apci3XXX_ai, 
+               NULL,
+               4,
+               4,
+               0xF,
+               0,
+               NULL,
+               0,
+               0,
+               6,
+               5000,
+               0,
+               v_APCI3XXX_Interrupt,
+               i_APCI3XXX_Reset,
+               i_APCI3XXX_InsnConfigAnalogInput,
+               i_APCI3XXX_InsnReadAnalogInput,                                       
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               i_APCI3XXX_InsnReadDigitalInput,
+               NULL,
+               i_APCI3XXX_InsnBitsDigitalInput,
+               NULL,
+               i_APCI3XXX_InsnWriteDigitalOutput,
+               i_APCI3XXX_InsnBitsDigitalOutput,
+               i_APCI3XXX_InsnReadDigitalOutput,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL
+               },
+
+               {"apci3002-8", 
+               0x15B8,
+               0x3003,
+               256,
+               256,
+               256,
+               256,
+               ADDIDATA_NO_EEPROM,
+               ADDIDATA_9054,
+               0, 
+               8, 
+               8, 
+               0, 
+               65535, 
+               0,
+               &range_apci3XXX_ai, 
+               NULL,
+               4,
+               4,
+               0xF,
+               0,
+               NULL,
+               0,
+               0,
+               6,
+               5000,
+               0,
+               v_APCI3XXX_Interrupt,
+               i_APCI3XXX_Reset,
+               i_APCI3XXX_InsnConfigAnalogInput,
+               i_APCI3XXX_InsnReadAnalogInput,                                       
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               i_APCI3XXX_InsnReadDigitalInput,
+               NULL,
+               i_APCI3XXX_InsnBitsDigitalInput,
+               NULL,
+               i_APCI3XXX_InsnWriteDigitalOutput,
+               i_APCI3XXX_InsnBitsDigitalOutput,
+               i_APCI3XXX_InsnReadDigitalOutput,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL
+               },
+
+               {"apci3002-4", 
+               0x15B8,
+               0x3004,
+               256,
+               256,
+               256,
+               256,
+               ADDIDATA_NO_EEPROM,
+               ADDIDATA_9054,
+               0, 
+               4, 
+               4, 
+               0, 
+               65535, 
+               0,
+               &range_apci3XXX_ai, 
+               NULL,
+               4,
+               4,
+               0xF,
+               0,
+               NULL,
+               0,
+               0,
+               6,
+               5000,
+               0,
+               v_APCI3XXX_Interrupt,
+               i_APCI3XXX_Reset,
+               i_APCI3XXX_InsnConfigAnalogInput,
+               i_APCI3XXX_InsnReadAnalogInput,                                       
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               i_APCI3XXX_InsnReadDigitalInput,
+               NULL,
+               i_APCI3XXX_InsnBitsDigitalInput,
+               NULL,
+               i_APCI3XXX_InsnWriteDigitalOutput,
+               i_APCI3XXX_InsnBitsDigitalOutput,
+               i_APCI3XXX_InsnReadDigitalOutput,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL
+               },
+
+               {"apci3500", 
+               0x15B8,
+               0x3024,
+               256,
+               256,
+               256,
+               256,
+               ADDIDATA_NO_EEPROM,
+               ADDIDATA_9054,
+               0, 
+               0, 
+               0, 
+               4, 
+               0, 
+               4095,
+               NULL, 
+               &range_apci3XXX_ao,
+               0,
+               0,
+               0,
+               24,
+               &range_apci3XXX_ttl,
+               0,
+               0,
+               0,
+               0,
+               0,
+               v_APCI3XXX_Interrupt,
+               i_APCI3XXX_Reset,
+               NULL,
+               NULL,                                       
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               i_APCI3XXX_InsnWriteAnalogOutput,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               i_APCI3XXX_InsnConfigInitTTLIO,
+               i_APCI3XXX_InsnBitsTTLIO,
+               i_APCI3XXX_InsnReadTTLIO,
+               i_APCI3XXX_InsnWriteTTLIO
+               },
+};
+
+#define n_boardtypes (sizeof(boardtypes)/sizeof(boardtype))
+
+comedi_driver driver_addi ={
+               driver_name:    "addi_common",
+               module:         THIS_MODULE,
+               attach:         i_ADDI_Attach,
+               detach:         i_ADDI_Detach, 
+               num_names:      n_boardtypes,
+               board_name:     boardtypes,
+               offset:         sizeof(boardtype),
+       };
 
 
 //This macro is defined in comedidev.h
@@ -523,7 +2465,6 @@ COMEDI_INITCLEANUP(driver_addi);
 
 
 
-
 /*
 +----------------------------------------------------------------------------+
 | Function name     :static int i_ADDI_Attach(comedi_device *dev,            |
@@ -548,339 +2489,293 @@ COMEDI_INITCLEANUP(driver_addi);
 static int i_ADDI_Attach(comedi_device *dev,comedi_devconfig *it)
 {
        comedi_subdevice *s;
-       int ret,pages,i;
+       int ret,pages,i,n_subdevices;
         DWORD dw_Dummy; 
-       unsigned short io_addr[5],master,irq;//v_58
-        unsigned int iobase_a,iobase_main,iobase_addon,iobase_reserved;
+       unsigned long io_addr[5];
+       unsigned short master,irq;//v_58
+        unsigned long iobase_a,iobase_main,iobase_addon,iobase_reserved;
        struct pcilst_struct *card=NULL;
        unsigned char pci_bus,pci_slot,pci_func;
+       int i_Dma = 0;
+       static char c_Identifier [150];
+       
+       sprintf (c_Identifier, "Addi-Data GmbH Comedi %s", this_board->pc_DriverName);
  
        if (!pci_list_builded) 
-       {
-               v_pci_card_list_init(this_board->i_VendorId,1); //1 for displaying the list..
-               pci_list_builded=1;
-       }
+           {
+           v_pci_card_list_init(this_board->i_VendorId,1); //1 for displaying the list..
+           pci_list_builded=1;
+           }
+           
        //rt_printk("comedi%d: addi_common: board=%s",dev->minor,this_board->pc_DriverName);
        
-        if ((card=ptr_select_and_alloc_pci_card(this_board->i_VendorId, this_board->i_DeviceId, it->options[0], it->options[1]))==NULL) 
-       return -EIO;
+       if ((this_board->i_Dma) && (it->options[2] == 0))
+          {
+          i_Dma = 1;
+          }
+       
+       if ((card=ptr_select_and_alloc_pci_card(this_board->i_VendorId, 
+                                               this_board->i_DeviceId,
+                                               it->options[0],
+                                               it->options[1],
+                                               i_Dma))==NULL) 
+          {
+          return -EIO;
+          }
+          
        if ((i_pci_card_data(card,&pci_bus,&pci_slot,&pci_func,&io_addr[0],&irq,&master))<0) 
-       {
-               i_pci_card_free(card);
-               rt_printk(" - Can't get AMCC data!\n");
-               return -EIO;
-       }
+          {
+          i_pci_card_free(card);
+          printk(" - Can't get AMCC data!\n");
+          return -EIO;
+          }
+          
        iobase_a=io_addr[0];
        iobase_main=io_addr[1];
        iobase_addon=io_addr[2];
         iobase_reserved=io_addr[3];
-       rt_printk(", b:s:f=%d:%d:%d, base0:0x%4x, base1: 0x%4x, base2: 0x%4x",pci_bus,pci_slot,pci_func,io_addr[0],io_addr[1],io_addr[2]);
-        if (check_region(iobase_main, this_board->i_IorangeBase1) < 0) 
-        {
-           rt_printk("I/O port conflict\n");
-           return -EIO;
-        }
-        //if(this_board->i_Dma)
-        if(iobase_a) 
-        {
-               if (check_region(iobase_a, this_board->i_IorangeBase0) < 0) 
-               {
-                       printk("AMCC check region failed\n"); 
-                       rt_printk("I/O port conflict\n");
-                       return -EIO;
-               }
-        }
-
-        // ##
-        if(io_addr[2])
-        {
-          if (check_region(io_addr[2], this_board->i_IorangeBase2) < 0) 
-               {
-                       printk("Base 2 check region failed\n"); 
-                       rt_printk("I/O port conflict\n");
-                       return -EIO;
-               }
-
-
-        }  
-       //##
-       dev->iobase=iobase_main;// DAQ base address...
-       request_region(dev->iobase,  this_board->i_IorangeBase1, "ADDI COMMON");
-
-       dev->board_name =this_board->pc_DriverName;
-       if((ret=alloc_private(dev,sizeof(addi_private)))<0)
-       return -ENOMEM;
-       devpriv->amcc=card;
-       devpriv->master=master; //testing 
-        devpriv->iobase=dev->iobase;
-       devpriv->i_IobaseAmcc=iobase_a;//AMCC base address...
-       devpriv->i_IobaseAddon=iobase_addon;//ADD ON base address....
-        devpriv->i_IobaseReserved=iobase_reserved; 
-
-        //if(this_board->i_Dma)
-        if(iobase_a)
-        {
-               request_region(devpriv->i_IobaseAmcc,this_board->i_IorangeBase0, "ADDI COMMON");
-        }
+       printk("\nBus %d: Slot %d: Funct%d\nBase0: 0x%8lx\nBase1: 0x%8lx\nBase2: 0x%8lx\nBase3: 0x%8lx\n",
+               pci_bus,pci_slot,pci_func,io_addr[0],io_addr[1],io_addr[2],io_addr[3]);
+       
+       if ((this_board->pc_EepromChip == NULL) || (strcmp (this_board->pc_EepromChip, ADDIDATA_9054) != 0))
+          {
+          if (iobase_main)
+             {
+             if (check_region(iobase_main, this_board->i_IorangeBase1) < 0) 
+                {
+                printk("I/O port conflict\n");
+                return -EIO;
+                }
+             }
+          
+           //if(this_board->i_Dma)
+           if(iobase_a) 
+              {
+             if (check_region(iobase_a, this_board->i_IorangeBase0) < 0) 
+                {
+                printk("AMCC check region failed\n"); 
+                printk("I/O port conflict\n");
+                return -EIO;
+               }
+             }
+
+          // ##
+          if(io_addr[2])
+             {
+             if (check_region(io_addr[2], this_board->i_IorangeBase2) < 0) 
+                {
+                printk("\nBase 2 check region failed"); 
+                printk("\nI/O port conflict");
+                return -EIO;
+                }
+             }
+          //##
+       
+          /************************************/
+          /* Test if more that 1 address used */
+          /************************************/
+       
+          if (this_board->i_IorangeBase1 != 0)
+             {
+             dev->iobase=iobase_main;// DAQ base address...
+             printk("\nrequest_region i_IorangeBase1 - 1\n");
+             request_region(dev->iobase,  this_board->i_IorangeBase1, c_Identifier);
+             printk("\nrequest_region i_IorangeBase1 - 1 OK\n");
+             }
+          else
+             {
+             dev->iobase=iobase_a;// DAQ base address...
+             printk("\nrequest_region i_IorangeBase0 - 2");
+             request_region(dev->iobase,  this_board->i_IorangeBase0, c_Identifier);
+             printk("\nrequest_region i_IorangeBase0 - 2 %lX OK", dev->iobase);
+             }
+
+          dev->board_name =this_board->pc_DriverName;
+          if((ret=alloc_private(dev,sizeof(addi_private)))<0)
+             {
+             return -ENOMEM;
+             }
+          devpriv->amcc=card;
+          devpriv->master=master; //testing 
+           devpriv->iobase=dev->iobase;
+          devpriv->i_IobaseAmcc=iobase_a;//AMCC base address...
+          devpriv->i_IobaseAddon=iobase_addon;//ADD ON base address....
+           devpriv->i_IobaseReserved=iobase_reserved; 
+          devpriv->ps_BoardInfo = this_board;
+
+           //if(this_board->i_Dma)
+          if((iobase_a) && (iobase_a != dev->iobase))
+             {
+             request_region(devpriv->i_IobaseAmcc,this_board->i_IorangeBase0, c_Identifier);
+             printk("\nrequest_region i_IorangeBase0 - 3 OK\n");
+             }
         
-        //##
-       if(io_addr[2])
-        {
-               request_region(io_addr[2],this_board->i_IorangeBase2, "ADDI COMMON");
-        }
+           //##
+          if(io_addr[2])
+             {
+             printk("request_region i_IorangeBase2\n");
+             request_region(io_addr[2],this_board->i_IorangeBase2, c_Identifier);
+             printk("request_region i_IorangeBase2 OK\n");
+             }
+          }
+       else
+          {
+          if((ret=alloc_private(dev,sizeof(addi_private)))<0)
+             {
+             return -ENOMEM;
+             }
+          
+          if (pci_request_regions (card->pcidev, c_Identifier))
+             {
+             printk("\nRequest regions error\n");
+             return -EIO;
+             }
+             
+          dev->board_name =this_board->pc_DriverName;
+          dev->iobase=io_addr[2];
+          devpriv->amcc=card;
+           devpriv->iobase=io_addr[2];
+          devpriv->ps_BoardInfo = this_board;
+          devpriv->i_IobaseReserved=io_addr[3];
+          printk ("\nioremap begin");
+          devpriv->dw_AiBase=(UINT) ioremap(io_addr[3],this_board->i_IorangeBase3);
+          printk ("\nioremap end");
+          }
 
         //##
 
        if (irq>0)  
-       {
-               if (comedi_request_irq(irq, v_ADDI_Interrupt, SA_SHIRQ, "ADDI COMMON", dev)) 
-               {
-                       rt_printk(", unable to allocate IRQ %d, DISABLING IT", irq);
-                       irq=0; /* Can't use IRQ */
-               } 
-               else 
-               {
-                       rt_printk(", irq=%d", irq);
-               }    
-       } 
+          {
+          if (comedi_request_irq(irq, v_ADDI_Interrupt, SA_SHIRQ, c_Identifier, dev) < 0) 
+             {
+             printk(", unable to allocate IRQ %d, DISABLING IT", irq);
+             irq=0; /* Can't use IRQ */
+             } 
+          else 
+             {
+             rt_printk("\nirq=%d", irq);
+             enable_irq (irq);
+             }    
+          } 
        else 
-       {
-               rt_printk(", IRQ disabled");
-       }
-       rt_printk("\n%d %d %d\n",it->options[0],it->options[1],it->options[2]); 
+          {
+          rt_printk(", IRQ disabled");
+          }
+          
+       printk("\nOption %d %d %d\n",it->options[0],it->options[1],it->options[2]); 
        dev->irq = irq;
         
        // Read eepeom and fill boardtype Structure
         
        if(this_board->i_PCIEeprom)
-       { 
-          if (!(strcmp(this_board->pc_EepromChip, "S5920")))
-             {                         
-               // Set 3 wait stait 
-               if(!(strcmp(this_board->pc_DriverName,"apci035")))
-                 {
-                  outl(0x80808082,devpriv->i_IobaseAmcc+0x60); 
-                 }
-               else
-                 { 
-               outl(0x83838383,devpriv->i_IobaseAmcc+0x60);
-                 }
-               // Enable the interrupt for the controler 
-               dw_Dummy =  inl(devpriv->i_IobaseAmcc+ 0x38);
-               outl(dw_Dummy | 0x2000,devpriv->i_IobaseAmcc+0x38);
-             }
-       i_EepromReadMainHeader(io_addr[0],this_board->pc_EepromChip,dev);
-       } 
-       if (it->options[2]>0)   \r
+          { 
+          printk("\nPCI Eeprom used"); 
+          if (!(strcmp(this_board->pc_EepromChip, "S5920")))
+             {
+             // Set 3 wait stait 
+             if(!(strcmp(this_board->pc_DriverName,"apci035")))
+                {
+                outl(0x80808082,devpriv->i_IobaseAmcc+0x60); 
+                }
+             else
+                { 
+                outl(0x83838383,devpriv->i_IobaseAmcc+0x60);
+                }
+             // Enable the interrupt for the controler 
+             dw_Dummy =  inl(devpriv->i_IobaseAmcc+ 0x38);
+             outl(dw_Dummy | 0x2000,devpriv->i_IobaseAmcc+0x38);
+             printk ("\nEnable the interrupt for the controler");
+             }
+          printk("\nRead Eeprom"); 
+          i_EepromReadMainHeader(io_addr[0],this_board->pc_EepromChip,dev);
+          } 
+       else
+          {
+          printk("\nPCI Eeprom unused"); 
+          }
+       
+       if (it->options[2]>0)   
          {
-            devpriv->us_UseDma=ADDI_DISABLE;
+         devpriv->us_UseDma=ADDI_DISABLE;
          }
        else
          {
-            devpriv->us_UseDma=ADDI_ENABLE;
+         devpriv->us_UseDma=ADDI_ENABLE;
          }
        
-        if(this_board->i_Dma)
-        { 
-               if (devpriv->us_UseDma==ADDI_ENABLE) 
-               {       
-                       // alloc DMA buffers
-                       devpriv->b_DmaDoubleBuffer=0;
-                       for (i=0; i<2; i++) 
-                       {
-                               for (pages=4; pages>=0; pages--)
-                               {
-                       
-                                       if((devpriv->ul_DmaBufferVirtual[i]=__get_free_pages(GFP_KERNEL,pages)))
-                                       break;
-                
-                               }
-        
-
-                               if (devpriv->ul_DmaBufferVirtual[i]) 
-                               {
-                                       devpriv->ui_DmaBufferPages[i]=pages;
-                                       devpriv->ui_DmaBufferSize[i]=PAGE_SIZE*pages;
-                                       devpriv->ui_DmaBufferSamples[i]=devpriv->ui_DmaBufferSize[i]>>1;
-                                       devpriv->ul_DmaBufferHw[i]=virt_to_bus((void*)devpriv->ul_DmaBufferVirtual[i]);
-                               
-                               }
-                       }
-                       if (!devpriv->ul_DmaBufferVirtual[0]) 
-                       {
-                               rt_printk(", Can't allocate DMA buffer, DMA disabled!");
-                               master=0;
-                               devpriv->us_UseDma=ADDI_DISABLE;
-                       }
-
-                       if (devpriv->ul_DmaBufferVirtual[1])
-                       devpriv->b_DmaDoubleBuffer=1;
-
-
-               }
-       
-
-               if ((devpriv->us_UseDma==ADDI_ENABLE)) 
-               {
-                       rt_printk("\nDMA ENABLED\n");
-               } 
-               else 
-               {
-                       rt_printk("\nDMA DISABLED\n");
-               }
-        }
-
-
-
- if (!strcmp(this_board->pc_DriverName,"apci1710"))
-    {
-       dev->n_subdevices = 9;
-       if((ret=alloc_subdevices(dev))<0)
-       return ret;
-        // Allocate and Initialise Timer Subdevice Structures          
-       s = dev->subdevices + 0;
-        
-       s->type = COMEDI_SUBD_TIMER;
-       s->subdev_flags = SDF_WRITEABLE|SDF_RT|SDF_GROUND|SDF_COMMON; 
-       s->n_chan = 3; 
-       s->maxdata = 0; 
-       s->len_chanlist = 3;
-       s->range_table = &range_digital;       
-        s->insn_write=i_APCI1710_InsnWriteEnableDisableTimer;
-       s->insn_read=i_APCI1710_InsnReadAllTimerValue;
-       s->insn_config=i_APCI1710_InsnConfigInitTimer;
-       s->insn_bits=i_APCI1710_InsnBitsTimer;
-       
-
-       // Allocate and Initialise DIO Subdevice Structures     
-       s = dev->subdevices + 1;
-        
-       s->type = COMEDI_SUBD_DIO;
-       s->subdev_flags = SDF_WRITEABLE|SDF_READABLE|SDF_RT|SDF_GROUND|SDF_COMMON;
-       s->n_chan = 7;
-       s->maxdata = 1;
-       s->len_chanlist = 7;
-       s->range_table = &range_digital;        
-               s->insn_config=i_APCI1710_InsnConfigDigitalIO;
-               s->insn_read= i_APCI1710_InsnReadDigitalIOChlValue;
-       s->insn_bits=i_APCI1710_InsnBitsDigitalIOPortOnOff;
-       s->insn_write=i_APCI1710_InsnWriteDigitalIOChlOnOff;
-        
-
-        // Allocate and Initialise Chrono Subdevice Structures         
-       s = dev->subdevices + 2;
-        
-       s->type = COMEDI_SUBD_CHRONO;
-       s->subdev_flags = SDF_WRITEABLE|SDF_RT|SDF_GROUND|SDF_COMMON; 
-       s->n_chan = 4; 
-       s->maxdata = 0; 
-       s->len_chanlist = 4;
-       s->range_table = &range_digital;        
-        s->insn_write=i_APCI1710_InsnWriteEnableDisableChrono;
-       s->insn_read=i_APCI1710_InsnReadChrono;
-       s->insn_config=i_APCI1710_InsnConfigInitChrono;
-       s->insn_bits=i_APCI1710_InsnBitsChronoDigitalIO;
+       if(this_board->i_Dma)
+          { 
+          printk("\nDMA used"); 
+          if (devpriv->us_UseDma==ADDI_ENABLE) 
+             {
+             // alloc DMA buffers
+             devpriv->b_DmaDoubleBuffer=0;
+             for (i=0; i<2; i++) 
+                {
+                for (pages=4; pages>=0; pages--)
+                   {
+                   if((devpriv->ul_DmaBufferVirtual[i]=__get_free_pages(GFP_KERNEL,pages)))
+                      {
+                      break;
+                      }
+                   }
+                if (devpriv->ul_DmaBufferVirtual[i]) 
+                   {
+                   devpriv->ui_DmaBufferPages[i]=pages;
+                   devpriv->ui_DmaBufferSize[i]=PAGE_SIZE*pages;
+                   devpriv->ui_DmaBufferSamples[i]=devpriv->ui_DmaBufferSize[i]>>1;
+                   devpriv->ul_DmaBufferHw[i]=virt_to_bus((void*)devpriv->ul_DmaBufferVirtual[i]);
+                   }
+                }
+             if (!devpriv->ul_DmaBufferVirtual[0]) 
+                {
+                rt_printk(", Can't allocate DMA buffer, DMA disabled!");
+                master=0;
+                devpriv->us_UseDma=ADDI_DISABLE;
+                }
+
+             if (devpriv->ul_DmaBufferVirtual[1])
+                {
+                devpriv->b_DmaDoubleBuffer=1;
+                }
+             }
        
-       
-       // Allocate and Initialise PWM Subdevice Structures                 
-       s = dev->subdevices + 3;
-       s->type = COMEDI_SUBD_PWM;
-       s->subdev_flags = SDF_WRITEABLE|SDF_READABLE|SDF_RT|SDF_GROUND|SDF_COMMON;
-       s->n_chan = 3;
-       s->maxdata = 1;
-       s->len_chanlist = 3;
-       s->range_table = &range_digital;
-       s->io_bits=0;           //all bits input        
-       s->insn_config = i_APCI1710_InsnConfigPWM;
-       s->insn_read   = i_APCI1710_InsnReadGetPWMStatus;
-       s->insn_write  = i_APCI1710_InsnWritePWM;
-        s->insn_bits   = i_APCI1710_InsnBitsReadPWMInterrupt;
-
-       // Allocate and Initialise TTLIO Subdevice Structures
-       s = dev->subdevices + 4;
-       s->type = COMEDI_SUBD_TTLIO;
-       s->subdev_flags = SDF_WRITEABLE|SDF_READABLE|SDF_RT|SDF_GROUND|SDF_COMMON;
-       s->n_chan = 8;
-       s->maxdata = 1;
-       s->len_chanlist = 8;
-       s->range_table = &range_apci1710_ttl; // to pass arguments in range     
-        s->insn_config         = i_APCI1710_InsnConfigInitTTLIO;
-       s->insn_bits    = i_APCI1710_InsnBitsReadTTLIO;
-       s->insn_write   = i_APCI1710_InsnWriteSetTTLIOChlOnOff;
-        s->insn_read   = i_APCI1710_InsnReadTTLIOAllPortValue;
-
 
-       // Allocate and Initialise TOR Subdevice Structures
-       s = dev->subdevices + 5;
-       s->type = COMEDI_SUBD_TOR;
-       s->subdev_flags = SDF_WRITEABLE|SDF_READABLE|SDF_RT|SDF_GROUND|SDF_COMMON;
-       s->n_chan = 8;
-       s->maxdata = 1;
-       s->len_chanlist = 8;
-       s->range_table = &range_digital;
-       s->io_bits=0;           //all bits input        
-        s->insn_config = i_APCI1710_InsnConfigInitTorCounter;
-       s->insn_read   = i_APCI1710_InsnReadGetTorCounterInitialisation;
-       s->insn_write  = i_APCI1710_InsnWriteEnableDisableTorCounter;
-       s->insn_bits   = i_APCI1710_InsnBitsGetTorCounterProgressStatusAndValue;
-       // Allocate and Initialise SSI Subdevice Structures
-       s = dev->subdevices + 6;
-       s->type = COMEDI_SUBD_SSI;
-       s->subdev_flags = SDF_WRITEABLE|SDF_READABLE|SDF_RT|SDF_GROUND|SDF_COMMON;
-       s->n_chan =4;
-       s->maxdata = 1;
-       s->len_chanlist = 4;
-       s->range_table = &range_apci1710_ssi;   
-       s->insn_config = i_APCI1710_InsnConfigInitSSI;
-       s->insn_read   = i_APCI1710_InsnReadSSIValue;
-       s->insn_bits  = i_APCI1710_InsnBitsSSIDigitalIO;
-       // Allocate and Initialise PULSEENCODER Subdevice Structures       
-       s                       = dev->subdevices + 7;
-       s->type                 = COMEDI_SUBD_PULSEENCODER;
-       s->subdev_flags = SDF_WRITEABLE|SDF_READABLE|SDF_RT|SDF_GROUND|SDF_COMMON;
-       s->n_chan               = 4;
-       s->maxdata              = 1;
-       s->len_chanlist = 4;
-       s->range_table  = &range_digital;       
-       s->insn_config  = i_APCI1710_InsnConfigInitPulseEncoder;
-       s->insn_write   = i_APCI1710_InsnWriteEnableDisablePulseEncoder;
-       s->insn_bits    = i_APCI1710_InsnBitsReadWritePulseEncoder;
-       s->insn_read    = i_APCI1710_InsnReadInterruptPulseEncoder;
-
-       // Allocate and Initialise INCREMENTALCOUNTER Subdevice Structures     
-       s                       = dev->subdevices + 8;
-       s->type                 = COMEDI_SUBD_INCREMENTALCOUNTER;
-       s->subdev_flags = SDF_WRITEABLE|SDF_READABLE|SDF_RT|SDF_GROUND|SDF_COMMON;
-       s->n_chan               = 500;
-       s->maxdata              = 1;
-       s->len_chanlist = 500;
-       s->range_table  = &range_apci1710_inccpt;       
-       s->insn_config  = i_APCI1710_InsnConfigINCCPT;
-       s->insn_write   = i_APCI1710_InsnWriteINCCPT;
-       s->insn_read    = i_APCI1710_InsnReadINCCPT;
-       s->insn_bits    = i_APCI1710_InsnBitsINCCPT;
-
-               // save base address
-       devpriv->s_BoardInfos.ui_Address=io_addr[2];
-  }       
-  else
-  {
-       dev->n_subdevices = 6;
-       if((ret=alloc_subdevices(dev))<0)
+          if ((devpriv->us_UseDma==ADDI_ENABLE)) 
+             {
+             rt_printk("\nDMA ENABLED\n");
+             } 
+          else 
+             {
+             printk("\nDMA DISABLED\n");
+             }
+          }
+
+       if (!strcmp(this_board->pc_DriverName,"apci1710"))
+          {
+          i_ADDI_AttachPCI1710 (dev);
+    
+          // save base address
+          devpriv->s_BoardInfos.ui_Address=io_addr[2];
+          }       
+       else
+       {
+       //Update-0.7.57->0.7.68dev->n_subdevices = 7;
+       n_subdevices = 7;
+       if((ret=alloc_subdevices(dev,n_subdevices))<0)
        return ret;
 
      // Allocate and Initialise AI Subdevice Structures
        s = dev->subdevices + 0;
-        if(this_board->i_NbrAiChannel)
+        if((this_board->i_NbrAiChannel) || (this_board->i_NbrAiChannelDiff))
         {
        dev->read_subdev = s;
        s->type = COMEDI_SUBD_AI;
        s->subdev_flags = SDF_READABLE|SDF_RT|SDF_COMMON|SDF_GROUND|SDF_DIFF;
-       s->n_chan = this_board->i_NbrAiChannel;
+       if (this_board->i_NbrAiChannel)
+          s->n_chan = this_board->i_NbrAiChannel;
+       else
+          s->n_chan = this_board->i_NbrAiChannelDiff;
        s->maxdata = this_board->i_AiMaxdata;
        s->len_chanlist = this_board->i_AiChannelList;
        s->range_table = this_board->pr_AiRangelist;
@@ -929,13 +2824,11 @@ static int i_ADDI_Attach(comedi_device *dev,comedi_devconfig *it)
        s->len_chanlist = this_board->i_NbrDiChannel;
        s->range_table = &range_digital;
        s->io_bits=0;           /* all bits input */
-       
         s->insn_config=this_board->i_hwdrv_InsnConfigDigitalInput;
         s->insn_read=this_board->i_hwdrv_InsnReadDigitalInput;
         s->insn_write=this_board->i_hwdrv_InsnWriteDigitalInput;
        s->insn_bits=this_board->i_hwdrv_InsnBitsDigitalInput;
-        }
+       }
        else
        {
                s->type=COMEDI_SUBD_UNUSED;
@@ -945,7 +2838,7 @@ static int i_ADDI_Attach(comedi_device *dev,comedi_devconfig *it)
         if(this_board->i_NbrDoChannel)
        {
        s->type = COMEDI_SUBD_DO;
-       s->subdev_flags = SDF_WRITEABLE|SDF_RT|SDF_GROUND|SDF_COMMON;
+       s->subdev_flags = SDF_READABLE|SDF_WRITEABLE|SDF_RT|SDF_GROUND|SDF_COMMON;
        s->n_chan= this_board->i_NbrDoChannel; 
        s->maxdata = this_board->i_DoMaxdata;
        s->len_chanlist =this_board->i_NbrDoChannel ;
@@ -982,9 +2875,30 @@ static int i_ADDI_Attach(comedi_device *dev,comedi_devconfig *it)
        {
                s->type=COMEDI_SUBD_UNUSED;
        }
-         
+
+    // Allocate and Initialise TTL
+        s = dev->subdevices + 5;
+       if(this_board->i_NbrTTLChannel)
+       {
+       s->type         = COMEDI_SUBD_TTLIO;
+       s->subdev_flags = SDF_WRITEABLE|SDF_READABLE|SDF_RT|SDF_GROUND|SDF_COMMON;
+       s->n_chan       = this_board->i_NbrTTLChannel;
+       s->maxdata      = 0;
+       s->io_bits=0;           /* all bits input */
+       s->len_chanlist = this_board->i_NbrTTLChannel;
+       s->range_table  = this_board->pr_TTLRangelist; // to pass arguments in range    
+        s->insn_config  = this_board->i_hwdr_ConfigInitTTLIO;
+       s->insn_bits    = this_board->i_hwdr_ReadTTLIOBits;
+        s->insn_read    = this_board->i_hwdr_ReadTTLIOAllPortValue;
+       s->insn_write   = this_board->i_hwdr_WriteTTLIOChlOnOff;
+        }
+        else
+       {
+               s->type=COMEDI_SUBD_UNUSED;
+       }
+       
         /* EEPROM */
-       s=dev->subdevices+5;
+       s=dev->subdevices+6;
         if(this_board->i_PCIEeprom)
        {
        s->type=COMEDI_SUBD_MEMORY;
@@ -998,6 +2912,8 @@ static int i_ADDI_Attach(comedi_device *dev,comedi_devconfig *it)
                s->type=COMEDI_SUBD_UNUSED;
        }
      }
+       
+       printk("\ni_ADDI_Attach end\n"); 
        i_ADDI_Reset(dev);
        devpriv->b_ValidDriver=1;
        return 0;
@@ -1026,39 +2942,80 @@ static int i_ADDI_Attach(comedi_device *dev,comedi_devconfig *it)
 
 
 static int i_ADDI_Detach(comedi_device *dev)
-{
-   
-     if (dev->private) 
        {
-               if (devpriv->b_ValidDriver) i_ADDI_Reset(dev);
-                if(devpriv->i_IobaseAmcc)
-                       release_region(devpriv->i_IobaseAmcc,this_board->i_IorangeBase0);
-               if (devpriv->allocated)
-                       i_pci_card_free(devpriv->amcc);
-               if (devpriv->ul_DmaBufferVirtual[0]) 
-                       free_pages(devpriv->ul_DmaBufferVirtual[0],devpriv->ui_DmaBufferPages[0]);
-               if (devpriv->ul_DmaBufferVirtual[1]) 
-                       free_pages(devpriv->ul_DmaBufferVirtual[1],devpriv->ui_DmaBufferPages[1]);
-       }
+   
+       if (dev->private) 
+          {
+          if (devpriv->b_ValidDriver) 
+             {
+             i_ADDI_Reset(dev);
+             }
+          
+          if ((devpriv->ps_BoardInfo->pc_EepromChip == NULL) || (strcmp (devpriv->ps_BoardInfo->pc_EepromChip, ADDIDATA_9054) != 0))
+             {
+             if(devpriv->i_IobaseAmcc)
+                {
+                printk("\nrelease_region base address 0");
+                release_region(devpriv->i_IobaseAmcc,this_board->i_IorangeBase0);
+                printk("\nrelease_region base address 0 OK");
+                }
+                
+             if(this_board->i_IorangeBase1) 
+                {
+                printk("\nrelease_region base address 1");
+                release_region(dev->iobase,this_board->i_IorangeBase1);
+                printk("\nrelease_region base address 1 OK");
+                }
+
+             if(this_board->i_IorangeBase2) 
+                {
+                printk("\nrelease_region base address 2");
+                release_region(devpriv->i_IobaseAddon,this_board->i_IorangeBase2); 
+                printk("\nrelease_region base address 2 OK");
+                }
+                
+             if (devpriv->allocated)
+                {          
+                i_pci_card_free(devpriv->amcc);
+                }
+          
+             if (devpriv->ul_DmaBufferVirtual[0]) 
+                {          
+                free_pages((unsigned long)devpriv->ul_DmaBufferVirtual[0],devpriv->ui_DmaBufferPages[0]);
+                }
+          
+             if (devpriv->ul_DmaBufferVirtual[1]) 
+                {          
+                free_pages((unsigned long)devpriv->ul_DmaBufferVirtual[1],devpriv->ui_DmaBufferPages[1]);
+                }
+             }
+          else
+             {
+             iounmap ((void *) devpriv->dw_AiBase);
+             
+             pci_release_regions(devpriv->amcc->pcidev);
+
+             if (devpriv->allocated)
+                {          
+                i_pci_card_free(devpriv->amcc);
+                }
+             }
            
-       if(dev->irq)
-       {
-               free_irq(dev->irq,dev);
-       }
+          if(dev->irq)
+             {
+             free_irq(dev->irq,dev);
+             }
        
-       if(dev->iobase) release_region(dev->iobase,this_board->i_IorangeBase1);
-        
-        if(devpriv->i_IobaseAddon) release_region(devpriv->i_IobaseAddon,this_board->i_IorangeBase2); 
-           
-       if (pci_list_builded) 
-       {
-         //v_pci_card_list_cleanup(PCI_VENDOR_ID_AMCC);
-          v_pci_card_list_cleanup(this_board->i_VendorId);
-         pci_list_builded=0;
-       }
-
+          if (pci_list_builded) 
+             {
+             //v_pci_card_list_cleanup(PCI_VENDOR_ID_AMCC);
+             v_pci_card_list_cleanup(this_board->i_VendorId);
+             pci_list_builded=0;
+             }
+          }
+             
        return 0;
-}
+       }
 
 
 /*
@@ -1107,11 +3064,11 @@ static int i_ADDI_Reset(comedi_device *dev)
 +----------------------------------------------------------------------------+
 */
 
-static void v_ADDI_Interrupt(int irq, void *d, struct pt_regs *regs)
+static irqreturn_t v_ADDI_Interrupt(int irq, void *d, struct pt_regs *regs)
 {
 comedi_device *dev = d;
 this_board->v_hwdrv_Interrupt(irq,d,regs);
-return;
+return IRQ_RETVAL(1);
 }
 // EEPROM Read Function
 /*
@@ -1147,8 +3104,3 @@ static int i_ADDIDATA_InsnReadEeprom(comedi_device *dev,comedi_subdevice *s,come
    return insn->n;
 
 }
-
-
-
index 3747497e523e13f96c6d796962dc3b2288cb5cdb..205efd370f8c33e75726d8e835b982510f4faa6b 100644 (file)
@@ -1,37 +1,41 @@
-/***********ADDI_COMMON.H*********************/
+/**
+@verbatim
 
+Copyright (C) 2004,2005  ADDI-DATA GmbH for the source code of this module. 
+        
+        ADDI-DATA GmbH 
+        Dieselstrasse 3 
+        D-77833 Ottersweier 
+        Tel: +19(0)7223/9493-0 
+        Fax: +49(0)7223/9493-92 
+        http://www.addi-data-com 
+        info@addi-data.com 
 
+This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
 
+This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
 
+You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 
+You shoud also find the complete GPL in the COPYING file accompanying this source code.
+
+@endverbatim
+*/
 /*
+    
   +-----------------------------------------------------------------------+
   | (C) ADDI-DATA GmbH          Dieselstrasse 3      D-77833 Ottersweier  |
   +-----------------------------------------------------------------------+
   | Tel : +49 (0) 7223/9493-0     | email    : info@addi-data.com         |
   | Fax : +49 (0) 7223/9493-92    | Internet : http://www.addi-data.com   |
   +-----------------------------------------------------------------------+
-  | Project   : ADDI DATA            | Compiler : GCC                                    |
+  | Project   : ADDI-DATA        | Compiler : GCC                        |
   | Modulname : addi_common.h     | Version  : 2.96                       |
   +-------------------------------+---------------------------------------+
-  | Author    :           | Date     :                                    |
+  | Project manager: Eric Stolz   | Date     :  02/12/2002                |
   +-----------------------------------------------------------------------+
   | Description : ADDI COMMON Header File                                 |
   +-----------------------------------------------------------------------+
-  |                             UPDATE'S                                  |
-  +-----------------------------------------------------------------------+
-  |   Date   |   Author  |          Description of updates                |
-  +----------+-----------+------------------------------------------------+
-  |          |                          |                                                                                                |
-  |          |           |                                                                                               |
-  |          |           |                                                           |
-  |          |           |                                                                                               |
-  |          |           |                                                                   |
-  +----------+-----------+------------------------------------------------+
-  |         |                   |                                                                        |
-  |          |           |                                                                                               |
-  |          |           |                                                                               |
-  +----------+-----------+------------------------------------------------+
 */
 
 
@@ -43,7 +47,8 @@
 #include <linux/module.h>
 #include <linux/sched.h>
 #include <linux/mm.h>
-#include <linux/malloc.h>
+//#include <linux/malloc.h>
+#include <linux/slab.h>
 #include <linux/errno.h>
 #include <linux/ioport.h>
 #include <linux/delay.h>
@@ -94,6 +99,7 @@
 #define ADDIDATA_93C76        "93C76"
 #define ADDIDATA_S5920        "S5920"
 #define ADDIDATA_S5933        "S5933"
+#define ADDIDATA_9054         "9054"
 
 // Structures
 // structure for the boardtype
@@ -120,9 +126,13 @@ typedef struct {
                INT         i_NbrDiChannel;      // Number of DI channels
                INT         i_NbrDoChannel;    // Number of DO channels
                INT         i_DoMaxdata;     // data to set all chanels high
-                 
+
+               INT         i_NbrTTLChannel;    // Number of TTL channels
+               PRANGE      pr_TTLRangelist;    // rangelist for TTL
+                                
                 INT         i_Dma;            // dma present or not
                 INT         i_Timer;         //   timer subdevice present or not     
+                BYTE        b_AvailableConvertUnit;
                UINT        ui_MinAcquisitiontimeNs; // Minimum Acquisition in Nano secs
                UINT        ui_MinDelaytimeNs;       // Minimum Delay in Nano secs
 
@@ -159,11 +169,18 @@ int (*i_hwdrv_InsnConfigDigitalOutput)(comedi_device *dev,comedi_subdevice *s,co
 int (*i_hwdrv_InsnWriteDigitalOutput)(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data);
 int (*i_hwdrv_InsnBitsDigitalOutput)(comedi_device *dev,comedi_subdevice *s, comedi_insn *insn,lsampl_t *data);
 int (*i_hwdrv_InsnReadDigitalOutput)(comedi_device *dev,comedi_subdevice *s, comedi_insn *insn,lsampl_t *data);
+
 //TIMER
  int (*i_hwdrv_InsnConfigTimer)(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data);
  int (*i_hwdrv_InsnWriteTimer)(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data);
  int (*i_hwdrv_InsnReadTimer)(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data);
  int (*i_hwdrv_InsnBitsTimer)(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data);  
+
+//TTL IO
+ int (*i_hwdr_ConfigInitTTLIO)(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data);
+ int (*i_hwdr_ReadTTLIOBits)(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data);
+ int (*i_hwdr_ReadTTLIOAllPortValue)(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data);
+ int (*i_hwdr_WriteTTLIOChlOnOff)(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data);
 } boardtype;
 
 
@@ -368,11 +385,13 @@ typedef struct{
                INT      i_IobaseAmcc;  // base+size for AMCC chip
                INT      i_IobaseAddon; //addon base address
                 INT      i_IobaseReserved;
+                DWORD    dw_AiBase;
                struct pcilst_struct    *amcc;          // ptr too AMCC data
                UINT                    master;         // master capable
                BYTE                    allocated;      // we have blocked card
                BYTE                b_ValidDriver;// driver is ok
                BYTE                b_AiContinuous;     // we do unlimited AI  
+               BYTE                b_AiInitialisation;
                UINT                ui_AiActualScan; //how many scans we finished
                UINT                ui_AiBufferPtr;// data buffer ptr in samples
                UINT                ui_AiNbrofChannels;// how many channels is measured
@@ -380,7 +399,9 @@ typedef struct{
                UINT                ui_AiActualScanPosition;  // position in actual scan
                PUINT               pui_AiChannelList; // actual chanlist
                 UINT                ui_AiChannelList[32]; // actual chanlist    
+                BYTE                b_AiChannelConfiguration[32]; // actual chanlist    
                 UINT                ui_AiReadData[32];    
+                DWORD               dw_AiInitialised;
                UINT                ui_AiTimer0;    //Timer Constant for Timer0
                UINT                ui_AiTimer1;    //Timer constant for Timer1 
                UINT                ui_AiFlags;
@@ -390,10 +411,12 @@ typedef struct{
                USHORT              us_UseDma; // To use Dma or not
                BYTE                b_DmaDoubleBuffer;// we can use double buffering
                UINT                ui_DmaActualBuffer; // which buffer is used now
-               ULONG               ul_DmaBufferVirtual[2];// pointers to begin of DMA buffer
+               //*UPDATE-0.7.57->0.7.68
+               //ULONG               ul_DmaBufferVirtual[2];// pointers to begin of DMA buffer
+               sampl_t               *ul_DmaBufferVirtual[2];// pointers to begin of DMA buffer
                ULONG               ul_DmaBufferHw[2]; // hw address of DMA buff
                UINT                ui_DmaBufferSize[2];// size of dma buffer in bytes
-               UINT                ui_DmaBufferUsesize[2];// which size e may now used for transfer
+               UINT                ui_DmaBufferUsesize[2];// which size we may now used for transfer
                UINT                ui_DmaBufferSamples[2];// size in samples
                UINT                ui_DmaBufferPages[2];// number of pages in buffer
                BYTE                b_DigitalOutputRegister; // Digital Output Register   
@@ -412,10 +435,14 @@ typedef struct{
                 BYTE                b_InterruptMode; // eoc eos or dma
                 BYTE                b_EocEosInterrupt; // Enable disable eoc eos interrupt
                 UINT                ui_EocEosConversionTime;  
+                BYTE                b_EocEosConversionTimeBase;
+                BYTE                b_SingelDiff;
                BYTE                            b_ExttrigEnable; //  To enable or disable external trigger
-                struct task_struct *tsk_Current;               // Pointer to the current process
-
-
+                
+               struct task_struct *tsk_Current;               // Pointer to the current process
+               boardtype   *ps_BoardInfo;
+               
+               
 
        // Hardware board infos for 1710
 
@@ -450,6 +477,7 @@ typedef struct{
              }s_InterruptParameters;
   
           str_ModuleInfo s_ModuleInfo [4];
+          ULONG         ul_TTLPortConfiguration[10];
 
        }       addi_private;
 
@@ -468,7 +496,7 @@ static int i_ADDI_Attach(comedi_device *dev,comedi_devconfig *it);
 static int i_ADDI_Detach(comedi_device *dev);
 static int i_ADDI_Reset(comedi_device *dev);
 
-static void v_ADDI_Interrupt(int irq, void *d, struct pt_regs *regs);
+static irqreturn_t v_ADDI_Interrupt(int irq, void *d, struct pt_regs *regs);
 static int i_ADDIDATA_InsnReadEeprom(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data);
 
 
index 72c0d318c2da1492ceba09b1762e80152b04a517..636efb10a2b0ef4c1949730b78df59feba737580 100644 (file)
-
-
-/*
-  +-----------------------------------------------------------------------+
-  | (C) ADDI-DATA GmbH          Dieselstrasse 3      D-77833 Ottersweier  |
-  +-----------------------------------------------------------------------+
-  | Tel : +49 (0) 7223/9493-0     | email    : info@addi-data.com         |
-  | Fax : +49 (0) 7223/9493-92    | Internet : http://www.addi-data.com   |
-  +-----------------------------------------------------------------------+
-  | Project   : ADDI DATA         | Compiler : GCC                                   |
-  | Modulname : addi_eeprom.c     | Version  : 2.96                       |
-  +-------------------------------+---------------------------------------+
-  | Author    :                                  | Date     :                                            |
-  +-----------------------------------------------------------------------+
-  | Description : ADDI EEPROM  Module                                     |
-  +-----------------------------------------------------------------------+
-  |                             UPDATE'S                                  |
-  +-----------------------------------------------------------------------+
-  |   Date   |   Author  |          Description of updates                |
-  +----------+-----------+------------------------------------------------+
-  |          |                          |                                                                                                |
-  |          |           |                                                                                               |
-  |          |           |                                                           |
-  |          |           |                                                                                               |
-  |          |           |                                                                   |
-  +----------+-----------+------------------------------------------------+
-  |         |                   |                                                                        |
-  |          |           |                                                                                               |
-  |          |           |                                                                               |
-  +----------+-----------+------------------------------------------------+
-*/
-
-
-
-
-
-
-
-
-#define NVCMD_BEGIN_READ       (0x7 << 5 ) // nvRam begin read command
-#define NVCMD_LOAD_LOW         (0x4 << 5 ) // nvRam load low command
-#define NVCMD_LOAD_HIGH        (0x5 << 5 ) // nvRam load high command
-#define EE76_CMD_LEN           13              // bits in instructions 
-#define EE_READ                0x0180          // 01 1000 0000 read instruction
-
-#define        WORD                            unsigned short
-#define        DWORD                           unsigned int
-#define PWORD                          unsigned short *
-#define PDWORD                         unsigned int  *
-
-
-
-
-#define EEPROM_DIGITALINPUT                    0
-#define EEPROM_DIGITALOUTPUT                   1
-#define EEPROM_ANALOGINPUT                             2
-#define EEPROM_ANALOGOUTPUT                            3
-#define EEPROM_TIMER                                   4
-#define EEPROM_WATCHDOG                                        5                       
-#define EEPROM_TIMER_WATCHDOG_COUNTER  10
-
-struct str_Functionality
-{
-       BYTE b_Type;
-       WORD w_Address;
-};
-
-
-typedef struct 
-{
-       WORD w_HeaderSize;
-       BYTE b_Nfunctions;
-       struct str_Functionality s_Functions[7];
-}str_MainHeader;
-
-
-
-typedef struct
-{
- WORD w_Nchannel;
- BYTE b_Interruptible;
- WORD w_NinterruptLogic;
-}str_DigitalInputHeader;
-
-typedef struct
-{
- WORD w_Nchannel;
-}str_DigitalOutputHeader;
-
-// used for timer as well as watchdog
-
-typedef struct
-{
-  WORD w_HeaderSize;
-  BYTE b_Resolution;
-  BYTE b_Mode;                // in case of Watchdog it is functionality 
-  WORD w_MinTiming;
-  BYTE b_TimeBase;
-}str_TimerDetails;
-typedef struct
-{
-
-  WORD w_Ntimer;
-  str_TimerDetails s_TimerDetails[4];  //  supports 4 timers
-}str_TimerMainHeader;  
-
-
-typedef struct
-{
-  WORD w_Nchannel;
-  BYTE b_Resolution;
-  }str_AnalogOutputHeader ;
-
-typedef struct
-{
-  WORD w_Nchannel;
-  WORD w_MinConvertTiming;
-  WORD w_MinDelayTiming;
-  BYTE b_HasDma;
-  BYTE b_Resolution;
-} str_AnalogInputHeader;
-
-               /*****************************************/
-               /*            Read Header Functions              */
-               /*****************************************/
-
-INT i_EepromReadMainHeader(WORD        w_PCIBoardEepromAddress,PCHAR   pc_PCIChipInformation,comedi_device *dev);
-
-INT i_EepromReadDigitalInputHeader(WORD w_PCIBoardEepromAddress,PCHAR pc_PCIChipInformation,WORD w_Address,str_DigitalInputHeader *s_Header);
-
-INT i_EepromReadDigitalOutputHeader(WORD w_PCIBoardEepromAddress,PCHAR pc_PCIChipInformation,WORD w_Address,str_DigitalOutputHeader *s_Header);
-
-INT i_EepromReadTimerHeader(WORD w_PCIBoardEepromAddress,PCHAR pc_PCIChipInformation,WORD w_Address,str_TimerMainHeader *s_Header);
-
-INT i_EepromReadAnlogOutputHeader(WORD w_PCIBoardEepromAddress,PCHAR pc_PCIChipInformation,WORD w_Address,str_AnalogOutputHeader *s_Header);
-
-INT i_EepromReadAnlogInputHeader(WORD w_PCIBoardEepromAddress,PCHAR pc_PCIChipInformation,WORD w_Address,str_AnalogInputHeader *s_Header);
-
-               /******************************************/
-               /*      Eeprom Specific Functions                         */
-               /******************************************/
-WORD w_EepromReadWord(WORD     w_PCIBoardEepromAddress,PCHAR   pc_PCIChipInformation,WORD   w_EepromStartAddress);
-VOID v_EepromWaitBusy(WORD     w_PCIBoardEepromAddress);
-VOID v_EepromClock76(DWORD dw_Address,DWORD dw_RegisterValue);
-VOID v_EepromWaitBusy(WORD     w_PCIBoardEepromAddress);
-VOID v_EepromSendCommand76(DWORD dw_Address,DWORD   dw_EepromCommand,BYTE    b_DataLengthInBits);
-VOID v_EepromCs76Read(DWORD dw_Address,WORD    w_offset,PWORD   pw_Value);
-
-
-
-/*
-+----------------------------------------------------------------------------+
-| Function   Name   : WORD w_EepromReadWord                                  |
-|                              (WORD   w_PCIBoardEepromAddress,                         |
-|                               PCHAR  pc_PCIChipInformation,                           |
-|                               WORD   w_EepromStartAddress)                            |
-+----------------------------------------------------------------------------+
-| Task              : Read from eepromn a word                               |
-+----------------------------------------------------------------------------+
-| Input Parameters  : WORD w_PCIBoardEepromAddress : PCI eeprom address      |
-|                                                                                                                                       |
-|                    PCHAR pc_PCIChipInformation  : PCI Chip Type.          |
-|                                                                                                                                       |
-|                    WORD w_EepromStartAddress    : Selected eeprom address |
-+----------------------------------------------------------------------------+
-| Output Parameters : -                                                      |
-+----------------------------------------------------------------------------+
-| Return Value      : Read word value from eeprom                            |
-+----------------------------------------------------------------------------+
-*/
-
+/**\r
+@verbatim\r
+\r
+Copyright (C) 2004,2005  ADDI-DATA GmbH for the source code of this module. \r
+        \r
+        ADDI-DATA GmbH \r
+        Dieselstrasse 3 \r
+        D-77833 Ottersweier \r
+        Tel: +19(0)7223/9493-0 \r
+        Fax: +49(0)7223/9493-92 \r
+        http://www.addi-data-com \r
+        info@addi-data.com \r
+\r
+This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.\r
+\r
+This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.\r
+\r
+You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+\r
+You shoud also find the complete GPL in the COPYING file accompanying this source code.\r
+\r
+@endverbatim\r
+*/\r
+/*\r
+    \r
+  +-----------------------------------------------------------------------+\r
+  | (C) ADDI-DATA GmbH          Dieselstrasse 3      D-77833 Ottersweier  |\r
+  +-----------------------------------------------------------------------+\r
+  | Tel : +49 (0) 7223/9493-0     | email    : info@addi-data.com         |\r
+  | Fax : +49 (0) 7223/9493-92    | Internet : http://www.addi-data.com   |\r
+  +-----------------------------------------------------------------------+\r
+  | Project   : ADDI DATA         | Compiler : GCC                                   |\r
+  | Modulname : addi_eeprom.c     | Version  : 2.96                       |\r
+  +-------------------------------+---------------------------------------+\r
+  | Project manager: Eric Stolz   | Date     :  02/12/2002                |\r
+  +-----------------------------------------------------------------------+\r
+  | Description : ADDI EEPROM  Module                                     |\r
+  +-----------------------------------------------------------------------+\r
+  |                             UPDATE'S                                  |\r
+  +-----------------------------------------------------------------------+\r
+  |   Date   |   Author  |          Description of updates                |\r
+  +----------+-----------+------------------------------------------------+\r
+  |          |                  |                                                |\r
+  |          |           |                                               |\r
+  +----------+-----------+------------------------------------------------+\r
+*/\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+#define NVCMD_BEGIN_READ       (0x7 << 5 ) // nvRam begin read command\r
+#define NVCMD_LOAD_LOW         (0x4 << 5 ) // nvRam load low command\r
+#define NVCMD_LOAD_HIGH        (0x5 << 5 ) // nvRam load high command\r
+#define EE76_CMD_LEN           13              // bits in instructions \r
+#define EE_READ                0x0180          // 01 1000 0000 read instruction\r
+\r
+#define        WORD                            unsigned short\r
+#define PWORD                          unsigned short *\r
+#define PDWORD                         unsigned int  *\r
+\r
+#define        DWORD                           unsigned int\r
+\r
+\r
+\r
+#define EEPROM_DIGITALINPUT                    0\r
+#define EEPROM_DIGITALOUTPUT                   1\r
+#define EEPROM_ANALOGINPUT                             2\r
+#define EEPROM_ANALOGOUTPUT                            3\r
+#define EEPROM_TIMER                                   4\r
+#define EEPROM_WATCHDOG                                        5                       \r
+#define EEPROM_TIMER_WATCHDOG_COUNTER  10\r
+\r
+struct str_Functionality\r
+{\r
+       BYTE b_Type;\r
+       WORD w_Address;\r
+};\r
+\r
+\r
+typedef struct \r
+{\r
+       WORD w_HeaderSize;\r
+       BYTE b_Nfunctions;\r
+       struct str_Functionality s_Functions[7];\r
+}str_MainHeader;\r
+\r
+\r
+\r
+typedef struct\r
+{\r
+ WORD w_Nchannel;\r
+ BYTE b_Interruptible;\r
+ WORD w_NinterruptLogic;\r
+}str_DigitalInputHeader;\r
+\r
+typedef struct\r
+{\r
+ WORD w_Nchannel;\r
+}str_DigitalOutputHeader;\r
+\r
+// used for timer as well as watchdog\r
+\r
+typedef struct\r
+{\r
+  WORD w_HeaderSize;\r
+  BYTE b_Resolution;\r
+  BYTE b_Mode;                // in case of Watchdog it is functionality \r
+  WORD w_MinTiming;\r
+  BYTE b_TimeBase;\r
+}str_TimerDetails;\r
+typedef struct\r
+{\r
+\r
+  WORD w_Ntimer;\r
+  str_TimerDetails s_TimerDetails[4];  //  supports 4 timers\r
+}str_TimerMainHeader;  \r
+\r
+\r
+typedef struct\r
+{\r
+  WORD w_Nchannel;\r
+  BYTE b_Resolution;\r
+  }str_AnalogOutputHeader ;\r
+\r
+typedef struct\r
+{\r
+  WORD w_Nchannel;\r
+  WORD w_MinConvertTiming;\r
+  WORD w_MinDelayTiming;\r
+  BYTE b_HasDma;\r
+  BYTE b_Resolution;\r
+} str_AnalogInputHeader;\r
+\r
+               /*****************************************/\r
+               /*            Read Header Functions              */\r
+               /*****************************************/\r
+\r
+INT i_EepromReadMainHeader(WORD        w_PCIBoardEepromAddress,PCHAR   pc_PCIChipInformation,comedi_device *dev);\r
+\r
+INT i_EepromReadDigitalInputHeader(WORD w_PCIBoardEepromAddress,PCHAR pc_PCIChipInformation,WORD w_Address,str_DigitalInputHeader *s_Header);\r
+\r
+INT i_EepromReadDigitalOutputHeader(WORD w_PCIBoardEepromAddress,PCHAR pc_PCIChipInformation,WORD w_Address,str_DigitalOutputHeader *s_Header);\r
+\r
+INT i_EepromReadTimerHeader(WORD w_PCIBoardEepromAddress,PCHAR pc_PCIChipInformation,WORD w_Address,str_TimerMainHeader *s_Header);\r
+\r
+INT i_EepromReadAnlogOutputHeader(WORD w_PCIBoardEepromAddress,PCHAR pc_PCIChipInformation,WORD w_Address,str_AnalogOutputHeader *s_Header);\r
+\r
+INT i_EepromReadAnlogInputHeader(WORD w_PCIBoardEepromAddress,PCHAR pc_PCIChipInformation,WORD w_Address,str_AnalogInputHeader *s_Header);\r
+\r
+               /******************************************/\r
+               /*      Eeprom Specific Functions                         */\r
+               /******************************************/\r
+WORD w_EepromReadWord(WORD     w_PCIBoardEepromAddress,PCHAR   pc_PCIChipInformation,WORD   w_EepromStartAddress);\r
+VOID v_EepromWaitBusy(WORD     w_PCIBoardEepromAddress);\r
+VOID v_EepromClock76(DWORD dw_Address,DWORD dw_RegisterValue);\r
+VOID v_EepromWaitBusy(WORD     w_PCIBoardEepromAddress);\r
+VOID v_EepromSendCommand76(DWORD dw_Address,DWORD   dw_EepromCommand,BYTE    b_DataLengthInBits);\r
+VOID v_EepromCs76Read(DWORD dw_Address,WORD    w_offset,PWORD   pw_Value);\r
+\r
+\r
+\r
+/*\r
++----------------------------------------------------------------------------+\r
+| Function   Name   : WORD w_EepromReadWord                                  |\r
+|                              (WORD   w_PCIBoardEepromAddress,                         |\r
+|                               PCHAR  pc_PCIChipInformation,                           |\r
+|                               WORD   w_EepromStartAddress)                            |\r
++----------------------------------------------------------------------------+\r
+| Task              : Read from eepromn a word                               |\r
++----------------------------------------------------------------------------+\r
+| Input Parameters  : WORD w_PCIBoardEepromAddress : PCI eeprom address      |\r
+|                                                                                                                                       |\r
+|                    PCHAR pc_PCIChipInformation  : PCI Chip Type.          |\r
+|                                                                                                                                       |\r
+|                    WORD w_EepromStartAddress    : Selected eeprom address |\r
++----------------------------------------------------------------------------+\r
+| Output Parameters : -                                                      |\r
++----------------------------------------------------------------------------+\r
+| Return Value      : Read word value from eeprom                            |\r
++----------------------------------------------------------------------------+\r
+*/\r
+\r
 WORD   w_EepromReadWord(WORD   w_PCIBoardEepromAddress,PCHAR   pc_PCIChipInformation,WORD   w_EepromStartAddress)\r
+\r
 {\r
+\r
        BYTE b_Counter = 0;\r
+\r
        BYTE b_ReadByte = 0;\r
+\r
        BYTE b_ReadLowByte = 0;\r
+\r
        BYTE b_ReadHighByte = 0;\r
+\r
        BYTE b_SelectedAddressLow = 0;\r
+\r
        BYTE b_SelectedAddressHigh = 0;\r
+\r
        WORD w_ReadWord = 0;\r
-       
+\r
+       \r
+\r
 \r
         /**************************/\r
+\r
         /* Test the PCI chip type */\r
+\r
         /**************************/\r
 \r
-
+\r
+\r
+\r
         if ((!strcmp(pc_PCIChipInformation, "S5920")) || \r
+\r
             (!strcmp(pc_PCIChipInformation, "S5933")))\r
+\r
         {\r
-               
+\r
+               \r
           for (b_Counter=0; b_Counter<2; b_Counter++)\r
+\r
             {\r
+\r
               b_SelectedAddressLow  = (w_EepromStartAddress + b_Counter) % 256; //Read the low 8 bit part\r
+\r
               b_SelectedAddressHigh = (w_EepromStartAddress + b_Counter) / 256; //Read the high 8 bit part\r
 \r
+\r
+\r
              /************************************/\r
+\r
              /* Select the load low address mode */\r
+\r
              /************************************/\r
-\r             outb(NVCMD_LOAD_LOW,w_PCIBoardEepromAddress + 0x3F);
-            
-\r             
+\r
+\r
+             outb(NVCMD_LOAD_LOW,w_PCIBoardEepromAddress + 0x3F);\r
+            \r
+\r
+             \r
              /****************/\r
+\r
              /* Wait on busy */\r
+\r
              /****************/\r
+\r
              v_EepromWaitBusy (w_PCIBoardEepromAddress);\r
-
+\r
+\r
              /************************/\r
+\r
              /* Load the low address */\r
+\r
              /************************/\r
-\r             outb(b_SelectedAddressLow,w_PCIBoardEepromAddress + 0x3E);
-             
-\r     
+\r
+\r
+             outb(b_SelectedAddressLow,w_PCIBoardEepromAddress + 0x3E);\r
+             \r
+\r
+     \r
              /****************/\r
+\r
              /* Wait on busy */\r
+\r
              /****************/\r
+\r
              v_EepromWaitBusy (w_PCIBoardEepromAddress);\r
 \r
+\r
+\r
              /*************************************/\r
+\r
              /* Select the load high address mode */\r
+\r
              /*************************************/\r
-\r             outb(NVCMD_LOAD_HIGH,w_PCIBoardEepromAddress + 0x3F);
-            
+\r
+\r
+             outb(NVCMD_LOAD_HIGH,w_PCIBoardEepromAddress + 0x3F);\r
+            \r
+\r
 \r
              /****************/\r
+\r
              /* Wait on busy */\r
+\r
              /****************/\r
+\r
              v_EepromWaitBusy (w_PCIBoardEepromAddress);\r
 \r
+\r
+\r
              /*************************/\r
+\r
              /* Load the high address */\r
+\r
              /*************************/\r
-\r             outb(b_SelectedAddressHigh,w_PCIBoardEepromAddress +0x3E);       
-            
-
+\r
+\r
+             outb(b_SelectedAddressHigh,w_PCIBoardEepromAddress +0x3E);        \r
+            \r
+\r
              /****************/\r
+\r
              /* Wait on busy */\r
+\r
              /****************/\r
+\r
              v_EepromWaitBusy (w_PCIBoardEepromAddress);\r
 \r
+\r
+\r
              /************************/\r
+\r
              /* Select the READ mode */\r
+\r
              /************************/\r
-\r             outb(NVCMD_BEGIN_READ,w_PCIBoardEepromAddress + 0x3F);  
-            
-
+\r
+\r
+             outb(NVCMD_BEGIN_READ,w_PCIBoardEepromAddress + 0x3F);  \r
+            \r
+\r
              /****************/\r
+\r
              /* Wait on busy */\r
-             /****************/\r\r
+\r
+             /****************/\r
+\r
+\r
              v_EepromWaitBusy (w_PCIBoardEepromAddress);\r
 \r
+\r
+\r
              /*****************************/\r
+\r
              /* Read data into the EEPROM */\r
+\r
              /*****************************/\r
+\r
               b_ReadByte = inb(w_PCIBoardEepromAddress + 0x3E);  \r
-            
-\r             
+\r
+            \r
+\r
+             \r
              /****************/\r
+\r
              /* Wait on busy */\r
+\r
              /****************/\r
 \r
+\r
+\r
              v_EepromWaitBusy (w_PCIBoardEepromAddress);\r
 \r
+\r
+\r
              /*********************************/\r
+\r
              /* Select the upper address part */\r
+\r
              /*********************************/\r
 \r
+\r
+\r
              if(b_Counter==0)\r
+\r
                 {\r
+\r
                 b_ReadLowByte=b_ReadByte;\r
+\r
                 } // if(b_Counter==0)\r
+\r
              else\r
+\r
                 {\r
+\r
                 b_ReadHighByte=b_ReadByte;\r
+\r
                 } // if(b_Counter==0)\r
+\r
            } // for (b_Counter=0; b_Counter<2; b_Counter++)\r
 \r
+\r
+\r
           w_ReadWord=(b_ReadLowByte | (((WORD) b_ReadHighByte) * 256));\r
-        \r     
+\r
+        \r
+     \r
            } // end of if ((!strcmp(pc_PCIChipInformation, "S5920")) || (!strcmp(pc_PCIChipInformation, "S5933"))) \r
+\r
         if (!strcmp(pc_PCIChipInformation, "93C76"))\r
+\r
            {\r
+\r
            /*************************************/\r
+\r
            /* Read 16 bit from the EEPROM 93C76 */\r
+\r
            /*************************************/\r
-\r         
+\r
+\r
+         \r
            v_EepromCs76Read(w_PCIBoardEepromAddress, w_EepromStartAddress, &w_ReadWord);\r
+\r
            }\r
-             
+\r
+             \r
        return (w_ReadWord);\r
+\r
        }\r
 \r
 \r
 \r
+\r
+\r
+\r
+\r
 /*\r
+\r
 +----------------------------------------------------------------------------+\r
+\r
 | Function   Name   : VOID v_EepromWaitBusy                                  |\r
+\r
 |                      (WORD   w_PCIBoardEepromAddress)                         |\r
+\r
 +----------------------------------------------------------------------------+\r
+\r
 | Task              : Wait the busy flag from PCI controller                 |\r
+\r
 +----------------------------------------------------------------------------+\r
+\r
 | Input Parameters  : WORD w_PCIBoardEepromAddress : PCI eeprom base address |\r
+\r
 +----------------------------------------------------------------------------+\r
+\r
 | Output Parameters : -                                                      |\r
+\r
 +----------------------------------------------------------------------------+\r
+\r
 | Return Value      : -                                                      |\r
+\r
 +----------------------------------------------------------------------------+\r
+\r
 */\r
 \r
+\r
+\r
 VOID   v_EepromWaitBusy(WORD   w_PCIBoardEepromAddress)\r
+\r
        {\r
+\r
        BYTE b_EepromBusy = 0;\r
 \r
+\r
+\r
        do\r
+\r
          {\r
+\r
           /*************/\r
+\r
           /* IMPORTANT */\r
+\r
           /*************/\r
 \r
+\r
+\r
           /************************************************************************/\r
-          /* An error has been written in the AMCC 5933 book at the page B-13*/\r        
-           /* Ex: if you read a byte and look for the busy statusEEPROM=0x80 and   */
\r        /*      the operator register is AMCC_OP_REG_MCSR+3*/\r 
-          /*      WORD read  EEPROM=0x8000 andAMCC_OP_REG_MCSR+2                  */\r   
-           /*      DWORD read  EEPROM=0x80000000 and AMCC_OP_REG_MCSR */\r        
-           /************************************************************************/\r \r 
-                  b_EepromBusy = inb(w_PCIBoardEepromAddress + 0x3F);             
+\r
+          /* An error has been written in the AMCC 5933 book at the page B-13*/\r
+        \r
+           /* Ex: if you read a byte and look for the busy statusEEPROM=0x80 and   */\r
\r
+          /*      the operator register is AMCC_OP_REG_MCSR+3*/\r
\r
+          /*      WORD read  EEPROM=0x8000 andAMCC_OP_REG_MCSR+2                  */\r
+        \r
+           /*      DWORD read  EEPROM=0x80000000 and AMCC_OP_REG_MCSR */\r
+         \r
+           /************************************************************************/\r
\r
\r
+                  b_EepromBusy = inb(w_PCIBoardEepromAddress + 0x3F);             \r
           b_EepromBusy = b_EepromBusy &0x80;\r
-        }\r     while(b_EepromBusy == 0x80);\r \r
-
+\r
+        }\r
+       while(b_EepromBusy == 0x80);\r
\r
+\r
+\r
        }\r
 \r
 \r
-
+\r
+\r
+\r
+\r
 /*\r
+\r
 +---------------------------------------------------------------------------------+\r
+\r
 | Function   Name   : VOID v_EepromClock76(DWORD dw_Address,                      |\r
+\r
 |                                         DWORD dw_RegisterValue)                                        |\r
+\r
 +---------------------------------------------------------------------------------+\r
+\r
 | Task              : This function sends the clocking sequence to the EEPROM.    |\r
+\r
 +---------------------------------------------------------------------------------+\r
+\r
 | Input Parameters  : DWORD dw_Address : PCI eeprom base address                  |\r
+\r
 |                    DWORD dw_RegisterValue : PCI eeprom register value to write.|\r
+\r
 +---------------------------------------------------------------------------------+\r
+\r
 | Output Parameters : -                                                           |\r
+\r
 +---------------------------------------------------------------------------------+\r
+\r
 | Return Value      : -                                                           |\r
+\r
 +---------------------------------------------------------------------------------+\r
+\r
 */\r
 \r
+\r
+\r
 VOID v_EepromClock76(DWORD dw_Address,DWORD dw_RegisterValue)\r
+\r
    {\r
 \r
+\r
+\r
    /************************/\r
+\r
    /* Set EEPROM clock Low */\r
+\r
    /************************/\r
-  \routl(dw_RegisterValue & 0x6,dw_Address);
-
+\r
+  \r
+outl(dw_RegisterValue & 0x6,dw_Address);\r
+\r
    /***************/\r
+\r
    /* Wait 0.1 ms */\r
-   /***************/\r\r
-    udelay(100);
+\r
+   /***************/\r
+\r
+\r
+    udelay(100);\r
    \r
+\r
    /*************************/\r
+\r
    /* Set EEPROM clock High */\r
+\r
    /*************************/\r
-\r  outl(dw_RegisterValue | 0x1,dw_Address);
+\r
+\r
+  outl(dw_RegisterValue | 0x1,dw_Address);\r
+\r
 \r
    /***************/\r
+\r
    /* Wait 0.1 ms */\r
+\r
    /***************/\r
-\r   udelay(100);
-
-   }\r
+\r
+\r
+   udelay(100);\r
+\r
+   }\r
+\r
+\r
 \r
 /*\r
+\r
 +---------------------------------------------------------------------------------+\r
+\r
 | Function   Name   : VOID v_EepromSendCommand76(DWORD dw_Address,                |\r
+\r
 |                                         DWORD   dw_EepromCommand,                              |\r
+\r
 |                                         BYTE    b_DataLengthInBits)                        |\r
+\r
 +---------------------------------------------------------------------------------+\r
+\r
 | Task              : This function sends a Command to the EEPROM 93C76.          |\r
+\r
 +---------------------------------------------------------------------------------+\r
+\r
 | Input Parameters  : DWORD dw_Address : PCI eeprom base address                  |\r
+\r
 |                    DWORD dw_EepromCommand : PCI eeprom command to write.       |\r
+\r
 |                    BYTE  b_DataLengthInBits : PCI eeprom command data length.  |\r
+\r
 +---------------------------------------------------------------------------------+\r
+\r
 | Output Parameters : -                                                           |\r
+\r
 +---------------------------------------------------------------------------------+\r
+\r
 | Return Value      : -                                                           |\r
+\r
 +---------------------------------------------------------------------------------+\r
+\r
 */\r
 \r
+\r
+\r
 VOID v_EepromSendCommand76(DWORD dw_Address,DWORD   dw_EepromCommand,BYTE    b_DataLengthInBits)\r
+\r
    {\r
+\r
    CHAR  c_BitPos = 0;\r
+\r
    DWORD dw_RegisterValue = 0;\r
 \r
+\r
+\r
  \r
+\r
    /*****************************/\r
+\r
    /* Enable EEPROM Chip Select */\r
+\r
    /*****************************/\r
+\r
    dw_RegisterValue = 0x2;\r
 \r
+\r
+\r
    /********************************************************************/\r
+\r
    /* Toggle EEPROM's Chip select to get it out of Shift Register Mode */\r
+\r
    /********************************************************************/\r
+\r
    outl(dw_RegisterValue,dw_Address);\r
+\r
\r
+\r
 \r
    /***************/\r
+\r
    /* Wait 0.1 ms */\r
+\r
    /***************/\r
-  \rudelay(100);
+\r
+  \r
+udelay(100);\r
\r
    \r
+\r
    /*******************************************/\r
+\r
    /* Send EEPROM command - one bit at a time */\r
-   /*******************************************/\r   \r
+\r
+   /*******************************************/\r
+   \r
+\r
    for (c_BitPos = (b_DataLengthInBits - 1); c_BitPos >= 0; c_BitPos--)\r
+\r
       {\r
-
+\r
+\r
       /**********************************/\r
+\r
       /* Check if current bit is 0 or 1 */\r
-      /**********************************/\r\r
+\r
+      /**********************************/\r
+\r
+\r
       if (dw_EepromCommand & (1 << c_BitPos))\r
+\r
         {\r
+\r
         /***********/\r
+\r
         /* Write 1 */\r
+\r
         /***********/\r
 \r
+\r
+\r
         dw_RegisterValue = dw_RegisterValue | 0x4;\r
+\r
         }\r
+\r
       else\r
+\r
         {\r
+\r
         /***********/\r
+\r
         /* Write 0 */\r
+\r
         /***********/\r
 \r
+\r
+\r
         dw_RegisterValue = dw_RegisterValue & 0x3;\r
+\r
         }\r
 \r
+\r
+\r
       /*********************/\r
+\r
       /* Write the command */\r
+\r
       /*********************/\r
-\r      outl(dw_RegisterValue,dw_Address);
-  
+\r
+\r
+      outl(dw_RegisterValue,dw_Address);\r
+  \r
+\r
 \r
       /***************/\r
+\r
       /* Wait 0.1 ms */\r
+\r
       /***************/\r
-   \r  udelay(100);
-  
+\r
+   \r
+  udelay(100);\r
+  \r
    \r
+\r
       /****************************/\r
+\r
       /* Trigger the EEPROM clock */\r
+\r
       /****************************/\r
+\r
       v_EepromClock76(dw_Address, dw_RegisterValue);\r
-
+\r
+\r
       }\r
 \r
+\r
+\r
    }\r
 \r
+\r
+\r
 /*\r
+\r
 +---------------------------------------------------------------------------------+\r
+\r
 | Function   Name   : VOID v_EepromCs76Read(DWORD dw_Address,                     |\r
+\r
 |                                         WORD    w_offset,                                              |\r
+\r
 |                                         PWORD   pw_Value)                                              |\r
+\r
 +---------------------------------------------------------------------------------+\r
+\r
 | Task              : This function read a value from the EEPROM 93C76.           |\r
+\r
 +---------------------------------------------------------------------------------+\r
+\r
 | Input Parameters  : DWORD dw_Address : PCI eeprom base address                  |\r
+\r
 |                    WORD    w_offset : Offset of the adress to read             |\r
+\r
 |                    PWORD   pw_Value : PCI eeprom 16 bit read value.            |\r
+\r
 +---------------------------------------------------------------------------------+\r
+\r
 | Output Parameters : -                                                           |\r
+\r
 +---------------------------------------------------------------------------------+\r
+\r
 | Return Value      : -                                                           |\r
+\r
 +---------------------------------------------------------------------------------+\r
+\r
 */\r
 \r
-VOID v_EepromCs76Read(DWORD dw_Address,WORD    w_offset,\rPWORD   pw_Value)\r
+\r
+\r
+VOID v_EepromCs76Read(DWORD dw_Address,WORD    w_offset,\r
+PWORD   pw_Value)\r
+\r
    {\r
+\r
    CHAR   c_BitPos = 0;\r
+\r
    DWORD  dw_RegisterValue = 0;\r
+\r
    DWORD  dw_RegisterValueRead = 0;\r
 \r
 \r
+\r
+\r
+\r
    /*************************************************/\r
+\r
    /* Send EEPROM read command and offset to EEPROM */\r
+\r
    /*************************************************/\r
+\r
    v_EepromSendCommand76(dw_Address, (EE_READ << 4) | (w_offset / 2), EE76_CMD_LEN);\r
 \r
+\r
+\r
    /*******************************/\r
+\r
    /* Get the last register value */\r
+\r
    /*******************************/\r
+\r
    dw_RegisterValue = (((w_offset / 2) & 0x1) << 2) | 0x2;\r
+\r
    \r
+\r
    /*****************************/\r
+\r
    /* Set the 16-bit value of 0 */\r
-   /*****************************/\r\r
+\r
+   /*****************************/\r
+\r
+\r
    *pw_Value = 0;\r
 \r
+\r
+\r
    /************************/\r
+\r
    /* Get the 16-bit value */\r
+\r
    /************************/\r
+\r
    for (c_BitPos = 0; c_BitPos < 16; c_BitPos++)\r
+\r
       {\r
-
+\r
+\r
       /****************************/\r
+\r
       /* Trigger the EEPROM clock */\r
-      /****************************/\r\r
+\r
+      /****************************/\r
+\r
+\r
       v_EepromClock76(dw_Address, dw_RegisterValue);\r
 \r
+\r
+\r
       /**********************/\r
+\r
       /* Get the result bit */\r
+\r
       /**********************/\r
-\r     dw_RegisterValueRead = inl(dw_Address);
-
+\r
+\r
+     dw_RegisterValueRead = inl(dw_Address);\r
+\r
       /***************/\r
+\r
       /* Wait 0.1 ms */\r
+\r
       /***************/\r
-   \r  udelay(100);
+\r
+   \r
+  udelay(100);\r
      \r
+\r
       /***************************************/\r
+\r
       /* Get bit value and shift into result */\r
-      /***************************************/\r\r
+\r
+      /***************************************/\r
+\r
+\r
       if (dw_RegisterValueRead & 0x8)\r
+\r
         {\r
-
+\r
+\r
         /**********/\r
+\r
         /* Read 1 */\r
-        /**********/\r\r
+\r
+        /**********/\r
+\r
+\r
         *pw_Value = (*pw_Value << 1) | 0x1;\r
+\r
         }\r
+\r
       else\r
+\r
         {\r
+\r
         /**********/\r
+\r
         /* Read 0 */\r
+\r
         /**********/\r
+\r
         *pw_Value = (*pw_Value << 1);\r
-        
+\r
+        \r
        }\r
+\r
       }\r
 \r
+\r
+\r
    /*************************/\r
+\r
    /* Clear all EEPROM bits */\r
-   /*************************/\r\r
+\r
+   /*************************/\r
+\r
+\r
    dw_RegisterValue = 0x0;\r
 \r
+\r
+\r
    /********************************************************************/\r
+\r
    /* Toggle EEPROM's Chip select to get it out of Shift Register Mode */\r
+\r
    /********************************************************************/\r
-\r  outl(dw_RegisterValue,dw_Address);
-     
+\r
+\r
+  outl(dw_RegisterValue,dw_Address);\r
+     \r
    /***************/\r
+\r
    /* Wait 0.1 ms */\r
+\r
    /***************/\r
-   udelay(100);
-    
+\r
+   udelay(100);\r
+    \r
    }\r
 \r
-
-
-       /******************************************/
-       /*      EEPROM HEADER READ FUNCTIONS      */
-       /******************************************/
-
-/*
-+----------------------------------------------------------------------------+
-| Function Name  : INT i_EepromReadMainHeader(WORD w_PCIBoardEepromAddress,  |
-|                              PCHAR   pc_PCIChipInformation,comedi_device *dev)    |
-+----------------------------------------------------------------------------+
-| Task              : Read from eeprom Main Header                           |
-+----------------------------------------------------------------------------+
-| Input Parameters  : WORD w_PCIBoardEepromAddress : PCI eeprom address      |
-|                                                                                                                                       |      
-|                    PCHAR pc_PCIChipInformation  : PCI Chip Type.          |
-|                                                                                                                                       |
-|                        comedi_device *dev               : comedi device structure |
-|                                                                                       pointer                                 |
-+----------------------------------------------------------------------------+
-| Output Parameters : -                                                      |
-+----------------------------------------------------------------------------+
-| Return Value      : 0                                                                                     |
-+----------------------------------------------------------------------------+
-*/
-
-
-INT i_EepromReadMainHeader(WORD        w_PCIBoardEepromAddress,PCHAR   pc_PCIChipInformation,comedi_device *dev)
-{
-       WORD w_Temp,i,w_Count=0;
-        UINT ui_Temp;
-       str_MainHeader  s_MainHeader;
-       str_DigitalInputHeader  s_DigitalInputHeader;
-       str_DigitalOutputHeader s_DigitalOutputHeader;
-       //str_TimerMainHeader     s_TimerMainHeader,s_WatchdogMainHeader;
-       str_AnalogOutputHeader   s_AnalogOutputHeader;
-       str_AnalogInputHeader   s_AnalogInputHeader;
-
-        // Read size
-       s_MainHeader.w_HeaderSize = w_EepromReadWord(w_PCIBoardEepromAddress,pc_PCIChipInformation,0x100+8);
-                
-        // Read nbr of functionality
-       w_Temp = w_EepromReadWord(w_PCIBoardEepromAddress,pc_PCIChipInformation,0x100+10);
-        s_MainHeader.b_Nfunctions =(BYTE)w_Temp & 0x00FF;
-
-       // Read functionality details
-       for(i=0;i<s_MainHeader.b_Nfunctions;i++)
-       {
-         // Read Type
-         w_Temp = w_EepromReadWord(w_PCIBoardEepromAddress,pc_PCIChipInformation,0x100+12+w_Count);
-         s_MainHeader.s_Functions[i].b_Type    =(BYTE) w_Temp & 0x3F;
-         w_Count=w_Count+2;
-       //Read Address
-        s_MainHeader.s_Functions[i].w_Address= w_EepromReadWord(w_PCIBoardEepromAddress,pc_PCIChipInformation,0x100+12+w_Count);    
-        w_Count=w_Count+2;
-       }
-
-        // Display main header info        
-       for(i=0;i<s_MainHeader.b_Nfunctions;i++)
-       {
-       
-          switch(s_MainHeader.s_Functions[i].b_Type)
-         {
-           case EEPROM_DIGITALINPUT:               
-                i_EepromReadDigitalInputHeader(w_PCIBoardEepromAddress,pc_PCIChipInformation,
-                s_MainHeader.s_Functions[i].w_Address,&s_DigitalInputHeader);  
-                 this_board->i_NbrDiChannel=s_DigitalInputHeader.w_Nchannel;
-                break;
-
-           case EEPROM_DIGITALOUTPUT:                 
-                i_EepromReadDigitalOutputHeader(w_PCIBoardEepromAddress,pc_PCIChipInformation,
-                s_MainHeader.s_Functions[i].w_Address,&s_DigitalOutputHeader);          
-                 this_board->i_NbrDoChannel=s_DigitalOutputHeader.w_Nchannel;
-                 ui_Temp=0xffffffff;
-                 this_board->i_DoMaxdata= ui_Temp >>(32 - this_board->i_NbrDoChannel);
-                break;
-
-           case EEPROM_ANALOGINPUT:
-                i_EepromReadAnlogInputHeader(w_PCIBoardEepromAddress,pc_PCIChipInformation,
-                s_MainHeader.s_Functions[i].w_Address,&s_AnalogInputHeader);   
-                this_board->i_NbrAiChannel=s_AnalogInputHeader.w_Nchannel;
-                 this_board->i_Dma=s_AnalogInputHeader.b_HasDma;
-                 this_board->ui_MinAcquisitiontimeNs=(UINT)s_AnalogInputHeader.w_MinConvertTiming * 1000;
-                 this_board->ui_MinDelaytimeNs      =(UINT)s_AnalogInputHeader.w_MinDelayTiming * 1000;  
-                 ui_Temp=0xffff;
-                 this_board->i_AiMaxdata = ui_Temp >> (16 - s_AnalogInputHeader.b_Resolution);
-                break;
-
-            case EEPROM_ANALOGOUTPUT:                                
-                i_EepromReadAnlogOutputHeader(w_PCIBoardEepromAddress,pc_PCIChipInformation,
-                s_MainHeader.s_Functions[i].w_Address,&s_AnalogOutputHeader);                 
-                 this_board->i_NbrAoChannel=s_AnalogOutputHeader.w_Nchannel;
-                 ui_Temp=0xffff;
-                 this_board->i_AoMaxdata= ui_Temp >>(16 - s_AnalogOutputHeader.b_Resolution);
-                break;
-
-           case EEPROM_TIMER:
-                this_board->i_Timer=1;//Timer subdevice present                                        
-                break;
-
-           case EEPROM_WATCHDOG:        
-                this_board->i_Timer=1; //Timer subdevice present 
-                 break;
-
-            case EEPROM_TIMER_WATCHDOG_COUNTER:         
-                this_board->i_Timer=1; //Timer subdevice present                               
-         } 
-       }
-
-       return 0;
-}
-
-
-
-
-/*
-+----------------------------------------------------------------------------+
-| Function Name  : INT i_EepromReadDigitalInputHeader(WORD                                      |
-|                      w_PCIBoardEepromAddress,PCHAR pc_PCIChipInformation,     |
-|                      WORD w_Address,str_DigitalInputHeader *s_Header)                 |
-|                                                                                                                                       |
-+----------------------------------------------------------------------------+
-| Task              : Read Digital Input Header                              |
-+----------------------------------------------------------------------------+
-| Input Parameters  : WORD w_PCIBoardEepromAddress : PCI eeprom address      |
-|                                                                                                                                       |
-|                    PCHAR pc_PCIChipInformation  : PCI Chip Type.          |
-|                                                                                                                                       |
-|                       str_DigitalInputHeader *s_Header: Digita Input Header   |
-|                                                                                                 Pointer                       |
-+----------------------------------------------------------------------------+
-| Output Parameters : -                                                      |
-+----------------------------------------------------------------------------+
-| Return Value      : 0                                                                                     |
-+----------------------------------------------------------------------------+
-*/
-INT i_EepromReadDigitalInputHeader(WORD w_PCIBoardEepromAddress,PCHAR pc_PCIChipInformation,WORD w_Address,str_DigitalInputHeader *s_Header)
-{
-  WORD w_Temp;
-
- // read nbr of channels
- s_Header->w_Nchannel=w_EepromReadWord(w_PCIBoardEepromAddress,pc_PCIChipInformation,0x100+w_Address+6);
-
- // interruptible or not
- w_Temp=w_EepromReadWord(w_PCIBoardEepromAddress,pc_PCIChipInformation,0x100+w_Address+8);
- s_Header->b_Interruptible=(BYTE) (w_Temp>>7)& 0x01;
-
-// How many interruptible logic
- s_Header->w_NinterruptLogic=w_EepromReadWord(w_PCIBoardEepromAddress,pc_PCIChipInformation,0x100+w_Address+10);
-
- return 0;
-}
-
-/*
-+----------------------------------------------------------------------------+
-| Function Name  : INT i_EepromReadDigitalOutputHeader(WORD                             |
-|                      w_PCIBoardEepromAddress,PCHAR pc_PCIChipInformation,     |
-|                      WORD w_Address,str_DigitalOutputHeader *s_Header)            |
-|                                                                                                                                       |
-+----------------------------------------------------------------------------+
-| Task              : Read Digital Output Header                             |
-+----------------------------------------------------------------------------+
-| Input Parameters  : WORD w_PCIBoardEepromAddress : PCI eeprom address      |
-|                                                                                                                                       |
-|                    PCHAR pc_PCIChipInformation  : PCI Chip Type.          |
-|                                                                                                                                       |
-|                       str_DigitalOutputHeader *s_Header: Digital Output Header|
-|                                                                                         Pointer                               |
-+----------------------------------------------------------------------------+
-| Output Parameters : -                                                      |
-+----------------------------------------------------------------------------+
-| Return Value      : 0                                                                                     |
-+----------------------------------------------------------------------------+
-*/
-INT i_EepromReadDigitalOutputHeader(WORD w_PCIBoardEepromAddress,PCHAR pc_PCIChipInformation,WORD w_Address,str_DigitalOutputHeader *s_Header)
-{
-// Read Nbr channels
- s_Header->w_Nchannel=w_EepromReadWord(w_PCIBoardEepromAddress,pc_PCIChipInformation,0x100+w_Address+6);
-return 0;
-}
-
-/*
-+----------------------------------------------------------------------------+
-| Function Name  : INT i_EepromReadTimerHeader(WORD w_PCIBoardEepromAddress, |
-|                      PCHAR pc_PCIChipInformation,WORD w_Address,                              |
-|                      str_TimerMainHeader *s_Header)                                                   | 
-+----------------------------------------------------------------------------+
-| Task              : Read Timer or Watchdog Header                          |
-+----------------------------------------------------------------------------+
-| Input Parameters  : WORD w_PCIBoardEepromAddress : PCI eeprom address      |
-|                                                                                                                                       |      
-|                    PCHAR pc_PCIChipInformation  : PCI Chip Type.          |
-|                                                                                                                                       |      
-|                       str_TimerMainHeader *s_Header: Timer Header                     |
-|                                                                                         Pointer                               |
-+----------------------------------------------------------------------------+
-| Output Parameters : -                                                      |
-+----------------------------------------------------------------------------+
-| Return Value      : 0                                                                                     |
-+----------------------------------------------------------------------------+
-*/
-INT i_EepromReadTimerHeader(WORD w_PCIBoardEepromAddress,PCHAR pc_PCIChipInformation,WORD w_Address,str_TimerMainHeader *s_Header)
-{
-
-WORD i,w_Size=0,w_Temp;
-  
-
-//Read No of Timer
-s_Header->w_Ntimer=w_EepromReadWord(w_PCIBoardEepromAddress,pc_PCIChipInformation,0x100+w_Address+6);
-//Read header size
-
-for(i=0;i<s_Header->w_Ntimer;i++)
-{
-  s_Header->s_TimerDetails[i].w_HeaderSize=w_EepromReadWord(w_PCIBoardEepromAddress,pc_PCIChipInformation,0x100+w_Address+8+w_Size+0);
-  w_Temp=w_EepromReadWord(w_PCIBoardEepromAddress,pc_PCIChipInformation,0x100+w_Address+8+w_Size+2) ;
-
-  //Read Resolution
-  s_Header->s_TimerDetails[i].b_Resolution=(BYTE)(w_Temp>>10)&0x3F;
-
-  //Read Mode
-  s_Header->s_TimerDetails[i].b_Mode           =(BYTE) (w_Temp>>4)&0x3F;
-
-  w_Temp=w_EepromReadWord(w_PCIBoardEepromAddress,pc_PCIChipInformation,0x100+w_Address+8+w_Size+4) ;
-
-  //Read MinTiming
-  s_Header->s_TimerDetails[i].w_MinTiming      =(w_Temp>>6)&0x3FF; 
-
-  //Read Timebase
-  s_Header->s_TimerDetails[i].b_TimeBase       =(BYTE)(w_Temp)&0x3F; 
-  w_Size += s_Header->s_TimerDetails[i].w_HeaderSize;
-}   
-return 0;
-}
-
-
-
-/*
-+----------------------------------------------------------------------------+
-| Function Name  : INT i_EepromReadAnlogOutputHeader(WORD                                       |
-|                      w_PCIBoardEepromAddress,PCHAR pc_PCIChipInformation,     |
-|                      WORD w_Address,str_AnalogOutputHeader *s_Header)         | 
-+----------------------------------------------------------------------------+
-| Task              : Read Nalog Output  Header                              |
-+----------------------------------------------------------------------------+
-| Input Parameters  : WORD w_PCIBoardEepromAddress : PCI eeprom address      |
-|                                                                                                                                       |      
-|                    PCHAR pc_PCIChipInformation  : PCI Chip Type.          |
-|                                                                                                                                       |
-|                       str_AnalogOutputHeader *s_Header:Anlog Output Header    |
-|                                                                                         Pointer                               |
-+----------------------------------------------------------------------------+
-| Output Parameters : -                                                      |
-+----------------------------------------------------------------------------+
-| Return Value      : 0                                                                                     |
-+----------------------------------------------------------------------------+
-*/
-
-INT i_EepromReadAnlogOutputHeader(WORD w_PCIBoardEepromAddress,PCHAR pc_PCIChipInformation,WORD w_Address,str_AnalogOutputHeader *s_Header)
-{
-  WORD w_Temp;
-  // No of channels for 1st hard component
-  w_Temp=w_EepromReadWord(w_PCIBoardEepromAddress,pc_PCIChipInformation,0x100+w_Address+10);
-  s_Header->w_Nchannel=(w_Temp>>4)& 0x03FF;
-  // Resolution for 1st hard component
-  w_Temp=w_EepromReadWord(w_PCIBoardEepromAddress,pc_PCIChipInformation,0x100+w_Address+16);
-  s_Header->b_Resolution=(BYTE)(w_Temp>>8) & 0xFF;
-  return 0;
-}
-
-
-/*
-+----------------------------------------------------------------------------+
-| Function Name  : INT i_EepromReadAnlogInputHeader(WORD                                        |
-|                      w_PCIBoardEepromAddress,PCHAR pc_PCIChipInformation,     |
-|                      WORD w_Address,str_AnalogInputHeader *s_Header)          |
-+----------------------------------------------------------------------------+
-| Task              : Read Nalog Output  Header                              |
-+----------------------------------------------------------------------------+
-| Input Parameters  : WORD w_PCIBoardEepromAddress : PCI eeprom address      |
-|                                                                                                                                       |
-|                    PCHAR pc_PCIChipInformation  : PCI Chip Type.          |
-|                                                                                                                                       |
-|                       str_AnalogInputHeader *s_Header:Anlog Input Header      |  
-|                                                                                         Pointer                               |
-+----------------------------------------------------------------------------+
-| Output Parameters : -                                                      |
-+----------------------------------------------------------------------------+
-| Return Value      : 0                                                                                     |
-+----------------------------------------------------------------------------+
-*/
-
-// Reads only for ONE  hardware component
-INT i_EepromReadAnlogInputHeader(WORD w_PCIBoardEepromAddress,PCHAR pc_PCIChipInformation,WORD w_Address,str_AnalogInputHeader *s_Header)
-{
-  WORD w_Temp,w_Offset;
-  w_Temp=w_EepromReadWord(w_PCIBoardEepromAddress,pc_PCIChipInformation,0x100+w_Address+10);
-  s_Header->w_Nchannel=(w_Temp>>4)& 0x03FF;
-  s_Header->w_MinConvertTiming=w_EepromReadWord(w_PCIBoardEepromAddress,pc_PCIChipInformation,0x100+w_Address+16);
-s_Header->w_MinDelayTiming=w_EepromReadWord(w_PCIBoardEepromAddress,pc_PCIChipInformation,0x100+w_Address+30);
-w_Temp=w_EepromReadWord(w_PCIBoardEepromAddress,pc_PCIChipInformation,0x100+w_Address+20);
-s_Header->b_HasDma=(w_Temp>>13) & 0x01; // whether dma present or not
-
-w_Temp=w_EepromReadWord(w_PCIBoardEepromAddress,pc_PCIChipInformation,0x100+w_Address+72);// reading Y
-w_Temp=w_Temp & 0x00FF;
-if(w_Temp)//Y>0
-{
-w_Offset=74+(2*w_Temp)+(10*(1+(w_Temp/16)));// offset of first analog input single header
-w_Offset= w_Offset+2; // resolution
-}
-else//Y=0
-{ 
-w_Offset=74; 
-w_Offset= w_Offset+2; // resolution
-}
-
-// read Resolution
-w_Temp=w_EepromReadWord(w_PCIBoardEepromAddress,pc_PCIChipInformation,0x100+w_Address+w_Offset);
-s_Header->b_Resolution=w_Temp & 0x001F;// last 5 bits
-
-return 0;
-}
+\r
+\r
+\r
+\r
+       /******************************************/\r
+       /*      EEPROM HEADER READ FUNCTIONS      */\r
+       /******************************************/\r
+\r
+/*\r
++----------------------------------------------------------------------------+\r
+| Function Name  : INT i_EepromReadMainHeader(WORD w_PCIBoardEepromAddress,  |\r
+|                              PCHAR   pc_PCIChipInformation,comedi_device *dev)    |\r
++----------------------------------------------------------------------------+\r
+| Task              : Read from eeprom Main Header                           |\r
++----------------------------------------------------------------------------+\r
+| Input Parameters  : WORD w_PCIBoardEepromAddress : PCI eeprom address      |\r
+|                                                                                                                                       |      \r
+|                    PCHAR pc_PCIChipInformation  : PCI Chip Type.          |\r
+|                                                                                                                                       |\r
+|                        comedi_device *dev               : comedi device structure |\r
+|                                                                                       pointer                                 |\r
++----------------------------------------------------------------------------+\r
+| Output Parameters : -                                                      |\r
++----------------------------------------------------------------------------+\r
+| Return Value      : 0                                                                                     |\r
++----------------------------------------------------------------------------+\r
+*/\r
+\r
+\r
+INT i_EepromReadMainHeader(WORD        w_PCIBoardEepromAddress,PCHAR   pc_PCIChipInformation,comedi_device *dev)\r
+{\r
+       WORD w_Temp,i,w_Count=0;\r
+        UINT ui_Temp;\r
+       str_MainHeader  s_MainHeader;\r
+       str_DigitalInputHeader  s_DigitalInputHeader;\r
+       str_DigitalOutputHeader s_DigitalOutputHeader;\r
+       //str_TimerMainHeader     s_TimerMainHeader,s_WatchdogMainHeader;\r
+       str_AnalogOutputHeader   s_AnalogOutputHeader;\r
+       str_AnalogInputHeader   s_AnalogInputHeader;\r
+\r
+        // Read size\r
+       s_MainHeader.w_HeaderSize = w_EepromReadWord(w_PCIBoardEepromAddress,pc_PCIChipInformation,0x100+8);\r
+                \r
+        // Read nbr of functionality\r
+       w_Temp = w_EepromReadWord(w_PCIBoardEepromAddress,pc_PCIChipInformation,0x100+10);\r
+        s_MainHeader.b_Nfunctions =(BYTE)w_Temp & 0x00FF;\r
+\r
+       // Read functionality details\r
+       for(i=0;i<s_MainHeader.b_Nfunctions;i++)\r
+       {\r
+         // Read Type\r
+         w_Temp = w_EepromReadWord(w_PCIBoardEepromAddress,pc_PCIChipInformation,0x100+12+w_Count);\r
+         s_MainHeader.s_Functions[i].b_Type    =(BYTE) w_Temp & 0x3F;\r
+         w_Count=w_Count+2;\r
+       //Read Address\r
+        s_MainHeader.s_Functions[i].w_Address= w_EepromReadWord(w_PCIBoardEepromAddress,pc_PCIChipInformation,0x100+12+w_Count);    \r
+        w_Count=w_Count+2;\r
+       }\r
+\r
+        // Display main header info        \r
+       for(i=0;i<s_MainHeader.b_Nfunctions;i++)\r
+       {\r
+       \r
+          switch(s_MainHeader.s_Functions[i].b_Type)\r
+         {\r
+           case EEPROM_DIGITALINPUT:               \r
+                i_EepromReadDigitalInputHeader(w_PCIBoardEepromAddress,pc_PCIChipInformation,\r
+                s_MainHeader.s_Functions[i].w_Address,&s_DigitalInputHeader);  \r
+                 this_board->i_NbrDiChannel=s_DigitalInputHeader.w_Nchannel;\r
+                break;\r
+\r
+           case EEPROM_DIGITALOUTPUT:                 \r
+                i_EepromReadDigitalOutputHeader(w_PCIBoardEepromAddress,pc_PCIChipInformation,\r
+                s_MainHeader.s_Functions[i].w_Address,&s_DigitalOutputHeader);          \r
+                 this_board->i_NbrDoChannel=s_DigitalOutputHeader.w_Nchannel;\r
+                 ui_Temp=0xffffffff;\r
+                 this_board->i_DoMaxdata= ui_Temp >>(32 - this_board->i_NbrDoChannel);\r
+                break;\r
+\r
+           case EEPROM_ANALOGINPUT:\r
+                i_EepromReadAnlogInputHeader(w_PCIBoardEepromAddress,pc_PCIChipInformation,\r
+                s_MainHeader.s_Functions[i].w_Address,&s_AnalogInputHeader); \r
+                if (!(strcmp(this_board->pc_DriverName, "apci3200")))  \r
+                   this_board->i_NbrAiChannel=s_AnalogInputHeader.w_Nchannel * 4;\r
+                else\r
+                   this_board->i_NbrAiChannel=s_AnalogInputHeader.w_Nchannel;\r
+                 this_board->i_Dma=s_AnalogInputHeader.b_HasDma;\r
+                 this_board->ui_MinAcquisitiontimeNs=(UINT)s_AnalogInputHeader.w_MinConvertTiming * 1000;\r
+                 this_board->ui_MinDelaytimeNs      =(UINT)s_AnalogInputHeader.w_MinDelayTiming * 1000;  \r
+                 ui_Temp=0xffff;\r
+                 this_board->i_AiMaxdata = ui_Temp >> (16 - s_AnalogInputHeader.b_Resolution);\r
+                break;\r
+\r
+            case EEPROM_ANALOGOUTPUT:                                \r
+                i_EepromReadAnlogOutputHeader(w_PCIBoardEepromAddress,pc_PCIChipInformation,\r
+                s_MainHeader.s_Functions[i].w_Address,&s_AnalogOutputHeader);                 \r
+                 this_board->i_NbrAoChannel=s_AnalogOutputHeader.w_Nchannel;\r
+                 ui_Temp=0xffff;\r
+                 this_board->i_AoMaxdata= ui_Temp >>(16 - s_AnalogOutputHeader.b_Resolution);\r
+                break;\r
+\r
+           case EEPROM_TIMER:\r
+                this_board->i_Timer=1;//Timer subdevice present                                        \r
+                break;\r
+\r
+           case EEPROM_WATCHDOG:        \r
+                this_board->i_Timer=1; //Timer subdevice present \r
+                 break;\r
+\r
+            case EEPROM_TIMER_WATCHDOG_COUNTER:         \r
+                this_board->i_Timer=1; //Timer subdevice present                               \r
+         } \r
+       }\r
+\r
+       return 0;\r
+}\r
+\r
+\r
+\r
+\r
+/*\r
++----------------------------------------------------------------------------+\r
+| Function Name  : INT i_EepromReadDigitalInputHeader(WORD                                      |\r
+|                      w_PCIBoardEepromAddress,PCHAR pc_PCIChipInformation,     |\r
+|                      WORD w_Address,str_DigitalInputHeader *s_Header)                 |\r
+|                                                                                                                                       |\r
++----------------------------------------------------------------------------+\r
+| Task              : Read Digital Input Header                              |\r
++----------------------------------------------------------------------------+\r
+| Input Parameters  : WORD w_PCIBoardEepromAddress : PCI eeprom address      |\r
+|                                                                                                                                       |\r
+|                    PCHAR pc_PCIChipInformation  : PCI Chip Type.          |\r
+|                                                                                                                                       |\r
+|                       str_DigitalInputHeader *s_Header: Digita Input Header   |\r
+|                                                                                                 Pointer                       |\r
++----------------------------------------------------------------------------+\r
+| Output Parameters : -                                                      |\r
++----------------------------------------------------------------------------+\r
+| Return Value      : 0                                                                                     |\r
++----------------------------------------------------------------------------+\r
+*/\r
+INT i_EepromReadDigitalInputHeader(WORD w_PCIBoardEepromAddress,PCHAR pc_PCIChipInformation,WORD w_Address,str_DigitalInputHeader *s_Header)\r
+{\r
+  WORD w_Temp;\r
+\r
+ // read nbr of channels\r
+ s_Header->w_Nchannel=w_EepromReadWord(w_PCIBoardEepromAddress,pc_PCIChipInformation,0x100+w_Address+6);\r
+\r
+ // interruptible or not\r
+ w_Temp=w_EepromReadWord(w_PCIBoardEepromAddress,pc_PCIChipInformation,0x100+w_Address+8);\r
+ s_Header->b_Interruptible=(BYTE) (w_Temp>>7)& 0x01;\r
+\r
+// How many interruptible logic\r
+ s_Header->w_NinterruptLogic=w_EepromReadWord(w_PCIBoardEepromAddress,pc_PCIChipInformation,0x100+w_Address+10);\r
+\r
+ return 0;\r
+}\r
+\r
+/*\r
++----------------------------------------------------------------------------+\r
+| Function Name  : INT i_EepromReadDigitalOutputHeader(WORD                             |\r
+|                      w_PCIBoardEepromAddress,PCHAR pc_PCIChipInformation,     |\r
+|                      WORD w_Address,str_DigitalOutputHeader *s_Header)            |\r
+|                                                                                                                                       |\r
++----------------------------------------------------------------------------+\r
+| Task              : Read Digital Output Header                             |\r
++----------------------------------------------------------------------------+\r
+| Input Parameters  : WORD w_PCIBoardEepromAddress : PCI eeprom address      |\r
+|                                                                                                                                       |\r
+|                    PCHAR pc_PCIChipInformation  : PCI Chip Type.          |\r
+|                                                                                                                                       |\r
+|                       str_DigitalOutputHeader *s_Header: Digital Output Header|\r
+|                                                                                         Pointer                               |\r
++----------------------------------------------------------------------------+\r
+| Output Parameters : -                                                      |\r
++----------------------------------------------------------------------------+\r
+| Return Value      : 0                                                                                     |\r
++----------------------------------------------------------------------------+\r
+*/\r
+INT i_EepromReadDigitalOutputHeader(WORD w_PCIBoardEepromAddress,PCHAR pc_PCIChipInformation,WORD w_Address,str_DigitalOutputHeader *s_Header)\r
+{\r
+// Read Nbr channels\r
+ s_Header->w_Nchannel=w_EepromReadWord(w_PCIBoardEepromAddress,pc_PCIChipInformation,0x100+w_Address+6);\r
+return 0;\r
+}\r
+\r
+/*\r
++----------------------------------------------------------------------------+\r
+| Function Name  : INT i_EepromReadTimerHeader(WORD w_PCIBoardEepromAddress, |\r
+|                      PCHAR pc_PCIChipInformation,WORD w_Address,                              |\r
+|                      str_TimerMainHeader *s_Header)                                                   | \r
++----------------------------------------------------------------------------+\r
+| Task              : Read Timer or Watchdog Header                          |\r
++----------------------------------------------------------------------------+\r
+| Input Parameters  : WORD w_PCIBoardEepromAddress : PCI eeprom address      |\r
+|                                                                                                                                       |      \r
+|                    PCHAR pc_PCIChipInformation  : PCI Chip Type.          |\r
+|                                                                                                                                       |      \r
+|                       str_TimerMainHeader *s_Header: Timer Header                     |\r
+|                                                                                         Pointer                               |\r
++----------------------------------------------------------------------------+\r
+| Output Parameters : -                                                      |\r
++----------------------------------------------------------------------------+\r
+| Return Value      : 0                                                                                     |\r
++----------------------------------------------------------------------------+\r
+*/\r
+INT i_EepromReadTimerHeader(WORD w_PCIBoardEepromAddress,PCHAR pc_PCIChipInformation,WORD w_Address,str_TimerMainHeader *s_Header)\r
+{\r
+\r
+WORD i,w_Size=0,w_Temp;\r
+  \r
+\r
+//Read No of Timer\r
+s_Header->w_Ntimer=w_EepromReadWord(w_PCIBoardEepromAddress,pc_PCIChipInformation,0x100+w_Address+6);\r
+//Read header size\r
+\r
+for(i=0;i<s_Header->w_Ntimer;i++)\r
+{\r
+  s_Header->s_TimerDetails[i].w_HeaderSize=w_EepromReadWord(w_PCIBoardEepromAddress,pc_PCIChipInformation,0x100+w_Address+8+w_Size+0);\r
+  w_Temp=w_EepromReadWord(w_PCIBoardEepromAddress,pc_PCIChipInformation,0x100+w_Address+8+w_Size+2) ;\r
+\r
+  //Read Resolution\r
+  s_Header->s_TimerDetails[i].b_Resolution=(BYTE)(w_Temp>>10)&0x3F;\r
+\r
+  //Read Mode\r
+  s_Header->s_TimerDetails[i].b_Mode           =(BYTE) (w_Temp>>4)&0x3F;\r
+\r
+  w_Temp=w_EepromReadWord(w_PCIBoardEepromAddress,pc_PCIChipInformation,0x100+w_Address+8+w_Size+4) ;\r
+\r
+  //Read MinTiming\r
+  s_Header->s_TimerDetails[i].w_MinTiming      =(w_Temp>>6)&0x3FF; \r
+\r
+  //Read Timebase\r
+  s_Header->s_TimerDetails[i].b_TimeBase       =(BYTE)(w_Temp)&0x3F; \r
+  w_Size += s_Header->s_TimerDetails[i].w_HeaderSize;\r
+}   \r
\r
+return 0;\r
+}\r
+\r
+\r
+\r
+/*\r
++----------------------------------------------------------------------------+\r
+| Function Name  : INT i_EepromReadAnlogOutputHeader(WORD                                       |\r
+|                      w_PCIBoardEepromAddress,PCHAR pc_PCIChipInformation,     |\r
+|                      WORD w_Address,str_AnalogOutputHeader *s_Header)         | \r
++----------------------------------------------------------------------------+\r
+| Task              : Read Nalog Output  Header                              |\r
++----------------------------------------------------------------------------+\r
+| Input Parameters  : WORD w_PCIBoardEepromAddress : PCI eeprom address      |\r
+|                                                                                                                                       |      \r
+|                    PCHAR pc_PCIChipInformation  : PCI Chip Type.          |\r
+|                                                                                                                                       |\r
+|                       str_AnalogOutputHeader *s_Header:Anlog Output Header    |\r
+|                                                                                         Pointer                               |\r
++----------------------------------------------------------------------------+\r
+| Output Parameters : -                                                      |\r
++----------------------------------------------------------------------------+\r
+| Return Value      : 0                                                                                     |\r
++----------------------------------------------------------------------------+\r
+*/\r
+\r
+INT i_EepromReadAnlogOutputHeader(WORD w_PCIBoardEepromAddress,PCHAR pc_PCIChipInformation,WORD w_Address,str_AnalogOutputHeader *s_Header)\r
+{\r
+  WORD w_Temp;\r
+  // No of channels for 1st hard component\r
+  w_Temp=w_EepromReadWord(w_PCIBoardEepromAddress,pc_PCIChipInformation,0x100+w_Address+10);\r
+  s_Header->w_Nchannel=(w_Temp>>4)& 0x03FF;\r
+  // Resolution for 1st hard component\r
+  w_Temp=w_EepromReadWord(w_PCIBoardEepromAddress,pc_PCIChipInformation,0x100+w_Address+16);\r
+  s_Header->b_Resolution=(BYTE)(w_Temp>>8) & 0xFF;\r
+  return 0;\r
+}\r
+\r
+\r
+/*\r
++----------------------------------------------------------------------------+\r
+| Function Name  : INT i_EepromReadAnlogInputHeader(WORD                                        |\r
+|                      w_PCIBoardEepromAddress,PCHAR pc_PCIChipInformation,     |\r
+|                      WORD w_Address,str_AnalogInputHeader *s_Header)          |\r
++----------------------------------------------------------------------------+\r
+| Task              : Read Nalog Output  Header                              |\r
++----------------------------------------------------------------------------+\r
+| Input Parameters  : WORD w_PCIBoardEepromAddress : PCI eeprom address      |\r
+|                                                                                                                                       |\r
+|                    PCHAR pc_PCIChipInformation  : PCI Chip Type.          |\r
+|                                                                                                                                       |\r
+|                       str_AnalogInputHeader *s_Header:Anlog Input Header      |  \r
+|                                                                                         Pointer                               |\r
++----------------------------------------------------------------------------+\r
+| Output Parameters : -                                                      |\r
++----------------------------------------------------------------------------+\r
+| Return Value      : 0                                                                                     |\r
++----------------------------------------------------------------------------+\r
+*/\r
+\r
+// Reads only for ONE  hardware component\r
+INT i_EepromReadAnlogInputHeader(WORD w_PCIBoardEepromAddress,PCHAR pc_PCIChipInformation,WORD w_Address,str_AnalogInputHeader *s_Header)\r
+{\r
+  WORD w_Temp,w_Offset;\r
+  w_Temp=w_EepromReadWord(w_PCIBoardEepromAddress,pc_PCIChipInformation,0x100+w_Address+10);\r
+  s_Header->w_Nchannel=(w_Temp>>4)& 0x03FF;\r
+  s_Header->w_MinConvertTiming=w_EepromReadWord(w_PCIBoardEepromAddress,pc_PCIChipInformation,0x100+w_Address+16);\r
+s_Header->w_MinDelayTiming=w_EepromReadWord(w_PCIBoardEepromAddress,pc_PCIChipInformation,0x100+w_Address+30);\r
+w_Temp=w_EepromReadWord(w_PCIBoardEepromAddress,pc_PCIChipInformation,0x100+w_Address+20);\r
+s_Header->b_HasDma=(w_Temp>>13) & 0x01; // whether dma present or not\r
+\r
+w_Temp=w_EepromReadWord(w_PCIBoardEepromAddress,pc_PCIChipInformation,0x100+w_Address+72);// reading Y\r
+w_Temp=w_Temp & 0x00FF;\r
+if(w_Temp)//Y>0\r
+{\r
+w_Offset=74+(2*w_Temp)+(10*(1+(w_Temp/16)));// offset of first analog input single header\r
+w_Offset= w_Offset+2; // resolution\r
+}\r
+else//Y=0\r
+{ \r
+w_Offset=74; \r
+w_Offset= w_Offset+2; // resolution\r
+}\r
+\r
+// read Resolution\r
+w_Temp=w_EepromReadWord(w_PCIBoardEepromAddress,pc_PCIChipInformation,0x100+w_Address+w_Offset);\r
+s_Header->b_Resolution=w_Temp & 0x001F;// last 5 bits\r
+\r
+return 0;\r
+}\r
index 5acb77f015dda0f3ac06f2d093eb8be08d314a11..853565394583d644e426d961345cf7068d55794b 100644 (file)
+/**\r
+@verbatim\r
+\r
+Copyright (C) 2004,2005  ADDI-DATA GmbH for the source code of this module. \r
+        \r
+        ADDI-DATA GmbH \r
+        Dieselstrasse 3 \r
+        D-77833 Ottersweier \r
+        Tel: +19(0)7223/9493-0 \r
+        Fax: +49(0)7223/9493-92 \r
+        http://www.addi-data-com \r
+        info@addi-data.com \r
+\r
+This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.\r
+\r
+This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.\r
+\r
+You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+\r
+You shoud also find the complete GPL in the COPYING file accompanying this source code.\r
+\r
+@endverbatim\r
+*/\r
+/*\r
+  +-----------------------------------------------------------------------+\r
+  | (C) ADDI-DATA GmbH          Dieselstraße 3       D-77833 Ottersweier  |\r
+  +-----------------------------------------------------------------------+\r
+  | Tel : +49 (0) 7223/9493-0     | email    : info@addi-data.com         |\r
+  | Fax : +49 (0) 7223/9493-92    | Internet : http://www.addi-data.com   |\r
+  +-------------------------------+---------------------------------------+\r
+  | Project     : APCI-1710       | Compiler   : GCC                      |\r
+  | Module name : hwdrv_apci1710.c| Version    : 2.96                     |\r
+  +-------------------------------+---------------------------------------+\r
+  | Project manager: Eric Stolz   | Date       :  02/12/2002              |\r
+  +-------------------------------+---------------------------------------+\r
+  | Description :   Hardware Layer Acces For APCI-1710                    |\r
+  +-----------------------------------------------------------------------+\r
+  |                             UPDATES                                   |\r
+  +----------+-----------+------------------------------------------------+\r
+  |   Date   |   Author  |          Description of updates                |\r
+  +----------+-----------+------------------------------------------------+\r
+  |          |           |                                                |\r
+  |          |           |                                                |\r
+  |          |           |                                                |\r
+  +----------+-----------+------------------------------------------------+\r
+*/\r
  #include "hwdrv_APCI1710.h"\r
- #include "APCI1710_Inp_cpt.c"\r 
+ #include "APCI1710_Inp_cpt.c"\r
\r
  #include "APCI1710_Ssi.c"\r
  #include "APCI1710_Tor.c"\r
- #include "APCI1710_Ttl.c"
- #include "APCI1710_Dig_io.c" 
- #include "APCI1710_82x54.c"
- #include "APCI1710_Chrono.c"
- #include "APCI1710_Pwm.c"
- #include "APCI1710_INCCPT.c"
-
-int i_APCI1710_Reset(comedi_device *dev);
-VOID v_APCI1710_Interrupt(int irq, void *d, struct pt_regs *regs) ;
-//for 1710
-
- int i_APCI1710_Reset(comedi_device *dev)
-{
-    int ret;
-    DWORD dw_Dummy;    
-  
-       /*********************************/ 
-       /* Read all module configuration */ 
-       /*********************************/ 
-        ret=inl(devpriv->s_BoardInfos.ui_Address+60);
-       devpriv->s_BoardInfos.dw_MolduleConfiguration [0]=ret;
-            
-        ret=inl(devpriv->s_BoardInfos.ui_Address+124);
-       devpriv->s_BoardInfos.dw_MolduleConfiguration [1]=ret;
-            
-        ret=inl(devpriv->s_BoardInfos.ui_Address+188);
-       devpriv->s_BoardInfos.dw_MolduleConfiguration [2]=ret;
-            
-        ret=inl(devpriv->s_BoardInfos.ui_Address+252);
-       devpriv->s_BoardInfos.dw_MolduleConfiguration [3]=ret;
-
-       // outl(0x80808082,devpriv->s_BoardInfos.ui_Address+0x60);
-       outl(0x83838383,devpriv->s_BoardInfos.ui_Address+0x60);  
-
-       // Enable the interrupt for the controler       
-       dw_Dummy =  inl(devpriv->s_BoardInfos.ui_Address+ 0x38);
-       outl(dw_Dummy | 0x2000,devpriv->s_BoardInfos.ui_Address+0x38);
-
-       return 0;
-}
-
-
-/*
-+----------------------------------------------------------------------------+
-| Function's Name   : __VOID__ v_APCI1710_InterruptFunction                  |
-|                              (BYTE b_Interrupt, __CPPARGS)                |
-+----------------------------------------------------------------------------+
-| Task              : APCI-1710 interrupt function                           |
-+----------------------------------------------------------------------------+
-| Input Parameters  : BYTE b_Interrupt : Interrupt number                    |
-+----------------------------------------------------------------------------+
-| Output Parameters : -                                                      |
-+----------------------------------------------------------------------------+
-| Return Value      : 0 : OK                                                 |
-|                    -1 : Error                                              |
-+----------------------------------------------------------------------------+
-*/
-
-
-       
-
-
-VOID v_APCI1710_Interrupt(int irq, void *d, struct pt_regs *regs)  
-{
-       comedi_device *dev = d;
-       comedi_subdevice *s = dev->subdevices + 0;      
-       BYTE   b_ModuleCpt       = 0;
-       BYTE   b_InterruptFlag   = 0;
-       BYTE   b_PWMCpt          = 0;
-       BYTE   b_ETMCpt          = 0;
-       BYTE   b_TorCounterCpt   = 0;
-       BYTE   b_PulseIncoderCpt = 0;
-       UINT  ui_16BitValue;
-       ULONG ul_InterruptLatchReg;
-       ULONG ul_LatchRegisterValue;
-       ULONG ul_82X54InterruptStatus;
-       ULONG ul_StatusRegister;
-
-       str_ModuleInfo  * ps_ModuleInfo;
-
-        printk("APCI1710 Interrupt\n");
-          for (b_ModuleCpt = 0; b_ModuleCpt < 4; b_ModuleCpt ++, ps_ModuleInfo ++)
-             {
-
-                /**************************/
-                /* 1199/0225 to 0100/0226 */
-                /**************************/
-                ps_ModuleInfo = &devpriv->s_ModuleInfo [b_ModuleCpt];
-
-
-                 /***********************/
-                /* Test if 82X54 timer */
-                /***********************/
-
-                if ((devpriv->
-                     s_BoardInfos.
-                     dw_MolduleConfiguration [b_ModuleCpt] & 0xFFFF0000UL) == APCI1710_82X54_TIMER)
-                   {
-                   
-                     //printk("TIMER Interrupt Occurred\n");
-                     ul_82X54InterruptStatus= inl(devpriv->s_BoardInfos.
-                              ui_Address + 12 + (64 * b_ModuleCpt));
-
-                   /***************************/
-                   /* Test if interrupt occur */
-                   /***************************/
-
-                   if ((ul_82X54InterruptStatus & ps_ModuleInfo->
-                                                  s_82X54ModuleInfo.
-                                                  b_InterruptMask) != 0)
-                      {
-                      devpriv->
-                      s_InterruptParameters.
-                      s_FIFOInterruptParameters [devpriv->
-                                                 s_InterruptParameters.
-                                                 ui_Write].
-                      ul_OldInterruptMask = (ul_82X54InterruptStatus & ps_ModuleInfo->
-                                                                       s_82X54ModuleInfo.
-                                                                       b_InterruptMask) << 4;
-
-                      devpriv->
-                      s_InterruptParameters.
-                      s_FIFOInterruptParameters [devpriv->
-                                                 s_InterruptParameters.
-                                                 ui_Write].
-                      b_OldModuleMask = 1 << b_ModuleCpt;
-
-                      devpriv->
-                      s_InterruptParameters.
-                      s_FIFOInterruptParameters [devpriv->
-                                                 s_InterruptParameters.
-                                                 ui_Write].
-                      ul_OldCounterLatchValue = 0;
-
-                      devpriv->
-                      s_InterruptParameters.
-                      ul_InterruptOccur ++;
-
-                      /****************************/
-                      /* Increment the write FIFO */
-                      /****************************/
-
-                      devpriv->
-                      s_InterruptParameters.
-                      ui_Write = (devpriv->
-                                  s_InterruptParameters.
-                                  ui_Write + 1) % APCI1710_SAVE_INTERRUPT;
-
-                      b_InterruptFlag = 1;
-
-                      
-                           
-                            /**********************/
-                            /* Call user function */
-                            /**********************/
-                         //Send a signal to from kernel to user space
-                            send_sig(SIGIO,devpriv->tsk_Current,0); 
-                           
-                      } // if ((ul_82X54InterruptStatus & 0x7) != 0)
-                   } // 82X54 timer
-
-
-
-
-
-                /***************************/
-                /* Test if increm. counter */
-                /***************************/
-
-                if ((devpriv->
-                     s_BoardInfos.
-                     dw_MolduleConfiguration [b_ModuleCpt] & 0xFFFF0000UL) == APCI1710_INCREMENTAL_COUNTER)
-                   {
-
-                        ul_InterruptLatchReg=inl(devpriv->s_BoardInfos.
-                              ui_Address + (64 * b_ModuleCpt));
-
-                   /*********************/
-                   /* Test if interrupt */
-                   /*********************/
-
-                   if ((ul_InterruptLatchReg & 0x22) && (ps_ModuleInfo->
-                                                         s_SiemensCounterInfo.
-                                                         s_ModeRegister.
-                                                         s_ByteModeRegister.
-                                                         b_ModeRegister2 & 0x80))
-                      {
-                      /************************************/
-                      /* Test if strobe latch I interrupt */
-                      /************************************/
-
-                      if (ul_InterruptLatchReg & 2)
-                         {
-                               ul_LatchRegisterValue=inl(devpriv->s_BoardInfos.
-                                    ui_Address + 4 + (64 * b_ModuleCpt));
-
-                         devpriv->
-                         s_InterruptParameters.
-                         s_FIFOInterruptParameters [devpriv->
-                                                    s_InterruptParameters.
-                                                    ui_Write].
-                         ul_OldInterruptMask = 1UL;
-
-                         devpriv->
-                         s_InterruptParameters.
-                         s_FIFOInterruptParameters [devpriv->
-                                                    s_InterruptParameters.
-                                                    ui_Write].
-                         b_OldModuleMask = 1 << b_ModuleCpt;
-
-                         devpriv->
-                         s_InterruptParameters.
-                         s_FIFOInterruptParameters [devpriv->
-                                                    s_InterruptParameters.
-                                                    ui_Write].
-                         ul_OldCounterLatchValue = ul_LatchRegisterValue;
-
-                         devpriv->
-                         s_InterruptParameters.
-                         ul_InterruptOccur ++;
-
-                         /****************************/
-                         /* 0899/0224 to 1199/0225   */
-                         /****************************/
-                         /* Increment the write FIFO */
-                      /****************************/
-
-                         devpriv->
-                         s_InterruptParameters.
-                         ui_Write = (devpriv->
-                                     s_InterruptParameters.
-                                     ui_Write + 1) % APCI1710_SAVE_INTERRUPT;
-
-                         b_InterruptFlag = 1;
-
-                        
-                            
-                               /**********************/
-                               /* Call user function */
-                               /**********************/
-                        //Send a signal to from kernel to user space
-                            send_sig(SIGIO,devpriv->tsk_Current,0); 
-                               
-                        
-                         }
-
-                      /*************************************/
-                      /* Test if strobe latch II interrupt */
-                      /*************************************/
-
-                      if (ul_InterruptLatchReg & 0x20)
-                         {
-                         
-                         ul_LatchRegisterValue=inl(devpriv->s_BoardInfos.
-                                    ui_Address + 8 + (64 * b_ModuleCpt));
-
-                         devpriv->
-                         s_InterruptParameters.
-                         s_FIFOInterruptParameters [devpriv->
-                                                    s_InterruptParameters.
-                                                    ui_Write].
-                         ul_OldInterruptMask = 2UL;
-
-                         devpriv->
-                         s_InterruptParameters.
-                         s_FIFOInterruptParameters [devpriv->
-                                                    s_InterruptParameters.
-                                                    ui_Write].
-                         b_OldModuleMask = 1 << b_ModuleCpt;
-
-                         devpriv->
-                         s_InterruptParameters.
-                         s_FIFOInterruptParameters [devpriv->
-                                                    s_InterruptParameters.
-                                                    ui_Write].
-                         ul_OldCounterLatchValue = ul_LatchRegisterValue;
-
-                         devpriv->
-                         s_InterruptParameters.
-                         ul_InterruptOccur ++;
-
-                         /****************************/
-                         /* 0899/0224 to 1199/0225   */
-                         /****************************/
-                         /* Increment the write FIFO */
-                         /****************************/
-
-                         devpriv->
-                         s_InterruptParameters.
-                         ui_Write = (devpriv->
-                                     s_InterruptParameters.
-                                     ui_Write + 1) % APCI1710_SAVE_INTERRUPT;
-
-                         b_InterruptFlag = 1;
-
-                         
-                           /**********************/
-                               /* Call user function */
-                               /**********************/
-                        //Send a signal to from kernel to user space
-                            send_sig(SIGIO,devpriv->tsk_Current,0); 
-                               
-                                 }
-                      }
-
-                 
-                       ul_InterruptLatchReg=inl(devpriv-> s_BoardInfos.
-                              ui_Address + 24 + (64 * b_ModuleCpt));
-
-                   /***************************/
-                   /* Test if index interrupt */
-                   /***************************/
-
-                   if (ul_InterruptLatchReg & 0x8)
-                      {
-                      ps_ModuleInfo->
-                      s_SiemensCounterInfo.
-                      s_InitFlag.
-                      b_IndexInterruptOccur = 1;
-
-                      if (ps_ModuleInfo->
-                          s_SiemensCounterInfo.
-                          s_ModeRegister.
-                          s_ByteModeRegister.
-                          b_ModeRegister2 & APCI1710_INDEX_AUTO_MODE)
-                         {
-
-                       outl(ps_ModuleInfo->
-                                     s_SiemensCounterInfo.
-                                     s_ModeRegister.
-                                     dw_ModeRegister1_2_3_4,devpriv->
-                                     s_BoardInfos.
-                                     ui_Address + 20 + (64 * b_ModuleCpt));
-                         }
-
-                      /*****************************/
-                      /* Test if interrupt enabled */
-                      /*****************************/
-
-                      if ((ps_ModuleInfo->
-                           s_SiemensCounterInfo.
-                           s_ModeRegister.
-                           s_ByteModeRegister.
-                           b_ModeRegister3 & APCI1710_ENABLE_INDEX_INT) == APCI1710_ENABLE_INDEX_INT)
-                         {
-                         devpriv->
-                         s_InterruptParameters.
-                         s_FIFOInterruptParameters [devpriv->
-                                                    s_InterruptParameters.
-                                                    ui_Write].
-                         ul_OldInterruptMask = 4UL;
-
-                         devpriv->
-                         s_InterruptParameters.
-                         s_FIFOInterruptParameters [devpriv->
-                                                    s_InterruptParameters.
-                                                    ui_Write].
-                         b_OldModuleMask = 1 << b_ModuleCpt;
-
-                         devpriv->
-                         s_InterruptParameters.
-                         s_FIFOInterruptParameters [devpriv->
-                                                    s_InterruptParameters.
-                                                    ui_Write].
-                         ul_OldCounterLatchValue = ul_LatchRegisterValue;
-
-                         devpriv->
-                         s_InterruptParameters.
-                         ul_InterruptOccur ++;
-
-                         /****************************/
-                         /* 0899/0224 to 1199/0225   */
-                         /****************************/
-                         /* Increment the write FIFO */
-                         /****************************/
-
-                         devpriv->
-                         s_InterruptParameters.
-                         ui_Write = (devpriv->
-                                     s_InterruptParameters.
-                                     ui_Write + 1) % APCI1710_SAVE_INTERRUPT;
-
-                         b_InterruptFlag = 1;
-
-                         
-                           
-                               /**********************/
-                               /* Call user function */
-                               /**********************/
-                        //Send a signal to from kernel to user space
-                            send_sig(SIGIO,devpriv->tsk_Current,0); 
-                               
-                               }
-                      }
-
-                   /*****************************/
-                   /* Test if compare interrupt */
-                   /*****************************/
-
-                   if (ul_InterruptLatchReg & 0x10)
-                      {
-                      /*****************************/
-                      /* Test if interrupt enabled */
-                      /*****************************/
-
-                      if ((ps_ModuleInfo->
-                           s_SiemensCounterInfo.
-                           s_ModeRegister.
-                           s_ByteModeRegister.
-                           b_ModeRegister3 & APCI1710_ENABLE_COMPARE_INT) == APCI1710_ENABLE_COMPARE_INT)
-                         {
-                         devpriv->
-                         s_InterruptParameters.
-                         s_FIFOInterruptParameters [devpriv->
-                                                    s_InterruptParameters.
-                                                    ui_Write].
-                         ul_OldInterruptMask = 8UL;
-
-                         devpriv->
-                         s_InterruptParameters.
-                         s_FIFOInterruptParameters [devpriv->
-                                                    s_InterruptParameters.
-                                                    ui_Write].
-                         b_OldModuleMask = 1 << b_ModuleCpt;
-
-                         devpriv->
-                         s_InterruptParameters.
-                         s_FIFOInterruptParameters [devpriv->
-                                                    s_InterruptParameters.
-                                                    ui_Write].
-                         ul_OldCounterLatchValue = ul_LatchRegisterValue;
-
-                         devpriv->
-                         s_InterruptParameters.
-                         ul_InterruptOccur ++;
-
-                         /****************************/
-                         /* 0899/0224 to 1199/0225   */
-                         /****************************/
-                         /* Increment the write FIFO */
-                      /****************************/
-
-                         devpriv->
-                         s_InterruptParameters.
-                         ui_Write = (devpriv->
-                                     s_InterruptParameters.
-                                     ui_Write + 1) % APCI1710_SAVE_INTERRUPT;
-
-                         b_InterruptFlag = 1;
-
-                         
-                           
-                               /**********************/
-                               /* Call user function */
-                               /**********************/
-                        //Send a signal to from kernel to user space
-                            send_sig(SIGIO,devpriv->tsk_Current,0); 
-                               
-                         
-                         }
-                      }
-
-                   /*******************************************/
-                   /* Test if frequency measurement interrupt */
-                   /*******************************************/
-
-                   if (ul_InterruptLatchReg & 0x20)
-                      {
-                      /*******************/
-                      /* Read the status */
-                      /*******************/
-
-                         ul_StatusRegister=inl(devpriv->s_BoardInfos.
-                                 ui_Address + 32 + (64 * b_ModuleCpt));
-
-                      /******************/
-                      /* Read the value */
-                      /******************/
-
-
-                         ul_LatchRegisterValue=inl(devpriv->s_BoardInfos.
-                                 ui_Address + 28 + (64 * b_ModuleCpt));
-
-                      switch ((ul_StatusRegister >> 1) & 3)
-                         {
-                         case 0:
-                              /*************************/
-                              /* Test the counter mode */
-                              /*************************/
-
-                              if ((devpriv->
-                                   s_ModuleInfo [b_ModuleCpt].
-                                   s_SiemensCounterInfo.
-                                   s_ModeRegister.
-                                   s_ByteModeRegister.
-                                   b_ModeRegister1 & APCI1710_16BIT_COUNTER) == APCI1710_16BIT_COUNTER)
-                                 {
-                                 /****************************************/
-                                 /* Test if 16-bit counter 1 pulse occur */
-                                 /****************************************/
-
-                                 if ((ul_LatchRegisterValue & 0xFFFFU) != 0)
-                                    {
-                                    ui_16BitValue         = (UINT) ul_LatchRegisterValue & 0xFFFFU;
-                                    ul_LatchRegisterValue = (ul_LatchRegisterValue & 0xFFFF0000UL) | (0xFFFFU - ui_16BitValue);
-                                    }
-
-                                 /****************************************/
-                                 /* Test if 16-bit counter 2 pulse occur */
-                                 /****************************************/
-
-                                 if ((ul_LatchRegisterValue & 0xFFFF0000UL) != 0)
-                                    {
-                                    ui_16BitValue         = (UINT) ((ul_LatchRegisterValue >> 16) & 0xFFFFU);
-                                    ul_LatchRegisterValue = (ul_LatchRegisterValue & 0xFFFFUL) | ((0xFFFFU - ui_16BitValue) << 16);
-                                    }
-                                 }
-                              else
-                                 {
-                                 if (ul_LatchRegisterValue != 0)
-                                    {
-                                    ul_LatchRegisterValue = 0xFFFFFFFFUL - ul_LatchRegisterValue;
-                                    }
-                                 }
-                              break;
-
-                         case 1:
-                              /****************************************/
-                              /* Test if 16-bit counter 2 pulse occur */
-                              /****************************************/
-
-                              if ((ul_LatchRegisterValue & 0xFFFF0000UL) != 0)
-                                 {
-                                 ui_16BitValue         = (UINT) ((ul_LatchRegisterValue >> 16) & 0xFFFFU);
-                                 ul_LatchRegisterValue = (ul_LatchRegisterValue & 0xFFFFUL) | ((0xFFFFU - ui_16BitValue) << 16);
-                                 }
-                              break;
-
-                         case 2:
-                              /****************************************/
-                              /* Test if 16-bit counter 1 pulse occur */
-                              /****************************************/
-
-                              if ((ul_LatchRegisterValue & 0xFFFFU) != 0)
-                                 {
-                                 ui_16BitValue         = (UINT) ul_LatchRegisterValue & 0xFFFFU;
-                                 ul_LatchRegisterValue = (ul_LatchRegisterValue & 0xFFFF0000UL) | (0xFFFFU - ui_16BitValue);
-                                 }
-                              break;
-                         }
-
-                      devpriv->
-                      s_InterruptParameters.
-                      s_FIFOInterruptParameters [devpriv->
-                                                 s_InterruptParameters.
-                                                 ui_Write].
-                      ul_OldInterruptMask = 0x10000UL;
-
-                      devpriv->
-                      s_InterruptParameters.
-                      s_FIFOInterruptParameters [devpriv->
-                                                 s_InterruptParameters.
-                                                 ui_Write].
-                      b_OldModuleMask = 1 << b_ModuleCpt;
-
-                      devpriv->
-                      s_InterruptParameters.
-                      s_FIFOInterruptParameters [devpriv->
-                                                 s_InterruptParameters.
-                                                 ui_Write].
-                      ul_OldCounterLatchValue = ul_LatchRegisterValue;
-
-                      devpriv->
-                      s_InterruptParameters.
-                      ul_InterruptOccur ++;
-
-                      /****************************/
-                      /* 0899/0224 to 1199/0225   */
-                      /****************************/
-                      /* Increment the write FIFO */
-                      /****************************/
-
-                      devpriv->
-                      s_InterruptParameters.
-                      ui_Write = (devpriv->
-                                  s_InterruptParameters.
-                                  ui_Write + 1) % APCI1710_SAVE_INTERRUPT;
-
-                      b_InterruptFlag = 1;
-
-                      
-                           
-                            /**********************/
-                            /* Call user function */
-                            /**********************/
-                        //Send a signal to from kernel to user space
-                            send_sig(SIGIO,devpriv->tsk_Current,0); 
-                           
-
-                      
-                      }
-                   } // Incremental counter
-
-
-
-
-
-
-                /***************/
-                /* Test if CDA */
-                /***************/
-
-                if ((devpriv->
-                     s_BoardInfos.
-                     dw_MolduleConfiguration [b_ModuleCpt] & 0xFFFF0000UL) == APCI1710_CDA)
-                   {
-                   /******************************************/
-                   /* Test if CDA enable and functionality 0 */
-                   /******************************************/
-
-                   if ((devpriv->
-                        s_ModuleInfo [b_ModuleCpt].
-                        s_CDAModuleInfo.
-                        b_CDAEnable == APCI1710_ENABLE) && (devpriv->
-                                                            s_ModuleInfo [b_ModuleCpt].
-                                                            s_CDAModuleInfo.
-                                                            b_FctSelection == 0))
-                      {
-                      /****************************/
-                      /* Get the interrupt status */
-                      /****************************/
-
-
-                       ul_StatusRegister=inl(devpriv->s_BoardInfos.
-                                 ui_Address + 16 + (64 * b_ModuleCpt));
-                      /***************************/
-                      /* Test if interrupt occur */
-                      /***************************/
-
-                      if (ul_StatusRegister & 1)
-                         {
-                         devpriv->
-                         s_InterruptParameters.
-                         s_FIFOInterruptParameters [devpriv->
-                                                    s_InterruptParameters.
-                                                    ui_Write].
-                         ul_OldInterruptMask = 0x80000UL;
-
-                         devpriv->
-                         s_InterruptParameters.
-                         s_FIFOInterruptParameters [devpriv->
-                                                    s_InterruptParameters.
-                                                    ui_Write].
-                         b_OldModuleMask = 1 << b_ModuleCpt;
-
-                         devpriv->
-                         s_InterruptParameters.
-                         s_FIFOInterruptParameters [devpriv->
-                                                    s_InterruptParameters.
-                                                    ui_Write].
-                         ul_OldCounterLatchValue = 0;
-
-                         devpriv->
-                         s_InterruptParameters.
-                         ul_InterruptOccur ++;
-
-                         
-                         /****************************/
-                         /* Increment the write FIFO */
-                         /****************************/
-
-                         devpriv->
-                         s_InterruptParameters.
-                         ui_Write = (devpriv->
-                                     s_InterruptParameters.
-                                     ui_Write + 1) % APCI1710_SAVE_INTERRUPT;
-
-                         b_InterruptFlag = 1;
-
-                         
-                          
-                               /**********************/
-                               /* Call user function */
-                               /**********************/
-
-                               //Send a signal to from kernel to user space
-                            send_sig(SIGIO,devpriv->tsk_Current,0);            
-
-                         } // if (ul_StatusRegister & 1)
-                     
-                        }
-                   } // CDA
-
-
-                /***********************/
-                /* Test if PWM counter */
-                /***********************/
-
-                if ((devpriv->
-                     s_BoardInfos.
-                     dw_MolduleConfiguration [b_ModuleCpt] & 0xFFFF0000UL) == APCI1710_PWM)
-                   {
-                   for (b_PWMCpt = 0; b_PWMCpt < 2; b_PWMCpt ++)
-                      {
-                      /*************************************/
-                      /* Test if PWM interrupt initialised */
-                      /*************************************/
-
-                      if (devpriv->
-                          s_ModuleInfo [b_ModuleCpt].
-                          s_PWMModuleInfo.
-                          s_PWMInfo [b_PWMCpt].
-                          b_InterruptEnable == APCI1710_ENABLE)
-                         {
-                         /*****************************/
-                         /* Read the interrupt status */
-                         /*****************************/
-
-                       ul_StatusRegister=inl(devpriv->s_BoardInfos.
-                                    ui_Address + 16 + (20 * b_PWMCpt) + (64 * b_ModuleCpt));
-
-
-                         /***************************/
-                         /* Test if interrupt occur */
-                         /***************************/
-
-                         if (ul_StatusRegister & 0x1)
-                            {
-                            devpriv->
-                            s_InterruptParameters.
-                            s_FIFOInterruptParameters [devpriv->
-                                                       s_InterruptParameters.
-                                                       ui_Write].
-                            ul_OldInterruptMask = 0x4000UL << b_PWMCpt;
-
-                            devpriv->
-                            s_InterruptParameters.
-                            s_FIFOInterruptParameters [devpriv->
-                                                       s_InterruptParameters.
-                                                       ui_Write].
-                            b_OldModuleMask = 1 << b_ModuleCpt;
-
-                            devpriv->
-                            s_InterruptParameters.
-                            ul_InterruptOccur ++;
-
-                            /****************************/
-                            /* Increment the write FIFO */
-                            /****************************/
-
-                            devpriv->
-                            s_InterruptParameters.
-                            ui_Write = (devpriv->
-                                        s_InterruptParameters.
-                                        ui_Write + 1) % APCI1710_SAVE_INTERRUPT;
-
-                            b_InterruptFlag = 1;
-
-                            
-                                  /**********************/
-                                  /* Call user function */
-                                  /**********************/
-                               //Send a signal to from kernel to user space
-                            send_sig(SIGIO,devpriv->tsk_Current,0); 
-
-                            
-                            } // if (ul_StatusRegister & 0x1)
-                         } // if (APCI1710_ENABLE)
-                      } // for (b_PWMCpt == 0; b_PWMCpt < 0; b_PWMCpt ++)
-                   } // PWM counter
-
-
-
-                /***********************/
-                /* Test if tor counter */
-                /***********************/
-
-                if ((devpriv->
-                     s_BoardInfos.
-                     dw_MolduleConfiguration [b_ModuleCpt] & 0xFFFF0000UL) == APCI1710_TOR_COUNTER)
-                   {
-                   for (b_TorCounterCpt = 0; b_TorCounterCpt < 2; b_TorCounterCpt ++)
-                      {
-                      /*************************************/
-                      /* Test if tor interrupt initialised */
-                      /*************************************/
-
-                      if (devpriv->
-                          s_ModuleInfo [b_ModuleCpt].
-                          s_TorCounterModuleInfo.
-                          s_TorCounterInfo [b_TorCounterCpt].
-                          b_InterruptEnable == APCI1710_ENABLE)
-                         {
-                         /*****************************/
-                         /* Read the interrupt status */
-                         /*****************************/
-
-                       
-                               ul_StatusRegister=inl(devpriv->s_BoardInfos.
-                                    ui_Address + 12 + (16 * b_TorCounterCpt) + (64 * b_ModuleCpt));
-
-                         /***************************/
-                         /* Test if interrupt occur */
-                         /***************************/
-
-                         if (ul_StatusRegister & 0x1)
-                            {
-                            /******************************/
-                            /* Read the tor counter value */
-                            /******************************/
-
-                            
-                          ul_LatchRegisterValue=inl(devpriv->s_BoardInfos.
-                                       ui_Address + 0 + (16 * b_TorCounterCpt) + (64 * b_ModuleCpt));
-
-                            devpriv->
-                            s_InterruptParameters.
-                            s_FIFOInterruptParameters [devpriv->
-                                                       s_InterruptParameters.
-                                                       ui_Write].
-                            ul_OldInterruptMask = 0x1000UL << b_TorCounterCpt;
-
-                            devpriv->
-                            s_InterruptParameters.
-                            s_FIFOInterruptParameters [devpriv->
-                                                       s_InterruptParameters.
-                                                       ui_Write].
-                            b_OldModuleMask = 1 << b_ModuleCpt;
-
-                            devpriv->
-                            s_InterruptParameters.
-                            s_FIFOInterruptParameters [devpriv->
-                                                       s_InterruptParameters.
-                                                       ui_Write].
-                            ul_OldCounterLatchValue = ul_LatchRegisterValue;
-
-                            devpriv->
-                            s_InterruptParameters.
-                            ul_InterruptOccur ++;
-
-                            
-                            /****************************/
-                            /* Increment the write FIFO */
-                            /****************************/
-
-                            devpriv->
-                            s_InterruptParameters.
-                            ui_Write = (devpriv->
-                                        s_InterruptParameters.
-                                        ui_Write + 1) % APCI1710_SAVE_INTERRUPT;
-
-                            b_InterruptFlag = 1;
-
-       
-                                  /**********************/
-                                  /* Call user function */
-                                  /**********************/
-
-                            //Send a signal to from kernel to user space
-                            send_sig(SIGIO,devpriv->tsk_Current,0); 
-                            } // if (ul_StatusRegister & 0x1)
-                         } // if (APCI1710_ENABLE)
-                      } // for (b_TorCounterCpt == 0; b_TorCounterCpt < 0; b_TorCounterCpt ++)
-                   } // Tor counter
-
-
-
-
-                /***********************/
-                /* Test if chronometer */
-                /***********************/
-
-                if ((devpriv->
-                     s_BoardInfos.
-                     dw_MolduleConfiguration [b_ModuleCpt] & 0xFFFF0000UL) == APCI1710_CHRONOMETER)
-                   {
-                    
-                       //printk("APCI1710 Chrono Interrupt\n");
-                   /*****************************/
-                   /* Read the interrupt status */
-                   /*****************************/
-
-                   
-                     ul_InterruptLatchReg=inl(devpriv->s_BoardInfos.
-                              ui_Address + 12 + (64 * b_ModuleCpt));
-
-                   /***************************/
-                   /* Test if interrupt occur */
-                   /***************************/
-
-                   if ((ul_InterruptLatchReg & 0x8) == 0x8)
-                      {
-                      /****************************/
-                      /* Clear the interrupt flag */
-                      /****************************/
-
-                     
-                               outl(0,devpriv->s_BoardInfos.
-                                  ui_Address + 32 + (64 * b_ModuleCpt));
-
-                      /***************************/
-                      /* Test if continuous mode */
-                      /***************************/
-
-                      if (ps_ModuleInfo->
-                          s_ChronoModuleInfo.
-                          b_CycleMode == APCI1710_ENABLE)
-                         {
-                         /********************/
-                         /* Clear the status */
-                         /********************/
-
-                         
-                       outl(0,devpriv->s_BoardInfos.
-                                     ui_Address + 36 + (64 * b_ModuleCpt));
-                         }
-
-                      /*************************/
-                      /* Read the timing value */
-                      /*************************/
-
-                      
-                               ul_LatchRegisterValue=inl(devpriv->s_BoardInfos.
-                                 ui_Address + 4 + (64 * b_ModuleCpt));
-
-                      /*****************************/
-                      /* Test if interrupt enabled */
-                      /*****************************/
-
-                      if (ps_ModuleInfo->
-                          s_ChronoModuleInfo.
-                          b_InterruptMask)
-                         {
-                         devpriv->
-                         s_InterruptParameters.
-                         s_FIFOInterruptParameters [devpriv->
-                                                    s_InterruptParameters.
-                                                    ui_Write].
-                         ul_OldInterruptMask = 0x80;
-
-                         devpriv->
-                         s_InterruptParameters.
-                         s_FIFOInterruptParameters [devpriv->
-                                                    s_InterruptParameters.
-                                                    ui_Write].
-                         b_OldModuleMask = 1 << b_ModuleCpt;
-
-                         devpriv->
-                         s_InterruptParameters.
-                         s_FIFOInterruptParameters [devpriv->
-                                                    s_InterruptParameters.
-                                                    ui_Write].
-                         ul_OldCounterLatchValue = ul_LatchRegisterValue;
-
-                         devpriv->
-                         s_InterruptParameters.
-                         ul_InterruptOccur ++;
-
-                         /****************************/
-                         /* Increment the write FIFO */
-                      /****************************/
-
-                         devpriv->
-                         s_InterruptParameters.
-                         ui_Write = (devpriv->
-                                     s_InterruptParameters.
-                                     ui_Write + 1) % APCI1710_SAVE_INTERRUPT;
-
-                         b_InterruptFlag = 1;
-
-                         
-                           
-                               /**********************/
-                               /* Call user function */
-                               /**********************/
-                               //Send a signal to from kernel to user space
-                            send_sig(SIGIO,devpriv->tsk_Current,0); 
-                               
-                         }
-                  }
-                } // Chronometer
-
-
-
-                /*************************/
-                /* Test if pulse encoder */
-                /*************************/
-
-                if ((devpriv->
-                     s_BoardInfos.
-                     dw_MolduleConfiguration [b_ModuleCpt] & 0xFFFF0000UL) == APCI1710_PULSE_ENCODER)
-                   {
-                   /****************************/
-                   /* Read the status register */
-                   /****************************/
-
-                   
-                       ul_StatusRegister=inl(devpriv->s_BoardInfos.
-                              ui_Address + 20 + (64 * b_ModuleCpt));
-
-                   if (ul_StatusRegister & 0xF)
-                      {
-                      for (b_PulseIncoderCpt = 0; b_PulseIncoderCpt < 4; b_PulseIncoderCpt ++)
-                         {
-                         /*************************************/
-                         /* Test if pulse encoder initialised */
-                         /*************************************/
-
-                         if ((ps_ModuleInfo->
-                              s_PulseEncoderModuleInfo.
-                              s_PulseEncoderInfo [b_PulseIncoderCpt].
-                              b_PulseEncoderInit == 1) &&
-                             (((ps_ModuleInfo->
-                                s_PulseEncoderModuleInfo.
-                                dw_SetRegister >> b_PulseIncoderCpt) & 1) == 1) &&
-                             (((ul_StatusRegister >> (b_PulseIncoderCpt)) & 1) == 1))
-                            {
-                            devpriv->
-                            s_InterruptParameters.
-                            s_FIFOInterruptParameters [devpriv->
-                                                       s_InterruptParameters.
-                                                       ui_Write].
-                            ul_OldInterruptMask = 0x100UL << b_PulseIncoderCpt;
-
-                            devpriv->
-                            s_InterruptParameters.
-                            s_FIFOInterruptParameters [devpriv->
-                                                       s_InterruptParameters.
-                                                       ui_Write].
-                            b_OldModuleMask = 1 << b_ModuleCpt;
-
-                            devpriv->
-                            s_InterruptParameters.
-                            s_FIFOInterruptParameters [devpriv->
-                                                       s_InterruptParameters.
-                                                       ui_Write].
-                            ul_OldCounterLatchValue = ul_LatchRegisterValue;
-
-                            devpriv->
-                            s_InterruptParameters.
-                            ul_InterruptOccur ++;
-
-                            /****************************/
-                            /* 0899/0224 to 1199/0225   */
-                            /****************************/
-                            /* Increment the write FIFO */
-                            /****************************/
-
-                           devpriv->
-                            s_InterruptParameters.
-                            ui_Write = (devpriv->
-                                        s_InterruptParameters.
-                                        ui_Write + 1) % APCI1710_SAVE_INTERRUPT;
-
-                            b_InterruptFlag = 1;
-                           
-                                  /**********************/
-                                  /* Call user function */
-                                  /**********************/
-                            //Send a signal to from kernel to user space
-                            send_sig(SIGIO,devpriv->tsk_Current,0); 
-                                  
-                
-                            }
-                               }
-                      }
-                   }//pulse encoder
-
-          }
-  return ; 
-
-}
-
+ #include "APCI1710_Ttl.c"\r
+ #include "APCI1710_Dig_io.c" \r
+ #include "APCI1710_82x54.c"\r
+ #include "APCI1710_Chrono.c"\r
+ #include "APCI1710_Pwm.c"\r
+ #include "APCI1710_INCCPT.c"\r
+\r
+\r
+void   i_ADDI_AttachPCI1710 (comedi_device *dev)\r
+       {\r
+       comedi_subdevice *s;\r
+       int ret          = 0;\r
+       int n_subdevices = 9;\r
+       \r
+       //Update-0.7.57->0.7.68dev->n_subdevices = 9;\r
+       if((ret=alloc_subdevices(dev,n_subdevices))<0)\r
+       return ret;\r
\r
+        // Allocate and Initialise Timer Subdevice Structures          \r
+       s = dev->subdevices + 0;\r
+        \r
+       s->type = COMEDI_SUBD_TIMER;\r
+       s->subdev_flags = SDF_WRITEABLE|SDF_RT|SDF_GROUND|SDF_COMMON; \r
+       s->n_chan = 3; \r
+       s->maxdata = 0; \r
+       s->len_chanlist = 3;\r
+       s->range_table = &range_digital;       \r
+        s->insn_write=i_APCI1710_InsnWriteEnableDisableTimer;\r
+       s->insn_read=i_APCI1710_InsnReadAllTimerValue;\r
+       s->insn_config=i_APCI1710_InsnConfigInitTimer;\r
+       s->insn_bits=i_APCI1710_InsnBitsTimer;\r
+       \r
+\r
+       // Allocate and Initialise DIO Subdevice Structures     \r
+       s = dev->subdevices + 1;\r
+        \r
+       s->type = COMEDI_SUBD_DIO;\r
+       s->subdev_flags = SDF_WRITEABLE|SDF_READABLE|SDF_RT|SDF_GROUND|SDF_COMMON;\r
+       s->n_chan = 7;\r
+       s->maxdata = 1;\r
+       s->len_chanlist = 7;\r
+       s->range_table = &range_digital;        \r
+               s->insn_config=i_APCI1710_InsnConfigDigitalIO;\r
+               s->insn_read= i_APCI1710_InsnReadDigitalIOChlValue;\r
+       s->insn_bits=i_APCI1710_InsnBitsDigitalIOPortOnOff;\r
+       s->insn_write=i_APCI1710_InsnWriteDigitalIOChlOnOff;\r
+        \r
+\r
+        // Allocate and Initialise Chrono Subdevice Structures         \r
+       s = dev->subdevices + 2;\r
+        \r
+       s->type = COMEDI_SUBD_CHRONO;\r
+       s->subdev_flags = SDF_WRITEABLE|SDF_RT|SDF_GROUND|SDF_COMMON; \r
+       s->n_chan = 4; \r
+       s->maxdata = 0; \r
+       s->len_chanlist = 4;\r
+       s->range_table = &range_digital;        \r
+        s->insn_write=i_APCI1710_InsnWriteEnableDisableChrono;\r
+       s->insn_read=i_APCI1710_InsnReadChrono;\r
+       s->insn_config=i_APCI1710_InsnConfigInitChrono;\r
+       s->insn_bits=i_APCI1710_InsnBitsChronoDigitalIO;\r
+       \r
+       \r
+       // Allocate and Initialise PWM Subdevice Structures                 \r
+       s = dev->subdevices + 3;\r
+       s->type = COMEDI_SUBD_PWM;\r
+       s->subdev_flags = SDF_WRITEABLE|SDF_READABLE|SDF_RT|SDF_GROUND|SDF_COMMON;\r
+       s->n_chan = 3;\r
+       s->maxdata = 1;\r
+       s->len_chanlist = 3;\r
+       s->range_table = &range_digital;\r
+       s->io_bits=0;           //all bits input        \r
+       s->insn_config = i_APCI1710_InsnConfigPWM;\r
+       s->insn_read   = i_APCI1710_InsnReadGetPWMStatus;\r
+       s->insn_write  = i_APCI1710_InsnWritePWM;\r
+        s->insn_bits   = i_APCI1710_InsnBitsReadPWMInterrupt;\r
+\r
+       // Allocate and Initialise TTLIO Subdevice Structures\r
+       s = dev->subdevices + 4;\r
+       s->type = COMEDI_SUBD_TTLIO;\r
+       s->subdev_flags = SDF_WRITEABLE|SDF_READABLE|SDF_RT|SDF_GROUND|SDF_COMMON;\r
+       s->n_chan = 8;\r
+       s->maxdata = 1;\r
+       s->len_chanlist = 8;\r
+       s->range_table = &range_apci1710_ttl; // to pass arguments in range     \r
+        s->insn_config         = i_APCI1710_InsnConfigInitTTLIO;\r
+       s->insn_bits    = i_APCI1710_InsnBitsReadTTLIO;\r
+       s->insn_write   = i_APCI1710_InsnWriteSetTTLIOChlOnOff;\r
+        s->insn_read   = i_APCI1710_InsnReadTTLIOAllPortValue;\r
+\r
+\r
+       // Allocate and Initialise TOR Subdevice Structures\r
+       s = dev->subdevices + 5;\r
+       s->type = COMEDI_SUBD_TOR;\r
+       s->subdev_flags = SDF_WRITEABLE|SDF_READABLE|SDF_RT|SDF_GROUND|SDF_COMMON;\r
+       s->n_chan = 8;\r
+       s->maxdata = 1;\r
+       s->len_chanlist = 8;\r
+       s->range_table = &range_digital;\r
+       s->io_bits=0;           //all bits input        \r
+        s->insn_config = i_APCI1710_InsnConfigInitTorCounter;\r
+       s->insn_read   = i_APCI1710_InsnReadGetTorCounterInitialisation;\r
+       s->insn_write  = i_APCI1710_InsnWriteEnableDisableTorCounter;\r
+       s->insn_bits   = i_APCI1710_InsnBitsGetTorCounterProgressStatusAndValue;\r
\r
+       // Allocate and Initialise SSI Subdevice Structures\r
+       s = dev->subdevices + 6;\r
+       s->type = COMEDI_SUBD_SSI;\r
+       s->subdev_flags = SDF_WRITEABLE|SDF_READABLE|SDF_RT|SDF_GROUND|SDF_COMMON;\r
+       s->n_chan =4;\r
+       s->maxdata = 1;\r
+       s->len_chanlist = 4;\r
+       s->range_table = &range_apci1710_ssi;   \r
+       s->insn_config = i_APCI1710_InsnConfigInitSSI;\r
+       s->insn_read   = i_APCI1710_InsnReadSSIValue;\r
+       s->insn_bits  = i_APCI1710_InsnBitsSSIDigitalIO;\r
\r
+       // Allocate and Initialise PULSEENCODER Subdevice Structures       \r
+       s                       = dev->subdevices + 7;\r
+       s->type                 = COMEDI_SUBD_PULSEENCODER;\r
+       s->subdev_flags = SDF_WRITEABLE|SDF_READABLE|SDF_RT|SDF_GROUND|SDF_COMMON;\r
+       s->n_chan               = 4;\r
+       s->maxdata              = 1;\r
+       s->len_chanlist = 4;\r
+       s->range_table  = &range_digital;       \r
+       s->insn_config  = i_APCI1710_InsnConfigInitPulseEncoder;\r
+       s->insn_write   = i_APCI1710_InsnWriteEnableDisablePulseEncoder;\r
+       s->insn_bits    = i_APCI1710_InsnBitsReadWritePulseEncoder;\r
+       s->insn_read    = i_APCI1710_InsnReadInterruptPulseEncoder;\r
+\r
+       // Allocate and Initialise INCREMENTALCOUNTER Subdevice Structures     \r
+       s                       = dev->subdevices + 8;\r
+       s->type                 = COMEDI_SUBD_INCREMENTALCOUNTER;\r
+       s->subdev_flags = SDF_WRITEABLE|SDF_READABLE|SDF_RT|SDF_GROUND|SDF_COMMON;\r
+       s->n_chan               = 500;\r
+       s->maxdata              = 1;\r
+       s->len_chanlist = 500;\r
+       s->range_table  = &range_apci1710_inccpt;       \r
+       s->insn_config  = i_APCI1710_InsnConfigINCCPT;\r
+       s->insn_write   = i_APCI1710_InsnWriteINCCPT;\r
+       s->insn_read    = i_APCI1710_InsnReadINCCPT;\r
+       s->insn_bits    = i_APCI1710_InsnBitsINCCPT;\r
+       }\r
\r
\r
\r
+int i_APCI1710_Reset(comedi_device *dev);\r
+VOID v_APCI1710_Interrupt(int irq, void *d, struct pt_regs *regs) ;\r
+//for 1710\r
+\r
+ int i_APCI1710_Reset(comedi_device *dev)\r
+{\r
+    int ret;\r
+    DWORD dw_Dummy;    \r
+  \r
+       /*********************************/ \r
+       /* Read all module configuration */ \r
+       /*********************************/ \r
+        ret=inl(devpriv->s_BoardInfos.ui_Address+60);\r
+       devpriv->s_BoardInfos.dw_MolduleConfiguration [0]=ret;\r
+            \r
+        ret=inl(devpriv->s_BoardInfos.ui_Address+124);\r
+       devpriv->s_BoardInfos.dw_MolduleConfiguration [1]=ret;\r
+            \r
+        ret=inl(devpriv->s_BoardInfos.ui_Address+188);\r
+       devpriv->s_BoardInfos.dw_MolduleConfiguration [2]=ret;\r
+            \r
+        ret=inl(devpriv->s_BoardInfos.ui_Address+252);\r
+       devpriv->s_BoardInfos.dw_MolduleConfiguration [3]=ret;\r
+\r
+       // outl(0x80808082,devpriv->s_BoardInfos.ui_Address+0x60);\r
+       outl(0x83838383,devpriv->s_BoardInfos.ui_Address+0x60);  \r
+       \r
+       devpriv->s_BoardInfos.b_BoardVersion = 1;\r
+\r
+       // Enable the interrupt for the controler       \r
+       dw_Dummy =  inl(devpriv->s_BoardInfos.ui_Address+ 0x38);\r
+       outl(dw_Dummy | 0x2000,devpriv->s_BoardInfos.ui_Address+0x38);\r
+\r
+       return 0;\r
+}\r
+\r
+\r
+/*\r
++----------------------------------------------------------------------------+\r
+| Function's Name   : __VOID__ v_APCI1710_InterruptFunction                  |\r
+|                              (BYTE b_Interrupt, __CPPARGS)                |\r
++----------------------------------------------------------------------------+\r
+| Task              : APCI-1710 interrupt function                           |\r
++----------------------------------------------------------------------------+\r
+| Input Parameters  : BYTE b_Interrupt : Interrupt number                    |\r
++----------------------------------------------------------------------------+\r
+| Output Parameters : -                                                      |\r
++----------------------------------------------------------------------------+\r
+| Return Value      : 0 : OK                                                 |\r
+|                    -1 : Error                                              |\r
++----------------------------------------------------------------------------+\r
+*/\r
+\r
+\r
+       \r
+\r
+\r
+VOID v_APCI1710_Interrupt(int irq, void *d, struct pt_regs *regs)  \r
+{\r
+       comedi_device *dev = d;\r
+       BYTE   b_ModuleCpt       = 0;\r
+       BYTE   b_InterruptFlag   = 0;\r
+       BYTE   b_PWMCpt          = 0;\r
+       BYTE   b_TorCounterCpt   = 0;\r
+       BYTE   b_PulseIncoderCpt = 0;\r
+       UINT  ui_16BitValue;\r
+       ULONG ul_InterruptLatchReg = 0;\r
+       ULONG ul_LatchRegisterValue;\r
+       ULONG ul_82X54InterruptStatus;\r
+       ULONG ul_StatusRegister;\r
+\r
+       str_ModuleInfo  * ps_ModuleInfo;\r
+\r
+        printk("APCI1710 Interrupt\n");\r
+          for (b_ModuleCpt = 0; b_ModuleCpt < 4; b_ModuleCpt ++, ps_ModuleInfo ++)\r
+             {\r
+\r
+                /**************************/\r
+                /* 1199/0225 to 0100/0226 */\r
+                /**************************/\r
+                ps_ModuleInfo = &devpriv->s_ModuleInfo [b_ModuleCpt];\r
+\r
+\r
+                 /***********************/\r
+                /* Test if 82X54 timer */\r
+                /***********************/\r
+\r
+                if ((devpriv->\r
+                     s_BoardInfos.\r
+                     dw_MolduleConfiguration [b_ModuleCpt] & 0xFFFF0000UL) == APCI1710_82X54_TIMER)\r
+                   {\r
+                   \r
+                     //printk("TIMER Interrupt Occurred\n");\r
+                     ul_82X54InterruptStatus= inl(devpriv->s_BoardInfos.\r
+                              ui_Address + 12 + (64 * b_ModuleCpt));\r
+\r
+                   /***************************/\r
+                   /* Test if interrupt occur */\r
+                   /***************************/\r
+\r
+                   if ((ul_82X54InterruptStatus & ps_ModuleInfo->\r
+                                                  s_82X54ModuleInfo.\r
+                                                  b_InterruptMask) != 0)\r
+                      {\r
+                      devpriv->\r
+                      s_InterruptParameters.\r
+                      s_FIFOInterruptParameters [devpriv->\r
+                                                 s_InterruptParameters.\r
+                                                 ui_Write].\r
+                      ul_OldInterruptMask = (ul_82X54InterruptStatus & ps_ModuleInfo->\r
+                                                                       s_82X54ModuleInfo.\r
+                                                                       b_InterruptMask) << 4;\r
+\r
+                      devpriv->\r
+                      s_InterruptParameters.\r
+                      s_FIFOInterruptParameters [devpriv->\r
+                                                 s_InterruptParameters.\r
+                                                 ui_Write].\r
+                      b_OldModuleMask = 1 << b_ModuleCpt;\r
+\r
+                      devpriv->\r
+                      s_InterruptParameters.\r
+                      s_FIFOInterruptParameters [devpriv->\r
+                                                 s_InterruptParameters.\r
+                                                 ui_Write].\r
+                      ul_OldCounterLatchValue = 0;\r
+\r
+                      devpriv->\r
+                      s_InterruptParameters.\r
+                      ul_InterruptOccur ++;\r
+\r
+                      /****************************/\r
+                      /* Increment the write FIFO */\r
+                      /****************************/\r
+\r
+                      devpriv->\r
+                      s_InterruptParameters.\r
+                      ui_Write = (devpriv->\r
+                                  s_InterruptParameters.\r
+                                  ui_Write + 1) % APCI1710_SAVE_INTERRUPT;\r
+\r
+                      b_InterruptFlag = 1;\r
+\r
+                      \r
+                           \r
+                            /**********************/\r
+                            /* Call user function */\r
+                            /**********************/\r
+                         //Send a signal to from kernel to user space\r
+                            send_sig(SIGIO,devpriv->tsk_Current,0); \r
+                           \r
+                      } // if ((ul_82X54InterruptStatus & 0x7) != 0)\r
+                   } // 82X54 timer\r
+\r
+\r
+\r
+\r
+\r
+                /***************************/\r
+                /* Test if increm. counter */\r
+                /***************************/\r
+\r
+                if ((devpriv->\r
+                     s_BoardInfos.\r
+                     dw_MolduleConfiguration [b_ModuleCpt] & 0xFFFF0000UL) == APCI1710_INCREMENTAL_COUNTER)\r
+                   {\r
+\r
+                        ul_InterruptLatchReg=inl(devpriv->s_BoardInfos.\r
+                              ui_Address + (64 * b_ModuleCpt));\r
+\r
+                   /*********************/\r
+                   /* Test if interrupt */\r
+                   /*********************/\r
+\r
+                   if ((ul_InterruptLatchReg & 0x22) && (ps_ModuleInfo->\r
+                                                         s_SiemensCounterInfo.\r
+                                                         s_ModeRegister.\r
+                                                         s_ByteModeRegister.\r
+                                                         b_ModeRegister2 & 0x80))\r
+                      {\r
+                      /************************************/\r
+                      /* Test if strobe latch I interrupt */\r
+                      /************************************/\r
+\r
+                      if (ul_InterruptLatchReg & 2)\r
+                         {\r
+                               ul_LatchRegisterValue=inl(devpriv->s_BoardInfos.\r
+                                    ui_Address + 4 + (64 * b_ModuleCpt));\r
+\r
+                         devpriv->\r
+                         s_InterruptParameters.\r
+                         s_FIFOInterruptParameters [devpriv->\r
+                                                    s_InterruptParameters.\r
+                                                    ui_Write].\r
+                         ul_OldInterruptMask = 1UL;\r
+\r
+                         devpriv->\r
+                         s_InterruptParameters.\r
+                         s_FIFOInterruptParameters [devpriv->\r
+                                                    s_InterruptParameters.\r
+                                                    ui_Write].\r
+                         b_OldModuleMask = 1 << b_ModuleCpt;\r
+\r
+                         devpriv->\r
+                         s_InterruptParameters.\r
+                         s_FIFOInterruptParameters [devpriv->\r
+                                                    s_InterruptParameters.\r
+                                                    ui_Write].\r
+                         ul_OldCounterLatchValue = ul_LatchRegisterValue;\r
+\r
+                         devpriv->\r
+                         s_InterruptParameters.\r
+                         ul_InterruptOccur ++;\r
+\r
+                         /****************************/\r
+                         /* 0899/0224 to 1199/0225   */\r
+                         /****************************/\r
+                         /* Increment the write FIFO */\r
+                      /****************************/\r
+\r
+                         devpriv->\r
+                         s_InterruptParameters.\r
+                         ui_Write = (devpriv->\r
+                                     s_InterruptParameters.\r
+                                     ui_Write + 1) % APCI1710_SAVE_INTERRUPT;\r
+\r
+                         b_InterruptFlag = 1;\r
+\r
+                        \r
+                            \r
+                               /**********************/\r
+                               /* Call user function */\r
+                               /**********************/\r
+                        //Send a signal to from kernel to user space\r
+                            send_sig(SIGIO,devpriv->tsk_Current,0); \r
+                               \r
+                        \r
+                         }\r
+\r
+                      /*************************************/\r
+                      /* Test if strobe latch II interrupt */\r
+                      /*************************************/\r
+\r
+                      if (ul_InterruptLatchReg & 0x20)\r
+                         {\r
+                         \r
+                         ul_LatchRegisterValue=inl(devpriv->s_BoardInfos.\r
+                                    ui_Address + 8 + (64 * b_ModuleCpt));\r
+\r
+                         devpriv->\r
+                         s_InterruptParameters.\r
+                         s_FIFOInterruptParameters [devpriv->\r
+                                                    s_InterruptParameters.\r
+                                                    ui_Write].\r
+                         ul_OldInterruptMask = 2UL;\r
+\r
+                         devpriv->\r
+                         s_InterruptParameters.\r
+                         s_FIFOInterruptParameters [devpriv->\r
+                                                    s_InterruptParameters.\r
+                                                    ui_Write].\r
+                         b_OldModuleMask = 1 << b_ModuleCpt;\r
+\r
+                         devpriv->\r
+                         s_InterruptParameters.\r
+                         s_FIFOInterruptParameters [devpriv->\r
+                                                    s_InterruptParameters.\r
+                                                    ui_Write].\r
+                         ul_OldCounterLatchValue = ul_LatchRegisterValue;\r
+\r
+                         devpriv->\r
+                         s_InterruptParameters.\r
+                         ul_InterruptOccur ++;\r
+\r
+                         /****************************/\r
+                         /* 0899/0224 to 1199/0225   */\r
+                         /****************************/\r
+                         /* Increment the write FIFO */\r
+                         /****************************/\r
+\r
+                         devpriv->\r
+                         s_InterruptParameters.\r
+                         ui_Write = (devpriv->\r
+                                     s_InterruptParameters.\r
+                                     ui_Write + 1) % APCI1710_SAVE_INTERRUPT;\r
+\r
+                         b_InterruptFlag = 1;\r
+\r
+                         \r
+                           /**********************/\r
+                               /* Call user function */\r
+                               /**********************/\r
+                        //Send a signal to from kernel to user space\r
+                            send_sig(SIGIO,devpriv->tsk_Current,0); \r
+                               \r
+                                 }\r
+                      }\r
+\r
+                 \r
+                       ul_InterruptLatchReg=inl(devpriv-> s_BoardInfos.\r
+                              ui_Address + 24 + (64 * b_ModuleCpt));\r
+\r
+                   /***************************/\r
+                   /* Test if index interrupt */\r
+                   /***************************/\r
+\r
+                   if (ul_InterruptLatchReg & 0x8)\r
+                      {\r
+                      ps_ModuleInfo->\r
+                      s_SiemensCounterInfo.\r
+                      s_InitFlag.\r
+                      b_IndexInterruptOccur = 1;\r
+\r
+                      if (ps_ModuleInfo->\r
+                          s_SiemensCounterInfo.\r
+                          s_ModeRegister.\r
+                          s_ByteModeRegister.\r
+                          b_ModeRegister2 & APCI1710_INDEX_AUTO_MODE)\r
+                         {\r
+\r
+                       outl(ps_ModuleInfo->\r
+                                     s_SiemensCounterInfo.\r
+                                     s_ModeRegister.\r
+                                     dw_ModeRegister1_2_3_4,devpriv->\r
+                                     s_BoardInfos.\r
+                                     ui_Address + 20 + (64 * b_ModuleCpt));\r
+                         }\r
+\r
+                      /*****************************/\r
+                      /* Test if interrupt enabled */\r
+                      /*****************************/\r
+\r
+                      if ((ps_ModuleInfo->\r
+                           s_SiemensCounterInfo.\r
+                           s_ModeRegister.\r
+                           s_ByteModeRegister.\r
+                           b_ModeRegister3 & APCI1710_ENABLE_INDEX_INT) == APCI1710_ENABLE_INDEX_INT)\r
+                         {\r
+                         devpriv->\r
+                         s_InterruptParameters.\r
+                         s_FIFOInterruptParameters [devpriv->\r
+                                                    s_InterruptParameters.\r
+                                                    ui_Write].\r
+                         ul_OldInterruptMask = 4UL;\r
+\r
+                         devpriv->\r
+                         s_InterruptParameters.\r
+                         s_FIFOInterruptParameters [devpriv->\r
+                                                    s_InterruptParameters.\r
+                                                    ui_Write].\r
+                         b_OldModuleMask = 1 << b_ModuleCpt;\r
+\r
+                         devpriv->\r
+                         s_InterruptParameters.\r
+                         s_FIFOInterruptParameters [devpriv->\r
+                                                    s_InterruptParameters.\r
+                                                    ui_Write].\r
+                         ul_OldCounterLatchValue = ul_LatchRegisterValue;\r
+\r
+                         devpriv->\r
+                         s_InterruptParameters.\r
+                         ul_InterruptOccur ++;\r
+\r
+                         /****************************/\r
+                         /* 0899/0224 to 1199/0225   */\r
+                         /****************************/\r
+                         /* Increment the write FIFO */\r
+                         /****************************/\r
+\r
+                         devpriv->\r
+                         s_InterruptParameters.\r
+                         ui_Write = (devpriv->\r
+                                     s_InterruptParameters.\r
+                                     ui_Write + 1) % APCI1710_SAVE_INTERRUPT;\r
+\r
+                         b_InterruptFlag = 1;\r
+\r
+                         \r
+                           \r
+                               /**********************/\r
+                               /* Call user function */\r
+                               /**********************/\r
+                        //Send a signal to from kernel to user space\r
+                            send_sig(SIGIO,devpriv->tsk_Current,0); \r
+                               \r
+                               }\r
+                      }\r
+\r
+                   /*****************************/\r
+                   /* Test if compare interrupt */\r
+                   /*****************************/\r
+\r
+                   if (ul_InterruptLatchReg & 0x10)\r
+                      {\r
+                      /*****************************/\r
+                      /* Test if interrupt enabled */\r
+                      /*****************************/\r
+\r
+                      if ((ps_ModuleInfo->\r
+                           s_SiemensCounterInfo.\r
+                           s_ModeRegister.\r
+                           s_ByteModeRegister.\r
+                           b_ModeRegister3 & APCI1710_ENABLE_COMPARE_INT) == APCI1710_ENABLE_COMPARE_INT)\r
+                         {\r
+                         devpriv->\r
+                         s_InterruptParameters.\r
+                         s_FIFOInterruptParameters [devpriv->\r
+                                                    s_InterruptParameters.\r
+                                                    ui_Write].\r
+                         ul_OldInterruptMask = 8UL;\r
+\r
+                         devpriv->\r
+                         s_InterruptParameters.\r
+                         s_FIFOInterruptParameters [devpriv->\r
+                                                    s_InterruptParameters.\r
+                                                    ui_Write].\r
+                         b_OldModuleMask = 1 << b_ModuleCpt;\r
+\r
+                         devpriv->\r
+                         s_InterruptParameters.\r
+                         s_FIFOInterruptParameters [devpriv->\r
+                                                    s_InterruptParameters.\r
+                                                    ui_Write].\r
+                         ul_OldCounterLatchValue = ul_LatchRegisterValue;\r
+\r
+                         devpriv->\r
+                         s_InterruptParameters.\r
+                         ul_InterruptOccur ++;\r
+\r
+                         /****************************/\r
+                         /* 0899/0224 to 1199/0225   */\r
+                         /****************************/\r
+                         /* Increment the write FIFO */\r
+                      /****************************/\r
+\r
+                         devpriv->\r
+                         s_InterruptParameters.\r
+                         ui_Write = (devpriv->\r
+                                     s_InterruptParameters.\r
+                                     ui_Write + 1) % APCI1710_SAVE_INTERRUPT;\r
+\r
+                         b_InterruptFlag = 1;\r
+\r
+                         \r
+                           \r
+                               /**********************/\r
+                               /* Call user function */\r
+                               /**********************/\r
+                        //Send a signal to from kernel to user space\r
+                            send_sig(SIGIO,devpriv->tsk_Current,0); \r
+                               \r
+                         \r
+                         }\r
+                      }\r
+\r
+                   /*******************************************/\r
+                   /* Test if frequency measurement interrupt */\r
+                   /*******************************************/\r
+\r
+                   if (ul_InterruptLatchReg & 0x20)\r
+                      {\r
+                      /*******************/\r
+                      /* Read the status */\r
+                      /*******************/\r
+\r
+                         ul_StatusRegister=inl(devpriv->s_BoardInfos.\r
+                                 ui_Address + 32 + (64 * b_ModuleCpt));\r
+\r
+                      /******************/\r
+                      /* Read the value */\r
+                      /******************/\r
+\r
+\r
+                         ul_LatchRegisterValue=inl(devpriv->s_BoardInfos.\r
+                                 ui_Address + 28 + (64 * b_ModuleCpt));\r
+\r
+                      switch ((ul_StatusRegister >> 1) & 3)\r
+                         {\r
+                         case 0:\r
+                              /*************************/\r
+                              /* Test the counter mode */\r
+                              /*************************/\r
+\r
+                              if ((devpriv->\r
+                                   s_ModuleInfo [b_ModuleCpt].\r
+                                   s_SiemensCounterInfo.\r
+                                   s_ModeRegister.\r
+                                   s_ByteModeRegister.\r
+                                   b_ModeRegister1 & APCI1710_16BIT_COUNTER) == APCI1710_16BIT_COUNTER)\r
+                                 {\r
+                                 /****************************************/\r
+                                 /* Test if 16-bit counter 1 pulse occur */\r
+                                 /****************************************/\r
+\r
+                                 if ((ul_LatchRegisterValue & 0xFFFFU) != 0)\r
+                                    {\r
+                                    ui_16BitValue         = (UINT) ul_LatchRegisterValue & 0xFFFFU;\r
+                                    ul_LatchRegisterValue = (ul_LatchRegisterValue & 0xFFFF0000UL) | (0xFFFFU - ui_16BitValue);\r
+                                    }\r
+\r
+                                 /****************************************/\r
+                                 /* Test if 16-bit counter 2 pulse occur */\r
+                                 /****************************************/\r
+\r
+                                 if ((ul_LatchRegisterValue & 0xFFFF0000UL) != 0)\r
+                                    {\r
+                                    ui_16BitValue         = (UINT) ((ul_LatchRegisterValue >> 16) & 0xFFFFU);\r
+                                    ul_LatchRegisterValue = (ul_LatchRegisterValue & 0xFFFFUL) | ((0xFFFFU - ui_16BitValue) << 16);\r
+                                    }\r
+                                 }\r
+                              else\r
+                                 {\r
+                                 if (ul_LatchRegisterValue != 0)\r
+                                    {\r
+                                    ul_LatchRegisterValue = 0xFFFFFFFFUL - ul_LatchRegisterValue;\r
+                                    }\r
+                                 }\r
+                              break;\r
+\r
+                         case 1:\r
+                              /****************************************/\r
+                              /* Test if 16-bit counter 2 pulse occur */\r
+                              /****************************************/\r
+\r
+                              if ((ul_LatchRegisterValue & 0xFFFF0000UL) != 0)\r
+                                 {\r
+                                 ui_16BitValue         = (UINT) ((ul_LatchRegisterValue >> 16) & 0xFFFFU);\r
+                                 ul_LatchRegisterValue = (ul_LatchRegisterValue & 0xFFFFUL) | ((0xFFFFU - ui_16BitValue) << 16);\r
+                                 }\r
+                              break;\r
+\r
+                         case 2:\r
+                              /****************************************/\r
+                              /* Test if 16-bit counter 1 pulse occur */\r
+                              /****************************************/\r
+\r
+                              if ((ul_LatchRegisterValue & 0xFFFFU) != 0)\r
+                                 {\r
+                                 ui_16BitValue         = (UINT) ul_LatchRegisterValue & 0xFFFFU;\r
+                                 ul_LatchRegisterValue = (ul_LatchRegisterValue & 0xFFFF0000UL) | (0xFFFFU - ui_16BitValue);\r
+                                 }\r
+                              break;\r
+                         }\r
+\r
+                      devpriv->\r
+                      s_InterruptParameters.\r
+                      s_FIFOInterruptParameters [devpriv->\r
+                                                 s_InterruptParameters.\r
+                                                 ui_Write].\r
+                      ul_OldInterruptMask = 0x10000UL;\r
+\r
+                      devpriv->\r
+                      s_InterruptParameters.\r
+                      s_FIFOInterruptParameters [devpriv->\r
+                                                 s_InterruptParameters.\r
+                                                 ui_Write].\r
+                      b_OldModuleMask = 1 << b_ModuleCpt;\r
+\r
+                      devpriv->\r
+                      s_InterruptParameters.\r
+                      s_FIFOInterruptParameters [devpriv->\r
+                                                 s_InterruptParameters.\r
+                                                 ui_Write].\r
+                      ul_OldCounterLatchValue = ul_LatchRegisterValue;\r
+\r
+                      devpriv->\r
+                      s_InterruptParameters.\r
+                      ul_InterruptOccur ++;\r
+\r
+                      /****************************/\r
+                      /* 0899/0224 to 1199/0225   */\r
+                      /****************************/\r
+                      /* Increment the write FIFO */\r
+                      /****************************/\r
+\r
+                      devpriv->\r
+                      s_InterruptParameters.\r
+                      ui_Write = (devpriv->\r
+                                  s_InterruptParameters.\r
+                                  ui_Write + 1) % APCI1710_SAVE_INTERRUPT;\r
+\r
+                      b_InterruptFlag = 1;\r
+\r
+                      \r
+                           \r
+                            /**********************/\r
+                            /* Call user function */\r
+                            /**********************/\r
+                        //Send a signal to from kernel to user space\r
+                            send_sig(SIGIO,devpriv->tsk_Current,0); \r
+                           \r
+\r
+                      \r
+                      }\r
+                   } // Incremental counter\r
+\r
+\r
+\r
+\r
+\r
+\r
+                /***************/\r
+                /* Test if CDA */\r
+                /***************/\r
+\r
+                if ((devpriv->\r
+                     s_BoardInfos.\r
+                     dw_MolduleConfiguration [b_ModuleCpt] & 0xFFFF0000UL) == APCI1710_CDA)\r
+                   {\r
+                   /******************************************/\r
+                   /* Test if CDA enable and functionality 0 */\r
+                   /******************************************/\r
+\r
+                   if ((devpriv->\r
+                        s_ModuleInfo [b_ModuleCpt].\r
+                        s_CDAModuleInfo.\r
+                        b_CDAEnable == APCI1710_ENABLE) && (devpriv->\r
+                                                            s_ModuleInfo [b_ModuleCpt].\r
+                                                            s_CDAModuleInfo.\r
+                                                            b_FctSelection == 0))\r
+                      {\r
+                      /****************************/\r
+                      /* Get the interrupt status */\r
+                      /****************************/\r
+\r
+\r
+                       ul_StatusRegister=inl(devpriv->s_BoardInfos.\r
+                                 ui_Address + 16 + (64 * b_ModuleCpt));\r
+                      /***************************/\r
+                      /* Test if interrupt occur */\r
+                      /***************************/\r
+\r
+                      if (ul_StatusRegister & 1)\r
+                         {\r
+                         devpriv->\r
+                         s_InterruptParameters.\r
+                         s_FIFOInterruptParameters [devpriv->\r
+                                                    s_InterruptParameters.\r
+                                                    ui_Write].\r
+                         ul_OldInterruptMask = 0x80000UL;\r
+\r
+                         devpriv->\r
+                         s_InterruptParameters.\r
+                         s_FIFOInterruptParameters [devpriv->\r
+                                                    s_InterruptParameters.\r
+                                                    ui_Write].\r
+                         b_OldModuleMask = 1 << b_ModuleCpt;\r
+\r
+                         devpriv->\r
+                         s_InterruptParameters.\r
+                         s_FIFOInterruptParameters [devpriv->\r
+                                                    s_InterruptParameters.\r
+                                                    ui_Write].\r
+                         ul_OldCounterLatchValue = 0;\r
+\r
+                         devpriv->\r
+                         s_InterruptParameters.\r
+                         ul_InterruptOccur ++;\r
+\r
+                         \r
+                         /****************************/\r
+                         /* Increment the write FIFO */\r
+                         /****************************/\r
+\r
+                         devpriv->\r
+                         s_InterruptParameters.\r
+                         ui_Write = (devpriv->\r
+                                     s_InterruptParameters.\r
+                                     ui_Write + 1) % APCI1710_SAVE_INTERRUPT;\r
+\r
+                         b_InterruptFlag = 1;\r
+\r
+                         \r
+                          \r
+                               /**********************/\r
+                               /* Call user function */\r
+                               /**********************/\r
+\r
+                               //Send a signal to from kernel to user space\r
+                            send_sig(SIGIO,devpriv->tsk_Current,0);            \r
+\r
+                         } // if (ul_StatusRegister & 1)\r
+                     \r
+                        }\r
+                   } // CDA\r
+\r
+\r
+                /***********************/\r
+                /* Test if PWM counter */\r
+                /***********************/\r
+\r
+                if ((devpriv->\r
+                     s_BoardInfos.\r
+                     dw_MolduleConfiguration [b_ModuleCpt] & 0xFFFF0000UL) == APCI1710_PWM)\r
+                   {\r
+                   for (b_PWMCpt = 0; b_PWMCpt < 2; b_PWMCpt ++)\r
+                      {\r
+                      /*************************************/\r
+                      /* Test if PWM interrupt initialised */\r
+                      /*************************************/\r
+\r
+                      if (devpriv->\r
+                          s_ModuleInfo [b_ModuleCpt].\r
+                          s_PWMModuleInfo.\r
+                          s_PWMInfo [b_PWMCpt].\r
+                          b_InterruptEnable == APCI1710_ENABLE)\r
+                         {\r
+                         /*****************************/\r
+                         /* Read the interrupt status */\r
+                         /*****************************/\r
+\r
+                       ul_StatusRegister=inl(devpriv->s_BoardInfos.\r
+                                    ui_Address + 16 + (20 * b_PWMCpt) + (64 * b_ModuleCpt));\r
+\r
+\r
+                         /***************************/\r
+                         /* Test if interrupt occur */\r
+                         /***************************/\r
+\r
+                         if (ul_StatusRegister & 0x1)\r
+                            {\r
+                            devpriv->\r
+                            s_InterruptParameters.\r
+                            s_FIFOInterruptParameters [devpriv->\r
+                                                       s_InterruptParameters.\r
+                                                       ui_Write].\r
+                            ul_OldInterruptMask = 0x4000UL << b_PWMCpt;\r
+\r
+                            devpriv->\r
+                            s_InterruptParameters.\r
+                            s_FIFOInterruptParameters [devpriv->\r
+                                                       s_InterruptParameters.\r
+                                                       ui_Write].\r
+                            b_OldModuleMask = 1 << b_ModuleCpt;\r
+\r
+                            devpriv->\r
+                            s_InterruptParameters.\r
+                            ul_InterruptOccur ++;\r
+\r
+                            /****************************/\r
+                            /* Increment the write FIFO */\r
+                            /****************************/\r
+\r
+                            devpriv->\r
+                            s_InterruptParameters.\r
+                            ui_Write = (devpriv->\r
+                                        s_InterruptParameters.\r
+                                        ui_Write + 1) % APCI1710_SAVE_INTERRUPT;\r
+\r
+                            b_InterruptFlag = 1;\r
+\r
+                            \r
+                                  /**********************/\r
+                                  /* Call user function */\r
+                                  /**********************/\r
+                               //Send a signal to from kernel to user space\r
+                            send_sig(SIGIO,devpriv->tsk_Current,0); \r
+\r
+                            \r
+                            } // if (ul_StatusRegister & 0x1)\r
+                         } // if (APCI1710_ENABLE)\r
+                      } // for (b_PWMCpt == 0; b_PWMCpt < 0; b_PWMCpt ++)\r
+                   } // PWM counter\r
+\r
+\r
+\r
+                /***********************/\r
+                /* Test if tor counter */\r
+                /***********************/\r
+\r
+                if ((devpriv->\r
+                     s_BoardInfos.\r
+                     dw_MolduleConfiguration [b_ModuleCpt] & 0xFFFF0000UL) == APCI1710_TOR_COUNTER)\r
+                   {\r
+                   for (b_TorCounterCpt = 0; b_TorCounterCpt < 2; b_TorCounterCpt ++)\r
+                      {\r
+                      /*************************************/\r
+                      /* Test if tor interrupt initialised */\r
+                      /*************************************/\r
+\r
+                      if (devpriv->\r
+                          s_ModuleInfo [b_ModuleCpt].\r
+                          s_TorCounterModuleInfo.\r
+                          s_TorCounterInfo [b_TorCounterCpt].\r
+                          b_InterruptEnable == APCI1710_ENABLE)\r
+                         {\r
+                         /*****************************/\r
+                         /* Read the interrupt status */\r
+                         /*****************************/\r
+\r
+                       \r
+                               ul_StatusRegister=inl(devpriv->s_BoardInfos.\r
+                                    ui_Address + 12 + (16 * b_TorCounterCpt) + (64 * b_ModuleCpt));\r
+\r
+                         /***************************/\r
+                         /* Test if interrupt occur */\r
+                         /***************************/\r
+\r
+                         if (ul_StatusRegister & 0x1)\r
+                            {\r
+                            /******************************/\r
+                            /* Read the tor counter value */\r
+                            /******************************/\r
+\r
+                            \r
+                          ul_LatchRegisterValue=inl(devpriv->s_BoardInfos.\r
+                                       ui_Address + 0 + (16 * b_TorCounterCpt) + (64 * b_ModuleCpt));\r
+\r
+                            devpriv->\r
+                            s_InterruptParameters.\r
+                            s_FIFOInterruptParameters [devpriv->\r
+                                                       s_InterruptParameters.\r
+                                                       ui_Write].\r
+                            ul_OldInterruptMask = 0x1000UL << b_TorCounterCpt;\r
+\r
+                            devpriv->\r
+                            s_InterruptParameters.\r
+                            s_FIFOInterruptParameters [devpriv->\r
+                                                       s_InterruptParameters.\r
+                                                       ui_Write].\r
+                            b_OldModuleMask = 1 << b_ModuleCpt;\r
+\r
+                            devpriv->\r
+                            s_InterruptParameters.\r
+                            s_FIFOInterruptParameters [devpriv->\r
+                                                       s_InterruptParameters.\r
+                                                       ui_Write].\r
+                            ul_OldCounterLatchValue = ul_LatchRegisterValue;\r
+\r
+                            devpriv->\r
+                            s_InterruptParameters.\r
+                            ul_InterruptOccur ++;\r
+\r
+                            \r
+                            /****************************/\r
+                            /* Increment the write FIFO */\r
+                            /****************************/\r
+\r
+                            devpriv->\r
+                            s_InterruptParameters.\r
+                            ui_Write = (devpriv->\r
+                                        s_InterruptParameters.\r
+                                        ui_Write + 1) % APCI1710_SAVE_INTERRUPT;\r
+\r
+                            b_InterruptFlag = 1;\r
+\r
+       \r
+                                  /**********************/\r
+                                  /* Call user function */\r
+                                  /**********************/\r
+\r
+                            //Send a signal to from kernel to user space\r
+                            send_sig(SIGIO,devpriv->tsk_Current,0); \r
+                            } // if (ul_StatusRegister & 0x1)\r
+                         } // if (APCI1710_ENABLE)\r
+                      } // for (b_TorCounterCpt == 0; b_TorCounterCpt < 0; b_TorCounterCpt ++)\r
+                   } // Tor counter\r
+\r
+\r
+\r
+\r
+                /***********************/\r
+                /* Test if chronometer */\r
+                /***********************/\r
+\r
+                if ((devpriv->\r
+                     s_BoardInfos.\r
+                     dw_MolduleConfiguration [b_ModuleCpt] & 0xFFFF0000UL) == APCI1710_CHRONOMETER)\r
+                   {\r
+                    \r
+                       //printk("APCI1710 Chrono Interrupt\n");\r
+                   /*****************************/\r
+                   /* Read the interrupt status */\r
+                   /*****************************/\r
+\r
+                   \r
+                     ul_InterruptLatchReg=inl(devpriv->s_BoardInfos.\r
+                              ui_Address + 12 + (64 * b_ModuleCpt));\r
+\r
+                   /***************************/\r
+                   /* Test if interrupt occur */\r
+                   /***************************/\r
+\r
+                   if ((ul_InterruptLatchReg & 0x8) == 0x8)\r
+                      {\r
+                      /****************************/\r
+                      /* Clear the interrupt flag */\r
+                      /****************************/\r
+\r
+                     \r
+                               outl(0,devpriv->s_BoardInfos.\r
+                                  ui_Address + 32 + (64 * b_ModuleCpt));\r
+\r
+                      /***************************/\r
+                      /* Test if continuous mode */\r
+                      /***************************/\r
+\r
+                      if (ps_ModuleInfo->\r
+                          s_ChronoModuleInfo.\r
+                          b_CycleMode == APCI1710_ENABLE)\r
+                         {\r
+                         /********************/\r
+                         /* Clear the status */\r
+                         /********************/\r
+\r
+                         \r
+                       outl(0,devpriv->s_BoardInfos.\r
+                                     ui_Address + 36 + (64 * b_ModuleCpt));\r
+                         }\r
+\r
+                      /*************************/\r
+                      /* Read the timing value */\r
+                      /*************************/\r
+\r
+                      \r
+                               ul_LatchRegisterValue=inl(devpriv->s_BoardInfos.\r
+                                 ui_Address + 4 + (64 * b_ModuleCpt));\r
+\r
+                      /*****************************/\r
+                      /* Test if interrupt enabled */\r
+                      /*****************************/\r
+\r
+                      if (ps_ModuleInfo->\r
+                          s_ChronoModuleInfo.\r
+                          b_InterruptMask)\r
+                         {\r
+                         devpriv->\r
+                         s_InterruptParameters.\r
+                         s_FIFOInterruptParameters [devpriv->\r
+                                                    s_InterruptParameters.\r
+                                                    ui_Write].\r
+                         ul_OldInterruptMask = 0x80;\r
+\r
+                         devpriv->\r
+                         s_InterruptParameters.\r
+                         s_FIFOInterruptParameters [devpriv->\r
+                                                    s_InterruptParameters.\r
+                                                    ui_Write].\r
+                         b_OldModuleMask = 1 << b_ModuleCpt;\r
+\r
+                         devpriv->\r
+                         s_InterruptParameters.\r
+                         s_FIFOInterruptParameters [devpriv->\r
+                                                    s_InterruptParameters.\r
+                                                    ui_Write].\r
+                         ul_OldCounterLatchValue = ul_LatchRegisterValue;\r
+\r
+                         devpriv->\r
+                         s_InterruptParameters.\r
+                         ul_InterruptOccur ++;\r
+\r
+                         /****************************/\r
+                         /* Increment the write FIFO */\r
+                      /****************************/\r
+\r
+                         devpriv->\r
+                         s_InterruptParameters.\r
+                         ui_Write = (devpriv->\r
+                                     s_InterruptParameters.\r
+                                     ui_Write + 1) % APCI1710_SAVE_INTERRUPT;\r
+\r
+                         b_InterruptFlag = 1;\r
+\r
+                         \r
+                           \r
+                               /**********************/\r
+                               /* Call user function */\r
+                               /**********************/\r
+                               //Send a signal to from kernel to user space\r
+                            send_sig(SIGIO,devpriv->tsk_Current,0); \r
+                               \r
+                         }\r
+                  }\r
+                } // Chronometer\r
+\r
+\r
+\r
+                /*************************/\r
+                /* Test if pulse encoder */\r
+                /*************************/\r
+\r
+                if ((devpriv->\r
+                     s_BoardInfos.\r
+                     dw_MolduleConfiguration [b_ModuleCpt] & 0xFFFF0000UL) == APCI1710_PULSE_ENCODER)\r
+                   {\r
+                   /****************************/\r
+                   /* Read the status register */\r
+                   /****************************/\r
+\r
+                   \r
+                       ul_StatusRegister=inl(devpriv->s_BoardInfos.\r
+                              ui_Address + 20 + (64 * b_ModuleCpt));\r
+\r
+                   if (ul_StatusRegister & 0xF)\r
+                      {\r
+                      for (b_PulseIncoderCpt = 0; b_PulseIncoderCpt < 4; b_PulseIncoderCpt ++)\r
+                         {\r
+                         /*************************************/\r
+                         /* Test if pulse encoder initialised */\r
+                         /*************************************/\r
+\r
+                         if ((ps_ModuleInfo->\r
+                              s_PulseEncoderModuleInfo.\r
+                              s_PulseEncoderInfo [b_PulseIncoderCpt].\r
+                              b_PulseEncoderInit == 1) &&\r
+                             (((ps_ModuleInfo->\r
+                                s_PulseEncoderModuleInfo.\r
+                                dw_SetRegister >> b_PulseIncoderCpt) & 1) == 1) &&\r
+                             (((ul_StatusRegister >> (b_PulseIncoderCpt)) & 1) == 1))\r
+                            {\r
+                            devpriv->\r
+                            s_InterruptParameters.\r
+                            s_FIFOInterruptParameters [devpriv->\r
+                                                       s_InterruptParameters.\r
+                                                       ui_Write].\r
+                            ul_OldInterruptMask = 0x100UL << b_PulseIncoderCpt;\r
+\r
+                            devpriv->\r
+                            s_InterruptParameters.\r
+                            s_FIFOInterruptParameters [devpriv->\r
+                                                       s_InterruptParameters.\r
+                                                       ui_Write].\r
+                            b_OldModuleMask = 1 << b_ModuleCpt;\r
+\r
+                            devpriv->\r
+                            s_InterruptParameters.\r
+                            s_FIFOInterruptParameters [devpriv->\r
+                                                       s_InterruptParameters.\r
+                                                       ui_Write].\r
+                            ul_OldCounterLatchValue = ul_LatchRegisterValue;\r
+\r
+                            devpriv->\r
+                            s_InterruptParameters.\r
+                            ul_InterruptOccur ++;\r
+\r
+                            /****************************/\r
+                            /* 0899/0224 to 1199/0225   */\r
+                            /****************************/\r
+                            /* Increment the write FIFO */\r
+                            /****************************/\r
+\r
+                           devpriv->\r
+                            s_InterruptParameters.\r
+                            ui_Write = (devpriv->\r
+                                        s_InterruptParameters.\r
+                                        ui_Write + 1) % APCI1710_SAVE_INTERRUPT;\r
+\r
+                            b_InterruptFlag = 1;\r
+                           \r
+                                  /**********************/\r
+                                  /* Call user function */\r
+                                  /**********************/\r
+                            //Send a signal to from kernel to user space\r
+                            send_sig(SIGIO,devpriv->tsk_Current,0); \r
+                                  \r
+                \r
+                            }\r
+                               }\r
+                      }\r
+                   }//pulse encoder\r
+\r
+          }\r
+  return ; \r
+\r
+}\r
+\r
index 9d0777c413e7cbefa3c3c7f7de0f8193f2d45535..6d2f9409b8edb7e12f4806873a4b2fa1f72ca627 100644 (file)
@@ -1,15 +1,37 @@
+/**\r
+@verbatim\r
 \r
-
-
-
+Copyright (C) 2004,2005  ADDI-DATA GmbH for the source code of this module. \r
+        \r
+        ADDI-DATA GmbH \r
+        Dieselstrasse 3 \r
+        D-77833 Ottersweier \r
+        Tel: +19(0)7223/9493-0 \r
+        Fax: +49(0)7223/9493-92 \r
+        http://www.addi-data-com \r
+        info@addi-data.com \r
 \r
-#define COMEDI_SUBD_TTLIO                              11  /* Digital Input Output But TTL */
-#define COMEDI_SUBD_PWM                                        12  /* Pulse width Measurement */
-#define COMEDI_SUBD_SSI                                        13  /* Synchronous serial interface */
-#define COMEDI_SUBD_TOR                                        14  /* Tor counter */
-#define COMEDI_SUBD_CHRONO              15  /* Chrono meter*/
-#define COMEDI_SUBD_PULSEENCODER        16  /* Pulse Encoder INP CPT*/
-#define COMEDI_SUBD_INCREMENTALCOUNTER  17  /* Incremental Counter */
+This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.\r
+\r
+This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.\r
+\r
+You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+\r
+You shoud also find the complete GPL in the COPYING file accompanying this source code.\r
+\r
+@endverbatim\r
+*/\r
+\r
+\r
+\r
+\r
+#define COMEDI_SUBD_TTLIO                              11  /* Digital Input Output But TTL */\r
+#define COMEDI_SUBD_PWM                                        12  /* Pulse width Measurement */\r
+#define COMEDI_SUBD_SSI                                        13  /* Synchronous serial interface */\r
+#define COMEDI_SUBD_TOR                                        14  /* Tor counter */\r
+#define COMEDI_SUBD_CHRONO              15  /* Chrono meter*/\r
+#define COMEDI_SUBD_PULSEENCODER        16  /* Pulse Encoder INP CPT*/\r
+#define COMEDI_SUBD_INCREMENTALCOUNTER  17  /* Incremental Counter */\r
 \r
 \r
    #define INT           int\r
 \r
 \r
 //MODULE INFO STRUCTURE\r
-
-\rcomedi_lrange range_apci1710_ttl={ 4, {
-               BIP_RANGE(10),
-               BIP_RANGE(5),
-               BIP_RANGE(2),
-               BIP_RANGE(1)            
-       }
-};
-\r
-\r
-\rcomedi_lrange range_apci1710_ssi={ 4, {
-               BIP_RANGE(10),
-               BIP_RANGE(5),
-               BIP_RANGE(2),
-               BIP_RANGE(1)            
-       }
-};
-
-comedi_lrange range_apci1710_inccpt={ 4, {
-               BIP_RANGE(10),
-               BIP_RANGE(5),
-               BIP_RANGE(2),
-               BIP_RANGE(1)            
-       }
-};
+\r
+\r
+comedi_lrange range_apci1710_ttl={ 4, {\r
+               BIP_RANGE(10),\r
+               BIP_RANGE(5),\r
+               BIP_RANGE(2),\r
+               BIP_RANGE(1)            \r
+       }\r
+};\r
+\r
+\r
+\r
+comedi_lrange range_apci1710_ssi={ 4, {\r
+               BIP_RANGE(10),\r
+               BIP_RANGE(5),\r
+               BIP_RANGE(2),\r
+               BIP_RANGE(1)            \r
+       }\r
+};\r
+\r
+comedi_lrange range_apci1710_inccpt={ 4, {\r
+               BIP_RANGE(10),\r
+               BIP_RANGE(5),\r
+               BIP_RANGE(2),\r
+               BIP_RANGE(1)            \r
+       }\r
+};\r
index 8d08c4f4ced79db5008c3ffca0b43d1d4eeebb69..d6985372fe48b0d1bf9fcce697a0102b9750d885 100644 (file)
@@ -1,14 +1,38 @@
+/**\r
+@verbatim\r
+\r
+Copyright (C) 2004,2005  ADDI-DATA GmbH for the source code of this module. \r
+        \r
+        ADDI-DATA GmbH \r
+        Dieselstrasse 3 \r
+        D-77833 Ottersweier \r
+        Tel: +19(0)7223/9493-0 \r
+        Fax: +49(0)7223/9493-92 \r
+        http://www.addi-data-com \r
+        info@addi-data.com \r
+\r
+This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.\r
+\r
+This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.\r
+\r
+You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+\r
+You shoud also find the complete GPL in the COPYING file accompanying this source code.\r
+\r
+@endverbatim\r
+*/\r
 /*\r
+    \r
   +-----------------------------------------------------------------------+\r
   | (C) ADDI-DATA GmbH          Dieselstraße 3       D-77833 Ottersweier  |\r
   +-----------------------------------------------------------------------+\r
   | Tel : +49 (0) 7223/9493-0     | email    : info@addi-data.com         |\r
   | Fax : +49 (0) 7223/9493-92    | Internet : http://www.addi-data.com   |\r
   +-------------------------------+---------------------------------------+\r
-  | Project     : 13Card Linux Driver | Compiler   : GCC                  |\r
-  | Module name : hwdrv_apci035.c|     Version    : 2.96                  |\r
+  | Project     : APCI-035        | Compiler   : GCC                      |\r
+  | Module name : hwdrv_apci035.c | Version    : 2.96                     |\r
   +-------------------------------+---------------------------------------+\r
-  | Author : Shitalkumar S Chavan |     Date       : 10.12.2001           |\r
+  | Project manager: Eric Stolz   | Date       :  02/12/2002              |\r
   +-------------------------------+---------------------------------------+\r
   | Description :   Hardware Layer Acces For APCI-035                     |\r
   +-----------------------------------------------------------------------+\r
 +----------------------------------------------------------------------------+\r
 */\r
 #include "hwdrv_apci035.h"\r
-INT i_WatchdogNbr=0;
-INT i_Temp=0;
-INT i_Flag=1;
-/*
-+----------------------------------------------------------------------------+
-| Function   Name   : int i_APCI035_ConfigTimerWatchdog                      |
-|                        (comedi_device *dev,comedi_subdevice *s,               | 
-|                      comedi_insn *insn,lsampl_t *data)                     |
-+----------------------------------------------------------------------------+
-| Task              : Configures The Timer , Counter or Watchdog             |
-+----------------------------------------------------------------------------+
-| Input Parameters  : comedi_device *dev : Driver handle                     |
-|                     UINT *data         : Data Pointer contains             |
-|                                          configuration parameters as below |
-|                                                                            | 
-|                                        data[0]            : 0 Configure As Timer      |      
-|                                                                                 1 Configure As Watchdog   | 
-                              data[1]            : Watchdog number                                         
-|                                        data[2]            : Time base Unit            |
-|                                        data[3]                        : Reload Value                      | 
-                              data[4]            : External Trigger          |
-                                                   1:Enable
-                                                   0:Disable                  
-                              data[5]            :External Trigger Level
-                                                  00 Trigger Disabled
-                                                  01 Trigger Enabled (Low level)
-                                                  10 Trigger Enabled (High Level)
-                                                  11 Trigger Enabled (High/Low level)   
-                              data[6]            : External Gate            |
-                                                   1:Enable
-                                                   0:Disable        
-                              data[7]            : External Gate level
-                                                  00 Gate Disabled
-                                                  01 Gate Enabled (Low level)
-                                                  10 Gate Enabled (High Level)
-                              data[8]            :Warning Relay
-                                                  1: ENABLE
-                                                  0: DISABLE  
-                              data[9]            :Warning Delay available
-                              data[10]           :Warning Relay Time unit
-                              data[11]           :Warning Relay Time Reload value
-                              data[12]           :Reset Relay
-                                                  1 : ENABLE
-                                                  0 : DISABLE  
-                              data[13]           :Interrupt
-                                                  1 : ENABLE
-                                                  0 : DISABLE  
-
-|                                      
-+----------------------------------------------------------------------------+
-| Output Parameters :  --                                                                                                       |
-+----------------------------------------------------------------------------+
-| Return Value      : TRUE  : No error occur                                 |
-|                          : FALSE : Error occur. Return the error          |
-|                                                                               |
-+----------------------------------------------------------------------------+
-*/
-INT i_APCI035_ConfigTimerWatchdog(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data)
-{
-UINT ui_Status=0;
-UINT ui_Command=0;
-UINT ui_Mode=0;
-i_Temp=0;
-devpriv->tsk_Current=current;
-devpriv->b_TimerSelectMode=data[0];
-i_WatchdogNbr=data[1];
-if(data[0]==0)
-   {
-   ui_Mode=2;
-   }
-else
-   {
-   ui_Mode=0;
-   }  
-//ui_Command = inl(devpriv->iobase+((i_WatchdogNbr-1)*32)+12);
-ui_Command=0;
-//ui_Command = ui_Command & 0xFFFFF9FEUL;
-outl(ui_Command,devpriv->iobase+((i_WatchdogNbr-1)*32)+12);
-ui_Command=0;
-ui_Command = inl(devpriv->iobase+((i_WatchdogNbr-1)*32)+12);
-/************************/
-/* Set the reload value */
-/************************/
-outl( data[3],devpriv->iobase+((i_WatchdogNbr-1)*32) + 4);
-/*********************/
-/* Set the time unit */
-/*********************/ 
-outl(data[2],devpriv->iobase+((i_WatchdogNbr-1)*32) + 8);
-if (data[0] == ADDIDATA_TIMER)
-   {
-                 
-
-                 /******************************/
-                 /* Set the mode :             */
-                 /* - Disable the hardware     */
-                 /* - Disable the counter mode */
-                 /* - Disable the warning      */
-                 /* - Disable the reset        */
-                 /* - Enable the timer mode    */
-                 /* - Set the timer mode       */
-                 /******************************/
-                
-
-    ui_Command = (ui_Command & 0xFFF719E2UL) | ui_Mode << 13UL | 0x10UL;
-
+INT i_WatchdogNbr=0;\r
+INT i_Temp=0;\r
+INT i_Flag=1;\r
+/*\r
++----------------------------------------------------------------------------+\r
+| Function   Name   : int i_APCI035_ConfigTimerWatchdog                      |\r
+|                        (comedi_device *dev,comedi_subdevice *s,               | \r
+|                      comedi_insn *insn,lsampl_t *data)                     |\r
++----------------------------------------------------------------------------+\r
+| Task              : Configures The Timer , Counter or Watchdog             |\r
++----------------------------------------------------------------------------+\r
+| Input Parameters  : comedi_device *dev : Driver handle                     |\r
+|                     UINT *data         : Data Pointer contains             |\r
+|                                          configuration parameters as below |\r
+|                                                                            | \r
+|                                        data[0]            : 0 Configure As Timer      |      \r
+|                                                                                 1 Configure As Watchdog   | \r
+                              data[1]            : Watchdog number                                         \r
+|                                        data[2]            : Time base Unit            |\r
+|                                        data[3]                        : Reload Value                      | \r
+                              data[4]            : External Trigger          |\r
+                                                   1:Enable\r
+                                                   0:Disable                  \r
+                              data[5]            :External Trigger Level\r
+                                                  00 Trigger Disabled\r
+                                                  01 Trigger Enabled (Low level)\r
+                                                  10 Trigger Enabled (High Level)\r
+                                                  11 Trigger Enabled (High/Low level)   \r
+                              data[6]            : External Gate            |\r
+                                                   1:Enable\r
+                                                   0:Disable        \r
+                              data[7]            : External Gate level\r
+                                                  00 Gate Disabled\r
+                                                  01 Gate Enabled (Low level)\r
+                                                  10 Gate Enabled (High Level)\r
+                              data[8]            :Warning Relay\r
+                                                  1: ENABLE\r
+                                                  0: DISABLE  \r
+                              data[9]            :Warning Delay available\r
+                              data[10]           :Warning Relay Time unit\r
+                              data[11]           :Warning Relay Time Reload value\r
+                              data[12]           :Reset Relay\r
+                                                  1 : ENABLE\r
+                                                  0 : DISABLE  \r
+                              data[13]           :Interrupt\r
+                                                  1 : ENABLE\r
+                                                  0 : DISABLE  \r
+\r
+|                                      \r
++----------------------------------------------------------------------------+\r
+| Output Parameters :  --                                                                                                       |\r
++----------------------------------------------------------------------------+\r
+| Return Value      : TRUE  : No error occur                                 |\r
+|                          : FALSE : Error occur. Return the error          |\r
+|                                                                               |\r
++----------------------------------------------------------------------------+\r
+*/\r
+INT i_APCI035_ConfigTimerWatchdog(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data)\r
+{\r
+UINT ui_Status=0;\r
+UINT ui_Command=0;\r
+UINT ui_Mode=0;\r
+i_Temp=0;\r
+devpriv->tsk_Current=current;\r
+devpriv->b_TimerSelectMode=data[0];\r
+i_WatchdogNbr=data[1];\r
+if(data[0]==0)\r
+   {\r
+   ui_Mode=2;\r
+   }\r
+else\r
+   {\r
+   ui_Mode=0;\r
+   }  \r
+//ui_Command = inl(devpriv->iobase+((i_WatchdogNbr-1)*32)+12);\r
+ui_Command=0;\r
+//ui_Command = ui_Command & 0xFFFFF9FEUL;\r
+outl(ui_Command,devpriv->iobase+((i_WatchdogNbr-1)*32)+12);\r
+ui_Command=0;\r
+ui_Command = inl(devpriv->iobase+((i_WatchdogNbr-1)*32)+12);\r
+/************************/\r
+/* Set the reload value */\r
+/************************/\r
+outl( data[3],devpriv->iobase+((i_WatchdogNbr-1)*32) + 4);\r
+/*********************/\r
+/* Set the time unit */\r
+/*********************/ \r
+outl(data[2],devpriv->iobase+((i_WatchdogNbr-1)*32) + 8);\r
+if (data[0] == ADDIDATA_TIMER)\r
+   {\r
+                 \r
+\r
+                 /******************************/\r
+                 /* Set the mode :             */\r
+                 /* - Disable the hardware     */\r
+                 /* - Disable the counter mode */\r
+                 /* - Disable the warning      */\r
+                 /* - Disable the reset        */\r
+                 /* - Enable the timer mode    */\r
+                 /* - Set the timer mode       */\r
+                 /******************************/\r
+                \r
+\r
+    ui_Command = (ui_Command & 0xFFF719E2UL) | ui_Mode << 13UL | 0x10UL;\r
+\r
    }//if (data[0] == ADDIDATA_TIMER)\r
- else
-   {
-      if(data[0]==ADDIDATA_WATCHDOG)
-         {           
-
-                 /******************************/
-                 /* Set the mode :             */
-                 /* - Disable the hardware     */
-                 /* - Disable the counter mode */
-                 /* - Disable the warning      */
-                 /* - Disable the reset        */
-                 /* - Disable the timer mode   */
-                 /******************************/
-                 
-
-            ui_Command = ui_Command & 0xFFF819E2UL;
-
-         } 
-      else 
-         {
-         printk("\n The parameter for Timer/watchdog selection is in error\n");
-         return -EINVAL;
-         }
-    }
-outl(ui_Command,devpriv->iobase+((i_WatchdogNbr-1)*32)+12);
-ui_Command=0;
-ui_Command = inl(devpriv->iobase+((i_WatchdogNbr-1)*32)+12);
-/********************************/
-/* Disable the hardware trigger */
-/********************************/
-ui_Command = ui_Command & 0xFFFFF89FUL;  
- if (data[4] == ADDIDATA_ENABLE)
-    {
-    /**********************************/
-    /* Set the hardware trigger level */
-    /**********************************/          
-     ui_Command = ui_Command |  ( data[5] << 5);
-    }           
-outl(ui_Command,devpriv->iobase+((i_WatchdogNbr-1)*32)+12);
-ui_Command=0;
-ui_Command = inl(devpriv->iobase+((i_WatchdogNbr-1)*32)+12); 
-/*****************************/
-/* Disable the hardware gate */
-/*****************************/   
-ui_Command = ui_Command & 0xFFFFF87FUL; 
-if (data[6] == ADDIDATA_ENABLE)
-   {
-/*******************************/
-/* Set the hardware gate level */
-/*******************************/             
-   ui_Command = ui_Command |( data[7] << 7);
-   }
-outl(ui_Command,devpriv->iobase+((i_WatchdogNbr-1)*32)+12);           
-ui_Command=0;
-ui_Command = inl(devpriv->iobase+((i_WatchdogNbr-1)*32)+12);             
-/*******************************/
-/* Disable the hardware output */
-/*******************************/
-ui_Command = ui_Command & 0xFFFFF9FBUL;           
-/*********************************/
-/* Set the hardware output level */
-/*********************************/
-ui_Command = ui_Command |( data[8] << 2);          
-outl(ui_Command,devpriv->iobase+((i_WatchdogNbr-1)*32)+12); 
-if(data[9]==ADDIDATA_ENABLE)  
-   { 
-   /************************/
-   /* Set the reload value */
-   /************************/         
-   outl (data[11],devpriv->iobase+((i_WatchdogNbr-1)*32) + 24);
-   /**********************/
-   /* Set the time unite */
-   /**********************/ 
-   outl(data[10],devpriv->iobase+((i_WatchdogNbr-1)*32)+ 28);
-   }
-
-    ui_Command=0;
-    ui_Command = inl(devpriv->iobase+((i_WatchdogNbr-1)*32)+12);              
- /*******************************/
- /* Disable the hardware output */
- /*******************************/         
-   ui_Command = ui_Command & 0xFFFFF9F7UL;          
-   /*********************************/
-   /* Set the hardware output level */
-   /*********************************/
- ui_Command = ui_Command |( data[12] << 3);           
- outl(ui_Command,devpriv->iobase+((i_WatchdogNbr-1)*32)+12); 
- /*************************************/
- /**  Enable the watchdog interrupt  **/
- /*************************************/ 
-ui_Command=0;
-ui_Command = inl(devpriv->iobase+((i_WatchdogNbr-1)*32)+12);  
-/*******************************/
-/* Set the interrupt selection */
-/*******************************/
-ui_Status =inl(devpriv->iobase+((i_WatchdogNbr-1)*32) + 16);
-
-ui_Command = (ui_Command & 0xFFFFF9FDUL) |  ( data[13] << 1);
-outl(ui_Command,devpriv->iobase+((i_WatchdogNbr-1)*32)+12); 
-
-return insn->n;
-}
-
+ else\r
+   {\r
+      if(data[0]==ADDIDATA_WATCHDOG)\r
+         {           \r
+\r
+                 /******************************/\r
+                 /* Set the mode :             */\r
+                 /* - Disable the hardware     */\r
+                 /* - Disable the counter mode */\r
+                 /* - Disable the warning      */\r
+                 /* - Disable the reset        */\r
+                 /* - Disable the timer mode   */\r
+                 /******************************/\r
+                 \r
+\r
+            ui_Command = ui_Command & 0xFFF819E2UL;\r
+\r
+         } \r
+      else \r
+         {\r
+         printk("\n The parameter for Timer/watchdog selection is in error\n");\r
+         return -EINVAL;\r
+         }\r
+    }\r
+outl(ui_Command,devpriv->iobase+((i_WatchdogNbr-1)*32)+12);\r
+ui_Command=0;\r
+ui_Command = inl(devpriv->iobase+((i_WatchdogNbr-1)*32)+12);\r
+/********************************/\r
+/* Disable the hardware trigger */\r
+/********************************/\r
+ui_Command = ui_Command & 0xFFFFF89FUL;  \r
+ if (data[4] == ADDIDATA_ENABLE)\r
+    {\r
+    /**********************************/\r
+    /* Set the hardware trigger level */\r
+    /**********************************/          \r
+     ui_Command = ui_Command |  ( data[5] << 5);\r
+    }           \r
+outl(ui_Command,devpriv->iobase+((i_WatchdogNbr-1)*32)+12);\r
+ui_Command=0;\r
+ui_Command = inl(devpriv->iobase+((i_WatchdogNbr-1)*32)+12); \r
+/*****************************/\r
+/* Disable the hardware gate */\r
+/*****************************/   \r
+ui_Command = ui_Command & 0xFFFFF87FUL; \r
+if (data[6] == ADDIDATA_ENABLE)\r
+   {\r
+/*******************************/\r
+/* Set the hardware gate level */\r
+/*******************************/             \r
+   ui_Command = ui_Command |( data[7] << 7);\r
+   }\r
+outl(ui_Command,devpriv->iobase+((i_WatchdogNbr-1)*32)+12);           \r
+ui_Command=0;\r
+ui_Command = inl(devpriv->iobase+((i_WatchdogNbr-1)*32)+12);             \r
+/*******************************/\r
+/* Disable the hardware output */\r
+/*******************************/\r
+ui_Command = ui_Command & 0xFFFFF9FBUL;           \r
+/*********************************/\r
+/* Set the hardware output level */\r
+/*********************************/\r
+ui_Command = ui_Command |( data[8] << 2);          \r
+outl(ui_Command,devpriv->iobase+((i_WatchdogNbr-1)*32)+12); \r
+if(data[9]==ADDIDATA_ENABLE)  \r
+   { \r
+   /************************/\r
+   /* Set the reload value */\r
+   /************************/         \r
+   outl (data[11],devpriv->iobase+((i_WatchdogNbr-1)*32) + 24);\r
+   /**********************/\r
+   /* Set the time unite */\r
+   /**********************/ \r
+   outl(data[10],devpriv->iobase+((i_WatchdogNbr-1)*32)+ 28);\r
+   }\r
+\r
+    ui_Command=0;\r
+    ui_Command = inl(devpriv->iobase+((i_WatchdogNbr-1)*32)+12);              \r
+ /*******************************/\r
+ /* Disable the hardware output */\r
+ /*******************************/         \r
+   ui_Command = ui_Command & 0xFFFFF9F7UL;          \r
+   /*********************************/\r
+   /* Set the hardware output level */\r
+   /*********************************/\r
+ ui_Command = ui_Command |( data[12] << 3);           \r
+ outl(ui_Command,devpriv->iobase+((i_WatchdogNbr-1)*32)+12); \r
+ /*************************************/\r
+ /**  Enable the watchdog interrupt  **/\r
+ /*************************************/ \r
+ui_Command=0;\r
+ui_Command = inl(devpriv->iobase+((i_WatchdogNbr-1)*32)+12);  \r
+/*******************************/\r
+/* Set the interrupt selection */\r
+/*******************************/\r
+ui_Status =inl(devpriv->iobase+((i_WatchdogNbr-1)*32) + 16);\r
+\r
+ui_Command = (ui_Command & 0xFFFFF9FDUL) |  ( data[13] << 1);\r
+outl(ui_Command,devpriv->iobase+((i_WatchdogNbr-1)*32)+12); \r
+\r
+return insn->n;\r
+}\r
+\r
 \r
 /*\r
 +----------------------------------------------------------------------------+\r
@@ -268,85 +292,87 @@ return insn->n;
 INT i_APCI035_StartStopWriteTimerWatchdog(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data)\r
 {\r
    UINT  ui_Command = 0; \r
-   INT i_Count=0;
+   INT i_Count=0;\r
       if  (data[0]==1) \r
          { \r
-         ui_Command = inl(devpriv->iobase+((i_WatchdogNbr-1)*32)+12);
-         /**********************/
-         /* Start the hardware */
-         /**********************/
-         ui_Command = (ui_Command & 0xFFFFF9FFUL) | 0x1UL;
-         outl(ui_Command,devpriv->iobase+((i_WatchdogNbr-1)*32)+12); 
+         ui_Command = inl(devpriv->iobase+((i_WatchdogNbr-1)*32)+12);\r
+         /**********************/\r
+         /* Start the hardware */\r
+         /**********************/\r
+         ui_Command = (ui_Command & 0xFFFFF9FFUL) | 0x1UL;\r
+         outl(ui_Command,devpriv->iobase+((i_WatchdogNbr-1)*32)+12); \r
          } // if  (data[0]==1)\r
-      if(data[0]==2)
-         {
-         ui_Command = inl(devpriv->iobase+((i_WatchdogNbr-1)*32)+12); 
-         /***************************/
-         /* Set the trigger command */
-         /***************************/
-         ui_Command = (ui_Command & 0xFFFFF9FFUL) | 0x200UL;
-         outl(ui_Command,devpriv->iobase+((i_WatchdogNbr-1)*32)+12);   
-         } 
-           
+      if(data[0]==2)\r
+         {\r
+         ui_Command = inl(devpriv->iobase+((i_WatchdogNbr-1)*32)+12); \r
+         /***************************/\r
+         /* Set the trigger command */\r
+         /***************************/\r
+         ui_Command = (ui_Command & 0xFFFFF9FFUL) | 0x200UL;\r
+         outl(ui_Command,devpriv->iobase+((i_WatchdogNbr-1)*32)+12);   \r
+         } \r
+           \r
       if (data[0]==0) //Stop The Watchdog \r
          {\r
          //Stop The Watchdog\r
-         ui_Command=0;
-         //ui_Command = inl(devpriv->iobase+((i_WatchdogNbr-1)*32)+12); 
-         //ui_Command = ui_Command & 0xFFFFF9FEUL;
-         outl(ui_Command,devpriv->iobase+((i_WatchdogNbr-1)*32)+12);   
+         ui_Command=0;\r
+         //ui_Command = inl(devpriv->iobase+((i_WatchdogNbr-1)*32)+12); \r
+         //ui_Command = ui_Command & 0xFFFFF9FEUL;\r
+         outl(ui_Command,devpriv->iobase+((i_WatchdogNbr-1)*32)+12);   \r
          } //  if (data[1]==0)\r
       if(data[0]==3)//stop all Watchdogs\r
-        {
-         ui_Command=0; 
-         for(i_Count=1;i_Count<=4;i_Count++)
+        {\r
+         ui_Command=0; \r
+         for(i_Count=1;i_Count<=4;i_Count++)\r
             {\r
-            if(devpriv->b_TimerSelectMode==ADDIDATA_WATCHDOG)
-              {
-               ui_Command=0x2UL;
-              }
-            else
-              {
+            if(devpriv->b_TimerSelectMode==ADDIDATA_WATCHDOG)\r
+              {\r
+               ui_Command=0x2UL;\r
+              }\r
+            else\r
+              {\r
               ui_Command = 0x10UL; \r
-              } 
-               i_WatchdogNbr=i_Count;
-               outl(ui_Command,devpriv->iobase+((i_WatchdogNbr-1)*32) + 0);
+              } \r
+               i_WatchdogNbr=i_Count;\r
+               outl(ui_Command,devpriv->iobase+((i_WatchdogNbr-1)*32) + 0);\r
              }\r
-\r         } 
+\r
+         } \r
       if(data[0]==4)//start all Watchdogs\r
         {\r
-         ui_Command = 0;
-         for(i_Count=1;i_Count<=4;i_Count++)
-            {
-            if(devpriv->b_TimerSelectMode==ADDIDATA_WATCHDOG)
-              {
-               ui_Command = 0x1UL;
-              }
-            else
-               {
-               ui_Command = 0x8UL;
-               } 
-               i_WatchdogNbr=i_Count;
-              outl(ui_Command,devpriv->iobase+((i_WatchdogNbr-1)*32) + 0);             
-             } 
+         ui_Command = 0;\r
+         for(i_Count=1;i_Count<=4;i_Count++)\r
+            {\r
+            if(devpriv->b_TimerSelectMode==ADDIDATA_WATCHDOG)\r
+              {\r
+               ui_Command = 0x1UL;\r
+              }\r
+            else\r
+               {\r
+               ui_Command = 0x8UL;\r
+               } \r
+               i_WatchdogNbr=i_Count;\r
+              outl(ui_Command,devpriv->iobase+((i_WatchdogNbr-1)*32) + 0);             \r
+             } \r
           }\r
       if(data[0]==5)//trigger all Watchdogs\r
         {\r
-         ui_Command =0;
-         for(i_Count=1;i_Count<=4;i_Count++)
-            {
-            if(devpriv->b_TimerSelectMode==ADDIDATA_WATCHDOG)
-               {
-               ui_Command=0x4UL;
-               }
-            else
-              {
-              ui_Command = 0x20UL; 
-              } 
-   \r          i_WatchdogNbr=i_Count;
-             outl(ui_Command,devpriv->iobase+((i_WatchdogNbr-1)*32) + 0);
-           }
-         i_Temp=1;
+         ui_Command =0;\r
+         for(i_Count=1;i_Count<=4;i_Count++)\r
+            {\r
+            if(devpriv->b_TimerSelectMode==ADDIDATA_WATCHDOG)\r
+               {\r
+               ui_Command=0x4UL;\r
+               }\r
+            else\r
+              {\r
+              ui_Command = 0x20UL; \r
+              } \r
+   \r
+          i_WatchdogNbr=i_Count;\r
+             outl(ui_Command,devpriv->iobase+((i_WatchdogNbr-1)*32) + 0);\r
+           }\r
+         i_Temp=1;\r
          }\r
    return insn->n;\r
 }\r
@@ -365,11 +391,13 @@ INT i_APCI035_StartStopWriteTimerWatchdog(comedi_device *dev,comedi_subdevice *s
 |                                                                            | \r
 |                                                                                                                                       |\r
 +----------------------------------------------------------------------------+\r
-| Output Parameters :  data[0]            : software trigger status                                                                                            \r              data[1]            : hardware trigger status  
-|                              data[2]            : Software clear status      
-                        data[3]            : Overflow status                                                                                            \r                     data[4]            : Timer actual value   
-                       
-
+| Output Parameters :  data[0]            : software trigger status                                                                                            \r
+              data[1]            : hardware trigger status  \r
+|                              data[2]            : Software clear status      \r
+                        data[3]            : Overflow status                                                                                            \r
+                     data[4]            : Timer actual value   \r
+                       \r
+\r
 +----------------------------------------------------------------------------+\r
 | Return Value      : TRUE  : No error occur                                 |\r
 |                          : FALSE : Error occur. Return the error          |\r
@@ -379,34 +407,34 @@ INT i_APCI035_StartStopWriteTimerWatchdog(comedi_device *dev,comedi_subdevice *s
 INT i_APCI035_ReadTimerWatchdog(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data)\r
 {\r
 UINT ui_Status = 0;   // Status register \r
- i_WatchdogNbr=insn->unused[0]; 
-              /******************/
-              /* Get the status */
-              /******************/  
+ i_WatchdogNbr=insn->unused[0]; \r
+              /******************/\r
+              /* Get the status */\r
+              /******************/  \r
       ui_Status =inl(devpriv->iobase+((i_WatchdogNbr-1)*32) + 16);\r
-      /***********************************/
-      /* Get the software trigger status */
-      /***********************************/
-      data[0] = ((ui_Status >> 1) & 1); 
-      /***********************************/
-      /* Get the hardware trigger status */
-      /***********************************/
-      data[1] =  ((ui_Status >> 2) & 1); 
-      /*********************************/
-      /* Get the software clear status */
-      /*********************************/ 
-      data[2] = ((ui_Status >> 3) & 1);
-      /***************************/
-      /* Get the overflow status */
-      /***************************/
-      data[3] = ((ui_Status >> 0) & 1);
+      /***********************************/\r
+      /* Get the software trigger status */\r
+      /***********************************/\r
+      data[0] = ((ui_Status >> 1) & 1); \r
+      /***********************************/\r
+      /* Get the hardware trigger status */\r
+      /***********************************/\r
+      data[1] =  ((ui_Status >> 2) & 1); \r
+      /*********************************/\r
+      /* Get the software clear status */\r
+      /*********************************/ \r
+      data[2] = ((ui_Status >> 3) & 1);\r
+      /***************************/\r
+      /* Get the overflow status */\r
+      /***************************/\r
+      data[3] = ((ui_Status >> 0) & 1);\r
     if  (devpriv->b_TimerSelectMode==ADDIDATA_TIMER) \r
       {\r
-      data[4]=inl(devpriv->iobase+((i_WatchdogNbr-1)*32) + 0);
-      
+      data[4]=inl(devpriv->iobase+((i_WatchdogNbr-1)*32) + 0);\r
+      \r
       } //  if  (devpriv->b_TimerSelectMode==ADDIDATA_TIMER) \r
-  
-      
+  \r
+      \r
    return insn->n;\r
 }\r
 \r
@@ -423,7 +451,7 @@ UINT ui_Status = 0;   // Status register
 |                     comedi_insn *insn       : Insn Structure Pointer       |  \r
 |                     lsampl_t *data          : Data Pointer contains        |\r
 |                                          configuration parameters as below |\r
-|                     data[0]                  : Warning delay value                                                              
+|                     data[0]                  : Warning delay value                                                              \r
 |                                                                            |         \r
 +----------------------------------------------------------------------------+\r
 | Output Parameters :  --                                                                                                       |\r
@@ -435,16 +463,16 @@ UINT ui_Status = 0;   // Status register
 */\r
 INT i_APCI035_ConfigAnalogInput(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data) \r
 {\r
-devpriv->tsk_Current=current;
-outl(0x200 | 0, devpriv->iobase+128 + 0x4);
-outl(0, devpriv->iobase+128 + 0);
-/********************************/
-/* Initialise the warning value */
-/********************************/
-outl(0x300 | 0, devpriv->iobase+128 + 0x4);
-outl((data[0] << 8), devpriv->iobase+128 + 0);
-outl(0x200000UL , devpriv->iobase+128 + 12);
-
+devpriv->tsk_Current=current;\r
+outl(0x200 | 0, devpriv->iobase+128 + 0x4);\r
+outl(0, devpriv->iobase+128 + 0);\r
+/********************************/\r
+/* Initialise the warning value */\r
+/********************************/\r
+outl(0x300 | 0, devpriv->iobase+128 + 0x4);\r
+outl((data[0] << 8), devpriv->iobase+128 + 0);\r
+outl(0x200000UL , devpriv->iobase+128 + 12);\r
+\r
 return insn->n;\r
 } \r
 \r
@@ -470,29 +498,29 @@ return insn->n;
 +----------------------------------------------------------------------------+\r
 */\r
 INT i_APCI035_ReadAnalogInput(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data) \r
-{ 
-UINT ui_CommandRegister=0;
-/******************/
-/*  Set the start */
-/******************/
-ui_CommandRegister =0x80000;  
- /******************************/
- /* Write the command register */
- /******************************/
-outl(ui_CommandRegister, devpriv->iobase+128 + 8);
-              
-/***************************************/
-/* Read the digital value of the input */
-/***************************************/
-data[0] = inl (devpriv->iobase+ 128 + 28);                           
+{ \r
+UINT ui_CommandRegister=0;\r
+/******************/\r
+/*  Set the start */\r
+/******************/\r
+ui_CommandRegister =0x80000;  \r
+ /******************************/\r
+ /* Write the command register */\r
+ /******************************/\r
+outl(ui_CommandRegister, devpriv->iobase+128 + 8);\r
+              \r
+/***************************************/\r
+/* Read the digital value of the input */\r
+/***************************************/\r
+data[0] = inl (devpriv->iobase+ 128 + 28);                           \r
 return insn->n;\r
 }\r
 \r
-
 \r
-
 \r
-
+\r
+\r
+\r
 \r
 /*\r
 +----------------------------------------------------------------------------+\r
@@ -510,15 +538,15 @@ return insn->n;
 +----------------------------------------------------------------------------+\r
 */\r
 INT i_APCI035_Reset(comedi_device *dev)\r
-{
-INT i_Count=0;
-for(i_Count=1;i_Count<=4;i_Count++)
-    {
-     i_WatchdogNbr=i_Count;
-     outl(0x0,devpriv->iobase+((i_WatchdogNbr-1)*32) + 0);//stop all timers
-    }
-outl(0x0 , devpriv->iobase+128 + 12);//Disable the warning delay
-
+{\r
+INT i_Count=0;\r
+for(i_Count=1;i_Count<=4;i_Count++)\r
+    {\r
+     i_WatchdogNbr=i_Count;\r
+     outl(0x0,devpriv->iobase+((i_WatchdogNbr-1)*32) + 0);//stop all timers\r
+    }\r
+outl(0x0 , devpriv->iobase+128 + 12);//Disable the warning delay\r
+\r
  return 0;\r
 }\r
 \r
@@ -543,58 +571,58 @@ outl(0x0 , devpriv->iobase+128 + 12);//Disable the warning delay
 static void v_APCI035_Interrupt(int irq, void *d, struct pt_regs *regs) \r
 {      \r
    comedi_device *dev = d;\r
-   UINT ui_StatusRegister1 = 0;
-   UINT ui_StatusRegister2=0;
-   UINT ui_ReadCommand =0;
-   UINT ui_ChannelNumber=0;
-   UINT ui_DigitalTemperature=0;
-   if(i_Temp==1)
-       {
-        i_WatchdogNbr=i_Flag;  
-        i_Flag=i_Flag+1;  
-       }     
-  /**************************************/
-  /* Read the interrupt status register of temperature Warning */
-  /**************************************/
-   ui_StatusRegister1 = inl(devpriv->iobase+128 + 16);  
-  /**************************************/
-   /* Read the interrupt status register for Watchdog/timer */ 
-   /**************************************/
-  
-   ui_StatusRegister2 = inl (devpriv->iobase+((i_WatchdogNbr-1)*32) + 20);
-   
-   if ((((ui_StatusRegister1 ) & 0x8) == 0x8))//Test if warning relay interrupt
-        {
-        /**********************************/
-        /* Disable the temperature warning */
-        /**********************************/
-         ui_ReadCommand = inl (devpriv->iobase+128 + 12);
-         ui_ReadCommand = ui_ReadCommand & 0xFFDF0000UL;
-         outl(ui_ReadCommand , devpriv->iobase+128 + 12);     
-      /***************************/
-      /* Read the channel number */
-      /***************************/   
-        ui_ChannelNumber  = inl(devpriv->iobase+128 + 60);
-        /**************************************/
-        /* Read the digital temperature value */
-        /**************************************/
-         ui_DigitalTemperature = inl(devpriv->iobase+128 + 60);  
-         send_sig(SIGIO,devpriv->tsk_Current,0); // send signal to the sample
-        }//if (((ui_StatusRegister1 & 0x8) == 0x8)) 
-           
-   else
-       {
-       if((ui_StatusRegister2 & 0x1) == 0x1)       
-          {
-           send_sig(SIGIO,devpriv->tsk_Current,0); // send signal to the sample     
-          }
-        }//else if (((ui_StatusRegister1 & 0x8) == 0x8))       
-        
-    
+   UINT ui_StatusRegister1 = 0;\r
+   UINT ui_StatusRegister2=0;\r
+   UINT ui_ReadCommand =0;\r
+   UINT ui_ChannelNumber=0;\r
+   UINT ui_DigitalTemperature=0;\r
+   if(i_Temp==1)\r
+       {\r
+        i_WatchdogNbr=i_Flag;  \r
+        i_Flag=i_Flag+1;  \r
+       }     \r
+  /**************************************/\r
+  /* Read the interrupt status register of temperature Warning */\r
+  /**************************************/\r
+   ui_StatusRegister1 = inl(devpriv->iobase+128 + 16);  \r
+  /**************************************/\r
+   /* Read the interrupt status register for Watchdog/timer */ \r
+   /**************************************/\r
+  \r
+   ui_StatusRegister2 = inl (devpriv->iobase+((i_WatchdogNbr-1)*32) + 20);\r
+   \r
+   if ((((ui_StatusRegister1 ) & 0x8) == 0x8))//Test if warning relay interrupt\r
+        {\r
+        /**********************************/\r
+        /* Disable the temperature warning */\r
+        /**********************************/\r
+         ui_ReadCommand = inl (devpriv->iobase+128 + 12);\r
+         ui_ReadCommand = ui_ReadCommand & 0xFFDF0000UL;\r
+         outl(ui_ReadCommand , devpriv->iobase+128 + 12);     \r
+      /***************************/\r
+      /* Read the channel number */\r
+      /***************************/   \r
+        ui_ChannelNumber  = inl(devpriv->iobase+128 + 60);\r
+        /**************************************/\r
+        /* Read the digital temperature value */\r
+        /**************************************/\r
+         ui_DigitalTemperature = inl(devpriv->iobase+128 + 60);  \r
+         send_sig(SIGIO,devpriv->tsk_Current,0); // send signal to the sample\r
+        }//if (((ui_StatusRegister1 & 0x8) == 0x8)) \r
+           \r
+   else\r
+       {\r
+       if((ui_StatusRegister2 & 0x1) == 0x1)       \r
+          {\r
+           send_sig(SIGIO,devpriv->tsk_Current,0); // send signal to the sample     \r
+          }\r
+        }//else if (((ui_StatusRegister1 & 0x8) == 0x8))       \r
+        \r
+    \r
 return;\r
 }\r
 \r
-
 \r
-
-
+\r
+\r
+\r
index 853ad7f9687db5dd326311e57d31ffd07689c248..4b7b90e1989f5641a12481925851add1f89fbec4 100644 (file)
@@ -1,37 +1,60 @@
+/**\r
+@verbatim\r
+\r
+Copyright (C) 2004,2005  ADDI-DATA GmbH for the source code of this module. \r
+        \r
+        ADDI-DATA GmbH \r
+        Dieselstrasse 3 \r
+        D-77833 Ottersweier \r
+        Tel: +19(0)7223/9493-0 \r
+        Fax: +49(0)7223/9493-92 \r
+        http://www.addi-data-com \r
+        info@addi-data.com \r
+\r
+This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.\r
+\r
+This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.\r
+\r
+You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+\r
+You shoud also find the complete GPL in the COPYING file accompanying this source code.\r
+\r
+@endverbatim\r
+*/\r
 // Card Specific information\r
 #define APCI035_BOARD_VENDOR_ID                 0x15B8\r
 #define APCI035_ADDRESS_RANGE                   255\r
 \r
-INT i_TW_Number;
-struct 
-{                              
- INT i_Gain ;
- INT i_Polarity;
- INT i_OffsetRange;
- INT i_Coupling;
- INT i_SingleDiff;
- INT i_AutoCalibration;
- UINT ui_ReloadValue;
- UINT ui_TimeUnitReloadVal;
- INT i_Interrupt;
- INT i_ModuleSelection;
-}Config_Parameters_Main;
-
-
-
-//ANALOG INPUT RANGE 
-comedi_lrange range_apci035_ai={ 8, {
-               BIP_RANGE(10),
-               BIP_RANGE(5),
-               BIP_RANGE(2),
-               BIP_RANGE(1),
-               UNI_RANGE(10),
-               UNI_RANGE(5),
-               UNI_RANGE(2),
-               UNI_RANGE(1)
-       }
-};
-
+INT i_TW_Number;\r
+struct \r
+{                              \r
+ INT i_Gain ;\r
+ INT i_Polarity;\r
+ INT i_OffsetRange;\r
+ INT i_Coupling;\r
+ INT i_SingleDiff;\r
+ INT i_AutoCalibration;\r
+ UINT ui_ReloadValue;\r
+ UINT ui_TimeUnitReloadVal;\r
+ INT i_Interrupt;\r
+ INT i_ModuleSelection;\r
+}Config_Parameters_Main;\r
+\r
+\r
+\r
+//ANALOG INPUT RANGE \r
+comedi_lrange range_apci035_ai={ 8, {\r
+               BIP_RANGE(10),\r
+               BIP_RANGE(5),\r
+               BIP_RANGE(2),\r
+               BIP_RANGE(1),\r
+               UNI_RANGE(10),\r
+               UNI_RANGE(5),\r
+               UNI_RANGE(2),\r
+               UNI_RANGE(1)\r
+       }\r
+};\r
+\r
 // Timer / Watchdog Related Defines \r
 \r
 #define APCI035_TCW_SYNC_ENABLEDISABLE           0\r
@@ -44,7 +67,7 @@ comedi_lrange range_apci035_ai={ 8, {
 #define APCI035_TCW_WARN_TIMEBASE                28\r
 \r
 #define ADDIDATA_TIMER                            0\r
-#define ADDIDATA_WATCHDOG                         1
+#define ADDIDATA_WATCHDOG                         1\r
 \r
 #define APCI035_TW1                               0\r
 #define APCI035_TW2                               32\r
@@ -64,18 +87,18 @@ comedi_lrange range_apci035_ai={ 8, {
 #define APCI035_RELOAD_CONV_TIME_VAL             32\r
 #define APCI035_DELAY_TIME_TIME_BASE             44\r
 #define APCI035_RELOAD_DELAY_TIME_VAL            40\r
-#define ENABLE_EXT_TRIG                          1
-#define ENABLE_EXT_GATE                          2
-#define ENABLE_EXT_TRIG_GATE                     3
-
-#define ANALOG_INPUT                             0
-#define TEMPERATURE                              1
-#define RESISTANCE                               2
-
-#define ADDIDATA_GREATER_THAN_TEST               0
-#define ADDIDATA_LESS_THAN_TEST                  1
-
-
+#define ENABLE_EXT_TRIG                          1\r
+#define ENABLE_EXT_GATE                          2\r
+#define ENABLE_EXT_TRIG_GATE                     3\r
+\r
+#define ANALOG_INPUT                             0\r
+#define TEMPERATURE                              1\r
+#define RESISTANCE                               2\r
+\r
+#define ADDIDATA_GREATER_THAN_TEST               0\r
+#define ADDIDATA_LESS_THAN_TEST                  1\r
+\r
+\r
 #define APCI035_MAXVOLT                         2.5\r
 \r
 #define ADDIDATA_UNIPOLAR                        1\r
@@ -99,26 +122,16 @@ comedi_lrange range_apci035_ai={ 8, {
 INT i_APCI035_ConfigTimerWatchdog (comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data);\r
 INT i_APCI035_StartStopWriteTimerWatchdog(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data);\r
 INT i_APCI035_ReadTimerWatchdog(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data);\r
-
-
-//Temperature Related Defines (Analog Input Subdevice)
-
-INT i_APCI035_ConfigAnalogInput(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data);
-INT i_APCI035_ReadAnalogInput(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data);
-
-
-//Interrupt\r
-static void v_APCI035_Interrupt(int irq, void *d, struct pt_regs *regs) ;\r
 \r
-//Reset functions\r
-INT i_APCI035_Reset(comedi_device *dev);       \r
 \r
+//Temperature Related Defines (Analog Input Subdevice)\r
 \r
-
-
-
-
-
+INT i_APCI035_ConfigAnalogInput(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data);\r
+INT i_APCI035_ReadAnalogInput(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data);\r
 \r
 \r
+//Interrupt\r
+static void v_APCI035_Interrupt(int irq, void *d, struct pt_regs *regs) ;\r
 \r
+//Reset functions\r
+INT i_APCI035_Reset(comedi_device *dev);       \r
index cef17cdb2c82c0e655cb1ce876917b2f21c87024..f1de6f3dccab59cd11512f807118d586d03b86bb 100644 (file)
@@ -1,14 +1,38 @@
+/**
+@verbatim
+
+Copyright (C) 2004,2005  ADDI-DATA GmbH for the source code of this module. 
+        
+        ADDI-DATA GmbH 
+        Dieselstrasse 3 
+        D-77833 Ottersweier 
+        Tel: +19(0)7223/9493-0 
+        Fax: +49(0)7223/9493-92 
+        http://www.addi-data-com 
+        info@addi-data.com 
+
+This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+You shoud also find the complete GPL in the COPYING file accompanying this source code.
+
+@endverbatim
+*/
 /*
+    
   +-----------------------------------------------------------------------+
   | (C) ADDI-DATA GmbH          Dieselstraße 3       D-77833 Ottersweier  |
   +-----------------------------------------------------------------------+
   | Tel : +49 (0) 7223/9493-0     | email    : info@addi-data.com         |
   | Fax : +49 (0) 7223/9493-92    | Internet : http://www.addi-data.com   |
   +-------------------------------+---------------------------------------+
-  | Project     : 13Card Linux Driver | Compiler   : GCC                  |
-  | Module name : hwdrv_apci1032.c|     Version    : 2.96                 |
+  | Project     : APCI-1032       | Compiler   : GCC                      |
+  | Module name : hwdrv_apci1032.c| Version    : 2.96                     |
   +-------------------------------+---------------------------------------+
-  | Author : Shitalkumar S Chavan |     Date       : 31.10.2001           |
+  | Project manager: Eric Stolz   | Date       :  02/12/2002              |
   +-------------------------------+---------------------------------------+
   | Description :   Hardware Layer Acces For APCI-1032                    |
   +-----------------------------------------------------------------------+
@@ -67,6 +91,7 @@ INT i_APCI1032_ConfigDigitalInput(comedi_device *dev,comedi_subdevice *s,comedi_
   ULONG  ul_Command1 = 0; 
   ULONG  ul_Command2 = 0;
   devpriv->tsk_Current=current;
+  
   /*******************************/
   /* Set the digital input logic */
   /*******************************/
@@ -85,7 +110,7 @@ INT i_APCI1032_ConfigDigitalInput(comedi_device *dev,comedi_subdevice *s,comedi_
        {
        outl(0x6 ,devpriv->iobase+APCI1032_DIGITAL_IP_IRQ);
        }//else if(data[1] == ADDIDATA_OR)
-      }// if( data[0] == ADDIDATA_ENABLE)
+     }// if( data[0] == ADDIDATA_ENABLE)
   else
      {
      ul_Command1 = ul_Command1 & 0xFFFF0000;
@@ -210,11 +235,11 @@ INT i_APCI1032_ReadMoreDigitalInput(comedi_device *dev,comedi_subdevice *s,comed
 |                     void *d                 : void pointer                 |
 |                     struct pt_regs *regs    : structure pointer            |
 +----------------------------------------------------------------------------+
-| Output Parameters :  --                                                                                                       |
+| Output Parameters :  --                                                   |
 +----------------------------------------------------------------------------+
 | Return Value      : TRUE  : No error occur                                 |
 |                          : FALSE : Error occur. Return the error          |
-|                                                                               |
+|                                                                           |
 +----------------------------------------------------------------------------+
 */
 static VOID v_APCI1032_Interrupt(int irq,void* d, struct pt_regs *regs) 
index 8e55bf5c7989e601459a77e257fe5abf9a3352cd..467fe753d93c0ffe26810e3478e8af4eb4921e7b 100644 (file)
@@ -1,3 +1,27 @@
+/**
+@verbatim
+
+Copyright (C) 2004,2005  ADDI-DATA GmbH for the source code of this module. 
+        
+        ADDI-DATA GmbH 
+        Dieselstrasse 3 
+        D-77833 Ottersweier 
+        Tel: +19(0)7223/9493-0 
+        Fax: +49(0)7223/9493-92 
+        http://www.addi-data-com 
+        info@addi-data.com 
+
+This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+You shoud also find the complete GPL in the COPYING file accompanying this source code.
+
+@endverbatim
+*/
+
 /*********      Definitions for APCI-1032 card  *****/
 
 #define APCI1032_BOARD_VENDOR_ID 0x15B8
@@ -55,5 +79,3 @@ INT i_APCI1032_ReadMoreDigitalInput(comedi_device *dev,comedi_subdevice *s,comed
 static VOID v_APCI1032_Interrupt(int irq, void *d, struct pt_regs *regs) ;
 //Reset
 INT i_APCI1032_Reset(comedi_device *dev);
-
-           
\ No newline at end of file
index c4e460a276f18b2336b18c08dd32b4fd9838d57c..5ac61a46fc68b78c8a92d529ddda8cfeb1ddc348 100644 (file)
@@ -1,14 +1,38 @@
+/**
+@verbatim
+
+Copyright (C) 2004,2005  ADDI-DATA GmbH for the source code of this module. 
+        
+        ADDI-DATA GmbH 
+        Dieselstrasse 3 
+        D-77833 Ottersweier 
+        Tel: +19(0)7223/9493-0 
+        Fax: +49(0)7223/9493-92 
+        http://www.addi-data-com 
+        info@addi-data.com 
+
+This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+You shoud also find the complete GPL in the COPYING file accompanying this source code.
+
+@endverbatim
+*/
 /*
+    
   +-----------------------------------------------------------------------+
   | (C) ADDI-DATA GmbH          Dieselstraße 3       D-77833 Ottersweier  |
   +-----------------------------------------------------------------------+
   | Tel : +49 (0) 7223/9493-0     | email    : info@addi-data.com         |
   | Fax : +49 (0) 7223/9493-92    | Internet : http://www.addi-data.com   |
   +-------------------------------+---------------------------------------+
-  | Project     : 13Card Linux Driver | Compiler   : GCC                  |
-  | Module name : hwdrv_apci1500.c|     Version    : 2.96                 |
+  | Project     : APCI-1500       | Compiler   : GCC                      |
+  | Module name : hwdrv_apci1500.c| Version    : 2.96                     |
   +-------------------------------+---------------------------------------+
-  | Author : Karl Andrade         |     Date       : 13.12.2001           |
+  | Project manager: Eric Stolz   | Date       :  02/12/2002              |
   +-------------------------------+---------------------------------------+
   | Description :   Hardware Layer Acces For APCI-1500                    |
   +-----------------------------------------------------------------------+
@@ -2706,21 +2730,3 @@ outb(APCI1500_RW_CPT_TMR3_CMD_STATUS,devpriv->iobase+APCI1500_Z8536_CONTROL_REGI
 outb(0x00,devpriv->iobase+APCI1500_Z8536_CONTROL_REGISTER);  
 return 0;
 }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-                                 
\ No newline at end of file
index 479a0ead1e13021663f8c91642e6e43fb718781a..631d0fb594cf3380e882ae5d580245db7f2a789f 100644 (file)
@@ -1,3 +1,27 @@
+/**
+@verbatim
+
+Copyright (C) 2004,2005  ADDI-DATA GmbH for the source code of this module. 
+        
+        ADDI-DATA GmbH 
+        Dieselstrasse 3 
+        D-77833 Ottersweier 
+        Tel: +19(0)7223/9493-0 
+        Fax: +49(0)7223/9493-92 
+        http://www.addi-data-com 
+        info@addi-data.com 
+
+This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+You shoud also find the complete GPL in the COPYING file accompanying this source code.
+
+@endverbatim
+*/
+
 /*********      Definitions for APCI-1500 card  *****/
 
 // Card Specific information
@@ -123,4 +147,3 @@ static void v_APCI1500_Interrupt(int irq, void *d, struct pt_regs *regs);
 static int i_APCI1500_ConfigureInterrupt(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data);
 /*----------RESET---------------*/
 static int i_APCI1500_Reset(comedi_device *dev) ; 
-                                                         
\ No newline at end of file
index 45501fe6af6a34dd4e14fd03b1d41d1025a3f694..a0ebb57c6e322128279c91d6f7fa07c13f3917f8 100644 (file)
@@ -1,14 +1,38 @@
+/**\r
+@verbatim\r
+\r
+Copyright (C) 2004,2005  ADDI-DATA GmbH for the source code of this module. \r
+        \r
+        ADDI-DATA GmbH \r
+        Dieselstrasse 3 \r
+        D-77833 Ottersweier \r
+        Tel: +19(0)7223/9493-0 \r
+        Fax: +49(0)7223/9493-92 \r
+        http://www.addi-data-com \r
+        info@addi-data.com \r
+\r
+This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.\r
+\r
+This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.\r
+\r
+You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+\r
+You shoud also find the complete GPL in the COPYING file accompanying this source code.\r
+\r
+@endverbatim\r
+*/\r
 /*\r
+    \r
   +-----------------------------------------------------------------------+\r
   | (C) ADDI-DATA GmbH          Dieselstraße 3       D-77833 Ottersweier  |\r
   +-----------------------------------------------------------------------+\r
   | Tel : +49 (0) 7223/9493-0     | email    : info@addi-data.com         |\r
   | Fax : +49 (0) 7223/9493-92    | Internet : http://www.addi-data.com   |\r
   +-------------------------------+---------------------------------------+\r
-  | Project     : 13Card Linux Driver | Compiler   : GCC                  |\r
-  | Module name : hwdrv_apci1516.c|     Version    : 2.96                 |\r
+  | Project     : APCI-1516       | Compiler   : GCC                      |\r
+  | Module name : hwdrv_apci1516.c| Version    : 2.96                     |\r
   +-------------------------------+---------------------------------------+\r
-  | Author : Shitalkumar S Chavan |     Date       : 31.10.2001           |\r
+  | Project manager: Eric Stolz   | Date       :  02/12/2002              |\r
   +-------------------------------+---------------------------------------+\r
   | Description :   Hardware Layer Acces For APCI-1516                    |\r
   +-----------------------------------------------------------------------+\r
 */\r
 #include "hwdrv_apci1516.h"\r
 \r
-
-/*
-+----------------------------------------------------------------------------+
-| Function   Name   : int i_APCI1516_Read1DigitalInput                       |
-|                        (comedi_device *dev,comedi_subdevice *s,               |
-|                      comedi_insn *insn,lsampl_t *data)                     |
-+----------------------------------------------------------------------------+
-| Task              : Return the status of the digital input                 |
-+----------------------------------------------------------------------------+
-| Input Parameters  : comedi_device *dev      : Driver handle                |
-|                     comedi_subdevice *s,   :pointer to subdevice structure
-                       comedi_insn *insn      :pointer to insn structure     |
-|                     lsampl_t *data          : Data Pointer to read status  |
-+----------------------------------------------------------------------------+
-| Output Parameters :  --                                                                                                       |
-+----------------------------------------------------------------------------+
-| Return Value      : TRUE  : No error occur                                 |
-|                          : FALSE : Error occur. Return the error          |
-|                                                                               |
-+----------------------------------------------------------------------------+
-*/
-INT i_APCI1516_Read1DigitalInput(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data)
-{
-   UINT ui_TmpValue=0;
-   UINT ui_Channel;
-   ui_Channel=CR_CHAN(insn->chanspec);
-   if  (ui_Channel >= 0 && ui_Channel <=7)
-      {
-      ui_TmpValue=(UINT) inw(devpriv->iobase + APCI1516_DIGITAL_IP);
-      //  since only 1 channel reqd  to bring it to last bit it is rotated 
-      //  8 +(chan - 1) times then ANDed with 1 for last bit. 
-      *data = (ui_TmpValue >> ui_Channel)&0x1 ;
-      }//if(ui_Channel >= 0 && ui_Channel <=7)
-   else 
-      {
-      //comedi_error(dev," \n chan spec wrong\n");
-      return -EINVAL;   // "sorry channel spec wrong "
-      }//else if(ui_Channel >= 0 && ui_Channel <=7)
-
-  return insn->n;
-}
-
-/*
-+----------------------------------------------------------------------------+
-| Function   Name   : int i_APCI1516_ReadMoreDigitalInput                    |
-|                        (comedi_device *dev,comedi_subdevice *s,               |
-|                     comedi_insn *insn,lsampl_t *data)                      |
-+----------------------------------------------------------------------------+
-| Task              : Return the status of the Requested digital inputs      |
-+----------------------------------------------------------------------------+
-| Input Parameters  : comedi_device *dev      : Driver handle                |
-|                      comedi_subdevice *s,   :pointer to subdevice structure
-                       comedi_insn *insn      :pointer to insn structure     |
-|                      lsampl_t *data         : Data Pointer to read status  |
-+----------------------------------------------------------------------------+
-| Output Parameters :  --                                                                                                       |
-+----------------------------------------------------------------------------+
-| Return Value      : TRUE  : No error occur                                 |
-|                          : FALSE : Error occur. Return the error          |
-|                                                                               |
-+----------------------------------------------------------------------------+
-*/
-
-INT i_APCI1516_ReadMoreDigitalInput(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data)
-{
-   UINT ui_PortValue=data[0];
-   UINT ui_Mask=0;
-   UINT ui_NoOfChannels;
-   
-   ui_NoOfChannels=CR_CHAN(insn->chanspec);
-   
-      *data=(UINT)inw(devpriv->iobase + APCI1516_DIGITAL_IP );
-      switch (ui_NoOfChannels)
-       {
-        case 2:ui_Mask=3;
-               *data=(*data >>(2*ui_PortValue))&ui_Mask; 
-               break;
-        case 4:ui_Mask=15;
-               *data=(*data >>(4*ui_PortValue))&ui_Mask; 
-              break;
-        case 7:break;
-        
-        default:
-               printk("\nWrong parameters\n");
-               return -EINVAL;   // "sorry channel spec wrong "  
-                break;
-        }//switch(ui_NoOfChannels)
-      
-  
-   return insn->n;
-}
-\r
-/*
-+----------------------------------------------------------------------------+
-| Function   Name   : int i_APCI1516_ConfigDigitalOutput (comedi_device *dev,
-                    comedi_subdevice *s comedi_insn *insn,lsampl_t *data)    |
-|                                                                                   |
-+----------------------------------------------------------------------------+
-| Task              : Configures The Digital Output Subdevice.               |
-+----------------------------------------------------------------------------+
-| Input Parameters  : comedi_device *dev : Driver handle                     |
-|                     lsampl_t *data         : Data Pointer contains         |
-|                                          configuration parameters as below |
-|                      comedi_subdevice *s,   :pointer to subdevice structure
-                       comedi_insn *insn      :pointer to insn structure                                                           | 
-|                                        data[0]  :1:Memory on                          | 
-|                                                  0:Memory off                         |      
-|                                                                                                           | 
-|                                                                                                                                       |
-+----------------------------------------------------------------------------+
-| Output Parameters :  --                                                                                                       |
-+----------------------------------------------------------------------------+
-| Return Value      : TRUE  : No error occur                                 |
-|                          : FALSE : Error occur. Return the error          |
-|                                                                               |
-+----------------------------------------------------------------------------+
-*/
-int i_APCI1516_ConfigDigitalOutput(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data){
- devpriv->b_OutputMemoryStatus=data[0];
-return insn->n;
-}
-
-/*
-+----------------------------------------------------------------------------+
-| Function   Name   : int i_APCI1516_WriteDigitalOutput                      |
-|                      (comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,
-                     lsampl_t *data)                                         |
-+----------------------------------------------------------------------------+
-| Task              : Writes port value  To the selected port                |
-+----------------------------------------------------------------------------+
-| Input Parameters  : comedi_device *dev      : Driver handle                |
-|                     comedi_subdevice *s,   :pointer to subdevice structure
-                      comedi_insn *insn      :pointer to insn structure      |
-|                    lsampl_t *data           : Data Pointer to read status  |
-+----------------------------------------------------------------------------+
-| Output Parameters :  --                                                                                                       |
-+----------------------------------------------------------------------------+
-| Return Value      : TRUE  : No error occur                                 |
-|                          : FALSE : Error occur. Return the error          |
-|                                                                               |
-+----------------------------------------------------------------------------+
-*/
-
-INT i_APCI1516_WriteDigitalOutput(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data) 
-{
-UINT ui_Temp,ui_Temp1;
-UINT ui_NoOfChannel = CR_CHAN(insn->chanspec); // get the channel
- if(devpriv->b_OutputMemoryStatus )
-   {
-   ui_Temp=inw(devpriv->iobase+APCI1516_DIGITAL_OP);
-   }//if(devpriv->b_OutputMemoryStatus )
- else
-   {
-   ui_Temp=0;
-    }//if(devpriv->b_OutputMemoryStatus )
-if(data[3]==0)
-  { 
-  if(data[1]==0)
-    {
-     data[0]=(data[0] << ui_NoOfChannel)|ui_Temp;
-     outw(data[0],devpriv->iobase+APCI1516_DIGITAL_OP); 
-    }//if(data[1]==0) 
-  else
-    {
-    if(data[1]==1)
-       { 
-       switch( ui_NoOfChannel)
-        {
-
-        case 2: data[0]=(data[0] << (2*data[2]))|ui_Temp; 
-              break;
-
-
-        case 4:data[0]=(data[0] << (4*data[2]))|ui_Temp;
-              break;
-
-        case 7:data[0]=data[0]|ui_Temp; 
-              break;
-
-         default:
-                 comedi_error(dev," chan spec wrong");
-                 return -EINVAL;   // "sorry channel spec wrong "  
-                
-
-         }//switch(ui_NoOfChannels)
-   
-     outw(data[0],devpriv->iobase+APCI1516_DIGITAL_OP);
-     }// if(data[1]==1)
-   else
-     {
-     printk("\nSpecified channel not supported\n");
-     }//else if(data[1]==1)
-   }//elseif(data[1]==0)
- }//if(data[3]==0)
-else
-   {
-    if(data[3]==1)
-       {
-        if(data[1]==0)
-          {
-          data[0]=~data[0]&0x1;
-          ui_Temp1=1;
-          ui_Temp1=ui_Temp1<<ui_NoOfChannel;
-          ui_Temp=ui_Temp|ui_Temp1;  
-          data[0]=(data[0] << ui_NoOfChannel)^0xff;
-          data[0]=data[0]& ui_Temp; 
-          outw(data[0],devpriv->iobase+APCI1516_DIGITAL_OP); 
-          }//if(data[1]==0) 
-        else
-          {
-          if(data[1]==1)
-             { 
-             switch( ui_NoOfChannel)
-              {
-
-              case 2: data[0]=~data[0]&0x3; 
-                       ui_Temp1=3;
-                       ui_Temp1=ui_Temp1<<2*data[2];
-                       ui_Temp=ui_Temp|ui_Temp1;   
-                       data[0]=((data[0] << (2*data[2]))^0xff)& ui_Temp; 
-                      break;
-
-
-              case 4:data[0]=~data[0]&0xf;
-                      ui_Temp1=15;
-                      ui_Temp1=ui_Temp1<<4*data[2];
-                      ui_Temp=ui_Temp|ui_Temp1;    
-                      data[0]=((data[0] << (4*data[2]))^0xff)&ui_Temp;
-                     break;
-
-              case 7: break;
-
-               default:
-                     comedi_error(dev," chan spec wrong");
-                     return -EINVAL;   // "sorry channel spec wrong "  
-                
-
-              }//switch(ui_NoOfChannels)
-   
-            outw(data[0],devpriv->iobase+APCI1516_DIGITAL_OP);
-            }// if(data[1]==1)
-         else
-           {
-            printk("\nSpecified channel not supported\n");
-           }//else if(data[1]==1)
-         }//elseif(data[1]==0)
-      }//if(data[3]==1);
-   else
-      {
-       printk("\nSpecified functionality does not exist\n");
-       return -EINVAL;
-      }//if else data[3]==1)
-   }//if else data[3]==0) 
-    return (insn->n);;
-}
-
-
-/*
-+----------------------------------------------------------------------------+
-| Function   Name   : int i_APCI1516_ReadDigitalOutput                       |
-|                      (comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,
-                    lsampl_t *data)                                         |
-+----------------------------------------------------------------------------+
-| Task              : Read  value  of the selected channel or port           |
-+----------------------------------------------------------------------------+
-| Input Parameters  : comedi_device *dev      : Driver handle                |
-|                     comedi_subdevice *s,   :pointer to subdevice structure
-                      comedi_insn *insn      :pointer to insn structure      |
-|                     lsampl_t *data          : Data Pointer to read status  |
-+----------------------------------------------------------------------------+
-| Output Parameters :  --                                                                                                       |
-+----------------------------------------------------------------------------+
-| Return Value      : TRUE  : No error occur                                 |
-|                          : FALSE : Error occur. Return the error          |
-|                                                                               |
-+----------------------------------------------------------------------------+
-*/
-
-INT i_APCI1516_ReadDigitalOutput(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data) 
-{
-
-UINT ui_Temp;
-UINT ui_NoOfChannel = CR_CHAN(insn->chanspec); // get the channel
-ui_Temp=data[0];
-*data=inw(devpriv->iobase+APCI1516_DIGITAL_OP_RW);
-if(ui_Temp==0)
-   {
-   *data=(*data >> ui_NoOfChannel)&0x1; 
-   }//if(ui_Temp==0)
-else
-   {
-    if(ui_Temp==1)
-       {
-       switch( ui_NoOfChannel)
-        {
-
-        case 2:*data=(*data >>(2*data[1]))&3; 
-               break;
-
-        case 4:*data=(*data >>(4*data[1]))&15; 
-              break;
-
-        case 7: break;
-         default:
-                 comedi_error(dev," chan spec wrong");
-                 return -EINVAL;   // "sorry channel spec wrong "  
-          
-
-         }//switch(ui_NoOfChannels)    
-       }//if(ui_Temp==1)
-   else
-     {
-     printk("\nSpecified channel not supported \n");
-     }//elseif(ui_Temp==1)
-  }//elseif(ui_Temp==0)
-return insn->n;
-}
-
-/*
-+----------------------------------------------------------------------------+
-| Function   Name   : int i_APCI1516_ConfigWatchdog(comedi_device *dev,
-                      comedi_subdevice *s,comedi_insn *insn,lsampl_t *data)  |
-|                                                                                   |
-+----------------------------------------------------------------------------+
-| Task              : Configures The Watchdog                                |
-+----------------------------------------------------------------------------+
-| Input Parameters  :   comedi_device *dev      : Driver handle              |
-|                     comedi_subdevice *s,   :pointer to subdevice structure
-                      comedi_insn *insn      :pointer to insn structure      |
-|                     lsampl_t *data          : Data Pointer to read status                                                     |  
-+----------------------------------------------------------------------------+
-| Output Parameters :  --                                                                                                       |
-+----------------------------------------------------------------------------+
-| Return Value      : TRUE  : No error occur                                 |
-|                          : FALSE : Error occur. Return the error          |
-|                                                                               |
-+----------------------------------------------------------------------------+
-*/
-
-int i_APCI1516_ConfigWatchdog(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data)
-{
-if(data[0]==0)
-   {
-   //Disable the watchdog
-   outw(0x0,devpriv->i_IobaseAddon+ APCI1516_WATCHDOG_ENABLEDISABLE);
-   //Loading the Reload value
-   outw(data[1],devpriv->i_IobaseAddon+APCI1516_WATCHDOG_RELOAD_VALUE);
-   data[1]=data[1]>>16;
-   outw(data[1],devpriv->i_IobaseAddon+APCI1516_WATCHDOG_RELOAD_VALUE+2);
-   }//if(data[0]==0)
-else
-   {
-     printk("\nThe input parameters are wrong\n");
-     return -EINVAL; 
-   }//elseif(data[0]==0)
-
-return insn->n;
-}
-
- /*
-+----------------------------------------------------------------------------+
-| Function   Name   : int i_APCI1516_StartStopWriteWatchdog                  |
-|                              (comedi_device *dev,comedi_subdevice *s,
-                     comedi_insn *insn,lsampl_t *data);                      |
-+----------------------------------------------------------------------------+
-| Task              : Start / Stop The Watchdog                              |
-+----------------------------------------------------------------------------+
-| Input Parameters  : comedi_device *dev      : Driver handle                |
-|                     comedi_subdevice *s,   :pointer to subdevice structure
-                      comedi_insn *insn      :pointer to insn structure      |
-|                     lsampl_t *data          : Data Pointer to read status  |
-+----------------------------------------------------------------------------+
-| Output Parameters :  --                                                                                                       |
-+----------------------------------------------------------------------------+
-| Return Value      : TRUE  : No error occur                                 |
-|                          : FALSE : Error occur. Return the error          |
-|                                                                               |
-+----------------------------------------------------------------------------+
-*/
-
-int i_APCI1516_StartStopWriteWatchdog(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data) 
-{
-   switch(data[0])
-      {
-       case 0://stop the watchdog
-                outw(0x0,devpriv->i_IobaseAddon+ APCI1516_WATCHDOG_ENABLEDISABLE);//disable the watchdog
-                break;
-       case 1://start the watchdog
-               outw(0x0001,devpriv->i_IobaseAddon+ APCI1516_WATCHDOG_ENABLEDISABLE);
-               break;
-       case 2://Software trigger  
-              outw(0x0201,devpriv->i_IobaseAddon+ APCI1516_WATCHDOG_ENABLEDISABLE);
-              break;
-       default:printk("\nSpecified functionality does not exist\n");
-              return -EINVAL;
-       }// switch(data[0])        
-return insn->n;
-}
-/*
-+----------------------------------------------------------------------------+
-| Function   Name   : int i_APCI1516_ReadWatchdog                            |
-|                      (comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,
-                    lsampl_t *data);                                        |
-+----------------------------------------------------------------------------+
-| Task              : Read The Watchdog                                      |
-+----------------------------------------------------------------------------+
-| Input Parameters  :   comedi_device *dev      : Driver handle              |
-|                     comedi_subdevice *s,   :pointer to subdevice structure
-                      comedi_insn *insn      :pointer to insn structure      |
-|                     lsampl_t *data          : Data Pointer to read status  |
-+----------------------------------------------------------------------------+
-| Output Parameters :  --                                                                                                       |
-+----------------------------------------------------------------------------+
-| Return Value      : TRUE  : No error occur                                 |
-|                          : FALSE : Error occur. Return the error          |
-|                                                                               |
-+----------------------------------------------------------------------------+
-*/
-
-int i_APCI1516_ReadWatchdog(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data)
- {
- data[0]= inw(devpriv->i_IobaseAddon+APCI1516_WATCHDOG_STATUS)&0x1; 
-return insn->n;
-}
-/*
-+----------------------------------------------------------------------------+
-| Function   Name   : int i_APCI1516_Reset(comedi_device *dev)               |                                                                                                          |
-+----------------------------------------------------------------------------+
-| Task              :resets all the registers                                |
-+----------------------------------------------------------------------------+
-| Input Parameters  : comedi_device *dev
-+----------------------------------------------------------------------------+
-| Output Parameters :  --                                                                                                       |
-+----------------------------------------------------------------------------+
-| Return Value      :                                                        |
-|                                                                               |
-+----------------------------------------------------------------------------+
-*/
-         
-INT i_APCI1516_Reset(comedi_device *dev) 
-{
-  outw(0x0 ,devpriv->iobase+APCI1516_DIGITAL_OP);//RESETS THE DIGITAL OUTPUTS
-  outw(0x0,devpriv->i_IobaseAddon+ APCI1516_WATCHDOG_ENABLEDISABLE);
- outw(0x0,devpriv->i_IobaseAddon+APCI1516_WATCHDOG_RELOAD_VALUE);
- outw(0x0,devpriv->i_IobaseAddon+APCI1516_WATCHDOG_RELOAD_VALUE+2);
-  return 0;
-}        
-
-
+\r
+/*\r
++----------------------------------------------------------------------------+\r
+| Function   Name   : int i_APCI1516_Read1DigitalInput                       |\r
+|                        (comedi_device *dev,comedi_subdevice *s,               |\r
+|                      comedi_insn *insn,lsampl_t *data)                     |\r
++----------------------------------------------------------------------------+\r
+| Task              : Return the status of the digital input                 |\r
++----------------------------------------------------------------------------+\r
+| Input Parameters  : comedi_device *dev      : Driver handle                |\r
+|                     comedi_subdevice *s,   :pointer to subdevice structure\r
+                       comedi_insn *insn      :pointer to insn structure     |\r
+|                     lsampl_t *data          : Data Pointer to read status  |\r
++----------------------------------------------------------------------------+\r
+| Output Parameters :  --                                                                                                       |\r
++----------------------------------------------------------------------------+\r
+| Return Value      : TRUE  : No error occur                                 |\r
+|                          : FALSE : Error occur. Return the error          |\r
+|                                                                               |\r
++----------------------------------------------------------------------------+\r
+*/\r
+INT i_APCI1516_Read1DigitalInput(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data)\r
+{\r
+   UINT ui_TmpValue=0;\r
+   UINT ui_Channel;\r
+   ui_Channel=CR_CHAN(insn->chanspec);\r
+   if  (ui_Channel >= 0 && ui_Channel <=7)\r
+      {\r
+      ui_TmpValue=(UINT) inw(devpriv->iobase + APCI1516_DIGITAL_IP);\r
+      //  since only 1 channel reqd  to bring it to last bit it is rotated \r
+      //  8 +(chan - 1) times then ANDed with 1 for last bit. \r
+      *data = (ui_TmpValue >> ui_Channel)&0x1 ;\r
+      }//if(ui_Channel >= 0 && ui_Channel <=7)\r
+   else \r
+      {\r
+      //comedi_error(dev," \n chan spec wrong\n");\r
+      return -EINVAL;   // "sorry channel spec wrong "\r
+      }//else if(ui_Channel >= 0 && ui_Channel <=7)\r
+\r
+  return insn->n;\r
+}\r
+\r
+/*\r
++----------------------------------------------------------------------------+\r
+| Function   Name   : int i_APCI1516_ReadMoreDigitalInput                    |\r
+|                        (comedi_device *dev,comedi_subdevice *s,               |\r
+|                     comedi_insn *insn,lsampl_t *data)                      |\r
++----------------------------------------------------------------------------+\r
+| Task              : Return the status of the Requested digital inputs      |\r
++----------------------------------------------------------------------------+\r
+| Input Parameters  : comedi_device *dev      : Driver handle                |\r
+|                      comedi_subdevice *s,   :pointer to subdevice structure\r
+                       comedi_insn *insn      :pointer to insn structure     |\r
+|                      lsampl_t *data         : Data Pointer to read status  |\r
++----------------------------------------------------------------------------+\r
+| Output Parameters :  --                                                                                                       |\r
++----------------------------------------------------------------------------+\r
+| Return Value      : TRUE  : No error occur                                 |\r
+|                          : FALSE : Error occur. Return the error          |\r
+|                                                                               |\r
++----------------------------------------------------------------------------+\r
+*/\r
+\r
+INT i_APCI1516_ReadMoreDigitalInput(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data)\r
+{\r
\r
+   UINT ui_PortValue=data[0];\r
+   UINT ui_Mask=0;\r
+   UINT ui_NoOfChannels;\r
+   \r
+   ui_NoOfChannels=CR_CHAN(insn->chanspec);\r
+   \r
+      *data=(UINT)inw(devpriv->iobase + APCI1516_DIGITAL_IP );\r
+      switch (ui_NoOfChannels)\r
+       {\r
+        case 2:ui_Mask=3;\r
+               *data=(*data >>(2*ui_PortValue))&ui_Mask; \r
+               break;\r
+        case 4:ui_Mask=15;\r
+               *data=(*data >>(4*ui_PortValue))&ui_Mask; \r
+              break;\r
+        case 7:break;\r
+        \r
+        default:\r
+               printk("\nWrong parameters\n");\r
+               return -EINVAL;   // "sorry channel spec wrong "  \r
+                break;\r
+        }//switch(ui_NoOfChannels)\r
+      \r
+  \r
+   return insn->n;\r
+}\r
+\r
+/*\r
++----------------------------------------------------------------------------+\r
+| Function   Name   : int i_APCI1516_ConfigDigitalOutput (comedi_device *dev,\r
+                    comedi_subdevice *s comedi_insn *insn,lsampl_t *data)    |\r
+|                                                                                   |\r
++----------------------------------------------------------------------------+\r
+| Task              : Configures The Digital Output Subdevice.               |\r
++----------------------------------------------------------------------------+\r
+| Input Parameters  : comedi_device *dev : Driver handle                     |\r
+|                     lsampl_t *data         : Data Pointer contains         |\r
+|                                          configuration parameters as below |\r
+|                      comedi_subdevice *s,   :pointer to subdevice structure\r
+                       comedi_insn *insn      :pointer to insn structure                                                           | \r
+|                                        data[0]  :1:Memory on                          | \r
+|                                                  0:Memory off                         |      \r
+|                                                                                                           | \r
+|                                                                                                                                       |\r
++----------------------------------------------------------------------------+\r
+| Output Parameters :  --                                                                                                       |\r
++----------------------------------------------------------------------------+\r
+| Return Value      : TRUE  : No error occur                                 |\r
+|                          : FALSE : Error occur. Return the error          |\r
+|                                                                               |\r
++----------------------------------------------------------------------------+\r
+*/\r
+int i_APCI1516_ConfigDigitalOutput(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data){\r
+ devpriv->b_OutputMemoryStatus=data[0];\r
+return insn->n;\r
+}\r
+\r
+/*\r
++----------------------------------------------------------------------------+\r
+| Function   Name   : int i_APCI1516_WriteDigitalOutput                      |\r
+|                      (comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,\r
+                     lsampl_t *data)                                         |\r
++----------------------------------------------------------------------------+\r
+| Task              : Writes port value  To the selected port                |\r
++----------------------------------------------------------------------------+\r
+| Input Parameters  : comedi_device *dev      : Driver handle                |\r
+|                     comedi_subdevice *s,   :pointer to subdevice structure\r
+                      comedi_insn *insn      :pointer to insn structure      |\r
+|                    lsampl_t *data           : Data Pointer to read status  |\r
++----------------------------------------------------------------------------+\r
+| Output Parameters :  --                                                                                                       |\r
++----------------------------------------------------------------------------+\r
+| Return Value      : TRUE  : No error occur                                 |\r
+|                          : FALSE : Error occur. Return the error          |\r
+|                                                                               |\r
++----------------------------------------------------------------------------+\r
+*/\r
+\r
+INT i_APCI1516_WriteDigitalOutput(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data) \r
+{\r
+UINT ui_Temp,ui_Temp1;\r
+UINT ui_NoOfChannel = CR_CHAN(insn->chanspec); // get the channel\r
+\r
+printk("EL311003 : @=%x\n",devpriv->iobase+APCI1516_DIGITAL_OP); \r
+\r
+ if(devpriv->b_OutputMemoryStatus )\r
+   {\r
+   ui_Temp=inw(devpriv->iobase+APCI1516_DIGITAL_OP);\r
\r
+   }//if(devpriv->b_OutputMemoryStatus )\r
+ else\r
+   {\r
+   ui_Temp=0;\r
+    }//if(devpriv->b_OutputMemoryStatus )\r
+if(data[3]==0)\r
+  { \r
+  if(data[1]==0)\r
+    {\r
+     data[0]=(data[0] << ui_NoOfChannel)|ui_Temp;\r
+     outw(data[0],devpriv->iobase+APCI1516_DIGITAL_OP); \r
+     \r
+     printk("EL311003 : d=%d @=%x\n",data[0],devpriv->iobase+APCI1516_DIGITAL_OP); \r
+     \r
+    }//if(data[1]==0) \r
+  else\r
+    {\r
+    if(data[1]==1)\r
+       { \r
+       switch( ui_NoOfChannel)\r
+        {\r
+\r
+        case 2: data[0]=(data[0] << (2*data[2]))|ui_Temp; \r
+              break;\r
+\r
+\r
+        case 4:data[0]=(data[0] << (4*data[2]))|ui_Temp;\r
+              break;\r
+\r
+        case 7:data[0]=data[0]|ui_Temp; \r
+              break;\r
+\r
+         default:\r
+                 comedi_error(dev," chan spec wrong");\r
+                 return -EINVAL;   // "sorry channel spec wrong "  \r
+                \r
+\r
+         }//switch(ui_NoOfChannels)\r
+   \r
+     outw(data[0],devpriv->iobase+APCI1516_DIGITAL_OP);\r
+     \r
+     printk("EL311003 : d=%d @=%x\n",data[0],devpriv->iobase+APCI1516_DIGITAL_OP); \r
+     }// if(data[1]==1)\r
+   else\r
+     {\r
+     printk("\nSpecified channel not supported\n");\r
+     }//else if(data[1]==1)\r
+   }//elseif(data[1]==0)\r
+ }//if(data[3]==0)\r
+else\r
+   {\r
+    if(data[3]==1)\r
+       {\r
+        if(data[1]==0)\r
+          {\r
+          data[0]=~data[0]&0x1;\r
+          ui_Temp1=1;\r
+          ui_Temp1=ui_Temp1<<ui_NoOfChannel;\r
+          ui_Temp=ui_Temp|ui_Temp1;  \r
+          data[0]=(data[0] << ui_NoOfChannel)^0xff;\r
+          data[0]=data[0]& ui_Temp; \r
+          outw(data[0],devpriv->iobase+APCI1516_DIGITAL_OP); \r
+          \r
+          printk("EL311003 : d=%d @=%x\n",data[0],devpriv->iobase+APCI1516_DIGITAL_OP); \r
+          \r
+          }//if(data[1]==0) \r
+        else\r
+          {\r
+          if(data[1]==1)\r
+             { \r
+             switch( ui_NoOfChannel)\r
+              {\r
+\r
+              case 2: data[0]=~data[0]&0x3; \r
+                       ui_Temp1=3;\r
+                       ui_Temp1=ui_Temp1<<2*data[2];\r
+                       ui_Temp=ui_Temp|ui_Temp1;   \r
+                       data[0]=((data[0] << (2*data[2]))^0xff)& ui_Temp; \r
+                      break;\r
+\r
+\r
+              case 4:data[0]=~data[0]&0xf;\r
+                      ui_Temp1=15;\r
+                      ui_Temp1=ui_Temp1<<4*data[2];\r
+                      ui_Temp=ui_Temp|ui_Temp1;    \r
+                      data[0]=((data[0] << (4*data[2]))^0xff)&ui_Temp;\r
+                     break;\r
+\r
+              case 7: break;\r
+\r
+               default:\r
+                     comedi_error(dev," chan spec wrong");\r
+                     return -EINVAL;   // "sorry channel spec wrong "  \r
+                \r
+\r
+              }//switch(ui_NoOfChannels)\r
+   \r
+            outw(data[0],devpriv->iobase+APCI1516_DIGITAL_OP);\r
+            \r
+            printk("EL311003 : d=%d @=%x\n",data[0],devpriv->iobase+APCI1516_DIGITAL_OP); \r
+            }// if(data[1]==1)\r
+         else\r
+           {\r
+            printk("\nSpecified channel not supported\n");\r
+           }//else if(data[1]==1)\r
+         }//elseif(data[1]==0)\r
+      }//if(data[3]==1);\r
+   else\r
+      {\r
+       printk("\nSpecified functionality does not exist\n");\r
+       return -EINVAL;\r
+      }//if else data[3]==1)\r
+   }//if else data[3]==0) \r
+    return (insn->n);;\r
+}\r
+\r
+\r
+/*\r
++----------------------------------------------------------------------------+\r
+| Function   Name   : int i_APCI1516_ReadDigitalOutput                       |\r
+|                      (comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,\r
+                    lsampl_t *data)                                         |\r
++----------------------------------------------------------------------------+\r
+| Task              : Read  value  of the selected channel or port           |\r
++----------------------------------------------------------------------------+\r
+| Input Parameters  : comedi_device *dev      : Driver handle                |\r
+|                     comedi_subdevice *s,   :pointer to subdevice structure\r
+                      comedi_insn *insn      :pointer to insn structure      |\r
+|                     lsampl_t *data          : Data Pointer to read status  |\r
++----------------------------------------------------------------------------+\r
+| Output Parameters :  --                                                                                                       |\r
++----------------------------------------------------------------------------+\r
+| Return Value      : TRUE  : No error occur                                 |\r
+|                          : FALSE : Error occur. Return the error          |\r
+|                                                                               |\r
++----------------------------------------------------------------------------+\r
+*/\r
+\r
+INT i_APCI1516_ReadDigitalOutput(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data) \r
+{\r
+\r
+UINT ui_Temp;\r
+UINT ui_NoOfChannel = CR_CHAN(insn->chanspec); // get the channel\r
+ui_Temp=data[0];\r
+*data=inw(devpriv->iobase+APCI1516_DIGITAL_OP_RW);\r
+if(ui_Temp==0)\r
+   {\r
+   *data=(*data >> ui_NoOfChannel)&0x1; \r
+   }//if(ui_Temp==0)\r
+else\r
+   {\r
+    if(ui_Temp==1)\r
+       {\r
+       switch( ui_NoOfChannel)\r
+        {\r
+\r
+        case 2:*data=(*data >>(2*data[1]))&3; \r
+               break;\r
+\r
\r
+        case 4:*data=(*data >>(4*data[1]))&15; \r
+              break;\r
+\r
+        case 7: break;\r
\r
+         default:\r
+                 comedi_error(dev," chan spec wrong");\r
+                 return -EINVAL;   // "sorry channel spec wrong "  \r
+          \r
+\r
+         }//switch(ui_NoOfChannels)    \r
+       }//if(ui_Temp==1)\r
+   else\r
+     {\r
+     printk("\nSpecified channel not supported \n");\r
+     }//elseif(ui_Temp==1)\r
+  }//elseif(ui_Temp==0)\r
+return insn->n;\r
+}\r
+\r
+/*\r
++----------------------------------------------------------------------------+\r
+| Function   Name   : int i_APCI1516_ConfigWatchdog(comedi_device *dev,\r
+                      comedi_subdevice *s,comedi_insn *insn,lsampl_t *data)  |\r
+|                                                                                   |\r
++----------------------------------------------------------------------------+\r
+| Task              : Configures The Watchdog                                |\r
++----------------------------------------------------------------------------+\r
+| Input Parameters  :   comedi_device *dev      : Driver handle              |\r
+|                     comedi_subdevice *s,   :pointer to subdevice structure\r
+                      comedi_insn *insn      :pointer to insn structure      |\r
+|                     lsampl_t *data          : Data Pointer to read status                                                     |  \r
++----------------------------------------------------------------------------+\r
+| Output Parameters :  --                                                                                                       |\r
++----------------------------------------------------------------------------+\r
+| Return Value      : TRUE  : No error occur                                 |\r
+|                          : FALSE : Error occur. Return the error          |\r
+|                                                                               |\r
++----------------------------------------------------------------------------+\r
+*/\r
+\r
+int i_APCI1516_ConfigWatchdog(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data)\r
+{\r
+if(data[0]==0)\r
+   {\r
+   //Disable the watchdog\r
+   outw(0x0,devpriv->i_IobaseAddon+ APCI1516_WATCHDOG_ENABLEDISABLE);\r
+   //Loading the Reload value\r
+   outw(data[1],devpriv->i_IobaseAddon+APCI1516_WATCHDOG_RELOAD_VALUE);\r
+   data[1]=data[1]>>16;\r
+   outw(data[1],devpriv->i_IobaseAddon+APCI1516_WATCHDOG_RELOAD_VALUE+2);\r
+   }//if(data[0]==0)\r
+else\r
+   {\r
+     printk("\nThe input parameters are wrong\n");\r
+     return -EINVAL; \r
+   }//elseif(data[0]==0)\r
+\r
+return insn->n;\r
+}\r
+\r
+ /*\r
++----------------------------------------------------------------------------+\r
+| Function   Name   : int i_APCI1516_StartStopWriteWatchdog                  |\r
+|                              (comedi_device *dev,comedi_subdevice *s,\r
+                     comedi_insn *insn,lsampl_t *data);                      |\r
++----------------------------------------------------------------------------+\r
+| Task              : Start / Stop The Watchdog                              |\r
++----------------------------------------------------------------------------+\r
+| Input Parameters  : comedi_device *dev      : Driver handle                |\r
+|                     comedi_subdevice *s,   :pointer to subdevice structure\r
+                      comedi_insn *insn      :pointer to insn structure      |\r
+|                     lsampl_t *data          : Data Pointer to read status  |\r
++----------------------------------------------------------------------------+\r
+| Output Parameters :  --                                                                                                       |\r
++----------------------------------------------------------------------------+\r
+| Return Value      : TRUE  : No error occur                                 |\r
+|                          : FALSE : Error occur. Return the error          |\r
+|                                                                               |\r
++----------------------------------------------------------------------------+\r
+*/\r
+\r
+int i_APCI1516_StartStopWriteWatchdog(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data) \r
+{\r
+   switch(data[0])\r
+      {\r
+       case 0://stop the watchdog\r
+                outw(0x0,devpriv->i_IobaseAddon+ APCI1516_WATCHDOG_ENABLEDISABLE);//disable the watchdog\r
+                break;\r
+       case 1://start the watchdog\r
+               outw(0x0001,devpriv->i_IobaseAddon+ APCI1516_WATCHDOG_ENABLEDISABLE);\r
+               break;\r
+       case 2://Software trigger  \r
+              outw(0x0201,devpriv->i_IobaseAddon+ APCI1516_WATCHDOG_ENABLEDISABLE);\r
+              break;\r
+       default:printk("\nSpecified functionality does not exist\n");\r
+              return -EINVAL;\r
+       }// switch(data[0])        \r
+return insn->n;\r
+}\r
+/*\r
++----------------------------------------------------------------------------+\r
+| Function   Name   : int i_APCI1516_ReadWatchdog                            |\r
+|                      (comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,\r
+                    lsampl_t *data);                                        |\r
++----------------------------------------------------------------------------+\r
+| Task              : Read The Watchdog                                      |\r
++----------------------------------------------------------------------------+\r
+| Input Parameters  :   comedi_device *dev      : Driver handle              |\r
+|                     comedi_subdevice *s,   :pointer to subdevice structure\r
+                      comedi_insn *insn      :pointer to insn structure      |\r
+|                     lsampl_t *data          : Data Pointer to read status  |\r
++----------------------------------------------------------------------------+\r
+| Output Parameters :  --                                                                                                       |\r
++----------------------------------------------------------------------------+\r
+| Return Value      : TRUE  : No error occur                                 |\r
+|                          : FALSE : Error occur. Return the error          |\r
+|                                                                               |\r
++----------------------------------------------------------------------------+\r
+*/\r
+\r
+int i_APCI1516_ReadWatchdog(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data)\r
+ {\r
+ data[0]= inw(devpriv->i_IobaseAddon+APCI1516_WATCHDOG_STATUS)&0x1; \r
+return insn->n;\r
+}\r
+/*\r
++----------------------------------------------------------------------------+\r
+| Function   Name   : int i_APCI1516_Reset(comedi_device *dev)               |                                                                                                          |\r
++----------------------------------------------------------------------------+\r
+| Task              :resets all the registers                                |\r
++----------------------------------------------------------------------------+\r
+| Input Parameters  : comedi_device *dev\r
++----------------------------------------------------------------------------+\r
+| Output Parameters :  --                                                                                                       |\r
++----------------------------------------------------------------------------+\r
+| Return Value      :                                                        |\r
+|                                                                               |\r
++----------------------------------------------------------------------------+\r
+*/\r
+         \r
+INT i_APCI1516_Reset(comedi_device *dev) \r
+{\r
+  outw(0x0 ,devpriv->iobase+APCI1516_DIGITAL_OP);//RESETS THE DIGITAL OUTPUTS\r
+  outw(0x0,devpriv->i_IobaseAddon+ APCI1516_WATCHDOG_ENABLEDISABLE);\r
+ outw(0x0,devpriv->i_IobaseAddon+APCI1516_WATCHDOG_RELOAD_VALUE);\r
+ outw(0x0,devpriv->i_IobaseAddon+APCI1516_WATCHDOG_RELOAD_VALUE+2);\r
+  return 0;\r
+}        \r
+\r
+\r
index 28c6f1f11bee1f761ef8c85266aa3056cfd22f33..e2888605d548acf32c6a6633c53531c32322efa4 100644 (file)
@@ -1,10 +1,34 @@
+/**\r
+@verbatim\r
+\r
+Copyright (C) 2004,2005  ADDI-DATA GmbH for the source code of this module. \r
+        \r
+        ADDI-DATA GmbH \r
+        Dieselstrasse 3 \r
+        D-77833 Ottersweier \r
+        Tel: +19(0)7223/9493-0 \r
+        Fax: +49(0)7223/9493-92 \r
+        http://www.addi-data-com \r
+        info@addi-data.com \r
+\r
+This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.\r
+\r
+This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.\r
+\r
+You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+\r
+You shoud also find the complete GPL in the COPYING file accompanying this source code.\r
+\r
+@endverbatim\r
+*/\r
+\r
 /*********      Definitions for APCI-1516 card  *****/\r
 \r
-// Card Specific information
-#define APCI1516_BOARD_VENDOR_ID                 0x15B8
-#define APCI1516_ADDRESS_RANGE                   8
-
-
+// Card Specific information\r
+#define APCI1516_BOARD_VENDOR_ID                 0x15B8\r
+#define APCI1516_ADDRESS_RANGE                   8\r
+\r
+\r
 //DIGITAL INPUT-OUTPUT DEFINE   \r
 \r
 #define APCI1516_DIGITAL_OP                    4 \r
@@ -12,7 +36,7 @@
 #define APCI1516_DIGITAL_IP                     0  \r
 \r
 \r
-
+\r
 \r
 // TIMER COUNTER WATCHDOG DEFINES  \r
 \r
 \r
 \r
 //Digital Input\r
-INT i_APCI1516_ReadMoreDigitalInput(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data);
+INT i_APCI1516_ReadMoreDigitalInput(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data);\r
 INT i_APCI1516_Read1DigitalInput(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data);\r
 \r
-
 \r
 \r
-//Digital Output
-int i_APCI1516_ConfigDigitalOutput(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data);
-INT i_APCI1516_WriteDigitalOutput(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data);
-INT i_APCI1516_ReadDigitalOutput(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data) ;
+\r
+//Digital Output\r
+int i_APCI1516_ConfigDigitalOutput(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data);\r
+INT i_APCI1516_WriteDigitalOutput(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data);\r
+INT i_APCI1516_ReadDigitalOutput(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data) ;\r
 \r
 \r
 // TIMER  \r
 // timer value is passed as u seconds\r
-int i_APCI1516_ConfigWatchdog(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data); 
+int i_APCI1516_ConfigWatchdog(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data); \r
 int i_APCI1516_StartStopWriteWatchdog(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data); \r
-int i_APCI1516_ReadWatchdog(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data);
-
-
-//reset
-INT i_APCI1516_Reset(comedi_device *dev); 
-
+int i_APCI1516_ReadWatchdog(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data);\r
+\r
+\r
+//reset\r
+INT i_APCI1516_Reset(comedi_device *dev); \r
+\r
index b4a55f23e48b3c173553e90f9f32179df6fcb3b9..28a62e7aee5519a0592373b86b0a4d46a2e9f5ba 100644 (file)
@@ -1,14 +1,38 @@
+/**\r
+@verbatim\r
+\r
+Copyright (C) 2004,2005  ADDI-DATA GmbH for the source code of this module. \r
+        \r
+        ADDI-DATA GmbH \r
+        Dieselstrasse 3 \r
+        D-77833 Ottersweier \r
+        Tel: +19(0)7223/9493-0 \r
+        Fax: +49(0)7223/9493-92 \r
+        http://www.addi-data-com \r
+        info@addi-data.com \r
+\r
+This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.\r
+\r
+This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.\r
+\r
+You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+\r
+You shoud also find the complete GPL in the COPYING file accompanying this source code.\r
+\r
+@endverbatim\r
+*/\r
 /*\r
+    \r
   +-----------------------------------------------------------------------+\r
   | (C) ADDI-DATA GmbH          Dieselstraße 3       D-77833 Ottersweier  |\r
   +-----------------------------------------------------------------------+\r
   | Tel : +49 (0) 7223/9493-0     | email    : info@addi-data.com         |\r
   | Fax : +49 (0) 7223/9493-92    | Internet : http://www.addi-data.com   |\r
   +-------------------------------+---------------------------------------+\r
-  | Project     : 13Card Linux Driver | Compiler   : GCC                  |\r
-  | Module name : hwdrv_apci1564.c|     Version    : 2.96                 |\r
+  | Project     : APCI-1564       | Compiler   : GCC                      |\r
+  | Module name : hwdrv_apci1564.c| Version    : 2.96                     |\r
   +-------------------------------+---------------------------------------+\r
-  | Author : Shitalkumar S Chavan |     Date       : 31.10.2001           |\r
+  | Project manager: Eric Stolz   | Date       :  02/12/2002              |\r
   +-------------------------------+---------------------------------------+\r
   | Description :   Hardware Layer Acces For APCI-1564                    |\r
   +-----------------------------------------------------------------------+\r
 |                               Included files                               |\r
 +----------------------------------------------------------------------------+\r
 */\r
-
-#include <linux/delay.h>
-#include "hwdrv_apci1564.h"
-
-//Global variables
-UINT ui_InterruptStatus_1564=0 ;
-UINT ui_InterruptData,ui_Type;
-
-/*
-+----------------------------------------------------------------------------+
-| Function   Name   : int i_APCI1564_ConfigDigitalInput                      |
-|                        (comedi_device *dev,comedi_subdevice *s,               | 
-|                      comedi_insn *insn,lsampl_t *data)                     |
-+----------------------------------------------------------------------------+
-| Task              : Configures the digital input Subdevice                 |
-+----------------------------------------------------------------------------+
-| Input Parameters  : comedi_device *dev : Driver handle                     |
-|                     lsampl_t *data         : Data Pointer contains         |
-|                                          configuration parameters as below |
-|                                                                            | 
-|                        data[0]            : 1 Enable  Digital Input Interrupt |      
-|                                                                 0 Disable Digital Input Interrupt | 
-|                        data[1]            : 0 ADDIDATA Interrupt OR LOGIC     | 
-|                                                               : 1 ADDIDATA Interrupt AND LOGIC    | 
-|                        data[2]                        : Interrupt mask for the mode 1         | 
-|                        data[3]                        : Interrupt mask for the mode 2         |
-|                                                                                                                                       |
-+----------------------------------------------------------------------------+
-| Output Parameters :  --                                                                                                       |
-+----------------------------------------------------------------------------+
-| Return Value      : TRUE  : No error occur                                 |
-|                          : FALSE : Error occur. Return the error          |
-|                                                                               |
-+----------------------------------------------------------------------------+
-*/
-INT i_APCI1564_ConfigDigitalInput(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data) 
-{
-   devpriv->tsk_Current=current;
-   /*******************************/
-   /* Set the digital input logic */
-   /*******************************/
-   if  ( data[0] == ADDIDATA_ENABLE)
-      {
-      data[2]=data[2]<<4;
-      data[3]=data[3]<<4;
-      outl (data[2] , devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP + APCI1564_DIGITAL_IP_INTERRUPT_MODE1);
-      outl (data[3] , devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP + APCI1564_DIGITAL_IP_INTERRUPT_MODE2);
-      if  (data[1] == ADDIDATA_OR)
-         {
-         outl(0x4 ,devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP + APCI1564_DIGITAL_IP_IRQ);
-         } // if  (data[1] == ADDIDATA_OR)
-      else
-         { 
-         outl(0x6 ,devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP + APCI1564_DIGITAL_IP_IRQ);
-         } // else if  (data[1] == ADDIDATA_OR)
-      } // if  (data[0] == ADDIDATA_ENABLE)
-   else
-      {
-      outl (0x0, devpriv->i_IobaseAmcc +APCI1564_DIGITAL_IP +APCI1564_DIGITAL_IP_INTERRUPT_MODE1);
-      outl (0x0, devpriv->i_IobaseAmcc +APCI1564_DIGITAL_IP +APCI1564_DIGITAL_IP_INTERRUPT_MODE2);
-      outl(0x0 ,devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP +APCI1564_DIGITAL_IP_IRQ);
-      } // else if  (data[0] == ADDIDATA_ENABLE)
-  
-   return insn->n;
-}
-
-/*
-+----------------------------------------------------------------------------+
-| Function   Name   : int i_APCI1564_Read1DigitalInput                       |
-|                        (comedi_device *dev,comedi_subdevice *s,               |
-|                      comedi_insn *insn,lsampl_t *data)                     |
-+----------------------------------------------------------------------------+
-| Task              : Return the status of the digital input                 |
-+----------------------------------------------------------------------------+
-| Input Parameters  : comedi_device *dev      : Driver handle                |
-|                            UINT ui_Channel : Channel number to read       |
-|                     lsampl_t *data          : Data Pointer to read status  |
-+----------------------------------------------------------------------------+
-| Output Parameters :  --                                                                                                       |
-+----------------------------------------------------------------------------+
-| Return Value      : TRUE  : No error occur                                 |
-|                          : FALSE : Error occur. Return the error          |
-|                                                                               |
-+----------------------------------------------------------------------------+
-*/
-INT i_APCI1564_Read1DigitalInput(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data)
-{
-   UINT ui_TmpValue=0;
-   UINT ui_Channel;
-   
-   ui_Channel=CR_CHAN(insn->chanspec);
-   if  (ui_Channel >= 0 && ui_Channel <=31)
-      {
-      ui_TmpValue=(UINT) inl(devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP );
-      //  since only 1 channel reqd  to bring it to last bit it is rotated 
-      //  8 +(chan - 1) times then ANDed with 1 for last bit. 
-      *data = (ui_TmpValue >> ui_Channel)&0x1 ;
-      } // if  (ui_Channel >= 0 && ui_Channel <=31)
-   else 
-      {
-      comedi_error(dev,"Not a valid channel number !!! \n");  
-      return -EINVAL;   // "sorry channel spec wrong "
-      }  //else if  (ui_Channel >= 0 && ui_Channel <=31)
-   return insn->n;
-}
-
-/*
-+----------------------------------------------------------------------------+
-| Function   Name   : int i_APCI1564_ReadMoreDigitalInput                    |
-|                        (comedi_device *dev,comedi_subdevice *s,               |
-|                     comedi_insn *insn,lsampl_t *data)                      |
-+----------------------------------------------------------------------------+
-| Task              : Return the status of the Requested digital inputs      |
-+----------------------------------------------------------------------------+
-| Input Parameters  : comedi_device *dev      : Driver handle                |
-|                     UINT ui_NoOfChannels    : No Of Channels To be Read    |
-|                      UINT *data             : Data Pointer to read status  |
-+----------------------------------------------------------------------------+
-| Output Parameters :  --                                                                                                       |
-+----------------------------------------------------------------------------+
-| Return Value      : TRUE  : No error occur                                 |
-|                          : FALSE : Error occur. Return the error          |
-|                                                                               |
-+----------------------------------------------------------------------------+
-*/
-INT i_APCI1564_ReadMoreDigitalInput(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data)
-{
-   UINT ui_PortValue=data[0];
-   UINT ui_Mask=0;
-   UINT ui_NoOfChannels;
-   
-   ui_NoOfChannels=CR_CHAN(insn->chanspec);
-   if  (data[1]==0)
-      {
-      *data=(UINT)inl(devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP );
-      switch (ui_NoOfChannels)
-        {
-        case 2: ui_Mask=3;
-                 *data=(*data >>(2*ui_PortValue))&ui_Mask; 
-                 break;
-        case 4: ui_Mask=15;
-                 *data=(*data >>(4*ui_PortValue))&ui_Mask; 
-                break;
-        case 8: ui_Mask=255;
-                *data=(*data >>(8*ui_PortValue))&ui_Mask;  
-                 break;
-         case 16:ui_Mask=65535;
-                 *data=(*data >>(16*ui_PortValue))&ui_Mask;
-                 break;
-         case 31:break;
-         default:
-                comedi_error(dev,"Not a valid Channel number !!!\n");  
-               return -EINVAL;   // "sorry channel spec wrong "  
-                break;
-         } // switch  (ui_NoOfChannels)
-      } // if  (data[1]==0)
-   else
-      {
-      if  (data[1]==1)
-         {
-         *data=ui_InterruptStatus_1564;
-         } // if  (data[1]==1)
-      } // else if  (data[1]==0)   
-   return insn->n;
-}
-
-/*
-+----------------------------------------------------------------------------+
-| Function   Name   : int i_APCI1564_ConfigDigitalOutput                     |
-|                        (comedi_device *dev,comedi_subdevice *s,               | 
-|                      comedi_insn *insn,lsampl_t *data)                     |
-+----------------------------------------------------------------------------+
-| Task              : Configures The Digital Output Subdevice.               |
-+----------------------------------------------------------------------------+
-| Input Parameters  : comedi_device *dev : Driver handle                     |
-|                     UINT *data         : Data Pointer contains             |
-|                                          configuration parameters as below |
-|                                                                            | 
-|                                        data[1]            : 1 Enable  VCC  Interrupt  |      
-|                                                                                 0 Disable VCC  Interrupt  | 
-|                                        data[2]            : 1 Enable  CC  Interrupt   |      
-|                                                                                 0 Disable CC  Interrupt   | 
-|                                                                                                                                       |
-+----------------------------------------------------------------------------+
-| Output Parameters :  --                                                                                                       |
-+----------------------------------------------------------------------------+
-| Return Value      : TRUE  : No error occur                                 |
-|                          : FALSE : Error occur. Return the error          |
-|                                                                               |
-+----------------------------------------------------------------------------+
-*/
-INT i_APCI1564_ConfigDigitalOutput(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data)
-{
-   ULONG  ul_Command = 0; 
-  
-   if  ((data[0]!=0) && (data[0]!=1)) 
-      {   
-      comedi_error(dev,"Not a valid Data !!! ,Data should be 1 or 0\n");  
-      return -EINVAL;
-      } // if  ((data[0]!=0) && (data[0]!=1)) 
-   if  (data[0])
-      {
-      devpriv->b_OutputMemoryStatus = ADDIDATA_ENABLE ; 
-      } // if  (data[0])
-   else
-      {
-      devpriv->b_OutputMemoryStatus = ADDIDATA_DISABLE;
-      } // else if  (data[0])
-   if  (data[1] == ADDIDATA_ENABLE)
-      {
-      ul_Command = ul_Command | 0x1;
-      } // if  (data[1] == ADDIDATA_ENABLE)
-   else
-      {
-      ul_Command = ul_Command & 0xFFFFFFFE;
-      } // else if  (data[1] == ADDIDATA_ENABLE)
-   if  (data[2] == ADDIDATA_ENABLE)
-      {
-      ul_Command = ul_Command | 0x2;
-      } // if  (data[2] == ADDIDATA_ENABLE)
-   else
-      {
-      ul_Command = ul_Command & 0xFFFFFFFD;
-      } // else if  (data[2] == ADDIDATA_ENABLE)
-   outl( ul_Command , devpriv->i_IobaseAmcc+APCI1564_DIGITAL_OP+APCI1564_DIGITAL_OP_INTERRUPT);
-   ui_InterruptData=inl( devpriv->i_IobaseAmcc+APCI1564_DIGITAL_OP+APCI1564_DIGITAL_OP_INTERRUPT); 
-   devpriv->tsk_Current=current;  
-   return insn->n;
-}
-
-/*
-+----------------------------------------------------------------------------+
-| Function   Name   : int i_APCI1564_WriteDigitalOutput                      |
-|                        (comedi_device *dev,comedi_subdevice *s,               | 
-|                      comedi_insn *insn,lsampl_t *data)                     |
-+----------------------------------------------------------------------------+
-| Task              : Writes port value  To the selected port                |
-+----------------------------------------------------------------------------+
-| Input Parameters  : comedi_device *dev      : Driver handle                |
-|                     UINT ui_NoOfChannels    : No Of Channels To Write      |
-|                     UINT *data              : Data Pointer to read status  |
-+----------------------------------------------------------------------------+
-| Output Parameters :  --                                                                                                       |
-+----------------------------------------------------------------------------+
-| Return Value      : TRUE  : No error occur                                 |
-|                          : FALSE : Error occur. Return the error          |
-|                                                                               |
-+----------------------------------------------------------------------------+
-*/
-INT i_APCI1564_WriteDigitalOutput(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data) {
-   UINT ui_Temp,ui_Temp1;
-   UINT ui_NoOfChannel;
-   
-   ui_NoOfChannel=CR_CHAN(insn->chanspec);
-   if  (devpriv->b_OutputMemoryStatus )
-      {
-      ui_Temp=inl(devpriv->i_IobaseAmcc + APCI1564_DIGITAL_OP + APCI1564_DIGITAL_OP_RW);
-      } // if  (devpriv->b_OutputMemoryStatus )
-   else
-      {
-      ui_Temp=0;
-      } // else if  (devpriv->b_OutputMemoryStatus )
-   if  (data[3]==0)
-      { 
-      if  (data[1]==0)
-         {
-         data[0]=(data[0] << ui_NoOfChannel)|ui_Temp;
-         outl(data[0],devpriv->i_IobaseAmcc + APCI1564_DIGITAL_OP + APCI1564_DIGITAL_OP_RW);  
-         } // if  (data[1]==0) 
-      else
-         {
-         if  (data[1]==1)
-            { 
-            switch (ui_NoOfChannel)
-              {
-               case 2: data[0]=(data[0] << (2*data[2]))|ui_Temp; 
-                      break;
-               case 4: data[0]=(data[0] << (4*data[2]))|ui_Temp;
-                      break;
-               case 8: data[0]=(data[0] <<(8*data[2]))|ui_Temp;  
-                       break;
-               case 16: data[0]=(data[0] <<(16*data[2]))|ui_Temp;
-                        break;
-               case 31: data[0]=data[0]|ui_Temp; 
-                        break;
-               default: comedi_error(dev," chan spec wrong");
-                        return -EINVAL;   // "sorry channel spec wrong "  
-               } // switch (ui_NoOfChannels)
-            outl(data[0],devpriv->i_IobaseAmcc + APCI1564_DIGITAL_OP + APCI1564_DIGITAL_OP_RW);
-            } // if  (data[1]==1)
-         else
-            {
-            printk("\nSpecified channel not supported\n");
-            } // else if  (data[1]==1)
-         } // else if (data[1]==0)
-      }//if(data[3]==0)
-   else
-      {
-      if  (data[3]==1)
-         {
-         if  (data[1]==0)
-            {
-            data[0]=~data[0]&0x1;
-            ui_Temp1=1;
-            ui_Temp1=ui_Temp1<<ui_NoOfChannel;
-            ui_Temp=ui_Temp|ui_Temp1;  
-            data[0]=(data[0] << ui_NoOfChannel)^0xffffffff;
-            data[0]=data[0]& ui_Temp; 
-            outl(data[0],devpriv->i_IobaseAmcc + APCI1564_DIGITAL_OP + APCI1564_DIGITAL_OP_RW);  
-            } // if  (data[1]==0) 
-         else
-            {
-            if  (data[1]==1)
-               { 
-               switch (ui_NoOfChannel)
-                 {
-                 case 2: data[0]=~data[0]&0x3; 
-                          ui_Temp1=3;
-                          ui_Temp1=ui_Temp1<<2*data[2];
-                          ui_Temp=ui_Temp|ui_Temp1;   
-                          data[0]=((data[0] << (2*data[2]))^0xffffffff)& ui_Temp; 
-                         break;
-                 case 4: data[0]=~data[0]&0xf;
-                          ui_Temp1=15;
-                          ui_Temp1=ui_Temp1<<4*data[2];
-                          ui_Temp=ui_Temp|ui_Temp1;    
-                          data[0]=((data[0] << (4*data[2]))^0xffffffff)&ui_Temp;
-                         break;
-                  case 8: data[0]=~data[0]&0xff;
-                          ui_Temp1=255;
-                          ui_Temp1=ui_Temp1<<8*data[2];
-                          ui_Temp=ui_Temp|ui_Temp1;    
-                          data[0]=((data[0] << (8*data[2]))^0xffffffff)&ui_Temp;  
-                         break;
-                  case 16: data[0]=~data[0]&0xffff;
-                           ui_Temp1=65535;
-                           ui_Temp1=ui_Temp1<<16*data[2];
-                           ui_Temp=ui_Temp|ui_Temp1;    
-                           data[0]=((data[0] << (16*data[2]))^0xffffffff)&ui_Temp;  
-                          break;
-                  case 31: break;
-                  default: comedi_error(dev," chan spec wrong");
-                           return -EINVAL;   // "sorry channel spec wrong "  
-                  }//switch(ui_NoOfChannels)
-               outl(data[0],devpriv->i_IobaseAmcc + APCI1564_DIGITAL_OP + APCI1564_DIGITAL_OP_RW);
-               } // if  (data[1]==1)
-            else
-               {
-               printk("\nSpecified channel not supported\n");
-               } // else if  (data[1]==1)
-            } // else if  (data[1]==0)
-         } // if  (data[3]==1);
-      else
-         {
-         printk("\nSpecified functionality does not exist\n");
-         return -EINVAL;
-         } // else if (data[3]==1)
-      } // else if (data[3]==0) 
-   return insn->n;
-}
-
-/*
-+----------------------------------------------------------------------------+
-| Function   Name   : int i_APCI1564_ReadDigitalOutput                       |
-|                        (comedi_device *dev,comedi_subdevice *s,               | 
-|                      comedi_insn *insn,lsampl_t *data)                     |
-+----------------------------------------------------------------------------+
-| Task              : Read  value  of the selected channel or port           |
-+----------------------------------------------------------------------------+
-| Input Parameters  : comedi_device *dev      : Driver handle                |
-|                     UINT ui_NoOfChannels    : No Of Channels To read       |
-|                     UINT *data              : Data Pointer to read status  |
-+----------------------------------------------------------------------------+
-| Output Parameters :  --                                                                                                       |
-+----------------------------------------------------------------------------+
-| Return Value      : TRUE  : No error occur                                 |
-|                          : FALSE : Error occur. Return the error          |
-|                                                                               |
-+----------------------------------------------------------------------------+
-*/
-INT i_APCI1564_ReadDigitalOutput(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data) 
-{
-   UINT ui_Temp;
-   UINT ui_NoOfChannel;
-
-   ui_NoOfChannel=CR_CHAN(insn->chanspec);
-   ui_Temp=data[0];
-   *data=inl(devpriv->i_IobaseAmcc+APCI1564_DIGITAL_OP+APCI1564_DIGITAL_OP_RW);
-   if  (ui_Temp==0)
-      {
-      *data=(*data >> ui_NoOfChannel)&0x1; 
-      } // if  (ui_Temp==0)
-   else
-      {
-      if  (ui_Temp==1)
-         {
-         switch (ui_NoOfChannel)
-          {
-           case 2: 
-                    *data=(*data >>(2*data[1]))&3; 
-                    break;
-
-           case 4: 
-                    *data=(*data >>(4*data[1]))&15; 
-                   break;
-          case 8:  
-                   *data=(*data >>(8*data[1]))&255;  
-                    break;
-           case 16: 
-                    *data=(*data >>(16*data[1]))&65535;
-                    break;
-
-           case 31: break;
-
-           default:
-                   comedi_error(dev," chan spec wrong");
-                   return -EINVAL;   // "sorry channel spec wrong "  
-                    break;
-           } // switch(ui_NoOfChannels)    
-        } // if  (ui_Temp==1)
-     else
-        {
-        printk("\nSpecified channel not supported \n");
-        } // else if (ui_Temp==1)
-     } // else if  (ui_Temp==0)
-   return insn->n;
-}
-
-/*
-+----------------------------------------------------------------------------+
-| Function   Name   : int i_APCI1564_ConfigTimerCounterWatchdog              |
-|                        (comedi_device *dev,comedi_subdevice *s,               | 
-|                      comedi_insn *insn,lsampl_t *data)                     |
-+----------------------------------------------------------------------------+
-| Task              : Configures The Timer , Counter or Watchdog             |
-+----------------------------------------------------------------------------+
-| Input Parameters  : comedi_device *dev : Driver handle                     |
-|                     UINT *data         : Data Pointer contains             |
-|                                          configuration parameters as below |
-|                                                                            | 
-|                                        data[0]            : 0 Configure As Timer      |      
-|                                                                                 1 Configure As Counter    |                            
-|                                                                                 2 Configure As Watchdog   |                            
-|                                        data[1]            : 1 Enable  Interrupt       |      
-|                                                                                 0 Disable Interrupt       |                           
-|                                        data[2]            : Time Unit                 |
-|                                        data[3]                        : Reload Value                      |                            
-|                                        data[4]            : Timer Mode                |                            
-|                                        data[5]                        : Timer Counter Watchdog Number|     
-                              data[6]            :  Counter Direction 
-+----------------------------------------------------------------------------+
-| Output Parameters :  --                                                                                                       |
-+----------------------------------------------------------------------------+
-| Return Value      : TRUE  : No error occur                                 |
-|                          : FALSE : Error occur. Return the error          |
-|                                                                               |
-+----------------------------------------------------------------------------+
-*/
-INT i_APCI1564_ConfigTimerCounterWatchdog (comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data) 
-{
-   ULONG  ul_Command1 = 0; 
-   devpriv->tsk_Current=current;
-   if  (data[0]==ADDIDATA_WATCHDOG)
-      {
-      devpriv->b_TimerSelectMode = ADDIDATA_WATCHDOG;   
-     
-      //Disable the watchdog
-      outl(0x0,devpriv->i_IobaseAmcc+ APCI1564_DIGITAL_OP_WATCHDOG+ APCI1564_TCW_PROG); 
-     //Loading the Reload value
-      outl(data[3],devpriv->i_IobaseAmcc+APCI1564_DIGITAL_OP_WATCHDOG+APCI1564_TCW_RELOAD_VALUE);  
-      } // if  (data[0]==ADDIDATA_WATCHDOG)
-   else if  (data[0]==ADDIDATA_TIMER)
-      {
-      //First Stop The Timer 
-      ul_Command1 =inl(devpriv->i_IobaseAmcc+ APCI1564_TIMER+ APCI1564_TCW_PROG);
-      ul_Command1 =ul_Command1 & 0xFFFFF9FEUL;
-      outl(ul_Command1,devpriv->i_IobaseAmcc+ APCI1564_TIMER+ APCI1564_TCW_PROG);//Stop The Timer
-
-      devpriv->b_TimerSelectMode =ADDIDATA_TIMER;
-      if  (data[1]==1)
-         { 
-         outl(0x02,devpriv->i_IobaseAmcc+ APCI1564_TIMER+ APCI1564_TCW_PROG);//Enable TIMER int & DISABLE ALL THE OTHER int SOURCES
-         outl(0x0,devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP + APCI1564_DIGITAL_IP_IRQ);
-         outl(0x0,devpriv->i_IobaseAmcc + APCI1564_DIGITAL_OP + APCI1564_DIGITAL_OP_IRQ); 
-         outl(0x0,devpriv->i_IobaseAmcc + APCI1564_DIGITAL_OP_WATCHDOG + APCI1564_TCW_IRQ);
-         outl(0x0,devpriv->iobase+APCI1564_COUNTER1 + APCI1564_TCW_IRQ);
-         outl(0x0,devpriv->iobase+APCI1564_COUNTER2 + APCI1564_TCW_IRQ);
-         outl(0x0,devpriv->iobase+APCI1564_COUNTER3 + APCI1564_TCW_IRQ);
-         outl(0x0,devpriv->iobase+APCI1564_COUNTER4 + APCI1564_TCW_IRQ);
-         } // if  (data[1]==1)
-      else
-         { 
-         outl(0x0,devpriv->i_IobaseAmcc+ APCI1564_TIMER+ APCI1564_TCW_PROG);//disable Timer interrupt
-         } // else if  (data[1]==1)
-    
-      // Loading Timebase
-     
-         outl(data[2],devpriv->i_IobaseAmcc+APCI1564_TIMER+APCI1564_TCW_TIMEBASE);
-        
-      //Loading the Reload value
-      outl(data[3],devpriv->i_IobaseAmcc+APCI1564_TIMER+APCI1564_TCW_RELOAD_VALUE);
-    
-      ul_Command1 =inl(devpriv->i_IobaseAmcc+ APCI1564_TIMER+ APCI1564_TCW_PROG);
-      ul_Command1 = (ul_Command1 & 0xFFF719E2UL) |  2UL << 13UL | 0x10UL;
-      outl(ul_Command1,devpriv->i_IobaseAmcc+ APCI1564_TIMER+ APCI1564_TCW_PROG);//mode 2
-      } // else if  (data[0]==ADDIDATA_TIMER)
-   else if  (data[0]==ADDIDATA_COUNTER)
-      {
-      devpriv->b_TimerSelectMode =ADDIDATA_COUNTER;
-      devpriv->b_ModeSelectRegister=data[5];
-
-      //First Stop The Counter
-      ul_Command1 =inl(devpriv->iobase+((data[5]-1)*0x20)+APCI1564_TCW_PROG); 
-      ul_Command1 =ul_Command1 & 0xFFFFF9FEUL;
-      outl(ul_Command1,devpriv->iobase+((data[5]-1)*0x20)+APCI1564_TCW_PROG);//Stop The Timer
-
-      /************************/
-      /* Set the reload value */
-      /************************/
-      outl(data[3] , devpriv->iobase+((data[5]-1)*0x20)+APCI1564_TCW_RELOAD_VALUE);
-      /******************************/
-      /* Set the mode :             */
-      /* - Disable the hardware     */
-      /* - Disable the counter mode */
-      /* - Disable the warning      */
-      /* - Disable the reset        */
-      /* - Disable the timer mode   */
-      /* - Enable the counter mode  */
-      /******************************/
-      ul_Command1 = (ul_Command1 & 0xFFFC19E2UL) | 0x80000UL | (ULONG) ((ULONG) data[4] << 16UL);
-      outl(ul_Command1 , devpriv->iobase+((data[5]-1)*0x20)+APCI1564_TCW_PROG); 
-
-      // Enable or Disable Interrupt 
-      ul_Command1= (ul_Command1 & 0xFFFFF9FD) | (data[1] << 1);                 
-      outl(ul_Command1 , devpriv->iobase+((data[5]-1)*0x20)+APCI1564_TCW_PROG);
-      /*****************************/
-      /* Set the Up/Down selection */
-      /*****************************/
-      ul_Command1 = (ul_Command1 & 0xFFFBF9FFUL) |  (data[6] << 18);
-      outl(ul_Command1 , devpriv->iobase+((data[5]-1)*0x20)+APCI1564_TCW_PROG);  
-      } // else if  (data[0]==ADDIDATA_COUNTER)
-   else   
-      {
-      printk(" Invalid subdevice.");
-      } // else if  (data[0]==ADDIDATA_WATCHDOG) 
-   
-   return insn->n;
-}
-
-/*
-+----------------------------------------------------------------------------+
-| Function   Name   : int i_APCI1564_StartStopWriteTimerCounterWatchdog      |
-|                        (comedi_device *dev,comedi_subdevice *s,               | 
-|                      comedi_insn *insn,lsampl_t *data)                     |
-+----------------------------------------------------------------------------+
-| Task              : Start / Stop The Selected Timer , Counter or Watchdog  |
-+----------------------------------------------------------------------------+
-| Input Parameters  : comedi_device *dev : Driver handle                     |
-|                     UINT *data         : Data Pointer contains             |
-|                                          configuration parameters as below |
-|                                                                            | 
-|                                        data[0]            : 0 Timer                   |
-|                                                                                 1 Counter                 |  
-|                                                                                 2 Watchdog                    |                             |                                                 data[1]            : 1 Start                   |       
-|                                                                                 0 Stop                    |       
-|                                                  2 Trigger                    |      
-|                                                    Clear (Only Counter)    |
-+----------------------------------------------------------------------------+
-| Output Parameters :  --                                                                                                       |
-+----------------------------------------------------------------------------+
-| Return Value      : TRUE  : No error occur                                 |
-|                          : FALSE : Error occur. Return the error          |
-|                                                                               |
-+----------------------------------------------------------------------------+
-*/
-INT i_APCI1564_StartStopWriteTimerCounterWatchdog(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data)
-{
-   ULONG  ul_Command1 = 0; 
-   if  (devpriv->b_TimerSelectMode==ADDIDATA_WATCHDOG)
-      {
-      switch (data[1])
-         {
-         case 0:  //stop the watchdog
-                  outl(0x0,devpriv->i_IobaseAmcc+ APCI1564_DIGITAL_OP_WATCHDOG+ APCI1564_TCW_PROG );//disable the watchdog
-                  break;
-         case 1:  //start the watchdog
-                  outl(0x0001,devpriv->i_IobaseAmcc+ APCI1564_DIGITAL_OP_WATCHDOG+ APCI1564_TCW_PROG);
-                  break;
-         case 2:  //Software trigger  
-                  outl(0x0201,devpriv->i_IobaseAmcc+ APCI1564_DIGITAL_OP_WATCHDOG+ APCI1564_TCW_PROG);
-                  break;
-         default: printk("\nSpecified functionality does not exist\n");
-                 return -EINVAL;
-         }  // switch (data[1])        
-      } // if  (devpriv->b_TimerSelectMode==ADDIDATA_WATCHDOG)   
-   if  (devpriv->b_TimerSelectMode==ADDIDATA_TIMER)
-      {
-      if  (data[1]==1) 
-         { 
-         ul_Command1=inl(devpriv->i_IobaseAmcc+ APCI1564_TIMER+ APCI1564_TCW_PROG);
-         ul_Command1=(ul_Command1& 0xFFFFF9FFUL) | 0x1UL;
-       
-         //Enable the Timer
-         outl(ul_Command1,devpriv->i_IobaseAmcc+ APCI1564_TIMER+ APCI1564_TCW_PROG);
-         } // if  (data[1]==1)
-      else if(data[1]==0)
-         {
-         //Stop The Timer
-          
-         ul_Command1=inl(devpriv->i_IobaseAmcc+ APCI1564_TIMER+ APCI1564_TCW_PROG);
-         ul_Command1 =ul_Command1 & 0xFFFFF9FEUL;
-         outl(ul_Command1,devpriv->i_IobaseAmcc+ APCI1564_TIMER+ APCI1564_TCW_PROG);
-         } // else if(data[1]==0)
-      } // if  (devpriv->b_TimerSelectMode==ADDIDATA_TIMER)
-   if  (devpriv->b_TimerSelectMode==ADDIDATA_COUNTER)
-      {
-      ul_Command1=inl(devpriv->iobase+((devpriv->b_ModeSelectRegister-1)*0x20)+APCI1564_TCW_PROG);
-      if  (data[1] == 1) 
-         {
-         //Start the Counter subdevice 
-         ul_Command1= (ul_Command1 & 0xFFFFF9FFUL) | 0x1UL;
-         } // if  (data[1] == 1)
-      else if (data[1] == 0)
-         {
-         // Stops the Counter subdevice 
-        ul_Command1 = 0;
-         
-         } // else if  (data[1] == 0)
-      else if (data[1] == 2)
-         {
-         // Clears the Counter subdevice
-         ul_Command1= (ul_Command1 & 0xFFFFF9FFUL)|0x400;
-         } // else if  (data[1] == 3)
-      outl(ul_Command1 , devpriv->iobase+((devpriv->b_ModeSelectRegister-1)*0x20)+APCI1564_TCW_PROG);
-      } // if (devpriv->b_TimerSelectMode==ADDIDATA_COUNTER)
-   return insn->n;
-}
-
-/*
-+----------------------------------------------------------------------------+
-| Function   Name   : int i_APCI1564_ReadTimerCounterWatchdog                |
-|                        (comedi_device *dev,comedi_subdevice *s,               | 
-|                      comedi_insn *insn,lsampl_t *data)                     |
-+----------------------------------------------------------------------------+
-| Task              : Read The Selected Timer , Counter or Watchdog          |
-+----------------------------------------------------------------------------+
-| Input Parameters  : comedi_device *dev : Driver handle                     |
-|                     UINT *data         : Data Pointer contains             |
-|                                          configuration parameters as below |
-|                                                                            | 
-                                       
-+----------------------------------------------------------------------------+
-| Output Parameters :  --                                                                                                       |
-+----------------------------------------------------------------------------+
-| Return Value      : TRUE  : No error occur                                 |
-|                          : FALSE : Error occur. Return the error          |
-|                                                                               |
-+----------------------------------------------------------------------------+
-*/
-INT i_APCI1564_ReadTimerCounterWatchdog(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data)
-{
-   ULONG  ul_Command1 = 0; 
-
-   if  (devpriv->b_TimerSelectMode==ADDIDATA_WATCHDOG)
-      { 
-      // Stores the status of the Watchdog 
-      data[0]= inl(devpriv->i_IobaseAmcc + APCI1564_DIGITAL_OP_WATCHDOG + APCI1564_TCW_TRIG_STATUS)&0x1;
-      data[1]= inl(devpriv->i_IobaseAmcc + APCI1564_DIGITAL_OP_WATCHDOG);
-      } // if  (devpriv->b_TimerSelectMode==ADDIDATA_WATCHDOG)
-   else if  (devpriv->b_TimerSelectMode==ADDIDATA_TIMER) 
-      {
-      // Stores the status of the Timer 
-      data[0]= inl(devpriv->i_IobaseAmcc+APCI1564_TIMER+APCI1564_TCW_TRIG_STATUS)&0x1; 
-
-      // Stores the Actual value of the Timer 
-      data[1]= inl(devpriv->i_IobaseAmcc + APCI1564_TIMER); 
-      }  // else if  (devpriv->b_TimerSelectMode==ADDIDATA_TIMER)
-   else  if  (devpriv->b_TimerSelectMode==ADDIDATA_COUNTER) 
-      {
-      // Read the Counter Actual Value. 
-      data[0] = inl(devpriv->iobase+((devpriv->b_ModeSelectRegister-1)*0x20)+APCI1564_TCW_SYNC_ENABLEDISABLE);
-      ul_Command1 =  inl(devpriv->iobase+((devpriv->b_ModeSelectRegister-1)*0x20)+APCI1564_TCW_TRIG_STATUS);
-
-      /***********************************/
-      /* Get the software trigger status */
-      /***********************************/
-      data[1]= (BYTE) ((ul_Command1 >> 1) & 1);
-
-      /***********************************/
-      /* Get the hardware trigger status */
-      /***********************************/
-      data[2]= (BYTE) ((ul_Command1 >> 2) & 1);
-
-      /*********************************/
-      /* Get the software clear status */
-      /*********************************/
-      data[3]= (BYTE) ((ul_Command1 >> 3) & 1);
-
-      /***************************/
-      /* Get the overflow status */
-      /***************************/
-      data[4]= (BYTE) ((ul_Command1 >> 0) & 1);
-      } // else  if  (devpriv->b_TimerSelectMode==ADDIDATA_COUNTER) 
-  else if ((devpriv->b_TimerSelectMode!=ADDIDATA_TIMER) && (devpriv->b_TimerSelectMode!=ADDIDATA_WATCHDOG)&& (devpriv->b_TimerSelectMode!=ADDIDATA_COUNTER))
-     {
-     printk ("\n Invalid Subdevice !!!\n");
-     } // else if ((devpriv->b_TimerSelectMode!=ADDIDATA_TIMER) && (devpriv->b_TimerSelectMode!=ADDIDATA_WATCHDOG)&& (devpriv->b_TimerSelectMode!=ADDIDATA_COUNTER))
-   return insn->n;
-}
-
-/*
-+----------------------------------------------------------------------------+
-| Function   Name   :  int i_APCI1564_ReadInterruptStatus                    |
-|                        (comedi_device *dev,comedi_subdevice *s,               | 
-|                      comedi_insn *insn,lsampl_t *data)                     |
-+----------------------------------------------------------------------------+
-| Task              :Reads the interrupt status register                     |
-+----------------------------------------------------------------------------+
-| Input Parameters  :                                                        |
-+----------------------------------------------------------------------------+
-| Output Parameters :  --                                                                                                       |
-+----------------------------------------------------------------------------+
-| Return Value      :                                                        |
-|                                                                               |
-+----------------------------------------------------------------------------+
-*/
-
-int i_APCI1564_ReadInterruptStatus(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data)
-{  
-    *data=ui_Type;
-    return insn->n;
-} 
-
-/*
-+----------------------------------------------------------------------------+
-| Function   Name   : static void v_APCI1564_Interrupt                                      |
-|                                        (int irq , void *d, struct pt_regs *regs)      |
-+----------------------------------------------------------------------------+
-| Task              : Interrupt handler for the interruptible digital inputs |
-+----------------------------------------------------------------------------+
-| Input Parameters  : int irq                 : irq number                   |
-|                     void *d                 : void pointer                 |
-|                     struct pt_regs *regs    : structure pointer            |
-+----------------------------------------------------------------------------+
-| Output Parameters :  --                                                                                                       |
-+----------------------------------------------------------------------------+
-| Return Value      : TRUE  : No error occur                                 |
-|                          : FALSE : Error occur. Return the error          |
-|                                                                               |
-+----------------------------------------------------------------------------+
-*/
-static VOID v_APCI1564_Interrupt(int irq,void* d, struct pt_regs *regs) 
-{
-   comedi_device *dev =d;      
-   UINT ui_DO, ui_DI;
-   UINT ui_Timer;
-   UINT ui_C1, ui_C2, ui_C3, ui_C4;
-   ULONG ul_Command2=0; 
-   ui_DI       = inl(devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP + APCI1564_DIGITAL_IP_IRQ) & 0x01;
-   ui_DO       = inl(devpriv->i_IobaseAmcc + APCI1564_DIGITAL_OP + APCI1564_DIGITAL_OP_IRQ) & 0x01;
-   ui_Timer    = inl(devpriv->i_IobaseAmcc + APCI1564_TIMER+ APCI1564_TCW_IRQ) & 0x01; 
-   ui_C1=inl(devpriv->iobase + APCI1564_COUNTER1 + APCI1564_TCW_IRQ ) & 0x1;
-   ui_C2=inl(devpriv->iobase + APCI1564_COUNTER2 + APCI1564_TCW_IRQ ) & 0x1;
-   ui_C3=inl(devpriv->iobase + APCI1564_COUNTER3 + APCI1564_TCW_IRQ ) & 0x1;
-   ui_C4=inl(devpriv->iobase + APCI1564_COUNTER4 + APCI1564_TCW_IRQ ) & 0x1;
-  if(ui_DI==0 && ui_DO==0 && ui_Timer==0 && ui_C1==0 && ui_C2==0 && ui_C3==0 && ui_C4==0)
-      {
-       printk("\nInterrupt from unknown source\n");
-      }// if(ui_DI==0 && ui_DO==0 && ui_Timer==0 && ui_C1==0 && ui_C2==0 && ui_C3==0 && ui_C4==0)
-      
-   if  (ui_DI == 1)
-      {
-      ui_DI = inl(devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP + APCI1564_DIGITAL_IP_IRQ);
-      outl(0x0 ,devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP + APCI1564_DIGITAL_IP_IRQ);
-      ui_InterruptStatus_1564=inl(devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP + APCI1564_DIGITAL_IP_INTERRUPT_STATUS);
-      ui_InterruptStatus_1564=ui_InterruptStatus_1564 & 0X000FFFF0;
-      send_sig(SIGIO,devpriv->tsk_Current,0); // send signal to the sample   
-      outl(ui_DI ,devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP + APCI1564_DIGITAL_IP_IRQ);//enable the interrupt
-      return;
-      }
-
-   if  (ui_DO == 1)
-      {
-      // Check for Digital Output interrupt Type - 1: Vcc interrupt 2: CC interrupt.
-      ui_Type=inl(devpriv->i_IobaseAmcc + APCI1564_DIGITAL_OP + APCI1564_DIGITAL_OP_INTERRUPT_STATUS) & 0x3;     
-       //Disable the  Interrupt 
-      outl(0x0,devpriv->i_IobaseAmcc + APCI1564_DIGITAL_OP + APCI1564_DIGITAL_OP_INTERRUPT);
-     
-         //Sends signal to user space 
-        send_sig(SIGIO,devpriv->tsk_Current,0);
-      
-      }  // if  (ui_DO)
-
-   if  ((ui_Timer == 1) && (devpriv->b_TimerSelectMode =ADDIDATA_TIMER))
-      {
-      // Disable Timer Interrupt 
-      ul_Command2=inl(devpriv->i_IobaseAmcc + APCI1564_TIMER + APCI1564_TCW_PROG);  
-      outl(0x0 , devpriv->i_IobaseAmcc + APCI1564_TIMER + APCI1564_TCW_PROG);
-
-      //Send a signal to from kernel to user space
-      send_sig(SIGIO,devpriv->tsk_Current,0); 
-
-      // Enable Timer Interrupt 
-     
-      outl(ul_Command2 , devpriv->i_IobaseAmcc + APCI1564_TIMER + APCI1564_TCW_PROG);
-      } // if  ((ui_Timer == 1) && (devpriv->b_TimerSelectMode =ADDIDATA_TIMER))
-
-   if  ((ui_C1 == 1) && (devpriv->b_TimerSelectMode = ADDIDATA_COUNTER))
-      {
-      // Disable Counter Interrupt 
-      ul_Command2=inl(devpriv->iobase + APCI1564_COUNTER1 + APCI1564_TCW_PROG);
-      outl(0x0 , devpriv->iobase + APCI1564_COUNTER1 + APCI1564_TCW_PROG);
-
-      //Send a signal to from kernel to user space
-      send_sig(SIGIO,devpriv->tsk_Current,0); 
-
-      // Enable Counter Interrupt 
-      outl(ul_Command2 , devpriv->iobase + APCI1564_COUNTER1 + APCI1564_TCW_PROG);
-      } // if  ((ui_C1 == 1) && (devpriv->b_TimerSelectMode = ADDIDATA_COUNTER))  
-
-   if  ((ui_C2 == 1) && (devpriv->b_TimerSelectMode =ADDIDATA_COUNTER))
-      {
-      // Disable Counter Interrupt
-      ul_Command2=inl(devpriv->iobase + APCI1564_COUNTER2 + APCI1564_TCW_PROG); 
-      outl(0x0 , devpriv->iobase + APCI1564_COUNTER2 + APCI1564_TCW_PROG);
-
-      //Send a signal to from kernel to user space
-      send_sig(SIGIO,devpriv->tsk_Current,0); 
-
-      // Enable Counter Interrupt 
-      outl(ul_Command2 , devpriv->iobase + APCI1564_COUNTER2 + APCI1564_TCW_PROG);
-      } // if  ((ui_C2 == 1) && (devpriv->b_TimerSelectMode =ADDIDATA_COUNTER)) 
-
-   if  ((ui_C3 == 1) && (devpriv->b_TimerSelectMode =ADDIDATA_COUNTER))
-      {
-      // Disable Counter Interrupt 
-      ul_Command2=inl(devpriv->iobase + APCI1564_COUNTER3 + APCI1564_TCW_PROG); 
-      outl(0x0 , devpriv->iobase + APCI1564_COUNTER3 + APCI1564_TCW_PROG);
-
-      //Send a signal to from kernel to user space
-      send_sig(SIGIO,devpriv->tsk_Current,0); 
-
-      // Enable Counter Interrupt 
-      outl(ul_Command2 , devpriv->iobase + APCI1564_COUNTER3 + APCI1564_TCW_PROG);
-      } // if ((ui_C3 == 1) && (devpriv->b_TimerSelectMode =ADDIDATA_COUNTER))
-
-    if ((ui_C4 == 1) && (devpriv->b_TimerSelectMode =ADDIDATA_COUNTER))
-      {
-      // Disable Counter Interrupt 
-      ul_Command2=inl(devpriv->iobase + APCI1564_COUNTER4 + APCI1564_TCW_PROG);   
-      outl(0x0 , devpriv->iobase + APCI1564_COUNTER4 + APCI1564_TCW_PROG);
-
-      //Send a signal to from kernel to user space
-      send_sig(SIGIO,devpriv->tsk_Current,0); 
-
-      // Enable Counter Interrupt 
-      outl(ul_Command2 , devpriv->iobase + APCI1564_COUNTER4 + APCI1564_TCW_PROG);
-      } // if ((ui_C4 == 1) && (devpriv->b_TimerSelectMode =ADDIDATA_COUNTER))
-   return;
-}        
-         
-/*
-+----------------------------------------------------------------------------+
-| Function   Name   : int i_APCI1564_Reset(comedi_device *dev)               |                                                       |
-+----------------------------------------------------------------------------+
-| Task              :resets all the registers                                |
-+----------------------------------------------------------------------------+
-| Input Parameters  : comedi_device *dev
-+----------------------------------------------------------------------------+
-| Output Parameters :  --                                                                                                       |
-+----------------------------------------------------------------------------+
-| Return Value      :                                                        |
-|                                                                               |
-+----------------------------------------------------------------------------+
-*/
-         
-INT i_APCI1564_Reset(comedi_device *dev) 
-{
-   outl(0x0 ,devpriv->i_IobaseAmcc+APCI1564_DIGITAL_IP_IRQ);//disable the interrupts
-   inl(devpriv->i_IobaseAmcc+APCI1564_DIGITAL_IP_INTERRUPT_STATUS);//Reset the interrupt status register         
-   outl (0x0 , devpriv->i_IobaseAmcc+APCI1564_DIGITAL_IP_INTERRUPT_MODE1);//Disable the and/or interrupt
-   outl (0x0 , devpriv->i_IobaseAmcc+APCI1564_DIGITAL_IP_INTERRUPT_MODE2);
-   devpriv->b_DigitalOutputRegister=0;
-   ui_Type=0;
-   outl(0x0,devpriv->i_IobaseAmcc+APCI1564_DIGITAL_OP);//Resets the output channels
-   outl(0x0,devpriv->i_IobaseAmcc+APCI1564_DIGITAL_OP_INTERRUPT);//Disables the interrupt.
-   outl(0x0,devpriv->i_IobaseAmcc+APCI1564_DIGITAL_OP_WATCHDOG+APCI1564_TCW_RELOAD_VALUE);  
-   outl(0x0,devpriv->i_IobaseAmcc+APCI1564_TIMER);
-   outl(0x0 , devpriv->i_IobaseAmcc + APCI1564_TIMER + APCI1564_TCW_PROG);
-
-   outl(0x0 , devpriv->iobase + APCI1564_COUNTER1 + APCI1564_TCW_PROG);
-   outl(0x0 , devpriv->iobase + APCI1564_COUNTER2 + APCI1564_TCW_PROG);
-   outl(0x0 , devpriv->iobase + APCI1564_COUNTER3 + APCI1564_TCW_PROG);
-   outl(0x0 , devpriv->iobase + APCI1564_COUNTER4 + APCI1564_TCW_PROG);
-   return 0;
-}        
+\r
+#include <linux/delay.h>\r
+#include "hwdrv_apci1564.h"\r
+\r
+//Global variables\r
+UINT ui_InterruptStatus_1564=0 ;\r
+UINT ui_InterruptData,ui_Type;\r
+\r
+/*\r
++----------------------------------------------------------------------------+\r
+| Function   Name   : int i_APCI1564_ConfigDigitalInput                      |\r
+|                        (comedi_device *dev,comedi_subdevice *s,               | \r
+|                      comedi_insn *insn,lsampl_t *data)                     |\r
++----------------------------------------------------------------------------+\r
+| Task              : Configures the digital input Subdevice                 |\r
++----------------------------------------------------------------------------+\r
+| Input Parameters  : comedi_device *dev : Driver handle                     |\r
+|                     lsampl_t *data         : Data Pointer contains         |\r
+|                                          configuration parameters as below |\r
+|                                                                            | \r
+|                        data[0]            : 1 Enable  Digital Input Interrupt |      \r
+|                                                                 0 Disable Digital Input Interrupt | \r
+|                        data[1]            : 0 ADDIDATA Interrupt OR LOGIC     | \r
+|                                                               : 1 ADDIDATA Interrupt AND LOGIC    | \r
+|                        data[2]                        : Interrupt mask for the mode 1         | \r
+|                        data[3]                        : Interrupt mask for the mode 2         |\r
+|                                                                                                                                       |\r
++----------------------------------------------------------------------------+\r
+| Output Parameters :  --                                                                                                       |\r
++----------------------------------------------------------------------------+\r
+| Return Value      : TRUE  : No error occur                                 |\r
+|                          : FALSE : Error occur. Return the error          |\r
+|                                                                               |\r
++----------------------------------------------------------------------------+\r
+*/\r
+INT i_APCI1564_ConfigDigitalInput(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data) \r
+{\r
+   devpriv->tsk_Current=current;\r
+   /*******************************/\r
+   /* Set the digital input logic */\r
+   /*******************************/\r
+   if  ( data[0] == ADDIDATA_ENABLE)\r
+      {\r
+      data[2]=data[2]<<4;\r
+      data[3]=data[3]<<4;\r
+      outl (data[2] , devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP + APCI1564_DIGITAL_IP_INTERRUPT_MODE1);\r
+      outl (data[3] , devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP + APCI1564_DIGITAL_IP_INTERRUPT_MODE2);\r
+      if  (data[1] == ADDIDATA_OR)\r
+         {\r
+         outl(0x4 ,devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP + APCI1564_DIGITAL_IP_IRQ);\r
+         } // if  (data[1] == ADDIDATA_OR)\r
+      else\r
+         { \r
+         outl(0x6 ,devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP + APCI1564_DIGITAL_IP_IRQ);\r
+         } // else if  (data[1] == ADDIDATA_OR)\r
+      } // if  (data[0] == ADDIDATA_ENABLE)\r
+   else\r
+      {\r
+      outl (0x0, devpriv->i_IobaseAmcc +APCI1564_DIGITAL_IP +APCI1564_DIGITAL_IP_INTERRUPT_MODE1);\r
+      outl (0x0, devpriv->i_IobaseAmcc +APCI1564_DIGITAL_IP +APCI1564_DIGITAL_IP_INTERRUPT_MODE2);\r
+      outl(0x0 ,devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP +APCI1564_DIGITAL_IP_IRQ);\r
+      } // else if  (data[0] == ADDIDATA_ENABLE)\r
+  \r
+   return insn->n;\r
+}\r
+\r
+/*\r
++----------------------------------------------------------------------------+\r
+| Function   Name   : int i_APCI1564_Read1DigitalInput                       |\r
+|                        (comedi_device *dev,comedi_subdevice *s,               |\r
+|                      comedi_insn *insn,lsampl_t *data)                     |\r
++----------------------------------------------------------------------------+\r
+| Task              : Return the status of the digital input                 |\r
++----------------------------------------------------------------------------+\r
+| Input Parameters  : comedi_device *dev      : Driver handle                |\r
+|                            UINT ui_Channel : Channel number to read       |\r
+|                     lsampl_t *data          : Data Pointer to read status  |\r
++----------------------------------------------------------------------------+\r
+| Output Parameters :  --                                                                                                       |\r
++----------------------------------------------------------------------------+\r
+| Return Value      : TRUE  : No error occur                                 |\r
+|                          : FALSE : Error occur. Return the error          |\r
+|                                                                               |\r
++----------------------------------------------------------------------------+\r
+*/\r
+INT i_APCI1564_Read1DigitalInput(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data)\r
+{\r
+   UINT ui_TmpValue=0;\r
+   UINT ui_Channel;\r
+   \r
+   ui_Channel=CR_CHAN(insn->chanspec);\r
+   if  (ui_Channel >= 0 && ui_Channel <=31)\r
+      {\r
+      ui_TmpValue=(UINT) inl(devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP );\r
+      //  since only 1 channel reqd  to bring it to last bit it is rotated \r
+      //  8 +(chan - 1) times then ANDed with 1 for last bit. \r
+      *data = (ui_TmpValue >> ui_Channel)&0x1 ;\r
+      } // if  (ui_Channel >= 0 && ui_Channel <=31)\r
+   else \r
+      {\r
+      comedi_error(dev,"Not a valid channel number !!! \n");  \r
+      return -EINVAL;   // "sorry channel spec wrong "\r
+      }  //else if  (ui_Channel >= 0 && ui_Channel <=31)\r
+   return insn->n;\r
+}\r
+\r
+/*\r
++----------------------------------------------------------------------------+\r
+| Function   Name   : int i_APCI1564_ReadMoreDigitalInput                    |\r
+|                        (comedi_device *dev,comedi_subdevice *s,               |\r
+|                     comedi_insn *insn,lsampl_t *data)                      |\r
++----------------------------------------------------------------------------+\r
+| Task              : Return the status of the Requested digital inputs      |\r
++----------------------------------------------------------------------------+\r
+| Input Parameters  : comedi_device *dev      : Driver handle                |\r
+|                     UINT ui_NoOfChannels    : No Of Channels To be Read    |\r
+|                      UINT *data             : Data Pointer to read status  |\r
++----------------------------------------------------------------------------+\r
+| Output Parameters :  --                                                                                                       |\r
++----------------------------------------------------------------------------+\r
+| Return Value      : TRUE  : No error occur                                 |\r
+|                          : FALSE : Error occur. Return the error          |\r
+|                                                                               |\r
++----------------------------------------------------------------------------+\r
+*/\r
+INT i_APCI1564_ReadMoreDigitalInput(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data)\r
+{\r
+   UINT ui_PortValue=data[0];\r
+   UINT ui_Mask=0;\r
+   UINT ui_NoOfChannels;\r
+   \r
+   ui_NoOfChannels=CR_CHAN(insn->chanspec);\r
+   if  (data[1]==0)\r
+      {\r
+      *data=(UINT)inl(devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP );\r
+      switch (ui_NoOfChannels)\r
+        {\r
+        case 2: ui_Mask=3;\r
+                 *data=(*data >>(2*ui_PortValue))&ui_Mask; \r
+                 break;\r
+        case 4: ui_Mask=15;\r
+                 *data=(*data >>(4*ui_PortValue))&ui_Mask; \r
+                break;\r
+        case 8: ui_Mask=255;\r
+                *data=(*data >>(8*ui_PortValue))&ui_Mask;  \r
+                 break;\r
+         case 16:ui_Mask=65535;\r
+                 *data=(*data >>(16*ui_PortValue))&ui_Mask;\r
+                 break;\r
+         case 31:break;\r
+         default:\r
+                comedi_error(dev,"Not a valid Channel number !!!\n");  \r
+               return -EINVAL;   // "sorry channel spec wrong "  \r
+                break;\r
+         } // switch  (ui_NoOfChannels)\r
+      } // if  (data[1]==0)\r
+   else\r
+      {\r
+      if  (data[1]==1)\r
+         {\r
+         *data=ui_InterruptStatus_1564;\r
+         } // if  (data[1]==1)\r
+      } // else if  (data[1]==0)   \r
+   return insn->n;\r
+}\r
+\r
+/*\r
++----------------------------------------------------------------------------+\r
+| Function   Name   : int i_APCI1564_ConfigDigitalOutput                     |\r
+|                        (comedi_device *dev,comedi_subdevice *s,               | \r
+|                      comedi_insn *insn,lsampl_t *data)                     |\r
++----------------------------------------------------------------------------+\r
+| Task              : Configures The Digital Output Subdevice.               |\r
++----------------------------------------------------------------------------+\r
+| Input Parameters  : comedi_device *dev : Driver handle                     |\r
+|                     UINT *data         : Data Pointer contains             |\r
+|                                          configuration parameters as below |\r
+|                                                                            | \r
+|                                        data[1]            : 1 Enable  VCC  Interrupt  |      \r
+|                                                                                 0 Disable VCC  Interrupt  | \r
+|                                        data[2]            : 1 Enable  CC  Interrupt   |      \r
+|                                                                                 0 Disable CC  Interrupt   | \r
+|                                                                                                                                       |\r
++----------------------------------------------------------------------------+\r
+| Output Parameters :  --                                                                                                       |\r
++----------------------------------------------------------------------------+\r
+| Return Value      : TRUE  : No error occur                                 |\r
+|                          : FALSE : Error occur. Return the error          |\r
+|                                                                               |\r
++----------------------------------------------------------------------------+\r
+*/\r
+INT i_APCI1564_ConfigDigitalOutput(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data)\r
+{\r
+   ULONG  ul_Command = 0; \r
+  \r
+   if  ((data[0]!=0) && (data[0]!=1)) \r
+      {   \r
+      comedi_error(dev,"Not a valid Data !!! ,Data should be 1 or 0\n");  \r
+      return -EINVAL;\r
+      } // if  ((data[0]!=0) && (data[0]!=1)) \r
+   if  (data[0])\r
+      {\r
+      devpriv->b_OutputMemoryStatus = ADDIDATA_ENABLE ; \r
+      } // if  (data[0])\r
+   else\r
+      {\r
+      devpriv->b_OutputMemoryStatus = ADDIDATA_DISABLE;\r
+      } // else if  (data[0])\r
+   if  (data[1] == ADDIDATA_ENABLE)\r
+      {\r
+      ul_Command = ul_Command | 0x1;\r
+      } // if  (data[1] == ADDIDATA_ENABLE)\r
+   else\r
+      {\r
+      ul_Command = ul_Command & 0xFFFFFFFE;\r
+      } // else if  (data[1] == ADDIDATA_ENABLE)\r
+   if  (data[2] == ADDIDATA_ENABLE)\r
+      {\r
+      ul_Command = ul_Command | 0x2;\r
+      } // if  (data[2] == ADDIDATA_ENABLE)\r
+   else\r
+      {\r
+      ul_Command = ul_Command & 0xFFFFFFFD;\r
+      } // else if  (data[2] == ADDIDATA_ENABLE)\r
+   outl( ul_Command , devpriv->i_IobaseAmcc+APCI1564_DIGITAL_OP+APCI1564_DIGITAL_OP_INTERRUPT);\r
+   ui_InterruptData=inl( devpriv->i_IobaseAmcc+APCI1564_DIGITAL_OP+APCI1564_DIGITAL_OP_INTERRUPT); \r
+   devpriv->tsk_Current=current;  \r
+   return insn->n;\r
+}\r
+\r
+/*\r
++----------------------------------------------------------------------------+\r
+| Function   Name   : int i_APCI1564_WriteDigitalOutput                      |\r
+|                        (comedi_device *dev,comedi_subdevice *s,               | \r
+|                      comedi_insn *insn,lsampl_t *data)                     |\r
++----------------------------------------------------------------------------+\r
+| Task              : Writes port value  To the selected port                |\r
++----------------------------------------------------------------------------+\r
+| Input Parameters  : comedi_device *dev      : Driver handle                |\r
+|                     UINT ui_NoOfChannels    : No Of Channels To Write      |\r
+|                     UINT *data              : Data Pointer to read status  |\r
++----------------------------------------------------------------------------+\r
+| Output Parameters :  --                                                                                                       |\r
++----------------------------------------------------------------------------+\r
+| Return Value      : TRUE  : No error occur                                 |\r
+|                          : FALSE : Error occur. Return the error          |\r
+|                                                                               |\r
++----------------------------------------------------------------------------+\r
+*/\r
+INT i_APCI1564_WriteDigitalOutput(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data) {\r
+   UINT ui_Temp,ui_Temp1;\r
+   UINT ui_NoOfChannel;\r
+   \r
+   ui_NoOfChannel=CR_CHAN(insn->chanspec);\r
+   if  (devpriv->b_OutputMemoryStatus )\r
+      {\r
+      ui_Temp=inl(devpriv->i_IobaseAmcc + APCI1564_DIGITAL_OP + APCI1564_DIGITAL_OP_RW);\r
+      } // if  (devpriv->b_OutputMemoryStatus )\r
+   else\r
+      {\r
+      ui_Temp=0;\r
+      } // else if  (devpriv->b_OutputMemoryStatus )\r
+   if  (data[3]==0)\r
+      { \r
+      if  (data[1]==0)\r
+         {\r
+         data[0]=(data[0] << ui_NoOfChannel)|ui_Temp;\r
+         outl(data[0],devpriv->i_IobaseAmcc + APCI1564_DIGITAL_OP + APCI1564_DIGITAL_OP_RW);  \r
+         } // if  (data[1]==0) \r
+      else\r
+         {\r
+         if  (data[1]==1)\r
+            { \r
+            switch (ui_NoOfChannel)\r
+              {\r
+               case 2: data[0]=(data[0] << (2*data[2]))|ui_Temp; \r
+                      break;\r
+               case 4: data[0]=(data[0] << (4*data[2]))|ui_Temp;\r
+                      break;\r
+               case 8: data[0]=(data[0] <<(8*data[2]))|ui_Temp;  \r
+                       break;\r
+               case 16: data[0]=(data[0] <<(16*data[2]))|ui_Temp;\r
+                        break;\r
+               case 31: data[0]=data[0]|ui_Temp; \r
+                        break;\r
+               default: comedi_error(dev," chan spec wrong");\r
+                        return -EINVAL;   // "sorry channel spec wrong "  \r
+               } // switch (ui_NoOfChannels)\r
+            outl(data[0],devpriv->i_IobaseAmcc + APCI1564_DIGITAL_OP + APCI1564_DIGITAL_OP_RW);\r
+            } // if  (data[1]==1)\r
+         else\r
+            {\r
+            printk("\nSpecified channel not supported\n");\r
+            } // else if  (data[1]==1)\r
+         } // else if (data[1]==0)\r
+      }//if(data[3]==0)\r
+   else\r
+      {\r
+      if  (data[3]==1)\r
+         {\r
+         if  (data[1]==0)\r
+            {\r
+            data[0]=~data[0]&0x1;\r
+            ui_Temp1=1;\r
+            ui_Temp1=ui_Temp1<<ui_NoOfChannel;\r
+            ui_Temp=ui_Temp|ui_Temp1;  \r
+            data[0]=(data[0] << ui_NoOfChannel)^0xffffffff;\r
+            data[0]=data[0]& ui_Temp; \r
+            outl(data[0],devpriv->i_IobaseAmcc + APCI1564_DIGITAL_OP + APCI1564_DIGITAL_OP_RW);  \r
+            } // if  (data[1]==0) \r
+         else\r
+            {\r
+            if  (data[1]==1)\r
+               { \r
+               switch (ui_NoOfChannel)\r
+                 {\r
+                 case 2: data[0]=~data[0]&0x3; \r
+                          ui_Temp1=3;\r
+                          ui_Temp1=ui_Temp1<<2*data[2];\r
+                          ui_Temp=ui_Temp|ui_Temp1;   \r
+                          data[0]=((data[0] << (2*data[2]))^0xffffffff)& ui_Temp; \r
+                         break;\r
+                 case 4: data[0]=~data[0]&0xf;\r
+                          ui_Temp1=15;\r
+                          ui_Temp1=ui_Temp1<<4*data[2];\r
+                          ui_Temp=ui_Temp|ui_Temp1;    \r
+                          data[0]=((data[0] << (4*data[2]))^0xffffffff)&ui_Temp;\r
+                         break;\r
+                  case 8: data[0]=~data[0]&0xff;\r
+                          ui_Temp1=255;\r
+                          ui_Temp1=ui_Temp1<<8*data[2];\r
+                          ui_Temp=ui_Temp|ui_Temp1;    \r
+                          data[0]=((data[0] << (8*data[2]))^0xffffffff)&ui_Temp;  \r
+                         break;\r
+                  case 16: data[0]=~data[0]&0xffff;\r
+                           ui_Temp1=65535;\r
+                           ui_Temp1=ui_Temp1<<16*data[2];\r
+                           ui_Temp=ui_Temp|ui_Temp1;    \r
+                           data[0]=((data[0] << (16*data[2]))^0xffffffff)&ui_Temp;  \r
+                          break;\r
+                  case 31: break;\r
+                  default: comedi_error(dev," chan spec wrong");\r
+                           return -EINVAL;   // "sorry channel spec wrong "  \r
+                  }//switch(ui_NoOfChannels)\r
+               outl(data[0],devpriv->i_IobaseAmcc + APCI1564_DIGITAL_OP + APCI1564_DIGITAL_OP_RW);\r
+               } // if  (data[1]==1)\r
+            else\r
+               {\r
+               printk("\nSpecified channel not supported\n");\r
+               } // else if  (data[1]==1)\r
+            } // else if  (data[1]==0)\r
+         } // if  (data[3]==1);\r
+      else\r
+         {\r
+         printk("\nSpecified functionality does not exist\n");\r
+         return -EINVAL;\r
+         } // else if (data[3]==1)\r
+      } // else if (data[3]==0) \r
+   return insn->n;\r
+}\r
+\r
+/*\r
++----------------------------------------------------------------------------+\r
+| Function   Name   : int i_APCI1564_ReadDigitalOutput                       |\r
+|                        (comedi_device *dev,comedi_subdevice *s,               | \r
+|                      comedi_insn *insn,lsampl_t *data)                     |\r
++----------------------------------------------------------------------------+\r
+| Task              : Read  value  of the selected channel or port           |\r
++----------------------------------------------------------------------------+\r
+| Input Parameters  : comedi_device *dev      : Driver handle                |\r
+|                     UINT ui_NoOfChannels    : No Of Channels To read       |\r
+|                     UINT *data              : Data Pointer to read status  |\r
++----------------------------------------------------------------------------+\r
+| Output Parameters :  --                                                                                                       |\r
++----------------------------------------------------------------------------+\r
+| Return Value      : TRUE  : No error occur                                 |\r
+|                          : FALSE : Error occur. Return the error          |\r
+|                                                                               |\r
++----------------------------------------------------------------------------+\r
+*/\r
+INT i_APCI1564_ReadDigitalOutput(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data) \r
+{\r
+   UINT ui_Temp;\r
+   UINT ui_NoOfChannel;\r
+\r
+   ui_NoOfChannel=CR_CHAN(insn->chanspec);\r
+   ui_Temp=data[0];\r
+   *data=inl(devpriv->i_IobaseAmcc+APCI1564_DIGITAL_OP+APCI1564_DIGITAL_OP_RW);\r
+   if  (ui_Temp==0)\r
+      {\r
+      *data=(*data >> ui_NoOfChannel)&0x1; \r
+      } // if  (ui_Temp==0)\r
+   else\r
+      {\r
+      if  (ui_Temp==1)\r
+         {\r
+         switch (ui_NoOfChannel)\r
+          {\r
+           case 2: \r
+                    *data=(*data >>(2*data[1]))&3; \r
+                    break;\r
+\r
+           case 4: \r
+                    *data=(*data >>(4*data[1]))&15; \r
+                   break;\r
\r
+          case 8:  \r
+                   *data=(*data >>(8*data[1]))&255;  \r
+                    break;\r
\r
+           case 16: \r
+                    *data=(*data >>(16*data[1]))&65535;\r
+                    break;\r
+\r
+           case 31: break;\r
+\r
+           default:\r
+                   comedi_error(dev," chan spec wrong");\r
+                   return -EINVAL;   // "sorry channel spec wrong "  \r
+                    break;\r
+           } // switch(ui_NoOfChannels)    \r
+        } // if  (ui_Temp==1)\r
+     else\r
+        {\r
+        printk("\nSpecified channel not supported \n");\r
+        } // else if (ui_Temp==1)\r
+     } // else if  (ui_Temp==0)\r
+   return insn->n;\r
+}\r
+\r
+/*\r
++----------------------------------------------------------------------------+\r
+| Function   Name   : int i_APCI1564_ConfigTimerCounterWatchdog              |\r
+|                        (comedi_device *dev,comedi_subdevice *s,               | \r
+|                      comedi_insn *insn,lsampl_t *data)                     |\r
++----------------------------------------------------------------------------+\r
+| Task              : Configures The Timer , Counter or Watchdog             |\r
++----------------------------------------------------------------------------+\r
+| Input Parameters  : comedi_device *dev : Driver handle                     |\r
+|                     UINT *data         : Data Pointer contains             |\r
+|                                          configuration parameters as below |\r
+|                                                                            | \r
+|                                        data[0]            : 0 Configure As Timer      |      \r
+|                                                                                 1 Configure As Counter    |                            \r
+|                                                                                 2 Configure As Watchdog   |                            \r
+|                                        data[1]            : 1 Enable  Interrupt       |      \r
+|                                                                                 0 Disable Interrupt       |                           \r
+|                                        data[2]            : Time Unit                 |\r
+|                                        data[3]                        : Reload Value                      |                            \r
+|                                        data[4]            : Timer Mode                |                            \r
+|                                        data[5]                        : Timer Counter Watchdog Number|     \r
+                              data[6]            :  Counter Direction \r
++----------------------------------------------------------------------------+\r
+| Output Parameters :  --                                                                                                       |\r
++----------------------------------------------------------------------------+\r
+| Return Value      : TRUE  : No error occur                                 |\r
+|                          : FALSE : Error occur. Return the error          |\r
+|                                                                               |\r
++----------------------------------------------------------------------------+\r
+*/\r
+INT i_APCI1564_ConfigTimerCounterWatchdog (comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data) \r
+{\r
+   ULONG  ul_Command1 = 0; \r
+   devpriv->tsk_Current=current;\r
+   if  (data[0]==ADDIDATA_WATCHDOG)\r
+      {\r
+      devpriv->b_TimerSelectMode = ADDIDATA_WATCHDOG;   \r
+     \r
+      //Disable the watchdog\r
+      outl(0x0,devpriv->i_IobaseAmcc+ APCI1564_DIGITAL_OP_WATCHDOG+ APCI1564_TCW_PROG); \r
+     //Loading the Reload value\r
+      outl(data[3],devpriv->i_IobaseAmcc+APCI1564_DIGITAL_OP_WATCHDOG+APCI1564_TCW_RELOAD_VALUE);  \r
+      } // if  (data[0]==ADDIDATA_WATCHDOG)\r
+   else if  (data[0]==ADDIDATA_TIMER)\r
+      {\r
+      //First Stop The Timer \r
+      ul_Command1 =inl(devpriv->i_IobaseAmcc+ APCI1564_TIMER+ APCI1564_TCW_PROG);\r
+      ul_Command1 =ul_Command1 & 0xFFFFF9FEUL;\r
+      outl(ul_Command1,devpriv->i_IobaseAmcc+ APCI1564_TIMER+ APCI1564_TCW_PROG);//Stop The Timer\r
+\r
+      devpriv->b_TimerSelectMode =ADDIDATA_TIMER;\r
+      if  (data[1]==1)\r
+         { \r
+         outl(0x02,devpriv->i_IobaseAmcc+ APCI1564_TIMER+ APCI1564_TCW_PROG);//Enable TIMER int & DISABLE ALL THE OTHER int SOURCES\r
+         outl(0x0,devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP + APCI1564_DIGITAL_IP_IRQ);\r
+         outl(0x0,devpriv->i_IobaseAmcc + APCI1564_DIGITAL_OP + APCI1564_DIGITAL_OP_IRQ); \r
+         outl(0x0,devpriv->i_IobaseAmcc + APCI1564_DIGITAL_OP_WATCHDOG + APCI1564_TCW_IRQ);\r
+         outl(0x0,devpriv->iobase+APCI1564_COUNTER1 + APCI1564_TCW_IRQ);\r
+         outl(0x0,devpriv->iobase+APCI1564_COUNTER2 + APCI1564_TCW_IRQ);\r
+         outl(0x0,devpriv->iobase+APCI1564_COUNTER3 + APCI1564_TCW_IRQ);\r
+         outl(0x0,devpriv->iobase+APCI1564_COUNTER4 + APCI1564_TCW_IRQ);\r
+         } // if  (data[1]==1)\r
+      else\r
+         { \r
+         outl(0x0,devpriv->i_IobaseAmcc+ APCI1564_TIMER+ APCI1564_TCW_PROG);//disable Timer interrupt\r
+         } // else if  (data[1]==1)\r
+    \r
+      // Loading Timebase\r
+     \r
+         outl(data[2],devpriv->i_IobaseAmcc+APCI1564_TIMER+APCI1564_TCW_TIMEBASE);\r
+        \r
+      //Loading the Reload value\r
+      outl(data[3],devpriv->i_IobaseAmcc+APCI1564_TIMER+APCI1564_TCW_RELOAD_VALUE);\r
+    \r
+      ul_Command1 =inl(devpriv->i_IobaseAmcc+ APCI1564_TIMER+ APCI1564_TCW_PROG);\r
+      ul_Command1 = (ul_Command1 & 0xFFF719E2UL) |  2UL << 13UL | 0x10UL;\r
+      outl(ul_Command1,devpriv->i_IobaseAmcc+ APCI1564_TIMER+ APCI1564_TCW_PROG);//mode 2\r
+      } // else if  (data[0]==ADDIDATA_TIMER)\r
+   else if  (data[0]==ADDIDATA_COUNTER)\r
+      {\r
+      devpriv->b_TimerSelectMode =ADDIDATA_COUNTER;\r
+      devpriv->b_ModeSelectRegister=data[5];\r
+\r
+      //First Stop The Counter\r
+      ul_Command1 =inl(devpriv->iobase+((data[5]-1)*0x20)+APCI1564_TCW_PROG); \r
+      ul_Command1 =ul_Command1 & 0xFFFFF9FEUL;\r
+      outl(ul_Command1,devpriv->iobase+((data[5]-1)*0x20)+APCI1564_TCW_PROG);//Stop The Timer\r
+\r
+      /************************/\r
+      /* Set the reload value */\r
+      /************************/\r
+      outl(data[3] , devpriv->iobase+((data[5]-1)*0x20)+APCI1564_TCW_RELOAD_VALUE);\r
\r
+      /******************************/\r
+      /* Set the mode :             */\r
+      /* - Disable the hardware     */\r
+      /* - Disable the counter mode */\r
+      /* - Disable the warning      */\r
+      /* - Disable the reset        */\r
+      /* - Disable the timer mode   */\r
+      /* - Enable the counter mode  */\r
+      /******************************/\r
+      ul_Command1 = (ul_Command1 & 0xFFFC19E2UL) | 0x80000UL | (ULONG) ((ULONG) data[4] << 16UL);\r
+      outl(ul_Command1 , devpriv->iobase+((data[5]-1)*0x20)+APCI1564_TCW_PROG); \r
+\r
+      // Enable or Disable Interrupt \r
+      ul_Command1= (ul_Command1 & 0xFFFFF9FD) | (data[1] << 1);                 \r
+      outl(ul_Command1 , devpriv->iobase+((data[5]-1)*0x20)+APCI1564_TCW_PROG);\r
\r
+      /*****************************/\r
+      /* Set the Up/Down selection */\r
+      /*****************************/\r
+      ul_Command1 = (ul_Command1 & 0xFFFBF9FFUL) |  (data[6] << 18);\r
+      outl(ul_Command1 , devpriv->iobase+((data[5]-1)*0x20)+APCI1564_TCW_PROG);  \r
+      } // else if  (data[0]==ADDIDATA_COUNTER)\r
+   else   \r
+      {\r
+      printk(" Invalid subdevice.");\r
+      } // else if  (data[0]==ADDIDATA_WATCHDOG) \r
+   \r
+   return insn->n;\r
+}\r
+\r
+/*\r
++----------------------------------------------------------------------------+\r
+| Function   Name   : int i_APCI1564_StartStopWriteTimerCounterWatchdog      |\r
+|                        (comedi_device *dev,comedi_subdevice *s,               | \r
+|                      comedi_insn *insn,lsampl_t *data)                     |\r
++----------------------------------------------------------------------------+\r
+| Task              : Start / Stop The Selected Timer , Counter or Watchdog  |\r
++----------------------------------------------------------------------------+\r
+| Input Parameters  : comedi_device *dev : Driver handle                     |\r
+|                     UINT *data         : Data Pointer contains             |\r
+|                                          configuration parameters as below |\r
+|                                                                            | \r
+|                                        data[0]            : 0 Timer                   |\r
+|                                                                                 1 Counter                 |  \r
+|                                                                                 2 Watchdog                    |                             |                                                 data[1]            : 1 Start                   |       \r
+|                                                                                 0 Stop                    |       \r
+|                                                  2 Trigger                    |      \r
+|                                                    Clear (Only Counter)    |\r
++----------------------------------------------------------------------------+\r
+| Output Parameters :  --                                                                                                       |\r
++----------------------------------------------------------------------------+\r
+| Return Value      : TRUE  : No error occur                                 |\r
+|                          : FALSE : Error occur. Return the error          |\r
+|                                                                               |\r
++----------------------------------------------------------------------------+\r
+*/\r
+INT i_APCI1564_StartStopWriteTimerCounterWatchdog(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data)\r
+{\r
+   ULONG  ul_Command1 = 0; \r
+   if  (devpriv->b_TimerSelectMode==ADDIDATA_WATCHDOG)\r
+      {\r
+      switch (data[1])\r
+         {\r
+         case 0:  //stop the watchdog\r
+                  outl(0x0,devpriv->i_IobaseAmcc+ APCI1564_DIGITAL_OP_WATCHDOG+ APCI1564_TCW_PROG );//disable the watchdog\r
+                  break;\r
+         case 1:  //start the watchdog\r
+                  outl(0x0001,devpriv->i_IobaseAmcc+ APCI1564_DIGITAL_OP_WATCHDOG+ APCI1564_TCW_PROG);\r
+                  break;\r
+         case 2:  //Software trigger  \r
+                  outl(0x0201,devpriv->i_IobaseAmcc+ APCI1564_DIGITAL_OP_WATCHDOG+ APCI1564_TCW_PROG);\r
+                  break;\r
+         default: printk("\nSpecified functionality does not exist\n");\r
+                 return -EINVAL;\r
+         }  // switch (data[1])        \r
+      } // if  (devpriv->b_TimerSelectMode==ADDIDATA_WATCHDOG)   \r
+   if  (devpriv->b_TimerSelectMode==ADDIDATA_TIMER)\r
+      {\r
+      if  (data[1]==1) \r
+         { \r
+         ul_Command1=inl(devpriv->i_IobaseAmcc+ APCI1564_TIMER+ APCI1564_TCW_PROG);\r
+         ul_Command1=(ul_Command1& 0xFFFFF9FFUL) | 0x1UL;\r
+       \r
+         //Enable the Timer\r
+         outl(ul_Command1,devpriv->i_IobaseAmcc+ APCI1564_TIMER+ APCI1564_TCW_PROG);\r
+         } // if  (data[1]==1)\r
+      else if(data[1]==0)\r
+         {\r
+         //Stop The Timer\r
+          \r
+         ul_Command1=inl(devpriv->i_IobaseAmcc+ APCI1564_TIMER+ APCI1564_TCW_PROG);\r
+         ul_Command1 =ul_Command1 & 0xFFFFF9FEUL;\r
+         outl(ul_Command1,devpriv->i_IobaseAmcc+ APCI1564_TIMER+ APCI1564_TCW_PROG);\r
+         } // else if(data[1]==0)\r
+      } // if  (devpriv->b_TimerSelectMode==ADDIDATA_TIMER)\r
+   if  (devpriv->b_TimerSelectMode==ADDIDATA_COUNTER)\r
+      {\r
+      ul_Command1=inl(devpriv->iobase+((devpriv->b_ModeSelectRegister-1)*0x20)+APCI1564_TCW_PROG);\r
+      if  (data[1] == 1) \r
+         {\r
+         //Start the Counter subdevice \r
+         ul_Command1= (ul_Command1 & 0xFFFFF9FFUL) | 0x1UL;\r
+         } // if  (data[1] == 1)\r
+      else if (data[1] == 0)\r
+         {\r
+         // Stops the Counter subdevice \r
+        ul_Command1 = 0;\r
+         \r
+         } // else if  (data[1] == 0)\r
+      else if (data[1] == 2)\r
+         {\r
+         // Clears the Counter subdevice\r
+         ul_Command1= (ul_Command1 & 0xFFFFF9FFUL)|0x400;\r
+         } // else if  (data[1] == 3)\r
+      outl(ul_Command1 , devpriv->iobase+((devpriv->b_ModeSelectRegister-1)*0x20)+APCI1564_TCW_PROG);\r
+      } // if (devpriv->b_TimerSelectMode==ADDIDATA_COUNTER)\r
+   return insn->n;\r
+}\r
+\r
+/*\r
++----------------------------------------------------------------------------+\r
+| Function   Name   : int i_APCI1564_ReadTimerCounterWatchdog                |\r
+|                        (comedi_device *dev,comedi_subdevice *s,               | \r
+|                      comedi_insn *insn,lsampl_t *data)                     |\r
++----------------------------------------------------------------------------+\r
+| Task              : Read The Selected Timer , Counter or Watchdog          |\r
++----------------------------------------------------------------------------+\r
+| Input Parameters  : comedi_device *dev : Driver handle                     |\r
+|                     UINT *data         : Data Pointer contains             |\r
+|                                          configuration parameters as below |\r
+|                                                                            | \r
+                                       \r
++----------------------------------------------------------------------------+\r
+| Output Parameters :  --                                                                                                       |\r
++----------------------------------------------------------------------------+\r
+| Return Value      : TRUE  : No error occur                                 |\r
+|                          : FALSE : Error occur. Return the error          |\r
+|                                                                               |\r
++----------------------------------------------------------------------------+\r
+*/\r
+INT i_APCI1564_ReadTimerCounterWatchdog(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data)\r
+{\r
+   ULONG  ul_Command1 = 0; \r
+\r
+   if  (devpriv->b_TimerSelectMode==ADDIDATA_WATCHDOG)\r
+      { \r
+      // Stores the status of the Watchdog \r
+      data[0]= inl(devpriv->i_IobaseAmcc + APCI1564_DIGITAL_OP_WATCHDOG + APCI1564_TCW_TRIG_STATUS)&0x1;\r
+      data[1]= inl(devpriv->i_IobaseAmcc + APCI1564_DIGITAL_OP_WATCHDOG);\r
+      } // if  (devpriv->b_TimerSelectMode==ADDIDATA_WATCHDOG)\r
+   else if  (devpriv->b_TimerSelectMode==ADDIDATA_TIMER) \r
+      {\r
+      // Stores the status of the Timer \r
+      data[0]= inl(devpriv->i_IobaseAmcc+APCI1564_TIMER+APCI1564_TCW_TRIG_STATUS)&0x1; \r
+\r
+      // Stores the Actual value of the Timer \r
+      data[1]= inl(devpriv->i_IobaseAmcc + APCI1564_TIMER); \r
+      }  // else if  (devpriv->b_TimerSelectMode==ADDIDATA_TIMER)\r
+   else  if  (devpriv->b_TimerSelectMode==ADDIDATA_COUNTER) \r
+      {\r
+      // Read the Counter Actual Value. \r
+      data[0] = inl(devpriv->iobase+((devpriv->b_ModeSelectRegister-1)*0x20)+APCI1564_TCW_SYNC_ENABLEDISABLE);\r
+      ul_Command1 =  inl(devpriv->iobase+((devpriv->b_ModeSelectRegister-1)*0x20)+APCI1564_TCW_TRIG_STATUS);\r
+\r
+      /***********************************/\r
+      /* Get the software trigger status */\r
+      /***********************************/\r
+      data[1]= (BYTE) ((ul_Command1 >> 1) & 1);\r
+\r
+      /***********************************/\r
+      /* Get the hardware trigger status */\r
+      /***********************************/\r
+      data[2]= (BYTE) ((ul_Command1 >> 2) & 1);\r
+\r
+      /*********************************/\r
+      /* Get the software clear status */\r
+      /*********************************/\r
+      data[3]= (BYTE) ((ul_Command1 >> 3) & 1);\r
+\r
+      /***************************/\r
+      /* Get the overflow status */\r
+      /***************************/\r
+      data[4]= (BYTE) ((ul_Command1 >> 0) & 1);\r
+      } // else  if  (devpriv->b_TimerSelectMode==ADDIDATA_COUNTER) \r
+  else if ((devpriv->b_TimerSelectMode!=ADDIDATA_TIMER) && (devpriv->b_TimerSelectMode!=ADDIDATA_WATCHDOG)&& (devpriv->b_TimerSelectMode!=ADDIDATA_COUNTER))\r
+     {\r
+     printk ("\n Invalid Subdevice !!!\n");\r
+     } // else if ((devpriv->b_TimerSelectMode!=ADDIDATA_TIMER) && (devpriv->b_TimerSelectMode!=ADDIDATA_WATCHDOG)&& (devpriv->b_TimerSelectMode!=ADDIDATA_COUNTER))\r
+   return insn->n;\r
+}\r
+\r
+/*\r
++----------------------------------------------------------------------------+\r
+| Function   Name   :  int i_APCI1564_ReadInterruptStatus                    |\r
+|                        (comedi_device *dev,comedi_subdevice *s,               | \r
+|                      comedi_insn *insn,lsampl_t *data)                     |\r
++----------------------------------------------------------------------------+\r
+| Task              :Reads the interrupt status register                     |\r
++----------------------------------------------------------------------------+\r
+| Input Parameters  :                                                        |\r
++----------------------------------------------------------------------------+\r
+| Output Parameters :  --                                                                                                       |\r
++----------------------------------------------------------------------------+\r
+| Return Value      :                                                        |\r
+|                                                                               |\r
++----------------------------------------------------------------------------+\r
+*/\r
+\r
+int i_APCI1564_ReadInterruptStatus(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data)\r
+{  \r
+    *data=ui_Type;\r
+    return insn->n;\r
+} \r
+\r
+/*\r
++----------------------------------------------------------------------------+\r
+| Function   Name   : static void v_APCI1564_Interrupt                                      |\r
+|                                        (int irq , void *d, struct pt_regs *regs)      |\r
++----------------------------------------------------------------------------+\r
+| Task              : Interrupt handler for the interruptible digital inputs |\r
++----------------------------------------------------------------------------+\r
+| Input Parameters  : int irq                 : irq number                   |\r
+|                     void *d                 : void pointer                 |\r
+|                     struct pt_regs *regs    : structure pointer            |\r
++----------------------------------------------------------------------------+\r
+| Output Parameters :  --                                                                                                       |\r
++----------------------------------------------------------------------------+\r
+| Return Value      : TRUE  : No error occur                                 |\r
+|                          : FALSE : Error occur. Return the error          |\r
+|                                                                               |\r
++----------------------------------------------------------------------------+\r
+*/\r
+static VOID v_APCI1564_Interrupt(int irq,void* d, struct pt_regs *regs) \r
+{\r
+   comedi_device *dev =d;      \r
+   UINT ui_DO, ui_DI;\r
+   UINT ui_Timer;\r
+   UINT ui_C1, ui_C2, ui_C3, ui_C4;\r
+   ULONG ul_Command2=0; \r
+   ui_DI       = inl(devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP + APCI1564_DIGITAL_IP_IRQ) & 0x01;\r
+   ui_DO       = inl(devpriv->i_IobaseAmcc + APCI1564_DIGITAL_OP + APCI1564_DIGITAL_OP_IRQ) & 0x01;\r
+   ui_Timer    = inl(devpriv->i_IobaseAmcc + APCI1564_TIMER+ APCI1564_TCW_IRQ) & 0x01; \r
+   ui_C1=inl(devpriv->iobase + APCI1564_COUNTER1 + APCI1564_TCW_IRQ ) & 0x1;\r
+   ui_C2=inl(devpriv->iobase + APCI1564_COUNTER2 + APCI1564_TCW_IRQ ) & 0x1;\r
+   ui_C3=inl(devpriv->iobase + APCI1564_COUNTER3 + APCI1564_TCW_IRQ ) & 0x1;\r
+   ui_C4=inl(devpriv->iobase + APCI1564_COUNTER4 + APCI1564_TCW_IRQ ) & 0x1;\r
+  if(ui_DI==0 && ui_DO==0 && ui_Timer==0 && ui_C1==0 && ui_C2==0 && ui_C3==0 && ui_C4==0)\r
+      {\r
+       printk("\nInterrupt from unknown source\n");\r
+      }// if(ui_DI==0 && ui_DO==0 && ui_Timer==0 && ui_C1==0 && ui_C2==0 && ui_C3==0 && ui_C4==0)\r
+      \r
+   if  (ui_DI == 1)\r
+      {\r
+      ui_DI = inl(devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP + APCI1564_DIGITAL_IP_IRQ);\r
+      outl(0x0 ,devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP + APCI1564_DIGITAL_IP_IRQ);\r
+      ui_InterruptStatus_1564=inl(devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP + APCI1564_DIGITAL_IP_INTERRUPT_STATUS);\r
+      ui_InterruptStatus_1564=ui_InterruptStatus_1564 & 0X000FFFF0;\r
+      send_sig(SIGIO,devpriv->tsk_Current,0); // send signal to the sample   \r
+      outl(ui_DI ,devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP + APCI1564_DIGITAL_IP_IRQ);//enable the interrupt\r
+      return;\r
+      }\r
+\r
+   if  (ui_DO == 1)\r
+      {\r
+      // Check for Digital Output interrupt Type - 1: Vcc interrupt 2: CC interrupt.\r
+      ui_Type=inl(devpriv->i_IobaseAmcc + APCI1564_DIGITAL_OP + APCI1564_DIGITAL_OP_INTERRUPT_STATUS) & 0x3;     \r
+       //Disable the  Interrupt \r
+      outl(0x0,devpriv->i_IobaseAmcc + APCI1564_DIGITAL_OP + APCI1564_DIGITAL_OP_INTERRUPT);\r
+     \r
+         //Sends signal to user space \r
+        send_sig(SIGIO,devpriv->tsk_Current,0);\r
+      \r
+      }  // if  (ui_DO)\r
+\r
+   if  ((ui_Timer == 1) && (devpriv->b_TimerSelectMode =ADDIDATA_TIMER))\r
+      {\r
+      // Disable Timer Interrupt \r
+      ul_Command2=inl(devpriv->i_IobaseAmcc + APCI1564_TIMER + APCI1564_TCW_PROG);  \r
+      outl(0x0 , devpriv->i_IobaseAmcc + APCI1564_TIMER + APCI1564_TCW_PROG);\r
+\r
+      //Send a signal to from kernel to user space\r
+      send_sig(SIGIO,devpriv->tsk_Current,0); \r
+\r
+      // Enable Timer Interrupt \r
+     \r
+      outl(ul_Command2 , devpriv->i_IobaseAmcc + APCI1564_TIMER + APCI1564_TCW_PROG);\r
+      } // if  ((ui_Timer == 1) && (devpriv->b_TimerSelectMode =ADDIDATA_TIMER))\r
+\r
\r
+   if  ((ui_C1 == 1) && (devpriv->b_TimerSelectMode = ADDIDATA_COUNTER))\r
+      {\r
+      // Disable Counter Interrupt \r
+      ul_Command2=inl(devpriv->iobase + APCI1564_COUNTER1 + APCI1564_TCW_PROG);\r
+      outl(0x0 , devpriv->iobase + APCI1564_COUNTER1 + APCI1564_TCW_PROG);\r
+\r
+      //Send a signal to from kernel to user space\r
+      send_sig(SIGIO,devpriv->tsk_Current,0); \r
+\r
+      // Enable Counter Interrupt \r
+      outl(ul_Command2 , devpriv->iobase + APCI1564_COUNTER1 + APCI1564_TCW_PROG);\r
+      } // if  ((ui_C1 == 1) && (devpriv->b_TimerSelectMode = ADDIDATA_COUNTER))  \r
+\r
+   if  ((ui_C2 == 1) && (devpriv->b_TimerSelectMode =ADDIDATA_COUNTER))\r
+      {\r
+      // Disable Counter Interrupt\r
+      ul_Command2=inl(devpriv->iobase + APCI1564_COUNTER2 + APCI1564_TCW_PROG); \r
+      outl(0x0 , devpriv->iobase + APCI1564_COUNTER2 + APCI1564_TCW_PROG);\r
+\r
+      //Send a signal to from kernel to user space\r
+      send_sig(SIGIO,devpriv->tsk_Current,0); \r
+\r
+      // Enable Counter Interrupt \r
+      outl(ul_Command2 , devpriv->iobase + APCI1564_COUNTER2 + APCI1564_TCW_PROG);\r
+      } // if  ((ui_C2 == 1) && (devpriv->b_TimerSelectMode =ADDIDATA_COUNTER)) \r
+\r
+   if  ((ui_C3 == 1) && (devpriv->b_TimerSelectMode =ADDIDATA_COUNTER))\r
+      {\r
+      // Disable Counter Interrupt \r
+      ul_Command2=inl(devpriv->iobase + APCI1564_COUNTER3 + APCI1564_TCW_PROG); \r
+      outl(0x0 , devpriv->iobase + APCI1564_COUNTER3 + APCI1564_TCW_PROG);\r
+\r
+      //Send a signal to from kernel to user space\r
+      send_sig(SIGIO,devpriv->tsk_Current,0); \r
+\r
+      // Enable Counter Interrupt \r
+      outl(ul_Command2 , devpriv->iobase + APCI1564_COUNTER3 + APCI1564_TCW_PROG);\r
+      } // if ((ui_C3 == 1) && (devpriv->b_TimerSelectMode =ADDIDATA_COUNTER))\r
+\r
+    if ((ui_C4 == 1) && (devpriv->b_TimerSelectMode =ADDIDATA_COUNTER))\r
+      {\r
+      // Disable Counter Interrupt \r
+      ul_Command2=inl(devpriv->iobase + APCI1564_COUNTER4 + APCI1564_TCW_PROG);   \r
+      outl(0x0 , devpriv->iobase + APCI1564_COUNTER4 + APCI1564_TCW_PROG);\r
+\r
+      //Send a signal to from kernel to user space\r
+      send_sig(SIGIO,devpriv->tsk_Current,0); \r
+\r
+      // Enable Counter Interrupt \r
+      outl(ul_Command2 , devpriv->iobase + APCI1564_COUNTER4 + APCI1564_TCW_PROG);\r
+      } // if ((ui_C4 == 1) && (devpriv->b_TimerSelectMode =ADDIDATA_COUNTER))\r
+   return;\r
+}        \r
+         \r
+/*\r
++----------------------------------------------------------------------------+\r
+| Function   Name   : int i_APCI1564_Reset(comedi_device *dev)               |                                                       |\r
++----------------------------------------------------------------------------+\r
+| Task              :resets all the registers                                |\r
++----------------------------------------------------------------------------+\r
+| Input Parameters  : comedi_device *dev\r
++----------------------------------------------------------------------------+\r
+| Output Parameters :  --                                                                                                       |\r
++----------------------------------------------------------------------------+\r
+| Return Value      :                                                        |\r
+|                                                                               |\r
++----------------------------------------------------------------------------+\r
+*/\r
+         \r
+INT i_APCI1564_Reset(comedi_device *dev) \r
+{\r
+   outl(0x0 ,devpriv->i_IobaseAmcc+APCI1564_DIGITAL_IP_IRQ);//disable the interrupts\r
+   inl(devpriv->i_IobaseAmcc+APCI1564_DIGITAL_IP_INTERRUPT_STATUS);//Reset the interrupt status register         \r
+   outl (0x0 , devpriv->i_IobaseAmcc+APCI1564_DIGITAL_IP_INTERRUPT_MODE1);//Disable the and/or interrupt\r
+   outl (0x0 , devpriv->i_IobaseAmcc+APCI1564_DIGITAL_IP_INTERRUPT_MODE2);\r
+   devpriv->b_DigitalOutputRegister=0;\r
+   ui_Type=0;\r
+   outl(0x0,devpriv->i_IobaseAmcc+APCI1564_DIGITAL_OP);//Resets the output channels\r
+   outl(0x0,devpriv->i_IobaseAmcc+APCI1564_DIGITAL_OP_INTERRUPT);//Disables the interrupt.\r
+   outl(0x0,devpriv->i_IobaseAmcc+APCI1564_DIGITAL_OP_WATCHDOG+APCI1564_TCW_RELOAD_VALUE);  \r
+   outl(0x0,devpriv->i_IobaseAmcc+APCI1564_TIMER);\r
+   outl(0x0 , devpriv->i_IobaseAmcc + APCI1564_TIMER + APCI1564_TCW_PROG);\r
+\r
+   outl(0x0 , devpriv->iobase + APCI1564_COUNTER1 + APCI1564_TCW_PROG);\r
+   outl(0x0 , devpriv->iobase + APCI1564_COUNTER2 + APCI1564_TCW_PROG);\r
+   outl(0x0 , devpriv->iobase + APCI1564_COUNTER3 + APCI1564_TCW_PROG);\r
+   outl(0x0 , devpriv->iobase + APCI1564_COUNTER4 + APCI1564_TCW_PROG);\r
+   return 0;\r
+}        \r
index 447223fa7d1aec4e8e338c171d51f31bc111bcd7..89c3614fa3fe2e1c0d098f484af13ca031a9ae54 100644 (file)
@@ -1,21 +1,45 @@
+/**\r
+@verbatim\r
+\r
+Copyright (C) 2004,2005  ADDI-DATA GmbH for the source code of this module. \r
+        \r
+        ADDI-DATA GmbH \r
+        Dieselstrasse 3 \r
+        D-77833 Ottersweier \r
+        Tel: +19(0)7223/9493-0 \r
+        Fax: +49(0)7223/9493-92 \r
+        http://www.addi-data-com \r
+        info@addi-data.com \r
+\r
+This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.\r
+\r
+This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.\r
+\r
+You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+\r
+You shoud also find the complete GPL in the COPYING file accompanying this source code.\r
+\r
+@endverbatim\r
+*/\r
+\r
 /*********      Definitions for APCI-1564 card  *****/\r
 \r
-#define APCI1564_BOARD_VENDOR_ID                0x15B8
-#define APCI1564_ADDRESS_RANGE                  128
-
-//DIGITAL INPUT-OUTPUT DEFINE  
-// Input defines
-#define APCI1564_DIGITAL_IP                     0x04  
-#define APCI1564_DIGITAL_IP_INTERRUPT_MODE1     4
-#define APCI1564_DIGITAL_IP_INTERRUPT_MODE2     8
-#define APCI1564_DIGITAL_IP_IRQ                 16
-\r
-// Output defines
+#define APCI1564_BOARD_VENDOR_ID                0x15B8\r
+#define APCI1564_ADDRESS_RANGE                  128\r
+\r
+//DIGITAL INPUT-OUTPUT DEFINE  \r
+// Input defines\r
+#define APCI1564_DIGITAL_IP                     0x04  \r
+#define APCI1564_DIGITAL_IP_INTERRUPT_MODE1     4\r
+#define APCI1564_DIGITAL_IP_INTERRUPT_MODE2     8\r
+#define APCI1564_DIGITAL_IP_IRQ                 16\r
+\r
+// Output defines\r
 #define APCI1564_DIGITAL_OP                    0x18\r
 #define APCI1564_DIGITAL_OP_RW                 0    \r
 #define APCI1564_DIGITAL_OP_INTERRUPT           4   \r
-#define APCI1564_DIGITAL_OP_IRQ                 12  
-
+#define APCI1564_DIGITAL_OP_IRQ                 12  \r
+\r
 \r
 //Digital Input IRQ Function Selection\r
 #define ADDIDATA_OR                             0\r
 #define APCI1564_TCW_IRQ                           20\r
 #define APCI1564_TCW_WARN_TIMEVAL                  24\r
 #define APCI1564_TCW_WARN_TIMEBASE                 28\r
-
+\r
 \r
 // Hardware Layer  functions for Apci1564\r
-\r\r
-//DI
-// for di read
-INT i_APCI1564_ConfigDigitalInput(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data);
-INT i_APCI1564_Read1DigitalInput(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data);
-INT i_APCI1564_ReadMoreDigitalInput(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data);
-
-//DO
-int i_APCI1564_ConfigDigitalOutput(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data);
-INT i_APCI1564_WriteDigitalOutput(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data);
-INT i_APCI1564_ReadDigitalOutput(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data);
+\r
+\r
+//DI\r
+// for di read\r
+INT i_APCI1564_ConfigDigitalInput(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data);\r
+INT i_APCI1564_Read1DigitalInput(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data);\r
+INT i_APCI1564_ReadMoreDigitalInput(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data);\r
+\r
+//DO\r
+int i_APCI1564_ConfigDigitalOutput(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data);\r
+INT i_APCI1564_WriteDigitalOutput(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data);\r
+INT i_APCI1564_ReadDigitalOutput(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data);\r
 int i_APCI1564_ReadInterruptStatus(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data);  \r
 \r
 \r
 // TIMER  \r
 // timer value is passed as u seconds\r
-INT i_APCI1564_ConfigTimerCounterWatchdog (comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data);
-int i_APCI1564_StartStopWriteTimerCounterWatchdog(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data);
-int i_APCI1564_ReadTimerCounterWatchdog(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data);
-
-// INTERRUPT
-static VOID v_APCI1564_Interrupt(int irq, void *d, struct pt_regs *regs) ;
-
-// RESET
-INT i_APCI1564_Reset(comedi_device *dev);
+INT i_APCI1564_ConfigTimerCounterWatchdog (comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data);\r
+int i_APCI1564_StartStopWriteTimerCounterWatchdog(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data);\r
+int i_APCI1564_ReadTimerCounterWatchdog(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data);\r
+\r
+// INTERRUPT\r
+static VOID v_APCI1564_Interrupt(int irq, void *d, struct pt_regs *regs) ;\r
+\r
+// RESET\r
+INT i_APCI1564_Reset(comedi_device *dev);\r
diff --git a/comedi/drivers/addi-data/hwdrv_apci16xx.c b/comedi/drivers/addi-data/hwdrv_apci16xx.c
new file mode 100755 (executable)
index 0000000..b4b737d
--- /dev/null
@@ -0,0 +1,813 @@
+/**\r
+@verbatim\r
+\r
+Copyright (C) 2004,2005  ADDI-DATA GmbH for the source code of this module. \r
+        \r
+        ADDI-DATA GmbH \r
+        Dieselstrasse 3 \r
+        D-77833 Ottersweier \r
+        Tel: +19(0)7223/9493-0 \r
+        Fax: +49(0)7223/9493-92 \r
+        http://www.addi-data-com \r
+        info@addi-data.com \r
+\r
+This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.\r
+\r
+This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.\r
+\r
+You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+\r
+You shoud also find the complete GPL in the COPYING file accompanying this source code.\r
+\r
+@endverbatim\r
+*/\r
+/*\r
+    \r
+  +-----------------------------------------------------------------------+\r
+  | (C) ADDI-DATA GmbH          Dieselstraße 3       D-77833 Ottersweier  |\r
+  +-----------------------------------------------------------------------+\r
+  | Tel : +49 (0) 7223/9493-0     | email    : info@addi-data.com         |\r
+  | Fax : +49 (0) 7223/9493-92    | Internet : http://www.addi-data.com   |\r
+  +-----------------------------------------------------------------------+\r
+  | Project     : API APCI1648    | Compiler : gcc                        |\r
+  | Module name : TTL.C           | Version  : 2.96                       |\r
+  +-------------------------------+---------------------------------------+\r
+  | Project manager: S. Weber     | Date     :  25/05/2005                |\r
+  +-----------------------------------------------------------------------+\r
+  | Description :   APCI-16XX TTL I/O module                              |\r
+  |                                                                       |\r
+  |                                                                       |\r
+  +-----------------------------------------------------------------------+\r
+  |                             UPDATES                                   |\r
+  +-----------------------------------------------------------------------+\r
+  |   Date   |   Author  |          Description of updates                |\r
+  +----------+-----------+------------------------------------------------+\r
+  |25.05.2005| S.Weber   | Creation                                       |\r
+  |          |           |                                                |\r
+  +-----------------------------------------------------------------------+\r
+*/\r
+\r
+/*\r
++----------------------------------------------------------------------------+\r
+|                               Included files                               |\r
++----------------------------------------------------------------------------+\r
+*/\r
+\r
+#include "hwdrv_apci16xx.h"\r
+\r
+\r
+/*\r
++----------------------------------------------------------------------------+\r
+| Function Name     : INT   i_APCI16XX_InsnConfigInitTTLIO                   |\r
+|                          (comedi_device    *dev,                           |\r
+|                           comedi_subdevice *s,                             |\r
+|                           comedi_insn      *insn,                          |\r
+|                           lsampl_t         *data)                          |\r
++----------------------------------------------------------------------------+\r
+| Task           APCI16XX_TTL_INIT (using defaults)   :                      |\r
+|                Configure the TTL I/O operating mode from all ports         |\r
+|                You must calling this function be                           |\r
+|                for you call any other function witch access of TTL.        |\r
+|                APCI16XX_TTL_INITDIRECTION(user inputs for direction)       |\r
++----------------------------------------------------------------------------+\r
+| Input Parameters  : b_InitType    = (BYTE) data[0];                        |\r
+|                     b_Port0Mode   = (BYTE) data[1];                        |\r
+|                     b_Port1Mode   = (BYTE) data[2];                        |\r
+|                     b_Port2Mode   = (BYTE) data[3];                        |\r
+|                     b_Port3Mode   = (BYTE) data[4];                        |\r
+|                     ........                                               |\r
++----------------------------------------------------------------------------+\r
+| Output Parameters : -                                                      |\r
++----------------------------------------------------------------------------+\r
+| Return Value      :>0: No error                                            |\r
+|                    -1: Port 0 mode selection is wrong                      |\r
+|                    -2: Port 1 mode selection is wrong                      |\r
+|                    -3: Port 2 mode selection is wrong                      |\r
+|                    -4: Port 3 mode selection is wrong                      |\r
+|                    -X: Port X-1 mode selection is wrong                    |\r
+|                    ....                                                    |\r
+|                    -100 : Config command error                             |\r
+|                    -101 : Data size error                                  |\r
++----------------------------------------------------------------------------+\r
+*/\r
+\r
+\r
+int   i_APCI16XX_InsnConfigInitTTLIO(comedi_device    *dev,\r
+                                     comedi_subdevice *s,\r
+                                     comedi_insn      *insn,\r
+                                     lsampl_t         *data) \r
+       {\r
+       INT        i_ReturnValue            = insn->n;\r
+       BYTE       b_Command                = 0;\r
+       BYTE       b_Cpt                    = 0;\r
+       BYTE       b_NumberOfPort           = (BYTE) (devpriv->ps_BoardInfo->i_NbrTTLChannel / 8);\r
+       \r
+       \r
+       /************************/\r
+       /* Test the buffer size */\r
+       /************************/\r
+       \r
+       if (insn->n >= 1)\r
+          {\r
+          /*******************/\r
+          /* Get the command */\r
+          /* *****************/\r
+          \r
+          b_Command = (BYTE) data[0];\r
+          \r
+          /********************/\r
+          /* Test the command */\r
+          /********************/\r
+          \r
+          if ((b_Command == APCI16XX_TTL_INIT)          || \r
+              (b_Command == APCI16XX_TTL_INITDIRECTION) || \r
+              (b_Command == APCI16XX_TTL_OUTPUTMEMORY))\r
+             {\r
+             /***************************************/\r
+             /* Test the initialisation buffer size */\r
+             /***************************************/\r
+             \r
+             if ((b_Command == APCI16XX_TTL_INITDIRECTION) && ((BYTE) (insn->n - 1) != b_NumberOfPort))\r
+                {\r
+                /*******************/\r
+                /* Data size error */\r
+                /*******************/\r
+                \r
+                 printk("\nBuffer size error");\r
+                i_ReturnValue = -101;\r
+                }\r
+\r
+             if ((b_Command == APCI16XX_TTL_OUTPUTMEMORY) && ((BYTE) (insn->n) != 2))\r
+                {\r
+                /*******************/\r
+                /* Data size error */\r
+                /*******************/\r
+                \r
+                 printk("\nBuffer size error");\r
+                i_ReturnValue = -101;\r
+                }\r
+             }\r
+          else\r
+             {\r
+             /************************/\r
+             /* Config command error */\r
+             /************************/\r
+             \r
+             printk("\nCommand selection error");\r
+             i_ReturnValue = -100;\r
+             }\r
+          }\r
+       else\r
+          {\r
+          /*******************/\r
+          /* Data size error */\r
+          /*******************/\r
+              \r
+          printk("\nBuffer size error");\r
+          i_ReturnValue = -101;\r
+          }\r
+          \r
+          \r
+       /**************************************************************************/\r
+       /* Test if no error occur and APCI16XX_TTL_INITDIRECTION command selected */\r
+       /**************************************************************************/\r
+       \r
+       if ((i_ReturnValue >= 0) && (b_Command == APCI16XX_TTL_INITDIRECTION))\r
+          {\r
+          memset (devpriv->ul_TTLPortConfiguration, 0, sizeof(devpriv->ul_TTLPortConfiguration));\r
+\r
+          /*************************************/\r
+          /* Test the port direction selection */\r
+          /*************************************/\r
+          \r
+          for (b_Cpt = 1; (b_Cpt <= b_NumberOfPort) && (i_ReturnValue >= 0); b_Cpt ++)\r
+             {\r
+             /**********************/\r
+             /* Test the direction */\r
+             /**********************/\r
+             \r
+             if ((data[b_Cpt] != 0) && (data[b_Cpt] != 0xFF))\r
+                {\r
+                /************************/\r
+                 /* Port direction error */\r
+                 /************************/\r
+                 \r
+                printk("\nPort %d direction selection error", (INT) b_Cpt);\r
+                i_ReturnValue = - (INT) b_Cpt;\r
+                }\r
+             \r
+              /**************************/\r
+              /* Save the configuration */\r
+              /**************************/\r
+\r
+\r
+              devpriv->ul_TTLPortConfiguration[(b_Cpt - 1) / 4] = devpriv->ul_TTLPortConfiguration[(b_Cpt - 1) / 4] |\r
+                                                                  (data[b_Cpt] << (8 * ((b_Cpt - 1) % 4)));\r
+             }\r
+          }\r
+          \r
+       /**************************/\r
+       /* Test if no error occur */\r
+       /**************************/\r
+       \r
+       if (i_ReturnValue >= 0)\r
+          {\r
+          /***********************************/\r
+          /* Test if TTL port initilaisation */\r
+          /***********************************/\r
+          \r
+          if ((b_Command == APCI16XX_TTL_INIT) || (b_Command == APCI16XX_TTL_INITDIRECTION))\r
+             {\r
+             /******************************/\r
+             /* Set all port configuration */\r
+             /******************************/\r
+          \r
+             for (b_Cpt = 0; b_Cpt <= b_NumberOfPort; b_Cpt ++)\r
+                {\r
+                if ((b_Cpt % 4) == 0)\r
+                   {\r
+                   /*************************/\r
+                   /* Set the configuration */\r
+                   /*************************/\r
+\r
+                    outl(devpriv->ul_TTLPortConfiguration[b_Cpt / 4],devpriv->iobase + 32 + b_Cpt);\r
+                    }\r
+                 }\r
+              }\r
+          }\r
+       \r
+       /************************************************/\r
+       /* Test if output memory initialisation command */\r
+       /************************************************/\r
+          \r
+       if (b_Command == APCI16XX_TTL_OUTPUTMEMORY)\r
+          {\r
+           if  (data[1])\r
+              {\r
+              devpriv->b_OutputMemoryStatus = ADDIDATA_ENABLE; \r
+              }\r
+           else\r
+              {\r
+              devpriv->b_OutputMemoryStatus = ADDIDATA_DISABLE;\r
+              }\r
+          }\r
+\r
+       return (i_ReturnValue);\r
+       }\r
+\r
+\r
+/*\r
++----------------------------------------------------------------------------+\r
+|                            INPUT FUNCTIONS                                 |\r
++----------------------------------------------------------------------------+\r
+*/\r
+\r
+\r
+/*\r
++----------------------------------------------------------------------------+\r
+| Function Name     : INT     i_APCI16XX_InsnBitsReadTTLIO                   |\r
+|                          (comedi_device    *dev,                           |\r
+|                           comedi_subdevice *s,                             |\r
+|                           comedi_insn      *insn,                          |\r
+|                           lsampl_t         *data)                          |\r
++----------------------------------------------------------------------------+\r
+| Task              : Read the status from selected TTL digital input        |\r
+|                     (b_InputChannel)                                       |\r
++----------------------------------------------------------------------------+\r
+| Task              : Read the status from digital input port                |\r
+|                     (b_SelectedPort)                                       |\r
++----------------------------------------------------------------------------+\r
+| Input Parameters  :                                                        |\r
+|              APCI16XX_TTL_READCHANNEL                                      |\r
+|                    b_SelectedPort= CR_RANGE(insn->chanspec);               |\r
+|                    b_InputChannel= CR_CHAN(insn->chanspec);                |\r
+|                    b_ReadType          = (BYTE) data[0];                          |\r
+|                                                                            |\r
+|              APCI16XX_TTL_READPORT                                         |\r
+|                    b_SelectedPort= CR_RANGE(insn->chanspec);               |\r
+|                    b_ReadType          = (BYTE) data[0];                          |\r
++----------------------------------------------------------------------------+\r
+| Output Parameters : data[0]    0 : Channle is not active                   | \r
+|                                1 : Channle is active                       |\r
++----------------------------------------------------------------------------+\r
+| Return Value      : >0  : No error                                         |\r
+|                    -100 : Config command error                             |\r
+|                    -101 : Data size error                                  |\r
+|                    -102 : The selected TTL input port is wrong             |\r
+|                    -103 : The selected TTL digital input is wrong          |\r
++----------------------------------------------------------------------------+\r
+*/\r
+\r
+\r
+int  i_APCI16XX_InsnBitsReadTTLIO   (comedi_device    *dev,\r
+                                     comedi_subdevice *s,\r
+                                    comedi_insn      *insn,\r
+                                    lsampl_t         *data)\r
+       {\r
+       INT        i_ReturnValue            = insn->n;\r
+       BYTE       b_Command                = 0;\r
+       BYTE       b_NumberOfPort           = (BYTE) (devpriv->ps_BoardInfo->i_NbrTTLChannel / 8);\r
+       BYTE       b_SelectedPort           = CR_RANGE(insn->chanspec);\r
+       BYTE       b_InputChannel           = CR_CHAN(insn->chanspec);\r
+       BYTE *    pb_Status;\r
+       DWORD     dw_Status;\r
+       \r
+       /************************/\r
+       /* Test the buffer size */\r
+       /************************/\r
+       \r
+       if (insn->n >= 1)\r
+          {\r
+          /*******************/\r
+          /* Get the command */\r
+          /* *****************/\r
+          \r
+          b_Command = (BYTE) data[0];\r
+          \r
+          /********************/\r
+          /* Test the command */\r
+          /********************/\r
+          \r
+          if ((b_Command == APCI16XX_TTL_READCHANNEL) || (b_Command == APCI16XX_TTL_READPORT))\r
+             {\r
+             /**************************/\r
+             /* Test the selected port */\r
+             /**************************/\r
+             \r
+             if (b_SelectedPort < b_NumberOfPort)\r
+                {\r
+                 /**********************/\r
+                 /* Test if input port */\r
+                 /**********************/\r
+\r
+                 if (((devpriv->ul_TTLPortConfiguration[b_SelectedPort / 4] >> (8 * (b_SelectedPort % 4))) & 0xFF) == 0)\r
+                    {\r
+                    /***************************/\r
+                    /* Test the channel number */\r
+                    /***************************/\r
+\r
+                   if ((b_Command == APCI16XX_TTL_READCHANNEL) && (b_InputChannel > 7))\r
+                      {\r
+                      /*******************************************/\r
+                      /* The selected TTL digital input is wrong */\r
+                      /*******************************************/\r
+                   \r
+                       printk("\nChannel selection error");\r
+                      i_ReturnValue = -103;\r
+                      }\r
+                    }\r
+                 else\r
+                    {\r
+                   /****************************************/\r
+                    /* The selected TTL input port is wrong */\r
+                    /****************************************/\r
+                 \r
+                    printk("\nPort selection error");\r
+                    i_ReturnValue = -102;\r
+                    }\r
+                }\r
+             else\r
+                {\r
+                /****************************************/\r
+                 /* The selected TTL input port is wrong */\r
+                 /****************************************/\r
+                 \r
+                 printk("\nPort selection error");\r
+                 i_ReturnValue = -102;\r
+                 }\r
+              }\r
+          else\r
+             {\r
+             /************************/\r
+             /* Config command error */\r
+             /************************/\r
+             \r
+             printk("\nCommand selection error");\r
+             i_ReturnValue = -100;\r
+             }\r
+          }\r
+       else\r
+          {\r
+          /*******************/\r
+          /* Data size error */\r
+          /*******************/\r
+              \r
+          printk("\nBuffer size error");\r
+          i_ReturnValue = -101;\r
+          }\r
+          \r
+          \r
+       /**************************/\r
+       /* Test if no error occur */\r
+       /**************************/\r
+       \r
+       if (i_ReturnValue >= 0)\r
+          {\r
+           pb_Status = (PBYTE) &data[0];\r
+           \r
+           /*******************************/\r
+          /* Get the digital inpu status */\r
+           /*******************************/\r
+           \r
+          dw_Status = inl(devpriv->iobase + 8 + ((b_SelectedPort / 4) * 4));\r
+          dw_Status = (dw_Status >> (8 * (b_SelectedPort % 4))) & 0xFF;\r
+          \r
+          /***********************/\r
+          /* Save the port value */\r
+          /***********************/\r
+          \r
+          *pb_Status = (BYTE) dw_Status;\r
+          \r
+          /***************************************/\r
+          /* Test if read channel status command */\r
+          /***************************************/\r
+          \r
+          if (b_Command == APCI16XX_TTL_READCHANNEL)\r
+             {\r
+             *pb_Status = (*pb_Status >> b_InputChannel) & 1;\r
+             }\r
+          }\r
+\r
+       return (i_ReturnValue);\r
+       }\r
+\r
+\r
+\r
+/*\r
++----------------------------------------------------------------------------+\r
+| Function Name     : INT i_APCI16XX_InsnReadTTLIOAllPortValue               |\r
+|                          (comedi_device    *dev,                           |\r
+|                           comedi_subdevice *s,                             |\r
+|                           comedi_insn      *insn,                          |\r
+|                           lsampl_t         *data)                          |\r
++----------------------------------------------------------------------------+\r
+| Task              : Read the status from all digital input ports           |\r
++----------------------------------------------------------------------------+\r
+| Input Parameters  : -                                                      |\r
++----------------------------------------------------------------------------+\r
+| Output Parameters : data[0] : Port 0 to 3 data                             |\r
+|                     data[1] : Port 4 to 7 data                             |\r
+|                     ....                                                   |\r
++----------------------------------------------------------------------------+\r
+| Return Value      : 0: No error                                            |\r
+|                    -100 : Read command error                               |\r
+|                    -101 : Data size error                                  |\r
++----------------------------------------------------------------------------+\r
+*/\r
+\r
+int i_APCI16XX_InsnReadTTLIOAllPortValue (comedi_device    *dev,\r
+                                          comedi_subdevice *s,\r
+                                          comedi_insn      *insn,\r
+                                          lsampl_t         *data)\r
+       {\r
+       BYTE         b_Command              = (BYTE) CR_AREF(insn->chanspec);\r
+       INT          i_ReturnValue          = insn->n;\r
+       BYTE         b_Cpt                  = 0;\r
+       BYTE         b_NumberOfPort         = 0;\r
+       lsampl_t * pls_ReadData             = data;\r
+       \r
+       /********************/\r
+       /* Test the command */\r
+       /********************/\r
+          \r
+       if ((b_Command == APCI16XX_TTL_READ_ALL_INPUTS) || (b_Command == APCI16XX_TTL_READ_ALL_OUTPUTS))\r
+          {\r
+          /**********************************/\r
+          /* Get the number of 32-Bit ports */\r
+          /**********************************/\r
+       \r
+          b_NumberOfPort = (BYTE) (devpriv->ps_BoardInfo->i_NbrTTLChannel / 32);\r
+          if ((b_NumberOfPort * 32) < devpriv->ps_BoardInfo->i_NbrTTLChannel)\r
+             {\r
+             b_NumberOfPort = b_NumberOfPort + 1;\r
+             }\r
+       \r
+          /************************/\r
+          /* Test the buffer size */\r
+          /************************/\r
+       \r
+          if (insn->n >= b_NumberOfPort)\r
+             {\r
+              if (b_Command == APCI16XX_TTL_READ_ALL_INPUTS)\r
+                 {\r
+                 /**************************/\r
+                 /* Read all digital input */\r
+                 /**************************/\r
+          \r
+                for (b_Cpt = 0; b_Cpt < b_NumberOfPort; b_Cpt ++)\r
+                   {\r
+                   /************************/\r
+                   /* Read the 32-Bit port */\r
+                   /************************/\r
+             \r
+                   pls_ReadData [b_Cpt]  = inl(devpriv->iobase + 8 + (b_Cpt * 4));\r
+           \r
+                   /**************************************/\r
+                   /* Mask all channels used als outputs */\r
+                   /**************************************/\r
+            \r
+                   pls_ReadData [b_Cpt]  = pls_ReadData [b_Cpt]  & (~devpriv->ul_TTLPortConfiguration[b_Cpt]);\r
+                   }\r
+                }\r
+             else\r
+                 {\r
+                 /****************************/\r
+                 /* Read all digital outputs */\r
+                 /****************************/\r
+          \r
+                for (b_Cpt = 0; b_Cpt < b_NumberOfPort; b_Cpt ++)\r
+                   {\r
+                   /************************/\r
+                   /* Read the 32-Bit port */\r
+                   /************************/\r
+             \r
+                   pls_ReadData [b_Cpt] = inl(devpriv->iobase + 20 + (b_Cpt * 4));\r
+            \r
+                   /**************************************/\r
+                   /* Mask all channels used als outputs */\r
+                   /**************************************/\r
+             \r
+                   pls_ReadData [b_Cpt]  = pls_ReadData [b_Cpt]  & devpriv->ul_TTLPortConfiguration[b_Cpt];\r
+                   }\r
+                }\r
+             }\r
+          else\r
+             {\r
+             /*******************/\r
+             /* Data size error */\r
+             /*******************/\r
+              \r
+             printk("\nBuffer size error");\r
+             i_ReturnValue = -101;\r
+             }\r
+          }\r
+       else\r
+          {\r
+          /*****************/\r
+          /* Command error */\r
+          /*****************/\r
+             \r
+          printk("\nCommand selection error");\r
+          i_ReturnValue = -100;\r
+          }\r
+\r
+       return (i_ReturnValue);\r
+       }\r
+\r
+/*\r
++----------------------------------------------------------------------------+\r
+|                            OUTPUT FUNCTIONS                                |\r
++----------------------------------------------------------------------------+\r
+*/\r
+\r
+/*\r
++----------------------------------------------------------------------------+\r
+| Function Name     : INT     i_APCI16XX_InsnBitsWriteTTLIO                  |\r
+|                          (comedi_device    *dev,                           |\r
+|                           comedi_subdevice *s,                             |\r
+|                           comedi_insn      *insn,                          |\r
+|                           lsampl_t         *data)                          |\r
++----------------------------------------------------------------------------+\r
+| Task              : Set the state from selected TTL digital output         |\r
+|                     (b_OutputChannel)                                      |\r
++----------------------------------------------------------------------------+\r
+| Task              : Set the state from digital output port                 |\r
+|                     (b_SelectedPort)                                       |\r
++----------------------------------------------------------------------------+\r
+| Input Parameters  :                                                        |\r
+|              APCI16XX_TTL_WRITECHANNEL_ON | APCI16XX_TTL_WRITECHANNEL_OFF  |\r
+|                    b_SelectedPort = CR_RANGE(insn->chanspec);              |\r
+|                    b_OutputChannel= CR_CHAN(insn->chanspec);               |\r
+|                    b_Command      = (BYTE) data[0];                        |\r
+|                                                                            |\r
+|              APCI16XX_TTL_WRITEPORT_ON | APCI16XX_TTL_WRITEPORT_OFF        |\r
+|                    b_SelectedPort = CR_RANGE(insn->chanspec);              |\r
+|                    b_Command      = (BYTE) data[0];                        |\r
++----------------------------------------------------------------------------+\r
+| Output Parameters : data[0] : TTL output port 0 to 3 data                  |\r
+|                     data[1] : TTL output port 4 to 7 data                  |\r
+|                     ....                                                   |\r
++----------------------------------------------------------------------------+\r
+| Return Value      : >0  : No error                                         |\r
+|                    -100 : Command error                                    |\r
+|                    -101 : Data size error                                  |\r
+|                    -102 : The selected TTL output port is wrong            |\r
+|                    -103 : The selected TTL digital output is wrong         |\r
+|                    -104 : Output memory disabled                           |\r
++----------------------------------------------------------------------------+\r
+*/\r
+\r
+\r
+int  i_APCI16XX_InsnBitsWriteTTLIO   (comedi_device    *dev,\r
+                                      comedi_subdevice *s,\r
+                                      comedi_insn      *insn,\r
+                                      lsampl_t         *data)\r
+       {\r
+       INT          i_ReturnValue          = insn->n;\r
+       BYTE         b_Command              = 0;\r
+       BYTE         b_NumberOfPort         = (BYTE) (devpriv->ps_BoardInfo->i_NbrTTLChannel / 8);\r
+       BYTE         b_SelectedPort         = CR_RANGE(insn->chanspec);\r
+       BYTE         b_OutputChannel        = CR_CHAN(insn->chanspec);\r
+       DWORD       dw_Status               = 0;\r
+\r
+       \r
+       /************************/\r
+       /* Test the buffer size */\r
+       /************************/\r
+       \r
+       if (insn->n >= 1)\r
+          {\r
+          /*******************/\r
+          /* Get the command */\r
+          /* *****************/\r
+          \r
+          b_Command = (BYTE) data[0];\r
+          \r
+          /********************/\r
+          /* Test the command */\r
+          /********************/\r
+          \r
+          if ((b_Command == APCI16XX_TTL_WRITECHANNEL_ON)  || \r
+              (b_Command == APCI16XX_TTL_WRITEPORT_ON)     ||\r
+              (b_Command == APCI16XX_TTL_WRITECHANNEL_OFF) ||\r
+              (b_Command == APCI16XX_TTL_WRITEPORT_OFF))\r
+             {\r
+             /**************************/\r
+             /* Test the selected port */\r
+             /**************************/\r
+             \r
+             if (b_SelectedPort < b_NumberOfPort)\r
+                {\r
+                 /***********************/\r
+                 /* Test if output port */\r
+                 /***********************/\r
+\r
+                 if (((devpriv->ul_TTLPortConfiguration[b_SelectedPort / 4] >> (8 * (b_SelectedPort % 4))) & 0xFF) == 0xFF)\r
+                    {\r
+                    /***************************/\r
+                    /* Test the channel number */\r
+                    /***************************/\r
+\r
+                    if (((b_Command == APCI16XX_TTL_WRITECHANNEL_ON) || \r
+                         (b_Command == APCI16XX_TTL_WRITECHANNEL_OFF)) && (b_OutputChannel > 7))\r
+                      {\r
+                      /********************************************/\r
+                      /* The selected TTL digital output is wrong */\r
+                      /********************************************/\r
+                   \r
+                       printk("\nChannel selection error");\r
+                      i_ReturnValue = -103;\r
+                      }\r
+                    \r
+                    if (((b_Command == APCI16XX_TTL_WRITECHANNEL_OFF) ||\r
+                        (b_Command == APCI16XX_TTL_WRITEPORT_OFF)) && (devpriv->b_OutputMemoryStatus == ADDIDATA_DISABLE))\r
+                      {\r
+                      /********************************************/\r
+                      /* The selected TTL digital output is wrong */\r
+                      /********************************************/\r
+                   \r
+                       printk("\nOutput memory disabled");\r
+                      i_ReturnValue = -104;\r
+                      }\r
+\r
+                   /************************/\r
+                   /* Test the buffer size */\r
+                   /************************/\r
+\r
+                    if (((b_Command == APCI16XX_TTL_WRITEPORT_ON) ||\r
+                        (b_Command == APCI16XX_TTL_WRITEPORT_OFF)) && (insn->n < 2))\r
+                      {\r
+                      /*******************/\r
+                      /* Data size error */\r
+                      /*******************/\r
+              \r
+                      printk("\nBuffer size error");\r
+                      i_ReturnValue = -101;\r
+                      }\r
+                   }\r
+                 else\r
+                    {\r
+                   /*****************************************/\r
+                    /* The selected TTL output port is wrong */\r
+                    /*****************************************/\r
+                 \r
+                    printk("\nPort selection error %lX", devpriv->ul_TTLPortConfiguration[0]);\r
+                    i_ReturnValue = -102;\r
+                    }\r
+                }\r
+             else\r
+                {\r
+                /****************************************/\r
+                 /* The selected TTL output port is wrong */\r
+                 /****************************************/\r
+                 \r
+                 printk("\nPort selection error %d %d",b_SelectedPort , b_NumberOfPort);\r
+                 i_ReturnValue = -102;\r
+                 }\r
+              }\r
+          else\r
+             {\r
+             /************************/\r
+             /* Config command error */\r
+             /************************/\r
+             \r
+             printk("\nCommand selection error");\r
+             i_ReturnValue = -100;\r
+             }\r
+          }\r
+       else\r
+          {\r
+          /*******************/\r
+          /* Data size error */\r
+          /*******************/\r
+              \r
+          printk("\nBuffer size error");\r
+          i_ReturnValue = -101;\r
+          }\r
+          \r
+          \r
+       /**************************/\r
+       /* Test if no error occur */\r
+       /**************************/\r
+       \r
+       if (i_ReturnValue >= 0)\r
+          {\r
+           /********************************/\r
+          /* Get the digital output state */\r
+           /********************************/\r
+             \r
+          dw_Status = inl(devpriv->iobase + 20 + ((b_SelectedPort / 4) * 4));\r
+\r
+          /**********************************/\r
+          /* Test if output memory not used */\r
+          /**********************************/\r
+           \r
+          if (devpriv->b_OutputMemoryStatus == ADDIDATA_DISABLE)\r
+             {\r
+             /*********************************/\r
+             /* Clear the selected port value */\r
+             /*********************************/\r
+             \r
+             dw_Status = dw_Status & (0xFFFFFFFFUL - (0xFFUL << (8 * (b_SelectedPort % 4))));\r
+             }\r
+            \r
+          /******************************/\r
+          /* Test if setting channel ON */\r
+          /******************************/ \r
+          \r
+          if (b_Command == APCI16XX_TTL_WRITECHANNEL_ON)\r
+             {\r
+             dw_Status = dw_Status | (1UL << ((8 * (b_SelectedPort % 4)) + b_OutputChannel));\r
+             }\r
+\r
+          /***************************/\r
+          /* Test if setting port ON */\r
+          /***************************/ \r
+             \r
+          if (b_Command == APCI16XX_TTL_WRITEPORT_ON)\r
+             {\r
+             dw_Status = dw_Status | ((data[1] & 0xFF) << (8 * (b_SelectedPort % 4)));\r
+             }\r
+\r
+          /*******************************/\r
+          /* Test if setting channel OFF */\r
+          /*******************************/ \r
+          \r
+          if (b_Command == APCI16XX_TTL_WRITECHANNEL_OFF)\r
+             {\r
+             dw_Status = dw_Status & (0xFFFFFFFFUL - (1UL << ((8 * (b_SelectedPort % 4)) + b_OutputChannel)));\r
+             }\r
+                   \r
+          /****************************/\r
+          /* Test if setting port OFF */\r
+          /****************************/ \r
+             \r
+          if (b_Command == APCI16XX_TTL_WRITEPORT_OFF)\r
+             {\r
+             dw_Status = dw_Status & (0xFFFFFFFFUL - ((data[1] & 0xFF) << (8 * (b_SelectedPort % 4))));\r
+             }\r
+          \r
+          \r
+           outl(dw_Status, devpriv->iobase + 20 + ((b_SelectedPort / 4) * 4));\r
+          }\r
+\r
+       return (i_ReturnValue);\r
+       }\r
+\r
+/*\r
++----------------------------------------------------------------------------+\r
+| Function   Name   : int i_APCI2200_Reset(comedi_device *dev)               |                                                         +----------------------------------------------------------------------------+\r
+| Task              :resets all the registers                                |\r
++----------------------------------------------------------------------------+\r
+| Input Parameters  : comedi_device *dev                                     |\r
++----------------------------------------------------------------------------+\r
+| Output Parameters : -                                                      |\r
++----------------------------------------------------------------------------+\r
+| Return Value      : -                                                      |\r
++----------------------------------------------------------------------------+\r
+*/\r
+         \r
+int  i_APCI16XX_Reset(comedi_device *dev) \r
+       {\r
+       return 0;\r
+       }        \r
diff --git a/comedi/drivers/addi-data/hwdrv_apci16xx.h b/comedi/drivers/addi-data/hwdrv_apci16xx.h
new file mode 100755 (executable)
index 0000000..4f1517c
--- /dev/null
@@ -0,0 +1,111 @@
+/**\r
+@verbatim\r
+\r
+Copyright (C) 2004,2005  ADDI-DATA GmbH for the source code of this module. \r
+        \r
+        ADDI-DATA GmbH \r
+        Dieselstrasse 3 \r
+        D-77833 Ottersweier \r
+        Tel: +19(0)7223/9493-0 \r
+        Fax: +49(0)7223/9493-92 \r
+        http://www.addi-data-com \r
+        info@addi-data.com \r
+\r
+This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.\r
+\r
+This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.\r
+\r
+You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+\r
+You shoud also find the complete GPL in the COPYING file accompanying this source code.\r
+\r
+@endverbatim\r
+*/\r
+\r
+\r
+\r
+#ifndef COMEDI_SUBD_TTLIO\r
+   #define COMEDI_SUBD_TTLIO   11  /* Digital Input Output But TTL */\r
+#endif\r
+\r
+#ifndef ADDIDATA_ENABLE\r
+   #define ADDIDATA_ENABLE  1\r
+   #define ADDIDATA_DISABLE 0\r
+#endif\r
+\r
+#define APCI16XX_TTL_INIT           0\r
+#define APCI16XX_TTL_INITDIRECTION  1\r
+#define APCI16XX_TTL_OUTPUTMEMORY   2\r
+\r
+\r
+#define APCI16XX_TTL_READCHANNEL            0\r
+#define APCI16XX_TTL_READPORT               1\r
+\r
+#define APCI16XX_TTL_WRITECHANNEL_ON        0\r
+#define APCI16XX_TTL_WRITECHANNEL_OFF       1\r
+#define APCI16XX_TTL_WRITEPORT_ON           2\r
+#define APCI16XX_TTL_WRITEPORT_OFF          3\r
+\r
+#define APCI16XX_TTL_READ_ALL_INPUTS        0\r
+#define APCI16XX_TTL_READ_ALL_OUTPUTS       1\r
+\r
+#ifdef __KERNEL__\r
+\r
+\r
+comedi_lrange range_apci16xx_ttl=\r
+              {12, \r
+               {BIP_RANGE(1),\r
+                BIP_RANGE(1),\r
+                BIP_RANGE(1),\r
+                BIP_RANGE(1),\r
+                BIP_RANGE(1),\r
+                BIP_RANGE(1),\r
+                BIP_RANGE(1),\r
+                BIP_RANGE(1),\r
+                BIP_RANGE(1),\r
+                BIP_RANGE(1),\r
+                BIP_RANGE(1),\r
+                BIP_RANGE(1)}};\r
+\r
+/*\r
++----------------------------------------------------------------------------+\r
+|                       TTL INISIALISATION FUNCTION                          |\r
++----------------------------------------------------------------------------+\r
+*/\r
+\r
+int   i_APCI16XX_InsnConfigInitTTLIO(comedi_device    *dev,\r
+                                     comedi_subdevice *s,\r
+                                     comedi_insn      *insn,\r
+                                     lsampl_t         *data);\r
+\r
+\r
+/*\r
++----------------------------------------------------------------------------+\r
+|                       TTL INPUT FUNCTION                                   |\r
++----------------------------------------------------------------------------+\r
+*/\r
+\r
+\r
+int  i_APCI16XX_InsnBitsReadTTLIO   (comedi_device    *dev,\r
+                                     comedi_subdevice *s,\r
+                                     comedi_insn      *insn,\r
+                                     lsampl_t         *data);\r
+\r
+int i_APCI16XX_InsnReadTTLIOAllPortValue (comedi_device    *dev,\r
+                                          comedi_subdevice *s,\r
+                                          comedi_insn      *insn,\r
+                                          lsampl_t         *data);\r
+\r
+/*\r
++----------------------------------------------------------------------------+\r
+|                            TTL OUTPUT FUNCTIONS                            |\r
++----------------------------------------------------------------------------+\r
+*/\r
+\r
+int  i_APCI16XX_InsnBitsWriteTTLIO   (comedi_device    *dev,\r
+                                      comedi_subdevice *s,\r
+                                      comedi_insn      *insn,\r
+                                      lsampl_t         *data);\r
+                                      \r
+int  i_APCI16XX_Reset(comedi_device *dev) ;                                      \r
+#endif\r
index d8af11687c0b81657a487f839b6d3af1f8638e95..69a81ee2b48f61c3d29ad324bc0f565774fb1708 100644 (file)
@@ -1,14 +1,38 @@
+/**\r
+@verbatim\r
+\r
+Copyright (C) 2004,2005  ADDI-DATA GmbH for the source code of this module. \r
+        \r
+        ADDI-DATA GmbH \r
+        Dieselstrasse 3 \r
+        D-77833 Ottersweier \r
+        Tel: +19(0)7223/9493-0 \r
+        Fax: +49(0)7223/9493-92 \r
+        http://www.addi-data-com \r
+        info@addi-data.com \r
+\r
+This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.\r
+\r
+This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.\r
+\r
+You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+\r
+You shoud also find the complete GPL in the COPYING file accompanying this source code.\r
+\r
+@endverbatim\r
+*/\r
 /*\r
+    \r
   +-----------------------------------------------------------------------+\r
   | (C) ADDI-DATA GmbH          Dieselstraße 3       D-77833 Ottersweier  |\r
   +-----------------------------------------------------------------------+\r
   | Tel : +49 (0) 7223/9493-0     | email    : info@addi-data.com         |\r
   | Fax : +49 (0) 7223/9493-92    | Internet : http://www.addi-data.com   |\r
   +-------------------------------+---------------------------------------+\r
-  | Project     : 13Card Linux Driver | Compiler   : GCC                  |\r
-  | Module name : hwdrv_apci2016.c|     Version    : 2.96                 |\r
+  | Project     : APCI-2016       | Compiler   : GCC                      |\r
+  | Module name : hwdrv_apci2016.c| Version    : 2.96                     |\r
   +-------------------------------+---------------------------------------+\r
-  | Author : Shitalkumar S Chavan |     Date       : 31.10.2001           |\r
+  | Project manager: Eric Stolz   | Date       :  02/12/2002              |\r
   +-------------------------------+---------------------------------------+\r
   | Description :   Hardware Layer Acces For APCI-2016                    |\r
   +-----------------------------------------------------------------------+\r
 |                               Included files                               |\r
 +----------------------------------------------------------------------------+\r
 */\r
-#include "hwdrv_apci2016.h"
+#include "hwdrv_apci2016.h"\r
 \r
 /*\r
 +----------------------------------------------------------------------------+\r
 | Function   Name   : int i_APCI2016_ConfigDigitalOutput                     |\r
-|                        (comedi_device *dev,comedi_subdevice *s,               | 
-|                      comedi_insn *insn,lsampl_t *data)                     |
+|                        (comedi_device *dev,comedi_subdevice *s,               | \r
+|                      comedi_insn *insn,lsampl_t *data)                     |\r
 +----------------------------------------------------------------------------+\r
 | Task              : Configures The Digital Output Subdevice.               |\r
 +----------------------------------------------------------------------------+\r
 */\r
 int i_APCI2016_ConfigDigitalOutput(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data) \r
 {\r
-  if  ((data[0]!=0) && (data[0]!=1)) 
-     {   
-     comedi_error(dev,"Not a valid Data !!! ,Data should be 1 or 0\n");  
-     return -EINVAL;
-     } // if  ((data[0]!=0) && (data[0]!=1)) 
-  if  (data[0])
-     {
-     devpriv->b_OutputMemoryStatus = ADDIDATA_ENABLE ; 
-     } // if  (data[0]
-  else
-     {
-     devpriv->b_OutputMemoryStatus = ADDIDATA_DISABLE;
-     } // else if  (data[0]
+  if  ((data[0]!=0) && (data[0]!=1)) \r
+     {   \r
+     comedi_error(dev,"Not a valid Data !!! ,Data should be 1 or 0\n");  \r
+     return -EINVAL;\r
+     } // if  ((data[0]!=0) && (data[0]!=1)) \r
+  if  (data[0])\r
+     {\r
+     devpriv->b_OutputMemoryStatus = ADDIDATA_ENABLE ; \r
+     } // if  (data[0]\r
+  else\r
+     {\r
+     devpriv->b_OutputMemoryStatus = ADDIDATA_DISABLE;\r
+     } // else if  (data[0]\r
   return insn->n;\r
 }\r
 \r
 /*\r
 +----------------------------------------------------------------------------+\r
 | Function   Name   : int i_APCI2016_WriteDigitalOutput                      |\r
-|                        (comedi_device *dev,comedi_subdevice *s,               |
-|                      comedi_insn *insn,lsampl_t *data)                     |
+|                        (comedi_device *dev,comedi_subdevice *s,               |\r
+|                      comedi_insn *insn,lsampl_t *data)                     |\r
 +----------------------------------------------------------------------------+\r
 | Task              : Writes port value  To the selected port                |\r
 +----------------------------------------------------------------------------+\r
@@ -90,202 +114,202 @@ int i_APCI2016_ConfigDigitalOutput(comedi_device *dev,comedi_subdevice *s,comedi
 */\r
 int i_APCI2016_WriteDigitalOutput(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data)  \r
 {\r
-   UINT  ui_NoOfChannel;
-   UINT ui_Temp,ui_Temp1;
-   ui_NoOfChannel=CR_CHAN(insn->chanspec);
-   if  ((ui_NoOfChannel<0) || (ui_NoOfChannel>15)) 
-      {   
-      comedi_error(dev,"Invalid Channel Numbers !!!, Channel Numbers must be between 0 and 15\n");  
-      return -EINVAL;
-      } // if  ((ui_NoOfChannel<0) || (ui_NoOfChannel>15))
-   if  (devpriv->b_OutputMemoryStatus )
-      {
-      ui_Temp=inw(devpriv->iobase+APCI2016_DIGITAL_OP);
-      } // if  (devpriv->b_OutputMemoryStatus )
-   else
-      { 
-      ui_Temp=0;
-      } // else if  (devpriv->b_OutputMemoryStatus )
-   if  ((data[1]!=0) && (data[1]!=1)) 
-      {   
-      comedi_error(dev,"Invalid Data[1] value !!!, Data[1] should be 0 or 1\n");  
-      return -EINVAL;
-      } // if  ((data[1]!=0) && (data[1]!=1))
-  
-   if  (data[3]==0)
-      { 
-      if  (data[1]==0)
-         {
-         data[0]=(data[0] << ui_NoOfChannel)|ui_Temp;
-         outw(data[0],devpriv->iobase+APCI2016_DIGITAL_OP); 
-         } // if (data[1]==0) 
-      else
-         {
-         if  (data[1]==1)
-            {   
-            switch (ui_NoOfChannel)
-              {
-               case 2:  data[0]=(data[0] << (2*data[2]))|ui_Temp; 
-                       break;
-               case 4:  data[0]=(data[0] << (4*data[2]))|ui_Temp;
-                       break;
-               case 8:  data[0]=(data[0] << (8*data[2]))|ui_Temp;
-                       break;
-               case 15: data[0]=data[0]|ui_Temp; 
-                        break;
-               default: comedi_error(dev," chan spec wrong");
-                        return -EINVAL;   // "sorry channel spec wrong "  
-               }//switch(ui_NoOfChannels)
-            outw(data[0],devpriv->iobase+APCI2016_DIGITAL_OP);
-            }// if  (data[1]==1)
-         else
-            {
-            printk("\nSpecified channel not supported\n");
-            } // else if  (data[1]==1)
-         } // else if (data[1]==0)
-      } // if (data[3]==0)
-   else
-      {
-      if  (data[3]==1)
-         {
-         if  (data[1]==0)
-            {
-            data[0]=~data[0]&0x1;
-            ui_Temp1=1;
-            ui_Temp1=ui_Temp1<<ui_NoOfChannel;
-            ui_Temp=ui_Temp|ui_Temp1;  
-            data[0]=(data[0] << ui_NoOfChannel)^0xffff;
-            data[0]=data[0]& ui_Temp; 
-            outw(data[0],devpriv->iobase+APCI2016_DIGITAL_OP); 
-            } // if  (data[1]==0) 
-         else
-            {
-            if  (data[1]==1)
-               { 
-               switch (ui_NoOfChannel)
-                 {
-                  case 2: data[0]=~data[0]&0x3; 
-                          ui_Temp1=3;
-                          ui_Temp1=ui_Temp1<<2*data[2];
-                          ui_Temp=ui_Temp|ui_Temp1;   
-                          data[0]=((data[0] << (2*data[2]))^0xffff)& ui_Temp; 
-                         break;
-                  case 4: data[0]=~data[0]&0xf;
-                          ui_Temp1=15;
-                          ui_Temp1=ui_Temp1<<4*data[2];
-                          ui_Temp=ui_Temp|ui_Temp1;    
-                          data[0]=((data[0] << (4*data[2]))^0xffff)&ui_Temp;
-                         break;
-                  case 8: data[0]=~data[0]&0xff;
-                          ui_Temp1=255;
-                          ui_Temp1=ui_Temp1<<8*data[2];
-                          ui_Temp=ui_Temp|ui_Temp1;    
-                          data[0]=((data[0] << (8*data[2]))^0xffff)&ui_Temp;
-                          break;
-                 case 15: break;
-                 default: comedi_error(dev," chan spec wrong");
-                             return -EINVAL;   // "sorry channel spec wrong "  
-                 }//switch(ui_NoOfChannels)
-              outw(data[0],devpriv->iobase+APCI2016_DIGITAL_OP);
-              }// if(data[1]==1)
-           else
-              {
-              printk("\nSpecified channel not supported\n");
-              }//else if(data[1]==1)
-           }//elseif(data[1]==0)
-        }//if(data[3]==1);
-     else
-        {
-        printk("\nSpecified functionality does not exist\n");
-        return -EINVAL;
-        }//if else data[3]==1)
-     }//if else data[3]==0) 
-  return insn->n;
-}
+   UINT  ui_NoOfChannel;\r
+   UINT ui_Temp,ui_Temp1;\r
+   ui_NoOfChannel=CR_CHAN(insn->chanspec);\r
+   if  ((ui_NoOfChannel<0) || (ui_NoOfChannel>15)) \r
+      {   \r
+      comedi_error(dev,"Invalid Channel Numbers !!!, Channel Numbers must be between 0 and 15\n");  \r
+      return -EINVAL;\r
+      } // if  ((ui_NoOfChannel<0) || (ui_NoOfChannel>15))\r
+   if  (devpriv->b_OutputMemoryStatus )\r
+      {\r
+      ui_Temp=inw(devpriv->iobase+APCI2016_DIGITAL_OP);\r
+      } // if  (devpriv->b_OutputMemoryStatus )\r
+   else\r
+      { \r
+      ui_Temp=0;\r
+      } // else if  (devpriv->b_OutputMemoryStatus )\r
+   if  ((data[1]!=0) && (data[1]!=1)) \r
+      {   \r
+      comedi_error(dev,"Invalid Data[1] value !!!, Data[1] should be 0 or 1\n");  \r
+      return -EINVAL;\r
+      } // if  ((data[1]!=0) && (data[1]!=1))\r
+  \r
+   if  (data[3]==0)\r
+      { \r
+      if  (data[1]==0)\r
+         {\r
+         data[0]=(data[0] << ui_NoOfChannel)|ui_Temp;\r
+         outw(data[0],devpriv->iobase+APCI2016_DIGITAL_OP); \r
+         } // if (data[1]==0) \r
+      else\r
+         {\r
+         if  (data[1]==1)\r
+            {   \r
+            switch (ui_NoOfChannel)\r
+              {\r
+               case 2:  data[0]=(data[0] << (2*data[2]))|ui_Temp; \r
+                       break;\r
+               case 4:  data[0]=(data[0] << (4*data[2]))|ui_Temp;\r
+                       break;\r
+               case 8:  data[0]=(data[0] << (8*data[2]))|ui_Temp;\r
+                       break;\r
+               case 15: data[0]=data[0]|ui_Temp; \r
+                        break;\r
+               default: comedi_error(dev," chan spec wrong");\r
+                        return -EINVAL;   // "sorry channel spec wrong "  \r
+               }//switch(ui_NoOfChannels)\r
+            outw(data[0],devpriv->iobase+APCI2016_DIGITAL_OP);\r
+            }// if  (data[1]==1)\r
+         else\r
+            {\r
+            printk("\nSpecified channel not supported\n");\r
+            } // else if  (data[1]==1)\r
+         } // else if (data[1]==0)\r
+      } // if (data[3]==0)\r
+   else\r
+      {\r
+      if  (data[3]==1)\r
+         {\r
+         if  (data[1]==0)\r
+            {\r
+            data[0]=~data[0]&0x1;\r
+            ui_Temp1=1;\r
+            ui_Temp1=ui_Temp1<<ui_NoOfChannel;\r
+            ui_Temp=ui_Temp|ui_Temp1;  \r
+            data[0]=(data[0] << ui_NoOfChannel)^0xffff;\r
+            data[0]=data[0]& ui_Temp; \r
+            outw(data[0],devpriv->iobase+APCI2016_DIGITAL_OP); \r
+            } // if  (data[1]==0) \r
+         else\r
+            {\r
+            if  (data[1]==1)\r
+               { \r
+               switch (ui_NoOfChannel)\r
+                 {\r
+                  case 2: data[0]=~data[0]&0x3; \r
+                          ui_Temp1=3;\r
+                          ui_Temp1=ui_Temp1<<2*data[2];\r
+                          ui_Temp=ui_Temp|ui_Temp1;   \r
+                          data[0]=((data[0] << (2*data[2]))^0xffff)& ui_Temp; \r
+                         break;\r
+                  case 4: data[0]=~data[0]&0xf;\r
+                          ui_Temp1=15;\r
+                          ui_Temp1=ui_Temp1<<4*data[2];\r
+                          ui_Temp=ui_Temp|ui_Temp1;    \r
+                          data[0]=((data[0] << (4*data[2]))^0xffff)&ui_Temp;\r
+                         break;\r
+                  case 8: data[0]=~data[0]&0xff;\r
+                          ui_Temp1=255;\r
+                          ui_Temp1=ui_Temp1<<8*data[2];\r
+                          ui_Temp=ui_Temp|ui_Temp1;    \r
+                          data[0]=((data[0] << (8*data[2]))^0xffff)&ui_Temp;\r
+                          break;\r
+                 case 15: break;\r
+                 default: comedi_error(dev," chan spec wrong");\r
+                             return -EINVAL;   // "sorry channel spec wrong "  \r
+                 }//switch(ui_NoOfChannels)\r
+              outw(data[0],devpriv->iobase+APCI2016_DIGITAL_OP);\r
+              }// if(data[1]==1)\r
+           else\r
+              {\r
+              printk("\nSpecified channel not supported\n");\r
+              }//else if(data[1]==1)\r
+           }//elseif(data[1]==0)\r
+        }//if(data[3]==1);\r
+     else\r
+        {\r
+        printk("\nSpecified functionality does not exist\n");\r
+        return -EINVAL;\r
+        }//if else data[3]==1)\r
+     }//if else data[3]==0) \r
+  return insn->n;\r
+}\r
+\r
+/*\r
++----------------------------------------------------------------------------+\r
+| Function   Name   : int i_APCI2016_BitsDigitalOutput                       |\r
+|                        (comedi_device *dev,comedi_subdevice *s,               |\r
+|                      comedi_insn *insn,lsampl_t *data)                     |\r
++----------------------------------------------------------------------------+\r
+| Task              : Read  value  of the selected channel or port           |\r
++----------------------------------------------------------------------------+\r
+| Input Parameters  : comedi_device *dev      : Driver handle                |\r
+|                     UINT ui_NoOfChannels    : No Of Channels To read       |\r
+|                     UINT *data              : Data Pointer to read status  |\r
++----------------------------------------------------------------------------+\r
+| Output Parameters :  --                                                                                                       |\r
++----------------------------------------------------------------------------+\r
+| Return Value      : TRUE  : No error occur                                 |\r
+|                          : FALSE : Error occur. Return the error          |\r
+|                                                                               |\r
++----------------------------------------------------------------------------+\r
+*/\r
+int i_APCI2016_BitsDigitalOutput(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data) \r
+{\r
+   UINT ui_Temp;\r
+   UINT ui_NoOfChannel;\r
+   ui_NoOfChannel=CR_CHAN(insn->chanspec);\r
+   if  ((ui_NoOfChannel<0) || (ui_NoOfChannel>15)) \r
+      {   \r
+      comedi_error(dev,"Invalid Channel Numbers !!!, Channel Numbers must be between 0 and 15\n");  \r
+      return -EINVAL;\r
+      } // if  ((ui_NoOfChannel<0) || (ui_NoOfChannel>15))\r
+   if  ((data[0]!=0) && (data[0]!=1)) \r
+      {   \r
+      comedi_error(dev,"Invalid Data[0] value !!!, Data[0] should be 0 or 1\n");  \r
+      return -EINVAL;\r
+      }  // if  ((data[0]!=0) && (data[0]!=1))\r
+   ui_Temp=data[0];\r
+   *data=inw(devpriv->iobase+APCI2016_DIGITAL_OP_RW);\r
+   if  (ui_Temp==0)\r
+      {\r
+       *data=(*data >> ui_NoOfChannel)&0x1;\r
+      } // if  (ui_Temp==0)\r
+   else\r
+      {\r
+      if  (ui_Temp==1)\r
+         {\r
+         switch (ui_NoOfChannel)\r
+          {\r
+           case 2: *data=(*data >>(2*data[1]))&3; \r
+                  break;\r
+       \r
+           case 4: *data=(*data >>(4*data[1]))&15; \r
+                  break;\r
+\r
+           case 8: *data=(*data >>(8*data[1]))&255;  \r
+                   break;\r
\r
+          case 15: break;\r
+\r
+          default:\r
+                 comedi_error(dev," chan spec wrong");\r
+                 return -EINVAL;   // "sorry channel spec wrong "  \r
+          }//switch(ui_NoOfChannel)    \r
+       } // if  (ui_Temp==1)\r
+    else\r
+       {\r
+       printk("\nSpecified channel not supported \n");\r
+       } // else if  (ui_Temp==1)\r
+    } // if  (ui_Temp==0)\r
+    return insn->n;\r
+}\r
+\r
 \r
-/*
-+----------------------------------------------------------------------------+
-| Function   Name   : int i_APCI2016_BitsDigitalOutput                       |
-|                        (comedi_device *dev,comedi_subdevice *s,               |
-|                      comedi_insn *insn,lsampl_t *data)                     |
-+----------------------------------------------------------------------------+
-| Task              : Read  value  of the selected channel or port           |
-+----------------------------------------------------------------------------+
-| Input Parameters  : comedi_device *dev      : Driver handle                |
-|                     UINT ui_NoOfChannels    : No Of Channels To read       |
-|                     UINT *data              : Data Pointer to read status  |
-+----------------------------------------------------------------------------+
-| Output Parameters :  --                                                                                                       |
-+----------------------------------------------------------------------------+
-| Return Value      : TRUE  : No error occur                                 |
-|                          : FALSE : Error occur. Return the error          |
-|                                                                               |
-+----------------------------------------------------------------------------+
-*/
-int i_APCI2016_BitsDigitalOutput(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data) 
-{
-   UINT ui_Temp;
-   UINT ui_NoOfChannel;
-   ui_NoOfChannel=CR_CHAN(insn->chanspec);
-   if  ((ui_NoOfChannel<0) || (ui_NoOfChannel>15)) 
-      {   
-      comedi_error(dev,"Invalid Channel Numbers !!!, Channel Numbers must be between 0 and 15\n");  
-      return -EINVAL;
-      } // if  ((ui_NoOfChannel<0) || (ui_NoOfChannel>15))
-   if  ((data[0]!=0) && (data[0]!=1)) 
-      {   
-      comedi_error(dev,"Invalid Data[0] value !!!, Data[0] should be 0 or 1\n");  
-      return -EINVAL;
-      }  // if  ((data[0]!=0) && (data[0]!=1))
-   ui_Temp=data[0];
-   *data=inw(devpriv->iobase+APCI2016_DIGITAL_OP_RW);
-   if  (ui_Temp==0)
-      {
-       *data=(*data >> ui_NoOfChannel)&0x1;
-      } // if  (ui_Temp==0)
-   else
-      {
-      if  (ui_Temp==1)
-         {
-         switch (ui_NoOfChannel)
-          {
-           case 2: *data=(*data >>(2*data[1]))&3; 
-                  break;
-       
-           case 4: *data=(*data >>(4*data[1]))&15; 
-                  break;
-
-           case 8: *data=(*data >>(8*data[1]))&255;  
-                   break;
-          case 15: break;
-
-          default:
-                 comedi_error(dev," chan spec wrong");
-                 return -EINVAL;   // "sorry channel spec wrong "  
-          }//switch(ui_NoOfChannel)    
-       } // if  (ui_Temp==1)
-    else
-       {
-       printk("\nSpecified channel not supported \n");
-       } // else if  (ui_Temp==1)
-    } // if  (ui_Temp==0)
-    return insn->n;
-}
-
-
 /*\r
 +----------------------------------------------------------------------------+\r
 | Function   Name   : int i_APCI2016_ConfigWatchdog                          |\r
-|                        (comedi_device *dev,comedi_subdevice *s,               |
-|                      comedi_insn *insn,lsampl_t *data)                     |
+|                        (comedi_device *dev,comedi_subdevice *s,               |\r
+|                      comedi_insn *insn,lsampl_t *data)                     |\r
 +----------------------------------------------------------------------------+\r
 | Task              : Configures The Watchdog                                |\r
 +----------------------------------------------------------------------------+\r
-| Input Parameters  :   comedi_device *dev      : Driver handle              |
-|                     comedi_subdevice *s,   :pointer to subdevice structure |
-|                     comedi_insn *insn      :pointer to insn structure      |
-|                     lsampl_t *data          : Data Pointer to read status  |    
+| Input Parameters  :   comedi_device *dev      : Driver handle              |\r
+|                     comedi_subdevice *s,   :pointer to subdevice structure |\r
+|                     comedi_insn *insn      :pointer to insn structure      |\r
+|                     lsampl_t *data          : Data Pointer to read status  |    \r
 +----------------------------------------------------------------------------+\r
 | Output Parameters :  --                                                                                                       |\r
 +----------------------------------------------------------------------------+\r
@@ -295,37 +319,37 @@ int i_APCI2016_BitsDigitalOutput(comedi_device *dev,comedi_subdevice *s,comedi_i
 +----------------------------------------------------------------------------+\r
 */\r
 int i_APCI2016_ConfigWatchdog(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data) \r
-{ 
-  
-   if  (data[0]==0)
-      {
-      //Disable the watchdog
-      outw(0x0,devpriv->i_IobaseAddon+ APCI2016_WATCHDOG_ENABLEDISABLE);
-      //Loading the Reload value
-      outw(data[1],devpriv->i_IobaseAddon+APCI2016_WATCHDOG_RELOAD_VALUE);
-      data[1]=data[1]>>16;
-      outw(data[1],devpriv->i_IobaseAddon+APCI2016_WATCHDOG_RELOAD_VALUE+2);
-      }
-   else
-      {
-      printk("\nThe input parameters are wrong\n");
-      }
-   return insn->n;
-}
-
-
+{ \r
+  \r
+   if  (data[0]==0)\r
+      {\r
+      //Disable the watchdog\r
+      outw(0x0,devpriv->i_IobaseAddon+ APCI2016_WATCHDOG_ENABLEDISABLE);\r
+      //Loading the Reload value\r
+      outw(data[1],devpriv->i_IobaseAddon+APCI2016_WATCHDOG_RELOAD_VALUE);\r
+      data[1]=data[1]>>16;\r
+      outw(data[1],devpriv->i_IobaseAddon+APCI2016_WATCHDOG_RELOAD_VALUE+2);\r
+      }\r
+   else\r
+      {\r
+      printk("\nThe input parameters are wrong\n");\r
+      }\r
+   return insn->n;\r
+}\r
+\r
+\r
 /*\r
 +----------------------------------------------------------------------------+\r
 | Function   Name   : int i_APCI2016_StartStopWriteWatchdog                  |\r
-|                        (comedi_device *dev,comedi_subdevice *s,               |
-|                      comedi_insn *insn,lsampl_t *data)                     |
+|                        (comedi_device *dev,comedi_subdevice *s,               |\r
+|                      comedi_insn *insn,lsampl_t *data)                     |\r
 +----------------------------------------------------------------------------+\r
 | Task              : Start / Stop The Watchdog                              |\r
 +----------------------------------------------------------------------------+\r
-| Input Parameters  : comedi_device *dev      : Driver handle                |
-|                     comedi_subdevice *s,   :pointer to subdevice structure |
-|                     comedi_insn *insn      :pointer to insn structure      |
-|                     lsampl_t *data          : Data Pointer to read status  |
+| Input Parameters  : comedi_device *dev      : Driver handle                |\r
+|                     comedi_subdevice *s,   :pointer to subdevice structure |\r
+|                     comedi_insn *insn      :pointer to insn structure      |\r
+|                     lsampl_t *data          : Data Pointer to read status  |\r
 +----------------------------------------------------------------------------+\r
 | Output Parameters :  --                                                                                                       |\r
 +----------------------------------------------------------------------------+\r
@@ -335,38 +359,39 @@ int i_APCI2016_ConfigWatchdog(comedi_device *dev,comedi_subdevice *s,comedi_insn
 +----------------------------------------------------------------------------+\r
 */\r
 int i_APCI2016_StartStopWriteWatchdog(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data)\r
-{
-
-   switch(data[0])
-      {
-       case 0://stop the watchdog
-                outw(0x0,devpriv->i_IobaseAddon+ APCI2016_WATCHDOG_ENABLEDISABLE);//disable the watchdog 
-                break;
-       case 1://start the watchdog
-               outw(0x0001,devpriv->i_IobaseAddon+ APCI2016_WATCHDOG_ENABLEDISABLE);
-               break;
-       case 2://Software trigger  
-              outw(0x0201,devpriv->i_IobaseAddon+ APCI2016_WATCHDOG_ENABLEDISABLE);
-              break;
-       default:printk("\nSpecified functionality does not exist\n");
-              return -EINVAL;
-       }// switch(data[0])  
-
-  return insn->n;
-}
-\r 
+{\r
+\r
+   switch(data[0])\r
+      {\r
+       case 0://stop the watchdog\r
+                outw(0x0,devpriv->i_IobaseAddon+ APCI2016_WATCHDOG_ENABLEDISABLE);//disable the watchdog \r
+                break;\r
+       case 1://start the watchdog\r
+               outw(0x0001,devpriv->i_IobaseAddon+ APCI2016_WATCHDOG_ENABLEDISABLE);\r
+               break;\r
+       case 2://Software trigger  \r
+              outw(0x0201,devpriv->i_IobaseAddon+ APCI2016_WATCHDOG_ENABLEDISABLE);\r
+              break;\r
+       default:printk("\nSpecified functionality does not exist\n");\r
+              return -EINVAL;\r
+       }// switch(data[0])  \r
+\r
+  return insn->n;\r
+}\r
+\r
\r
 /*\r
 +----------------------------------------------------------------------------+\r
 | Function   Name   : int i_APCI2016_ReadWatchdog                            |\r
-|                        (comedi_device *dev,comedi_subdevice *s,               |
-|                      comedi_insn *insn,lsampl_t *data)                     |
+|                        (comedi_device *dev,comedi_subdevice *s,               |\r
+|                      comedi_insn *insn,lsampl_t *data)                     |\r
 +----------------------------------------------------------------------------+\r
 | Task              : Read The Watchdog                                      |\r
 +----------------------------------------------------------------------------+\r
-| Input Parameters  : comedi_device *dev      : Driver handle                |
-|                     comedi_subdevice *s,   :pointer to subdevice structure | 
-|                     comedi_insn *insn      :pointer to insn structure      |
-|                     lsampl_t *data          : Data Pointer to read status  |
+| Input Parameters  : comedi_device *dev      : Driver handle                |\r
+|                     comedi_subdevice *s,   :pointer to subdevice structure | \r
+|                     comedi_insn *insn      :pointer to insn structure      |\r
+|                     lsampl_t *data          : Data Pointer to read status  |\r
 +----------------------------------------------------------------------------+\r
 | Output Parameters :  --                                                                                                       |\r
 +----------------------------------------------------------------------------+\r
@@ -374,34 +399,35 @@ int i_APCI2016_StartStopWriteWatchdog(comedi_device *dev,comedi_subdevice *s,com
 |                          : FALSE : Error occur. Return the error          |\r
 |                                                                               |\r
 +----------------------------------------------------------------------------+\r
-*/\r\r
-int i_APCI2016_ReadWatchdog(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data)
-{  
-   udelay(5);   
-   data[0]= inw(devpriv->i_IobaseAddon+APCI2016_WATCHDOG_STATUS)&0x1; 
-   return insn->n;
-}
-
-/*
-+----------------------------------------------------------------------------+
-| Function   Name   : int i_APCI2016_Reset(comedi_device *dev)               |                                                       |
-+----------------------------------------------------------------------------+
-| Task              :resets all the registers                                |
-+----------------------------------------------------------------------------+
-| Input Parameters  : comedi_device *dev
-+----------------------------------------------------------------------------+
-| Output Parameters :  --                                                                                                       |
-+----------------------------------------------------------------------------+
-| Return Value      :                                                        |
-|                                                                               |
-+----------------------------------------------------------------------------+
-*/
-         
-INT i_APCI2016_Reset(comedi_device *dev) 
-{
-  outw(0x0,devpriv->iobase+APCI2016_DIGITAL_OP);   // Resets the digital output channels
-  outw(0x0,devpriv->i_IobaseAddon+ APCI2016_WATCHDOG_ENABLEDISABLE);
-  outw(0x0,devpriv->i_IobaseAddon+APCI2016_WATCHDOG_RELOAD_VALUE);
-  outw(0x0,devpriv->i_IobaseAddon+APCI2016_WATCHDOG_RELOAD_VALUE+2);
-  return 0;
-}        
\ No newline at end of file
+*/\r
+\r
+int i_APCI2016_ReadWatchdog(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data)\r
+{  \r
+   udelay(5);   \r
+   data[0]= inw(devpriv->i_IobaseAddon+APCI2016_WATCHDOG_STATUS)&0x1; \r
+   return insn->n;\r
+}\r
+\r
+/*\r
++----------------------------------------------------------------------------+\r
+| Function   Name   : int i_APCI2016_Reset(comedi_device *dev)               |                                                       |\r
++----------------------------------------------------------------------------+\r
+| Task              :resets all the registers                                |\r
++----------------------------------------------------------------------------+\r
+| Input Parameters  : comedi_device *dev\r
++----------------------------------------------------------------------------+\r
+| Output Parameters :  --                                                                                                       |\r
++----------------------------------------------------------------------------+\r
+| Return Value      :                                                        |\r
+|                                                                               |\r
++----------------------------------------------------------------------------+\r
+*/\r
+         \r
+INT i_APCI2016_Reset(comedi_device *dev) \r
+{\r
+  outw(0x0,devpriv->iobase+APCI2016_DIGITAL_OP);   // Resets the digital output channels\r
+  outw(0x0,devpriv->i_IobaseAddon+ APCI2016_WATCHDOG_ENABLEDISABLE);\r
+  outw(0x0,devpriv->i_IobaseAddon+APCI2016_WATCHDOG_RELOAD_VALUE);\r
+  outw(0x0,devpriv->i_IobaseAddon+APCI2016_WATCHDOG_RELOAD_VALUE+2);\r
+  return 0;\r
+}\r
index 2d1c8f2fffe72a70099c7db2d62f7b55905949f8..3659aa033b3b8954264264e7987d5cdc856d7893 100644 (file)
@@ -1,8 +1,31 @@
+/**\r
+@verbatim\r
+\r
+Copyright (C) 2004,2005  ADDI-DATA GmbH for the source code of this module. \r
+        \r
+        ADDI-DATA GmbH \r
+        Dieselstrasse 3 \r
+        D-77833 Ottersweier \r
+        Tel: +19(0)7223/9493-0 \r
+        Fax: +49(0)7223/9493-92 \r
+        http://www.addi-data-com \r
+        info@addi-data.com \r
+\r
+This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.\r
+\r
+This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.\r
+\r
+You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+\r
+You shoud also find the complete GPL in the COPYING file accompanying this source code.\r
+\r
+@endverbatim\r
+*/\r
 /*********      Definitions for APCI-2016 card  *****/\r
 \r
-#define APCI2016_BOARD_VENDOR_ID 0x15B8
-#define APCI2016_ADDRESS_RANGE   8
-
+#define APCI2016_BOARD_VENDOR_ID 0x15B8\r
+#define APCI2016_ADDRESS_RANGE   8\r
+\r
 \r
 //DIGITAL INPUT-OUTPUT DEFINE   \r
 \r
 #define APCI2016_WATCHDOG_RELOAD_VALUE             4\r
 #define APCI2016_WATCHDOG_STATUS                   16\r
 \r
-
+\r
 // Hardware Layer  functions for Apci2016\r
 \r
 //DO\r
 int i_APCI2016_ConfigDigitalOutput(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data) ;\r
 \r
-int i_APCI2016_WriteDigitalOutput(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data);  
-
+int i_APCI2016_WriteDigitalOutput(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data);  \r
+\r
 int i_APCI2016_BitsDigitalOutput(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data);\r
 \r
 \r
 // TIMER  \r
 // timer value is passed as u seconds\r
 \r
-
+\r
 int i_APCI2016_ConfigWatchdog(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data) ;\r
 \r
 int i_APCI2016_StartStopWriteWatchdog(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data);\r
 \r
-int i_APCI2016_ReadWatchdog(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data);
-
-
-// Interrupt functions.....
-
-// VOID v_APCI2016_Interrupt(int irq, void *d, struct pt_regs *regs) ;
-
- //VOID v_APCI2016_Interrupt(int irq, void *d, struct pt_regs *regs);
-// RESET
-INT i_APCI2016_Reset(comedi_device *dev);
+int i_APCI2016_ReadWatchdog(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data);\r
+\r
+\r
+// Interrupt functions.....\r
+\r
+// VOID v_APCI2016_Interrupt(int irq, void *d, struct pt_regs *regs) ;\r
+\r
+ //VOID v_APCI2016_Interrupt(int irq, void *d, struct pt_regs *regs);\r
+// RESET\r
+INT i_APCI2016_Reset(comedi_device *dev);\r
index a22a1d7a650f9e7f3c4b7365b0c367b2a766019c..1b1535ab6eeec948cb0fe6d4cd2a28f560ef5f3e 100644 (file)
@@ -1,14 +1,38 @@
+/**
+@verbatim
+
+Copyright (C) 2004,2005  ADDI-DATA GmbH for the source code of this module. 
+        
+        ADDI-DATA GmbH 
+        Dieselstrasse 3 
+        D-77833 Ottersweier 
+        Tel: +19(0)7223/9493-0 
+        Fax: +49(0)7223/9493-92 
+        http://www.addi-data-com 
+        info@addi-data.com 
+
+This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+You shoud also find the complete GPL in the COPYING file accompanying this source code.
+
+@endverbatim
+*/
 /*
+    
   +-----------------------------------------------------------------------+
   | (C) ADDI-DATA GmbH          Dieselstraße 3       D-77833 Ottersweier  |
   +-----------------------------------------------------------------------+
   | Tel : +49 (0) 7223/9493-0     | email    : info@addi-data.com         |
   | Fax : +49 (0) 7223/9493-92    | Internet : http://www.addi-data.com   |
   +-------------------------------+---------------------------------------+
-  | Project     : 13Card Linux Driver | Compiler   : GCC                  |
-  | Module name : hwdrv_apci2032.c|     Version    : 2.96                 |
+  | Project     : APCI-2032       | Compiler   : GCC                      |
+  | Module name : hwdrv_apci2032.c| Version    : 2.96                     |
   +-------------------------------+---------------------------------------+
-  | Author : Shitalkumar S Chavan |     Date       : 31.10.2001           |
+  | Project manager: Eric Stolz   | Date       :  02/12/2002              |
   +-------------------------------+---------------------------------------+
   | Description :   Hardware Layer Acces For APCI-2032                    |
   +-----------------------------------------------------------------------+
index 0e642866843e01145e068cf53661f7de6c0a0e8d..839c84cbf7bd32173a988a64d0cb0bea06899629 100644 (file)
@@ -1,9 +1,32 @@
+/**\r
+@verbatim\r
+\r
+Copyright (C) 2004,2005  ADDI-DATA GmbH for the source code of this module. \r
+        \r
+        ADDI-DATA GmbH \r
+        Dieselstrasse 3 \r
+        D-77833 Ottersweier \r
+        Tel: +19(0)7223/9493-0 \r
+        Fax: +49(0)7223/9493-92 \r
+        http://www.addi-data-com \r
+        info@addi-data.com \r
+\r
+This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.\r
+\r
+This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.\r
+\r
+You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+\r
+You shoud also find the complete GPL in the COPYING file accompanying this source code.\r
+\r
+@endverbatim\r
+*/\r
 /*********      Definitions for APCI-2032 card  *****/\r
-
-// Card Specific information
-#define APCI2032_BOARD_VENDOR_ID                 0x15B8
-#define APCI2032_ADDRESS_RANGE                   63
-
+\r
+// Card Specific information\r
+#define APCI2032_BOARD_VENDOR_ID                 0x15B8\r
+#define APCI2032_ADDRESS_RANGE                   63\r
+\r
 \r
 //DIGITAL INPUT-OUTPUT DEFINE   \r
 \r
@@ -11,7 +34,7 @@
 #define APCI2032_DIGITAL_OP_RW                         0 \r
 #define APCI2032_DIGITAL_OP_INTERRUPT           4\r
 #define APCI2032_DIGITAL_OP_IRQ                 12\r
-
+\r
 //Digital Output Interrupt Status\r
 #define APCI2032_DIGITAL_OP_INTERRUPT_STATUS    8\r
 \r
 // TIMER COUNTER WATCHDOG DEFINES  \r
 \r
 #define ADDIDATA_WATCHDOG                          2\r
-#define APCI2032_DIGITAL_OP_WATCHDOG               16
+#define APCI2032_DIGITAL_OP_WATCHDOG               16\r
 #define APCI2032_TCW_RELOAD_VALUE                  4\r
 #define APCI2032_TCW_TIMEBASE                      8\r
 #define APCI2032_TCW_PROG                          12\r
 #define APCI2032_TCW_TRIG_STATUS                   16\r
 #define APCI2032_TCW_IRQ                           20\r
-
+\r
 \r
 \r
 \r
 \r
 //DO\r
 int i_APCI2032_ConfigDigitalOutput(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data);\r
-INT i_APCI2032_WriteDigitalOutput(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data);
-INT i_APCI2032_ReadDigitalOutput(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data);
-int i_APCI2032_ReadInterruptStatus(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data);
+INT i_APCI2032_WriteDigitalOutput(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data);\r
+INT i_APCI2032_ReadDigitalOutput(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data);\r
+int i_APCI2032_ReadInterruptStatus(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data);\r
 \r
 // TIMER  \r
 // timer value is passed as u seconds\r
 INT i_APCI2032_ConfigWatchdog(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data);\r
-int i_APCI2032_StartStopWriteWatchdog(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data); 
-int i_APCI2032_ReadWatchdog(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data);
+int i_APCI2032_StartStopWriteWatchdog(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data); \r
+int i_APCI2032_ReadWatchdog(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data);\r
\r
 // Interrupt functions.....\r
 \r
 void v_APCI2032_Interrupt(int irq, void *d, struct pt_regs *regs) ;\r
-
-//Reset functions
- int i_APCI2032_Reset(comedi_device *dev);     
+\r
+//Reset functions\r
+ int i_APCI2032_Reset(comedi_device *dev);     \r
index d530b0bbd13ad57b86b71829c832097f8e260aeb..46024efbf24ad8cc5cb98dbc579a70cc3d472028 100644 (file)
@@ -1,14 +1,38 @@
+/**
+@verbatim
+
+Copyright (C) 2004,2005  ADDI-DATA GmbH for the source code of this module. 
+        
+        ADDI-DATA GmbH 
+        Dieselstrasse 3 
+        D-77833 Ottersweier 
+        Tel: +19(0)7223/9493-0 
+        Fax: +49(0)7223/9493-92 
+        http://www.addi-data-com 
+        info@addi-data.com 
+
+This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+You shoud also find the complete GPL in the COPYING file accompanying this source code.
+
+@endverbatim
+*/
 /*
+    
   +-----------------------------------------------------------------------+
   | (C) ADDI-DATA GmbH          Dieselstraße 3       D-77833 Ottersweier  |
   +-----------------------------------------------------------------------+
   | Tel : +49 (0) 7223/9493-0     | email    : info@addi-data.com         |
   | Fax : +49 (0) 7223/9493-92    | Internet : http://www.addi-data.com   |
   +-------------------------------+---------------------------------------+
-  | Project     : 13Card Linux Driver | Compiler   : GCC                  |
-  | Module name : hwdrv_apci2200.c|     Version    : 2.96                 |
+  | Project     : APCI-2200       | Compiler   : GCC                      |
+  | Module name : hwdrv_apci2200.c| Version    : 2.96                     |
   +-------------------------------+---------------------------------------+
-  | Author : Karl Andrade         |     Date       : 18.12.2001           |
+  | Project manager: Eric Stolz   | Date       :  02/12/2002              |
   +-------------------------------+---------------------------------------+
   | Description :   Hardware Layer Acces For APCI-2200                    |
   +-----------------------------------------------------------------------+
index a71d16682787d889b7b502bbd169081c17d4f855..574bacc23305165e2ec5c33341f9c37bcd68a880 100644 (file)
@@ -1,3 +1,26 @@
+/**
+@verbatim
+
+Copyright (C) 2004,2005  ADDI-DATA GmbH for the source code of this module. 
+        
+        ADDI-DATA GmbH 
+        Dieselstrasse 3 
+        D-77833 Ottersweier 
+        Tel: +19(0)7223/9493-0 
+        Fax: +49(0)7223/9493-92 
+        http://www.addi-data-com 
+        info@addi-data.com 
+
+This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+You shoud also find the complete GPL in the COPYING file accompanying this source code.
+
+@endverbatim
+*/
 /*********      Definitions for APCI-2200 card  *****/
 
 // Card Specific information
index effd7b64aebe515cea471fe39e2451c20bc12185..f6929a73d614210f3c2d1c30607a6478c6e0585b 100644 (file)
@@ -1,6 +1,26 @@
+/**
+@verbatim
 
+Copyright (C) 2004,2005  ADDI-DATA GmbH for the source code of this module. 
+        
+        ADDI-DATA GmbH 
+        Dieselstrasse 3 
+        D-77833 Ottersweier 
+        Tel: +19(0)7223/9493-0 
+        Fax: +49(0)7223/9493-92 
+        http://www.addi-data-com 
+        info@addi-data.com 
+
+This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
 
+You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 
+You shoud also find the complete GPL in the COPYING file accompanying this source code.
+
+@endverbatim
+*/
 /*
   +-----------------------------------------------------------------------+
   | (C) ADDI-DATA GmbH          Dieselstrasse 3      D-77833 Ottersweier  |
   | Tel : +49 (0) 7223/9493-0     | email    : info@addi-data.com         |
   | Fax : +49 (0) 7223/9493-92    | Internet : http://www.addi-data.com   |
   +-----------------------------------------------------------------------+
-  | Project   : ADDI DATA         | Compiler : GCC                                   |
-  | Modulname : hwdrv_apci3120.c  | Version  : 2.96  Redhat Linux         |
-  |                               |                    kernel-2.4.2       |
+  | Project     : APCI-3120       | Compiler   : GCC                      |
+  | Module name : hwdrv_apci3120.c| Version    : 2.96                     |
   +-------------------------------+---------------------------------------+
-  | Author    :                          | Date     :                                    |
+  | Project manager: Eric Stolz   | Date       :  02/12/2002              |
   +-----------------------------------------------------------------------+
-  | Description :APCI3120 Module  . Hardware abstraction Layer for APCI3120|
+  | Description :APCI3120 Module Hardware abstraction Layer for APCI3120|
   +-----------------------------------------------------------------------+
   |                             UPDATE'S                                  |
   +-----------------------------------------------------------------------+
   |   Date   |   Author  |          Description of updates                |
   +----------+-----------+------------------------------------------------+
-  |          |                          |                                                                                                |
-  |          |           |                                                                                               |
-  |          |           |                                                           |
-  |          |           |                                                                                               |
-  |          |           |                                                                   |
-  +----------+-----------+------------------------------------------------+
-  |         |                   |                                                                        |
-  |          |           |                                                                                               |
-  |          |           |                                                                               |
+  |          |                  |                                                |
+  |          |           |                                               |
   +----------+-----------+------------------------------------------------+
 */
 
@@ -74,7 +86,7 @@ int i_APCI3120_InsnConfigAnalogInput(comedi_device *dev,comedi_subdevice *s,come
                                                                                                                                                        lsampl_t *data)
 {
         UINT i;
-               
+
        if((data[0] != APCI3120_EOC_MODE) && (data[0] != APCI3120_EOS_MODE))
         return -1 ;
                  
@@ -160,6 +172,7 @@ int i_APCI3120_InsnReadAnalogInput(comedi_device *dev, comedi_subdevice *s,
        USHORT us_ConvertTiming,us_TmpValue,i;
        BYTE b_Tmp;
 
+
        // fix convertion time to 10 us 
        if(!devpriv->ui_EocEosConversionTime) 
         {
@@ -174,7 +187,7 @@ int i_APCI3120_InsnReadAnalogInput(comedi_device *dev, comedi_subdevice *s,
         devpriv->b_TimerSelectMode=0;
         devpriv->b_ModeSelectRegister=0;
         devpriv->us_OutputRegister=0;
-        devpriv->b_DigitalOutputRegister=0;
+//        devpriv->b_DigitalOutputRegister=0;
 
         if(insn->unused[0]==222)// second insn read
         {
@@ -190,16 +203,17 @@ int i_APCI3120_InsnReadAnalogInput(comedi_device *dev, comedi_subdevice *s,
            devpriv->tsk_Current=current; // Save the current process task structure
            //Testing if board have the new Quartz and calculate the time value 
            //to set in the timer
+                       
+           us_TmpValue=(USHORT) inw(devpriv->iobase+APCI3120_RD_STATUS);
            
-            us_TmpValue=(USHORT) inw(devpriv->iobase+APCI3120_RD_STATUS);
-           if((us_TmpValue & 0x00B0)==0x00B0)
+           //EL250804: Testing if board APCI3120 have the new Quartz or if it is an APCI3001
+           if((us_TmpValue & 0x00B0)==0x00B0 || !strcmp(this_board->pc_DriverName,"apci3001") )
               {
-                   us_ConvertTiming=(us_ConvertTiming * 2) -2;
+                   us_ConvertTiming=(us_ConvertTiming * 2) -2;             
               }
            else
               {
-                       us_ConvertTiming=((us_ConvertTiming * 12926)/10000) -1;
-        
+                       us_ConvertTiming=((us_ConvertTiming * 12926)/10000) -1;                 
                }
 
            us_TmpValue=(USHORT)devpriv->b_InterruptMode;
@@ -249,7 +263,7 @@ int i_APCI3120_InsnReadAnalogInput(comedi_device *dev, comedi_subdevice *s,
                        outw(devpriv->us_OutputRegister,devpriv->iobase+APCI3120_WR_ADDRESS);
 
                        // Select Timer 0
-                       b_Tmp=((devpriv->b_DigitalOutputRegister<<4) & 0xF0) | APCI3120_SELECT_TIMER_0_WORD;
+                       b_Tmp=((devpriv->b_DigitalOutputRegister) & 0xF0) | APCI3120_SELECT_TIMER_0_WORD;
                        outb(b_Tmp,devpriv->iobase+APCI3120_TIMER_CRT0);
 
 
@@ -286,19 +300,17 @@ int i_APCI3120_InsnReadAnalogInput(comedi_device *dev, comedi_subdevice *s,
                     // clear PA PR  and disable timer 0
 
                     devpriv->us_OutputRegister=(devpriv->us_OutputRegister & APCI3120_CLEAR_PA_PR) | APCI3120_DISABLE_TIMER0;
-                    
+                                       
                        outw(devpriv->us_OutputRegister,devpriv->iobase+APCI3120_WR_ADDRESS);
-         
-
+                       
                        if (!i_APCI3120_SetupChannelList(dev,s,devpriv->ui_AiNbrofChannels,devpriv->ui_AiChannelList,0))                return -EINVAL;
 
                        //Initialize Timer 0 mode 2
                        devpriv->b_TimerSelectMode = (devpriv->b_TimerSelectMode & 0xFC) | APCI3120_TIMER_0_MODE_2;
                        outb(devpriv->b_TimerSelectMode,devpriv->iobase+APCI3120_TIMER_CRT1);
-               
-       
+                       
                        //Select Timer 0
-                       b_Tmp=((devpriv->b_DigitalOutputRegister<<4) & 0xF0) | APCI3120_SELECT_TIMER_0_WORD;
+                       b_Tmp=((devpriv->b_DigitalOutputRegister) & 0xF0) | APCI3120_SELECT_TIMER_0_WORD;
                        outb(b_Tmp,devpriv->iobase+APCI3120_TIMER_CRT0);
                
                        //Set the convertion time
@@ -307,7 +319,7 @@ int i_APCI3120_InsnReadAnalogInput(comedi_device *dev, comedi_subdevice *s,
                        //Set the scan bit
                        devpriv->b_ModeSelectRegister=devpriv->b_ModeSelectRegister | APCI3120_ENABLE_SCAN;
                        outb(devpriv->b_ModeSelectRegister,devpriv->iobase+APCI3120_WRITE_MODE_SELECT);
-                 
+                       
                        //If Interrupt function is loaded 
                        if(devpriv->b_EocEosInterrupt==APCI3120_ENABLE)
                        {
@@ -326,7 +338,7 @@ int i_APCI3120_InsnReadAnalogInput(comedi_device *dev, comedi_subdevice *s,
                 
                        //Sets gate 0
                        
-                    devpriv->us_OutputRegister=devpriv->us_OutputRegister  | APCI3120_ENABLE_TIMER0;
+                       devpriv->us_OutputRegister=devpriv->us_OutputRegister  | APCI3120_ENABLE_TIMER0;
                        outw(devpriv->us_OutputRegister,devpriv->iobase+APCI3120_WR_ADDRESS);
 
                        //Start conversion
@@ -344,10 +356,9 @@ int i_APCI3120_InsnReadAnalogInput(comedi_device *dev, comedi_subdevice *s,
 
                                for(i=0;i< devpriv->ui_AiNbrofChannels;i++)
                                {
-                               //Read the result in FIFO and write them in shared memory
-                               us_TmpValue=inw(devpriv->iobase);
-                            data[i]=(UINT) us_TmpValue;
-                               
+                                       //Read the result in FIFO and write them in shared memory
+                                       us_TmpValue=inw(devpriv->iobase);
+                                       data[i]=(UINT) us_TmpValue;                             
                                }
 
                                devpriv->b_InterruptMode = APCI3120_EOC_MODE; // Restore defaults.
@@ -428,8 +439,7 @@ int i_APCI3120_StopCyclicAcquisition(comedi_device *dev,comedi_subdevice *s)
        devpriv->b_AiCyclicAcquisition=APCI3120_DISABLE;
         devpriv->b_InterruptMode=APCI3120_EOC_MODE;
        devpriv->b_EocEosInterrupt=APCI3120_DISABLE;       
-        i_APCI3120_Reset(dev); 
-        //printk("Stopped cyclic acquisition\n");  
+        i_APCI3120_Reset(dev);         
        return 0;    
 }
 
@@ -459,6 +469,7 @@ int i_APCI3120_CommandTestAnalogInput(comedi_device *dev,comedi_subdevice *s,com
         
        // step 1: make sure trigger sources are trivially valid 
 
+
        tmp=cmd->start_src;
        cmd->start_src &= TRIG_NOW|TRIG_EXT;
        if(!cmd->start_src || tmp!=cmd->start_src)err++;
@@ -621,14 +632,17 @@ int i_APCI3120_CommandTestAnalogInput(comedi_device *dev,comedi_subdevice *s,com
  int i_APCI3120_CommandAnalogInput(comedi_device *dev,comedi_subdevice *s)
 {          
        comedi_cmd *cmd=&s->async->cmd;
-
+       
        //loading private structure with cmd structure inputs
        devpriv->ui_AiFlags=cmd->flags;
        devpriv->ui_AiNbrofChannels=cmd->chanlist_len;
        devpriv->ui_AiScanLength=cmd->scan_end_arg;
        devpriv->pui_AiChannelList=cmd->chanlist;
-       devpriv->AiData=s->async->data;
-       devpriv->ui_AiDataLength=s->async->data_len;
+       
+       //UPDATE-0.7.57->0.7.68devpriv->AiData=s->async->data;
+       devpriv->AiData=s->async->prealloc_buf;
+       //UPDATE-0.7.57->0.7.68devpriv->ui_AiDataLength=s->async->data_len;
+       devpriv->ui_AiDataLength=s->async->prealloc_bufsz;
        
        if (cmd->stop_src==TRIG_COUNT) 
        { 
@@ -695,67 +709,93 @@ int i_APCI3120_CommandTestAnalogInput(comedi_device *dev,comedi_subdevice *s,com
 */
 
 int i_APCI3120_CyclicAnalogInput(int mode, comedi_device * dev,comedi_subdevice * s)
-{
-        float f_DelayValue,f_ConvertValue;
+{        
        BYTE b_Tmp;
        UINT ui_Tmp,ui_DelayTiming=0,ui_TimerValue1=0,dmalen0=0,dmalen1=0,ui_TimerValue2=0,ui_TimerValue0,ui_ConvertTiming;
        USHORT us_TmpValue;
-   
-         devpriv->b_AiCyclicAcquisition=APCI3120_ENABLE;
-       //Flush FIFO
-       inb(dev->iobase+APCI3120_RESET_FIFO);  
-       inw(dev->iobase+APCI3120_RD_STATUS);
-
-        
-        // clear software  registers
-
-           devpriv->b_TimerSelectMode=0;
-           devpriv->b_DigitalOutputRegister=0;
-           devpriv->us_OutputRegister=0;
-          devpriv->b_ModeSelectRegister=0;
-
-          /****************************/
-          /* Clear Timer Write TC INT */
-          /****************************/
-
-           outl(APCI3120_CLEAR_WRITE_TC_INT,devpriv->i_IobaseAmcc+ APCI3120_AMCC_OP_REG_INTCSR);
-
-           /************************************/
-          /* Clears the timer status register */
-          /************************************/
-          inw(dev->iobase+APCI3120_TIMER_STATUS_REGISTER);
-
-
-           /**************************/
-          /* Disables All Timer     */
-          /* Sets PR and PA to 0    */
-          /**************************/
-          
-          devpriv->us_OutputRegister = devpriv->us_OutputRegister &APCI3120_DISABLE_TIMER0 & APCI3120_DISABLE_TIMER1 &APCI3120_CLEAR_PA_PR ;
-           outw(devpriv->us_OutputRegister,dev->iobase+APCI3120_WR_ADDRESS);
-
-
-          devpriv->ui_AiActualScan=0;
-          devpriv->ui_AiActualScanPosition=0;
-          s->async->cur_chan=0;
-          devpriv->ui_AiBufferPtr=0;
-          devpriv->ui_DmaActualBuffer=0;
-
-
 
+       //BEGIN JK 07.05.04: Comparison between WIN32 and Linux driver  
+    //devpriv->b_AiCyclicAcquisition=APCI3120_ENABLE;  
+       //END JK 07.05.04: Comparison between WIN32 and Linux driver
+       
+       /*******************/
+       /* Resets the FIFO */
+       /*******************/
+    inb(dev->iobase + APCI3120_RESET_FIFO);  
+    
+       //BEGIN JK 07.05.04: Comparison between WIN32 and Linux driver
+       //inw(dev->iobase+APCI3120_RD_STATUS);
+       //END JK 07.05.04: Comparison between WIN32 and Linux driver
+       
+       /***************************/
+       /* Acquisition initialized */
+       /***************************/   
+       //BEGIN JK 07.05.04: Comparison between WIN32 and Linux driver  
+    devpriv->b_AiCyclicAcquisition = APCI3120_ENABLE;  
+       //END JK 07.05.04: Comparison between WIN32 and Linux driver
 
-         ui_TimerValue2 = devpriv->ui_AiNbrofScans-2; // value for timer2  minus -2 has to be done .....dunno y??   
-         ui_ConvertTiming=devpriv->ui_AiTimer0;
+        
+    // clear software  registers
+    devpriv->b_TimerSelectMode=0;
+    devpriv->us_OutputRegister=0;
+       devpriv->b_ModeSelectRegister=0;
+       //devpriv->b_DigitalOutputRegister=0;
+               
+       //COMMENT JK 07.05.04: Followings calls are in i_APCI3120_StartAnalogInputAcquisition
+       
+   /****************************/
+   /* Clear Timer Write TC INT */
+   /****************************/
+   outl(APCI3120_CLEAR_WRITE_TC_INT,devpriv->i_IobaseAmcc+ APCI3120_AMCC_OP_REG_INTCSR);
+
+   /************************************/
+   /* Clears the timer status register */
+   /************************************/
+   //BEGIN JK 07.05.04: Comparison between WIN32 and Linux driver
+   //inw(dev->iobase+APCI3120_TIMER_STATUS_REGISTER);
+   inb(dev->iobase+APCI3120_TIMER_STATUS_REGISTER);
+   //END JK 07.05.04: Comparison between WIN32 and Linux driver
+
+   /**************************/
+   /* Disables All Timer     */
+   /* Sets PR and PA to 0    */
+   /**************************/           
+   devpriv->us_OutputRegister = devpriv->us_OutputRegister & 
+                                APCI3120_DISABLE_TIMER0 & 
+                                APCI3120_DISABLE_TIMER1 &
+                                APCI3120_CLEAR_PA_PR;
+                                
+   outw(devpriv->us_OutputRegister,dev->iobase + APCI3120_WR_ADDRESS);
+
+   /*******************/
+   /* Resets the FIFO */
+   /*******************/
+   //BEGIN JK 07.05.04: Comparison between WIN32 and Linux driver
+   inb (devpriv->iobase + APCI3120_RESET_FIFO);
+   //END JK 07.05.04: Comparison between WIN32 and Linux driver   
+
+   devpriv->ui_AiActualScan=0;
+   devpriv->ui_AiActualScanPosition=0;
+   s->async->cur_chan=0;
+   devpriv->ui_AiBufferPtr=0;
+   devpriv->ui_DmaActualBuffer=0;
+
+   // value for timer2  minus -2 has to be done .....dunno y??   
+   ui_TimerValue2 = devpriv->ui_AiNbrofScans-2; 
+   ui_ConvertTiming=devpriv->ui_AiTimer0;
   
-         if(mode==2) ui_DelayTiming =  devpriv->ui_AiTimer1; 
+         if (mode==2) 
+            ui_DelayTiming =  devpriv->ui_AiTimer1; 
 
 
-          // initialise sequence ram
-
+   /**********************************/
+   /* Initializes the sequence array */
+   /**********************************/
          if (!i_APCI3120_SetupChannelList(dev, s, devpriv->ui_AiNbrofChannels, devpriv->pui_AiChannelList, 0)) 
-         return -EINVAL;
+            return -EINVAL;
 
         us_TmpValue=(USHORT) inw(dev->iobase+APCI3120_RD_STATUS);  
+/*** EL241003 : add this section in comment because floats must not be used     
         if((us_TmpValue & 0x00B0)==0x00B0)
         {       
            f_ConvertValue=(((float)ui_ConvertTiming * 0.002) - 2);
@@ -776,6 +816,35 @@ int i_APCI3120_CyclicAnalogInput(int mode, comedi_device * dev,comedi_subdevice
                     ui_TimerValue1  =   (UINT) f_DelayValue;
                }
        }
+***********************************************************************************************/
+/*** EL241003 Begin : add this section to replace floats calculation by integer calculations **/
+       //EL250804: Testing if board APCI3120 have the new Quartz or if it is an APCI3001
+       if((us_TmpValue & 0x00B0)==0x00B0 || !strcmp(this_board->pc_DriverName,"apci3001") )
+          {
+            ui_TimerValue0 = ui_ConvertTiming * 2 - 2000;
+           ui_TimerValue0 = ui_TimerValue0 / 1000;
+           
+           if (mode==2)
+              {
+              ui_DelayTiming = ui_DelayTiming / 1000;
+              ui_TimerValue1 = ui_DelayTiming * 2 - 200;
+              ui_TimerValue1 = ui_TimerValue1 / 100;
+              }
+           }
+        else
+           {
+           ui_ConvertTiming = ui_ConvertTiming / 1000;
+           ui_TimerValue0 = ui_ConvertTiming * 12926 - 10000;
+           ui_TimerValue0 = ui_TimerValue0 / 10000;
+           
+           if (mode == 2)
+              {
+              ui_DelayTiming = ui_DelayTiming / 1000;
+              ui_TimerValue1 = ui_DelayTiming * 12926 -1;
+              ui_TimerValue1 = ui_TimerValue1 / 1000000;
+              }
+           }
+/*** EL241003 End ******************************************************************************/       
        
        if(devpriv->b_ExttrigEnable==APCI3120_ENABLE)
        {
@@ -789,9 +858,8 @@ int i_APCI3120_CyclicAnalogInput(int mode, comedi_device * dev,comedi_subdevice
                outb(devpriv->b_TimerSelectMode,dev->iobase+APCI3120_TIMER_CRT1);
 
                //Select Timer 0
-               b_Tmp=((devpriv->b_DigitalOutputRegister<<4) & 0xF0) | APCI3120_SELECT_TIMER_0_WORD;
+               b_Tmp=((devpriv->b_DigitalOutputRegister) & 0xF0) | APCI3120_SELECT_TIMER_0_WORD;
                outb(b_Tmp,dev->iobase+APCI3120_TIMER_CRT0);
-
                //Set the convertion time
                outw(((USHORT)ui_TimerValue0),dev->iobase+APCI3120_TIMER_VALUE);
                break;
@@ -804,7 +872,6 @@ int i_APCI3120_CyclicAnalogInput(int mode, comedi_device * dev,comedi_subdevice
                //Select Timer 1
                b_Tmp=((devpriv->b_DigitalOutputRegister) & 0xF0) | APCI3120_SELECT_TIMER_1_WORD;
                outb(b_Tmp,dev->iobase+APCI3120_TIMER_CRT0);
-       
                //Set the convertion time
                outw(((USHORT)ui_TimerValue1),dev->iobase+APCI3120_TIMER_VALUE);
 
@@ -813,9 +880,10 @@ int i_APCI3120_CyclicAnalogInput(int mode, comedi_device * dev,comedi_subdevice
                outb(devpriv->b_TimerSelectMode,dev->iobase+APCI3120_TIMER_CRT1);
        
                //Select Timer 0
-               b_Tmp=((devpriv->b_DigitalOutputRegister<<4) & 0xF0) | APCI3120_SELECT_TIMER_0_WORD;
+               b_Tmp=((devpriv->b_DigitalOutputRegister) & 0xF0) | APCI3120_SELECT_TIMER_0_WORD;
                outb(b_Tmp,dev->iobase+APCI3120_TIMER_CRT0);
                
+               
                //Set the convertion time
                outw(((USHORT)ui_TimerValue0),dev->iobase+APCI3120_TIMER_VALUE);
                break;
@@ -823,8 +891,14 @@ int i_APCI3120_CyclicAnalogInput(int mode, comedi_device * dev,comedi_subdevice
        }
        //   ##########common for all modes#################
 
-       //disable the scan bit
-       devpriv->b_ModeSelectRegister=devpriv->b_ModeSelectRegister | APCI3120_DISABLE_SCAN;
+       /***********************/
+       /* Clears the SCAN bit */
+       /***********************/
+    //BEGIN JK 07.05.04: Comparison between WIN32 and Linux driver     
+    //devpriv->b_ModeSelectRegister=devpriv->b_ModeSelectRegister | APCI3120_DISABLE_SCAN;
+    devpriv->b_ModeSelectRegister = devpriv->b_ModeSelectRegister & 
+                                    APCI3120_DISABLE_SCAN;
+    //END JK 07.05.04: Comparison between WIN32 and Linux driver                                    
        outb(devpriv->b_ModeSelectRegister,dev->iobase+APCI3120_WRITE_MODE_SELECT);
 
        // If DMA is disabled  
@@ -854,12 +928,12 @@ int i_APCI3120_CyclicAnalogInput(int mode, comedi_device * dev,comedi_subdevice
                       outb(devpriv->b_TimerSelectMode,dev->iobase+APCI3120_TIMER_CRT1);
          
                       //Writing LOW WORD
-                      b_Tmp=((devpriv->b_DigitalOutputRegister<<4) & 0xF0) | APCI3120_SELECT_TIMER_2_LOW_WORD;
+                      b_Tmp=((devpriv->b_DigitalOutputRegister) & 0xF0) | APCI3120_SELECT_TIMER_2_LOW_WORD;
                       outb(b_Tmp,dev->iobase+APCI3120_TIMER_CRT0);
                       outw(LOWORD(ui_TimerValue2),dev->iobase+APCI3120_TIMER_VALUE);
               
                       //Writing HIGH WORD
-                      b_Tmp=((devpriv->b_DigitalOutputRegister<<4) & 0xF0) | APCI3120_SELECT_TIMER_2_HIGH_WORD;
+                      b_Tmp=((devpriv->b_DigitalOutputRegister) & 0xF0) | APCI3120_SELECT_TIMER_2_HIGH_WORD;
                       outb(b_Tmp,dev->iobase+APCI3120_TIMER_CRT0);
                       outw(HIWORD(ui_TimerValue2),dev->iobase+APCI3120_TIMER_VALUE);
 
@@ -879,11 +953,17 @@ int i_APCI3120_CyclicAnalogInput(int mode, comedi_device * dev,comedi_subdevice
        else 
          {
         // If DMA Enabled 
-                inw(dev->iobase+0);// reset EOC bit    
-                devpriv->b_InterruptMode=APCI3120_DMA_MODE;
-
-               // disable EOC and EOS interrupt
-        devpriv->b_ModeSelectRegister = devpriv->b_ModeSelectRegister & APCI3120_DISABLE_EOC_INT & APCI3120_DISABLE_EOS_INT;
+       //BEGIN JK 07.05.04: Comparison between WIN32 and Linux driver         
+       //inw(dev->iobase+0);// reset EOC bit    
+       //END JK 07.05.04: Comparison between WIN32 and Linux driver
+       devpriv->b_InterruptMode=APCI3120_DMA_MODE;
+
+      /************************************/
+         /* Disables the EOC, EOS interrupt  */
+         /************************************/                
+      devpriv->b_ModeSelectRegister = devpriv->b_ModeSelectRegister & 
+                                      APCI3120_DISABLE_EOC_INT & 
+                                      APCI3120_DISABLE_EOS_INT;
                
                outb(devpriv->b_ModeSelectRegister,dev->iobase+APCI3120_WRITE_MODE_SELECT);
                
@@ -941,14 +1021,28 @@ int i_APCI3120_CyclicAnalogInput(int mode, comedi_device * dev,comedi_subdevice
                outl(ui_Tmp,devpriv->i_IobaseAmcc+AMCC_OP_REG_AGCSTS);
         
                // changed  since 16 bit interface for add on
+               /*********************/
+               /* ENABLE BUS MASTER */
+               /*********************/         
                outw(APCI3120_ADD_ON_AGCSTS_LOW,devpriv->i_IobaseAddon+0);
                outw(APCI3120_ENABLE_TRANSFER_ADD_ON_LOW,devpriv->i_IobaseAddon+2);
+               
                outw(APCI3120_ADD_ON_AGCSTS_HIGH,devpriv->i_IobaseAddon+0);
                outw(APCI3120_ENABLE_TRANSFER_ADD_ON_HIGH,devpriv->i_IobaseAddon+2); 
+               
+               // TO VERIFIED
+               //BEGIN JK 07.05.04: Comparison between WIN32 and Linux driver          
+               outw(0x1000,devpriv->i_IobaseAddon+2);          
+               //END JK 07.05.04: Comparison between WIN32 and Linux driver    
+                               
                //2  No change
                // A2P FIFO MANAGEMENT
-               // A2P fifo reset  & transfer control enable
-               outl(APCI3120_A2P_FIFO_MANAGEMENT,devpriv->i_IobaseAmcc+AMCC_OP_REG_MCSR );
+           // A2P fifo reset  & transfer control enable
+                /***********************/
+                /* A2P FIFO MANAGEMENT */
+                /***********************/          
+               outl(APCI3120_A2P_FIFO_MANAGEMENT,devpriv->i_IobaseAmcc + 
+                                                          APCI3120_AMCC_OP_MCSR);
 
                //3
                //beginning address of dma buf 
@@ -960,22 +1054,26 @@ int i_APCI3120_CyclicAnalogInput(int mode, comedi_device * dev,comedi_subdevice
                outw(APCI3120_ADD_ON_MWAR_LOW,devpriv->i_IobaseAddon+0);
                outw((devpriv->ul_DmaBufferHw[0]& 0xFFFF),devpriv->i_IobaseAddon+2);
 
-               // DMA Start Adress High 
+                /*************************/
+                /* DMA Start Adress High */
+                /*************************/    
                outw(APCI3120_ADD_ON_MWAR_HIGH,devpriv->i_IobaseAddon+0);
-
-               // outw((devpriv->ul_DmaBufferHw[0]/65536),devpriv->i_IobaseAddon+2);
                outw((devpriv->ul_DmaBufferHw[0]/65536),devpriv->i_IobaseAddon+2);
 
                //4
                // amount of bytes to be transfered  set transfer count
                // used ADDON MWTC register
                //commented testing             outl(devpriv->ui_DmaBufferUsesize[0], devpriv->i_IobaseAddon+AMCC_OP_REG_AMWTC);
-               // Nbr of acquisition LOW 
-                
+
+                /**************************/
+                /* Nbr of acquisition LOW */
+                /**************************/   
                outw(APCI3120_ADD_ON_MWTC_LOW,devpriv->i_IobaseAddon + 0);
                outw((devpriv->ui_DmaBufferUsesize[0] & 0xFFFF),devpriv->i_IobaseAddon + 2);
 
-               // Nbr of acquisition HIGH 
+                /***************************/
+                /* Nbr of acquisition HIGH */
+                /***************************/
                outw(APCI3120_ADD_ON_MWTC_HIGH,devpriv->i_IobaseAddon + 0);
                outw((devpriv->ui_DmaBufferUsesize[0]/65536),devpriv->i_IobaseAddon + 2);
                
@@ -983,15 +1081,42 @@ int i_APCI3120_CyclicAnalogInput(int mode, comedi_device * dev,comedi_subdevice
                // To configure A2P FIFO
                // testing outl( FIFO_ADVANCE_ON_BYTE_2,devpriv->i_IobaseAmcc+AMCC_OP_REG_INTCSR);  
 
+               /******************/
+               /* A2P FIFO RESET */
+               /******************/
+               // TO VERIFY
+               //BEGIN JK 07.05.04: Comparison between WIN32 and Linux driver          
+               outl(0x04000000UL, devpriv->i_IobaseAmcc+AMCC_OP_REG_MCSR);     
+               //END JK 07.05.04: Comparison between WIN32 and Linux driver    
+               
                //6 
                //ENABLE A2P FIFO WRITE AND ENABLE AMWEN 
                // AMWEN_ENABLE | A2P_FIFO_WRITE_ENABLE (0x01|0x02)=0x03
-               outw(3,devpriv->i_IobaseAddon + 4);
+               //BEGIN JK 07.05.04: Comparison between WIN32 and Linux driver                                          
+               //outw(3,devpriv->i_IobaseAddon + 4);
+               //END JK 07.05.04: Comparison between WIN32 and Linux driver    
 
                //7
-               //initialise end of dma interrupt  AINT_WRITE_COMPL = ENABLE_WRITE_TC_INT(ADDI)    
-               outl((APCI3120_FIFO_ADVANCE_ON_BYTE_2| APCI3120_ENABLE_WRITE_TC_INT), devpriv->i_IobaseAmcc+AMCC_OP_REG_INTCSR);        
-
+        //initialise end of dma interrupt  AINT_WRITE_COMPL = ENABLE_WRITE_TC_INT(ADDI)    
+               /***************************************************/
+               /* A2P FIFO CONFIGURATE, END OF DMA INTERRUPT INIT */
+               /***************************************************/        
+               outl((APCI3120_FIFO_ADVANCE_ON_BYTE_2 | APCI3120_ENABLE_WRITE_TC_INT), 
+                     devpriv->i_IobaseAmcc+AMCC_OP_REG_INTCSR);        
+
+               //BEGIN JK 07.05.04: Comparison between WIN32 and Linux driver                                                
+               /******************************************/
+               /* ENABLE A2P FIFO WRITE AND ENABLE AMWEN */
+               /******************************************/                  
+               outw(3,devpriv->i_IobaseAddon + 4);
+               //END JK 07.05.04: Comparison between WIN32 and Linux driver            
+               
+               /******************/
+               /* A2P FIFO RESET */
+               /******************/
+               //BEGIN JK 07.05.04: Comparison between WIN32 and Linux driver          
+               outl(0x04000000UL, devpriv->i_IobaseAmcc+APCI3120_AMCC_OP_MCSR);        
+               //END JK 07.05.04: Comparison between WIN32 and Linux driver    
          }
       
         if ((devpriv->us_UseDma==APCI3120_DISABLE) && !devpriv->b_AiContinuous) 
@@ -1022,10 +1147,6 @@ int i_APCI3120_CyclicAnalogInput(int mode, comedi_device * dev,comedi_subdevice
 
 }
 
-
-
-
-
 /*
 +----------------------------------------------------------------------------+
 |                      INTERNAL FUNCTIONS                                                               |
@@ -1055,6 +1176,7 @@ int i_APCI3120_Reset(comedi_device *dev)
 {
        unsigned int i;
        unsigned short us_TmpValue;
+       
        devpriv->b_AiCyclicAcquisition=APCI3120_DISABLE;
        devpriv->b_EocEosInterrupt=APCI3120_DISABLE;
         devpriv->b_InterruptMode=APCI3120_EOC_MODE;
@@ -1088,7 +1210,7 @@ int i_APCI3120_Reset(comedi_device *dev)
 
        //  Reset digital output to L0W 
        
-       outb(0x0,dev->iobase+APCI3120_DIGITAL_OUTPUT);  
+//ES05 outb(0x0,dev->iobase+APCI3120_DIGITAL_OUTPUT);  
        udelay(10);
 
        inw(dev->iobase+0);                                             //make a dummy read
@@ -1133,9 +1255,10 @@ int i_APCI3120_Reset(comedi_device *dev)
 
 int i_APCI3120_SetupChannelList(comedi_device * dev, comedi_subdevice * s, int n_chan, unsigned int *chanlist,char check) 
 {
-       unsigned int i;//, differencial=0, bipolar=0;
+       unsigned int i;//, differencial=0, bipolar=0;       
        unsigned int gain;
        unsigned short us_TmpValue;
+       
        /* correct channel and range number check itself comedi/range.c */
        if (n_chan<1) 
         {
@@ -1162,14 +1285,18 @@ int i_APCI3120_SetupChannelList(comedi_device * dev, comedi_subdevice * s, int n
                }
              else 
               {
-                  us_TmpValue|=APCI3120_UNIPOLAR; // enable unipolar......
+                  us_TmpValue|=APCI3120_UNIPOLAR; // enable unipolar......             
               }
-             gain=CR_RANGE(chanlist[i]);               // get gain number
-              
+             
+             gain=CR_RANGE(chanlist[i]);               // get gain number              
              us_TmpValue|=((gain & 0x03)<<4);  //<<4 for G0 and G1 bit in RAM 
-             us_TmpValue|= i<<8;                                       //To select the RAM LOCATION....
-              
+             us_TmpValue|= i<<8;                                       //To select the RAM LOCATION....              
              outw(us_TmpValue,dev->iobase+APCI3120_SEQ_RAM_ADDRESS);       
+
+             
+             printk ("\n Gain = %i", (((unsigned char) CR_RANGE(chanlist[i]) & 0x03) << 2));
+             printk ("\n Channel = %i", CR_CHAN(chanlist[i]));
+             printk ("\n Polarity = %i", us_TmpValue & APCI3120_UNIPOLAR);
         }
        return 1; // we can serve this with scan logic
 }
@@ -1178,6 +1305,7 @@ int i_APCI3120_SetupChannelList(comedi_device * dev, comedi_subdevice * s, int n
 
 
 
+
 /*
 +----------------------------------------------------------------------------+
 | Function name     :  int i_APCI3120_ExttrigEnable(comedi_device * dev)    |
@@ -1198,6 +1326,8 @@ int i_APCI3120_SetupChannelList(comedi_device * dev, comedi_subdevice * s, int n
 
 int i_APCI3120_ExttrigEnable(comedi_device * dev)
 {
+
+
        devpriv->us_OutputRegister|=APCI3120_ENABLE_EXT_TRIGGER;
        outw(devpriv->us_OutputRegister,dev->iobase+APCI3120_WR_ADDRESS);
        return 0;
@@ -1269,14 +1399,15 @@ int i_APCI3120_ExttrigDisable(comedi_device * dev)
 {      
        comedi_device *dev = d;
         USHORT int_daq;
-        
+
        unsigned int int_amcc,ui_Check,i;
         USHORT us_TmpValue;
        BYTE  b_DummyRead;      
         
        comedi_subdevice *s = dev->subdevices + 0;      
         ui_Check=1;    
-        
+
+
        int_daq=inw(dev->iobase+APCI3120_RD_STATUS) & 0xf000;           // get IRQ reasons
        int_amcc=inl(devpriv->i_IobaseAmcc+AMCC_OP_REG_INTCSR); // get AMCC INT register
         
@@ -1390,7 +1521,11 @@ int i_APCI3120_ExttrigDisable(comedi_device * dev)
                         //stop timer 0 and timer 1
                        i_APCI3120_StopCyclicAcquisition(dev,s);
                         devpriv->b_AiCyclicAcquisition=APCI3120_DISABLE;
-                        comedi_done(dev,s); 
+                        
+                       //UPDATE-0.7.57->0.7.68comedi_done(dev,s); 
+                       s->async->events |= COMEDI_CB_EOA;
+                       comedi_event(dev,s,s->async->events);                   
+                       
                        break;  
                                  
                        
@@ -1426,8 +1561,6 @@ int i_APCI3120_ExttrigDisable(comedi_device * dev)
        
        if ((int_daq & 0x4) &&(devpriv->b_InterruptMode == APCI3120_DMA_MODE))
          {
-               
-               //DPRINTK("\n interrupt is DMA\n");
                 if(devpriv->b_AiCyclicAcquisition==APCI3120_ENABLE) 
                {
                    
@@ -1445,6 +1578,7 @@ int i_APCI3120_ExttrigDisable(comedi_device * dev)
                }
                 else
                 {
+               /* Stops the Timer */
                outw(devpriv->us_OutputRegister & APCI3120_DISABLE_TIMER0 & APCI3120_DISABLE_TIMER1,dev->iobase+APCI3120_WR_ADDRESS);
                 }
 
@@ -1473,7 +1607,8 @@ int i_APCI3120_ExttrigDisable(comedi_device * dev)
 +----------------------------------------------------------------------------+
 */
 
-int i_APCI3120_InterruptHandleEos(comedi_device *dev)
+
+/*int i_APCI3120_InterruptHandleEos(comedi_device *dev)
 {  
        int n_chan,i;
        sampl_t *data;
@@ -1481,6 +1616,7 @@ int i_APCI3120_InterruptHandleEos(comedi_device *dev)
        comedi_async *async = s->async;
        data=async->data+async->buf_int_ptr;//new samples added from here onwards
        n_chan=devpriv->ui_AiNbrofChannels;
+       
        for(i=0;i<n_chan;i++)
          { 
            data[i]=inw(dev->iobase+0);
@@ -1490,15 +1626,34 @@ int i_APCI3120_InterruptHandleEos(comedi_device *dev)
        comedi_eos(dev,s);
        if (s->async->buf_int_ptr>=s->async->data_len) //  for buffer rool over  
          { 
-               /* buffer rollover */
-               s->async->buf_int_ptr=0;
+*/             /* buffer rollover */
+/*             s->async->buf_int_ptr=0;
                comedi_eobuf(dev,s);
          }
        return 0;
-}  
-
-
-
+}*/  
+int i_APCI3120_InterruptHandleEos(comedi_device *dev)
+{  
+       int n_chan,i;
+       comedi_subdevice *s=dev->subdevices+0;
+       int err=1;
+       
+       n_chan=devpriv->ui_AiNbrofChannels;
+       
+       s->async->events = 0;
+       
+       for(i=0;i<n_chan;i++)       
+           err &= comedi_buf_put(s->async, inw(dev->iobase+0));
+        
+        s->async->events |= COMEDI_CB_EOS;
+                       
+       if (err==0)
+          s->async->events |= COMEDI_CB_OVERFLOW;
+       
+        comedi_event(dev,s,s->async->events);  
+         
+       return 0;
+}
 
 
 
@@ -1525,13 +1680,13 @@ int i_APCI3120_InterruptHandleEos(comedi_device *dev)
  void v_APCI3120_InterruptDma(int irq, void *d, struct pt_regs *regs) 
 {
        comedi_device *dev = d;
-       comedi_subdevice *s = dev->subdevices + 0;
-       sampl_t *ptr;
-       unsigned int next_dma_buf, samplesinbuf,m;
+       comedi_subdevice *s = dev->subdevices + 0;      
+       unsigned int next_dma_buf, samplesinbuf;
        unsigned long low_word,high_word,var;
+       
        UINT ui_Tmp;              
        samplesinbuf=devpriv->ui_DmaBufferUsesize[devpriv->ui_DmaActualBuffer]-inl(devpriv->i_IobaseAmcc+AMCC_OP_REG_MWTC);
-       //rt_printk("\nSamples in buffer=%d \n", samplesinbuf);
+       
        if (samplesinbuf<devpriv->ui_DmaBufferUsesize[devpriv->ui_DmaActualBuffer]) 
        {
            comedi_error(dev,"Interrupted DMA transfer!");
@@ -1541,7 +1696,7 @@ int i_APCI3120_InterruptHandleEos(comedi_device *dev)
                comedi_error(dev,"Odd count of bytes in DMA ring!");
                i_APCI3120_StopCyclicAcquisition(dev,s);
                 devpriv->b_AiCyclicAcquisition=APCI3120_DISABLE;
-               comedi_error_done(dev,s);
+
                return;
        }
        samplesinbuf=samplesinbuf>>1;   // number of received samples
@@ -1549,33 +1704,42 @@ int i_APCI3120_InterruptHandleEos(comedi_device *dev)
        {
                // switch DMA buffers if is used double buffering
                next_dma_buf=1-devpriv->ui_DmaActualBuffer;
+               
                ui_Tmp=AGCSTS_TC_ENABLE  | AGCSTS_RESET_A2P_FIFO ;
                outl(ui_Tmp,devpriv->i_IobaseAddon+AMCC_OP_REG_AGCSTS);
+                               
                // changed  since 16 bit interface for add on
                outw(APCI3120_ADD_ON_AGCSTS_LOW,devpriv->i_IobaseAddon+0);
                outw(APCI3120_ENABLE_TRANSFER_ADD_ON_LOW,devpriv->i_IobaseAddon+2);
                outw(APCI3120_ADD_ON_AGCSTS_HIGH,devpriv->i_IobaseAddon+0);
                outw(APCI3120_ENABLE_TRANSFER_ADD_ON_HIGH ,devpriv->i_IobaseAddon+2); // 0x1000 is out putted in windows driver 
-
-               // A2P FIFO MANAGEMENT
-               // A2P fifo reset  & transfer control enable
-               outl(APCI3120_A2P_FIFO_MANAGEMENT,devpriv->i_IobaseAmcc+AMCC_OP_REG_MCSR );
+               
                var=devpriv->ul_DmaBufferHw[next_dma_buf];
                low_word=var & 0xffff;
                var=devpriv->ul_DmaBufferHw[next_dma_buf];
                high_word=var /65536;
+               
+               /* DMA Start Adress Low */
                outw(APCI3120_ADD_ON_MWAR_LOW,devpriv->i_IobaseAddon+0);
                outw(low_word,devpriv->i_IobaseAddon+2);
+               
+               /* DMA Start Adress High */
                outw(APCI3120_ADD_ON_MWAR_HIGH,devpriv->i_IobaseAddon+0);
                outw(high_word,devpriv->i_IobaseAddon+2);
-               var=devpriv->ui_DmaBufferUsesize[next_dma_buf];
+               
+               var=devpriv->ui_DmaBufferUsesize[next_dma_buf];         
                low_word=var & 0xffff;
                var=devpriv->ui_DmaBufferUsesize[next_dma_buf];
                high_word=var /65536;
+               
+               /* Nbr of acquisition LOW */
                outw(APCI3120_ADD_ON_MWTC_LOW,devpriv->i_IobaseAddon+0);
                outw(low_word,devpriv->i_IobaseAddon+2);
+               
+               /* Nbr of acquisition HIGH */
                outw(APCI3120_ADD_ON_MWTC_HIGH,devpriv->i_IobaseAddon+0);
                outw(high_word,devpriv->i_IobaseAddon+2);
+               
                // To configure A2P FIFO 
                // ENABLE A2P FIFO WRITE AND ENABLE AMWEN 
                // AMWEN_ENABLE | A2P_FIFO_WRITE_ENABLE (0x01|0x02)=0x03
@@ -1584,10 +1748,11 @@ int i_APCI3120_InterruptHandleEos(comedi_device *dev)
                outl((APCI3120_FIFO_ADVANCE_ON_BYTE_2| APCI3120_ENABLE_WRITE_TC_INT), devpriv->i_IobaseAmcc+AMCC_OP_REG_INTCSR);        
                  
        }
-       
+/*UPDATE-0.7.57->0.7.68        
        ptr=(sampl_t *)devpriv->ul_DmaBufferVirtual[devpriv->ui_DmaActualBuffer];
-          
        
+
+       // if there is not enough space left in the buffer to copy all data contained in the DMABufferVirtual
        if(s->async->buf_int_ptr+samplesinbuf*sizeof(sampl_t)>=devpriv->ui_AiDataLength)
        {
                m=(devpriv->ui_AiDataLength-s->async->buf_int_ptr)/sizeof(sampl_t);
@@ -1620,11 +1785,31 @@ int i_APCI3120_InterruptHandleEos(comedi_device *dev)
                comedi_done(dev,s); 
                return;
        }
+*/     
+       if (samplesinbuf) 
+       {
+               v_APCI3120_InterruptDmaMoveBlock16bit(dev,s,devpriv->ul_DmaBufferVirtual[devpriv->ui_DmaActualBuffer],samplesinbuf);
+                
+               if (!(devpriv->ui_AiFlags & TRIG_WAKE_EOS)) 
+               {
+                       s->async->events |= COMEDI_CB_EOS;
+                       comedi_event(dev,s,s->async->events);
+                }
+       }
+       if (!devpriv->b_AiContinuous)
+       if ( devpriv->ui_AiActualScan>=devpriv->ui_AiNbrofScans ) 
+       { 
+           // all data sampled 
+           i_APCI3120_StopCyclicAcquisition(dev,s);
+            devpriv->b_AiCyclicAcquisition=APCI3120_DISABLE;
+           s->async->events |= COMEDI_CB_EOA;
+           comedi_event(dev,s,s->async->events);                       
+            return;
+       }
        
        if (devpriv->b_DmaDoubleBuffer) 
        {       // switch dma buffers
                devpriv->ui_DmaActualBuffer=1-devpriv->ui_DmaActualBuffer; 
-                
        } 
        else 
        { 
@@ -1691,7 +1876,7 @@ int i_APCI3120_InterruptHandleEos(comedi_device *dev)
 +----------------------------------------------------------------------------+
 */
 
-void v_APCI3120_InterruptDmaMoveBlock16bit(comedi_device *dev,comedi_subdevice *s,sampl_t *dma,sampl_t *data,int n)
+/*void v_APCI3120_InterruptDmaMoveBlock16bit(comedi_device *dev,comedi_subdevice *s,sampl_t *dma,sampl_t *data,int n)
 {
        int i,j,m;
 
@@ -1711,7 +1896,7 @@ void v_APCI3120_InterruptDmaMoveBlock16bit(comedi_device *dev,comedi_subdevice *
                                m=0;
                                devpriv->ui_AiActualScan++;
                                if (devpriv->ui_AiFlags & TRIG_WAKE_EOS) 
-                                       comedi_eos(dev,s);  
+;//UPDATE-0.7.57->0.7.68                                       comedi_eos(dev,s);  
                        }
                }
        }
@@ -1719,7 +1904,15 @@ void v_APCI3120_InterruptDmaMoveBlock16bit(comedi_device *dev,comedi_subdevice *
        s->async->cur_chan=j;
                 
 }
-
+*/
+void v_APCI3120_InterruptDmaMoveBlock16bit(comedi_device *dev,comedi_subdevice *s,sampl_t *dma_buffer,unsigned int num_samples)
+{
+       devpriv->ui_AiActualScan += (s->async->cur_chan + num_samples) / devpriv->ui_AiScanLength;
+       s->async->cur_chan += num_samples;
+       s->async->cur_chan %= devpriv->ui_AiScanLength;
+       
+       cfc_write_array_to_buffer(s, dma_buffer, num_samples * sizeof(sampl_t));                
+}
 
 
 
@@ -1774,8 +1967,9 @@ int i_APCI3120_InsnConfigTimer(comedi_device *dev,comedi_subdevice *s,comedi_ins
        //this_board->i_hwdrv_InsnConfigTimer(dev, ui_Timervalue2,(BYTE)data[0]);
         us_TmpValue=(USHORT) inw(devpriv->iobase+APCI3120_RD_STATUS);
        
-       //Testing if board have the new Quartz and calculate the time value to set in the timer
-       if((us_TmpValue & 0x00B0)==0x00B0)
+       //EL250804: Testing if board APCI3120 have the new Quartz or if it is an APCI3001
+       // and calculate the time value to set in the timer
+       if((us_TmpValue & 0x00B0)==0x00B0 || !strcmp(this_board->pc_DriverName,"apci3001") )
        {
                //Calculate the time value to set in the timer
                ui_Timervalue2=ui_Timervalue2 / 50;   
@@ -1812,12 +2006,12 @@ int i_APCI3120_InsnConfigTimer(comedi_device *dev,comedi_subdevice *s,comedi_ins
                //are erase (Set to 0)
 
                //Writing LOW WORD
-               b_Tmp=((devpriv->b_DigitalOutputRegister<<4) & 0xF0) | APCI3120_SELECT_TIMER_2_LOW_WORD;
+               b_Tmp=((devpriv->b_DigitalOutputRegister) & 0xF0) | APCI3120_SELECT_TIMER_2_LOW_WORD;
                outb(b_Tmp,devpriv->iobase+APCI3120_TIMER_CRT0);
                outw(LOWORD(ui_Timervalue2),devpriv->iobase+APCI3120_TIMER_VALUE);
               
                //Writing HIGH WORD
-               b_Tmp=((devpriv->b_DigitalOutputRegister<<4) & 0xF0) | APCI3120_SELECT_TIMER_2_HIGH_WORD;
+               b_Tmp=((devpriv->b_DigitalOutputRegister) & 0xF0) | APCI3120_SELECT_TIMER_2_HIGH_WORD;
                outb(b_Tmp,devpriv->iobase+APCI3120_TIMER_CRT0);
                outw(HIWORD(ui_Timervalue2),devpriv->iobase+APCI3120_TIMER_VALUE);
                // timer2 in Timer mode enabled
@@ -1839,13 +2033,14 @@ int i_APCI3120_InsnConfigTimer(comedi_device *dev,comedi_subdevice *s,comedi_ins
                //are erase (Set to 0)
 
                //Writing LOW WORD
-               b_Tmp=((devpriv->b_DigitalOutputRegister<<4) & 0xF0) | APCI3120_SELECT_TIMER_2_LOW_WORD;
+               b_Tmp=((devpriv->b_DigitalOutputRegister) & 0xF0) | APCI3120_SELECT_TIMER_2_LOW_WORD;
                outb(b_Tmp,devpriv->iobase+APCI3120_TIMER_CRT0);
                outw(LOWORD(ui_Timervalue2),devpriv->iobase+APCI3120_TIMER_VALUE);
               
                //Writing HIGH WORD
-               b_Tmp=((devpriv->b_DigitalOutputRegister<<4) & 0xF0) | APCI3120_SELECT_TIMER_2_HIGH_WORD;
+               b_Tmp=((devpriv->b_DigitalOutputRegister) & 0xF0) | APCI3120_SELECT_TIMER_2_HIGH_WORD;
                outb(b_Tmp,devpriv->iobase+APCI3120_TIMER_CRT0);
+
                outw(HIWORD(ui_Timervalue2),devpriv->iobase+APCI3120_TIMER_VALUE);
                //watchdog enabled
                devpriv->b_Timer2Mode=APCI3120_WATCHDOG;
@@ -1894,9 +2089,7 @@ int i_APCI3120_InsnWriteTimer(comedi_device *dev,comedi_subdevice *s, comedi_ins
                USHORT us_TmpValue; 
        BYTE b_Tmp;
   
-  
-       
+
        if((devpriv->b_Timer2Mode!=APCI3120_WATCHDOG) && (devpriv->b_Timer2Mode!=APCI3120_TIMER))
        {
                comedi_error(dev,"\nwrite:timer2  not configured ");
@@ -1998,11 +2191,12 @@ int i_APCI3120_InsnWriteTimer(comedi_device *dev,comedi_subdevice *s, comedi_ins
                       // ui_Timervalue2=data[1]; // passed as argument
                         us_TmpValue=(USHORT) inw(devpriv->iobase+APCI3120_RD_STATUS);
 
-                       //Testing if board have the new Quartz and calculate the time value to set in the timer
-                       if((us_TmpValue & 0x00B0)==0x00B0)
-                       {
-                       //Calculate the time value to set in the timer
-                       ui_Timervalue2=ui_Timervalue2 / 50;   
+                        //EL250804: Testing if board APCI3120 have the new Quartz or if it is an APCI3001
+                        // and calculate the time value to set in the timer
+                       if((us_TmpValue & 0x00B0)==0x00B0 || !strcmp(this_board->pc_DriverName,"apci3001") )
+                       {
+                               //Calculate the time value to set in the timer
+                               ui_Timervalue2=ui_Timervalue2 / 50;   
                        }
                        else
                        {
@@ -2010,13 +2204,15 @@ int i_APCI3120_InsnWriteTimer(comedi_device *dev,comedi_subdevice *s, comedi_ins
                        ui_Timervalue2=ui_Timervalue2 / 70;                 
                        }
                        //Writing LOW WORD
-                       b_Tmp=((devpriv->b_DigitalOutputRegister<<4) & 0xF0) | APCI3120_SELECT_TIMER_2_LOW_WORD;
+                       b_Tmp=((devpriv->b_DigitalOutputRegister) & 0xF0) | APCI3120_SELECT_TIMER_2_LOW_WORD;
                        outb(b_Tmp,devpriv->iobase+APCI3120_TIMER_CRT0);
+
                        outw(LOWORD(ui_Timervalue2),devpriv->iobase+APCI3120_TIMER_VALUE);
               
                        //Writing HIGH WORD
-                       b_Tmp=((devpriv->b_DigitalOutputRegister<<4) & 0xF0) | APCI3120_SELECT_TIMER_2_HIGH_WORD;
+                       b_Tmp=((devpriv->b_DigitalOutputRegister) & 0xF0) | APCI3120_SELECT_TIMER_2_HIGH_WORD;
                        outb(b_Tmp,devpriv->iobase+APCI3120_TIMER_CRT0);
+                       
                        outw(HIWORD(ui_Timervalue2),devpriv->iobase+APCI3120_TIMER_VALUE);
 
                        break;    
@@ -2055,6 +2251,7 @@ int i_APCI3120_InsnReadTimer(comedi_device *dev,comedi_subdevice *s,comedi_insn
         BYTE b_Tmp;
        USHORT us_TmpValue,us_TmpValue_2,us_StatusValue;
        
+       
        if((devpriv->b_Timer2Mode!=APCI3120_WATCHDOG) &&  (devpriv->b_Timer2Mode!=APCI3120_TIMER))
        {
           comedi_error(dev,"\nread:timer2  not configured ");
@@ -2066,13 +2263,15 @@ int i_APCI3120_InsnReadTimer(comedi_device *dev,comedi_subdevice *s,comedi_insn
        {
                
                //Read the LOW WORD of Timer 2 register
-               b_Tmp=((devpriv->b_DigitalOutputRegister<<4) & 0xF0) | APCI3120_SELECT_TIMER_2_LOW_WORD;
+               b_Tmp=((devpriv->b_DigitalOutputRegister) & 0xF0) | APCI3120_SELECT_TIMER_2_LOW_WORD;
                outb(b_Tmp,devpriv->iobase+APCI3120_TIMER_CRT0);
+               
                us_TmpValue=inw(devpriv->iobase+APCI3120_TIMER_VALUE);
                 
                //Read the HIGH WORD of Timer 2 register
-               b_Tmp=((devpriv->b_DigitalOutputRegister<<4) & 0xF0) | APCI3120_SELECT_TIMER_2_HIGH_WORD;
+               b_Tmp=((devpriv->b_DigitalOutputRegister) & 0xF0) | APCI3120_SELECT_TIMER_2_HIGH_WORD;
                outb(b_Tmp,devpriv->iobase+APCI3120_TIMER_CRT0);
+               
                us_TmpValue_2=inw(devpriv->iobase+APCI3120_TIMER_VALUE);
        
                // combining both words
@@ -2131,6 +2330,7 @@ int i_APCI3120_InsnReadDigitalInput(comedi_device *dev,comedi_subdevice
          UINT  ui_Chan,ui_TmpValue;
          
         ui_Chan = CR_CHAN(insn->chanspec); // channel specified
+
         //this_board->i_hwdrv_InsnReadDigitalInput(dev,ui_Chan,data);
          if(ui_Chan >= 0 && ui_Chan <= 3)
        {
@@ -2178,6 +2378,7 @@ int i_APCI3120_InsnBitsDigitalInput(comedi_device *dev,comedi_subdevice *s,
                        rotated right 8 times to bring them to last four bits
                        ANDed with oxf for  value.
        *****/
+       
        *data=(ui_TmpValue >>8) & 0xf;
         //this_board->i_hwdrv_InsnBitsDigitalInput(dev,data);
        return insn->n;
@@ -2226,7 +2427,7 @@ int i_APCI3120_InsnConfigDigitalOutput(comedi_device *dev,comedi_subdevice *s,
        else
        {
        devpriv->b_OutputMemoryStatus = APCI3120_DISABLE;
-       
+        devpriv -> b_DigitalOutputRegister = 0;       
        }
         if(!devpriv->b_OutputMemoryStatus )
           {
@@ -2265,8 +2466,6 @@ int i_APCI3120_InsnConfigDigitalOutput(comedi_device *dev,comedi_subdevice *s,
 int i_APCI3120_InsnBitsDigitalOutput(comedi_device *dev,comedi_subdevice 
                                                                        *s, comedi_insn *insn,lsampl_t *data)
 {
-      
        if ((data[0] > this_board->i_DoMaxdata) || (data[0]<0))
        {
        
@@ -2277,16 +2476,17 @@ int i_APCI3120_InsnBitsDigitalOutput(comedi_device *dev,comedi_subdevice
    
         switch(data[1])
            {
-           case 1 :data[0]=(data[0]<<4)|ui_Temp;
+           case 1 :data[0]=(data[0]<<4)|devpriv -> b_DigitalOutputRegister;
                    break;
        
-           case 2 :data[0]=data[0]<<4;  
+           case 2 :data[0]=data[0];  
                   break;
            default :printk("\nThe parameter passed is in error \n");
                     return -EINVAL;
            }// switch(data[1])
         outb(data[0], devpriv->iobase + APCI3120_DIGITAL_OUTPUT);
-        ui_Temp=data[0]&0xF0;
+       
+        devpriv->b_DigitalOutputRegister = data[0]&0xF0;
      
        return  insn->n;
 
@@ -2339,7 +2539,8 @@ int i_APCI3120_InsnWriteDigitalOutput(comedi_device *dev,comedi_subdevice
           switch(data[1])
            {
            case 1 :data[0]=(data[0] << ui_NoOfChannel);
-                   data[0]=(data[0]<<4)|ui_Temp;
+//ES05                   data[0]=(data[0]<<4)|ui_Temp;
+                   data[0]=(data[0]<<4)|devpriv -> b_DigitalOutputRegister;
                    break;
        
            case 2 :
@@ -2347,16 +2548,22 @@ int i_APCI3120_InsnWriteDigitalOutput(comedi_device *dev,comedi_subdevice
                    ui_Temp1=1;   
                    ui_Temp1=ui_Temp1<<ui_NoOfChannel;
                    ui_Temp1=ui_Temp1<<4; 
-                   ui_Temp=ui_Temp|ui_Temp1;
+//ES05                   ui_Temp=ui_Temp|ui_Temp1;
+                   devpriv -> b_DigitalOutputRegister = 
+                  devpriv -> b_DigitalOutputRegister | ui_Temp1;
+
                    data[0]=(data[0] << ui_NoOfChannel)^0xf;
                    data[0]=data[0]<<4;
-                   data[0]=data[0]& ui_Temp;
+//ES05                   data[0]=data[0]& ui_Temp;
+                   data[0]=data[0] & devpriv -> b_DigitalOutputRegister;
                    break;
           default :printk("\nThe parameter passed is in error \n");
                     return -EINVAL;
            }// switch(data[1])
                outb(data[0], devpriv->iobase + APCI3120_DIGITAL_OUTPUT);
-        ui_Temp=data[0] & 0xf0;
+       
+//ES05        ui_Temp=data[0] & 0xf0;
+        devpriv -> b_DigitalOutputRegister = data[0] & 0xf0;
        return (insn->n);
 
 }
@@ -2400,6 +2607,7 @@ int i_APCI3120_InsnWriteAnalogOutput(comedi_device *dev,comedi_subdevice
        
          ui_Range              =       CR_RANGE(insn->chanspec);
          ui_Channel    =       CR_CHAN(insn->chanspec);
+
  
           //this_board->i_hwdrv_InsnWriteAnalogOutput(dev, ui_Range, ui_Channel,data[0]);
           if(ui_Range)  // if 1 then unipolar 
index c653d71243f7aa26ffc9817db40d97451676be52..b93cf7842c347978a061b83b7d6a7c4fe963ac91 100644 (file)
@@ -1,8 +1,32 @@
 
+
 // hwdrv_apci3120.h
 
+/**
+@verbatim
+
+Copyright (C) 2004,2005  ADDI-DATA GmbH for the source code of this module. 
+        
+        ADDI-DATA GmbH 
+        Dieselstrasse 3 
+        D-77833 Ottersweier 
+        Tel: +19(0)7223/9493-0 
+        Fax: +49(0)7223/9493-92 
+        http://www.addi-data-com 
+        info@addi-data.com 
+
+This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
 
+You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+You shoud also find the complete GPL in the COPYING file accompanying this source code.
+
+@endverbatim
+*/
 /*
+   
   +-----------------------------------------------------------------------+
   | (C) ADDI-DATA GmbH          Dieselstrasse 3      D-77833 Ottersweier  |
   +-----------------------------------------------------------------------+
@@ -215,7 +239,8 @@ int i_APCI3120_Reset(comedi_device *dev);
 int i_APCI3120_CyclicAnalogInput(int mode, comedi_device * dev,comedi_subdevice * s);
 // Interrupt functions
 void v_APCI3120_Interrupt(int irq, void *d, struct pt_regs *regs) ;
-void v_APCI3120_InterruptDmaMoveBlock16bit(comedi_device *dev,comedi_subdevice *s,sampl_t *dma,sampl_t *data,int n);
+//UPDATE-0.7.57->0.7.68        void v_APCI3120_InterruptDmaMoveBlock16bit(comedi_device *dev,comedi_subdevice *s,sampl_t *dma,sampl_t *data,int n);
+void v_APCI3120_InterruptDmaMoveBlock16bit(comedi_device *dev,comedi_subdevice *s,sampl_t *dma_buffer,unsigned int num_samples);
 int i_APCI3120_InterruptHandleEos(comedi_device *dev);
 void v_APCI3120_InterruptDma(int irq, void *d, struct pt_regs *regs) ;
 
index e099ca87ff6c05095db325a442c5fa78fc33206f..59a8b57517faf8ac2ae7dfb1466f9a6ed089fc0c 100644 (file)
@@ -1,14 +1,38 @@
+/**
+@verbatim
+
+Copyright (C) 2004,2005  ADDI-DATA GmbH for the source code of this module. 
+        
+        ADDI-DATA GmbH 
+        Dieselstrasse 3 
+        D-77833 Ottersweier 
+        Tel: +19(0)7223/9493-0 
+        Fax: +49(0)7223/9493-92 
+        http://www.addi-data-com 
+        info@addi-data.com 
+
+This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+You shoud also find the complete GPL in the COPYING file accompanying this source code.
+
+@endverbatim
+*/
 /*
+    
   +-----------------------------------------------------------------------+
   | (C) ADDI-DATA GmbH          Dieselstraße 3       D-77833 Ottersweier  |
   +-----------------------------------------------------------------------+
   | Tel : +49 (0) 7223/9493-0     | email    : info@addi-data.com         |
   | Fax : +49 (0) 7223/9493-92    | Internet : http://www.addi-data.com   |
   +-------------------------------+---------------------------------------+
-  | Project     : 13Card Linux Driver | Compiler   : GCC                  |
-  | Module name : hwdrv_apci3200.c|     Version    : 2.96                 |
+  | Project     : APCI-3200       | Compiler   : GCC                      |
+  | Module name : hwdrv_apci3200.c| Version    : 2.96                     |
   +-------------------------------+---------------------------------------+
-  | Author : Shitalkumar S Chavan |     Date       : 10.12.2001           |
+  | Project manager: Eric Stolz   | Date       :  02/12/2002              |
   +-------------------------------+---------------------------------------+
   | Description :   Hardware Layer Acces For APCI-3200                    |
   +-----------------------------------------------------------------------+
   +----------+-----------+------------------------------------------------+
   |   Date   |   Author  |          Description of updates                |
   +----------+-----------+------------------------------------------------+
-  |          |           |                                                |
+  | 02.07.04 | J. Krauth | Modification from the driver in order to       |
+  |          |           | correct some errors when using several boards. |
   |          |           |                                                |
   |          |           |                                                |
   +----------+-----------+------------------------------------------------+
+  | 26.10.04 | J. Krauth | - Update for COMEDI 0.7.68                     |
+  |          |           | - Read eeprom value                            |
+  |          |           | - Append APCI-3300                             |
+  +----------+-----------+------------------------------------------------+  
 */
 
+
 /*
-+----------------------------------------------------------------------------+
-|                               Included files                               |
-+----------------------------------------------------------------------------+
+  +----------------------------------------------------------------------------+
+  |                               Included files                               |
+  +----------------------------------------------------------------------------+
 */
 #include "hwdrv_apci3200.h"
-INT i_CJCAvailable=1; 
-INT i_CJCPolarity=0;
-INT i_CJCGain=0;
-INT i_InterruptFlag=0;
-INT i_ADDIDATAPolarity;
-INT i_ADDIDATAGain;                  
-INT   i_AutoCalibration=0;   //: auto calibration  
-INT i_ADDIDATAConversionTime;
-INT i_ADDIDATAConversionTimeUnit; 
-INT i_ADDIDATAType;
-INT i_ChannelNo;
-INT i_ChannelCount=0;
-INT i_ScanType;
-INT i_FirstChannel;
-INT i_LastChannel;
-INT i_Sum=0;
-INT i_Offset;
-UINT ui_Channel_num=0;
-static int i_Count=0;
-INT i_Initialised=0;
-UINT ui_InterruptChannelValue[96]; //Buffer
+//Begin JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values
+#include "addi_amcc_S5920.h"
+//#define PRINT_INFO
+
+//End JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values
+
+//BEGIN JK 06.07.04: Management of sevrals boards
 /*
-+----------------------------------------------------------------------------+
-| Function   Name   : int i_APCI3200_ReadDigitalInput                       |
-|                        (comedi_device *dev,comedi_subdevice *s,               | 
-|                      comedi_insn *insn,lsampl_t *data)                     |
-+----------------------------------------------------------------------------+
-| Task              : Read  value  of the selected channel or port           |
-+----------------------------------------------------------------------------+
-| Input Parameters  : comedi_device *dev      : Driver handle                |
-|                     UINT ui_NoOfChannels    : No Of Channels To read  for Port   
-                                                Channel Numberfor single channel
-|                     UINT data[0]            : 0: Read single channel
-                                                1: Read port value   
-                           data[1]              Port number       
-+----------------------------------------------------------------------------+
-| Output Parameters :  --      data[0] :Read status value
-+----------------------------------------------------------------------------+
-| Return Value      : TRUE  : No error occur                                 |
-|                          : FALSE : Error occur. Return the error          |
-|                                                                               |
-+----------------------------------------------------------------------------+
+  INT i_CJCAvailable=1; 
+  INT i_CJCPolarity=0;
+  INT i_CJCGain=2;//changed from 0 to 2 
+  INT i_InterruptFlag=0;
+  INT i_ADDIDATAPolarity;
+  INT i_ADDIDATAGain;                  
+  INT i_AutoCalibration=0;   //: auto calibration  
+  INT i_ADDIDATAConversionTime;
+  INT i_ADDIDATAConversionTimeUnit; 
+  INT i_ADDIDATAType;
+  INT i_ChannelNo;
+  INT i_ChannelCount=0;
+  INT i_ScanType;
+  INT i_FirstChannel;
+  INT i_LastChannel;
+  INT i_Sum=0;
+  INT i_Offset;
+  UINT ui_Channel_num=0;
+  static int i_Count=0;
+  INT i_Initialised=0;
+  UINT ui_InterruptChannelValue[96]; //Buffer
 */
+str_BoardInfos s_BoardInfos [100]; // 100 will be the max number of boards to be used
+//END JK 06.07.04: Management of sevrals boards
+
+//Begin JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values
+
+/*+----------------------------------------------------------------------------+*/
+/*| Function   Name   : INT i_AddiHeaderRW_ReadEeprom                          |*/
+/*|                               (INT    i_NbOfWordsToRead,                   |*/ 
+/*|                                DWORD dw_PCIBoardEepromAddress,             |*/
+/*|                                WORD   w_EepromStartAddress,                |*/
+/*|                                PWORD pw_DataRead)                          |*/
+/*+----------------------------------------------------------------------------+*/
+/*| Task              : Read word from the 5920 eeprom.                        |*/
+/*+----------------------------------------------------------------------------+*/
+/*| Input Parameters  : INT    i_NbOfWordsToRead : Nbr. of word to read        |*/ 
+/*|                     DWORD dw_PCIBoardEepromAddress : Address of the eeprom |*/
+/*|                     WORD   w_EepromStartAddress : Eeprom strat address     |*/
+/*+----------------------------------------------------------------------------+*/
+/*| Output Parameters : PWORD pw_DataRead : Read data                          |*/                                                     
+/*+----------------------------------------------------------------------------+*/
+/*| Return Value      : -                                                      |*/
+/*+----------------------------------------------------------------------------+*/
+
+INT i_AddiHeaderRW_ReadEeprom (INT    i_NbOfWordsToRead,
+                               DWORD dw_PCIBoardEepromAddress,
+                               WORD   w_EepromStartAddress,
+                               PWORD pw_DataRead)
+{
+  DWORD dw_eeprom_busy=0;    
+  INT i_Counter=0;     
+  INT i_WordCounter;
+  INT i;
+  BYTE pb_ReadByte[1];
+  BYTE b_ReadLowByte = 0;
+  BYTE b_ReadHighByte = 0;
+  BYTE b_SelectedAddressLow = 0;
+  BYTE b_SelectedAddressHigh = 0;
+  WORD w_ReadWord = 0;
+   
+  for (i_WordCounter = 0;i_WordCounter<i_NbOfWordsToRead;i_WordCounter++)
+    {
+      do
+       {                           
+         dw_eeprom_busy = inl (dw_PCIBoardEepromAddress + AMCC_OP_REG_MCSR);
+         dw_eeprom_busy=dw_eeprom_busy & EEPROM_BUSY;
+       }
+      while (dw_eeprom_busy==EEPROM_BUSY);
 
-INT i_APCI3200_ReadDigitalInput(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data) 
+      for(i_Counter=0;i_Counter<2;i_Counter++)
+        {
+         b_SelectedAddressLow=(w_EepromStartAddress+i_Counter) % 256; //Read the low 8 bit part
+         b_SelectedAddressHigh=(w_EepromStartAddress+i_Counter)/256;  //Read the high 8 bit part
+
+         //Select the load low address mode
+         outb (NVCMD_LOAD_LOW, dw_PCIBoardEepromAddress+AMCC_OP_REG_MCSR+3);
+
+         //Wait on busy
+         do
+           {
+             dw_eeprom_busy = inl (dw_PCIBoardEepromAddress + AMCC_OP_REG_MCSR);
+             dw_eeprom_busy=dw_eeprom_busy & EEPROM_BUSY;
+           }
+         while(dw_eeprom_busy==EEPROM_BUSY);
+
+         //Load the low address
+         outb(b_SelectedAddressLow, dw_PCIBoardEepromAddress+AMCC_OP_REG_MCSR+2);
+
+         //Wait on busy
+         do
+           {
+             dw_eeprom_busy = inl (dw_PCIBoardEepromAddress + AMCC_OP_REG_MCSR);
+             dw_eeprom_busy=dw_eeprom_busy & EEPROM_BUSY;
+           }
+         while(dw_eeprom_busy== EEPROM_BUSY);
+
+         //Select the load high address mode
+         outb(NVCMD_LOAD_HIGH, dw_PCIBoardEepromAddress+AMCC_OP_REG_MCSR+3);
+
+         //Wait on busy
+         do
+           {
+             dw_eeprom_busy = inl (dw_PCIBoardEepromAddress + AMCC_OP_REG_MCSR);
+             dw_eeprom_busy=dw_eeprom_busy & EEPROM_BUSY;
+           }
+         while(dw_eeprom_busy== EEPROM_BUSY);
+
+         //Load the high address
+         outb (b_SelectedAddressHigh, dw_PCIBoardEepromAddress+AMCC_OP_REG_MCSR+2);
+
+         //Wait on busy
+         do
+           {
+             dw_eeprom_busy = inl (dw_PCIBoardEepromAddress + AMCC_OP_REG_MCSR);
+             dw_eeprom_busy=dw_eeprom_busy & EEPROM_BUSY;
+           }
+         while(dw_eeprom_busy== EEPROM_BUSY);
+
+         //Select the READ mode
+         outb (NVCMD_BEGIN_READ, dw_PCIBoardEepromAddress+AMCC_OP_REG_MCSR+3);
+
+         //Wait on busy
+         do
+           {
+             dw_eeprom_busy = inl (dw_PCIBoardEepromAddress + AMCC_OP_REG_MCSR);
+             dw_eeprom_busy=dw_eeprom_busy & EEPROM_BUSY;
+           }
+         while(dw_eeprom_busy== EEPROM_BUSY);
+
+         //Read data into the EEPROM
+         *pb_ReadByte = inb (dw_PCIBoardEepromAddress+AMCC_OP_REG_MCSR+2);
+
+         //Wait on busy
+         do
+           {
+             dw_eeprom_busy = inl (dw_PCIBoardEepromAddress + AMCC_OP_REG_MCSR);
+             dw_eeprom_busy=dw_eeprom_busy & EEPROM_BUSY;
+           }
+         while(dw_eeprom_busy== EEPROM_BUSY);
+
+         //Select the upper address part
+         if(i_Counter==0)
+           {   b_ReadLowByte=pb_ReadByte[0];
+           }else
+           {   b_ReadHighByte=pb_ReadByte[0];
+           }
+                
+         //Sleep
+         for (i=0; i < 10000; i++);
+   
+       }
+      w_ReadWord=(b_ReadLowByte|( ( (unsigned short) b_ReadHighByte) *256) );
+      
+      pw_DataRead[i_WordCounter]=w_ReadWord;
+
+      w_EepromStartAddress +=2; // to read the next word          
+
+    } // for (...) i_NbOfWordsToRead
+  return (0);
+}
+
+/*+----------------------------------------------------------------------------+*/
+/*| Function   Name   : VOID v_GetAPCI3200EepromCalibrationValue (VOID)        |*/
+/*+----------------------------------------------------------------------------+*/
+/*| Task              : Read calibration value from the APCI-3200 eeprom.      |*/
+/*+----------------------------------------------------------------------------+*/
+/*| Input Parameters  : -                                                      |*/
+/*+----------------------------------------------------------------------------+*/
+/*| Output Parameters : -                                                      |*/
+/*+----------------------------------------------------------------------------+*/
+/*| Return Value      : -                                                      |*/
+/*+----------------------------------------------------------------------------+*/
+
+VOID v_GetAPCI3200EepromCalibrationValue (DWORD dw_PCIBoardEepromAddress,
+                                         str_BoardInfos *BoardInformations)
+{
+  WORD w_AnalogInputMainHeaderAddress;
+  WORD w_AnalogInputComponentAddress;
+  WORD w_NumberOfModuls = 0;
+  WORD w_CurrentSources [2];
+  WORD w_ModulCounter = 0;
+  WORD w_FirstHeaderSize = 0;
+  WORD w_NumberOfInputs = 0;
+  WORD w_CJCFlag = 0;
+  WORD w_NumberOfGainValue = 0;
+  WORD w_SingleHeaderAddress = 0;
+  WORD w_SingleHeaderSize = 0;
+  WORD w_Input = 0;
+  WORD w_GainFactorAddress = 0;
+  WORD w_GainFactorValue [2];
+  WORD w_GainIndex = 0;
+  WORD w_GainValue = 0;
+   
+  /*****************************************/
+  /** Get the Analog input header address **/
+  /*****************************************/ 
+  i_AddiHeaderRW_ReadEeprom (1, //i_NbOfWordsToRead
+                            dw_PCIBoardEepromAddress,
+                            0x116,//w_EepromStartAddress: Analog input header address
+                            &w_AnalogInputMainHeaderAddress);
+        
+  /*******************************************/
+  /** Compute the real analog input address **/
+  /*******************************************/
+  w_AnalogInputMainHeaderAddress = w_AnalogInputMainHeaderAddress + 0x100; 
+
+  /******************************/
+  /** Get the number of moduls **/
+  /******************************/  
+  i_AddiHeaderRW_ReadEeprom (1, //i_NbOfWordsToRead
+                            dw_PCIBoardEepromAddress,
+                            w_AnalogInputMainHeaderAddress + 0x02,//w_EepromStartAddress: Number of conponment
+                            &w_NumberOfModuls);
+
+  for (w_ModulCounter = 0; w_ModulCounter < w_NumberOfModuls; w_ModulCounter ++)
+    {
+      /***********************************/
+      /** Compute the component address **/
+      /***********************************/
+      w_AnalogInputComponentAddress = w_AnalogInputMainHeaderAddress + (w_FirstHeaderSize * w_ModulCounter) + 0x04;          
+          
+      /****************************/
+      /** Read first header size **/
+      /****************************/
+      i_AddiHeaderRW_ReadEeprom (1, //i_NbOfWordsToRead
+                                dw_PCIBoardEepromAddress,
+                                w_AnalogInputComponentAddress, // Address of the first header  
+                                &w_FirstHeaderSize);
+           
+      w_FirstHeaderSize = w_FirstHeaderSize >> 4;
+
+      /***************************/
+      /** Read number of inputs **/
+      /***************************/
+      i_AddiHeaderRW_ReadEeprom (1, //i_NbOfWordsToRead
+                                dw_PCIBoardEepromAddress,
+                                w_AnalogInputComponentAddress + 0x06, // Number of inputs for the first modul  
+                                &w_NumberOfInputs);
+
+      w_NumberOfInputs = w_NumberOfInputs >> 4;
+
+      /***********************/
+      /** Read the CJC flag **/
+      /***********************/
+      i_AddiHeaderRW_ReadEeprom (1, //i_NbOfWordsToRead
+                                dw_PCIBoardEepromAddress,
+                                w_AnalogInputComponentAddress + 0x08, // CJC flag
+                                &w_CJCFlag);
+          
+      w_CJCFlag = (w_CJCFlag >> 3) & 0x1; // Get only the CJC flag
+
+      /*******************************/
+      /** Read number of gain value **/
+      /*******************************/
+      i_AddiHeaderRW_ReadEeprom (1, //i_NbOfWordsToRead
+                                dw_PCIBoardEepromAddress,
+                                w_AnalogInputComponentAddress + 0x44, // Number of gain value
+                                &w_NumberOfGainValue);
+
+      w_NumberOfGainValue = w_NumberOfGainValue & 0xFF;
+
+      /***********************************/
+      /** Compute single header address **/
+      /***********************************/
+      w_SingleHeaderAddress = w_AnalogInputComponentAddress + 0x46 + (((w_NumberOfGainValue / 16) + 1) * 2) + (6 * w_NumberOfGainValue) + (4 * (((w_NumberOfGainValue / 16) + 1) * 2));
+
+      /********************************************/
+      /** Read current sources value for input 1 **/
+      /********************************************/
+      i_AddiHeaderRW_ReadEeprom (1, //i_NbOfWordsToRead
+                                dw_PCIBoardEepromAddress,
+                                w_SingleHeaderAddress ,//w_EepromStartAddress: Single header address
+                                &w_SingleHeaderSize);
+
+      w_SingleHeaderSize = w_SingleHeaderSize >> 4;
+
+      /*************************************/
+      /** Read gain factor for the module **/
+      /*************************************/
+      w_GainFactorAddress = w_AnalogInputComponentAddress;
+      for (w_GainIndex = 0; w_GainIndex < w_NumberOfGainValue; w_GainIndex++)
+       {
+         /************************************/
+         /** Read gain value for the module **/ 
+         /************************************/
+         i_AddiHeaderRW_ReadEeprom (1, //i_NbOfWordsToRead
+                                    dw_PCIBoardEepromAddress,
+                                    w_AnalogInputComponentAddress + 70 + (2 * (1 + ( w_NumberOfGainValue / 16))) + (0x02 * w_GainIndex), // Gain value
+                                    &w_GainValue);
+
+         BoardInformations->s_Module [w_ModulCounter].w_GainValue [w_GainIndex] = w_GainValue; 
+              
+#             ifdef PRINT_INFO 
+         printk ("\n Gain value = %d", BoardInformations->s_Module [w_ModulCounter].w_GainValue [w_GainIndex]);
+#             endif
+
+         /*************************************/
+         /** Read gain factor for the module **/
+         /*************************************/
+         i_AddiHeaderRW_ReadEeprom (2, //i_NbOfWordsToRead
+                                    dw_PCIBoardEepromAddress,
+                                    w_AnalogInputComponentAddress + 70 + ((2 * w_NumberOfGainValue) + (2 * (1 + ( w_NumberOfGainValue / 16)))) + (0x04 * w_GainIndex), // Gain factor
+                                    w_GainFactorValue);
+                       
+         BoardInformations->s_Module [w_ModulCounter].ul_GainFactor [w_GainIndex] = (w_GainFactorValue [1] << 16) + w_GainFactorValue [0]; 
+
+#             ifdef PRINT_INFO               
+         printk ("\n w_GainFactorValue [%d] = %lu", w_GainIndex, BoardInformations->s_Module [w_ModulCounter].ul_GainFactor [w_GainIndex]);                                   
+#             endif
+       }
+
+      /***************************************************************/
+      /** Read current source value for each channels of the module **/
+      /***************************************************************/
+      for (w_Input = 0; w_Input < w_NumberOfInputs; w_Input++)
+       {
+         /********************************************/
+         /** Read current sources value for input 1 **/
+         /********************************************/
+         i_AddiHeaderRW_ReadEeprom (2, //i_NbOfWordsToRead
+                                    dw_PCIBoardEepromAddress,
+                                    (w_Input * w_SingleHeaderSize) + w_SingleHeaderAddress + 0x0C,
+                                    w_CurrentSources);
+
+              
+         /************************************/
+         /** Save the current sources value **/
+         /************************************/
+         BoardInformations->s_Module [w_ModulCounter].ul_CurrentSource [w_Input] = (w_CurrentSources [0] + ((w_CurrentSources [1] & 0xFFF) << 16));   
+
+#             ifdef PRINT_INFO 
+         printk ("\n Current sources [%d] = %lu", w_Input, BoardInformations->s_Module [w_ModulCounter].ul_CurrentSource [w_Input]);                      
+#             endif 
+       }
+            
+      /***************************************/
+      /** Read the CJC current source value **/
+      /***************************************/
+      i_AddiHeaderRW_ReadEeprom (2, //i_NbOfWordsToRead
+                                dw_PCIBoardEepromAddress,
+                                (w_Input * w_SingleHeaderSize) + w_SingleHeaderAddress + 0x0C,
+                                w_CurrentSources);
+          
+      /************************************/
+      /** Save the current sources value **/
+      /************************************/
+      BoardInformations->s_Module [w_ModulCounter].ul_CurrentSourceCJC = (w_CurrentSources [0] + ((w_CurrentSources [1] & 0xFFF) << 16));             
+
+#          ifdef PRINT_INFO 
+      printk ("\n Current sources CJC = %lu", BoardInformations->s_Module [w_ModulCounter].ul_CurrentSourceCJC);                      
+#          endif
+    }
+}
+
+INT i_APCI3200_GetChannelCalibrationValue (comedi_device *dev, unsigned int ui_Channel_num, lsampl_t *CJCCurrentSource, 
+                                          lsampl_t *ChannelCurrentSource, 
+                                          lsampl_t *ChannelGainFactor) 
 { 
-   UINT ui_Temp=0;
-   UINT ui_NoOfChannel=0;
-   ui_NoOfChannel=CR_CHAN(insn->chanspec);
-   ui_Temp=data[0];
-   *data=inl(devpriv->i_IobaseReserved);
+  int i_DiffChannel = 0;
+  int i_Module = 0;
+#ifdef PRINT_INFO 
+  printk ("\n Channel = %u", ui_Channel_num);
+#endif
+
+  //Test if single or differential mode   
+  if (s_BoardInfos [dev->minor].i_ConnectionType == 1)
+    {       
+      //if diff
    
-   if  (ui_Temp==0)
-      {
+      if((ui_Channel_num >=0) && (ui_Channel_num <=1))
+       i_DiffChannel=ui_Channel_num, i_Module = 0; 
+      else
+       if((ui_Channel_num >=2) && (ui_Channel_num <=3))
+         i_DiffChannel=ui_Channel_num-2, i_Module = 1; 
+       else
+         if((ui_Channel_num >=4) && (ui_Channel_num <=5))
+           i_DiffChannel=ui_Channel_num-4, i_Module = 2; 
+         else
+           if((ui_Channel_num >=6) && (ui_Channel_num <=7))
+             i_DiffChannel=ui_Channel_num-6, i_Module = 3; 
+      
+    }
+  else
+    {      
+      // if single
+      if((ui_Channel_num == 0) || (ui_Channel_num == 1))
+       i_DiffChannel=0, i_Module = 0; 
+      else
+       if((ui_Channel_num == 2) || (ui_Channel_num == 3))
+         i_DiffChannel=1, i_Module = 0; 
+       else      
+         if((ui_Channel_num == 4) || (ui_Channel_num == 5))
+           i_DiffChannel=0, i_Module = 1; 
+         else
+           if((ui_Channel_num == 6) || (ui_Channel_num == 7))
+             i_DiffChannel=1, i_Module = 1;       
+           else      
+             if((ui_Channel_num == 8) || (ui_Channel_num == 9))
+               i_DiffChannel=0, i_Module = 2; 
+             else
+               if((ui_Channel_num == 10) || (ui_Channel_num == 11))
+                 i_DiffChannel=1, i_Module = 2;   
+               else      
+                 if((ui_Channel_num == 12) || (ui_Channel_num == 13))
+                   i_DiffChannel=0, i_Module = 3; 
+                 else
+                   if((ui_Channel_num == 14) || (ui_Channel_num == 15))
+                     i_DiffChannel=1, i_Module = 3;                  
+    }  
+                                
+  //Test if thermocouple or RTD mode
+  *CJCCurrentSource = s_BoardInfos [dev->minor].s_Module[i_Module].ul_CurrentSourceCJC;
+#ifdef PRINT_INFO 
+  printk ("\n CJCCurrentSource = %lu", *CJCCurrentSource);
+#endif
+      
+  *ChannelCurrentSource = s_BoardInfos [dev->minor].s_Module[i_Module].ul_CurrentSource [i_DiffChannel];
+#ifdef PRINT_INFO       
+  printk ("\n ChannelCurrentSource = %lu", *ChannelCurrentSource);
+#endif  
+  //      }    
+  //   }
+                
+  //Channle gain factor 
+  *ChannelGainFactor = s_BoardInfos [dev->minor].s_Module[i_Module].ul_GainFactor [s_BoardInfos [dev->minor].i_ADDIDATAGain];    
+#ifdef PRINT_INFO    
+  printk ("\n ChannelGainFactor = %lu", *ChannelGainFactor);  
+#endif   
+  //End JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values   
+   
+  return (0);      
+}
+
+//End JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values
+
+
+
+
+
+
+/*
+  +----------------------------------------------------------------------------+
+  | Function   Name   : int i_APCI3200_ReadDigitalInput                       |
+  |                      (comedi_device *dev,comedi_subdevice *s,               | 
+  |                      comedi_insn *insn,lsampl_t *data)                     |
+  +----------------------------------------------------------------------------+
+  | Task              : Read  value  of the selected channel or port           |
+  +----------------------------------------------------------------------------+
+  | Input Parameters  : comedi_device *dev      : Driver handle                |
+  |                     UINT ui_NoOfChannels    : No Of Channels To read  for Port   
+  Channel Numberfor single channel
+  |                     UINT data[0]            : 0: Read single channel
+  1: Read port value   
+  data[1]              Port number       
+  +----------------------------------------------------------------------------+
+  | Output Parameters :        --      data[0] :Read status value
+  +----------------------------------------------------------------------------+
+  | Return Value      : TRUE  : No error occur                                 |
+  |                        : FALSE : Error occur. Return the error          |
+  |                                                                             |
+  +----------------------------------------------------------------------------+
+*/
+
+INT i_APCI3200_ReadDigitalInput(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data) 
+{ 
+  UINT ui_Temp=0;
+  UINT ui_NoOfChannel=0;
+  ui_NoOfChannel=CR_CHAN(insn->chanspec);
+  ui_Temp=data[0];
+  *data=inl(devpriv->i_IobaseReserved);
+    
+  if  (ui_Temp==0)
+    {
       *data=(*data >> ui_NoOfChannel)&0x1; 
-      } //if  (ui_Temp==0)
-   else
-      {
+    } //if  (ui_Temp==0)
+  else
+    {
       if  (ui_Temp==1)
-         {
-         if(data[1] < 0 || data[1] >1)
-           {
-           printk("\nThe port number is in error\n");
-           return -EINVAL;
-           }//if(data[1] < 0 || data[1] >1)
-         switch( ui_NoOfChannel)
-          {
-
-          case 2:
-                 *data=(*data >>(2*data[1]))&0x3;  
-                 break;
-           case 3:
-                 *data=(*data & 15 ); 
-                  break;
-           default:
-                  comedi_error(dev," chan spec wrong");
-                  return -EINVAL;   // "sorry channel spec wrong "  
+       {
+         if(data[1] < 0 || data[1] >1)
+           {
+             printk("\nThe port number is in error\n");
+             return -EINVAL;
+           }//if(data[1] < 0 || data[1] >1)
+         switch( ui_NoOfChannel)
+           {
+
+           case 2:
+             *data=(*data >>(2*data[1]))&0x3;  
+             break;
+           case 3:
+             *data=(*data & 15 ); 
+             break;
+           default:
+             comedi_error(dev," chan spec wrong");
+             return -EINVAL;   // "sorry channel spec wrong "  
                  
-          }//switch(ui_NoOfChannels)    
-         }//if  (ui_Temp==1)
-  else
-     {
-     printk("\nSpecified channel not supported \n");
-     }//elseif  (ui_Temp==1)
-  }  
-return insn->n;
+           }//switch(ui_NoOfChannels)    
+       }//if  (ui_Temp==1)
+      else
+       {
+         printk("\nSpecified channel not supported \n");
+       }//elseif  (ui_Temp==1)
+    }  
+  return insn->n;
 }
 
 /*
-+----------------------------------------------------------------------------+
-| Function   Name   : int i_APCI3200_ConfigDigitalOutput                     |
-|                        (comedi_device *dev,comedi_subdevice *s,                               | 
-|                      comedi_insn *insn,lsampl_t *data)                     |
-+----------------------------------------------------------------------------+
-| Task              : Configures The Digital Output Subdevice.               |
-+----------------------------------------------------------------------------+
-| Input Parameters  : comedi_device *dev : Driver handle                     |
-|                        data[0]  :1  Memory enable
-                                0  Memory Disable                                                                                                               
-+----------------------------------------------------------------------------+
-| Output Parameters :  --                                                                                                       |
-+----------------------------------------------------------------------------+
-| Return Value      : TRUE  : No error occur                                 |
-|                          : FALSE : Error occur. Return the error                      |
-|                                                                                                                                       |
-+----------------------------------------------------------------------------+
+  +----------------------------------------------------------------------------+
+  | Function   Name   : int i_APCI3200_ConfigDigitalOutput                     |
+  |                      (comedi_device *dev,comedi_subdevice *s,                               | 
+  |                      comedi_insn *insn,lsampl_t *data)                     |
+  +----------------------------------------------------------------------------+
+  | Task              : Configures The Digital Output Subdevice.               |
+  +----------------------------------------------------------------------------+
+  | Input Parameters  : comedi_device *dev : Driver handle                     |
+  |                      data[0]  :1  Memory enable
+  0  Memory Disable                                                                                                             
+  +----------------------------------------------------------------------------+
+  | Output Parameters :        --                                                                                                       |
+  +----------------------------------------------------------------------------+
+  | Return Value      : TRUE  : No error occur                                 |
+  |                        : FALSE : Error occur. Return the error                      |
+  |                                                                                                                                     |
+  +----------------------------------------------------------------------------+
 */
 int i_APCI3200_ConfigDigitalOutput(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data)
 { 
 
-if  ( (data[0]!=0) && (data[0]!=1) ) 
-     {   
-     comedi_error(dev,"Not a valid Data !!! ,Data should be 1 or 0\n");  
-     return -EINVAL;
-     }//if  ( (data[0]!=0) && (data[0]!=1) ) 
+  if  ( (data[0]!=0) && (data[0]!=1) ) 
+    {   
+      comedi_error(dev,"Not a valid Data !!! ,Data should be 1 or 0\n");  
+      return -EINVAL;
+    }//if  ( (data[0]!=0) && (data[0]!=1) ) 
   if  (data[0])
-     {
-     devpriv->b_OutputMemoryStatus = ADDIDATA_ENABLE ; 
-     }// if  (data[0])
+    {
+      devpriv->b_OutputMemoryStatus = ADDIDATA_ENABLE ; 
+    }// if  (data[0])
   else
-     {
-     devpriv->b_OutputMemoryStatus = ADDIDATA_DISABLE;
-     }//else if  (data[0])
-return insn->n;
+    {
+      devpriv->b_OutputMemoryStatus = ADDIDATA_DISABLE;
+    }//else if  (data[0])
+  return insn->n;
 }
 
 
 
 /*
-+----------------------------------------------------------------------------+
-| Function   Name   : int i_APCI3200_WriteDigitalOutput                      |
-|                        (comedi_device *dev,comedi_subdevice *s,                               | 
-|                      comedi_insn *insn,lsampl_t *data)                     |
-+----------------------------------------------------------------------------+
-| Task              : writes To the digital Output Subdevice                 |
-+----------------------------------------------------------------------------+
-| Input Parameters  : comedi_device *dev      : Driver handle                |
-|                     comedi_subdevice *s     : Subdevice Pointer            |  
-|                     comedi_insn *insn       : Insn Structure Pointer       |  
-|                     lsampl_t *data          : Data Pointer contains        |
-|                                          configuration parameters as below |
-|                     data[0]             :Value to output
-                      data[1]             : 0 o/p single channel
-                                            1 o/p port
-                      data[2]             : port no
-                      data[3]             :0 set the digital o/p on
-                                           1 set the digital o/p off   
-+----------------------------------------------------------------------------+
-| Output Parameters :  --                                                                                                       |
-+----------------------------------------------------------------------------+
-| Return Value      : TRUE  : No error occur                                 |
-|                          : FALSE : Error occur. Return the error              |
-|                                                                               |
-+----------------------------------------------------------------------------+
+  +----------------------------------------------------------------------------+
+  | Function   Name   : int i_APCI3200_WriteDigitalOutput                      |
+  |                      (comedi_device *dev,comedi_subdevice *s,                               | 
+  |                      comedi_insn *insn,lsampl_t *data)                     |
+  +----------------------------------------------------------------------------+
+  | Task              : writes To the digital Output Subdevice                 |
+  +----------------------------------------------------------------------------+
+  | Input Parameters  : comedi_device *dev      : Driver handle                |
+  |                     comedi_subdevice *s     : Subdevice Pointer            |  
+  |                     comedi_insn *insn       : Insn Structure Pointer       |  
+  |                     lsampl_t *data          : Data Pointer contains        |
+  |                                          configuration parameters as below |
+  |                     data[0]             :Value to output
+  data[1]             : 0 o/p single channel
+  1 o/p port
+  data[2]             : port no
+  data[3]             :0 set the digital o/p on
+  1 set the digital o/p off    
+  +----------------------------------------------------------------------------+
+  | Output Parameters :        --                                                                                                       |
+  +----------------------------------------------------------------------------+
+  | Return Value      : TRUE  : No error occur                                 |
+  |                        : FALSE : Error occur. Return the error              |
+  |                                                                             |
+  +----------------------------------------------------------------------------+
 */
 INT i_APCI3200_WriteDigitalOutput(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data) 
 {
-UINT ui_Temp=0,ui_Temp1=0;
-UINT ui_NoOfChannel = CR_CHAN(insn->chanspec); // get the channel
- if(devpriv->b_OutputMemoryStatus )
-   {
-    ui_Temp=inl(devpriv->i_IobaseAddon);
+  UINT ui_Temp=0,ui_Temp1=0;
+  UINT ui_NoOfChannel = CR_CHAN(insn->chanspec); // get the channel
 if(devpriv->b_OutputMemoryStatus )
+    {
+      ui_Temp=inl(devpriv->i_IobaseAddon);
  
-   }//if(devpriv->b_OutputMemoryStatus )
- else
-   {
-   ui_Temp=0;
     }//if(devpriv->b_OutputMemoryStatus )
-if(data[3]==0)
-  { 
-  if(data[1]==0)
-    {
-     data[0]=(data[0] << ui_NoOfChannel)|ui_Temp;
-     outl(data[0],devpriv->i_IobaseAddon);  
-    }//if(data[1]==0) 
   else
     {
-    if(data[1]==1)
-       { 
-       switch( ui_NoOfChannel)
-        {
-
-        case 2:data[0]=(data[0] << (2 * data[2]))|ui_Temp; 
-               break;
-         case 3:data[0]=(data[0]|ui_Temp);
-               break;
-         }//switch(ui_NoOfChannels)
+      ui_Temp=0;
+    }//if(devpriv->b_OutputMemoryStatus )
+  if(data[3]==0)
+    { 
+      if(data[1]==0)
+       {
+         data[0]=(data[0] << ui_NoOfChannel)|ui_Temp;
+         outl(data[0],devpriv->i_IobaseAddon);  
+       }//if(data[1]==0) 
+      else
+       {
+         if(data[1]==1)
+           { 
+             switch( ui_NoOfChannel)
+               {
+
+               case 2:data[0]=(data[0] << (2 * data[2]))|ui_Temp; 
+                 break;
+               case 3:data[0]=(data[0]|ui_Temp);
+                 break;
+               }//switch(ui_NoOfChannels)
    
-     outl(data[0],devpriv->i_IobaseAddon);
-     }// if(data[1]==1)
-   else
-     {
-     printk("\nSpecified channel not supported\n");
-     }//else if(data[1]==1)
-   }//elseif(data[1]==0)
- }//if(data[3]==0)
-else
-   {
-    if(data[3]==1)
-       {
-        if(data[1]==0)
-          {
-          data[0]=~data[0]&0x1;
-          ui_Temp1=1;
-          ui_Temp1=ui_Temp1<<ui_NoOfChannel;
-          ui_Temp=ui_Temp|ui_Temp1;  
-          data[0]=(data[0] << ui_NoOfChannel)^0xf;
-          data[0]=data[0]& ui_Temp; 
-          outl(data[0],devpriv->i_IobaseAddon);  
-          }//if(data[1]==0) 
-        else
-          {
-          if(data[1]==1)
-             { 
-             switch( ui_NoOfChannel)
-              {
-
-              case 2: data[0]=~data[0]&0x3; 
-                       ui_Temp1=3;
-                       ui_Temp1=ui_Temp1<<2 * data[2];
-                       ui_Temp=ui_Temp|ui_Temp1;   
-                       data[0]=((data[0] << (2 * data[2]))^0xf)& ui_Temp; 
-
-                      break;
-              case 3:
-                          break;
-
-               default:
+             outl(data[0],devpriv->i_IobaseAddon);
+           }// if(data[1]==1)
+         else
+           {
+             printk("\nSpecified channel not supported\n");
+           }//else if(data[1]==1)
+       }//elseif(data[1]==0)
   }//if(data[3]==0)
+  else
+    {
+      if(data[3]==1)
+       {
+         if(data[1]==0)
+           {
+             data[0]=~data[0]&0x1;
+             ui_Temp1=1;
+             ui_Temp1=ui_Temp1<<ui_NoOfChannel;
+             ui_Temp=ui_Temp|ui_Temp1;  
+             data[0]=(data[0] << ui_NoOfChannel)^0xf;
+             data[0]=data[0]& ui_Temp; 
+             outl(data[0],devpriv->i_IobaseAddon);  
+           }//if(data[1]==0) 
+         else
+           {
+             if(data[1]==1)
+               
+                 switch( ui_NoOfChannel)
+                   {
+
+                   case 2: data[0]=~data[0]&0x3; 
+                     ui_Temp1=3;
+                     ui_Temp1=ui_Temp1<<2 * data[2];
+                     ui_Temp=ui_Temp|ui_Temp1;   
+                     data[0]=((data[0] << (2 * data[2]))^0xf)& ui_Temp; 
+
+                     break;
+                   case 3:
+                     break;
+
+                   default:
                      comedi_error(dev," chan spec wrong");
                      return -EINVAL;   // "sorry channel spec wrong "  
- }//switch(ui_NoOfChannels)
                  }//switch(ui_NoOfChannels)
    
-            outl(data[0],devpriv->i_IobaseAddon);
-            }// if(data[1]==1)
-         else
-           {
-            printk("\nSpecified channel not supported\n");
-           }//else if(data[1]==1)
-         }//elseif(data[1]==0)
-      }//if(data[3]==1);
-   else
-      {
-       printk("\nSpecified functionality does not exist\n");
-       return -EINVAL;
-      }//if else data[3]==1)
-   }//if else data[3]==0) 
-return insn->n;
+                 outl(data[0],devpriv->i_IobaseAddon);
+               }// if(data[1]==1)
+             else
+               {
+                 printk("\nSpecified channel not supported\n");
+               }//else if(data[1]==1)
+           }//elseif(data[1]==0)
+       }//if(data[3]==1);
+      else
+       {
+         printk("\nSpecified functionality does not exist\n");
+         return -EINVAL;
+       }//if else data[3]==1)
+    }//if else data[3]==0) 
+  return insn->n;
 }
 
 /*
-+----------------------------------------------------------------------------+
-| Function   Name   : int i_APCI3200_ReadDigitalOutput                       |
-|                        (comedi_device *dev,comedi_subdevice *s,               | 
-|                      comedi_insn *insn,lsampl_t *data)                     |
-+----------------------------------------------------------------------------+
-| Task              : Read  value  of the selected channel or port           |
-+----------------------------------------------------------------------------+
-| Input Parameters  : comedi_device *dev      : Driver handle                |
-|                     UINT ui_NoOfChannels    : No Of Channels To read       |
-|                     UINT *data              : Data Pointer to read status  |
-                      data[0]                 :0 read single channel
-                                               1 read port value
-                      data[1]                  port no
+  +----------------------------------------------------------------------------+
+  | Function   Name   : int i_APCI3200_ReadDigitalOutput                       |
+  |                      (comedi_device *dev,comedi_subdevice *s,               | 
+  |                      comedi_insn *insn,lsampl_t *data)                     |
+  +----------------------------------------------------------------------------+
+  | Task              : Read  value  of the selected channel or port           |
+  +----------------------------------------------------------------------------+
+  | Input Parameters  : comedi_device *dev      : Driver handle                |
+  |                     UINT ui_NoOfChannels    : No Of Channels To read       |
+  |                     UINT *data              : Data Pointer to read status  |
+  data[0]                 :0 read single channel
+  1 read port value
+  data[1]                  port no
                      
-+----------------------------------------------------------------------------+
-| Output Parameters :  --                                                                                                       |
-+----------------------------------------------------------------------------+
-| Return Value      : TRUE  : No error occur                                 |
-|                          : FALSE : Error occur. Return the error          |
-|                                                                               |
-+----------------------------------------------------------------------------+
+  +----------------------------------------------------------------------------+
+  | Output Parameters :        --                                                                                                       |
+  +----------------------------------------------------------------------------+
+  | Return Value      : TRUE  : No error occur                                 |
+  |                        : FALSE : Error occur. Return the error          |
+  |                                                                             |
+  +----------------------------------------------------------------------------+
 */
 INT i_APCI3200_ReadDigitalOutput(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data) 
 {
@@ -307,1669 +767,2132 @@ INT i_APCI3200_ReadDigitalOutput(comedi_device *dev,comedi_subdevice *s,comedi_i
   ui_NoOfChannel=CR_CHAN(insn->chanspec);
   ui_Temp=data[0];
   *data=inl(devpriv->i_IobaseAddon);
-   if  (ui_Temp==0)
-      {
+  if  (ui_Temp==0)
+    {
       *data=(*data >> ui_NoOfChannel)&0x1; 
-      } // if  (ui_Temp==0)
-   else
-      {
+    } // if  (ui_Temp==0)
+  else
+    {
       if  (ui_Temp==1)
-         {
-         if(data[1] <0 ||data[1] >1)
+       {
+         if(data[1] <0 ||data[1] >1)
             {
-             printk("\nThe port selection is in error\n");
-             return -EINVAL;
+             printk("\nThe port selection is in error\n");
+             return -EINVAL;
             }//if(data[1] <0 ||data[1] >1)   
-         switch (ui_NoOfChannel)
-          {
-           case 2: 
-                    *data=(*data >>(2*data[1]))&3; 
-                    break;
+         switch (ui_NoOfChannel)
+           {
+           case 2: 
+             *data=(*data >>(2*data[1]))&3; 
+             break;
 
-           case 3:break; 
+           case 3:break; 
                     
 
-           default:
-                   comedi_error(dev," chan spec wrong");
-                   return -EINVAL;   // "sorry channel spec wrong "  
-                    break;
-           } // switch(ui_NoOfChannels)    
+           default:
+             comedi_error(dev," chan spec wrong");
+             return -EINVAL;   // "sorry channel spec wrong "  
+             break;
+           } // switch(ui_NoOfChannels)    
         } // if  (ui_Temp==1)
-     else
+      else
         {
-        printk("\nSpecified channel not supported \n");
+         printk("\nSpecified channel not supported \n");
         } // else if (ui_Temp==1)
-     } // else if  (ui_Temp==0)
-   return insn->n;
+    } // else if  (ui_Temp==0)
+  return insn->n;
 }
 
 /*
- +----------------------------------------------------------------------------+
-| Function   Name   : INT i_APCI3200_ConfigAnalogInput                       |
-|                        (comedi_device *dev,comedi_subdevice *s,               | 
-|                      comedi_insn *insn,lsampl_t *data)                     |
-+----------------------------------------------------------------------------+
-| Task              : Configures The Analog Input Subdevice                  |
-+----------------------------------------------------------------------------+
-| Input Parameters  : comedi_device *dev      : Driver handle                |
-|                     comedi_subdevice *s     : Subdevice Pointer            |  
-|                     comedi_insn *insn       : Insn Structure Pointer       |  
-|                     lsampl_t *data          : Data Pointer contains        |
-|                                          configuration parameters as below |
-|                                                                            | 
-|                                      data[0]            
-|                                               0:Normal AI                  |
-|                                               1:RTD                        |  
-|                                               2:THERMOCOUPLE               |
-|                                  data[1]            : Gain To Use                 |
-|                                                                            |
-|                           data[2]            : Polarity                              
-|                                                0:Bipolar                   |         
-|                                                1:Unipolar                  |         
-|                                                                                                                               |      
-|                           data[3]            : Offset Range                          
-|                                                                            |         
-|                           data[4]            : Coupling                            
-|                                                0:DC Coupling               |
-|                                                1:AC Coupling               |
-|                                                                            |
-|                           data[5]            :Differential/Single                   
-|                                                0:Single                    |
-|                                                1:Differential              |
-|                                                                            |
-|                           data[6]            :TimerReloadValue                     
-|                                                                            |
-|                           data[7]            :ConvertingTimeUnit                   
-|                                                                            |
-|                           data[8]             :0 Analog voltage measurement
-                                                 1 Resistance measurement
-                                                 2 Temperature measurement    
-|                           data[9]            :Interrupt                            
-|                                              0:Disable                         
-|                                              1:Enable    
-                           data[10]           :Type of Thermocouple                       
-|                          data[11]           : 0: single channel
-                                                Module Number                    
-|                                        
-|                          data[12]                                    
-|                                             0:Single Read                            
-|                                             1:Read more channel  
-                                              2:Single scan                            
-|                                             3:Continous Scan                
-                           data[13]          :Number of channels to read       
-|                          data[14]          :RTD connection type
-                                             :0:RTD not used
-                                              1:RTD 2 wire connection
-                                              2:RTD 3 wire connection
-                                              3:RTD 4 wire connection                                          
-|                                                                            | 
-|                                                                            | 
-|                                                                            |         
-+----------------------------------------------------------------------------+
-| Output Parameters :  --                                                                                                       |
-+----------------------------------------------------------------------------+
-| Return Value      : TRUE  : No error occur                                 |
-|                          : FALSE : Error occur. Return the error          |
-|                                                                               |
-+----------------------------------------------------------------------------+
 +----------------------------------------------------------------------------+
+  | Function   Name   : INT i_APCI3200_ConfigAnalogInput                       |
+  |                      (comedi_device *dev,comedi_subdevice *s,               | 
+  |                      comedi_insn *insn,lsampl_t *data)                     |
+  +----------------------------------------------------------------------------+
+  | Task              : Configures The Analog Input Subdevice                  |
+  +----------------------------------------------------------------------------+
+  | Input Parameters  : comedi_device *dev      : Driver handle                |
+  |                     comedi_subdevice *s     : Subdevice Pointer            |  
+  |                     comedi_insn *insn       : Insn Structure Pointer       |  
+  |                     lsampl_t *data          : Data Pointer contains        |
+  |                                          configuration parameters as below |
+  |                                                                            | 
+  |                                    data[0]            
+  |                                               0:Normal AI                  |
+  |                                               1:RTD                        |  
+  |                                               2:THERMOCOUPLE               |
+  |                                data[1]            : Gain To Use                 |
+  |                                                                            |
+  |                           data[2]            : Polarity                                    
+  |                                                0:Bipolar                   |       
+  |                                                1:Unipolar                  |       
+  |                                                                                                                             |      
+  |                           data[3]            : Offset Range                                
+  |                                                                            |       
+  |                           data[4]            : Coupling                            
+  |                                                0:DC Coupling               |
+  |                                                1:AC Coupling               |
+  |                                                                            |
+  |                           data[5]            :Differential/Single                   
+  |                                                0:Single                    |
+  |                                                1:Differential              |
+  |                                                                            |
+  |                           data[6]            :TimerReloadValue                     
+  |                                                                            |
+  |                           data[7]            :ConvertingTimeUnit                   
+  |                                                                            |
+  |                           data[8]             :0 Analog voltage measurement
+  1 Resistance measurement
+  2 Temperature measurement    
+  |                           data[9]            :Interrupt                            
+  |                                              0:Disable                         
+  |                                              1:Enable    
+  data[10]           :Type of Thermocouple                       
+  |                          data[11]           : 0: single channel
+  Module Number                    
+  |                                        
+  |                          data[12]                                  
+  |                                             0:Single Read                          
+  |                                             1:Read more channel  
+  2:Single scan                        
+  |                                             3:Continous Scan                
+  data[13]          :Number of channels to read        
+  |                          data[14]          :RTD connection type
+  :0:RTD not used
+  1:RTD 2 wire connection
+  2:RTD 3 wire connection
+  3:RTD 4 wire connection                                          
+  |                                                                            | 
+  |                                                                            | 
+  |                                                                            |       
+  +----------------------------------------------------------------------------+
+  | Output Parameters :        --                                                                                                       |
+  +----------------------------------------------------------------------------+
+  | Return Value      : TRUE  : No error occur                                 |
+  |                        : FALSE : Error occur. Return the error          |
+  |                                                                             |
+  +----------------------------------------------------------------------------+
 */
 INT i_APCI3200_ConfigAnalogInput(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data) 
 {
 
-   UINT  ul_Config = 0,ul_Temp=0 ; 
-   UINT ui_ChannelNo=0; 
-   UINT ui_Dummy=0;
-   INT i_err=0;                 
-   if(data[0]!=0 && data[0]!=1 && data[0]!=2)
-      {
-       printk("\nThe selection of acquisition type is in error\n");
-       i_err++;
-      }//if(data[0]!=0 && data[0]!=1 && data[0]!=2)
-   if(data[0]==1)
-      {
-       if(data[14]!=0 && data[14]!=1 && data[14]!=2 && data[14]!=4)
-         {
+  UINT  ul_Config = 0,ul_Temp=0 ; 
+  UINT ui_ChannelNo=0; 
+  UINT ui_Dummy=0;
+  INT i_err=0; 
+  
+  //Begin JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values
+  
+#ifdef PRINT_INFO   
+  INT i=0, i2=0;
+#endif  
+  //End JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values
+  
+  //BEGIN JK 06.07.04: Management of sevrals boards   
+  // Initialize the structure
+  if (s_BoardInfos [dev->minor].b_StructInitialized != 1)
+    {
+      s_BoardInfos [dev->minor].i_CJCAvailable=1; 
+      s_BoardInfos [dev->minor].i_CJCPolarity=0;
+      s_BoardInfos [dev->minor].i_CJCGain=2;//changed from 0 to 2 
+      s_BoardInfos [dev->minor].i_InterruptFlag=0;
+      s_BoardInfos [dev->minor].i_AutoCalibration=0;   //: auto calibration  
+      s_BoardInfos [dev->minor].i_ChannelCount=0;
+      s_BoardInfos [dev->minor].i_Sum=0;
+      s_BoardInfos [dev->minor].ui_Channel_num=0;
+      s_BoardInfos [dev->minor].i_Count=0;
+      s_BoardInfos [dev->minor].i_Initialised=0;      
+      s_BoardInfos [dev->minor].b_StructInitialized = 1;
+      
+      //Begin JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values 
+      s_BoardInfos [dev->minor].i_ConnectionType = 0;
+      //End JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values 
+      
+      //Begin JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values 
+      memset (s_BoardInfos [dev->minor].s_Module, 0, sizeof (s_BoardInfos [dev->minor].s_Module[MAX_MODULE]));
+      
+      v_GetAPCI3200EepromCalibrationValue (devpriv->i_IobaseAmcc, &s_BoardInfos [dev->minor]);       
+
+#ifdef PRINT_INFO 
+      for (i=0; i<MAX_MODULE; i++)
+       {
+         printk ("\n s_Module[%i].ul_CurrentSourceCJC = %lu",i, s_BoardInfos [dev->minor].s_Module[i].ul_CurrentSourceCJC);
+        
+         for (i2=0; i2<5; i2++)
+           {
+             printk ("\n s_Module[%i].ul_CurrentSource [%i] = %lu",i, i2, s_BoardInfos [dev->minor].s_Module[i].ul_CurrentSource [i2]);         
+           }
+        
+         for (i2=0; i2<8; i2++)
+           {
+             printk ("\n s_Module[%i].ul_GainFactor [%i] = %lu",i, i2, s_BoardInfos [dev->minor].s_Module[i].ul_GainFactor [i2]);       
+           }
+           
+         for (i2=0; i2<8; i2++)
+           {
+             printk ("\n s_Module[%i].w_GainValue [%i] = %u",i, i2, s_BoardInfos [dev->minor].s_Module[i].w_GainValue [i2]);       
+           }       
+       }
+#endif
+      //End JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values 
+    }  
+        
+  if(data[0]!=0 && data[0]!=1 && data[0]!=2)
+    {
+      printk("\nThe selection of acquisition type is in error\n");
+      i_err++;
+    }//if(data[0]!=0 && data[0]!=1 && data[0]!=2)
+  if(data[0]==1)
+    {
+      if(data[14]!=0 && data[14]!=1 && data[14]!=2 && data[14]!=4)
+       {
           printk("\n Error in selection of RTD connection type\n");
           i_err++; 
-         }//if(data[14]!=0 && data[14]!=1 && data[14]!=2 && data[14]!=4)
-       }//if(data[0]==1 )  
-    if(data[1]<0 || data[1]>7)
-      {
-        printk("\nThe selection of gain is in error\n");
-        i_err++;
-      } // if(data[1]<0 || data[1]>7)
-    if(data[2]!=0 &&  data[2]!=1)
-       {
-        printk("\nThe selection of polarity is in error\n"); 
-        i_err++;
-       }//if(data[2]!=0 &&  data[2]!=1)
-    if(data[3]!=0)
-      {
-       printk("\nThe selection of offset range  is in error\n"); 
-       i_err++;
-      }// if(data[3]!=0)
-     if(data[4]!=0 &&  data[4]!=1)
-       {
-        printk("\nThe selection of coupling is in error\n"); 
-        i_err++;
-       }//if(data[4]!=0 &&  data[4]!=1)
-      if(data[5]!=0 &&  data[5]!=1)
-       {
-        printk("\nThe selection of single/differential mode is in error\n"); 
-        i_err++;
-       }//if(data[5]!=0 &&  data[5]!=1)
-     if(data[8]!=0 && data[8]!=1 && data[2]!=2)
-        {
-        printk("\nError in selection of functionality\n");
-        }//if(data[8]!=0 && data[8]!=1 && data[2]!=2)     
-    if(data[12]==0 || data[12]==1)
-      {
+       }//if(data[14]!=0 && data[14]!=1 && data[14]!=2 && data[14]!=4)
+    }//if(data[0]==1 )  
+  if(data[1]<0 || data[1]>7)
+    {
+      printk("\nThe selection of gain is in error\n");
+      i_err++;
+    } // if(data[1]<0 || data[1]>7)
+  if(data[2]!=0 &&  data[2]!=1)
+    {
+      printk("\nThe selection of polarity is in error\n"); 
+      i_err++;
+    }//if(data[2]!=0 &&  data[2]!=1)
+  if(data[3]!=0)
+    {
+      printk("\nThe selection of offset range  is in error\n"); 
+      i_err++;
+    }// if(data[3]!=0)
+  if(data[4]!=0 &&  data[4]!=1)
+    {
+      printk("\nThe selection of coupling is in error\n"); 
+      i_err++;
+    }//if(data[4]!=0 &&  data[4]!=1)
+  if(data[5]!=0 &&  data[5]!=1)
+    {
+      printk("\nThe selection of single/differential mode is in error\n"); 
+      i_err++;
+    }//if(data[5]!=0 &&  data[5]!=1)
+  if(data[8]!=0 && data[8]!=1 && data[2]!=2)
+    {
+      printk("\nError in selection of functionality\n");
+    }//if(data[8]!=0 && data[8]!=1 && data[2]!=2)     
+  if(data[12]==0 || data[12]==1)
+    {
       if (data[6]!=20 && data[6]!=40 && data[6]!=80 && data[6]!=160 )
-         {
-         printk("\nThe selection of conversion time reload value is in error\n");
-         i_err++;
-         }// if (data[6]!=20 && data[6]!=40 && data[6]!=80 && data[6]!=160 )
+       {
+         printk("\nThe selection of conversion time reload value is in error\n");
+         i_err++;
+       }// if (data[6]!=20 && data[6]!=40 && data[6]!=80 && data[6]!=160 )
       if(data[7]!=2)
         {
-        printk("\nThe selection of conversion time unit  is in error\n");
-        i_err++;
+         printk("\nThe selection of conversion time unit  is in error\n");
+         i_err++;
         }// if(data[7]!=2)
-       }  
-      if(data[9]!=0 &&  data[9]!=1)
-       {
-        printk("\nThe selection of interrupt enable is in error\n"); 
-        i_err++;
-       }//if(data[9]!=0 &&  data[9]!=1)
-      if(data[11] < 0 || data[11] > 4)
-        {
-        printk("\nThe selection of module is in error\n"); 
-        i_err++;
-       }//if(data[11] <0 ||  data[11]>1)
-      if(data[12] < 0 || data[12] > 3)
-        {
-        printk("\nThe selection of singlechannel/scan selection is in error\n"); 
-        i_err++;
-        }//if(data[12] < 0 ||  data[12]> 3) 
-      if(data[13] <0 ||data[13] >16)
-        {
-        printk("\nThe selection of number of channels is in error\n"); 
-        i_err++;
-        }// if(data[13] <0 ||data[13] >15)
+    }  
+  if(data[9]!=0 &&  data[9]!=1)
+    {
+      printk("\nThe selection of interrupt enable is in error\n"); 
+      i_err++;
+    }//if(data[9]!=0 &&  data[9]!=1)
+  if(data[11] < 0 || data[11] > 4)
+    {
+      printk("\nThe selection of module is in error\n"); 
+      i_err++;
+    }//if(data[11] <0 ||  data[11]>1)
+  if(data[12] < 0 || data[12] > 3)
+    {
+      printk("\nThe selection of singlechannel/scan selection is in error\n"); 
+      i_err++;
+    }//if(data[12] < 0 ||  data[12]> 3) 
+  if(data[13] <0 ||data[13] >16)
+    {
+      printk("\nThe selection of number of channels is in error\n"); 
+      i_err++;
+    }// if(data[13] <0 ||data[13] >15)
    
-          
-   i_ChannelCount=data[13];
-   i_ScanType=data[12];
-  i_ADDIDATAPolarity = data[2];
-   i_ADDIDATAGain=data[1];
-   i_ADDIDATAConversionTime=data[6];
-   i_ADDIDATAConversionTimeUnit=data[7];
-   i_ADDIDATAType=data[0]; 
-   while(i_InterruptFlag==1)
-     {
+  
+  //BEGIN JK 06.07.04: Management of sevrals boards
+  /*          
+             i_ChannelCount=data[13];
+             i_ScanType=data[12];
+             i_ADDIDATAPolarity = data[2];
+             i_ADDIDATAGain=data[1];
+             i_ADDIDATAConversionTime=data[6];
+             i_ADDIDATAConversionTimeUnit=data[7];
+             i_ADDIDATAType=data[0]; 
+  */
+  
+  // Save acquisition configuration for the actual board
+  s_BoardInfos [dev->minor].i_ChannelCount=data[13];
+  s_BoardInfos [dev->minor].i_ScanType=data[12];
+  s_BoardInfos [dev->minor].i_ADDIDATAPolarity = data[2];
+  s_BoardInfos [dev->minor].i_ADDIDATAGain=data[1];
+  s_BoardInfos [dev->minor].i_ADDIDATAConversionTime=data[6];
+  s_BoardInfos [dev->minor].i_ADDIDATAConversionTimeUnit=data[7];
+  s_BoardInfos [dev->minor].i_ADDIDATAType=data[0]; 
+  //Begin JK 19.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68
+  s_BoardInfos [dev->minor].i_ConnectionType=data[5]; 
+  //End JK 19.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68
+  //END JK 06.07.04: Management of sevrals boards
+  
+  //Begin JK 19.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68
+  memset (s_BoardInfos [dev->minor].ui_ScanValueArray, 0, (7+12)*sizeof (lsampl_t)); // 7 is the maximal number of channels
+  //End JK 19.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68  
+    
+  //BEGIN JK 02.07.04 : This while can't be do, it block the process when using severals boards
+  //while(i_InterruptFlag==1)
+  while(s_BoardInfos [dev->minor].i_InterruptFlag==1)
+    {
+#ifndef MSXBOX
       udelay(1);
-     }
+#else
+      // In the case where the driver is compiled for the MSX-Box 
+      // we used a printk to have a little delay because udelay
+      // seems to be broken under the MSX-Box.
+      // This solution hat to be studied. 
+      printk("");
+#endif
+    }
+  //END JK 02.07.04 : This while can't be do, it block the process when using severals boards
     
-   ui_ChannelNo = CR_CHAN(insn->chanspec); // get the channel
-   i_ChannelNo=ui_ChannelNo; 
-   ui_Channel_num =ui_ChannelNo;
- if(data[5]==0)
-   {    
-   if(ui_ChannelNo<0 || ui_ChannelNo>15)
-      {
-      printk("\nThe Selection of the channel is in error\n");  
-      i_err++;
-      }// if(ui_ChannelNo<0 || ui_ChannelNo>15)
+  ui_ChannelNo = CR_CHAN(insn->chanspec); // get the channel
+  //BEGIN JK 06.07.04: Management of sevrals boards
+  //i_ChannelNo=ui_ChannelNo; 
+  //ui_Channel_num =ui_ChannelNo;
+  
+  s_BoardInfos [dev->minor].i_ChannelNo=ui_ChannelNo;  
+  s_BoardInfos [dev->minor].ui_Channel_num=ui_ChannelNo;    
+
+  //END JK 06.07.04: Management of sevrals boards
+
+  if(data[5]==0)
+    {    
+      if(ui_ChannelNo<0 || ui_ChannelNo>15)
+       {
+         printk("\nThe Selection of the channel is in error\n");  
+         i_err++;
+       }// if(ui_ChannelNo<0 || ui_ChannelNo>15)
     }//if(data[5]==0)
- else
-    {
-     if(data[14]==2)
-       {
-       if(ui_ChannelNo<0 || ui_ChannelNo>3) 
-         {
-         printk("\nThe Selection of the channel is in error\n");  
-         i_err++;
-         }// if(ui_ChannelNo<0 || ui_ChannelNo>3) 
-       }//if(data[14]==2)
-    else
-       {  
-       if(ui_ChannelNo<0 || ui_ChannelNo>7)
-          {
-          printk("\nThe Selection of the channel is in error\n");  
-          i_err++;
-          }// if(ui_ChannelNo<0 || ui_ChannelNo>7)
-       }//elseif(data[14]==2)
-     }//elseif(data[5]==0)
-   if(data[12]==0 || data[12]==1)
-      {
-       switch(data[5])
-          {
-           case 0:   
-              if(ui_ChannelNo >=0 && ui_ChannelNo <=3)
-                {
-                i_Offset=0;
-                }//if(ui_ChannelNo >=0 && ui_ChannelNo <=3) 
-              if(ui_ChannelNo >=4 && ui_ChannelNo <=7)
-                {
-                i_Offset=64;
-                }//if(ui_ChannelNo >=4 && ui_ChannelNo <=7) 
-              if(ui_ChannelNo >=8 && ui_ChannelNo <=11)
-                {
-                i_Offset=128;
-                }//if(ui_ChannelNo >=8 && ui_ChannelNo <=11) 
-              if(ui_ChannelNo >=12 && ui_ChannelNo <=15)
-                {
-                i_Offset=192;
-                }//if(ui_ChannelNo >=12 && ui_ChannelNo <=15)
-                break;
-          case 1:
-                if(data[14]==2)
-                  {
-                   if(ui_ChannelNo ==0 )
-                   {
-                   i_Offset=0;
-                   }//if(ui_ChannelNo ==0 )
-                 if(ui_ChannelNo ==1)
-                   { 
-                   i_Offset=64;
-                   }// if(ui_ChannelNo ==1)
-                 if(ui_ChannelNo ==2 )
-                   {
-                   i_Offset=128;
-                   }//if(ui_ChannelNo ==2 )
-                 if(ui_ChannelNo ==3)
-                   {
-                   i_Offset=192;
-                   }//if(ui_ChannelNo ==3) 
-                   i_ChannelNo=0;
-                   ui_ChannelNo=0;
-                   break;   
-                  }//if(data[14]==2)
-                if(ui_ChannelNo >=0 && ui_ChannelNo <=1)
-                   {
-                   i_Offset=0;
-                   }//if(ui_ChannelNo >=0 && ui_ChannelNo <=1) 
-                 if(ui_ChannelNo >=2 && ui_ChannelNo <=3)
-                   {
-                   i_ChannelNo=i_ChannelNo-2;
-                   ui_ChannelNo=ui_ChannelNo-2; 
-                   i_Offset=64;
-                   }//if(ui_ChannelNo >=2 && ui_ChannelNo <=3) 
-                 if(ui_ChannelNo >=4 && ui_ChannelNo <=5)
-                   {
-                   i_ChannelNo=i_ChannelNo-4;
-                   ui_ChannelNo=ui_ChannelNo-4; 
-                   i_Offset=128;
-                   }//if(ui_ChannelNo >=4 && ui_ChannelNo <=5) 
-                 if(ui_ChannelNo >=6 && ui_ChannelNo <=7)
-                   {
-                   i_ChannelNo=i_ChannelNo-6;
-                   ui_ChannelNo=ui_ChannelNo-6; 
-                   i_Offset=192;
-                   }//if(ui_ChannelNo >=6 && ui_ChannelNo <=7) 
-                 break;
+  else
+    {
+      if(data[14]==2)
+       {
+         if(ui_ChannelNo<0 || ui_ChannelNo>3) 
+           {
+             printk("\nThe Selection of the channel is in error\n");  
+             i_err++;
+           }// if(ui_ChannelNo<0 || ui_ChannelNo>3) 
+       }//if(data[14]==2)
+      else
+       {  
+         if(ui_ChannelNo<0 || ui_ChannelNo>7)
+           {
+             printk("\nThe Selection of the channel is in error\n");  
+             i_err++;
+           }// if(ui_ChannelNo<0 || ui_ChannelNo>7)
+       }//elseif(data[14]==2)
+    }//elseif(data[5]==0)
+  if(data[12]==0 || data[12]==1)
+    {
+      switch(data[5])
+       {
+       case 0:   
+         if(ui_ChannelNo >=0 && ui_ChannelNo <=3)
+           {
+             //BEGIN JK 06.07.04: Management of sevrals boards
+             //i_Offset=0;
+             s_BoardInfos [dev->minor].i_Offset=0;  
+              //END JK 06.07.04: Management of sevrals boards
+           }//if(ui_ChannelNo >=0 && ui_ChannelNo <=3) 
+         if(ui_ChannelNo >=4 && ui_ChannelNo <=7)
+           {
+             //BEGIN JK 06.07.04: Management of sevrals boards
+             //i_Offset=64;
+             s_BoardInfos [dev->minor].i_Offset=64;  
+              //END JK 06.07.04: Management of sevrals boards
+           }//if(ui_ChannelNo >=4 && ui_ChannelNo <=7) 
+         if(ui_ChannelNo >=8 && ui_ChannelNo <=11)
+           {
+             //BEGIN JK 06.07.04: Management of sevrals boards
+             //i_Offset=128;
+             s_BoardInfos [dev->minor].i_Offset=128;  
+              //END JK 06.07.04: Management of sevrals boards
+           }//if(ui_ChannelNo >=8 && ui_ChannelNo <=11) 
+         if(ui_ChannelNo >=12 && ui_ChannelNo <=15)
+           {
+             //BEGIN JK 06.07.04: Management of sevrals boards
+             //i_Offset=192;
+             s_BoardInfos [dev->minor].i_Offset=192;  
+              //END JK 06.07.04: Management of sevrals boards
+           }//if(ui_ChannelNo >=12 && ui_ChannelNo <=15)
+         break;
+       case 1:
+         if(data[14]==2)
+           {
+             if(ui_ChannelNo ==0 )
+               {
+                 //BEGIN JK 06.07.04: Management of sevrals boards
+                 //i_Offset=0;
+                 s_BoardInfos [dev->minor].i_Offset=0;  
+                 //END JK 06.07.04: Management of sevrals boards
+               }//if(ui_ChannelNo ==0 )
+             if(ui_ChannelNo ==1)
+               { 
+                 //BEGIN JK 06.07.04: Management of sevrals boards
+                 //i_Offset=0;
+                 s_BoardInfos [dev->minor].i_Offset=64;  
+                 //END JK 06.07.04: Management of sevrals boards
+               }// if(ui_ChannelNo ==1)
+             if(ui_ChannelNo ==2 )
+               {
+                 //BEGIN JK 06.07.04: Management of sevrals boards
+                 //i_Offset=128;
+                 s_BoardInfos [dev->minor].i_Offset=128;  
+                 //END JK 06.07.04: Management of sevrals boards
+               }//if(ui_ChannelNo ==2 )
+             if(ui_ChannelNo ==3)
+               {
+                 //BEGIN JK 06.07.04: Management of sevrals boards
+                 //i_Offset=192;
+                 s_BoardInfos [dev->minor].i_Offset=192;  
+                 //END JK 06.07.04: Management of sevrals boards
+               }//if(ui_ChannelNo ==3) 
+             
+             //BEGIN JK 06.07.04: Management of sevrals boards
+             //i_ChannelNo=0;
+             s_BoardInfos [dev->minor].i_ChannelNo=0;
+             //END JK 06.07.04: Management of sevrals boards
+             ui_ChannelNo=0;
+             break;   
+           }//if(data[14]==2)
+         if(ui_ChannelNo >=0 && ui_ChannelNo <=1)
+           {
+             //BEGIN JK 06.07.04: Management of sevrals boards
+             //i_Offset=0;
+             s_BoardInfos [dev->minor].i_Offset=0;  
+              //END JK 06.07.04: Management of sevrals boards
+           }//if(ui_ChannelNo >=0 && ui_ChannelNo <=1) 
+         if(ui_ChannelNo >=2 && ui_ChannelNo <=3)
+           {
+             //BEGIN JK 06.07.04: Management of sevrals boards
+             //i_ChannelNo=i_ChannelNo-2;
+             //i_Offset=64;
+             s_BoardInfos [dev->minor].i_ChannelNo=s_BoardInfos [dev->minor].i_ChannelNo-2;
+             s_BoardInfos [dev->minor].i_Offset=64;
+              //END JK 06.07.04: Management of sevrals boards        
+             ui_ChannelNo=ui_ChannelNo-2; 
+           }//if(ui_ChannelNo >=2 && ui_ChannelNo <=3) 
+         if(ui_ChannelNo >=4 && ui_ChannelNo <=5)
+           {
+             //BEGIN JK 06.07.04: Management of sevrals boards
+             //i_ChannelNo=i_ChannelNo-4;
+             //i_Offset=128;
+             s_BoardInfos [dev->minor].i_ChannelNo=s_BoardInfos [dev->minor].i_ChannelNo-4;
+             s_BoardInfos [dev->minor].i_Offset=128;
+              //END JK 06.07.04: Management of sevrals boards     
+             ui_ChannelNo=ui_ChannelNo-4; 
+           }//if(ui_ChannelNo >=4 && ui_ChannelNo <=5) 
+         if(ui_ChannelNo >=6 && ui_ChannelNo <=7)
+           {
+             //BEGIN JK 06.07.04: Management of sevrals boards
+             //i_ChannelNo=i_ChannelNo-6;
+             //i_Offset=192;
+             s_BoardInfos [dev->minor].i_ChannelNo=s_BoardInfos [dev->minor].i_ChannelNo-6;
+             s_BoardInfos [dev->minor].i_Offset=192;
+              //END JK 06.07.04: Management of sevrals boards   
+             ui_ChannelNo=ui_ChannelNo-6; 
+           }//if(ui_ChannelNo >=6 && ui_ChannelNo <=7) 
+         break;
        
         default: printk("\n This selection of polarity does not exist\n");
-                 i_err++;
+         i_err++;
         }//switch(data[2])         
-       }//if(data[12]==0 || data[12]==1)
-   else
-       {
-       switch(data[11])
-         {
-         case 1:i_Offset=0;
-                break;
-         case 2:i_Offset=64;
-                break;
-         case 3:i_Offset=128;
-                break;
-         case 4:i_Offset=192;
-                break;
-         default:
-                printk("\nError in module selection\n");
-                i_err++;
-         }// switch(data[11]) 
-       }// elseif(data[12]==0 || data[12]==1)       
-    if(i_err)
-      {
+    }//if(data[12]==0 || data[12]==1)
+  else
+    {
+      switch(data[11])
+       {
+       case 1:
+         //BEGIN JK 06.07.04: Management of sevrals boards
+         //i_Offset=0;
+         s_BoardInfos [dev->minor].i_Offset=0;  
+         //END JK 06.07.04: Management of sevrals boards
+         break;
+       case 2:
+         //BEGIN JK 06.07.04: Management of sevrals boards
+         //i_Offset=64;
+         s_BoardInfos [dev->minor].i_Offset=64;  
+         //END JK 06.07.04: Management of sevrals boards
+         break;
+       case 3:
+         //BEGIN JK 06.07.04: Management of sevrals boards
+         //i_Offset=128;
+         s_BoardInfos [dev->minor].i_Offset=128;  
+         //END JK 06.07.04: Management of sevrals boards
+         break;
+       case 4:
+         //BEGIN JK 06.07.04: Management of sevrals boards
+         //i_Offset=192;
+         s_BoardInfos [dev->minor].i_Offset=192;  
+         //END JK 06.07.04: Management of sevrals boards
+         break;
+       default:
+         printk("\nError in module selection\n");
+         i_err++;
+       }// switch(data[11]) 
+    }// elseif(data[12]==0 || data[12]==1)       
+  if(i_err)
+    {
       i_APCI3200_Reset(dev);
       return -EINVAL; 
-      }
-   if(i_ScanType!=1)
-      {
-      i_Count=0;
-      i_Sum=0;
-      }//if(i_ScanType!=1)
-    
-      
-  
-    ul_Config =  data[1] |(data[2] << 6) |(data[5]<< 7) |(data[3] << 8) |(data[4] << 9);
-                              
-                              
-                              
-              while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);                   
-              /*********************************/
-              /* Write the channel to configure*/
-              /*********************************/
-              outl(0 | ui_ChannelNo , devpriv->iobase+i_Offset + 0x4);
-            
-              while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); 
-              /**************************/                                                          
-              /* Reset the configuration */                                                           
-              /**************************/  
-               outl(0 , devpriv->iobase+i_Offset + 0x0);  
+    }
+  //if(i_ScanType!=1)
+  if(s_BoardInfos [dev->minor].i_ScanType!=1)
+    {
+      //BEGIN JK 06.07.04: Management of sevrals boards
+      //i_Count=0;
+      //i_Sum=0;
+      s_BoardInfos [dev->minor].i_Count=0;  
+      s_BoardInfos [dev->minor].i_Sum=0;  
+      //END JK 06.07.04: Management of sevrals boards
+    }//if(i_ScanType!=1)
             
-               while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
+  ul_Config =  data[1] |(data[2] << 6) |(data[5]<< 7) |(data[3] << 8) |(data[4] << 9);                                                            
+  //BEGIN JK 06.07.04: Management of sevrals boards                              
+  //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);                   
+  while (((inl(devpriv->iobase+s_BoardInfos [dev->minor].i_Offset+12)>>19) & 1) != 1);                   
+  //END JK 06.07.04: Management of sevrals boards
+  /*********************************/
+  /* Write the channel to configure*/
+  /*********************************/
+  //BEGIN JK 06.07.04: Management of sevrals boards 
+  //outl(0 | ui_ChannelNo , devpriv->iobase+i_Offset + 0x4);
+  outl(0 | ui_ChannelNo , devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 0x4);
+  //END JK 06.07.04: Management of sevrals boards 
+  
+  //BEGIN JK 06.07.04: Management of sevrals boards                
+  //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); 
+  while (((inl(devpriv->iobase+s_BoardInfos [dev->minor].i_Offset+12)>>19) & 1) != 1); 
+  //END JK 06.07.04: Management of sevrals boards 
+  /**************************/                                                          
+  /* Reset the configuration */                                                           
+  /**************************/  
+  //BEGIN JK 06.07.04: Management of sevrals boards                
+  //outl(0 , devpriv->iobase+i_Offset + 0x0);  
+  outl(0 , devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 0x0);  
+  //END JK 06.07.04: Management of sevrals boards                
+  
+  //BEGIN JK 06.07.04: Management of sevrals boards                          
+  //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
+  while (((inl(devpriv->iobase+s_BoardInfos [dev->minor].i_Offset+12)>>19) & 1) != 1);
+  //END JK 06.07.04: Management of sevrals boards                          
                   
-              /***************************/
-              /* Write the configuration */
-              /***************************/
-              outl(ul_Config , devpriv->iobase+i_Offset + 0x0);
-
-              /***************************/
-              /*Reset the calibration bit*/
-              /***************************/
-              ul_Temp = inl(devpriv->iobase+i_Offset + 12);
-              while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
-              outl((ul_Temp & 0xFFF9FFFF) , devpriv->iobase+i_Offset + 12);
-              if(data[9]==1)
-                 {
-                 devpriv->tsk_Current=current;
-                 i_InterruptFlag=1;
-                 }// if(data[9]==1)
-              else
-                 {
-                  i_InterruptFlag=0;
-                 }//else  if(data[9]==1)
-              i_Initialised=1;
-              if(i_ScanType==1)
-                 {
-                 i_Sum=i_Sum+1;
-                 insn->unused[0]=0; 
-                 i_APCI3200_ReadAnalogInput(dev,s,insn,&ui_Dummy);
-                 }         
-return insn->n;
+  /***************************/
+  /* Write the configuration */
+  /***************************/
+  //BEGIN JK 06.07.04: Management of sevrals boards                          
+  //outl(ul_Config , devpriv->iobase+i_Offset + 0x0);
+  outl(ul_Config , devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 0x0);
+  //END JK 06.07.04: Management of sevrals boards                          
+
+  /***************************/
+  /*Reset the calibration bit*/
+  /***************************/
+  //BEGIN JK 06.07.04: Management of sevrals boards 
+  //ul_Temp = inl(devpriv->iobase+i_Offset + 12);
+  ul_Temp = inl(devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 12);
+  //END JK 06.07.04: Management of sevrals boards 
+  
+  //BEGIN JK 06.07.04: Management of sevrals boards 
+  //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
+  while (((inl(devpriv->iobase+s_BoardInfos [dev->minor].i_Offset+12)>>19) & 1) != 1);
+  //END JK 06.07.04: Management of sevrals boards 
+  
+  //BEGIN JK 06.07.04: Management of sevrals boards  
+  //outl((ul_Temp & 0xFFF9FFFF) , devpriv->iobase+.i_Offset + 12);
+  outl((ul_Temp & 0xFFF9FFFF) , devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 12);
+  //END JK 06.07.04: Management of sevrals boards 
+
+  if(data[9]==1)
+    {      
+      devpriv->tsk_Current=current;
+      //BEGIN JK 06.07.04: Management of sevrals boards
+      //i_InterruptFlag=1;
+      s_BoardInfos [dev->minor].i_InterruptFlag=1;
+      //END JK 06.07.04: Management of sevrals boards
+    }// if(data[9]==1)
+  else
+    {
+      //BEGIN JK 06.07.04: Management of sevrals boards
+      //i_InterruptFlag=0;
+      s_BoardInfos [dev->minor].i_InterruptFlag=0;
+      //END JK 06.07.04: Management of sevrals boards
+    }//else  if(data[9]==1)
+  
+  //BEGIN JK 06.07.04: Management of sevrals boards
+  //i_Initialised=1;
+  s_BoardInfos [dev->minor].i_Initialised=1;
+  //END JK 06.07.04: Management of sevrals boards
+  
+  //BEGIN JK 06.07.04: Management of sevrals boards
+  //if(i_ScanType==1)
+  if(s_BoardInfos [dev->minor].i_ScanType==1)
+    //END JK 06.07.04: Management of sevrals boards
+    {
+      //BEGIN JK 06.07.04: Management of sevrals boards
+      //i_Sum=i_Sum+1;
+      s_BoardInfos [dev->minor].i_Sum=s_BoardInfos [dev->minor].i_Sum+1;
+      //END JK 06.07.04: Management of sevrals boards
+      
+      insn->unused[0]=0; 
+      i_APCI3200_ReadAnalogInput(dev,s,insn,&ui_Dummy);
+    }         
+  return insn->n;
 } 
 
 /*
-+----------------------------------------------------------------------------+
-| Function   Name   : int i_APCI3200_ReadAnalogInput                         |
-|                                (comedi_device *dev,comedi_subdevice *s,       | 
-|                     comedi_insn *insn,lsampl_t *data)                      |
-+----------------------------------------------------------------------------+
-| Task              : Read  value  of the selected channel                              |
-+----------------------------------------------------------------------------+
-| Input Parameters  : comedi_device *dev      : Driver handle                |
-|                     UINT ui_NoOfChannels    : No Of Channels To read       |
-|                     UINT *data              : Data Pointer to read status  |
-+----------------------------------------------------------------------------+
-| Output Parameters :  --                                                                                                       |
-|                                 data[0]  : Digital Value Of Input             |
-|                                 data[1]  : Calibration Offset Value           |
-|                                 data[2]  : Calibration Gain Value          
-                               data[3]  : CJC value  
-                               data[4]  : CJC offset value
-                               data[5]  : CJC gain value 
-+----------------------------------------------------------------------------+
-| Return Value      : TRUE  : No error occur                                 |
-|                          : FALSE : Error occur. Return the error          |
-|                                                                               |
-+----------------------------------------------------------------------------+
+  +----------------------------------------------------------------------------+
+  | Function   Name   : int i_APCI3200_ReadAnalogInput                         |
+  |                              (comedi_device *dev,comedi_subdevice *s,       | 
+  |                     comedi_insn *insn,lsampl_t *data)                      |
+  +----------------------------------------------------------------------------+
+  | Task              : Read  value  of the selected channel                            |
+  +----------------------------------------------------------------------------+
+  | Input Parameters  : comedi_device *dev      : Driver handle                |
+  |                     UINT ui_NoOfChannels    : No Of Channels To read       |
+  |                     UINT *data              : Data Pointer to read status  |
+  +----------------------------------------------------------------------------+
+  | Output Parameters :        --                                                                                                       |
+  |                            data[0]  : Digital Value Of Input             |
+  |                            data[1]  : Calibration Offset Value           |
+  |                            data[2]  : Calibration Gain Value          
+  |                            data[3]  : CJC value  
+  |                            data[4]  : CJC offset value
+  |                            data[5]  : CJC gain value 
+  | Begin JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values 
+  |                            data[6] : CJC current source from eeprom
+  |                            data[7] : Channel current source from eeprom
+  |                            data[8] : Channle gain factor from eeprom
+  | End JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values 
+  +----------------------------------------------------------------------------+
+  | Return Value      : TRUE  : No error occur                                 |
+  |                        : FALSE : Error occur. Return the error          |
+  |                                                                             |
+  +----------------------------------------------------------------------------+
 */
 INT i_APCI3200_ReadAnalogInput(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data) 
 { 
-   UINT ui_DummyValue=0;
-   int i_ConvertCJCCalibration;
-   int i=0;
-   
-   
-   if(i_Initialised==0)
-     {
-     printk("\nThe channel is not initialised\n");
-     i_APCI3200_Reset(dev);
-     return -EINVAL;
-     }//if(i_Initialised==0);
+  UINT ui_DummyValue=0;
+  int i_ConvertCJCCalibration;
+  int i=0;
      
-         
-   switch(insn->unused[0])
-      {
-      case 0:     
+  //BEGIN JK 06.07.04: Management of sevrals boards
+  //if(i_Initialised==0)
+  if(s_BoardInfos [dev->minor].i_Initialised==0)
+    //END JK 06.07.04: Management of sevrals boards     
+    {
+      i_APCI3200_Reset(dev);
+      return -EINVAL;
+    }//if(i_Initialised==0);
+        
+#ifdef PRINT_INFO             
+  printk ("\n insn->unused[0] = %i", insn->unused[0]);
+#endif
+      
+  switch(insn->unused[0])
+    {
+    case 0:     
            
-             i_APCI3200_Read1AnalogInputChannel(dev,s,insn,&ui_DummyValue);
-             ui_InterruptChannelValue[i_Count+0]=ui_DummyValue; 
-
-             if((i_ADDIDATAType==2) && (i_InterruptFlag == FALSE) && (i_CJCAvailable==1))
-                {
-                i_APCI3200_ReadCJCValue(dev,&ui_DummyValue);
-                ui_InterruptChannelValue[i_Count + 3]=ui_DummyValue; 
-                }//if((i_ADDIDATAType==2) && (i_InterruptFlag == FALSE))
-             else
-                {
-                  ui_InterruptChannelValue[i_Count + 3]=0;
-                }//elseif((i_ADDIDATAType==2) && (i_InterruptFlag == FALSE) && (i_CJCAvailable==1))  
-             if (( i_AutoCalibration == FALSE) && (i_InterruptFlag == FALSE))    
-                {  
-                i_APCI3200_ReadCalibrationOffsetValue(dev,&ui_DummyValue);
-                ui_InterruptChannelValue[i_Count + 1]=ui_DummyValue;  
-                i_APCI3200_ReadCalibrationGainValue(dev,&ui_DummyValue);  
-                ui_InterruptChannelValue[i_Count + 2]=ui_DummyValue; 
-                }//if (( i_AutoCalibration == FALSE) && (i_InterruptFlag == FALSE)) 
-             if((i_ADDIDATAType==2) && (i_InterruptFlag == FALSE)&& (i_CJCAvailable==1))
-                {
-                /**********************************************************/
-                /*Test if the Calibration channel must be read for the CJC*/
-                /**********************************************************/
-                 /**********************************/
-                 /*Test if the polarity is the same*/
-                 /**********************************/                                     
-                 if(i_CJCPolarity!=i_ADDIDATAPolarity)
-                    {
-                    i_ConvertCJCCalibration=1;
-                    }//if(i_CJCPolarity!=i_ADDIDATAPolarity)
-                 else 
-                    {
-                    if(i_CJCGain==i_ADDIDATAGain) 
-                      {
-                       i_ConvertCJCCalibration=0;
-                      }//if(i_CJCGain==i_ADDIDATAGain) 
-                    else
-                      {
-                      i_ConvertCJCCalibration=1;
-                      }//elseif(i_CJCGain==i_ADDIDATAGain)  
-                    }//elseif(i_CJCPolarity!=i_ADDIDATAPolarity)           
-                if(i_ConvertCJCCalibration==1)
-                   {
-                   i_APCI3200_ReadCJCCalOffset(dev,&ui_DummyValue);
-                   ui_InterruptChannelValue[i_Count+4]=ui_DummyValue;
-                   i_APCI3200_ReadCJCCalGain(dev,&ui_DummyValue);
-                   ui_InterruptChannelValue[i_Count+5]=ui_DummyValue;
-                   }//if(i_ConvertCJCCalibration==1)
-                else
-                   {
-                    ui_InterruptChannelValue[i_Count+4]=0;
-                    ui_InterruptChannelValue[i_Count+5]=0;
-                   }//elseif(i_ConvertCJCCalibration==1) 
-                }//if((i_ADDIDATAType==2) && (i_InterruptFlag == FALSE)) 
-                if(i_ScanType!=1)
-                   {
-                   i_Count=0;
-                   }//if(i_ScanType!=1)
-                else  
-                   {
-                   i_Count=i_Count +6;
-                   }//else if(i_ScanType!=1)  
-                if((i_ScanType==1) &&(i_InterruptFlag==1))
-                   {
-                   i_Count=i_Count-6;
-                   } 
-                if(i_ScanType==0)
-                  {           
-                  data[0]= ui_InterruptChannelValue[0];
-                  data[1]= ui_InterruptChannelValue[1];
-                  data[2]= ui_InterruptChannelValue[2];  
-                  data[3]= ui_InterruptChannelValue[3];
-                  data[4]= ui_InterruptChannelValue[4];
-                  data[5]= ui_InterruptChannelValue[5];  
-                  
-
-                  }   
-                 break;
-         case 1 :
-                for(i=0;i<insn->n;i++)
-                  { 
-                  data[i]=ui_InterruptChannelValue[i]; 
-                  }
-
-                  i_Count=0;
-                  i_Sum=0;
-                if(i_ScanType==1)
-                  {           
-                  i_Initialised=0; 
-                  i_InterruptFlag=0; 
-                  }   
-                 break;  
-         default:printk("\nThe parameters passed are in error\n");
-                 i_APCI3200_Reset(dev);
-                 return -EINVAL;
-         }//switch(insn->unused[0])    
-return insn->n;
+      i_APCI3200_Read1AnalogInputChannel(dev,s,insn,&ui_DummyValue);
+      //BEGIN JK 06.07.04: Management of sevrals boards
+      //ui_InterruptChannelValue[i_Count+0]=ui_DummyValue; 
+      s_BoardInfos [dev->minor].ui_InterruptChannelValue[s_BoardInfos [dev->minor].i_Count+0]=ui_DummyValue;       
+      //END JK 06.07.04: Management of sevrals boards    
+      
+      //Begin JK 25.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values        
+      i_APCI3200_GetChannelCalibrationValue (dev,s_BoardInfos [dev->minor].ui_Channel_num, 
+                                            &s_BoardInfos [dev->minor].ui_InterruptChannelValue [s_BoardInfos [dev->minor].i_Count+6], 
+                                            &s_BoardInfos [dev->minor].ui_InterruptChannelValue [s_BoardInfos [dev->minor].i_Count+7], 
+                                            &s_BoardInfos [dev->minor].ui_InterruptChannelValue [s_BoardInfos [dev->minor].i_Count+8]);
+                                                
+#ifdef PRINT_INFO                                               
+      printk ("\n s_BoardInfos [dev->minor].ui_InterruptChannelValue[s_BoardInfos [dev->minor].i_Count+6] = %lu", s_BoardInfos [dev->minor].ui_InterruptChannelValue[s_BoardInfos [dev->minor].i_Count+6]);
+                                                
+      printk ("\n s_BoardInfos [dev->minor].ui_InterruptChannelValue[s_BoardInfos [dev->minor].i_Count+7] = %lu", s_BoardInfos [dev->minor].ui_InterruptChannelValue[s_BoardInfos [dev->minor].i_Count+7]);
+                                                
+      printk ("\n s_BoardInfos [dev->minor].ui_InterruptChannelValue[s_BoardInfos [dev->minor].i_Count+8] = %lu", s_BoardInfos [dev->minor].ui_InterruptChannelValue[s_BoardInfos [dev->minor].i_Count+8]);                                                    
+#endif
+        
+      //End JK 25.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values             
+      
+      //BEGIN JK 06.07.04: Management of sevrals boards
+      //if((i_ADDIDATAType==2) && (i_InterruptFlag == FALSE) && (i_CJCAvailable==1))
+      if((s_BoardInfos [dev->minor].i_ADDIDATAType==2) && (s_BoardInfos [dev->minor].i_InterruptFlag == FALSE) && (s_BoardInfos [dev->minor].i_CJCAvailable==1))
+       //END JK 06.07.04: Management of sevrals boards             
+       {
+         i_APCI3200_ReadCJCValue(dev,&ui_DummyValue);
+         //BEGIN JK 06.07.04: Management of sevrals boards
+         //ui_InterruptChannelValue[i_Count + 3]=ui_DummyValue; 
+         s_BoardInfos [dev->minor].ui_InterruptChannelValue[s_BoardInfos [dev->minor].i_Count + 3]=ui_DummyValue; 
+         //END JK 06.07.04: Management of sevrals boards         
+       }//if((i_ADDIDATAType==2) && (i_InterruptFlag == FALSE))
+      else
+       {
+         //BEGIN JK 06.07.04: Management of sevrals boards
+         //ui_InterruptChannelValue[i_Count + 3]=0;
+         s_BoardInfos [dev->minor].ui_InterruptChannelValue[s_BoardInfos [dev->minor].i_Count + 3]=0;
+         //END JK 06.07.04: Management of sevrals boards
+       }//elseif((i_ADDIDATAType==2) && (i_InterruptFlag == FALSE) && (i_CJCAvailable==1))  
+      
+      //BEGIN JK 06.07.04: Management of sevrals boards
+      //if (( i_AutoCalibration == FALSE) && (i_InterruptFlag == FALSE))    
+      if ((s_BoardInfos [dev->minor].i_AutoCalibration == FALSE) && (s_BoardInfos [dev->minor].i_InterruptFlag == FALSE))    
+       //END JK 06.07.04: Management of sevrals boards
+       {  
+         i_APCI3200_ReadCalibrationOffsetValue(dev,&ui_DummyValue);
+         //BEGIN JK 06.07.04: Management of sevrals boards
+         //ui_InterruptChannelValue[i_Count + 1]=ui_DummyValue;
+         s_BoardInfos [dev->minor].ui_InterruptChannelValue[s_BoardInfos [dev->minor].i_Count + 1]=ui_DummyValue;
+         //END JK 06.07.04: Management of sevrals boards  
+         i_APCI3200_ReadCalibrationGainValue(dev,&ui_DummyValue);  
+          //BEGIN JK 06.07.04: Management of sevrals boards
+         //ui_InterruptChannelValue[i_Count + 2]=ui_DummyValue; 
+         s_BoardInfos [dev->minor].ui_InterruptChannelValue[s_BoardInfos [dev->minor].i_Count + 2]=ui_DummyValue; 
+         //END JK 06.07.04: Management of sevrals boards
+       }//if (( i_AutoCalibration == FALSE) && (i_InterruptFlag == FALSE)) 
+      
+      //BEGIN JK 06.07.04: Management of sevrals boards
+      //if((i_ADDIDATAType==2) && (i_InterruptFlag == FALSE)&& (i_CJCAvailable==1))
+      if((s_BoardInfos [dev->minor].i_ADDIDATAType==2) && (s_BoardInfos [dev->minor].i_InterruptFlag == FALSE)&& (s_BoardInfos [dev->minor].i_CJCAvailable==1))
+       //END JK 06.07.04: Management of sevrals boards
+       {
+         /**********************************************************/
+         /*Test if the Calibration channel must be read for the CJC*/
+         /**********************************************************/
+         /**********************************/
+         /*Test if the polarity is the same*/
+         /**********************************/         
+          //BEGIN JK 06.07.04: Management of sevrals boards                                  
+         //if(i_CJCPolarity!=i_ADDIDATAPolarity)
+         if(s_BoardInfos [dev->minor].i_CJCPolarity!=s_BoardInfos [dev->minor].i_ADDIDATAPolarity)
+           //END JK 06.07.04: Management of sevrals boards                                   
+           {
+             i_ConvertCJCCalibration=1;
+           }//if(i_CJCPolarity!=i_ADDIDATAPolarity)
+         else 
+           {
+             //BEGIN JK 06.07.04: Management of sevrals boards                               
+             //if(i_CJCGain==i_ADDIDATAGain) 
+             if(s_BoardInfos [dev->minor].i_CJCGain==s_BoardInfos [dev->minor].i_ADDIDATAGain) 
+               //END JK 06.07.04: Management of sevrals boards                               
+               {
+                 i_ConvertCJCCalibration=0;
+               }//if(i_CJCGain==i_ADDIDATAGain) 
+             else
+               {
+                 i_ConvertCJCCalibration=1;
+               }//elseif(i_CJCGain==i_ADDIDATAGain)  
+           }//elseif(i_CJCPolarity!=i_ADDIDATAPolarity)           
+         if(i_ConvertCJCCalibration==1)
+           {
+             i_APCI3200_ReadCJCCalOffset(dev,&ui_DummyValue);
+             //BEGIN JK 06.07.04: Management of sevrals boards                               
+             //ui_InterruptChannelValue[i_Count+4]=ui_DummyValue;
+             s_BoardInfos [dev->minor].ui_InterruptChannelValue[s_BoardInfos [dev->minor].i_Count+4]=ui_DummyValue;
+              //END JK 06.07.04: Management of sevrals boards                                
+
+             i_APCI3200_ReadCJCCalGain(dev,&ui_DummyValue);
+             
+              //BEGIN JK 06.07.04: Management of sevrals boards 
+             //ui_InterruptChannelValue[i_Count+5]=ui_DummyValue;
+             s_BoardInfos [dev->minor].ui_InterruptChannelValue[s_BoardInfos [dev->minor].i_Count+5]=ui_DummyValue;
+             //END JK 06.07.04: Management of sevrals boards 
+           }//if(i_ConvertCJCCalibration==1)
+         else
+           {
+             //BEGIN JK 06.07.04: Management of sevrals boards 
+             //ui_InterruptChannelValue[i_Count+4]=0;
+             //ui_InterruptChannelValue[i_Count+5]=0;
+             
+             s_BoardInfos [dev->minor].ui_InterruptChannelValue[s_BoardInfos [dev->minor].i_Count+4]=0;
+             s_BoardInfos [dev->minor].ui_InterruptChannelValue[s_BoardInfos [dev->minor].i_Count+5]=0;
+             //END JK 06.07.04: Management of sevrals boards 
+           }//elseif(i_ConvertCJCCalibration==1) 
+       }//if((i_ADDIDATAType==2) && (i_InterruptFlag == FALSE)) 
+      
+      //BEGIN JK 06.07.04: Management of sevrals boards 
+      //if(i_ScanType!=1)
+      if(s_BoardInfos [dev->minor].i_ScanType!=1)
+       {
+         //i_Count=0;
+         s_BoardInfos [dev->minor].i_Count=0;
+       }//if(i_ScanType!=1)
+      else  
+       {
+         //i_Count=i_Count +6;
+         //Begin JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values   
+         //s_BoardInfos [dev->minor].i_Count=s_BoardInfos [dev->minor].i_Count +6;
+         s_BoardInfos [dev->minor].i_Count=s_BoardInfos [dev->minor].i_Count +9;
+         //End JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values   
+       }//else if(i_ScanType!=1)  
+
+      //if((i_ScanType==1) &&(i_InterruptFlag==1))
+      if((s_BoardInfos [dev->minor].i_ScanType==1) &&(s_BoardInfos [dev->minor].i_InterruptFlag==1))
+       {
+         //i_Count=i_Count-6;
+         //Begin JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values
+         //s_BoardInfos [dev->minor].i_Count=s_BoardInfos [dev->minor].i_Count-6;
+         s_BoardInfos [dev->minor].i_Count=s_BoardInfos [dev->minor].i_Count-9;
+         //End JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values
+       } 
+      //if(i_ScanType==0)
+      if(s_BoardInfos [dev->minor].i_ScanType==0)
+       {           
+         /*
+           data[0]= ui_InterruptChannelValue[0];
+           data[1]= ui_InterruptChannelValue[1];
+           data[2]= ui_InterruptChannelValue[2];  
+           data[3]= ui_InterruptChannelValue[3];
+           data[4]= ui_InterruptChannelValue[4];
+           data[5]= ui_InterruptChannelValue[5];  
+         */          
+#ifdef PRINT_INFO        
+         printk("\n data[0]= s_BoardInfos [dev->minor].ui_InterruptChannelValue[0];");
+#endif   
+         data[0]= s_BoardInfos [dev->minor].ui_InterruptChannelValue[0];
+         data[1]= s_BoardInfos [dev->minor].ui_InterruptChannelValue[1];
+         data[2]= s_BoardInfos [dev->minor].ui_InterruptChannelValue[2];  
+         data[3]= s_BoardInfos [dev->minor].ui_InterruptChannelValue[3];
+         data[4]= s_BoardInfos [dev->minor].ui_InterruptChannelValue[4];
+         data[5]= s_BoardInfos [dev->minor].ui_InterruptChannelValue[5];  
+         
+         //Begin JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values
+         //printk("\n 0 - i_APCI3200_GetChannelCalibrationValue data [6] = %lu, data [7] = %lu, data [8] = %lu", data [6], data [7], data [8]);
+         i_APCI3200_GetChannelCalibrationValue (dev, s_BoardInfos [dev->minor].ui_Channel_num, &data [6], &data [7], &data [8]);
+         //End JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values             
+       }   
+      break;
+    case 1 :
+      
+      for(i=0;i<insn->n;i++)
+       { 
+         //data[i]=ui_InterruptChannelValue[i]; 
+         data[i]=s_BoardInfos [dev->minor].ui_InterruptChannelValue[i]; 
+       }       
+
+      //i_Count=0;
+      //i_Sum=0;
+      //if(i_ScanType==1)
+      s_BoardInfos [dev->minor].i_Count=0;
+      s_BoardInfos [dev->minor].i_Sum=0;
+      if(s_BoardInfos [dev->minor].i_ScanType==1)
+       {           
+         //i_Initialised=0; 
+         //i_InterruptFlag=0; 
+         s_BoardInfos [dev->minor].i_Initialised=0; 
+         s_BoardInfos [dev->minor].i_InterruptFlag=0; 
+         //END JK 06.07.04: Management of sevrals boards
+       }   
+      break;  
+    default:printk("\nThe parameters passed are in error\n");
+      i_APCI3200_Reset(dev);
+      return -EINVAL;
+    }//switch(insn->unused[0])   
+    
+            
+  return insn->n;
 }
 
 /*
-+----------------------------------------------------------------------------+
-| Function   Name   : int i_APCI3200_Read1AnalogInputChannel                 |
-|                                (comedi_device *dev,comedi_subdevice *s,       | 
-|                     comedi_insn *insn,lsampl_t *data)                      |
-+----------------------------------------------------------------------------+
-| Task              : Read  value  of the selected channel                              |
-+----------------------------------------------------------------------------+
-| Input Parameters  : comedi_device *dev      : Driver handle                |
-|                     UINT ui_NoOfChannel    : Channel No to read            |
-|                     UINT *data              : Data Pointer to read status  |
-+----------------------------------------------------------------------------+
-| Output Parameters :  --                                                                                                       |
-|                                data[0]  : Digital Value read                   |
-|                                                                
-+----------------------------------------------------------------------------+
-| Return Value      : TRUE  : No error occur                                 |
-|                          : FALSE : Error occur. Return the error          |
-|                                                                               |
-+----------------------------------------------------------------------------+
+  +----------------------------------------------------------------------------+
+  | Function   Name   : int i_APCI3200_Read1AnalogInputChannel                 |
+  |                              (comedi_device *dev,comedi_subdevice *s,       | 
+  |                     comedi_insn *insn,lsampl_t *data)                      |
+  +----------------------------------------------------------------------------+
+  | Task              : Read  value  of the selected channel                            |
+  +----------------------------------------------------------------------------+
+  | Input Parameters  : comedi_device *dev      : Driver handle                |
+  |                     UINT ui_NoOfChannel    : Channel No to read            |
+  |                     UINT *data              : Data Pointer to read status  |
+  +----------------------------------------------------------------------------+
+  | Output Parameters :        --                                                                                                       |
+  |                              data[0]  : Digital Value read                   |
+  |                                                              
+  +----------------------------------------------------------------------------+
+  | Return Value      : TRUE  : No error occur                                 |
+  |                        : FALSE : Error occur. Return the error          |
+  |                                                                             |
+  +----------------------------------------------------------------------------+
 */
 INT i_APCI3200_Read1AnalogInputChannel(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data){
-UINT ui_EOC=0;
-UINT ui_ChannelNo=0;
-UINT ui_CommandRegister=0;
-     
- ui_ChannelNo=i_ChannelNo;
-              while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);                   
-              /*********************************/
-              /* Write the channel to configure*/
-              /*********************************/
-              outl(0 | ui_Channel_num , devpriv->iobase+i_Offset + 0x4);
+  UINT ui_EOC=0;
+  UINT ui_ChannelNo=0;
+  UINT ui_CommandRegister=0;
+  
+  //BEGIN JK 06.07.04: Management of sevrals boards
+  //ui_ChannelNo=i_ChannelNo;
+  ui_ChannelNo=s_BoardInfos [dev->minor].i_ChannelNo;
+  
+  //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);                   
+  while (((inl(devpriv->iobase+s_BoardInfos [dev->minor].i_Offset+12)>>19) & 1) != 1);                   
+  /*********************************/
+  /* Write the channel to configure*/
+  /*********************************/
+  //Begin JK 20.10.2004: Bad channel value is used when using differential mode
+  //outl(0 | ui_Channel_num , devpriv->iobase+i_Offset + 0x4);
+  //outl(0 | s_BoardInfos [dev->minor].ui_Channel_num , devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 0x4);
+  outl(0 | s_BoardInfos [dev->minor].i_ChannelNo , devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 0x4);
+  //End JK 20.10.2004: Bad channel value is used when using differential mode
            
-/*******************************/
-/* Set the convert timing unit */
-/*******************************/
-while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
-outl(i_ADDIDATAConversionTimeUnit , devpriv->iobase+i_Offset + 36);                             
-/**************************/
-/* Set the convert timing */
-/**************************/
-while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
-outl(i_ADDIDATAConversionTime , devpriv->iobase+i_Offset + 32);
+  /*******************************/
+  /* Set the convert timing unit */
+  /*******************************/
+  //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
+  while (((inl(devpriv->iobase+s_BoardInfos [dev->minor].i_Offset+12)>>19) & 1) != 1);
+
+  //outl(i_ADDIDATAConversionTimeUnit , devpriv->iobase+i_Offset + 36);                             
+  outl(s_BoardInfos [dev->minor].i_ADDIDATAConversionTimeUnit , devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 36);                             
+  
+  /**************************/
+  /* Set the convert timing */
+  /**************************/
+  //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
+  while (((inl(devpriv->iobase+s_BoardInfos [dev->minor].i_Offset+12)>>19) & 1) != 1);
+  
+  //outl(i_ADDIDATAConversionTime , devpriv->iobase+i_Offset + 32);
+  outl(s_BoardInfos [dev->minor].i_ADDIDATAConversionTime , devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 32);
          
-/**************************************************************************/
-/* Set the start end stop index to the selected channel and set the start */
-/**************************************************************************/ 
+  /**************************************************************************/
+  /* Set the start end stop index to the selected channel and set the start */
+  /**************************************************************************/ 
 
-  
-ui_CommandRegister = ui_ChannelNo | (ui_ChannelNo << 8) | 0x80000;  
+  ui_CommandRegister = ui_ChannelNo | (ui_ChannelNo << 8) | 0x80000;  
     
-   /*********************************/
-   /*Test if the interrupt is enable*/
-   /*********************************/
+  /*********************************/
+  /*Test if the interrupt is enable*/
+  /*********************************/
              
- if (i_InterruptFlag == ADDIDATA_ENABLE)
-   { 
-   /************************/
-   /* Enable the interrupt */
-   /************************/
-   ui_CommandRegister = ui_CommandRegister | 0x00100000;
-   }//if (i_InterruptFlag == ADDIDATA_ENABLE)
+  //if (i_InterruptFlag == ADDIDATA_ENABLE)
+  if (s_BoardInfos [dev->minor].i_InterruptFlag == ADDIDATA_ENABLE)
+    { 
+      /************************/
+      /* Enable the interrupt */
+      /************************/
+      ui_CommandRegister = ui_CommandRegister | 0x00100000;
+    }//if (i_InterruptFlag == ADDIDATA_ENABLE)
               
-   /******************************/
-   /* Write the command register */
-   /******************************/
-    while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
-    outl(ui_CommandRegister, devpriv->iobase+i_Offset + 8);
-   /*****************************/
-   /*Test if interrupt is enable*/
-   /*****************************/              
-if (i_InterruptFlag == ADDIDATA_DISABLE)
-   {
-    do
-       {
-        /*************************/
-        /*Read the EOC Status bit*/
-        /*************************/
+  /******************************/
+  /* Write the command register */
+  /******************************/
+  //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
+  while (((inl(devpriv->iobase+s_BoardInfos [dev->minor].i_Offset+12)>>19) & 1) != 1);
+
+  //outl(ui_CommandRegister, devpriv->iobase+i_Offset + 8);
+  outl(ui_CommandRegister, devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 8);
+
+  /*****************************/
+  /*Test if interrupt is enable*/
+  /*****************************/              
+  //if (i_InterruptFlag == ADDIDATA_DISABLE)
+  if (s_BoardInfos [dev->minor].i_InterruptFlag == ADDIDATA_DISABLE)
+    {
+      do
+       {
+         /*************************/
+         /*Read the EOC Status bit*/
+         /*************************/
                     
-        ui_EOC = inl(devpriv->iobase+i_Offset + 20) & 1;
+         //ui_EOC = inl(devpriv->iobase+i_Offset + 20) & 1;
+         ui_EOC = inl(devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 20) & 1;
 
-       } while (ui_EOC != 1);
+       } while (ui_EOC != 1);
                 
 
-        /***************************************/
-        /* Read the digital value of the input */
-        /***************************************/
+      /***************************************/
+      /* Read the digital value of the input */
+      /***************************************/
                 
 
-        data[0] = inl (devpriv->iobase+i_Offset + 28);
-
+      //data[0] = inl (devpriv->iobase+i_Offset + 28);
+      data[0] = inl (devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 28);
+      //END JK 06.07.04: Management of sevrals boards
               
     }// if (i_InterruptFlag == ADDIDATA_DISABLE)
-return 0;
+  return 0;
 } 
 
 /*
-+----------------------------------------------------------------------------+
-| Function   Name   : int i_APCI3200_ReadCalibrationOffsetValue              |
-|                                (comedi_device *dev,comedi_subdevice *s,       | 
-|                     comedi_insn *insn,lsampl_t *data)                      |
-+----------------------------------------------------------------------------+
-| Task              : Read calibration offset  value  of the selected channel|
-+----------------------------------------------------------------------------+
-| Input Parameters  : comedi_device *dev      : Driver handle                |
-|                     UINT *data              : Data Pointer to read status  |
-+----------------------------------------------------------------------------+
-| Output Parameters :  --                                                                                                       |
-|                                data[0]  : Calibration offset Value   |
-|                                                                
-+----------------------------------------------------------------------------+
-| Return Value      : TRUE  : No error occur                                 |
-|                          : FALSE : Error occur. Return the error          |
-|                                                                               |
-+----------------------------------------------------------------------------+
+  +----------------------------------------------------------------------------+
+  | Function   Name   : int i_APCI3200_ReadCalibrationOffsetValue              |
+  |                              (comedi_device *dev,comedi_subdevice *s,       | 
+  |                     comedi_insn *insn,lsampl_t *data)                      |
+  +----------------------------------------------------------------------------+
+  | Task              : Read calibration offset  value  of the selected channel|
+  +----------------------------------------------------------------------------+
+  | Input Parameters  : comedi_device *dev      : Driver handle                |
+  |                     UINT *data              : Data Pointer to read status  |
+  +----------------------------------------------------------------------------+
+  | Output Parameters :        --                                                                                                       |
+  |                              data[0]  : Calibration offset Value   |
+  |                                                              
+  +----------------------------------------------------------------------------+
+  | Return Value      : TRUE  : No error occur                                 |
+  |                        : FALSE : Error occur. Return the error          |
+  |                                                                             |
+  +----------------------------------------------------------------------------+
 */
 int i_APCI3200_ReadCalibrationOffsetValue(comedi_device *dev,UINT *data)
 {
-   UINT ui_Temp=0 , ui_EOC=0;
-   UINT ui_CommandRegister=0;
-    while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);                   
-              /*********************************/
-              /* Write the channel to configure*/
-              /*********************************/
-              outl(0 | ui_Channel_num , devpriv->iobase+i_Offset + 0x4);
+  UINT ui_Temp=0 , ui_EOC=0;
+  UINT ui_CommandRegister=0;
+  
+  //BEGIN JK 06.07.04: Management of sevrals boards
+  //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);                   
+  while (((inl(devpriv->iobase+s_BoardInfos [dev->minor].i_Offset+12)>>19) & 1) != 1);                   
+  /*********************************/
+  /* Write the channel to configure*/
+  /*********************************/    
+  //Begin JK 20.10.2004: This seems not necessary !
+  //outl(0 | ui_Channel_num , devpriv->iobase+i_Offset + 0x4);
+  //outl(0 | s_BoardInfos [dev->minor].ui_Channel_num , devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 0x4);
+  //End JK 20.10.2004: This seems not necessary !
    
-              /*******************************/
-              /* Set the convert timing unit */
-              /*******************************/
-              while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
-              outl(i_ADDIDATAConversionTimeUnit , devpriv->iobase+i_Offset + 36);
-              /**************************/
-              /* Set the convert timing */
-              /**************************/
-              while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
-              outl(i_ADDIDATAConversionTime , devpriv->iobase+i_Offset + 32);
-              /*****************************/
-              /*Read the calibration offset*/
-              /*****************************/
-               ui_Temp = inl(devpriv->iobase+i_Offset + 12);
-
-              /*********************************/
-              /*Configure the Offset Conversion*/
-              /*********************************/
-              while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
-              outl((ui_Temp | 0x00020000), devpriv->iobase+i_Offset + 12);
-              /*******************************/
-              /*Initialise ui_CommandRegister*/
-              /*******************************/
+  /*******************************/
+  /* Set the convert timing unit */
+  /*******************************/
+  //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
+  while (((inl(devpriv->iobase+s_BoardInfos [dev->minor].i_Offset+12)>>19) & 1) != 1);
+  //outl(i_ADDIDATAConversionTimeUnit , devpriv->iobase+i_Offset + 36);
+  outl(s_BoardInfos [dev->minor].i_ADDIDATAConversionTimeUnit , devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 36);
+  /**************************/
+  /* Set the convert timing */
+  /**************************/
+  //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
+  while (((inl(devpriv->iobase+s_BoardInfos [dev->minor].i_Offset+12)>>19) & 1) != 1);
+  //outl(i_ADDIDATAConversionTime , devpriv->iobase+i_Offset + 32);
+  outl(s_BoardInfos [dev->minor].i_ADDIDATAConversionTime , devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 32);
+  /*****************************/
+  /*Read the calibration offset*/
+  /*****************************/
+  //ui_Temp = inl(devpriv->iobase+i_Offset + 12);
+  ui_Temp = inl(devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 12);
+
+  /*********************************/
+  /*Configure the Offset Conversion*/
+  /*********************************/
+  //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
+  while (((inl(devpriv->iobase+s_BoardInfos [dev->minor].i_Offset+12)>>19) & 1) != 1);
+  //outl((ui_Temp | 0x00020000), devpriv->iobase+i_Offset + 12);
+  outl((ui_Temp | 0x00020000), devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 12);
+  /*******************************/
+  /*Initialise ui_CommandRegister*/
+  /*******************************/
              
-              ui_CommandRegister = 0;
+  ui_CommandRegister = 0;
 
-              /*********************************/
-              /*Test if the interrupt is enable*/
-              /*********************************/
+  /*********************************/
+  /*Test if the interrupt is enable*/
+  /*********************************/
 
-              if (i_InterruptFlag == ADDIDATA_ENABLE)
-                 {
+  //if (i_InterruptFlag == ADDIDATA_ENABLE)
+  if (s_BoardInfos [dev->minor].i_InterruptFlag == ADDIDATA_ENABLE)
+    {
         
-                 /**********************/
-                 /*Enable the interrupt*/
-                 /**********************/
+      /**********************/
+      /*Enable the interrupt*/
+      /**********************/
 
-                 ui_CommandRegister = ui_CommandRegister | 0x00100000;
+      ui_CommandRegister = ui_CommandRegister | 0x00100000;
 
-                 }//if (i_InterruptFlag == ADDIDATA_ENABLE)
+    }//if (i_InterruptFlag == ADDIDATA_ENABLE)
              
-              /**********************/
-              /*Start the conversion*/
-              /**********************/
-              ui_CommandRegister = ui_CommandRegister | 0x00080000;
-
-
-              /***************************/
-              /*Write the command regiter*/
-              /***************************/
-              while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
-              outl(ui_CommandRegister, devpriv->iobase+i_Offset + 8);
-
-              /*****************************/
-              /*Test if interrupt is enable*/
-              /*****************************/
+  /**********************/
+  /*Start the conversion*/
+  /**********************/
+  ui_CommandRegister = ui_CommandRegister | 0x00080000;
+
+
+  /***************************/
+  /*Write the command regiter*/
+  /***************************/
+  //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
+  while (((inl(devpriv->iobase+s_BoardInfos [dev->minor].i_Offset+12)>>19) & 1) != 1);
+  //outl(ui_CommandRegister, devpriv->iobase+i_Offset + 8);
+  outl(ui_CommandRegister, devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 8);
+
+  /*****************************/
+  /*Test if interrupt is enable*/
+  /*****************************/
               
-              if (i_InterruptFlag == ADDIDATA_DISABLE)
-                 {
+  //if (i_InterruptFlag == ADDIDATA_DISABLE)
+  if (s_BoardInfos [dev->minor].i_InterruptFlag == ADDIDATA_DISABLE)
+    {
             
-                 do
-                    {
-                    /*******************/
-                    /*Read the EOC flag*/
-                    /*******************/
+      do
+       {
+         /*******************/
+         /*Read the EOC flag*/
+         /*******************/
                     
-                    ui_EOC = inl (devpriv->iobase+i_Offset + 20) & 1;
+         //ui_EOC = inl (devpriv->iobase+i_Offset + 20) & 1;
+         ui_EOC = inl (devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 20) & 1;
 
-                    } while (ui_EOC != 1);
+       } while (ui_EOC != 1);
                 
 
-                 /**************************************************/
-                 /*Read the digital value of the calibration Offset*/
-                 /**************************************************/
+      /**************************************************/
+      /*Read the digital value of the calibration Offset*/
+      /**************************************************/
                  
 
-                 data[0] = inl(devpriv->iobase+i_Offset+ 28);
-                 }//if (i_InterruptFlag == ADDIDATA_DISABLE)
-return 0;
+      //data[0] = inl(devpriv->iobase+i_Offset+ 28);
+      data[0] = inl(devpriv->iobase+s_BoardInfos [dev->minor].i_Offset+ 28);
+    }//if (i_InterruptFlag == ADDIDATA_DISABLE)
+  return 0;
 }
 
 /*
-+----------------------------------------------------------------------------+
-| Function   Name   : int i_APCI3200_ReadCalibrationGainValue                |
-|                                (comedi_device *dev,comedi_subdevice *s,       | 
-|                     comedi_insn *insn,lsampl_t *data)                      |
-+----------------------------------------------------------------------------+
-| Task              : Read calibration gain  value  of the selected channel  |
-+----------------------------------------------------------------------------+
-| Input Parameters  : comedi_device *dev      : Driver handle                |
-|                     UINT *data              : Data Pointer to read status  |
-+----------------------------------------------------------------------------+
-| Output Parameters :  --                                                                                                       |
-|                                data[0]  : Calibration gain Value Of Input     |
-|                                                                
-+----------------------------------------------------------------------------+
-| Return Value      : TRUE  : No error occur                                 |
-|                          : FALSE : Error occur. Return the error          |
-|                                                                               |
-+----------------------------------------------------------------------------+
+  +----------------------------------------------------------------------------+
+  | Function   Name   : int i_APCI3200_ReadCalibrationGainValue                |
+  |                              (comedi_device *dev,comedi_subdevice *s,       | 
+  |                     comedi_insn *insn,lsampl_t *data)                      |
+  +----------------------------------------------------------------------------+
+  | Task              : Read calibration gain  value  of the selected channel  |
+  +----------------------------------------------------------------------------+
+  | Input Parameters  : comedi_device *dev      : Driver handle                |
+  |                     UINT *data              : Data Pointer to read status  |
+  +----------------------------------------------------------------------------+
+  | Output Parameters :        --                                                                                                       |
+  |                              data[0]  : Calibration gain Value Of Input     |
+  |                                                              
+  +----------------------------------------------------------------------------+
+  | Return Value      : TRUE  : No error occur                                 |
+  |                        : FALSE : Error occur. Return the error          |
+  |                                                                             |
+  +----------------------------------------------------------------------------+
 */ 
 int i_APCI3200_ReadCalibrationGainValue(comedi_device *dev,UINT *data)
 {
   UINT ui_EOC=0;
   INT ui_CommandRegister=0;
- while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);                   
-              /*********************************/
-              /* Write the channel to configure*/
-              /*********************************/
-              outl(0 | ui_Channel_num , devpriv->iobase+i_Offset + 0x4);
+
+  //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);                   
+  while (((inl(devpriv->iobase+s_BoardInfos [dev->minor].i_Offset+12)>>19) & 1) != 1);                   
+  /*********************************/
+  /* Write the channel to configure*/
+  /*********************************/
+  //Begin JK 20.10.2004: This seems not necessary !
+  //outl(0 | ui_Channel_num , devpriv->iobase+i_Offset + 0x4);
+  //outl(0 | s_BoardInfos [dev->minor].ui_Channel_num , devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 0x4);
+  //End JK 20.10.2004: This seems not necessary !
     
-              /***************************/
-              /*Read the calibration gain*/
-              /***************************/
-              /*******************************/
-              /* Set the convert timing unit */
-              /*******************************/
-              while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
-              outl(i_ADDIDATAConversionTimeUnit , devpriv->iobase+i_Offset + 36);
-              /**************************/
-              /* Set the convert timing */
-              /**************************/
-              while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
-              outl(i_ADDIDATAConversionTime , devpriv->iobase+i_Offset + 32);
-              /*******************************/
-              /*Configure the Gain Conversion*/
-              /*******************************/
-              while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
-              outl(0x00040000 , devpriv->iobase+i_Offset + 12);
+  /***************************/
+  /*Read the calibration gain*/
+  /***************************/
+  /*******************************/
+  /* Set the convert timing unit */
+  /*******************************/
+  //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
+  while (((inl(devpriv->iobase+s_BoardInfos [dev->minor].i_Offset+12)>>19) & 1) != 1);
+  //outl(i_ADDIDATAConversionTimeUnit , devpriv->iobase+i_Offset + 36);
+  outl(s_BoardInfos [dev->minor].i_ADDIDATAConversionTimeUnit , devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 36);
+  /**************************/
+  /* Set the convert timing */
+  /**************************/
+  //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
+  while (((inl(devpriv->iobase+s_BoardInfos [dev->minor].i_Offset+12)>>19) & 1) != 1);
+  //outl(i_ADDIDATAConversionTime , devpriv->iobase+i_Offset + 32);
+  outl(s_BoardInfos [dev->minor].i_ADDIDATAConversionTime , devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 32);
+  /*******************************/
+  /*Configure the Gain Conversion*/
+  /*******************************/
+  //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
+  while (((inl(devpriv->iobase+s_BoardInfos [dev->minor].i_Offset+12)>>19) & 1) != 1);
+  //outl(0x00040000 , devpriv->iobase+i_Offset + 12);
+  outl(0x00040000 , devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 12);
              
 
-              /*******************************/
-              /*Initialise ui_CommandRegister*/
-              /*******************************/
+  /*******************************/
+  /*Initialise ui_CommandRegister*/
+  /*******************************/
 
-              ui_CommandRegister = 0;
+  ui_CommandRegister = 0;
 
-              /*********************************/
-              /*Test if the interrupt is enable*/
-              /*********************************/
+  /*********************************/
+  /*Test if the interrupt is enable*/
+  /*********************************/
               
-              if (i_InterruptFlag == ADDIDATA_ENABLE)
-                 {
+  //if (i_InterruptFlag == ADDIDATA_ENABLE)
+  if (s_BoardInfos [dev->minor].i_InterruptFlag == ADDIDATA_ENABLE)
+    {
                  
-                 /**********************/
-                 /*Enable the interrupt*/
-                 /**********************/
+      /**********************/
+      /*Enable the interrupt*/
+      /**********************/
             
-                 ui_CommandRegister = ui_CommandRegister | 0x00100000;
+      ui_CommandRegister = ui_CommandRegister | 0x00100000;
 
-                 }//if (i_InterruptFlag == ADDIDATA_ENABLE)
+    }//if (i_InterruptFlag == ADDIDATA_ENABLE)
               
-              /**********************/
-              /*Start the conversion*/
-              /**********************/
+  /**********************/
+  /*Start the conversion*/
+  /**********************/
               
-              ui_CommandRegister = ui_CommandRegister | 0x00080000;
-              /***************************/
-              /*Write the command regiter*/
-              /***************************/
-              while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
-              outl(ui_CommandRegister , devpriv->iobase+i_Offset + 8);
-
-              /*****************************/
-              /*Test if interrupt is enable*/
-              /*****************************/
+  ui_CommandRegister = ui_CommandRegister | 0x00080000;
+  /***************************/
+  /*Write the command regiter*/
+  /***************************/
+  //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
+  while (((inl(devpriv->iobase+s_BoardInfos [dev->minor].i_Offset+12)>>19) & 1) != 1);
+  //outl(ui_CommandRegister , devpriv->iobase+i_Offset + 8);
+  outl(ui_CommandRegister , devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 8);
+
+  /*****************************/
+  /*Test if interrupt is enable*/
+  /*****************************/
               
-              if (i_InterruptFlag == ADDIDATA_DISABLE)
-                 {
+  //if (i_InterruptFlag == ADDIDATA_DISABLE)
+  if (s_BoardInfos [dev->minor].i_InterruptFlag == ADDIDATA_DISABLE)
+    {
                
-                 do
-                    {
+      do
+       {
                    
-                    /*******************/
-                    /*Read the EOC flag*/
-                    /*******************/
+         /*******************/
+         /*Read the EOC flag*/
+         /*******************/
                     
-                    ui_EOC = inl(devpriv->iobase+i_Offset + 20) & 1;
+         //ui_EOC = inl(devpriv->iobase+i_Offset + 20) & 1;
+         ui_EOC = inl(devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 20) & 1;
 
-                    } while (ui_EOC != 1);
+       } while (ui_EOC != 1);
                  
-                 /************************************************/
-                 /*Read the digital value of the calibration Gain*/
-                 /************************************************/
+      /************************************************/
+      /*Read the digital value of the calibration Gain*/
+      /************************************************/
 
-                 data[0] = inl(devpriv->iobase+i_Offset + 28);
+      //data[0] = inl(devpriv->iobase+i_Offset + 28);
+      data[0] = inl(devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 28);
 
-                 }//if (i_InterruptFlag == ADDIDATA_DISABLE)
-return 0;
+    }//if (i_InterruptFlag == ADDIDATA_DISABLE)
+  return 0;
 }
 
 /*
-+----------------------------------------------------------------------------+
-| Function   Name   : int i_APCI3200_ReadCJCValue                            |
-|                                (comedi_device *dev,comedi_subdevice *s,       | 
-|                     comedi_insn *insn,lsampl_t *data)                      |
-+----------------------------------------------------------------------------+
-| Task              : Read CJC  value  of the selected channel               |
-+----------------------------------------------------------------------------+
-| Input Parameters  : comedi_device *dev      : Driver handle                |
-|                     UINT *data              : Data Pointer to read status  |
-+----------------------------------------------------------------------------+
-| Output Parameters :  --                                                                                                       |
-|                                data[0]  : CJC Value                           |
-|                                                                
-+----------------------------------------------------------------------------+
-| Return Value      : TRUE  : No error occur                                 |
-|                          : FALSE : Error occur. Return the error          |
-|                                                                               |
-+----------------------------------------------------------------------------+
+  +----------------------------------------------------------------------------+
+  | Function   Name   : int i_APCI3200_ReadCJCValue                            |
+  |                              (comedi_device *dev,comedi_subdevice *s,       | 
+  |                     comedi_insn *insn,lsampl_t *data)                      |
+  +----------------------------------------------------------------------------+
+  | Task              : Read CJC  value  of the selected channel               |
+  +----------------------------------------------------------------------------+
+  | Input Parameters  : comedi_device *dev      : Driver handle                |
+  |                     UINT *data              : Data Pointer to read status  |
+  +----------------------------------------------------------------------------+
+  | Output Parameters :        --                                                                                                       |
+  |                              data[0]  : CJC Value                           |
+  |                                                              
+  +----------------------------------------------------------------------------+
+  | Return Value      : TRUE  : No error occur                                 |
+  |                        : FALSE : Error occur. Return the error          |
+  |                                                                             |
+  +----------------------------------------------------------------------------+
 */ 
 
 int i_APCI3200_ReadCJCValue(comedi_device *dev,lsampl_t *data)
 {
- UINT  ui_EOC=0;
- INT ui_CommandRegister=0;
 UINT  ui_EOC=0;
 INT ui_CommandRegister=0;
    
-           /******************************/
-           /*Set the converting time unit*/
-           /******************************/
+  /******************************/
+  /*Set the converting time unit*/
+  /******************************/
           
-            while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
-            outl(i_ADDIDATAConversionTimeUnit , devpriv->iobase+i_Offset + 36);
-              /**************************/
-              /* Set the convert timing */
-              /**************************/
-             while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
-             outl(i_ADDIDATAConversionTime , devpriv->iobase+i_Offset + 32);  
-
-              /******************************/
-              /*Configure the CJC Conversion*/
-              /******************************/
-              while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
-              outl( 0x00000400 , devpriv->iobase+i_Offset + 4);
-              /*******************************/
-              /*Initialise dw_CommandRegister*/
-              /*******************************/
-              ui_CommandRegister = 0;
-             /*********************************/
-             /*Test if the interrupt is enable*/
-             /*********************************/  
-             if (i_InterruptFlag == ADDIDATA_ENABLE)
-                 { 
-                  /**********************/
-                  /*Enable the interrupt*/
-                  /**********************/
-                 ui_CommandRegister =ui_CommandRegister | 0x00100000; 
-                  }
+  //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
+  while (((inl(devpriv->iobase+s_BoardInfos [dev->minor].i_Offset+12)>>19) & 1) != 1);
+  
+  //outl(i_ADDIDATAConversionTimeUnit , devpriv->iobase+i_Offset + 36);
+  outl(s_BoardInfos [dev->minor].i_ADDIDATAConversionTimeUnit , devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 36);
+  /**************************/
+  /* Set the convert timing */
+  /**************************/
+  //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
+  while (((inl(devpriv->iobase+s_BoardInfos [dev->minor].i_Offset+12)>>19) & 1) != 1);
+  
+  //outl(i_ADDIDATAConversionTime , devpriv->iobase+i_Offset + 32);  
+  outl(s_BoardInfos [dev->minor].i_ADDIDATAConversionTime , devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 32);  
+
+  /******************************/
+  /*Configure the CJC Conversion*/
+  /******************************/
+  //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
+  while (((inl(devpriv->iobase+s_BoardInfos [dev->minor].i_Offset+12)>>19) & 1) != 1);
+
+  //outl( 0x00000400 , devpriv->iobase+i_Offset + 4);
+  outl( 0x00000400 , devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 4);
+  /*******************************/
+  /*Initialise dw_CommandRegister*/
+  /*******************************/
+  ui_CommandRegister = 0;
+  /*********************************/
+  /*Test if the interrupt is enable*/
+  /*********************************/  
+  //if (i_InterruptFlag == ADDIDATA_ENABLE)
+  if (s_BoardInfos [dev->minor].i_InterruptFlag == ADDIDATA_ENABLE)
+    { 
+      /**********************/
+      /*Enable the interrupt*/
+      /**********************/
+      ui_CommandRegister =ui_CommandRegister | 0x00100000; 
+    }
               
-             /**********************/
-              /*Start the conversion*/
-              /**********************/
+  /**********************/
+  /*Start the conversion*/
+  /**********************/
              
-              ui_CommandRegister = ui_CommandRegister | 0x00080000;
-
-              /***************************/
-              /*Write the command regiter*/
-              /***************************/
-              while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
-              outl(ui_CommandRegister , devpriv->iobase+i_Offset + 8);
+  ui_CommandRegister = ui_CommandRegister | 0x00080000;
+
+  /***************************/
+  /*Write the command regiter*/
+  /***************************/
+  //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
+  while (((inl(devpriv->iobase+s_BoardInfos [dev->minor].i_Offset+12)>>19) & 1) != 1);
+  //outl(ui_CommandRegister , devpriv->iobase+i_Offset + 8);
+  outl(ui_CommandRegister , devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 8);
          
-              /*****************************/
-              /*Test if interrupt is enable*/
-              /*****************************/
+  /*****************************/
+  /*Test if interrupt is enable*/
+  /*****************************/
               
-              if (i_InterruptFlag == ADDIDATA_DISABLE)
-                 {
-                 do
-                    {
+  //if (i_InterruptFlag == ADDIDATA_DISABLE)
+  if (s_BoardInfos [dev->minor].i_InterruptFlag == ADDIDATA_DISABLE)
+    {
+      do
+       {
                    
-                    /*******************/
-                    /*Read the EOC flag*/
-                    /*******************/
+         /*******************/
+         /*Read the EOC flag*/
+         /*******************/
                     
-                    ui_EOC = inl(devpriv->iobase+i_Offset + 20) & 1;
+         //ui_EOC = inl(devpriv->iobase+i_Offset + 20) & 1;
+         ui_EOC = inl(devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 20) & 1;
 
-                    } while (ui_EOC != 1);
+       } while (ui_EOC != 1);
                  
-                 /***********************************/
-                 /*Read the digital value of the CJC*/
-                 /***********************************/
+      /***********************************/
+      /*Read the digital value of the CJC*/
+      /***********************************/
                  
-                 data[0] = inl(devpriv->iobase+i_Offset + 28);
+      //data[0] = inl(devpriv->iobase+i_Offset + 28);
+      data[0] = inl(devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 28);
 
-                 }//if (i_InterruptFlag == ADDIDATA_DISABLE) 
-return 0;
+    }//if (i_InterruptFlag == ADDIDATA_DISABLE) 
+  return 0;
 }      
 
 /*
-+----------------------------------------------------------------------------+
-| Function   Name   : int i_APCI3200_ReadCJCCalOffset                        |
-|                                (comedi_device *dev,comedi_subdevice *s,       | 
-|                     comedi_insn *insn,lsampl_t *data)                      |
-+----------------------------------------------------------------------------+
-| Task              : Read CJC calibration offset  value  of the selected channel  
-+----------------------------------------------------------------------------+
-| Input Parameters  : comedi_device *dev      : Driver handle                |
-|                     UINT *data              : Data Pointer to read status  |
-+----------------------------------------------------------------------------+
-| Output Parameters :  --                                                                                                       |
-|                                data[0]  : CJC calibration offset Value                    
-|                                                                
-+----------------------------------------------------------------------------+
-| Return Value      : TRUE  : No error occur                                 |
-|                          : FALSE : Error occur. Return the error          |
-|                                                                               |
-+----------------------------------------------------------------------------+
+  +----------------------------------------------------------------------------+
+  | Function   Name   : int i_APCI3200_ReadCJCCalOffset                        |
+  |                              (comedi_device *dev,comedi_subdevice *s,       | 
+  |                     comedi_insn *insn,lsampl_t *data)                      |
+  +----------------------------------------------------------------------------+
+  | Task              : Read CJC calibration offset  value  of the selected channel  
+  +----------------------------------------------------------------------------+
+  | Input Parameters  : comedi_device *dev      : Driver handle                |
+  |                     UINT *data              : Data Pointer to read status  |
+  +----------------------------------------------------------------------------+
+  | Output Parameters :        --                                                                                                       |
+  |                              data[0]  : CJC calibration offset Value                    
+  |                                                              
+  +----------------------------------------------------------------------------+
+  | Return Value      : TRUE  : No error occur                                 |
+  |                        : FALSE : Error occur. Return the error          |
+  |                                                                             |
+  +----------------------------------------------------------------------------+
 */
 int i_APCI3200_ReadCJCCalOffset(comedi_device *dev,lsampl_t *data)
 {
- UINT  ui_EOC=0;
- INT ui_CommandRegister=0;
-               /*******************************************/
-               /*Read calibration offset value for the CJC*/
-               /*******************************************/ 
-               /*******************************/
-               /* Set the convert timing unit */
-               /*******************************/
-              while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
-              outl(i_ADDIDATAConversionTimeUnit , devpriv->iobase+i_Offset + 36);
-              /**************************/
-              /* Set the convert timing */
-              /**************************/
-              while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
-              outl(i_ADDIDATAConversionTime , devpriv->iobase+i_Offset + 32);               
-              /******************************/
-              /*Configure the CJC Conversion*/
-              /******************************/
-              while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
-              outl(0x00000400 , devpriv->iobase+i_Offset + 4); 
-              /*********************************/
-              /*Configure the Offset Conversion*/
-              /*********************************/
-              while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
-              outl(0x00020000, devpriv->iobase+i_Offset + 12); 
-              
-              /*******************************/
-              /*Initialise ui_CommandRegister*/
-              /*******************************/
-              ui_CommandRegister = 0;
-              /*********************************/
-              /*Test if the interrupt is enable*/
-              /*********************************/
+  UINT  ui_EOC=0;
+  INT ui_CommandRegister=0;
+  /*******************************************/
+  /*Read calibration offset value for the CJC*/
+  /*******************************************/ 
+  /*******************************/
+  /* Set the convert timing unit */
+  /*******************************/
+  //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
+  while (((inl(devpriv->iobase+s_BoardInfos [dev->minor].i_Offset+12)>>19) & 1) != 1);
+  //outl(i_ADDIDATAConversionTimeUnit , devpriv->iobase+i_Offset + 36);
+  outl(s_BoardInfos [dev->minor].i_ADDIDATAConversionTimeUnit , devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 36);
+  /**************************/
+  /* Set the convert timing */
+  /**************************/
+  //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
+  while (((inl(devpriv->iobase+s_BoardInfos [dev->minor].i_Offset+12)>>19) & 1) != 1);
+  //outl(i_ADDIDATAConversionTime , devpriv->iobase+i_Offset + 32);               
+  outl(s_BoardInfos [dev->minor].i_ADDIDATAConversionTime , devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 32);               
+  /******************************/
+  /*Configure the CJC Conversion*/
+  /******************************/
+  //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
+  while (((inl(devpriv->iobase+s_BoardInfos [dev->minor].i_Offset+12)>>19) & 1) != 1);
+  //outl(0x00000400 , devpriv->iobase+i_Offset + 4); 
+  outl(0x00000400 , devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 4); 
+  /*********************************/
+  /*Configure the Offset Conversion*/
+  /*********************************/
+  //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
+  while (((inl(devpriv->iobase+s_BoardInfos [dev->minor].i_Offset+12)>>19) & 1) != 1);  
+  //outl(0x00020000, devpriv->iobase+i_Offset + 12); 
+  outl(0x00020000, devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 12);             
+  /*******************************/
+  /*Initialise ui_CommandRegister*/
+  /*******************************/
+  ui_CommandRegister = 0;
+  /*********************************/
+  /*Test if the interrupt is enable*/
+  /*********************************/
               
-             if (i_InterruptFlag == ADDIDATA_ENABLE)
-                 { 
-                  /**********************/
-                  /*Enable the interrupt*/
-                  /**********************/
-                 ui_CommandRegister =ui_CommandRegister | 0x00100000; 
+  //if (i_InterruptFlag == ADDIDATA_ENABLE)
+  if (s_BoardInfos [dev->minor].i_InterruptFlag == ADDIDATA_ENABLE)
+    { 
+      /**********************/
+      /*Enable the interrupt*/
+      /**********************/
+      ui_CommandRegister =ui_CommandRegister | 0x00100000; 
                
-                  }
+    }
               
-             /**********************/
-              /*Start the conversion*/
-              /**********************/
-             ui_CommandRegister = ui_CommandRegister | 0x00080000;
-             /***************************/
-              /*Write the command regiter*/
-              /***************************/
-              while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
-              outl(ui_CommandRegister,devpriv->iobase+i_Offset + 8);  
-              if (i_InterruptFlag == ADDIDATA_DISABLE)
-                 {
-                 do
-                    {
-                    /*******************/
-                    /*Read the EOC flag*/
-                    /*******************/
-                    ui_EOC = inl(devpriv->iobase+i_Offset + 20) & 1;
-                    } while (ui_EOC != 1);
+  /**********************/
+  /*Start the conversion*/
+  /**********************/
+  ui_CommandRegister = ui_CommandRegister | 0x00080000;
+  /***************************/
+  /*Write the command regiter*/
+  /***************************/
+  //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
+  while (((inl(devpriv->iobase+s_BoardInfos [dev->minor].i_Offset+12)>>19) & 1) != 1);
+  //outl(ui_CommandRegister,devpriv->iobase+i_Offset + 8);  
+  outl(ui_CommandRegister,devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 8);  
+  //if (i_InterruptFlag == ADDIDATA_DISABLE)
+  if (s_BoardInfos [dev->minor].i_InterruptFlag == ADDIDATA_DISABLE)
+    {
+      do
+       {
+         /*******************/
+         /*Read the EOC flag*/
+         /*******************/
+         //ui_EOC = inl(devpriv->iobase+i_Offset + 20) & 1;
+         ui_EOC = inl(devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 20) & 1;
+       } while (ui_EOC != 1);
                  
-                 /**************************************************/
-                 /*Read the digital value of the calibration Offset*/
-                 /**************************************************/
-                 data[0] = inl(devpriv->iobase+i_Offset + 28);
-                 }//if (i_InterruptFlag == ADDIDATA_DISABLE) 
-return 0;
+      /**************************************************/
+      /*Read the digital value of the calibration Offset*/
+      /**************************************************/
+      //data[0] = inl(devpriv->iobase+i_Offset + 28);
+      data[0] = inl(devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 28);
+    }//if (i_InterruptFlag == ADDIDATA_DISABLE) 
+  return 0;
 } 
 
 /*
-+----------------------------------------------------------------------------+
-| Function   Name   : int i_APCI3200_ReadCJCGainValue                        |
-|                                (comedi_device *dev,comedi_subdevice *s,       | 
-|                     comedi_insn *insn,lsampl_t *data)                      |
-+----------------------------------------------------------------------------+
-| Task              : Read CJC calibration gain value  
-+----------------------------------------------------------------------------+
-| Input Parameters  : comedi_device *dev      : Driver handle                |
-|                     UINT ui_NoOfChannels    : No Of Channels To read       |
-|                     UINT *data              : Data Pointer to read status  |
-+----------------------------------------------------------------------------+
-| Output Parameters :  --                                                                                                       |
-|                                data[0]  : CJC calibration gain value                      
-|                                                                
-+----------------------------------------------------------------------------+
-| Return Value      : TRUE  : No error occur                                 |
-|                          : FALSE : Error occur. Return the error          |
-|                                                                               |
-+----------------------------------------------------------------------------+
+  +----------------------------------------------------------------------------+
+  | Function   Name   : int i_APCI3200_ReadCJCGainValue                        |
+  |                              (comedi_device *dev,comedi_subdevice *s,       | 
+  |                     comedi_insn *insn,lsampl_t *data)                      |
+  +----------------------------------------------------------------------------+
+  | Task              : Read CJC calibration gain value  
+  +----------------------------------------------------------------------------+
+  | Input Parameters  : comedi_device *dev      : Driver handle                |
+  |                     UINT ui_NoOfChannels    : No Of Channels To read       |
+  |                     UINT *data              : Data Pointer to read status  |
+  +----------------------------------------------------------------------------+
+  | Output Parameters :        --                                                                                                       |
+  |                              data[0]  : CJC calibration gain value                      
+  |                                                              
+  +----------------------------------------------------------------------------+
+  | Return Value      : TRUE  : No error occur                                 |
+  |                        : FALSE : Error occur. Return the error          |
+  |                                                                             |
+  +----------------------------------------------------------------------------+
 */ 
 int i_APCI3200_ReadCJCCalGain(comedi_device *dev,lsampl_t *data)  
 {   
- UINT  ui_EOC=0;
- INT ui_CommandRegister=0;
- /*******************************/
- /* Set the convert timing unit */
- /*******************************/
- while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
- outl(i_ADDIDATAConversionTimeUnit , devpriv->iobase+i_Offset + 36);
- /**************************/
- /* Set the convert timing */
- /**************************/
-  while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
-   outl(i_ADDIDATAConversionTime , devpriv->iobase+i_Offset + 32);
- /******************************/
- /*Configure the CJC Conversion*/
- /******************************/
-  while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
-  outl(0x00000400,devpriv->iobase+i_Offset + 4); 
-/*******************************/
-/*Configure the Gain Conversion*/
-/*******************************/
- while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
- outl(0x00040000,devpriv->iobase+i_Offset + 12);             
-
- /*******************************/
- /*Initialise dw_CommandRegister*/
- /*******************************/
-   ui_CommandRegister = 0;            
-/*********************************/
-/*Test if the interrupt is enable*/
-/*********************************/
- if (i_InterruptFlag == ADDIDATA_ENABLE)  
-{          
-/**********************/
-/*Enable the interrupt*/
-/**********************/
-ui_CommandRegister = ui_CommandRegister | 0x00100000;           
-}
-/**********************/
-/*Start the conversion*/
-/**********************/             
-ui_CommandRegister = ui_CommandRegister | 0x00080000;
-/***************************/
-/*Write the command regiter*/
-/***************************/            
-while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
-outl(ui_CommandRegister ,devpriv->iobase+i_Offset + 8);
-if (i_InterruptFlag == ADDIDATA_DISABLE)
+  UINT  ui_EOC=0;
+  INT ui_CommandRegister=0;
+  /*******************************/
+  /* Set the convert timing unit */
+  /*******************************/
+  //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
+  while (((inl(devpriv->iobase+s_BoardInfos [dev->minor].i_Offset+12)>>19) & 1) != 1);
+  //outl(i_ADDIDATAConversionTimeUnit , devpriv->iobase+i_Offset + 36);
+  outl(s_BoardInfos [dev->minor].i_ADDIDATAConversionTimeUnit , devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 36);
+  /**************************/
+  /* Set the convert timing */
+  /**************************/
+  //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
+  while (((inl(devpriv->iobase+s_BoardInfos [dev->minor].i_Offset+12)>>19) & 1) != 1);
+  //outl(i_ADDIDATAConversionTime , devpriv->iobase+i_Offset + 32);
+  outl(s_BoardInfos [dev->minor].i_ADDIDATAConversionTime , devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 32);
+  /******************************/
+  /*Configure the CJC Conversion*/
+  /******************************/
+  //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
+  while (((inl(devpriv->iobase+s_BoardInfos [dev->minor].i_Offset+12)>>19) & 1) != 1);
+  //outl(0x00000400,devpriv->iobase+i_Offset + 4); 
+  outl(0x00000400,devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 4); 
+  /*******************************/
+  /*Configure the Gain Conversion*/
+  /*******************************/
+  //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
+  while (((inl(devpriv->iobase+s_BoardInfos [dev->minor].i_Offset+12)>>19) & 1) != 1);
+  //outl(0x00040000,devpriv->iobase+i_Offset + 12);             
+  outl(0x00040000,devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 12);           
+
+  /*******************************/
+  /*Initialise dw_CommandRegister*/
+  /*******************************/
+  ui_CommandRegister = 0;            
+  /*********************************/
+  /*Test if the interrupt is enable*/
+  /*********************************/
+  //if (i_InterruptFlag == ADDIDATA_ENABLE)  
+  if (s_BoardInfos [dev->minor].i_InterruptFlag == ADDIDATA_ENABLE) 
+    {          
+      /**********************/
+      /*Enable the interrupt*/
+      /**********************/
+      ui_CommandRegister = ui_CommandRegister | 0x00100000;           
+    }
+  /**********************/
+  /*Start the conversion*/
+  /**********************/             
+  ui_CommandRegister = ui_CommandRegister | 0x00080000;
+  /***************************/
+  /*Write the command regiter*/
+  /***************************/            
+  //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
+  while (((inl(devpriv->iobase+s_BoardInfos [dev->minor].i_Offset+12)>>19) & 1) != 1);
+  //outl(ui_CommandRegister ,devpriv->iobase+i_Offset + 8);
+  outl(ui_CommandRegister ,devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 8);
+  //if (i_InterruptFlag == ADDIDATA_DISABLE)
+  if (s_BoardInfos [dev->minor].i_InterruptFlag == ADDIDATA_DISABLE)
     {
       do
-         {            
-         /*******************/
-         /*Read the EOC flag*/
-         /*******************/
-          ui_EOC = inl(devpriv->iobase+i_Offset + 20) & 1;      
-         } while (ui_EOC != 1);         
-       /************************************************/
-       /*Read the digital value of the calibration Gain*/
-       /************************************************/
-        data[0] = inl (devpriv->iobase+i_Offset + 28);           
+       {            
+         /*******************/
+         /*Read the EOC flag*/
+         /*******************/
+          //ui_EOC = inl(devpriv->iobase+i_Offset + 20) & 1;      
+         ui_EOC = inl(devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 20) & 1;      
+       } while (ui_EOC != 1);         
+      /************************************************/
+      /*Read the digital value of the calibration Gain*/
+      /************************************************/
+      //data[0] = inl (devpriv->iobase+i_Offset + 28);           
+      data[0] = inl (devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 28);
     }//if (i_InterruptFlag == ADDIDATA_DISABLE)
-return 0;
+  return 0;
 }              
 
                   
 /*
-+----------------------------------------------------------------------------+
-| Function   Name   : int i_APCI3200_InsnBits_AnalogInput_Test               |
-|                        (comedi_device *dev,comedi_subdevice *s,               | 
-|                      comedi_insn *insn,lsampl_t *data)                     |
-+----------------------------------------------------------------------------+
-| Task              : Tests the Selected Anlog Input Channel                 |
-+----------------------------------------------------------------------------+
-| Input Parameters  : comedi_device *dev      : Driver handle                |
-|                     comedi_subdevice *s     : Subdevice Pointer            |  
-|                     comedi_insn *insn       : Insn Structure Pointer       |  
-|                     lsampl_t *data          : Data Pointer contains        |
-|                                          configuration parameters as below |
-|                                                                           
-|                         
-|                           data[0]            : 0 TestAnalogInputShortCircuit                      
-|                                                                           1 TestAnalogInputConnection                                                                                                                                                                                                | 
-
-+----------------------------------------------------------------------------+
-| Output Parameters :  --                                                                                                       |
-|                              data[0]            : Digital value obtained      | 
-|                           data[1]            : calibration offset          |
-|                           data[2]            : calibration gain            |         
-|                                                                               |
-|                                                                               |
-+----------------------------------------------------------------------------+
-| Return Value      : TRUE  : No error occur                                 |
-|                          : FALSE : Error occur. Return the error          |
-|                                                                               |
-+----------------------------------------------------------------------------+
+  +----------------------------------------------------------------------------+
+  | Function   Name   : int i_APCI3200_InsnBits_AnalogInput_Test               |
+  |                      (comedi_device *dev,comedi_subdevice *s,               | 
+  |                      comedi_insn *insn,lsampl_t *data)                     |
+  +----------------------------------------------------------------------------+
+  | Task              : Tests the Selected Anlog Input Channel                 |
+  +----------------------------------------------------------------------------+
+  | Input Parameters  : comedi_device *dev      : Driver handle                |
+  |                     comedi_subdevice *s     : Subdevice Pointer            |  
+  |                     comedi_insn *insn       : Insn Structure Pointer       |  
+  |                     lsampl_t *data          : Data Pointer contains        |
+  |                                          configuration parameters as below |
+  |                                                                           
+  |                         
+  |                           data[0]            : 0 TestAnalogInputShortCircuit                            
+  |                                                                         1 TestAnalogInputConnection                                                                                                                                                                                                | 
+
+  +----------------------------------------------------------------------------+
+  | Output Parameters :        --                                                                                                       |
+  |                            data[0]            : Digital value obtained      | 
+  |                           data[1]            : calibration offset          |
+  |                           data[2]            : calibration gain            |         
+  |                                                                             |
+  |                                                                             |
+  +----------------------------------------------------------------------------+
+  | Return Value      : TRUE  : No error occur                                 |
+  |                        : FALSE : Error occur. Return the error          |
+  |                                                                             |
+  +----------------------------------------------------------------------------+
 */
 
 INT i_APCI3200_InsnBits_AnalogInput_Test(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data) 
 {
-UINT   ui_Configuration=0;
-INT i_Temp,i_TimeUnit;
-if(i_Initialised==0)
-   {
-   printk("\nThe channel is not initialised\n");
-   i_APCI3200_Reset(dev);
-   return -EINVAL;
-   }//if(i_Initialised==0);   
-if(data[0]!=0 && data[0]!=1)
-  {
-   printk("\nError in selection of functionality\n");
-   i_APCI3200_Reset(dev);
-   return -EINVAL;
-  }//if(data[0]!=0 && data[0]!=1)
-
-if(data[0]==1) //Perform Short Circuit TEST 
-  {
-  /**************************/
-  /*Set the short-cicuit bit*/
-  /**************************/
-  while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
-  outl((0x00001000 |i_ChannelNo) , devpriv->iobase+i_Offset + 4);
+  UINT         ui_Configuration=0;
+  //INT i_Temp,i_TimeUnit;
+  //if(i_Initialised==0)
+  
+  if(s_BoardInfos [dev->minor].i_Initialised==0)  
+    {
+      i_APCI3200_Reset(dev);
+      return -EINVAL;
+    }//if(i_Initialised==0);   
+  if(data[0]!=0 && data[0]!=1)
+    {
+      printk("\nError in selection of functionality\n");
+      i_APCI3200_Reset(dev);
+      return -EINVAL;
+    }//if(data[0]!=0 && data[0]!=1)
+
+  if(data[0]==1) //Perform Short Circuit TEST 
+    {
+      /**************************/
+      /*Set the short-cicuit bit*/
+      /**************************/
+      //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
+      while (((inl(devpriv->iobase+s_BoardInfos [dev->minor].i_Offset+12)>>19) & 1) != 1);
+      //outl((0x00001000 |i_ChannelNo) , devpriv->iobase+i_Offset + 4);
+      outl((0x00001000 |s_BoardInfos [dev->minor].i_ChannelNo) , devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 4);
       /*************************/
       /*Set the time unit to ns*/
       /*************************/
-     /* i_TimeUnit= i_ADDIDATAConversionTimeUnit;
-      i_ADDIDATAConversionTimeUnit= 1;*/
-       i_Temp= i_InterruptFlag ;  
-      i_InterruptFlag = ADDIDATA_DISABLE;
+      /* i_TimeUnit= i_ADDIDATAConversionTimeUnit;
+        i_ADDIDATAConversionTimeUnit= 1;*/
+      //i_Temp= i_InterruptFlag ;  
+      i_Temp= s_BoardInfos [dev->minor].i_InterruptFlag ;  
+      //i_InterruptFlag = ADDIDATA_DISABLE;
+      s_BoardInfos [dev->minor].i_InterruptFlag = ADDIDATA_DISABLE;
       i_APCI3200_Read1AnalogInputChannel(dev,s,insn,data); 
-       if(i_AutoCalibration == FALSE)
-         {
-          while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
-          outl((0x00001000 |i_ChannelNo) , devpriv->iobase+i_Offset + 4);
+      //if(i_AutoCalibration == FALSE)
+      if(s_BoardInfos [dev->minor].i_AutoCalibration == FALSE)
+       {
+          //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
+         while (((inl(devpriv->iobase+s_BoardInfos [dev->minor].i_Offset+12)>>19) & 1) != 1);
+          
+         //outl((0x00001000 |i_ChannelNo) , devpriv->iobase+i_Offset + 4);
+         outl((0x00001000 |s_BoardInfos [dev->minor].i_ChannelNo) , devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 4);
           data++;
           i_APCI3200_ReadCalibrationOffsetValue(dev,data);  
           data++; 
           i_APCI3200_ReadCalibrationGainValue(dev,data); 
-         }  
-   }
-else
-   {
-     while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
-     outl((0x00000800|i_ChannelNo) , devpriv->iobase+i_Offset + 4); 
-     ui_Configuration = inl(devpriv->iobase+i_Offset + 0);
+       }  
+    }
+  else
+    {
+      //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
+      while (((inl(devpriv->iobase+s_BoardInfos [dev->minor].i_Offset+12)>>19) & 1) != 1);
+      //outl((0x00000800|i_ChannelNo) , devpriv->iobase+i_Offset + 4); 
+      outl((0x00000800|s_BoardInfos [dev->minor].i_ChannelNo) , devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 4); 
+      //ui_Configuration = inl(devpriv->iobase+i_Offset + 0);
+      ui_Configuration = inl(devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 0);
       /*************************/
       /*Set the time unit to ns*/
       /*************************/
-     /* i_TimeUnit= i_ADDIDATAConversionTimeUnit;
-      i_ADDIDATAConversionTimeUnit= 1;*/
-       i_Temp= i_InterruptFlag ;  
-      i_InterruptFlag = ADDIDATA_DISABLE;
+      /* i_TimeUnit= i_ADDIDATAConversionTimeUnit;
+        i_ADDIDATAConversionTimeUnit= 1;*/
+      //i_Temp= i_InterruptFlag ;  
+      i_Temp= s_BoardInfos [dev->minor].i_InterruptFlag ;  
+      //i_InterruptFlag = ADDIDATA_DISABLE;
+      s_BoardInfos [dev->minor].i_InterruptFlag = ADDIDATA_DISABLE;
       i_APCI3200_Read1AnalogInputChannel(dev,s,insn,data); 
-      if(i_AutoCalibration == FALSE)
-         {
-         while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
-         outl((0x00000800|i_ChannelNo) , devpriv->iobase+i_Offset + 4);
+      //if(i_AutoCalibration == FALSE)
+      if(s_BoardInfos [dev->minor].i_AutoCalibration == FALSE)
+       {
+         //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
+         while (((inl(devpriv->iobase+s_BoardInfos [dev->minor].i_Offset+12)>>19) & 1) != 1);
+         //outl((0x00000800|i_ChannelNo) , devpriv->iobase+i_Offset + 4);
+         outl((0x00000800|s_BoardInfos [dev->minor].i_ChannelNo) , devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 4);
           data++;
           i_APCI3200_ReadCalibrationOffsetValue(dev,data);
           data++;     
           i_APCI3200_ReadCalibrationGainValue(dev,data);    
-         }
-     }
-          i_InterruptFlag=i_Temp ;
-printk("\ni_InterruptFlag=%d\n",i_InterruptFlag);
-return insn->n;
+       }
+    }
+  //i_InterruptFlag=i_Temp ;
+  s_BoardInfos [dev->minor].i_InterruptFlag=i_Temp ;
+  //printk("\ni_InterruptFlag=%d\n",i_InterruptFlag);
+  return insn->n;
 } 
 
 /*
-+----------------------------------------------------------------------------+
-| Function   Name   : int i_APCI3200_InsnWriteReleaseAnalogInput             |
-|                        (comedi_device *dev,comedi_subdevice *s,               | 
-|                      comedi_insn *insn,lsampl_t *data)                     |
-+----------------------------------------------------------------------------+
-| Task              :  Resets the channels                                                      |
-+----------------------------------------------------------------------------+
-| Input Parameters  : comedi_device *dev      : Driver handle                |
-|                     comedi_subdevice *s     : Subdevice Pointer            |  
-|                     comedi_insn *insn       : Insn Structure Pointer       |  
-|                     lsampl_t *data          : Data Pointer 
-+----------------------------------------------------------------------------+
-| Output Parameters :  --                                                                                                       |
-
-+----------------------------------------------------------------------------+
-| Return Value      : TRUE  : No error occur                                 |
-|                          : FALSE : Error occur. Return the error          |
-|                                                                               |
-+----------------------------------------------------------------------------+
+  +----------------------------------------------------------------------------+
+  | Function   Name   : int i_APCI3200_InsnWriteReleaseAnalogInput             |
+  |                      (comedi_device *dev,comedi_subdevice *s,               | 
+  |                      comedi_insn *insn,lsampl_t *data)                     |
+  +----------------------------------------------------------------------------+
+  | Task              :  Resets the channels                                                      |
+  +----------------------------------------------------------------------------+
+  | Input Parameters  : comedi_device *dev      : Driver handle                |
+  |                     comedi_subdevice *s     : Subdevice Pointer            |  
+  |                     comedi_insn *insn       : Insn Structure Pointer       |  
+  |                     lsampl_t *data          : Data Pointer 
+  +----------------------------------------------------------------------------+
+  | Output Parameters :        --                                                                                                       |
+
+  +----------------------------------------------------------------------------+
+  | Return Value      : TRUE  : No error occur                                 |
+  |                        : FALSE : Error occur. Return the error          |
+  |                                                                             |
+  +----------------------------------------------------------------------------+
 */
 
 INT i_APCI3200_InsnWriteReleaseAnalogInput(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data)
 { 
   i_APCI3200_Reset(dev);   
   return insn->n;
-    }    
+}    
           
-                 
-          
-                 
-     
-                 
-     
+   
 /*
-+----------------------------------------------------------------------------+
-| Function name     :int i_APCI3200_CommandTestAnalogInput(comedi_device *dev|
-|                      ,comedi_subdevice *s,comedi_cmd *cmd)                            |
-|                                                                                                               |
-+----------------------------------------------------------------------------+
-| Task              : Test validity for a command for cyclic anlog input     |
-|                       acquisition                                                                     | 
-|                                                                                                               |
-+----------------------------------------------------------------------------+
-| Input Parameters  : comedi_device *dev                                                                        |
-|                     comedi_subdevice *s                                                                       |
-|                     comedi_cmd *cmd                                                           |
-|                                                                                                               |
-|           
-|                                                                                                               |
-|                                                                                                               |
-|                                                                                                               |
-+----------------------------------------------------------------------------+
-| Return Value      :0                                                                      |
-|                                                                                                                           |
-+----------------------------------------------------------------------------+
+  +----------------------------------------------------------------------------+
+  | Function name     :int i_APCI3200_CommandTestAnalogInput(comedi_device *dev|
+  |                    ,comedi_subdevice *s,comedi_cmd *cmd)                            |
+  |                                                                                                             |
+  +----------------------------------------------------------------------------+
+  | Task              : Test validity for a command for cyclic anlog input     |
+  |                       acquisition                                                                           | 
+  |                                                                                                                     |
+  +----------------------------------------------------------------------------+
+  | Input Parameters  : comedi_device *dev                                                                      |
+  |                     comedi_subdevice *s                                                                     |
+  |                     comedi_cmd *cmd                                                         |
+  |                                                                                                                     |
+  |           
+  |                                                                                                                     |
+  |                                                                                                                     |
+  |                                                                                                                     |
+  +----------------------------------------------------------------------------+
+  | Return Value      :0                                                                    |
+  |                                                                                                                                 |
+  +----------------------------------------------------------------------------+
 */
 
 int i_APCI3200_CommandTestAnalogInput(comedi_device *dev,comedi_subdevice *s,comedi_cmd *cmd)
 {
 
-        int err=0;
-       int tmp;// divisor1,divisor2;
-        UINT ui_ConvertTime=0;
-        UINT ui_ConvertTimeBase=0;
-        UINT ui_DelayTime=0;
-        UINT ui_DelayTimeBase=0;
-        INT i_Triggermode=0;
-        INT i_TriggerEdge=0; 
-        INT i_NbrOfChannel=0;
-        INT i_Cpt=0;
-        double d_ConversionTimeForAllChannels=0.0;
-        double d_SCANTimeNewUnit=0.0;
-       // step 1: make sure trigger sources are trivially valid 
-
-       tmp=cmd->start_src;
-       cmd->start_src &= TRIG_NOW|TRIG_EXT;
-       if(!cmd->start_src || tmp!=cmd->start_src)err++;
-       tmp=cmd->scan_begin_src;
-       cmd->scan_begin_src &= TRIG_TIMER|TRIG_FOLLOW;
-       if(!cmd->scan_begin_src || tmp!=cmd->scan_begin_src)err++;
-        tmp=cmd->convert_src;
-       cmd->convert_src &= TRIG_TIMER;
-       if(!cmd->convert_src || tmp!=cmd->convert_src)err++;
-        tmp=cmd->scan_end_src;
-       cmd->scan_end_src &= TRIG_COUNT;
-       if(!cmd->scan_end_src || tmp!=cmd->scan_end_src)err++;
-       tmp=cmd->stop_src;
-       cmd->stop_src &= TRIG_COUNT|TRIG_NONE;
-       if(!cmd->stop_src || tmp!=cmd->stop_src)err++; 
-        if(i_InterruptFlag==0)
-          {
-          err++;
-//          printk("\nThe interrupt should be enabled\n");
-          }
-       if(err) 
-           {
-            i_APCI3200_Reset(dev);
-            return 1;
-           }  
+  int err=0;
+  int tmp;// divisor1,divisor2;
+  UINT ui_ConvertTime=0;
+  UINT ui_ConvertTimeBase=0;
+  UINT ui_DelayTime=0;
+  UINT ui_DelayTimeBase=0;
+  INT i_Triggermode=0;
+  INT i_TriggerEdge=0; 
+  INT i_NbrOfChannel=0;
+  INT i_Cpt=0;
+  double d_ConversionTimeForAllChannels=0.0;
+  double d_SCANTimeNewUnit=0.0;
+  // step 1: make sure trigger sources are trivially valid 
+
+  tmp=cmd->start_src;
+  cmd->start_src &= TRIG_NOW|TRIG_EXT;
+  if(!cmd->start_src || tmp!=cmd->start_src)err++;
+  tmp=cmd->scan_begin_src;
+  cmd->scan_begin_src &= TRIG_TIMER|TRIG_FOLLOW;
+  if(!cmd->scan_begin_src || tmp!=cmd->scan_begin_src)err++;
+  tmp=cmd->convert_src;
+  cmd->convert_src &= TRIG_TIMER;
+  if(!cmd->convert_src || tmp!=cmd->convert_src)err++;
+  tmp=cmd->scan_end_src;
+  cmd->scan_end_src &= TRIG_COUNT;
+  if(!cmd->scan_end_src || tmp!=cmd->scan_end_src)err++;
+  tmp=cmd->stop_src;
+  cmd->stop_src &= TRIG_COUNT|TRIG_NONE;
+  if(!cmd->stop_src || tmp!=cmd->stop_src)err++; 
+  //if(i_InterruptFlag==0)
+  if(s_BoardInfos [dev->minor].i_InterruptFlag==0)
+    {
+      err++;
+      //          printk("\nThe interrupt should be enabled\n");
+    }
+  if(err) 
+    {
+      i_APCI3200_Reset(dev);
+      return 1;
+    }  
         
 
-       if(cmd->start_src!=TRIG_NOW && cmd->start_src!=TRIG_EXT) 
-        {
-               err++;
+  if(cmd->start_src!=TRIG_NOW && cmd->start_src!=TRIG_EXT) 
+    {
+      err++;
+    }
+  if(cmd->start_src==TRIG_EXT)
+    {
+      i_TriggerEdge=cmd->start_arg & 0xFFFF;
+      i_Triggermode=cmd->start_arg >> 16;
+      if(i_TriggerEdge < 1 || i_TriggerEdge >3 )
+       {
+         err++;
+         printk("\nThe trigger edge selection is in error\n") ;
        }
-        if(cmd->start_src==TRIG_EXT)
-           {
-            i_TriggerEdge=cmd->start_arg & 0xFFFF;
-            i_Triggermode=cmd->start_arg >> 16;
-            if(i_TriggerEdge < 1 || i_TriggerEdge >3 )
-              {
-               err++;
-               printk("\nThe trigger edge selection is in error\n") ;
-              }
-             if(i_Triggermode!=2)
-              {
-               err++;
-               printk("\nThe trigger mode selection is in error\n") ;
-              }   
-           }    
-
-        if(cmd->scan_begin_src!=TRIG_TIMER &&
-            cmd->scan_begin_src!=TRIG_FOLLOW) err++;
-
-        if(cmd->convert_src!=TRIG_TIMER ) err++;
+      if(i_Triggermode!=2)
+       {
+         err++;
+         printk("\nThe trigger mode selection is in error\n") ;
+       }   
+    }    
+
+  if(cmd->scan_begin_src!=TRIG_TIMER &&
+     cmd->scan_begin_src!=TRIG_FOLLOW) err++;
+
+  if(cmd->convert_src!=TRIG_TIMER ) err++;
         
-        if(cmd->scan_end_src!=TRIG_COUNT) 
-        {
-               cmd->scan_end_src=TRIG_COUNT;
-               err++;
-       }
+  if(cmd->scan_end_src!=TRIG_COUNT) 
+    {
+      cmd->scan_end_src=TRIG_COUNT;
+      err++;
+    }
                   
-        if(cmd->stop_src!=TRIG_NONE &&
-          cmd->stop_src!=TRIG_COUNT ) err++;
-
-        if(err) 
-           {
-           i_APCI3200_Reset(dev); 
-           return 2;
-           
+  if(cmd->stop_src!=TRIG_NONE &&
+     cmd->stop_src!=TRIG_COUNT ) err++;
+
+  if(err) 
+    {
+      i_APCI3200_Reset(dev); 
+      return 2;
+    } 
           
-         i_FirstChannel=cmd->chanlist[0];
-         i_LastChannel=cmd->chanlist[1];   
+  //i_FirstChannel=cmd->chanlist[0];
+  s_BoardInfos [dev->minor].i_FirstChannel=cmd->chanlist[0];
+  //i_LastChannel=cmd->chanlist[1];   
+  s_BoardInfos [dev->minor].i_LastChannel=cmd->chanlist[1];
   
        
-        if (cmd->convert_src==TRIG_TIMER)
-            {
-              ui_ConvertTime=cmd->convert_arg & 0xFFFF;
-              ui_ConvertTimeBase=cmd->convert_arg >> 16; 
-        if (ui_ConvertTime!=20 && ui_ConvertTime!=40 && ui_ConvertTime!=80 && ui_ConvertTime!=160 )
+  if (cmd->convert_src==TRIG_TIMER)
+    {
+      ui_ConvertTime=cmd->convert_arg & 0xFFFF;
+      ui_ConvertTimeBase=cmd->convert_arg >> 16; 
+      if (ui_ConvertTime!=20 && ui_ConvertTime!=40 && ui_ConvertTime!=80 && ui_ConvertTime!=160 )
 
        {
-         printk("\nThe selection of conversion time reload value is in error\n");
-         err++;
-         }// if (ui_ConvertTime!=20 && ui_ConvertTime!=40 && ui_ConvertTime!=80 && ui_ConvertTime!=160 ) 
+         printk("\nThe selection of conversion time reload value is in error\n");
+         err++;
+       }// if (ui_ConvertTime!=20 && ui_ConvertTime!=40 && ui_ConvertTime!=80 && ui_ConvertTime!=160 ) 
       if(ui_ConvertTimeBase!=2)
         {
-        printk("\nThe selection of conversion time unit  is in error\n");
-        err++;
+         printk("\nThe selection of conversion time unit  is in error\n");
+         err++;
         }//if(ui_ConvertTimeBase!=2)  
-            }
-         else
-            {
-             ui_ConvertTime=0;
-             ui_ConvertTimeBase=0; 
-            }
-        if(cmd->scan_begin_src==TRIG_FOLLOW)
-           { 
-             ui_DelayTime=0;
-             ui_DelayTimeBase=0;
-            }//if(cmd->scan_begin_src==TRIG_FOLLOW)
-        else
-            {
-            ui_DelayTime=cmd->scan_begin_arg & 0xFFFF;
-            ui_DelayTimeBase=cmd->scan_begin_arg >> 16; 
-            if(ui_DelayTimeBase!=2 && ui_DelayTimeBase!=3)
-               {
-               err++;
-               printk("\nThe Delay time base selection is in error\n");
-               }
-             if(ui_DelayTime < 1 && ui_DelayTime >1023)
-                {
-                 err++;
-                 printk("\nThe Delay time value is in error\n"); 
-                }
-               if(err)
-                 {
-                 i_APCI3200_Reset(dev);  
-                 return 3;
-                 }
-            d_SCANTimeNewUnit = (double)ui_DelayTime;
-            i_NbrOfChannel= i_LastChannel-i_FirstChannel + 4;
-             /**********************************************************/
-             /*calculate the total conversion time for all the channels*/
-             /**********************************************************/
-             d_ConversionTimeForAllChannels = (double)((double)ui_ConvertTime / (double)i_NbrOfChannel);
+    }
+  else
+    {
+      ui_ConvertTime=0;
+      ui_ConvertTimeBase=0; 
+    }
+  if(cmd->scan_begin_src==TRIG_FOLLOW)
+    { 
+      ui_DelayTime=0;
+      ui_DelayTimeBase=0;
+    }//if(cmd->scan_begin_src==TRIG_FOLLOW)
+  else
+    {
+      ui_DelayTime=cmd->scan_begin_arg & 0xFFFF;
+      ui_DelayTimeBase=cmd->scan_begin_arg >> 16; 
+      if(ui_DelayTimeBase!=2 && ui_DelayTimeBase!=3)
+       {
+         err++;
+         printk("\nThe Delay time base selection is in error\n");
+       }
+      if(ui_DelayTime < 1 && ui_DelayTime >1023)
+       {
+         err++;
+         printk("\nThe Delay time value is in error\n"); 
+       }
+      if(err)
+       {
+         i_APCI3200_Reset(dev);  
+         return 3;
+       }
+      fpu_begin ();
+      d_SCANTimeNewUnit = (double)ui_DelayTime;
+      //i_NbrOfChannel= i_LastChannel-i_FirstChannel + 4;
+      i_NbrOfChannel= s_BoardInfos [dev->minor].i_LastChannel-s_BoardInfos [dev->minor].i_FirstChannel + 4;
+      /**********************************************************/
+      /*calculate the total conversion time for all the channels*/
+      /**********************************************************/
+      d_ConversionTimeForAllChannels = (double)((double)ui_ConvertTime / (double)i_NbrOfChannel);
              
-             /*******************************/
-             /*Convert the frequence in time*/
-             /*******************************/ 
-             d_ConversionTimeForAllChannels =(double) 1.0/ d_ConversionTimeForAllChannels;
-             ui_ConvertTimeBase=3; 
-              /***********************************/
-              /*Test if the time unit is the same*/
-              /***********************************/
+      /*******************************/
+      /*Convert the frequence in time*/
+      /*******************************/ 
+      d_ConversionTimeForAllChannels =(double) 1.0/ d_ConversionTimeForAllChannels;
+      ui_ConvertTimeBase=3; 
+      /***********************************/
+      /*Test if the time unit is the same*/
+      /***********************************/
                    
-                    if (ui_DelayTimeBase <= ui_ConvertTimeBase)
-                       {
+      if (ui_DelayTimeBase <= ui_ConvertTimeBase)
+       {
                       
-                       for (i_Cpt = 0; i_Cpt < (ui_ConvertTimeBase-ui_DelayTimeBase);i_Cpt++)
-                          {
+         for (i_Cpt = 0; i_Cpt < (ui_ConvertTimeBase-ui_DelayTimeBase);i_Cpt++)
+           {
                            
-                          d_ConversionTimeForAllChannels = d_ConversionTimeForAllChannels * 1000;
-                          d_ConversionTimeForAllChannels=d_ConversionTimeForAllChannels+1;
-                          }
-                       }
-                    else
-                       {
-                       for (i_Cpt = 0; i_Cpt < (ui_DelayTimeBase-ui_ConvertTimeBase);i_Cpt++)
-                          {
-                          d_SCANTimeNewUnit = d_SCANTimeNewUnit * 1000;
-
-                          }
-                       }
+             d_ConversionTimeForAllChannels = d_ConversionTimeForAllChannels * 1000;
+             d_ConversionTimeForAllChannels=d_ConversionTimeForAllChannels+1;
+           }
+       }
+      else
+       {
+         for (i_Cpt = 0; i_Cpt < (ui_DelayTimeBase-ui_ConvertTimeBase);i_Cpt++)
+           {
+             d_SCANTimeNewUnit = d_SCANTimeNewUnit * 1000;
+
+           }
+       }
                       
-                       if (d_ConversionTimeForAllChannels >= d_SCANTimeNewUnit)
-                         {
+      if (d_ConversionTimeForAllChannels >= d_SCANTimeNewUnit)
+       {
                        
-                       printk("\nSCAN Delay value cannot be used\n");
-                       /*********************************/
-                       /*SCAN Delay value cannot be used*/
-                       /*********************************/
-                       err++;
-                       }           
-            }//else if(cmd->scan_begin_src==TRIG_FOLLOW) 
+         printk("\nSCAN Delay value cannot be used\n");
+         /*********************************/
+         /*SCAN Delay value cannot be used*/
+         /*********************************/
+         err++;
+       }           
+      fpu_end ();
+    }//else if(cmd->scan_begin_src==TRIG_FOLLOW) 
 
        
          
-       if(err) 
-           {
-           i_APCI3200_Reset(dev);  
-           return 4;
-           }
+  if(err) 
+    {
+      i_APCI3200_Reset(dev);  
+      return 4;
+    }
         
   return 0;
-  }
+}
 
 /*
-+----------------------------------------------------------------------------+
-| Function name     :int i_APCI3200_StopCyclicAcquisition(comedi_device *dev,|
-|                                                                                           comedi_subdevice *s)|
-|                                                                                                               |
-+----------------------------------------------------------------------------+
-| Task              : Stop the  acquisition                                                 |
-|                                                                                                               |
-+----------------------------------------------------------------------------+
-| Input Parameters  : comedi_device *dev                                                                        |
-|                     comedi_subdevice *s                                                                       |
-|                                                                                               |
-+----------------------------------------------------------------------------+
-| Return Value      :0                                                                      |
-|                                                                                                                           |
-+----------------------------------------------------------------------------+
+  +----------------------------------------------------------------------------+
+  | Function name     :int i_APCI3200_StopCyclicAcquisition(comedi_device *dev,|
+  |                                                                                         comedi_subdevice *s)|
+  |                                                                                                             |
+  +----------------------------------------------------------------------------+
+  | Task              : Stop the  acquisition                                                       |
+  |                                                                                                                     |
+  +----------------------------------------------------------------------------+
+  | Input Parameters  : comedi_device *dev                                                                      |
+  |                     comedi_subdevice *s                                                                     |
+  |                                                                                             |
+  +----------------------------------------------------------------------------+
+  | Return Value      :0                                                                    |
+  |                                                                                                                                 |
+  +----------------------------------------------------------------------------+
 */
 
 int i_APCI3200_StopCyclicAcquisition(comedi_device *dev,comedi_subdevice *s)
 {
-UINT ui_Configuration=0;
-i_InterruptFlag=0;
-i_Initialised==0;
-i_Count=0;
-i_Sum=0;
- /*******************/
- /*Read the register*/
- /*******************/
-  ui_Configuration = inl(devpriv->iobase+i_Offset + 8);             
-/*****************************/
-/*Reset the START and IRQ bit*/
-/*****************************/
- while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
- outl((ui_Configuration & 0xFFE7FFFF),devpriv->iobase+i_Offset + 8);
-return 0;             
+  UINT ui_Configuration=0;
+  //i_InterruptFlag=0;
+  //i_Initialised=0;
+  //i_Count=0;
+  //i_Sum=0;
+  s_BoardInfos [dev->minor].i_InterruptFlag=0;
+  s_BoardInfos [dev->minor].i_Initialised=0;
+  s_BoardInfos [dev->minor].i_Count=0;
+  s_BoardInfos [dev->minor].i_Sum=0;
+
+  /*******************/
+  /*Read the register*/
+  /*******************/
+  //ui_Configuration = inl(devpriv->iobase+i_Offset + 8);             
+  ui_Configuration = inl(devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 8);             
+  /*****************************/
+  /*Reset the START and IRQ bit*/
+  /*****************************/
+  //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
+  while (((inl(devpriv->iobase+s_BoardInfos [dev->minor].i_Offset+12)>>19) & 1) != 1);
+  //outl((ui_Configuration & 0xFFE7FFFF),devpriv->iobase+i_Offset + 8);
+  outl((ui_Configuration & 0xFFE7FFFF),devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 8);
+  return 0;             
 }
 /*
-+----------------------------------------------------------------------------+
-| Function name     : int i_APCI3200_CommandAnalogInput(comedi_device *dev,  |
-|                                                                                              comedi_subdevice *s) |
-|                                                                                                               |
-+----------------------------------------------------------------------------+
-| Task              : Does asynchronous acquisition                          |
-|                     Determines the mode 1 or 2.                                                   |
-|                                                                                                               |
-+----------------------------------------------------------------------------+
-| Input Parameters  : comedi_device *dev                                                                        |
-|                     comedi_subdevice *s                                                                       |
-|                                                                                                                               |
-|                                                                                                                               |
-+----------------------------------------------------------------------------+
-| Return Value      :                                                                           |
-|                                                                                                                           |
-+----------------------------------------------------------------------------+
+  +----------------------------------------------------------------------------+
+  | Function name     : int i_APCI3200_CommandAnalogInput(comedi_device *dev,  |
+  |                                                                                            comedi_subdevice *s) |
+  |                                                                                                             |
+  +----------------------------------------------------------------------------+
+  | Task              : Does asynchronous acquisition                          |
+  |                     Determines the mode 1 or 2.                                                 |
+  |                                                                                                                     |
+  +----------------------------------------------------------------------------+
+  | Input Parameters  : comedi_device *dev                                                                      |
+  |                     comedi_subdevice *s                                                                     |
+  |                                                                                                                                     |
+  |                                                                                                                                     |
+  +----------------------------------------------------------------------------+
+  | Return Value      :                                                                         |
+  |                                                                                                                                 |
+  +----------------------------------------------------------------------------+
 */
 
- int i_APCI3200_CommandAnalogInput(comedi_device *dev,comedi_subdevice *s)
+int i_APCI3200_CommandAnalogInput(comedi_device *dev,comedi_subdevice *s)
 {
-comedi_cmd *cmd=&s->async->cmd; 
-UINT ui_Configuration=0;
-INT  i_CurrentSource = 0; 
-UINT ui_Trigger=0;
-UINT ui_TriggerEdge=0;
-UINT ui_Triggermode=0; 
-UINT ui_ScanMode=0;
-UINT ui_ConvertTime=0;
-UINT ui_ConvertTimeBase=0;
-UINT ui_DelayTime=0;
-UINT ui_DelayTimeBase=0;
-UINT ui_DelayMode=0;
-     i_FirstChannel=cmd->chanlist[0];
-     i_LastChannel=cmd->chanlist[1];
-     if(cmd->start_src==TRIG_EXT) 
-        {
-         ui_Trigger=1;
-         ui_TriggerEdge=cmd->start_arg &0xFFFF;
-         ui_Triggermode=cmd->start_arg >> 16;
-        }//if(cmd->start_src==TRIG_EXT) 
-     else
-        {
-         ui_Trigger=0;
-        }//elseif(cmd->start_src==TRIG_EXT)    
+  comedi_cmd *cmd=&s->async->cmd; 
+  UINT ui_Configuration=0;
+  //INT  i_CurrentSource = 0; 
+  UINT ui_Trigger=0;
+  UINT ui_TriggerEdge=0;
+  UINT ui_Triggermode=0; 
+  UINT ui_ScanMode=0;
+  UINT ui_ConvertTime=0;
+  UINT ui_ConvertTimeBase=0;
+  UINT ui_DelayTime=0;
+  UINT ui_DelayTimeBase=0;
+  UINT ui_DelayMode=0;
+  //i_FirstChannel=cmd->chanlist[0];
+  //i_LastChannel=cmd->chanlist[1];
+  s_BoardInfos [dev->minor].i_FirstChannel=cmd->chanlist[0];
+  s_BoardInfos [dev->minor].i_LastChannel=cmd->chanlist[1];
+  if(cmd->start_src==TRIG_EXT) 
+    {
+      ui_Trigger=1;
+      ui_TriggerEdge=cmd->start_arg &0xFFFF;
+      ui_Triggermode=cmd->start_arg >> 16;
+    }//if(cmd->start_src==TRIG_EXT) 
+  else
+    {
+      ui_Trigger=0;
+    }//elseif(cmd->start_src==TRIG_EXT)    
      
-     if (cmd->stop_src==TRIG_COUNT) 
-       
-            ui_ScanMode=0; 
-       }// if (cmd->stop_src==TRIG_COUNT) 
-     else   
-       
-           ui_ScanMode=2;
-       }//else if (cmd->stop_src==TRIG_COUNT) 
+  if (cmd->stop_src==TRIG_COUNT) 
+    { 
+      ui_ScanMode=0; 
+    }// if (cmd->stop_src==TRIG_COUNT) 
+  else   
+    { 
+      ui_ScanMode=2;
+    }//else if (cmd->stop_src==TRIG_COUNT) 
          
-       if(cmd->scan_begin_src==TRIG_FOLLOW)
-           { 
-             ui_DelayTime=0;
-             ui_DelayTimeBase=0;
-             ui_DelayMode=0;
-            }//if(cmd->scan_begin_src==TRIG_FOLLOW)
-        else
-            {
-            ui_DelayTime=cmd->scan_begin_arg & 0xFFFF;
-            ui_DelayTimeBase=cmd->scan_begin_arg >> 16;
-            ui_DelayMode =1;  
-            }//else if(cmd->scan_begin_src==TRIG_FOLLOW) 
-//        printk("\nui_DelayTime=%u\n",ui_DelayTime);
-//        printk("\nui_DelayTimeBase=%u\n",ui_DelayTimeBase);
-        if (cmd->convert_src==TRIG_TIMER)
-            {
-              ui_ConvertTime=cmd->convert_arg & 0xFFFF;
-              ui_ConvertTimeBase=cmd->convert_arg >> 16; 
-            }
-         else
-            {
-             ui_ConvertTime=0;
-             ui_ConvertTimeBase=0; 
-            }
-       printk("\nui_ConvertTime=%u\n",ui_ConvertTime);
-       printk("\nui_ConvertTimebase=%u\n",ui_ConvertTimeBase);
-    // if(i_ADDIDATAType ==1 || ((i_ADDIDATAType==2)))
-     //   {
-     /**************************************************/
-     /*Read the old configuration of the current source*/
-     /**************************************************/   
-     ui_Configuration = inl(devpriv->iobase+i_Offset + 12);
-     /***********************************************/
-     /*Write the configuration of the current source*/
-     /***********************************************/
-     while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
-    outl((ui_Configuration & 0xFFC00000 ), devpriv->iobase+i_Offset +12);
-       // } 
-     ui_Configuration=0;
-//     printk("\nfirstchannel=%u\n",i_FirstChannel);
-//     printk("\nlastchannel=%u\n",i_LastChannel);
-//     printk("\nui_Trigger=%u\n",ui_Trigger); 
-//     printk("\nui_TriggerEdge=%u\n",ui_TriggerEdge);
-//     printk("\nui_Triggermode=%u\n",ui_Triggermode);   
-//      printk("\nui_DelayMode=%u\n",ui_DelayMode);  
-//     printk("\nui_ScanMode=%u\n",ui_ScanMode);       
-     ui_Configuration = i_FirstChannel |(i_LastChannel << 8)| 0x00100000 |
-                                 (ui_Trigger << 24) |
-                                 (ui_TriggerEdge << 25)|
-                                 (ui_Triggermode << 27)| 
-                                 (ui_DelayMode << 18) |
-                                 (ui_ScanMode << 16);
+  if(cmd->scan_begin_src==TRIG_FOLLOW)
+    { 
+      ui_DelayTime=0;
+      ui_DelayTimeBase=0;
+      ui_DelayMode=0;
+    }//if(cmd->scan_begin_src==TRIG_FOLLOW)
+  else
+    {
+      ui_DelayTime=cmd->scan_begin_arg & 0xFFFF;
+      ui_DelayTimeBase=cmd->scan_begin_arg >> 16;
+      ui_DelayMode =1;  
+    }//else if(cmd->scan_begin_src==TRIG_FOLLOW) 
+  //        printk("\nui_DelayTime=%u\n",ui_DelayTime);
+  //        printk("\nui_DelayTimeBase=%u\n",ui_DelayTimeBase);
+  if (cmd->convert_src==TRIG_TIMER)
+    {
+      ui_ConvertTime=cmd->convert_arg & 0xFFFF;
+      ui_ConvertTimeBase=cmd->convert_arg >> 16; 
+    }
+  else
+    {
+      ui_ConvertTime=0;
+      ui_ConvertTimeBase=0; 
+    }
+
+  // if(i_ADDIDATAType ==1 || ((i_ADDIDATAType==2)))
+  //   {
+  /**************************************************/
+  /*Read the old configuration of the current source*/
+  /**************************************************/   
+  //ui_Configuration = inl(devpriv->iobase+i_Offset + 12);
+  ui_Configuration = inl(devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 12);
+  /***********************************************/
+  /*Write the configuration of the current source*/
+  /***********************************************/
+  //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
+  while (((inl(devpriv->iobase+s_BoardInfos [dev->minor].i_Offset+12)>>19) & 1) != 1);
+  //outl((ui_Configuration & 0xFFC00000 ), devpriv->iobase+i_Offset +12);
+  outl((ui_Configuration & 0xFFC00000 ), devpriv->iobase+s_BoardInfos [dev->minor].i_Offset +12);
+  // } 
+  ui_Configuration=0;
+  //     printk("\nfirstchannel=%u\n",i_FirstChannel);
+  //     printk("\nlastchannel=%u\n",i_LastChannel);
+  //     printk("\nui_Trigger=%u\n",ui_Trigger); 
+  //     printk("\nui_TriggerEdge=%u\n",ui_TriggerEdge);
+  //     printk("\nui_Triggermode=%u\n",ui_Triggermode);   
+  //      printk("\nui_DelayMode=%u\n",ui_DelayMode);  
+  //     printk("\nui_ScanMode=%u\n",ui_ScanMode);       
+  
+  //ui_Configuration = i_FirstChannel |(i_LastChannel << 8)| 0x00100000 |
+  ui_Configuration = s_BoardInfos [dev->minor].i_FirstChannel |(s_BoardInfos [dev->minor].i_LastChannel << 8)| 0x00100000 |
+    (ui_Trigger << 24) |
+    (ui_TriggerEdge << 25)|
+    (ui_Triggermode << 27)| 
+    (ui_DelayMode << 18) |
+    (ui_ScanMode << 16);
     
  
-      /*************************/
-      /*Write the Configuration*/
-      /*************************/
-        while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
-        outl( ui_Configuration, devpriv->iobase+i_Offset + 0x8);          
-     /***********************/
-     /*Write the Delay Value*/
-     /***********************/
-     while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
-     outl(ui_DelayTime,devpriv->iobase+i_Offset + 40);                      
-      /***************************/
-      /*Write the Delay time base*/
-      /***************************/
-      while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
-      outl(ui_DelayTimeBase,devpriv->iobase+i_Offset + 44);                      
-      /*********************************/
-      /*Write the conversion time value*/
-      /*********************************/
-       while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
-       outl(ui_ConvertTime,devpriv->iobase+i_Offset + 32);                  
-       /********************************/
-       /*Write the conversion time base*/
-       /********************************/
-       while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
-       outl(ui_ConvertTimeBase,devpriv->iobase+i_Offset + 36);          
-        /*******************/
-        /*Read the register*/
-        /*******************/
-         ui_Configuration = inl(devpriv->iobase+i_Offset + 4);       
-       /******************/
-       /*Set the SCAN bit*/
-       /******************/
-       while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
-
-       outl(((ui_Configuration & 0x1E0FF) | 0x00002000),devpriv->iobase+i_Offset + 4);                  
-      /*******************/
-      /*Read the register*/
-      /*******************/
-       ui_Configuration=0;       
-       ui_Configuration = inl(devpriv->iobase+i_Offset + 8);
-
-       /*******************/
-        /*Set the START bit*/
-        /*******************/
-       while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
-       outl((ui_Configuration | 0x00080000),devpriv->iobase+i_Offset + 8);        
+  /*************************/
+  /*Write the Configuration*/
+  /*************************/
+  //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
+  while (((inl(devpriv->iobase+s_BoardInfos [dev->minor].i_Offset+12)>>19) & 1) != 1);
+  //outl( ui_Configuration, devpriv->iobase+i_Offset + 0x8);          
+  outl( ui_Configuration, devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 0x8);  
+  /***********************/
+  /*Write the Delay Value*/
+  /***********************/
+  //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
+  while (((inl(devpriv->iobase+s_BoardInfos [dev->minor].i_Offset+12)>>19) & 1) != 1);
+  //outl(ui_DelayTime,devpriv->iobase+i_Offset + 40);                      
+  outl(ui_DelayTime,devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 40);                      
+  /***************************/
+  /*Write the Delay time base*/
+  /***************************/
+  //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
+  while (((inl(devpriv->iobase+s_BoardInfos [dev->minor].i_Offset+12)>>19) & 1) != 1);
+  //outl(ui_DelayTimeBase,devpriv->iobase+i_Offset + 44);                      
+  outl(ui_DelayTimeBase,devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 44);                      
+  /*********************************/
+  /*Write the conversion time value*/
+  /*********************************/
+  //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
+  while (((inl(devpriv->iobase+s_BoardInfos [dev->minor].i_Offset+12)>>19) & 1) != 1);
+  //outl(ui_ConvertTime,devpriv->iobase+i_Offset + 32);                  
+  outl(ui_ConvertTime,devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 32);       
+              
+  /********************************/
+  /*Write the conversion time base*/
+  /********************************/
+  //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
+  while (((inl(devpriv->iobase+s_BoardInfos [dev->minor].i_Offset+12)>>19) & 1) != 1);
+  //outl(ui_ConvertTimeBase,devpriv->iobase+i_Offset + 36);          
+  outl(ui_ConvertTimeBase,devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 36);          
+  /*******************/
+  /*Read the register*/
+  /*******************/
+  //ui_Configuration = inl(devpriv->iobase+i_Offset + 4);       
+  ui_Configuration = inl(devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 4);       
+  /******************/
+  /*Set the SCAN bit*/
+  /******************/
+  //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
+  while (((inl(devpriv->iobase+s_BoardInfos [dev->minor].i_Offset+12)>>19) & 1) != 1);
+
+  //outl(((ui_Configuration & 0x1E0FF) | 0x00002000),devpriv->iobase+i_Offset + 4);                  
+  outl(((ui_Configuration & 0x1E0FF) | 0x00002000),devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 4);                  
+  /*******************/
+  /*Read the register*/
+  /*******************/
+  ui_Configuration=0;       
+  //ui_Configuration = inl(devpriv->iobase+i_Offset + 8);
+  ui_Configuration = inl(devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 8);
+
+  /*******************/
+  /*Set the START bit*/
+  /*******************/
+  //while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1);
+  while (((inl(devpriv->iobase+s_BoardInfos [dev->minor].i_Offset+12)>>19) & 1) != 1);
+  //outl((ui_Configuration | 0x00080000),devpriv->iobase+i_Offset + 8);        
+  outl((ui_Configuration | 0x00080000),devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 8);
   return 0;
 }
 
@@ -1978,140 +2901,172 @@ UINT ui_DelayMode=0;
 
 
 /*
-+----------------------------------------------------------------------------+
-| Function   Name   :  int i_APCI3200_Reset(comedi_device *dev)                             |
-|                                                                                               |
-+----------------------------------------------------------------------------+
-| Task              :Resets the registers of the card                        |
-+----------------------------------------------------------------------------+
-| Input Parameters  :                                                        |
-+----------------------------------------------------------------------------+
-| Output Parameters :  --                                                                                                       |
-+----------------------------------------------------------------------------+
-| Return Value      :                                                        |
-|                                                                                       |
-+----------------------------------------------------------------------------+
+  +----------------------------------------------------------------------------+
+  | Function   Name   :  int i_APCI3200_Reset(comedi_device *dev)                           |
+  |                                                                                             |
+  +----------------------------------------------------------------------------+
+  | Task              :Resets the registers of the card                        |
+  +----------------------------------------------------------------------------+
+  | Input Parameters  :                                                        |
+  +----------------------------------------------------------------------------+
+  | Output Parameters :        --                                                                                                       |
+  +----------------------------------------------------------------------------+
+  | Return Value      :                                                        |
+  |                                                                                     |
+  +----------------------------------------------------------------------------+
 */
 
 int i_APCI3200_Reset(comedi_device *dev)
 {
-INT i_Temp;
-DWORD dw_Dummy;
-i_InterruptFlag=0;
-i_Initialised==0;
-i_Count=0;
-i_Sum=0;
-
-outl(0x83838383,devpriv->i_IobaseAmcc+0x60);
+  INT i_Temp;
+  DWORD dw_Dummy;
+  //i_InterruptFlag=0;
+  //i_Initialised==0;
+  //i_Count=0;
+  //i_Sum=0;
+  
+  s_BoardInfos [dev->minor].i_InterruptFlag=0;
+  s_BoardInfos [dev->minor].i_Initialised=0;
+  s_BoardInfos [dev->minor].i_Count=0;
+  s_BoardInfos [dev->minor].i_Sum=0;
+  s_BoardInfos [dev->minor].b_StructInitialized = 0;
+
+  outl(0x83838383,devpriv->i_IobaseAmcc+0x60);
                  
-               // Enable the interrupt for the controler 
-               dw_Dummy =  inl(devpriv->i_IobaseAmcc+ 0x38);
-               outl(dw_Dummy | 0x2000,devpriv->i_IobaseAmcc+0x38);
-outl(0,devpriv->i_IobaseAddon);//Resets the output
-/***************/
-/*Empty the buffer*/
-/**************/
-for(i_Temp=0;i_Temp<=95;i_Temp++)
-   {
-    ui_InterruptChannelValue[i_Temp]=0;
-   }//for(i_Temp=0;i_Temp<=95;i_Temp++) 
-/*****************************/
-/*Reset the START and IRQ bit*/
-/*****************************/
-for(i_Temp=0;i_Temp<=192;)
-  {
-  while (((inl(devpriv->iobase+i_Temp+12)>>19) & 1) != 1);
-  outl(0,devpriv->iobase+i_Temp + 8);
-  i_Temp=i_Temp+64;
-  }//for(i_Temp=0;i_Temp<=192;i_Temp+64) 
-return 0;
+  // Enable the interrupt for the controler 
+  dw_Dummy =  inl(devpriv->i_IobaseAmcc+ 0x38);
+  outl(dw_Dummy | 0x2000,devpriv->i_IobaseAmcc+0x38);
+  outl(0,devpriv->i_IobaseAddon);//Resets the output
+  /***************/
+  /*Empty the buffer*/
+  /**************/
+  for(i_Temp=0;i_Temp<=95;i_Temp++)
+    {
+      //ui_InterruptChannelValue[i_Temp]=0;
+      s_BoardInfos [dev->minor].ui_InterruptChannelValue[i_Temp]=0;
+    }//for(i_Temp=0;i_Temp<=95;i_Temp++) 
+  /*****************************/
+  /*Reset the START and IRQ bit*/
+  /*****************************/
+  for(i_Temp=0;i_Temp<=192;)
+    {
+      while (((inl(devpriv->iobase+i_Temp+12)>>19) & 1) != 1);
+      outl(0,devpriv->iobase+i_Temp + 8);
+      i_Temp=i_Temp+64;
+    }//for(i_Temp=0;i_Temp<=192;i_Temp+64) 
+  return 0;
 }
 
 /*
-+----------------------------------------------------------------------------+
-| Function   Name   : static void v_APCI3200_Interrupt                                      |
-|                                        (int irq , void *d, struct pt_regs *regs)                              |
-+----------------------------------------------------------------------------+
-| Task              : Interrupt processing Routine                           |
-+----------------------------------------------------------------------------+
-| Input Parameters  : int irq                 : irq number                   |
-|                     void *d                 : void pointer                 |
-|                     struct pt_regs *regs    : structure pointer            |
-+----------------------------------------------------------------------------+
-| Output Parameters :  --                                                                                                       |
-+----------------------------------------------------------------------------+
-| Return Value      : TRUE  : No error occur                                 |
-|                          : FALSE : Error occur. Return the error                                      |
-|                                                                                               |
-+----------------------------------------------------------------------------+
+  +----------------------------------------------------------------------------+
+  | Function   Name   : static void v_APCI3200_Interrupt                                            |
+  |                                      (int irq , void *d, struct pt_regs *regs)                              |
+  +----------------------------------------------------------------------------+
+  | Task              : Interrupt processing Routine                           |
+  +----------------------------------------------------------------------------+
+  | Input Parameters  : int irq                 : irq number                   |
+  |                     void *d                 : void pointer                 |
+  |                     struct pt_regs *regs    : structure pointer            |
+  +----------------------------------------------------------------------------+
+  | Output Parameters :        --                                                                                                       |
+  +----------------------------------------------------------------------------+
+  | Return Value      : TRUE  : No error occur                                 |
+  |                        : FALSE : Error occur. Return the error                                      |
+  |                                                                                             |
+  +----------------------------------------------------------------------------+
 */
- void v_APCI3200_Interrupt(int irq, void *d, struct pt_regs *regs) 
+void v_APCI3200_Interrupt(int irq, void *d, struct pt_regs *regs) 
 {      
- comedi_device *dev = d;
- UINT ui_StatusRegister=0;
- UINT ui_ChannelNumber = 0;
- INT  i_CalibrationFlag = 0;
- INT i_CJCFlag=0;
- UINT  ui_DummyValue = 0;
- UINT ui_DigitalTemperature=0;
- UINT ui_DigitalInput =0;
- int i_ConvertCJCCalibration;
- int k;
-
-switch(i_ScanType)
-   {
+  comedi_device *dev = d;
+  UINT ui_StatusRegister=0;
+  UINT ui_ChannelNumber = 0;
+  INT  i_CalibrationFlag = 0;
+  INT i_CJCFlag=0;
+  UINT  ui_DummyValue = 0;
+  UINT ui_DigitalTemperature=0;
+  UINT ui_DigitalInput =0;
+  int i_ConvertCJCCalibration;
+  
+  //BEGIN JK TEST
+  int i_ReturnValue = 0;
+  //END JK TEST
+  
+  
+  //printk ("\n i_ScanType = %i i_ADDIDATAType = %i", s_BoardInfos [dev->minor].i_ScanType, s_BoardInfos [dev->minor].i_ADDIDATAType);
+
+  //switch(i_ScanType)
+  switch(s_BoardInfos [dev->minor].i_ScanType)
+    {
     case 0: 
     case 1: 
-          switch(i_ADDIDATAType)
-             {        
-              case 0:
-              case 1: 
+      //switch(i_ADDIDATAType)
+      switch(s_BoardInfos [dev->minor].i_ADDIDATAType)
+       {        
+       case 0:
+       case 1: 
              
-             /************************************/
-             /*Read the interrupt status register*/
-             /************************************/
-             ui_StatusRegister = inl(devpriv->iobase+i_Offset + 16);
-             if ((ui_StatusRegister & 0x2) == 0x2)
-                {
-                i_CalibrationFlag = ((inl(devpriv->iobase+i_Offset + 12) & 0x00060000) >> 17); 
-                /*************************/
-                /*Read the channel number*/
-                /*************************/
-                ui_ChannelNumber = inl(devpriv->iobase+i_Offset + 24);
-                /*************************************/
-                /*Read the digital analog input value*/
-                /*************************************/
-                ui_DigitalInput = inl(devpriv->iobase+i_Offset + 28);
-                /***********************************************/
-                /* Test if the value read is the channel value */
-                /***********************************************/
-                if (i_CalibrationFlag == 0)
-                  {
-                   ui_InterruptChannelValue[i_Count + 0] = ui_DigitalInput;
-
-                   /******************************************************/
-                   /*Start the conversion of the calibration offset value*/
-                   /******************************************************/
-                   i_APCI3200_ReadCalibrationOffsetValue(dev,&ui_DummyValue);
-                  }//if (i_CalibrationFlag == 0)
-                /**********************************************************/
-                /* Test if the value read is the calibration offset value */
-                /**********************************************************/
-
-               if (i_CalibrationFlag == 1)
-                 {
+         /************************************/
+         /*Read the interrupt status register*/
+         /************************************/
+         //ui_StatusRegister = inl(devpriv->iobase+i_Offset + 16);
+         ui_StatusRegister = inl(devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 16);
+         if ((ui_StatusRegister & 0x2) == 0x2)
+           {
+             //i_CalibrationFlag = ((inl(devpriv->iobase+i_Offset + 12) & 0x00060000) >> 17); 
+             i_CalibrationFlag = ((inl(devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 12) & 0x00060000) >> 17); 
+             /*************************/
+             /*Read the channel number*/
+             /*************************/
+             //ui_ChannelNumber = inl(devpriv->iobase+i_Offset + 24);
+       
+             /*************************************/
+             /*Read the digital analog input value*/
+             /*************************************/
+             //ui_DigitalInput = inl(devpriv->iobase+i_Offset + 28);
+             ui_DigitalInput = inl(devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 28);
+             
+             /***********************************************/
+             /* Test if the value read is the channel value */
+             /***********************************************/
+             if (i_CalibrationFlag == 0)
+               {
+                 //ui_InterruptChannelValue[i_Count + 0] = ui_DigitalInput;
+                 s_BoardInfos [dev->minor].ui_InterruptChannelValue[s_BoardInfos [dev->minor].i_Count + 0] = ui_DigitalInput;            
+                 
+                 //Begin JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values
+                 /*
+                   printk("\n 1 - i_APCI3200_GetChannelCalibrationValue (dev, s_BoardInfos %i", ui_ChannelNumber);
+                   i_APCI3200_GetChannelCalibrationValue (dev, s_BoardInfos [dev->minor].ui_Channel_num, 
+                   &s_BoardInfos [dev->minor].ui_InterruptChannelValue[s_BoardInfos [dev->minor].i_Count + 6], 
+                   &s_BoardInfos [dev->minor].ui_InterruptChannelValue[s_BoardInfos [dev->minor].i_Count + 7], 
+                   &s_BoardInfos [dev->minor].ui_InterruptChannelValue[s_BoardInfos [dev->minor].i_Count + 8]);
+                 */
+                 //End JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values
+
+                 /******************************************************/
+                 /*Start the conversion of the calibration offset value*/
+                 /******************************************************/
+                 i_APCI3200_ReadCalibrationOffsetValue(dev,&ui_DummyValue);
+               }//if (i_CalibrationFlag == 0)
+             /**********************************************************/
+             /* Test if the value read is the calibration offset value */
+             /**********************************************************/
+
+             if (i_CalibrationFlag == 1)
+               {
                 
-                 /******************/
-                 /* Save the value */
-                 /******************/
+                 /******************/
+                 /* Save the value */
+                 /******************/
               
-                 ui_InterruptChannelValue[i_Count + 1] = ui_DigitalInput;
-
-                 /******************************************************/
-                 /* Start the conversion of the calibration gain value */
-                 /******************************************************/
-                 i_APCI3200_ReadCalibrationGainValue(dev,&ui_DummyValue);
-                 }//if (i_CalibrationFlag == 1)
+                 //ui_InterruptChannelValue[i_Count + 1] = ui_DigitalInput;
+                 s_BoardInfos [dev->minor].ui_InterruptChannelValue[s_BoardInfos [dev->minor].i_Count + 1] = ui_DigitalInput;
+
+                 /******************************************************/
+                 /* Start the conversion of the calibration gain value */
+                 /******************************************************/
+                 i_APCI3200_ReadCalibrationGainValue(dev,&ui_DummyValue);
+               }//if (i_CalibrationFlag == 1)
               /******************************************************/
               /*Test if the value read is the calibration gain value*/
               /******************************************************/
@@ -2119,295 +3074,396 @@ switch(i_ScanType)
               if (i_CalibrationFlag == 2)
                 {
               
-                /****************/
-                /*Save the value*/
-                /****************/ 
-                ui_InterruptChannelValue[i_Count + 2] = ui_DigitalInput;
-                if(i_ScanType==1)
-                   { 
-
-                   i_InterruptFlag=0;
-                   i_Count=i_Count + 6;
-                   }//if(i_ScanType==1)
-                else
-                  {
-                  i_Count=0;
-                  }//elseif(i_ScanType==1)
-                if(i_ScanType!=1)
-                  { 
-
-                  send_sig(SIGIO,devpriv->tsk_Current,0); // send signal to the sample
-                  }//if(i_ScanType!=1)
-                else
-                  {
-                  if(i_ChannelCount==i_Sum)
-                    {
-
-                    send_sig(SIGIO,devpriv->tsk_Current,0); // send signal to the sample               
-                    }
-                  }//if(i_ScanType!=1)
+                 /****************/
+                 /*Save the value*/
+                 /****************/ 
+                 //ui_InterruptChannelValue[i_Count + 2] = ui_DigitalInput;
+                 s_BoardInfos [dev->minor].ui_InterruptChannelValue[s_BoardInfos [dev->minor].i_Count + 2] = ui_DigitalInput;
+                 //if(i_ScanType==1)
+                 if(s_BoardInfos [dev->minor].i_ScanType==1)
+                   { 
+
+                     //i_InterruptFlag=0;
+                     s_BoardInfos [dev->minor].i_InterruptFlag=0;
+                     //i_Count=i_Count + 6;
+                     //Begin JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values
+                     //s_BoardInfos [dev->minor].i_Count=s_BoardInfos [dev->minor].i_Count + 6;
+                     s_BoardInfos [dev->minor].i_Count=s_BoardInfos [dev->minor].i_Count + 9;
+                     //End JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values
+                   }//if(i_ScanType==1)
+                 else
+                   {
+                     //i_Count=0;
+                     s_BoardInfos [dev->minor].i_Count=0;
+                   }//elseif(i_ScanType==1)
+                 //if(i_ScanType!=1)
+                 if(s_BoardInfos [dev->minor].i_ScanType!=1)
+                   {                    
+                     i_ReturnValue = send_sig(SIGIO,devpriv->tsk_Current,0); // send signal to the sample                                                                  
+                   }//if(i_ScanType!=1)
+                 else
+                   {
+                     //if(i_ChannelCount==i_Sum)
+                     if(s_BoardInfos [dev->minor].i_ChannelCount==s_BoardInfos [dev->minor].i_Sum)
+                       {
+                         send_sig(SIGIO,devpriv->tsk_Current,0); // send signal to the sample               
+                       }
+                   }//if(i_ScanType!=1)
                 }//if (i_CalibrationFlag == 2)
-               }// if ((ui_StatusRegister & 0x2) == 0x2)  
-               break;
+           }// if ((ui_StatusRegister & 0x2) == 0x2)  
+           
+         break;
            
-          case 2: 
-                  /************************************/
-                  /*Read the interrupt status register*/
-                  /************************************/
-
-                 ui_StatusRegister = inl(devpriv->iobase+i_Offset + 16);
-                 /*************************/
-                 /*Test if interrupt occur*/
-                 /*************************/
+       case 2: 
+         /************************************/
+         /*Read the interrupt status register*/
+         /************************************/
+
+         //ui_StatusRegister = inl(devpriv->iobase+i_Offset + 16);
+         ui_StatusRegister = inl(devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 16);
+         /*************************/
+         /*Test if interrupt occur*/
+         /*************************/
      
 
-                if ((ui_StatusRegister & 0x2) == 0x2)
-                  {
+         if ((ui_StatusRegister & 0x2) == 0x2)
+           {
            
-                  i_CJCFlag = ((inl(devpriv->iobase+i_Offset + 4) & 0x00000400) >> 10);
+             //i_CJCFlag = ((inl(devpriv->iobase+i_Offset + 4) & 0x00000400) >> 10);
+             i_CJCFlag = ((inl(devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 4) & 0x00000400) >> 10);
 
-                  i_CalibrationFlag = ((inl(devpriv->iobase+i_Offset + 12) & 0x00060000) >> 17);
+             //i_CalibrationFlag = ((inl(devpriv->iobase+i_Offset + 12) & 0x00060000) >> 17);
+             i_CalibrationFlag = ((inl(devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 12) & 0x00060000) >> 17);
 
-                /*************************/
-                /*Read the channel number*/
-                /*************************/
+             /*************************/
+             /*Read the channel number*/
+             /*************************/
            
-                   ui_ChannelNumber = inl(devpriv->iobase+i_Offset + 24);
-
+             //ui_ChannelNumber = inl(devpriv->iobase+i_Offset + 24);
+             ui_ChannelNumber = inl(devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 24);
+             //Begin JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values
+             s_BoardInfos [dev->minor].ui_Channel_num = ui_ChannelNumber;
+             //End JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values
            
-                   /************************************/
-                   /*Read the digital temperature value*/
-                   /************************************/
-                   ui_DigitalTemperature = inl(devpriv->iobase+i_Offset + 28);
-
+             /************************************/
+             /*Read the digital temperature value*/
+             /************************************/
+             //ui_DigitalTemperature = inl(devpriv->iobase+i_Offset + 28);
+             ui_DigitalTemperature = inl(devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 28);             
            
-
-                   /*********************************************/
-                   /*Test if the value read is the channel value*/
-                   /*********************************************/
+             /*********************************************/
+             /*Test if the value read is the channel value*/
+             /*********************************************/
            
-
-                 if ((i_CalibrationFlag == 0) && (i_CJCFlag == 0))
-                    {
-                     ui_InterruptChannelValue[i_Count + 0]=ui_DigitalTemperature;
-
-                    /*********************************/
-                    /*Start the conversion of the CJC*/
-                    /*********************************/
-                    i_APCI3200_ReadCJCValue(dev,&ui_DummyValue);
-
-                    }//if ((i_CalibrationFlag == 0) && (i_CJCFlag == 0))
+             if ((i_CalibrationFlag == 0) && (i_CJCFlag == 0))
+               {
+                 //ui_InterruptChannelValue[i_Count + 0]=ui_DigitalTemperature;
+                 s_BoardInfos [dev->minor].ui_InterruptChannelValue[s_BoardInfos [dev->minor].i_Count + 0]=ui_DigitalTemperature;
+                 
+                 /*********************************/
+                 /*Start the conversion of the CJC*/
+                 /*********************************/
+                 i_APCI3200_ReadCJCValue(dev,&ui_DummyValue);
+
+               }//if ((i_CalibrationFlag == 0) && (i_CJCFlag == 0))
            
 
                  /*****************************************/
                  /*Test if the value read is the CJC value*/
                  /*****************************************/
            
-                if ((i_CJCFlag == 1) && (i_CalibrationFlag == 0))
-                   {
-                   ui_InterruptChannelValue[i_Count + 3]=ui_DigitalTemperature;
+             if ((i_CJCFlag == 1) && (i_CalibrationFlag == 0))
+               {
+                 //ui_InterruptChannelValue[i_Count + 3]=ui_DigitalTemperature;
+                 s_BoardInfos [dev->minor].ui_InterruptChannelValue[s_BoardInfos [dev->minor].i_Count + 3]=ui_DigitalTemperature;
 
               
-                /******************************************************/
-                /*Start the conversion of the calibration offset value*/
-                /******************************************************/
-                   i_APCI3200_ReadCalibrationOffsetValue(dev,&ui_DummyValue);
-                   }// if ((i_CJCFlag == 1) && (i_CalibrationFlag == 0))
+                 /******************************************************/
+                 /*Start the conversion of the calibration offset value*/
+                 /******************************************************/
+                 i_APCI3200_ReadCalibrationOffsetValue(dev,&ui_DummyValue);
+               }// if ((i_CJCFlag == 1) && (i_CalibrationFlag == 0))
            
 
                  /********************************************************/
                  /*Test if the value read is the calibration offset value*/
                  /********************************************************/
            
-                 if ((i_CalibrationFlag == 1) && (i_CJCFlag == 0))
-                    {
-                    ui_InterruptChannelValue[i_Count + 1]=ui_DigitalTemperature;
-
-                 /****************************************************/
-                 /*Start the conversion of the calibration gain value*/
-                 /****************************************************/
+             if ((i_CalibrationFlag == 1) && (i_CJCFlag == 0))
+               {
+                 //ui_InterruptChannelValue[i_Count + 1]=ui_DigitalTemperature;
+                 s_BoardInfos [dev->minor].ui_InterruptChannelValue[s_BoardInfos [dev->minor].i_Count + 1]=ui_DigitalTemperature;
+
+                 /****************************************************/
+                 /*Start the conversion of the calibration gain value*/
+                 /****************************************************/
                   i_APCI3200_ReadCalibrationGainValue(dev,&ui_DummyValue);
 
-                     }//if ((i_CalibrationFlag == 1) && (i_CJCFlag == 0))
+               }//if ((i_CalibrationFlag == 1) && (i_CJCFlag == 0))
            
 
-                    /******************************************************/
-                    /*Test if the value read is the calibration gain value*/
-                    /******************************************************/
+             /******************************************************/
+             /*Test if the value read is the calibration gain value*/
+             /******************************************************/
            
 
-                if ((i_CalibrationFlag == 2) && (i_CJCFlag == 0))
-                    {
-                    ui_InterruptChannelValue[i_Count + 2]=ui_DigitalTemperature;
+             if ((i_CalibrationFlag == 2) && (i_CJCFlag == 0))
+               {
+                 //ui_InterruptChannelValue[i_Count + 2]=ui_DigitalTemperature;
+                 s_BoardInfos [dev->minor].ui_InterruptChannelValue[s_BoardInfos [dev->minor].i_Count + 2]=ui_DigitalTemperature;
 
-                   /**********************************************************/
-                   /*Test if the Calibration channel must be read for the CJC*/
-                   /**********************************************************/
+                 /**********************************************************/
+                 /*Test if the Calibration channel must be read for the CJC*/
+                 /**********************************************************/
               
-                    /*Test if the polarity is the same*/
-                    /**********************************/                                     
-                    if(i_CJCPolarity!=i_ADDIDATAPolarity)
-                       {
-                       i_ConvertCJCCalibration=1;
-                       }//if(i_CJCPolarity!=i_ADDIDATAPolarity)
-                    else 
-                       {
-                       if(i_CJCGain==i_ADDIDATAGain) 
-                          {
+                 /*Test if the polarity is the same*/
+                 /**********************************/                                     
+                 //if(i_CJCPolarity!=i_ADDIDATAPolarity)
+                  if(s_BoardInfos [dev->minor].i_CJCPolarity!=s_BoardInfos [dev->minor].i_ADDIDATAPolarity) 
+                   {
+                     i_ConvertCJCCalibration=1;
+                   }//if(i_CJCPolarity!=i_ADDIDATAPolarity)
+                 else 
+                   {
+                     //if(i_CJCGain==i_ADDIDATAGain) 
+                     if(s_BoardInfos [dev->minor].i_CJCGain==s_BoardInfos [dev->minor].i_ADDIDATAGain) 
+                       {
                           i_ConvertCJCCalibration=0;
-                          }//if(i_CJCGain==i_ADDIDATAGain)
-                       else
-                          {
-                           i_ConvertCJCCalibration=1;
-                          }//elseif(i_CJCGain==i_ADDIDATAGain)
-                        }//elseif(i_CJCPolarity!=i_ADDIDATAPolarity)          
-                    if(i_ConvertCJCCalibration==1)
-                       {
-                       /****************************************************************/
-                       /*Start the conversion of the calibration gain value for the CJC*/
-                       /****************************************************************/
-                       i_APCI3200_ReadCJCCalOffset(dev,&ui_DummyValue);
+                       }//if(i_CJCGain==i_ADDIDATAGain)
+                     else
+                       {
+                         i_ConvertCJCCalibration=1;
+                       }//elseif(i_CJCGain==i_ADDIDATAGain)
+                   }//elseif(i_CJCPolarity!=i_ADDIDATAPolarity)          
+                 if(i_ConvertCJCCalibration==1)
+                   {
+                     /****************************************************************/
+                     /*Start the conversion of the calibration gain value for the CJC*/
+                     /****************************************************************/
+                     i_APCI3200_ReadCJCCalOffset(dev,&ui_DummyValue);
  
-                       }//if(i_ConvertCJCCalibration==1)
-                    else
-                       {
-                       ui_InterruptChannelValue[i_Count + 4]=0;
-                       ui_InterruptChannelValue[i_Count + 5]=0;
-
-                     }//elseif(i_ConvertCJCCalibration==1)
-                  }//else if ((i_CalibrationFlag == 2) && (i_CJCFlag == 0))
+                   }//if(i_ConvertCJCCalibration==1)
+                 else
+                   {
+                     //ui_InterruptChannelValue[i_Count + 4]=0;
+                     //ui_InterruptChannelValue[i_Count + 5]=0;
+                     s_BoardInfos [dev->minor].ui_InterruptChannelValue[s_BoardInfos [dev->minor].i_Count + 4]=0;
+                     s_BoardInfos [dev->minor].ui_InterruptChannelValue[s_BoardInfos [dev->minor].i_Count + 5]=0;
+                   }//elseif(i_ConvertCJCCalibration==1)
+               }//else if ((i_CalibrationFlag == 2) && (i_CJCFlag == 0))
 
                  /********************************************************************/
                  /*Test if the value read is the calibration offset value for the CJC*/
                  /********************************************************************/
            
 
-                if ((i_CalibrationFlag == 1) && (i_CJCFlag == 1))
-                  {
-                  ui_InterruptChannelValue[i_Count + 4]=ui_DigitalTemperature; 
+             if ((i_CalibrationFlag == 1) && (i_CJCFlag == 1))
+               {
+                  //ui_InterruptChannelValue[i_Count + 4]=ui_DigitalTemperature; 
+                 s_BoardInfos [dev->minor].ui_InterruptChannelValue[s_BoardInfos [dev->minor].i_Count + 4]=ui_DigitalTemperature; 
 
                   /****************************************************************/
                   /*Start the conversion of the calibration gain value for the CJC*/
                   /****************************************************************/
                   i_APCI3200_ReadCJCCalGain(dev,&ui_DummyValue);
           
-                  }//if ((i_CalibrationFlag == 1) && (i_CJCFlag == 1))
+               }//if ((i_CalibrationFlag == 1) && (i_CJCFlag == 1))
            
 
-               /******************************************************************/
-               /*Test if the value read is the calibration gain value for the CJC*/
-               /******************************************************************/
+             /******************************************************************/
+             /*Test if the value read is the calibration gain value for the CJC*/
+             /******************************************************************/
           
 
-               if ((i_CalibrationFlag == 2) && (i_CJCFlag == 1))
-                  {
-                   ui_InterruptChannelValue[i_Count + 5]=ui_DigitalTemperature;  
-
-                  if(i_ScanType==1)
-                     { 
-
-                     i_InterruptFlag=0;
-                     i_Count=i_Count + 6;
-                     }//if(i_ScanType==1)
+             if ((i_CalibrationFlag == 2) && (i_CJCFlag == 1))
+               {
+                 //ui_InterruptChannelValue[i_Count + 5]=ui_DigitalTemperature;  
+                 s_BoardInfos [dev->minor].ui_InterruptChannelValue[s_BoardInfos [dev->minor].i_Count + 5]=ui_DigitalTemperature;  
+
+                  //if(i_ScanType==1)
+                 if(s_BoardInfos [dev->minor].i_ScanType==1)
+                   { 
+
+                     //i_InterruptFlag=0;
+                     s_BoardInfos [dev->minor].i_InterruptFlag=0;
+                     //i_Count=i_Count + 6;
+                     //Begin JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values        
+                     //s_BoardInfos [dev->minor].i_Count=s_BoardInfos [dev->minor].i_Count + 6;
+                     s_BoardInfos [dev->minor].i_Count=s_BoardInfos [dev->minor].i_Count + 9;
+                     //End JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values          
+                   }//if(i_ScanType==1)
                   else
-                     {
-                     i_Count=0;
-                     }//elseif(i_ScanType==1)
-                  if(i_ScanType!=1)
+                   {
+                     //i_Count=0;
+                     s_BoardInfos [dev->minor].i_Count=0;
+                   }//elseif(i_ScanType==1)
+                  
+                 //if(i_ScanType!=1)
+                 if(s_BoardInfos [dev->minor].i_ScanType!=1)
                     { 
-                    
-                    send_sig(SIGIO,devpriv->tsk_Current,0); // send signal to the sample
+                     send_sig(SIGIO,devpriv->tsk_Current,0); // send signal to the sample
                     }//if(i_ScanType!=1)
                   else
                     {
-                    if(i_ChannelCount==i_Sum)
-                      {
-                      send_sig(SIGIO,devpriv->tsk_Current,0); // send signal to the sample
+                     //if(i_ChannelCount==i_Sum)
+                     if(s_BoardInfos [dev->minor].i_ChannelCount==s_BoardInfos [dev->minor].i_Sum)
+                       {
+                         send_sig(SIGIO,devpriv->tsk_Current,0); // send signal to the sample
                                   
-                      }//if(i_ChannelCount==i_Sum)
+                       }//if(i_ChannelCount==i_Sum)
                     }//else if(i_ScanType!=1) 
-                  }//if ((i_CalibrationFlag == 2) && (i_CJCFlag == 1))
-
-                }//else if ((ui_StatusRegister & 0x2) == 0x2)
-                break;
-              }//switch(i_ADDIDATAType) 
-              break;
-     case 2:
-     case 3:
-             i_APCI3200_InterruptHandleEos(dev);
-             break;
-           }//switch(i_ScanType)        
-return;
+               }//if ((i_CalibrationFlag == 2) && (i_CJCFlag == 1))
+
+           }//else if ((ui_StatusRegister & 0x2) == 0x2)
+         break;
+       }//switch(i_ADDIDATAType) 
+      break;
+    case 2:
+    case 3:
+      i_APCI3200_InterruptHandleEos(dev);
+      break;
+    }//switch(i_ScanType)        
+  return;
 }
 
 
 
 /*
-+----------------------------------------------------------------------------+
-| Function name     :int i_APCI3200_InterruptHandleEos(comedi_device *dev)   |
-|                                                                                                               |
-|                                                                                               |
-+----------------------------------------------------------------------------+
-| Task              : .                   |
-|                     This function copies the acquired data(from FIFO)      |
-|                              to Comedi buffer.                                                                        |
-|                                                                                                               |
-+----------------------------------------------------------------------------+
-| Input Parameters  : comedi_device *dev                                                                        |
-|                                                                                                                               |
-|                                                                                               |
-+----------------------------------------------------------------------------+
-| Return Value      : 0                                                                         |
-|                                                                                                                           |
-+----------------------------------------------------------------------------+
+  +----------------------------------------------------------------------------+
+  | Function name     :int i_APCI3200_InterruptHandleEos(comedi_device *dev)   |
+  |                                                                                                             |
+  |                                                                                                     |
+  +----------------------------------------------------------------------------+
+  | Task              : .                   |
+  |                     This function copies the acquired data(from FIFO)      |
+  |                            to Comedi buffer.                                                                        |
+  |                                                                                                                     |
+  +----------------------------------------------------------------------------+
+  | Input Parameters  : comedi_device *dev                                                                      |
+  |                                                                                                                                     |
+  |                                                                                             |
+  +----------------------------------------------------------------------------+
+  | Return Value      : 0                                                                       |
+  |                                                                                                                                 |
+  +----------------------------------------------------------------------------+
 */
 int i_APCI3200_InterruptHandleEos(comedi_device *dev)
 {  
-       UINT ui_StatusRegister=0;
-       UINT ui_ChannelNumber = 0;
-       UINT *data;
-       comedi_subdevice *s=dev->subdevices+0;
-       comedi_async *async = s->async;
-        data=async->data+async->buf_int_ptr;//new samples added from here onwards
+  UINT ui_StatusRegister=0;  
+  comedi_subdevice *s=dev->subdevices+0;
+
+  //BEGIN JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68
+  //comedi_async *async = s->async;
+  //UINT *data;  
+  //data=async->data+async->buf_int_ptr;//new samples added from here onwards
+  int n = 0, i = 0;
+  //END JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68
        
-           /************************************/
-           /*Read the interrupt status register*/
-           /************************************/
-           ui_StatusRegister = inl(devpriv->iobase+i_Offset + 16);
-           /*************************/
-           /*Test if interrupt occur*/
-           /*************************/
+  /************************************/
+  /*Read the interrupt status register*/
+  /************************************/
+  //ui_StatusRegister = inl(devpriv->iobase+i_Offset + 16);
+  ui_StatusRegister = inl(devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 16);
+    
+  /*************************/
+  /*Test if interrupt occur*/
+  /*************************/
         
-          if ((ui_StatusRegister & 0x2) == 0x2)
-            {
-           /*************************/
-           /*Read the channel number*/
-           /*************************/
-            ui_ChannelNumber = inl(devpriv->iobase+i_Offset + 24);
-
-           /*************************************/
-           /*Read the digital Analog Input value*/
-           /*************************************/
-
-           data[i_Count] = inl(devpriv->iobase+i_Offset + 28);
-//           printk("\ndata[%d]=%x\n",i_Count,data[i_Count]);
-            if((i_Count == (i_LastChannel-i_FirstChannel+3)))
-             {
-               i_Count=-1; 
-             async->buf_int_count+=(i_LastChannel-i_FirstChannel+4)*sizeof(UINT);
-             async->buf_int_ptr+=(i_LastChannel-i_FirstChannel+4)*sizeof(UINT);
-             comedi_eos(dev,s);
-             if (s->async->buf_int_ptr>=s->async->data_len) //  for buffer rool over  
-              { 
-               /* buffer rollover */
-               s->async->buf_int_ptr=0;
-               comedi_eobuf(dev,s);
-              }
-            }  
-           i_Count++;
-            }
-        i_InterruptFlag=0;
-       return 0;
+  if ((ui_StatusRegister & 0x2) == 0x2)
+    {
+      /*************************/
+      /*Read the channel number*/
+      /*************************/
+      //ui_ChannelNumber = inl(devpriv->iobase+i_Offset + 24);
+      //BEGIN JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68
+      //This value is not used      
+      //ui_ChannelNumber = inl(devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 24);
+      s->async->events = 0;
+      //END JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68
+
+      /*************************************/
+      /*Read the digital Analog Input value*/
+      /*************************************/
+
+      //data[i_Count] = inl(devpriv->iobase+i_Offset + 28);
+      //Begin JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68
+      //data[s_BoardInfos [dev->minor].i_Count] = inl(devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 28);
+      s_BoardInfos [dev->minor].ui_ScanValueArray [s_BoardInfos [dev->minor].i_Count] = inl(devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 28);
+      //End JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68
+      
+      //if((i_Count == (i_LastChannel-i_FirstChannel+3)))
+      if((s_BoardInfos [dev->minor].i_Count == (s_BoardInfos [dev->minor].i_LastChannel-s_BoardInfos [dev->minor].i_FirstChannel+3)))
+       {
+       
+         //Begin JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values 
+         s_BoardInfos [dev->minor].i_Count++;
+
+         for (i=s_BoardInfos [dev->minor].i_FirstChannel; i<=s_BoardInfos [dev->minor].i_LastChannel; i++)
+           {      
+             i_APCI3200_GetChannelCalibrationValue (dev, i, 
+                                                    &s_BoardInfos [dev->minor].ui_ScanValueArray [s_BoardInfos [dev->minor].i_Count + 
+                                                                                                  ((i-s_BoardInfos [dev->minor].i_FirstChannel)*3)], 
+                                                    &s_BoardInfos [dev->minor].ui_ScanValueArray [s_BoardInfos [dev->minor].i_Count + 
+                                                                                                  ((i-s_BoardInfos [dev->minor].i_FirstChannel)*3) + 1], 
+                                                    &s_BoardInfos [dev->minor].ui_ScanValueArray [s_BoardInfos [dev->minor].i_Count + 
+                                                                                                  ((i-s_BoardInfos [dev->minor].i_FirstChannel)*3) + 2]);
+           }
+          
+         //End JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values
+       
+         //i_Count=-1; 
+       
+         s_BoardInfos [dev->minor].i_Count=-1; 
+       
+         //async->buf_int_count+=(i_LastChannel-i_FirstChannel+4)*sizeof(UINT);
+         //Begin JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68
+         //async->buf_int_count+=(s_BoardInfos [dev->minor].i_LastChannel-s_BoardInfos [dev->minor].i_FirstChannel+4)*sizeof(UINT);
+         //End JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68
+         //async->buf_int_ptr+=(i_LastChannel-i_FirstChannel+4)*sizeof(UINT);
+         //Begin JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68
+         //async->buf_int_ptr+=(s_BoardInfos [dev->minor].i_LastChannel-s_BoardInfos [dev->minor].i_FirstChannel+4)*sizeof(UINT);
+         //comedi_eos(dev,s);
+               
+         // Set the event type (Comedi Buffer End Of Scan) 
+         s->async->events |= COMEDI_CB_EOS;            
+       
+         // Test if enougth memory is available and allocate it for 7 values
+         //n = comedi_buf_write_alloc(s->async, 7*sizeof(lsampl_t));
+         n = comedi_buf_write_alloc(s->async, (7+12)*sizeof(lsampl_t));
+        
+         // If not enougth memory available, event is set to Comedi Buffer Errror         
+         if (n > ((7+12)*sizeof(lsampl_t)))
+           {
+             printk ("\ncomedi_buf_write_alloc n = %i", n);
+             s->async->events |= COMEDI_CB_ERROR;
+           } 
+              
+         // Write all 7 scan values in the comedi buffer   
+         comedi_buf_memcpy_to(s->async, 0, (lsampl_t*)s_BoardInfos [dev->minor].ui_ScanValueArray, (7+12)*sizeof(lsampl_t));
+       
+         // Update comedi buffer pinters indexes
+         comedi_buf_write_free(s->async, (7+12)*sizeof(lsampl_t));     
+
+         // Send events
+         comedi_event(dev,s,s->async->events);           
+         //End JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68
+
+         //BEGIN JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68         
+         //
+         //if (s->async->buf_int_ptr>=s->async->data_len) //  for buffer rool over  
+         //  { 
+         //    /* buffer rollover */
+         //    s->async->buf_int_ptr=0;
+         //    comedi_eobuf(dev,s);
+         //  } 
+         //End JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68
+       }  
+      //i_Count++;
+      s_BoardInfos [dev->minor].i_Count++;     
+    }
+  //i_InterruptFlag=0;
+  s_BoardInfos [dev->minor].i_InterruptFlag=0;
+  return 0;
 }  
 
 
index 8b12313131a47845ddb736ed23ac3aea81a33a45..50e6f2683aff0adb2d3cbc2832bc3ff4aec6ae78 100644 (file)
@@ -1,39 +1,71 @@
+/**\r
+@verbatim\r
+\r
+Copyright (C) 2004,2005  ADDI-DATA GmbH for the source code of this module. \r
+        \r
+        ADDI-DATA GmbH \r
+        Dieselstrasse 3 \r
+        D-77833 Ottersweier \r
+        Tel: +19(0)7223/9493-0 \r
+        Fax: +49(0)7223/9493-92 \r
+        http://www.addi-data-com \r
+        info@addi-data.com \r
+\r
+This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.\r
+\r
+This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.\r
+\r
+You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+\r
+You shoud also find the complete GPL in the COPYING file accompanying this source code.\r
+\r
+@endverbatim\r
+*/\r
+\r
 // Card Specific information\r
 #define APCI3200_BOARD_VENDOR_ID                 0x15B8\r
 //#define APCI3200_ADDRESS_RANGE                   264\r
-
-
-
-int MODULE_NO ;
- struct 
-{                              
- INT i_Gain ;
- INT i_Polarity;
- INT i_OffsetRange;
- INT i_Coupling;
- INT i_SingleDiff;
- INT i_AutoCalibration;
- UINT ui_ReloadValue;
- UINT ui_TimeUnitReloadVal;
- INT i_Interrupt;
- INT i_ModuleSelection;
-}Config_Parameters_Module1,Config_Parameters_Module2,Config_Parameters_Module3,Config_Parameters_Module4;
-
-
-
-//ANALOG INPUT RANGE 
-comedi_lrange range_apci3200_ai={ 8, {
-               BIP_RANGE(10),
-               BIP_RANGE(5),
-               BIP_RANGE(2),
-               BIP_RANGE(1),
-               UNI_RANGE(10),
-               UNI_RANGE(5),
-               UNI_RANGE(2),
-               UNI_RANGE(1)
-       }
-};
-
+\r
+\r
+\r
+int MODULE_NO ;\r
+ struct \r
+{                              \r
+ INT i_Gain ;\r
+ INT i_Polarity;\r
+ INT i_OffsetRange;\r
+ INT i_Coupling;\r
+ INT i_SingleDiff;\r
+ INT i_AutoCalibration;\r
+ UINT ui_ReloadValue;\r
+ UINT ui_TimeUnitReloadVal;\r
+ INT i_Interrupt;\r
+ INT i_ModuleSelection;\r
+}Config_Parameters_Module1,Config_Parameters_Module2,Config_Parameters_Module3,Config_Parameters_Module4;\r
+\r
+\r
+\r
+//ANALOG INPUT RANGE \r
+comedi_lrange range_apci3200_ai={ 8, {\r
+               BIP_RANGE(10),\r
+               BIP_RANGE(5),\r
+               BIP_RANGE(2),\r
+               BIP_RANGE(1),\r
+               UNI_RANGE(10),\r
+               UNI_RANGE(5),\r
+               UNI_RANGE(2),\r
+               UNI_RANGE(1)\r
+       }\r
+};\r
+\r
+comedi_lrange range_apci3300_ai={ 4, {\r
+               UNI_RANGE(10),\r
+               UNI_RANGE(5),\r
+               UNI_RANGE(2),\r
+               UNI_RANGE(1)\r
+       }\r
+};\r
+\r
 //Analog Input related Defines\r
 #define APCI3200_AI_OFFSET_GAIN                  0\r
 #define APCI3200_AI_SC_TEST                      4\r
@@ -47,8 +79,8 @@ comedi_lrange range_apci3200_ai={ 8, {
 #define APCI3200_AI_MODULE2                      64\r
 #define APCI3200_AI_MODULE3                      128\r
 #define APCI3200_AI_MODULE4                      192\r
-#define TRUE                                     1
-#define FALSE                                    0
+#define TRUE                                     1\r
+#define FALSE                                    0\r
 #define APCI3200_AI_EOSIRQ                       16\r
 #define APCI3200_AI_EOS                          20\r
 #define APCI3200_AI_CHAN_ID                      24\r
@@ -72,38 +104,95 @@ comedi_lrange range_apci3200_ai={ 8, {
 //ADDIDATA Enable Disable\r
 #define ADDIDATA_ENABLE                            1\r
 #define ADDIDATA_DISABLE                           0\r
-
-typedef struct
-   {
-   ULONG ul_NumberOfValue;
-   ULONG *pul_ResistanceValue;
-   ULONG *pul_TemperatureValue;
-   }str_ADDIDATA_RTDStruct,*pstr_ADDIDATA_RTDStruct;
+\r
+//BEGIN JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values\r
+#define MAX_MODULE                             4\r
+//END JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values\r
+\r
+typedef struct\r
+   {\r
+   ULONG ul_NumberOfValue;\r
+   ULONG *pul_ResistanceValue;\r
+   ULONG *pul_TemperatureValue;\r
+   }str_ADDIDATA_RTDStruct,*pstr_ADDIDATA_RTDStruct;\r
+\r
+//BEGIN JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values\r
+typedef struct\r
+   {\r
+   // Begin JK 05/08/2003 change for Linux    \r
+   unsigned long ul_CurrentSourceCJC;\r
+   unsigned long ul_CurrentSource [5];\r
+   // End JK 05/08/2003 change for Linux\r
+\r
+   // Begin CG 15/02/02 Rev 1.0 -> Rev 1.1 : Add Header Type 1\r
+   unsigned long  ul_GainFactor [8]; // Gain Factor \r
+   unsigned int w_GainValue [10];\r
+   // End CG 15/02/02 Rev 1.0 -> Rev 1.1 : Add Header Type 1\r
+   }str_Module;\r
+//END JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values\r
+   \r
+//BEGIN JK 06.07.04: Management of sevrals boards\r
+typedef struct \r
+   {\r
+   INT i_CJCAvailable; \r
+   INT i_CJCPolarity;\r
+   INT i_CJCGain;\r
+   INT i_InterruptFlag;\r
+   INT i_ADDIDATAPolarity;\r
+   INT i_ADDIDATAGain;                  \r
+   INT i_AutoCalibration;\r
+   INT i_ADDIDATAConversionTime;\r
+   INT i_ADDIDATAConversionTimeUnit; \r
+   INT i_ADDIDATAType;\r
+   INT i_ChannelNo;\r
+   INT i_ChannelCount;\r
+   INT i_ScanType;\r
+   INT i_FirstChannel;\r
+   INT i_LastChannel;\r
+   INT i_Sum;\r
+   INT i_Offset;\r
+   UINT ui_Channel_num;\r
+   INT i_Count;\r
+   INT i_Initialised;\r
+   //UINT ui_InterruptChannelValue[96]; //Buffer\r
+   UINT ui_InterruptChannelValue[144]; //Buffer\r
+   BYTE b_StructInitialized;\r
+   //Begin JK 19.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68\r
+   lsampl_t ui_ScanValueArray [7+12]; // 7 is the maximal number of channels\r
+   //End JK 19.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68\r
+   \r
+   //Begin JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values   \r
+   INT i_ConnectionType;\r
+   INT     i_NbrOfModule;\r
+   str_Module s_Module [MAX_MODULE];\r
+   //End JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values\r
+   } str_BoardInfos;\r
+//END JK 06.07.04: Management of sevrals boards\r
 \r
 \r
 // Hardware Layer  functions for Apci3200\r
 \r
 //AI\r
-
+\r
 INT i_APCI3200_ConfigAnalogInput(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data);\r
 INT i_APCI3200_ReadAnalogInput(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data);\r
-INT i_APCI3200_InsnWriteReleaseAnalogInput(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data);
-INT i_APCI3200_InsnBits_AnalogInput_Test(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data); 
-INT i_APCI3200_StopCyclicAcquisition(comedi_device *dev,comedi_subdevice *s);
-INT i_APCI3200_InterruptHandleEos(comedi_device *dev);
-INT i_APCI3200_CommandTestAnalogInput(comedi_device *dev,comedi_subdevice *s,comedi_cmd *cmd) ;
-INT i_APCI3200_CommandAnalogInput(comedi_device *dev,comedi_subdevice *s);
-INT i_APCI3200_ReadDigitalInput(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data);
+INT i_APCI3200_InsnWriteReleaseAnalogInput(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data);\r
+INT i_APCI3200_InsnBits_AnalogInput_Test(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data); \r
+INT i_APCI3200_StopCyclicAcquisition(comedi_device *dev,comedi_subdevice *s);\r
+INT i_APCI3200_InterruptHandleEos(comedi_device *dev);\r
+INT i_APCI3200_CommandTestAnalogInput(comedi_device *dev,comedi_subdevice *s,comedi_cmd *cmd) ;\r
+INT i_APCI3200_CommandAnalogInput(comedi_device *dev,comedi_subdevice *s);\r
+INT i_APCI3200_ReadDigitalInput(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data);\r
 //Interrupt\r
 void v_APCI3200_Interrupt(int irq, void *d, struct pt_regs *regs) ;\r
 int i_APCI3200_InterruptHandleEos(comedi_device *dev);\r
 //Reset functions\r
 INT i_APCI3200_Reset(comedi_device *dev);      \r
-
-
+\r
+\r
 int i_APCI3200_ReadCJCCalOffset(comedi_device *dev,lsampl_t *data);\r
 int i_APCI3200_ReadCJCValue(comedi_device *dev,lsampl_t *data);\r
 int i_APCI3200_ReadCalibrationGainValue(comedi_device *dev,UINT *data);\r
-int i_APCI3200_ReadCalibrationOffsetValue(comedi_device *dev,UINT *data);
-int i_APCI3200_Read1AnalogInputChannel(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data);
+int i_APCI3200_ReadCalibrationOffsetValue(comedi_device *dev,UINT *data);\r
+int i_APCI3200_Read1AnalogInputChannel(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data);\r
 int i_APCI3200_ReadCJCCalGain(comedi_device *dev,lsampl_t *data);\r
index a58502925388270ac41b8cf16d551e4eac1664df..eed480e179a07ff2a45a1f7549b83acdf8f9e203 100644 (file)
@@ -1,14 +1,38 @@
-/*
+/**
+@verbatim
+
+Copyright (C) 2004,2005  ADDI-DATA GmbH for the source code of this module. 
+        
+        ADDI-DATA GmbH 
+        Dieselstrasse 3 
+        D-77833 Ottersweier 
+        Tel: +19(0)7223/9493-0 
+        Fax: +49(0)7223/9493-92 
+        http://www.addi-data-com 
+        info@addi-data.com 
+
+This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+You shoud also find the complete GPL in the COPYING file accompanying this source code.
+
+@endverbatim
+*/
+/*.
+    
   +-----------------------------------------------------------------------+
   | (C) ADDI-DATA GmbH          Dieselstraße 3       D-77833 Ottersweier  |
   +-----------------------------------------------------------------------+
   | Tel : +49 (0) 7223/9493-0     | email    : info@addi-data.com         |
   | Fax : +49 (0) 7223/9493-92    | Internet : http://www.addi-data.com   |
   +-------------------------------+---------------------------------------+
-  | Project     : 13Card Linux Driver | Compiler   : GCC                  |
-  | Module name : hwdrv_apci3501.c|     Version    : 2.96                 |
+  | Project     : APCI-3501       | Compiler   : GCC                      |
+  | Module name : hwdrv_apci3501.c| Version    : 2.96                     |
   +-------------------------------+---------------------------------------+
-  | Author : Shitalkumar S Chavan |     Date       : 10.12.2001           |
+  | Project manager: Eric Stolz   | Date       :  02/12/2002              |
   +-------------------------------+---------------------------------------+
   | Description :   Hardware Layer Acces For APCI-3501                    |
   +-----------------------------------------------------------------------+
index 957abae5abea0568800c8e60b5283ca59f27ffe7..1797eb6bf14aa8de73788f8f05a41fac5b2aadc7 100644 (file)
@@ -1,3 +1,26 @@
+/**
+@verbatim
+
+Copyright (C) 2004,2005  ADDI-DATA GmbH for the source code of this module. 
+        
+        ADDI-DATA GmbH 
+        Dieselstrasse 3 
+        D-77833 Ottersweier 
+        Tel: +19(0)7223/9493-0 
+        Fax: +49(0)7223/9493-92 
+        http://www.addi-data-com 
+        info@addi-data.com 
+
+This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+You shoud also find the complete GPL in the COPYING file accompanying this source code.
+
+@endverbatim
+*/
 // Card Specific information
 #define APCI3501_BOARD_VENDOR_ID                 0x15B8
 #define APCI3501_ADDRESS_RANGE                   255
diff --git a/comedi/drivers/addi-data/hwdrv_apci3xxx.c b/comedi/drivers/addi-data/hwdrv_apci3xxx.c
new file mode 100755 (executable)
index 0000000..d1705d0
--- /dev/null
@@ -0,0 +1,1771 @@
+/**
+@verbatim
+
+Copyright (C) 2004,2005  ADDI-DATA GmbH for the source code of this module. 
+        
+        ADDI-DATA GmbH 
+        Dieselstrasse 3 
+        D-77833 Ottersweier 
+        Tel: +19(0)7223/9493-0 
+        Fax: +49(0)7223/9493-92 
+        http://www.addi-data-com 
+        info@addi-data.com 
+
+This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+You shoud also find the complete GPL in the COPYING file accompanying this source code.
+
+
+
+@endverbatim
+*/
+/*
+  +-----------------------------------------------------------------------+
+  | (C) ADDI-DATA GmbH          Dieselstrasse 3      D-77833 Ottersweier  |
+  +-----------------------------------------------------------------------+
+  | Tel : +49 (0) 7223/9493-0     | email    : info@addi-data.com         |
+  | Fax : +49 (0) 7223/9493-92    | Internet : http://www.addi-data.com   |
+  +-----------------------------------------------------------------------+
+  | Project     : APCI-3XXX       | Compiler   : GCC                      |
+  | Module name : hwdrv_apci3xxx.c| Version    : 2.96                     |
+  +-------------------------------+---------------------------------------+
+  | Project manager: S. Weber     | Date       :  15/09/2005              |
+  +-----------------------------------------------------------------------+
+  | Description :APCI3XXX Module.  Hardware abstraction Layer for APCI3XXX|
+  +-----------------------------------------------------------------------+
+  |                             UPDATE'S                                  |
+  +-----------------------------------------------------------------------+
+  |   Date   |   Author  |          Description of updates                |
+  +----------+-----------+------------------------------------------------+
+  |          |                  |                                                |
+  |          |           |                                               |
+  +----------+-----------+------------------------------------------------+
+*/
+
+
+#include "hwdrv_apci3xxx.h"
+
+
+/*
++----------------------------------------------------------------------------+
+|                         ANALOG INPUT FUNCTIONS                             |
++----------------------------------------------------------------------------+
+*/
+
+/*
++----------------------------------------------------------------------------+
+| Function Name     : INT   i_APCI3XXX_TestConversionStarted                 |
+|                          (comedi_device    *dev)                           |
++----------------------------------------------------------------------------+
+| Task                Test if any conversion started                         |
++----------------------------------------------------------------------------+
+| Input Parameters  : -                                                      |
++----------------------------------------------------------------------------+
+| Output Parameters : -                                                      |
++----------------------------------------------------------------------------+
+| Return Value      : 0 : Conversion not started                             |
+|                     1 : Conversion started                                 |
++----------------------------------------------------------------------------+
+*/
+
+int    i_APCI3XXX_TestConversionStarted (comedi_device *dev) 
+       {
+       if ((readl ((void *) (devpriv->dw_AiBase + 8)) & 0x80000UL) == 0x80000UL)
+          {
+          return (1);
+          }
+       else
+          {
+          return (0);
+          }
+       }
+
+
+/*
++----------------------------------------------------------------------------+
+| Function Name     : INT   i_APCI3XXX_AnalogInputConfigOperatingMode        |
+|                          (comedi_device    *dev,                           |
+|                           comedi_subdevice *s,                             |
+|                           comedi_insn      *insn,                          |
+|                           lsampl_t         *data)                          |
++----------------------------------------------------------------------------+
+| Task           Converting mode and convert time selection                  |
++----------------------------------------------------------------------------+
+| Input Parameters  : b_SingleDiff  = (BYTE)  data[1];                       |
+|                     b_TimeBase    = (BYTE)  data[2]; (0: ns, 1:micros 2:ms)|
+|                    dw_ReloadValue = (DWORD) data[3];                       |
+|                     ........                                               |
++----------------------------------------------------------------------------+
+| Output Parameters : -                                                      |
++----------------------------------------------------------------------------+
+| Return Value      :>0 : No error                                           |
+|                    -1 : Single/Diff selection error                        |
+|                    -2 : Convert time base unity selection error            |
+|                    -3 : Convert time value selection error                 |
+|                    -10: Any conversion started                             |
+|                    ....                                                    |
+|                    -100 : Config command error                             |
+|                    -101 : Data size error                                  |
++----------------------------------------------------------------------------+
+*/
+
+int   i_APCI3XXX_AnalogInputConfigOperatingMode (comedi_device    *dev,
+                                                 comedi_subdevice *s,
+                                                 comedi_insn      *insn,
+                                                 lsampl_t         *data) 
+       {
+       INT        i_ReturnValue              = insn->n;
+       BYTE       b_TimeBase                 = 0;
+       BYTE       b_SingleDiff               = 0;
+       DWORD     dw_ReloadValue              = 0;
+       DWORD     dw_TestReloadValue          = 0;
+       
+       /************************/
+       /* Test the buffer size */
+       /************************/
+       
+       if (insn->n == 4)
+          {
+          /****************************/
+          /* Get the Singel/Diff flag */
+          /****************************/
+          
+          b_SingleDiff = (BYTE) data[1];
+          
+          /****************************/
+          /* Get the time base unitiy */
+          /****************************/
+          
+          b_TimeBase = (BYTE) data[2];
+          
+          /*************************************/
+          /* Get the convert time reload value */
+          /*************************************/
+          
+          dw_ReloadValue = (DWORD) data[3];
+       
+          /**********************/
+          /* Test the time base */
+          /**********************/
+                
+          if ((devpriv->ps_BoardInfo->b_AvailableConvertUnit & (1 << b_TimeBase)) != 0)
+             {
+             /*******************************/
+             /* Test the convert time value */
+             /*******************************/
+                   
+             if ((dw_ReloadValue >= 0) && (dw_ReloadValue <= 65535))
+                {
+                dw_TestReloadValue = dw_ReloadValue;
+                    
+                if (b_TimeBase == 1)
+                   {
+                   dw_TestReloadValue = dw_TestReloadValue * 1000UL;
+                   }
+                if (b_TimeBase == 2)
+                   {
+                   dw_TestReloadValue = dw_TestReloadValue * 1000000UL;
+                   }
+                         
+                /*******************************/
+                /* Test the convert time value */
+                /*******************************/
+                   
+                if (dw_TestReloadValue >= devpriv->ps_BoardInfo->ui_MinAcquisitiontimeNs)
+                   {
+                   if ((b_SingleDiff == APCI3XXX_SINGLE) || (b_SingleDiff == APCI3XXX_DIFF))
+                       {
+                       if (((b_SingleDiff == APCI3XXX_SINGLE) && (devpriv->ps_BoardInfo->i_NbrAiChannel == 0)) || 
+                           ((b_SingleDiff == APCI3XXX_DIFF)   && (devpriv->ps_BoardInfo->i_NbrAiChannelDiff == 0)))
+                          {
+                          /*******************************/
+                          /* Single/Diff selection error */
+                          /*******************************/
+             
+                          printk("Single/Diff selection error\n");
+                          i_ReturnValue = -1;
+                          }
+                       else
+                          {
+                          /**********************************/
+                          /* Test if conversion not started */
+                          /**********************************/
+                             
+                          if (i_APCI3XXX_TestConversionStarted (dev) == 0)
+                             {
+                             devpriv->ui_EocEosConversionTime    = (UINT) dw_ReloadValue;
+                             devpriv->b_EocEosConversionTimeBase = b_TimeBase;
+                             devpriv->b_SingelDiff               = b_SingleDiff;
+                             devpriv->b_AiInitialisation         = 1;
+                                
+                                
+                             /*******************************/
+                             /* Set the convert timing unit */
+                             /*******************************/
+                               
+                             writel((DWORD) b_TimeBase, (void *) (devpriv->dw_AiBase + 36)); 
+
+                             /**************************/
+                             /* Set the convert timing */
+                             /*************************/
+                               
+                             writel(dw_ReloadValue, (void *) (devpriv->dw_AiBase + 32)); 
+                             }
+                          else
+                             {
+                             /**************************/
+                             /* Any conversion started */
+                             /**************************/
+             
+                             printk("Any conversion started\n");
+                             i_ReturnValue = -10;
+                             }
+                          }
+                       }
+                   else
+                      {
+                      /*******************************/
+                      /* Single/Diff selection error */
+                      /*******************************/
+             
+                      printk("Single/Diff selection error\n");
+                      i_ReturnValue = -1;
+                      }
+                   }
+                else
+                   {
+                   /************************/
+                   /* Time selection error */
+                   /************************/
+             
+                   printk("Convert time value selection error\n");
+                   i_ReturnValue = -3;
+                   }
+                }
+             else
+                {
+                /************************/
+                /* Time selection error */
+                /************************/
+             
+                printk("Convert time value selection error\n");
+                i_ReturnValue = -3;
+                }
+             }
+          else
+             {
+             /*****************************/
+             /* Time base selection error */
+             /*****************************/
+             
+             printk("Convert time base unity selection error\n");
+             i_ReturnValue = -2;
+             }
+          }
+       else
+          {
+          /*******************/
+          /* Data size error */
+          /*******************/
+              
+          printk("Buffer size error\n");
+          i_ReturnValue = -101;
+          }
+          
+       return (i_ReturnValue);
+       }
+
+
+
+
+
+
+
+
+/*
++----------------------------------------------------------------------------+
+| Function Name     : INT   i_APCI3XXX_InsnConfigAnalogInput                 |
+|                          (comedi_device    *dev,                           |
+|                           comedi_subdevice *s,                             |
+|                           comedi_insn      *insn,                          |
+|                           lsampl_t         *data)                          |
++----------------------------------------------------------------------------+
+| Task           Converting mode and convert time selection                  |
++----------------------------------------------------------------------------+
+| Input Parameters  : b_ConvertMode = (BYTE)  data[0];                       |
+|                     b_TimeBase    = (BYTE)  data[1]; (0: ns, 1:micros 2:ms)|
+|                    dw_ReloadValue = (DWORD) data[2];                       |
+|                     ........                                               |
++----------------------------------------------------------------------------+
+| Output Parameters : -                                                      |
++----------------------------------------------------------------------------+
+| Return Value      :>0: No error                                            |
+|                    ....                                                    |
+|                    -100 : Config command error                             |
+|                    -101 : Data size error                                  |
++----------------------------------------------------------------------------+
+*/
+
+
+int   i_APCI3XXX_InsnConfigAnalogInput(comedi_device    *dev,
+                                       comedi_subdevice *s,
+                                       comedi_insn      *insn,
+                                       lsampl_t         *data) 
+       {
+       INT i_ReturnValue  = insn->n;
+       
+       /************************/
+       /* Test the buffer size */
+       /************************/
+       
+       if (insn->n >= 1)
+          {
+          switch ((BYTE) data[0])
+             {
+             case APCI3XXX_CONFIGURATION:
+                  i_ReturnValue = i_APCI3XXX_AnalogInputConfigOperatingMode (dev, s, insn, data) ;
+                  break;
+                  
+             default:
+                  i_ReturnValue = -100;
+                  printk("Config command error %d\n", data[0]);
+                  break;
+             }
+          }
+       else
+          {
+          /*******************/
+          /* Data size error */
+          /*******************/
+              
+          printk("Buffer size error\n");
+          i_ReturnValue = -101;
+          }
+          
+       return (i_ReturnValue);
+       }
+
+
+/*
++----------------------------------------------------------------------------+
+| Function Name     : INT   i_APCI3XXX_InsnReadAnalogInput                   |
+|                          (comedi_device    *dev,                           |
+|                           comedi_subdevice *s,                             |
+|                           comedi_insn      *insn,                          |
+|                           lsampl_t         *data)                          |
++----------------------------------------------------------------------------+
+| Task                Read 1 analog input                                    |
++----------------------------------------------------------------------------+
+| Input Parameters  : b_Range             = CR_RANGE(insn->chanspec);        |
+|                     b_Channel           = CR_CHAN(insn->chanspec);         |
+|                     dw_NbrOfAcquisition = insn->n;                         |
++----------------------------------------------------------------------------+
+| Output Parameters : -                                                      |
++----------------------------------------------------------------------------+
+| Return Value      :>0: No error                                            |
+|                    -3 : Channel selection error                            |
+|                    -4 : Configuration selelection error                    |
+|                    -10: Any conversion started                             |
+|                    ....                                                    |
+|                    -100 : Config command error                             |
+|                    -101 : Data size error                                  |
++----------------------------------------------------------------------------+
+*/
+
+int   i_APCI3XXX_InsnReadAnalogInput (comedi_device    *dev,
+                                      comedi_subdevice *s,
+                                      comedi_insn      *insn,
+                                      lsampl_t         *data) 
+       {
+       INT    i_ReturnValue      = insn->n;
+       BYTE   b_Configuration    = (BYTE) CR_RANGE(insn->chanspec);
+       BYTE   b_Channel          = (BYTE) CR_CHAN(insn->chanspec);
+       DWORD dw_Temp             = 0;
+       DWORD dw_Configuration    = 0;
+       DWORD dw_AcquisitionCpt   = 0;
+       BYTE   b_Interrupt        = 0;
+
+       /*************************************/
+       /* Test if operating mode configured */
+       /*************************************/
+
+       if (devpriv->b_AiInitialisation)
+          {
+          /***************************/
+          /* Test the channel number */
+          /***************************/
+                
+           if (((b_Channel < devpriv->ps_BoardInfo->i_NbrAiChannel)     && (devpriv->b_SingelDiff == APCI3XXX_SINGLE)) ||
+              ((b_Channel < devpriv->ps_BoardInfo->i_NbrAiChannelDiff) && (devpriv->b_SingelDiff == APCI3XXX_DIFF)))
+             {
+             /**********************************/
+             /* Test the channel configuration */
+             /**********************************/
+          
+             if (b_Configuration > 7)
+                {
+                /***************************/
+                /* Channel not initialised */
+                /***************************/
+                   
+                i_ReturnValue = -4;
+                printk ("Channel %d range %d selection error\n", b_Channel, b_Configuration);
+                }
+             }
+          else
+             {
+             /***************************/
+             /* Channel selection error */
+             /***************************/
+                   
+             i_ReturnValue = -3;
+             printk ("Channel %d selection error\n", b_Channel);
+             }
+          
+          /**************************/
+          /* Test if no error occur */
+          /**************************/   
+          
+          if (i_ReturnValue >= 0)
+             {
+             /************************/
+             /* Test the buffer size */
+             /************************/
+             
+             if ((b_Interrupt != 0) || ((b_Interrupt == 0) && (insn->n >= 1)))
+                {
+                /**********************************/
+                /* Test if conversion not started */
+                /**********************************/
+                             
+                if (i_APCI3XXX_TestConversionStarted (dev) == 0)
+                   {
+                   /******************/
+                   /* Clear the FIFO */
+                   /******************/
+                   
+                   writel(0x10000UL, (void *) (devpriv->dw_AiBase + 12));
+
+                   /*******************************/
+                   /* Get and save the delay mode */
+                   /*******************************/
+                   
+                   dw_Temp = readl((void *) (devpriv->dw_AiBase + 4));
+                   dw_Temp = dw_Temp & 0xFFFFFEF0UL;
+                   
+                   /***********************************/
+                   /* Channel configuration selection */
+                   /***********************************/
+                      
+                   writel(dw_Temp, (void *) (devpriv->dw_AiBase + 4));
+
+                   /**************************/
+                   /* Make the configuration */
+                   /**************************/
+                      
+                   dw_Configuration = (b_Configuration & 3) | 
+                                      ((DWORD) (b_Configuration >> 2) << 6) | 
+                                      ((DWORD) devpriv->b_SingelDiff << 7);
+
+                   /***************************/
+                   /* Write the configuration */
+                   /***************************/
+                   
+                   writel(dw_Configuration, (void *) (devpriv->dw_AiBase + 0)); 
+                      
+                   /*********************/
+                   /* Channel selection */
+                   /*********************/
+                      
+                   writel(dw_Temp | 0x100UL, (void *) (devpriv->dw_AiBase + 4));
+                   writel((DWORD) b_Channel, (void *) (devpriv->dw_AiBase + 0)); 
+
+                   /***********************/
+                   /* Restaure delay mode */
+                   /***********************/
+                   
+                   writel(dw_Temp, (void *) (devpriv->dw_AiBase + 4));
+       
+                   /***********************************/
+                   /* Set the number of sequence to 1 */
+                   /***********************************/
+                   
+                   writel(1, (void *) (devpriv->dw_AiBase + 48));
+
+                   /***************************/
+                   /* Save the interrupt flag */
+                   /***************************/
+                   
+                   devpriv->b_EocEosInterrupt  = b_Interrupt;
+                   
+                   /*******************************/
+                   /* Save the number of channels */
+                   /*******************************/
+                   
+                   devpriv->ui_AiNbrofChannels = 1;
+                                        
+                   /******************************/
+                   /* Test if interrupt not used */
+                   /******************************/
+                   
+                   if (b_Interrupt == 0)
+                      {
+                      for (dw_AcquisitionCpt = 0; dw_AcquisitionCpt < insn->n; dw_AcquisitionCpt ++)
+                         {
+                         /************************/
+                         /* Start the conversion */
+                         /************************/
+                   
+                         writel(0x80000UL, (void *) (devpriv->dw_AiBase + 8));
+                   
+                         /****************/
+                         /* Wait the EOS */
+                         /****************/
+                      
+                         do
+                            {
+                            dw_Temp = readl((void *) (devpriv->dw_AiBase + 20));
+                            dw_Temp = dw_Temp & 1;
+                            }
+                         while (dw_Temp != 1);
+                      
+                         /*************************/
+                         /* Read the analog value */
+                         /*************************/
+                      
+                         data[dw_AcquisitionCpt] = (lsampl_t) readl((void *) (devpriv->dw_AiBase + 28));
+                         }
+                      }
+                   else
+                      {
+                      /************************/
+                      /* Start the conversion */
+                      /************************/
+                   
+                      writel(0x180000UL, (void *) (devpriv->dw_AiBase + 8));
+                      }
+                   }
+                else
+                   {
+                   /**************************/
+                   /* Any conversion started */
+                   /**************************/
+             
+                   printk("Any conversion started\n");
+                   i_ReturnValue = -10;
+                   }
+                }
+             else
+                {
+                /*******************/
+                /* Data size error */
+                /*******************/
+              
+                printk("Buffer size error\n");
+                i_ReturnValue = -101;
+                }
+             }
+          }
+       else
+          {
+          /***************************/
+          /* Channel selection error */
+          /***************************/
+          
+          printk("Operating mode not configured\n");
+          i_ReturnValue = -1;
+          }
+       
+       return (i_ReturnValue);
+       }
+
+
+
+/*
++----------------------------------------------------------------------------+
+| Function name     : void v_APCI3XXX_Interrupt (int            irq,         |
+|                                                void           *d,          | 
+|                                                struct pt_regs *regs)       |
++----------------------------------------------------------------------------+
+| Task              :Interrupt handler for APCI3XXX                          |
+|                    When interrupt occurs this gets called.                 |
+|                    First it finds which interrupt has been generated and   | 
+|                    handles  corresponding interrupt                        |
++----------------------------------------------------------------------------+
+| Input Parameters  : -                                                      |
++----------------------------------------------------------------------------+
+| Return Value      : -                                                      |
++----------------------------------------------------------------------------+
+*/
+
+
+void   v_APCI3XXX_Interrupt(int irq, void *d, struct pt_regs *regs) 
+       {
+       comedi_device *dev       = d;
+       BYTE           b_CopyCpt = 0;
+       DWORD         dw_Status  = 0;
+       
+       
+       /***************************/
+       /* Test if interrupt occur */
+       /***************************/
+       
+       if (((dw_Status = readl ((void *) (devpriv->dw_AiBase + 16))) & 0x2UL) == 0x2UL)
+          {
+          /***********************/
+          /* Reset the interrupt */
+          /***********************/
+          
+          writel(dw_Status, (void *) (devpriv->dw_AiBase + 16));
+          
+          /*****************************/
+          /* Test if interrupt enabled */
+          /*****************************/
+          
+          if (devpriv->b_EocEosInterrupt == 1)
+             {
+             /********************************/
+             /* Read all analog inputs value */
+             /********************************/
+             
+             for (b_CopyCpt = 0; b_CopyCpt < devpriv->ui_AiNbrofChannels; b_CopyCpt ++)
+                {
+                devpriv->ui_AiReadData[b_CopyCpt] = (UINT) readl((void *) (devpriv->dw_AiBase + 28));
+                }
+                
+             /**************************/
+             /* Set the interrupt flag */
+             /**************************/
+             
+             devpriv->b_EocEosInterrupt = 2;
+             
+             /**********************************************/
+             /* Send a signal to from kernel to user space */
+             /**********************************************/
+       
+             send_sig(SIGIO,devpriv->tsk_Current,0); 
+             }
+          }
+       }
+
+
+
+/*
++----------------------------------------------------------------------------+
+|                            ANALOG OUTPUT SUBDEVICE                         |
++----------------------------------------------------------------------------+
+*/
+
+
+/*
++----------------------------------------------------------------------------+
+| Function Name     : INT   i_APCI3XXX_InsnWriteAnalogOutput                 |
+|                          (comedi_device    *dev,                           |
+|                           comedi_subdevice *s,                             |
+|                           comedi_insn      *insn,                          |
+|                           lsampl_t         *data)                          |
++----------------------------------------------------------------------------+
+| Task                Read 1 analog input                                    |
++----------------------------------------------------------------------------+
+| Input Parameters  : b_Range    = CR_RANGE(insn->chanspec);                 |
+|                     b_Channel  = CR_CHAN(insn->chanspec);                  |
+|                     data[0]    = analog value;                             |
++----------------------------------------------------------------------------+
+| Output Parameters : -                                                      |
++----------------------------------------------------------------------------+
+| Return Value      :>0: No error                                            |
+|                    -3 : Channel selection error                            |
+|                    -4 : Configuration selelection error                    |
+|                    ....                                                    |
+|                    -101 : Data size error                                  |
++----------------------------------------------------------------------------+
+*/
+
+int   i_APCI3XXX_InsnWriteAnalogOutput (comedi_device    *dev,
+                                        comedi_subdevice *s,
+                                        comedi_insn      *insn,
+                                        lsampl_t         *data) 
+       {
+       BYTE   b_Range       = (BYTE) CR_RANGE(insn->chanspec);
+       BYTE   b_Channel     = (BYTE) CR_CHAN (insn->chanspec);
+       DWORD dw_Status      = 0;
+       INT    i_ReturnValue = insn->n;
+
+       /************************/
+       /* Test the buffer size */
+       /************************/
+       
+       if (insn->n >= 1)
+          {
+          /***************************/
+          /* Test the channel number */
+          /***************************/
+                
+           if (b_Channel < devpriv->ps_BoardInfo->i_NbrAoChannel)
+             {
+             /**********************************/
+             /* Test the channel configuration */
+             /**********************************/
+          
+             if (b_Range < 2)
+                {
+                /***************************/
+                /* Set the range selection */
+                /***************************/
+          
+                writel(b_Range, (void *) (devpriv->dw_AiBase + 96));
+          
+                /**************************************************/
+                /* Write the analog value to the selected channel */
+                /**************************************************/
+          
+                writel((data[0] << 8) | b_Channel, (void *) (devpriv->dw_AiBase + 100));
+          
+                /****************************/
+                /* Wait the end of transfer */
+                /****************************/
+          
+                do
+                   {
+                   dw_Status = readl ((void *) (devpriv->dw_AiBase + 96));
+                   }
+                while ((dw_Status & 0x100) != 0x100);
+                }
+             else
+                {
+                /***************************/
+                /* Channel not initialised */
+                /***************************/
+                   
+                i_ReturnValue = -4;
+                printk ("Channel %d range %d selection error\n", b_Channel, b_Range);
+                }
+             }
+          else
+             {
+             /***************************/
+             /* Channel selection error */
+             /***************************/
+                   
+             i_ReturnValue = -3;
+             printk ("Channel %d selection error\n", b_Channel);
+             }
+          }
+       else
+          {
+          /*******************/
+          /* Data size error */
+          /*******************/
+              
+          printk("Buffer size error\n");
+          i_ReturnValue = -101;
+          }
+       
+       return (i_ReturnValue);
+       }
+
+
+
+/*
++----------------------------------------------------------------------------+
+|                              TTL FUNCTIONS                                 |
++----------------------------------------------------------------------------+
+*/
+
+/*
++----------------------------------------------------------------------------+
+| Function Name     : INT   i_APCI3XXX_InsnConfigInitTTLIO                   |
+|                          (comedi_device    *dev,                           |
+|                           comedi_subdevice *s,                             |
+|                           comedi_insn      *insn,                          |
+|                           lsampl_t         *data)                          |
++----------------------------------------------------------------------------+
+| Task           You must calling this function be                           |
+|                for you call any other function witch access of TTL.        |
+|                APCI3XXX_TTL_INIT_DIRECTION_PORT2(user inputs for direction)|
++----------------------------------------------------------------------------+
+| Input Parameters  : b_InitType    = (BYTE) data[0];                        |
+|                     b_Port2Mode   = (BYTE) data[1];                        |
++----------------------------------------------------------------------------+
+| Output Parameters : -                                                      |
++----------------------------------------------------------------------------+
+| Return Value      :>0: No error                                            |
+|                    -1: Port 2 mode selection is wrong                      |
+|                    ....                                                    |
+|                    -100 : Config command error                             |
+|                    -101 : Data size error                                  |
++----------------------------------------------------------------------------+
+*/
+
+
+int   i_APCI3XXX_InsnConfigInitTTLIO(comedi_device    *dev,
+                                     comedi_subdevice *s,
+                                     comedi_insn      *insn,
+                                     lsampl_t         *data) 
+       {
+       INT        i_ReturnValue = insn->n;
+       BYTE       b_Command     = 0;
+
+       /************************/
+       /* Test the buffer size */
+       /************************/
+       
+       if (insn->n >= 1)
+          {
+          /*******************/
+          /* Get the command */
+          /* *****************/
+          
+          b_Command = (BYTE) data[0];
+          
+          /********************/
+          /* Test the command */
+          /********************/
+          
+          if (b_Command == APCI3XXX_TTL_INIT_DIRECTION_PORT2)
+             {
+             /***************************************/
+             /* Test the initialisation buffer size */
+             /***************************************/
+             
+             if ((b_Command == APCI3XXX_TTL_INIT_DIRECTION_PORT2) && (insn->n != 2))
+                {
+                /*******************/
+                /* Data size error */
+                /*******************/
+                
+                printk("Buffer size error\n");
+                i_ReturnValue = -101;
+                }
+             }
+          else
+             {
+             /************************/
+             /* Config command error */
+             /************************/
+             
+             printk("Command selection error\n");
+             i_ReturnValue = -100;
+             }
+          }
+       else
+          {
+          /*******************/
+          /* Data size error */
+          /*******************/
+              
+          printk("Buffer size error\n");
+          i_ReturnValue = -101;
+          }
+          
+          
+       /*********************************************************************************/
+       /* Test if no error occur and APCI3XXX_TTL_INIT_DIRECTION_PORT2 command selected */
+       /*********************************************************************************/
+       
+       if ((i_ReturnValue >= 0) && (b_Command == APCI3XXX_TTL_INIT_DIRECTION_PORT2))
+          {
+          /**********************/
+          /* Test the direction */
+          /**********************/
+             
+          if ((data[1] == 0) || (data[1] == 0xFF))
+             {
+             /**************************/
+             /* Save the configuration */
+             /**************************/
+       
+             devpriv->ul_TTLPortConfiguration[0] = devpriv->ul_TTLPortConfiguration[0] | data[1];
+             }
+          else
+             {
+             /************************/
+             /* Port direction error */
+             /************************/
+                        
+             printk("Port 2 direction selection error\n");
+             i_ReturnValue = - 1;
+             }
+          }
+          
+       /**************************/
+       /* Test if no error occur */
+       /**************************/
+       
+       if (i_ReturnValue >= 0)
+          {
+          /***********************************/
+          /* Test if TTL port initilaisation */
+          /***********************************/
+          
+          if (b_Command == APCI3XXX_TTL_INIT_DIRECTION_PORT2)
+             {
+             /*************************/
+             /* Set the configuration */
+             /*************************/
+       
+             outl(data[1],devpriv->iobase + 224);
+             }
+          }
+       
+       return (i_ReturnValue);
+       }
+
+
+/*
++----------------------------------------------------------------------------+
+|                        TTL INPUT FUNCTIONS                                 |
++----------------------------------------------------------------------------+
+*/
+
+
+/*
++----------------------------------------------------------------------------+
+| Function Name     : INT     i_APCI3XXX_InsnBitsTTLIO                       |
+|                          (comedi_device    *dev,                           |
+|                           comedi_subdevice *s,                             |
+|                           comedi_insn      *insn,                          |
+|                           lsampl_t         *data)                          |
++----------------------------------------------------------------------------+
+| Task              : Write the selected output mask and read the status from| 
+|                     all TTL channles                                       |
++----------------------------------------------------------------------------+
+| Input Parameters  : dw_ChannelMask = data [0];                             |
+|                     dw_BitMask     = data [1];                             |
++----------------------------------------------------------------------------+
+| Output Parameters : data[1] : All TTL channles states                      |
++----------------------------------------------------------------------------+
+| Return Value      : >0  : No error                                         |
+|                    -4   : Channel mask error                               |
+|                    -101 : Data size error                                  |
++----------------------------------------------------------------------------+
+*/
+
+
+int  i_APCI3XXX_InsnBitsTTLIO   (comedi_device    *dev,
+                                 comedi_subdevice *s,
+                                comedi_insn      *insn,
+                                lsampl_t         *data)
+       {
+       INT        i_ReturnValue = insn->n;
+       BYTE       b_ChannelCpt  = 0;
+       DWORD     dw_ChannelMask = 0;
+       DWORD     dw_BitMask     = 0;
+       DWORD     dw_Status      = 0;
+
+       /************************/
+       /* Test the buffer size */
+       /************************/
+       
+       if (insn->n >= 2)
+          {
+          /*******************************/
+          /* Get the channe and bit mask */
+          /*******************************/
+          
+          dw_ChannelMask = data [0];
+          dw_BitMask     = data [1];
+          
+          /*************************/
+          /* Test the channel mask */
+          /*************************/
+          
+          if (((dw_ChannelMask & 0XFF00FF00) == 0) &&
+              (((devpriv->ul_TTLPortConfiguration[0] & 0xFF) == 0xFF) ||
+              (((devpriv->ul_TTLPortConfiguration[0] & 0xFF) == 0) && ((dw_ChannelMask & 0XFF0000) == 0))))
+             {
+             /*********************************/
+             /* Test if set/reset any channel */
+             /*********************************/
+          
+             if (dw_ChannelMask)
+                {
+                /****************************************/
+                /* Test if set/rest any port 0 channels */
+                /****************************************/
+             
+                if (dw_ChannelMask & 0xFF)
+                   {
+                   /*******************************************/
+                   /* Read port 0 (first digital output port) */
+                   /*******************************************/
+             
+                   dw_Status = inl(devpriv->iobase + 80);
+             
+                   for (b_ChannelCpt = 0; b_ChannelCpt < 8; b_ChannelCpt ++)
+                      {
+                      if ((dw_ChannelMask >> b_ChannelCpt) & 1)
+                         {
+                         dw_Status = (dw_Status & (0xFF - (1 << b_ChannelCpt))) | (dw_BitMask & (1 << b_ChannelCpt));
+                         }
+                      }
+             
+                   outl (dw_Status, devpriv->iobase + 80);
+                   }
+          
+                /****************************************/
+                /* Test if set/rest any port 2 channels */
+                /****************************************/
+             
+                if (dw_ChannelMask & 0xFF0000)
+                   {
+                   dw_BitMask     = dw_BitMask     >> 16;
+                   dw_ChannelMask = dw_ChannelMask >> 16;
+                
+                   /********************************************/
+                   /* Read port 2 (second digital output port) */
+                   /********************************************/
+             
+                   dw_Status = inl(devpriv->iobase + 112);
+             
+                   for (b_ChannelCpt = 0; b_ChannelCpt < 8; b_ChannelCpt ++)
+                      {
+                      if ((dw_ChannelMask >> b_ChannelCpt) & 1)
+                         {
+                         dw_Status = (dw_Status & (0xFF - (1 << b_ChannelCpt))) | (dw_BitMask & (1 << b_ChannelCpt));
+                         }
+                      }
+             
+                   outl (dw_Status, devpriv->iobase + 112);
+                   }
+                }
+                
+             /*******************************************/
+             /* Read port 0 (first digital output port) */
+             /*******************************************/
+                
+             data [1] = inl(devpriv->iobase + 80);
+             
+             /******************************************/
+             /* Read port 1 (first digital input port) */
+             /******************************************/
+                
+             data [1] = data [1] | (inl(devpriv->iobase + 64) << 8);
+       
+             /************************/
+             /* Test if port 2 input */
+             /************************/
+                
+             if ((devpriv->ul_TTLPortConfiguration[0] & 0xFF) == 0)
+                {
+                data [1] = data [1] | (inl(devpriv->iobase + 96) << 16);
+                }
+             else
+                {
+                data [1] = data [1] | (inl(devpriv->iobase + 112) << 16);
+                }
+             }
+          else
+             {
+             /************************/
+             /* Config command error */
+             /************************/
+             
+             printk("Channel mask error\n");
+             i_ReturnValue = -4;
+             }
+          }
+       else
+          {
+          /*******************/
+          /* Data size error */
+          /*******************/
+              
+          printk("Buffer size error\n");
+          i_ReturnValue = -101;
+          }
+          
+          
+       return (i_ReturnValue);
+       }
+
+
+/*
++----------------------------------------------------------------------------+
+| Function Name     : INT i_APCI3XXX_InsnReadTTLIO                           |
+|                          (comedi_device    *dev,                           |
+|                           comedi_subdevice *s,                             |
+|                           comedi_insn      *insn,                          |
+|                           lsampl_t         *data)                          |
++----------------------------------------------------------------------------+
+| Task              : Read the status from selected channel                  |
++----------------------------------------------------------------------------+
+| Input Parameters  : b_Channel = CR_CHAN(insn->chanspec)                    |
++----------------------------------------------------------------------------+
+| Output Parameters : data[0] : Selected TTL channel state                   |
++----------------------------------------------------------------------------+
+| Return Value      : 0   : No error                                         |
+|                    -3   : Channel selection error                          |
+|                    -101 : Data size error                                  |
++----------------------------------------------------------------------------+
+*/
+
+int i_APCI3XXX_InsnReadTTLIO (comedi_device    *dev,
+                              comedi_subdevice *s,
+                              comedi_insn      *insn,
+                              lsampl_t         *data)
+       {
+       BYTE         b_Channel      = (BYTE) CR_CHAN(insn->chanspec);
+       INT          i_ReturnValue  = insn->n;
+       lsampl_t * pls_ReadData     = data;
+
+       /************************/
+       /* Test the buffer size */
+       /************************/
+       
+       if (insn->n >= 1)
+          {
+          /***********************/
+          /* Test if read port 0 */
+          /***********************/
+          
+          if (b_Channel < 8)
+             {
+             /*******************************************/
+             /* Read port 0 (first digital output port) */
+             /*******************************************/
+                
+             pls_ReadData [0] = inl(devpriv->iobase + 80);
+             pls_ReadData [0] = (pls_ReadData [0] >> b_Channel) & 1;
+             }
+          else
+             {
+             /***********************/
+             /* Test if read port 1 */
+             /***********************/
+          
+             if ((b_Channel > 7) && (b_Channel < 16))
+                {
+                /******************************************/
+                /* Read port 1 (first digital input port) */
+                /******************************************/
+                
+                pls_ReadData [0] = inl(devpriv->iobase + 64);
+                pls_ReadData [0] = (pls_ReadData [0] >> (b_Channel - 8)) & 1;
+                }
+             else
+                {
+                /***********************/
+                /* Test if read port 2 */
+                /***********************/
+          
+                if ((b_Channel > 15) && (b_Channel < 24))
+                   {
+                   /************************/
+                   /* Test if port 2 input */
+                   /************************/
+                
+                   if ((devpriv->ul_TTLPortConfiguration[0] & 0xFF) == 0)
+                      {
+                      pls_ReadData [0] = inl(devpriv->iobase + 96);
+                      pls_ReadData [0] = (pls_ReadData [0] >> (b_Channel - 16)) & 1;
+                      }
+                   else
+                      {
+                      pls_ReadData [0] = inl(devpriv->iobase + 112);
+                      pls_ReadData [0] = (pls_ReadData [0] >> (b_Channel - 16)) & 1;
+                      }
+                   }
+                else
+                   {
+                   /***************************/
+                   /* Channel selection error */
+                   /***************************/
+                   
+                   i_ReturnValue = -3;
+                   printk ("Channel %d selection error\n", b_Channel);
+                   }
+                }
+             }
+          }
+       else
+          {
+          /*******************/
+          /* Data size error */
+          /*******************/
+              
+          printk("Buffer size error\n");
+          i_ReturnValue = -101;
+          }
+
+       return (i_ReturnValue);
+       }
+
+/*
++----------------------------------------------------------------------------+
+|                        TTL OUTPUT FUNCTIONS                                |
++----------------------------------------------------------------------------+
+*/
+
+/*
++----------------------------------------------------------------------------+
+| Function Name     : INT     i_APCI3XXX_InsnWriteTTLIO                      |
+|                          (comedi_device    *dev,                           |
+|                           comedi_subdevice *s,                             |
+|                           comedi_insn      *insn,                          |
+|                           lsampl_t         *data)                          |
++----------------------------------------------------------------------------+
+| Task              : Set the state from TTL output channel                  |
++----------------------------------------------------------------------------+
+| Input Parameters  : b_Channel = CR_CHAN(insn->chanspec)                    |
+|                     b_State   = data [0]                                   |
++----------------------------------------------------------------------------+
+| Output Parameters : -                                                      |
++----------------------------------------------------------------------------+
+| Return Value      : 0   : No error                                         |
+|                    -3   : Channel selection error                          |
+|                    -101 : Data size error                                  |
++----------------------------------------------------------------------------+
+*/
+
+
+int  i_APCI3XXX_InsnWriteTTLIO   (comedi_device    *dev,
+                                  comedi_subdevice *s,
+                                  comedi_insn      *insn,
+                                  lsampl_t         *data)
+       {
+       INT          i_ReturnValue   = insn->n;
+       BYTE         b_Channel       = (BYTE) CR_CHAN(insn->chanspec);
+       BYTE         b_State         = 0;
+       DWORD       dw_Status        = 0;
+
+       /************************/
+       /* Test the buffer size */
+       /************************/
+       
+       if (insn->n >= 1)
+          {
+          b_State = (BYTE) data [0];
+          
+          /***********************/
+          /* Test if read port 0 */
+          /***********************/
+          
+          if (b_Channel < 8)
+             {
+             /*****************************************************************************/
+             /* Read port 0 (first digital output port) and set/reset the selcted channel */
+             /*****************************************************************************/
+                
+             dw_Status = inl(devpriv->iobase + 80);
+             dw_Status = (dw_Status & (0xFF - (1 << b_Channel))) | ((b_State & 1) << b_Channel);
+             outl(dw_Status, devpriv->iobase + 80);
+             }
+          else
+             {
+             /***********************/
+             /* Test if read port 2 */
+             /***********************/
+          
+             if ((b_Channel > 15) && (b_Channel < 24))
+                {
+                /*************************/
+                /* Test if port 2 output */
+                /*************************/
+                
+                if ((devpriv->ul_TTLPortConfiguration[0] & 0xFF) == 0xFF)
+                   {
+                   /*****************************************************************************/
+                   /* Read port 2 (first digital output port) and set/reset the selcted channel */
+                   /*****************************************************************************/
+                
+                   dw_Status = inl(devpriv->iobase + 112);
+                   dw_Status = (dw_Status & (0xFF - (1 << (b_Channel - 16)))) | ((b_State & 1) << (b_Channel - 16));
+                   outl(dw_Status, devpriv->iobase + 112);
+                   }
+                else
+                   {
+                   /***************************/
+                   /* Channel selection error */
+                   /***************************/
+                   
+                   i_ReturnValue = -3;
+                   printk ("Channel %d selection error\n", b_Channel);
+                   }
+                 }
+             else
+                {
+                /***************************/
+                /* Channel selection error */
+                /***************************/
+                   
+                i_ReturnValue = -3;
+                printk ("Channel %d selection error\n", b_Channel);
+                }
+             }
+          }
+       else
+          {
+          /*******************/
+          /* Data size error */
+          /*******************/
+              
+          printk("Buffer size error\n");
+          i_ReturnValue = -101;
+          }
+
+       return (i_ReturnValue);
+       }
+
+/*
++----------------------------------------------------------------------------+
+|                           DIGITAL INPUT SUBDEVICE                          |
++----------------------------------------------------------------------------+
+*/
+
+
+/*
++----------------------------------------------------------------------------+
+| Function name     :int i_APCI3XXX_InsnReadDigitalInput                     |
+|                                          (comedi_device *dev,              |
+|                                           comedi_subdevice *s,             |
+|                                           comedi_insn *insn,               |
+|                                           lsampl_t *data)                  |
++----------------------------------------------------------------------------+
+| Task              : Reads the value of the specified Digital input channel |
++----------------------------------------------------------------------------+
+| Input Parameters  : b_Channel = CR_CHAN(insn->chanspec) (0 to 3)           |
++----------------------------------------------------------------------------+
+| Output Parameters : data[0] : Channel value                                |
++----------------------------------------------------------------------------+
+| Return Value      : 0   : No error                                         |
+|                    -3   : Channel selection error                          |
+|                    -101 : Data size error                                  |
++----------------------------------------------------------------------------+
+*/
+
+int    i_APCI3XXX_InsnReadDigitalInput(comedi_device    *dev,
+                                        comedi_subdevice *s, 
+                                        comedi_insn      *insn,
+                                        lsampl_t         *data)
+       {
+       INT    i_ReturnValue = insn->n;
+       BYTE   b_Channel     = (BYTE) CR_CHAN(insn->chanspec);
+       DWORD dw_Temp        = 0;
+         
+       /***************************/
+       /* Test the channel number */
+       /***************************/
+       
+       if(b_Channel <= devpriv->ps_BoardInfo->i_NbrDiChannel)
+          {
+          /************************/
+          /* Test the buffer size */
+          /************************/
+       
+          if (insn->n >= 1)
+             {
+             dw_Temp = inl (devpriv->iobase + 32);
+             *data = (dw_Temp >> b_Channel) & 1;
+             }
+          else
+             {
+             /*******************/
+             /* Data size error */
+             /*******************/
+              
+             printk("Buffer size error\n");
+             i_ReturnValue = -101;
+             }
+          }
+       else 
+          {
+          /***************************/
+          /* Channel selection error */
+          /***************************/
+              
+          printk("Channel selection error\n");
+          i_ReturnValue = -3;
+          }
+          
+       return (i_ReturnValue); 
+       }
+
+/*
++----------------------------------------------------------------------------+
+| Function name     :int i_APCI3XXX_InsnBitsDigitalInput                     |
+|                                          (comedi_device *dev,              |
+|                                           comedi_subdevice *s,             |
+|                                           comedi_insn *insn,               |
+|                                           lsampl_t *data)                  |
++----------------------------------------------------------------------------+
+| Task              : Reads the value of the Digital input Port i.e.4channels|
++----------------------------------------------------------------------------+
+| Input Parameters  : -                                                      |
++----------------------------------------------------------------------------+
+| Output Parameters : data[0] : Port value                                   |
++----------------------------------------------------------------------------+
+| Return Value      :>0: No error                                            |
+|                    ....                                                    |
+|                    -101 : Data size error                                  |
++----------------------------------------------------------------------------+
+*/
+int i_APCI3XXX_InsnBitsDigitalInput (comedi_device    *dev,
+                                     comedi_subdevice *s, 
+                                     comedi_insn      *insn,
+                                     lsampl_t         *data)
+       {
+       INT    i_ReturnValue = insn->n;
+       DWORD dw_Temp        = 0;
+       
+       /************************/
+       /* Test the buffer size */
+       /************************/
+       
+       if (insn->n >= 1)
+          {
+          dw_Temp=  inl (devpriv->iobase + 32);
+          *data= dw_Temp & 0xf;
+          }
+       else
+          {
+          /*******************/
+          /* Data size error */
+          /*******************/
+              
+          printk("Buffer size error\n");
+          i_ReturnValue = -101;
+          }
+          
+       return (i_ReturnValue); 
+       }
+
+/*
++----------------------------------------------------------------------------+
+|                           DIGITAL OUTPUT SUBDEVICE                         |
++----------------------------------------------------------------------------+
+
+*/
+
+
+
+/*
++----------------------------------------------------------------------------+
+| Function name     :int i_APCI3XXX_InsnBitsDigitalOutput                    |
+|                                          (comedi_device *dev,              |
+|                                           comedi_subdevice *s,             |
+|                                           comedi_insn *insn,               |
+|                                           lsampl_t *data)                  |
++----------------------------------------------------------------------------+
+| Task              : Write the selected output mask and read the status from| 
+|                     all digital output channles                            |
++----------------------------------------------------------------------------+
+| Input Parameters  : dw_ChannelMask = data [0];                             |
+|                     dw_BitMask     = data [1];                             |
++----------------------------------------------------------------------------+
+| Output Parameters : data[1] : All digital output channles states           |
++----------------------------------------------------------------------------+
+| Return Value      : >0  : No error                                         |
+|                    -4   : Channel mask error                               |
+|                    -101 : Data size error                                  |
++----------------------------------------------------------------------------+
+*/
+int i_APCI3XXX_InsnBitsDigitalOutput (comedi_device    *dev,
+                                      comedi_subdevice *s, 
+                                      comedi_insn      *insn,
+                                      lsampl_t         *data)
+       {
+       INT        i_ReturnValue = insn->n;
+       BYTE       b_ChannelCpt  = 0;
+       DWORD     dw_ChannelMask = 0;
+       DWORD     dw_BitMask     = 0;
+       DWORD     dw_Status      = 0;
+
+       /************************/
+       /* Test the buffer size */
+       /************************/
+       
+       if (insn->n >= 2)
+          {
+          /*******************************/
+          /* Get the channe and bit mask */
+          /*******************************/
+          
+          dw_ChannelMask = data [0];
+          dw_BitMask     = data [1];
+          
+          /*************************/
+          /* Test the channel mask */
+          /*************************/
+          
+          if ((dw_ChannelMask & 0XFFFFFFF0) == 0)
+             {
+             /*********************************/
+             /* Test if set/reset any channel */
+             /*********************************/
+          
+             if (dw_ChannelMask & 0xF)
+                {
+                /********************************/
+                /* Read the digital output port */
+                /********************************/
+             
+                dw_Status = inl(devpriv->iobase + 48);
+             
+                for (b_ChannelCpt = 0; b_ChannelCpt < 4; b_ChannelCpt ++)
+                   {
+                   if ((dw_ChannelMask >> b_ChannelCpt) & 1)
+                      {
+                      dw_Status = (dw_Status & (0xF - (1 << b_ChannelCpt))) | (dw_BitMask & (1 << b_ChannelCpt));
+                      }
+                   }
+             
+                outl (dw_Status, devpriv->iobase + 48);
+                }
+          
+             /********************************/
+             /* Read the digital output port */
+             /********************************/
+                
+             data [1] = inl(devpriv->iobase + 48);
+             }
+          else
+             {
+             /************************/
+             /* Config command error */
+             /************************/
+             
+             printk("Channel mask error\n");
+             i_ReturnValue = -4;
+             }
+          }
+       else
+          {
+          /*******************/
+          /* Data size error */
+          /*******************/
+              
+          printk("Buffer size error\n");
+          i_ReturnValue = -101;
+          }
+          
+          
+       return (i_ReturnValue);
+       }
+
+/*
++----------------------------------------------------------------------------+
+| Function name     :int i_APCI3XXX_InsnWriteDigitalOutput                   |
+|                                          (comedi_device *dev,              |
+|                                           comedi_subdevice *s,             |
+|                                           comedi_insn *insn,               |
+|                                           lsampl_t *data)                  |
++----------------------------------------------------------------------------+
+| Task              : Set the state from digital output channel              |
++----------------------------------------------------------------------------+
+| Input Parameters  : b_Channel = CR_CHAN(insn->chanspec)                    |
+|                     b_State   = data [0]                                   |
++----------------------------------------------------------------------------+
+| Output Parameters : -                                                      |
++----------------------------------------------------------------------------+
+| Return Value      : >0  : No error                                         |
+|                    -3   : Channel selection error                          |
+|                    -101 : Data size error                                  |
++----------------------------------------------------------------------------+
+*/
+
+
+int i_APCI3XXX_InsnWriteDigitalOutput (comedi_device    *dev,
+                                       comedi_subdevice *s, 
+                                       comedi_insn      *insn,
+                                       lsampl_t         *data)
+       {
+       INT    i_ReturnValue = insn->n;
+       BYTE   b_Channel     = CR_CHAN(insn->chanspec);
+       BYTE   b_State       = 0;
+       DWORD dw_Status      = 0;
+      
+       /************************/
+       /* Test the buffer size */
+       /************************/
+       
+       if (insn->n >= 1)
+          {
+          /***************************/
+          /* Test the channel number */
+          /***************************/
+       
+          if(b_Channel < devpriv->ps_BoardInfo->i_NbrDoChannel)
+             {
+             /*******************/
+             /* Get the command */
+             /*******************/
+          
+             b_State = (BYTE) data[0];
+       
+             /********************************/
+             /* Read the digital output port */
+             /********************************/
+             
+             dw_Status = inl(devpriv->iobase + 48);
+             
+             dw_Status = (dw_Status & (0xF - (1 << b_Channel))) | ((b_State & 1) << b_Channel);
+             outl (dw_Status, devpriv->iobase + 48);
+             }
+          else
+             {
+             /***************************/
+             /* Channel selection error */
+             /***************************/
+              
+             printk("Channel selection error\n");
+             i_ReturnValue = -3;
+             }
+          }
+       else
+          {
+          /*******************/
+          /* Data size error */
+          /*******************/
+              
+          printk("Buffer size error\n");
+          i_ReturnValue = -101;
+          }
+          
+       return (i_ReturnValue); 
+       }
+
+/*
++----------------------------------------------------------------------------+
+| Function name     :int i_APCI3XXX_InsnReadDigitalOutput                    |
+|                                          (comedi_device *dev,              |
+|                                           comedi_subdevice *s,             |
+|                                           comedi_insn *insn,               |
+|                                           lsampl_t *data)                  |
++----------------------------------------------------------------------------+
+| Task              : Read the state from digital output channel             |
++----------------------------------------------------------------------------+
+| Input Parameters  : b_Channel = CR_CHAN(insn->chanspec)                    |
++----------------------------------------------------------------------------+
+| Output Parameters : b_State   = data [0]                                   |
++----------------------------------------------------------------------------+
+| Return Value      : >0  : No error                                         |
+|                    -3   : Channel selection error                          |
+|                    -101 : Data size error                                  |
++----------------------------------------------------------------------------+
+*/
+
+
+int i_APCI3XXX_InsnReadDigitalOutput (comedi_device    *dev,
+                                       comedi_subdevice *s, 
+                                       comedi_insn      *insn,
+                                       lsampl_t         *data)
+       {
+       INT    i_ReturnValue = insn->n;
+       BYTE   b_Channel     = CR_CHAN(insn->chanspec);
+       DWORD dw_Status      = 0;
+      
+       /************************/
+       /* Test the buffer size */
+       /************************/
+       
+       if (insn->n >= 1)
+          {
+          /***************************/
+          /* Test the channel number */
+          /***************************/
+       
+          if(b_Channel < devpriv->ps_BoardInfo->i_NbrDoChannel)
+             {
+             /********************************/
+             /* Read the digital output port */
+             /********************************/
+             
+             dw_Status = inl(devpriv->iobase + 48);
+             
+             dw_Status = (dw_Status >> b_Channel) & 1;
+             *data = dw_Status;
+             }
+          else
+             {
+             /***************************/
+             /* Channel selection error */
+             /***************************/
+              
+             printk("Channel selection error\n");
+             i_ReturnValue = -3;
+             }
+          }
+       else
+          {
+          /*******************/
+          /* Data size error */
+          /*******************/
+              
+          printk("Buffer size error\n");
+          i_ReturnValue = -101;
+          }
+          
+       return (i_ReturnValue); 
+       }
+
+
+/*
++----------------------------------------------------------------------------+
+| Function   Name   : int i_APCI3XXX_Reset(comedi_device *dev)               |                                                         +----------------------------------------------------------------------------+
+| Task              :resets all the registers                                |
++----------------------------------------------------------------------------+
+| Input Parameters  : comedi_device *dev                                     |
++----------------------------------------------------------------------------+
+| Output Parameters : -                                                      |
++----------------------------------------------------------------------------+
+| Return Value      : -                                                      |
++----------------------------------------------------------------------------+
+*/
+         
+int     i_APCI3XXX_Reset(comedi_device *dev) 
+       {
+       unsigned char b_Cpt = 0;
+       
+       /*************************/
+       /* Disable the interrupt */
+       /*************************/
+       
+       disable_irq(dev->irq);
+       
+       /****************************/
+       /* Reset the interrupt flag */
+       /****************************/
+       
+       devpriv->b_EocEosInterrupt = 0;
+       
+       /***************************/
+       /* Clear the start command */
+       /***************************/
+       
+       writel (0, (void *) (devpriv->dw_AiBase + 8));
+       
+       /*****************************/
+       /* Reset the interrupt flags */
+       /*****************************/
+       
+       writel (readl ((void *) (devpriv->dw_AiBase + 16)), (void *) (devpriv->dw_AiBase + 16));
+       
+       /*****************/
+       /* clear the EOS */
+       /*****************/
+       
+       readl ((void *) (devpriv->dw_AiBase + 20));
+       
+       /******************/
+       /* Clear the FIFO */
+       /******************/
+       
+       for (b_Cpt = 0; b_Cpt < 16; b_Cpt ++)
+          {
+          readl ((void *) (devpriv->dw_AiBase + 28));
+          }
+       
+       /************************/
+       /* Enable the interrupt */
+       /************************/
+       
+       enable_irq(dev->irq);
+       
+       return 0;
+       }        
diff --git a/comedi/drivers/addi-data/hwdrv_apci3xxx.h b/comedi/drivers/addi-data/hwdrv_apci3xxx.h
new file mode 100755 (executable)
index 0000000..1f670e9
--- /dev/null
@@ -0,0 +1,70 @@
+/**\r
+@verbatim\r
+\r
+Copyright (C) 2004,2005  ADDI-DATA GmbH for the source code of this module. \r
+        \r
+        ADDI-DATA GmbH \r
+        Dieselstrasse 3 \r
+        D-77833 Ottersweier \r
+        Tel: +19(0)7223/9493-0 \r
+        Fax: +49(0)7223/9493-92 \r
+        http://www.addi-data-com \r
+        info@addi-data.com \r
+\r
+This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.\r
+\r
+This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.\r
+\r
+You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+\r
+You shoud also find the complete GPL in the COPYING file accompanying this source code.\r
+\r
+@endverbatim\r
+*/\r
+\r
+\r
+\r
+#ifndef COMEDI_SUBD_TTLIO\r
+   #define COMEDI_SUBD_TTLIO   11  /* Digital Input Output But TTL */\r
+#endif\r
+\r
+#ifndef ADDIDATA_ENABLE\r
+   #define ADDIDATA_ENABLE  1\r
+   #define ADDIDATA_DISABLE 0\r
+#endif\r
+\r
+#define APCI3XXX_SINGLE                              0\r
+#define APCI3XXX_DIFF                                1\r
+#define APCI3XXX_CONFIGURATION                       0\r
+\r
+\r
+#define APCI3XXX_TTL_INIT_DIRECTION_PORT2   0\r
+\r
+#ifdef __KERNEL__\r
+\r
+\r
+comedi_lrange range_apci3XXX_ai={ 8, {BIP_RANGE(10),\r
+                                      BIP_RANGE(5),\r
+                                      BIP_RANGE(2),\r
+                                      BIP_RANGE(1),\r
+                                      UNI_RANGE(10),\r
+                                      UNI_RANGE(5),\r
+                                      UNI_RANGE(2),\r
+                                      UNI_RANGE(1)}};\r
+                                     \r
+comedi_lrange range_apci3XXX_ttl= {12, {BIP_RANGE(1),\r
+                                        BIP_RANGE(1),\r
+                                        BIP_RANGE(1),\r
+                                        BIP_RANGE(1),\r
+                                        BIP_RANGE(1),\r
+                                        BIP_RANGE(1),\r
+                                        BIP_RANGE(1),\r
+                                        BIP_RANGE(1),\r
+                                        BIP_RANGE(1),\r
+                                        BIP_RANGE(1),\r
+                                        BIP_RANGE(1),\r
+                                        BIP_RANGE(1)}};\r
+\r
+comedi_lrange range_apci3XXX_ao= { 2, {BIP_RANGE(10),\r
+                                       UNI_RANGE(10)}};\r
+#endif\r