4 Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module.
10 Fax: +49(0)7223/9493-92
11 http://www.addi-data.com
14 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.
16 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.
18 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
20 You should also find the complete GPL in the COPYING file accompanying this source code.
26 +-----------------------------------------------------------------------+
27 | (C) ADDI-DATA GmbH Dieselstraße 3 D-77833 Ottersweier |
28 +-----------------------------------------------------------------------+
29 | Tel : +49 (0) 7223/9493-0 | email : info@addi-data.com |
30 | Fax : +49 (0) 7223/9493-92 | Internet : http://www.addi-data.com |
31 +-----------------------------------------------------------------------+
32 | Project : API APCI1710 | Compiler : gcc |
33 | Module name : CHRONO.C | Version : 2.96 |
34 +-------------------------------+---------------------------------------+
35 | Project manager: Eric Stolz | Date : 02/12/2002 |
36 +-----------------------------------------------------------------------+
37 | Description : APCI-1710 chronometer module |
40 +-----------------------------------------------------------------------+
42 +-----------------------------------------------------------------------+
43 | Date | Author | Description of updates |
44 +----------+-----------+------------------------------------------------+
45 | 29/06/98 | S. Weber | Digital input / output implementation |
46 |----------|-----------|------------------------------------------------|
47 | 08/05/00 | Guinot C | - 0400/0228 All Function in RING 0 |
49 +-----------------------------------------------------------------------+
52 +-----------------------------------------------------------------------+
56 +----------------------------------------------------------------------------+
58 +----------------------------------------------------------------------------+
60 #include "APCI1710_Chrono.h"
63 +----------------------------------------------------------------------------+
64 | Function Name : _INT_ i_APCI1710_InitChrono |
65 | (unsigned char_ b_BoardHandle, |
66 | unsigned char_ b_ModulNbr, |
67 | unsigned char_ b_ChronoMode, |
68 | unsigned char_ b_PCIInputClock, |
69 | unsigned char_ b_TimingUnit, |
70 | ULONG_ ul_TimingInterval, |
71 | PULONG_ pul_RealTimingInterval)
73 +----------------------------------------------------------------------------+
74 | Task : Configure the chronometer operating mode (b_ChronoMode)|
75 | from selected module (b_ModulNbr). |
76 | The ul_TimingInterval and ul_TimingUnit determine the |
77 | timing base for the measurement. |
78 | The pul_RealTimingInterval return the real timing |
79 | value. You must calling this function be for you call |
80 | any other function witch access of the chronometer. |
82 | Witch this functionality from the APCI-1710 you have |
83 | the possibility to measure the timing witch two event. |
85 | The mode 0 and 1 is appropriate for period measurement.|
86 | The mode 2 and 3 is appropriate for frequent |
88 | The mode 4 to 7 is appropriate for measuring the timing|
89 | between two event. |
90 +----------------------------------------------------------------------------+
91 | Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
92 | unsigned char_ b_ModulNbr CR_AREF(insn->chanspec) : Module number to configure |
94 | unsigned char_ b_ChronoMode data[0] : Chronometer action mode |
96 | unsigned char_ b_PCIInputClock data[1] : Selection from PCI bus clock|
97 | - APCI1710_30MHZ : |
98 | The PC have a PCI bus |
100 | - APCI1710_33MHZ : |
101 | The PC have a PCI bus |
102 | clock from 33 MHz |
104 | The APCI-1710 have a |
107 | unsigned char_ b_TimingUnit data[2] : Base timing unity (0 to 4) |
113 | ULONG_ ul_TimingInterval : data[3] Base timing value. |
114 +----------------------------------------------------------------------------+
115 | Output Parameters : PULONG_ pul_RealTimingInterval : Real base timing |
118 +----------------------------------------------------------------------------+
119 | Return Value : 0: No error |
120 | -1: The handle parameter of the board is wrong |
121 | -2: Module selection wrong |
122 | -3: The module is not a Chronometer module |
123 | -4: Chronometer mode selection is wrong |
124 | -5: The selected PCI input clock is wrong |
125 | -6: Timing unity selection is wrong |
126 | -7: Base timing selection is wrong |
127 | -8: You can not used the 40MHz clock selection with |
129 | -9: You can not used the 40MHz clock selection with |
130 | this CHRONOS version |
131 +----------------------------------------------------------------------------+
134 int i_APCI1710_InsnConfigInitChrono(struct comedi_device *dev, struct comedi_subdevice *s,
135 struct comedi_insn *insn, unsigned int *data)
137 struct addi_private *devpriv = dev->private;
138 int i_ReturnValue = 0;
139 unsigned int ul_TimerValue = 0;
140 unsigned int ul_TimingInterval = 0;
141 unsigned int ul_RealTimingInterval = 0;
142 double d_RealTimingInterval = 0;
143 unsigned int dw_ModeArray[8] =
144 { 0x01, 0x05, 0x00, 0x04, 0x02, 0x0E, 0x0A, 0x06 };
145 unsigned char b_ModulNbr, b_ChronoMode, b_PCIInputClock, b_TimingUnit;
147 b_ModulNbr = CR_AREF(insn->chanspec);
148 b_ChronoMode = (unsigned char) data[0];
149 b_PCIInputClock = (unsigned char) data[1];
150 b_TimingUnit = (unsigned char) data[2];
151 ul_TimingInterval = (unsigned int) data[3];
152 i_ReturnValue = insn->n;
154 /**************************/
155 /* Test the module number */
156 /**************************/
158 if (b_ModulNbr < 4) {
159 /***********************/
160 /* Test if chronometer */
161 /***********************/
163 if ((devpriv->s_BoardInfos.
164 dw_MolduleConfiguration[b_ModulNbr] &
165 0xFFFF0000UL) == APCI1710_CHRONOMETER) {
166 /*****************************/
167 /* Test the chronometer mode */
168 /*****************************/
170 if (b_ChronoMode <= 7) {
171 /**************************/
172 /* Test the PCI bus clock */
173 /**************************/
175 if ((b_PCIInputClock == APCI1710_30MHZ) ||
176 (b_PCIInputClock == APCI1710_33MHZ) ||
177 (b_PCIInputClock == APCI1710_40MHZ)) {
178 /*************************/
179 /* Test the timing unity */
180 /*************************/
182 if (b_TimingUnit <= 4) {
183 /**********************************/
184 /* Test the base timing selection */
185 /**********************************/
187 if (((b_PCIInputClock == APCI1710_30MHZ) && (b_TimingUnit == 0) && (ul_TimingInterval >= 66) && (ul_TimingInterval <= 0xFFFFFFFFUL)) || ((b_PCIInputClock == APCI1710_30MHZ) && (b_TimingUnit == 1) && (ul_TimingInterval >= 1) && (ul_TimingInterval <= 143165576UL)) || ((b_PCIInputClock == APCI1710_30MHZ) && (b_TimingUnit == 2) && (ul_TimingInterval >= 1) && (ul_TimingInterval <= 143165UL)) || ((b_PCIInputClock == APCI1710_30MHZ) && (b_TimingUnit == 3) && (ul_TimingInterval >= 1) && (ul_TimingInterval <= 143UL)) || ((b_PCIInputClock == APCI1710_30MHZ) && (b_TimingUnit == 4) && (ul_TimingInterval >= 1) && (ul_TimingInterval <= 2UL)) || ((b_PCIInputClock == APCI1710_33MHZ) && (b_TimingUnit == 0) && (ul_TimingInterval >= 60) && (ul_TimingInterval <= 0xFFFFFFFFUL)) || ((b_PCIInputClock == APCI1710_33MHZ) && (b_TimingUnit == 1) && (ul_TimingInterval >= 1) && (ul_TimingInterval <= 130150240UL)) || ((b_PCIInputClock == APCI1710_33MHZ) && (b_TimingUnit == 2) && (ul_TimingInterval >= 1) && (ul_TimingInterval <= 130150UL)) || ((b_PCIInputClock == APCI1710_33MHZ) && (b_TimingUnit == 3) && (ul_TimingInterval >= 1) && (ul_TimingInterval <= 130UL)) || ((b_PCIInputClock == APCI1710_33MHZ) && (b_TimingUnit == 4) && (ul_TimingInterval >= 1) && (ul_TimingInterval <= 2UL)) || ((b_PCIInputClock == APCI1710_40MHZ) && (b_TimingUnit == 0) && (ul_TimingInterval >= 50) && (ul_TimingInterval <= 0xFFFFFFFFUL)) || ((b_PCIInputClock == APCI1710_40MHZ) && (b_TimingUnit == 1) && (ul_TimingInterval >= 1) && (ul_TimingInterval <= 107374182UL)) || ((b_PCIInputClock == APCI1710_40MHZ) && (b_TimingUnit == 2) && (ul_TimingInterval >= 1) && (ul_TimingInterval <= 107374UL)) || ((b_PCIInputClock == APCI1710_40MHZ) && (b_TimingUnit == 3) && (ul_TimingInterval >= 1) && (ul_TimingInterval <= 107UL)) || ((b_PCIInputClock == APCI1710_40MHZ) && (b_TimingUnit == 4) && (ul_TimingInterval >= 1) && (ul_TimingInterval <= 1UL))) {
188 /**************************/
189 /* Test the board version */
190 /**************************/
192 if (((b_PCIInputClock == APCI1710_40MHZ) && (devpriv->s_BoardInfos.b_BoardVersion > 0)) || (b_PCIInputClock != APCI1710_40MHZ)) {
193 /************************/
194 /* Test the TOR version */
195 /************************/
197 if (((b_PCIInputClock == APCI1710_40MHZ) && ((devpriv->s_BoardInfos.dw_MolduleConfiguration[b_ModulNbr] & 0xFFFF) >= 0x3131)) || (b_PCIInputClock != APCI1710_40MHZ)) {
201 /****************************************/
202 /* Calculate the timer 0 division fator */
203 /****************************************/
205 switch (b_TimingUnit) {
221 (0.001 * b_PCIInputClock));
223 /*******************/
224 /* Round the value */
225 /*******************/
227 if ((double)((double)ul_TimingInterval * (0.001 * (double)b_PCIInputClock)) >= ((double)((double)ul_TimerValue + 0.5))) {
235 /*****************************/
236 /* Calculate the real timing */
237 /*****************************/
239 ul_RealTimingInterval
244 (0.001 * (double)b_PCIInputClock));
255 if ((double)((double)ul_TimerValue / (0.001 * (double)b_PCIInputClock)) >= (double)((double)ul_RealTimingInterval + 0.5)) {
256 ul_RealTimingInterval
258 ul_RealTimingInterval
273 if (b_PCIInputClock != APCI1710_40MHZ) {
301 (1.0 * b_PCIInputClock));
303 /*******************/
304 /* Round the value */
305 /*******************/
307 if ((double)((double)ul_TimingInterval * (1.0 * (double)b_PCIInputClock)) >= ((double)((double)ul_TimerValue + 0.5))) {
315 /*****************************/
316 /* Calculate the real timing */
317 /*****************************/
319 ul_RealTimingInterval
324 (1.0 * (double)b_PCIInputClock));
337 if ((double)((double)ul_TimerValue / (1.0 * (double)b_PCIInputClock)) >= (double)((double)ul_RealTimingInterval + 0.5)) {
338 ul_RealTimingInterval
340 ul_RealTimingInterval
355 if (b_PCIInputClock != APCI1710_40MHZ) {
386 /*******************/
387 /* Round the value */
388 /*******************/
390 if ((double)((double)ul_TimingInterval * (1000.0 * (double)b_PCIInputClock)) >= ((double)((double)ul_TimerValue + 0.5))) {
398 /*****************************/
399 /* Calculate the real timing */
400 /*****************************/
402 ul_RealTimingInterval
407 (1000.0 * (double)b_PCIInputClock));
418 if ((double)((double)ul_TimerValue / (1000.0 * (double)b_PCIInputClock)) >= (double)((double)ul_RealTimingInterval + 0.5)) {
419 ul_RealTimingInterval
421 ul_RealTimingInterval
436 if (b_PCIInputClock != APCI1710_40MHZ) {
468 /*******************/
469 /* Round the value */
470 /*******************/
472 if ((double)((double)ul_TimingInterval * (1000000.0 * (double)b_PCIInputClock)) >= ((double)((double)ul_TimerValue + 0.5))) {
480 /*****************************/
481 /* Calculate the real timing */
482 /*****************************/
484 ul_RealTimingInterval
503 if ((double)((double)ul_TimerValue / (1000000.0 * (double)b_PCIInputClock)) >= (double)((double)ul_RealTimingInterval + 0.5)) {
504 ul_RealTimingInterval
506 ul_RealTimingInterval
521 if (b_PCIInputClock != APCI1710_40MHZ) {
556 /*******************/
557 /* Round the value */
558 /*******************/
560 if ((double)((double)(ul_TimingInterval * 60.0) * (1000000.0 * (double)b_PCIInputClock)) >= ((double)((double)ul_TimerValue + 0.5))) {
568 /*****************************/
569 /* Calculate the real timing */
570 /*****************************/
572 ul_RealTimingInterval
589 (0.001 * (double)b_PCIInputClock)) / 60.0;
591 if ((double)(((double)ul_TimerValue / (1000000.0 * (double)b_PCIInputClock)) / 60.0) >= (double)((double)ul_RealTimingInterval + 0.5)) {
592 ul_RealTimingInterval
594 ul_RealTimingInterval
609 if (b_PCIInputClock != APCI1710_40MHZ) {
625 /****************************/
626 /* Save the PCI input clock */
627 /****************************/
637 /*************************/
638 /* Save the timing unity */
639 /*************************/
649 /************************/
650 /* Save the base timing */
651 /************************/
659 d_RealTimingInterval;
661 /****************************/
662 /* Set the chronometer mode */
663 /****************************/
674 /***********************/
675 /* Test if 40 MHz used */
676 /***********************/
678 if (b_PCIInputClock == APCI1710_40MHZ) {
694 outl(devpriv->s_ModuleInfo[b_ModulNbr].s_ChronoModuleInfo.dw_ConfigReg, devpriv->s_BoardInfos.ui_Address + 16 + (64 * b_ModulNbr));
696 /***********************/
697 /* Write timer 0 value */
698 /***********************/
700 outl(ul_TimerValue, devpriv->s_BoardInfos.ui_Address + (64 * b_ModulNbr));
702 /*********************/
703 /* Chronometer init. */
704 /*********************/
714 /***********************************************/
715 /* TOR version error for 40MHz clock selection */
716 /***********************************************/
718 DPRINTK("TOR version error for 40MHz clock selection\n");
724 /**************************************************************/
725 /* You can not use the 40MHz clock selection with this board */
726 /**************************************************************/
728 DPRINTK("You can not used the 40MHz clock selection with this board\n");
733 /**********************************/
734 /* Base timing selection is wrong */
735 /**********************************/
737 DPRINTK("Base timing selection is wrong\n");
740 } /* if ((b_TimingUnit >= 0) && (b_TimingUnit <= 4)) */
742 /***********************************/
743 /* Timing unity selection is wrong */
744 /***********************************/
746 DPRINTK("Timing unity selection is wrong\n");
748 } /* if ((b_TimingUnit >= 0) && (b_TimingUnit <= 4)) */
749 } /* if ((b_PCIInputClock == APCI1710_30MHZ) || (b_PCIInputClock == APCI1710_33MHZ)) */
751 /*****************************************/
752 /* The selected PCI input clock is wrong */
753 /*****************************************/
755 DPRINTK("The selected PCI input clock is wrong\n");
757 } /* if ((b_PCIInputClock == APCI1710_30MHZ) || (b_PCIInputClock == APCI1710_33MHZ)) */
758 } /* if (b_ChronoMode >= 0 && b_ChronoMode <= 7) */
760 /***************************************/
761 /* Chronometer mode selection is wrong */
762 /***************************************/
764 DPRINTK("Chronometer mode selection is wrong\n");
766 } /* if (b_ChronoMode >= 0 && b_ChronoMode <= 7) */
768 /******************************************/
769 /* The module is not a Chronometer module */
770 /******************************************/
772 DPRINTK("The module is not a Chronometer module\n");
776 /***********************/
777 /* Module number error */
778 /***********************/
780 DPRINTK("Module number error\n");
783 data[0] = ul_RealTimingInterval;
784 return i_ReturnValue;
788 +----------------------------------------------------------------------------+
789 | Function Name : _INT_ i_APCI1710_EnableChrono |
790 | (unsigned char_ b_BoardHandle, |
791 | unsigned char_ b_ModulNbr, |
792 | unsigned char_ b_CycleMode, |
793 | unsigned char_ b_InterruptEnable)
794 int i_APCI1710_InsnWriteEnableDisableChrono(struct comedi_device *dev,
795 struct comedi_subdevice *s,struct comedi_insn *insn,unsigned int *data) |
796 +----------------------------------------------------------------------------+
797 | Task : Enable the chronometer from selected module |
798 | (b_ModulNbr). You must calling the |
799 | "i_APCI1710_InitChrono" function be for you call this |
801 | If you enable the chronometer interrupt, the |
802 | chronometer generate a interrupt after the stop signal.|
803 | See function "i_APCI1710_SetBoardIntRoutineX" and the |
804 | Interrupt mask description chapter from this manual. |
805 | The b_CycleMode parameter determine if you will |
806 | measured a single or more cycle.
808 | Disable the chronometer from selected module |
809 | (b_ModulNbr). If you disable the chronometer after a |
810 | start signal occur and you restart the chronometer |
811 | witch the " i_APCI1710_EnableChrono" function, if no |
812 | stop signal occur this start signal is ignored.
813 +----------------------------------------------------------------------------+
814 | Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
815 | unsigned char_ b_ModulNbr CR_AREF(chanspec) : Selected module number (0 to 3) |
816 data[0] ENABle/Disable chrono
817 | unsigned char_ b_CycleMode : Selected the chronometer |
818 | data[1] acquisition mode |
819 | unsigned char_ b_InterruptEnable : Enable or disable the |
820 | data[2] chronometer interrupt. |
822 | Enable the chronometer |
824 | APCI1710_DISABLE: |
825 | Disable the chronometer |
827 +----------------------------------------------------------------------------+
828 | Output Parameters : - |
829 +----------------------------------------------------------------------------+
830 | Return Value : 0: No error |
831 | -1: The handle parameter of the board is wrong |
832 | -2: Module selection wrong |
833 | -3: The module is not a Chronometer module |
834 | -4: Chronometer not initialised see function |
835 | "i_APCI1710_InitChrono" |
836 | -5: Chronometer acquisition mode cycle is wrong |
837 | -6: Interrupt parameter is wrong |
838 | -7: Interrupt function not initialised. |
839 | See function "i_APCI1710_SetBoardIntRoutineX"
840 -8: data[0] wrong input |
841 +----------------------------------------------------------------------------+
844 int i_APCI1710_InsnWriteEnableDisableChrono(struct comedi_device *dev,
845 struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
847 struct addi_private *devpriv = dev->private;
848 int i_ReturnValue = 0;
849 unsigned char b_ModulNbr, b_CycleMode, b_InterruptEnable, b_Action;
850 b_ModulNbr = CR_AREF(insn->chanspec);
851 b_Action = (unsigned char) data[0];
852 b_CycleMode = (unsigned char) data[1];
853 b_InterruptEnable = (unsigned char) data[2];
854 i_ReturnValue = insn->n;
856 /**************************/
857 /* Test the module number */
858 /**************************/
860 if (b_ModulNbr < 4) {
861 /***********************/
862 /* Test if chronometer */
863 /***********************/
865 if ((devpriv->s_BoardInfos.
866 dw_MolduleConfiguration[b_ModulNbr] &
867 0xFFFF0000UL) == APCI1710_CHRONOMETER) {
868 /***********************************/
869 /* Test if chronometer initialised */
870 /***********************************/
872 if (devpriv->s_ModuleInfo[b_ModulNbr].
873 s_ChronoModuleInfo.b_ChronoInit == 1) {
877 case APCI1710_ENABLE:
879 /*********************************/
880 /* Test the cycle mode parameter */
881 /*********************************/
883 if ((b_CycleMode == APCI1710_SINGLE)
885 APCI1710_CONTINUOUS)) {
886 /***************************/
887 /* Test the interrupt flag */
888 /***************************/
890 if ((b_InterruptEnable ==
892 || (b_InterruptEnable ==
896 /***************************/
897 /* Save the interrupt flag */
898 /***************************/
908 /***********************/
909 /* Save the cycle mode */
910 /***********************/
935 /*****************************/
936 /* Test if interrupt enabled */
937 /*****************************/
939 if (b_InterruptEnable ==
942 /****************************/
943 /* Clear the interrupt flag */
944 /****************************/
956 devpriv->tsk_Current = current; /* Save the current process task structure */
959 /***********************************/
960 /* Enable or disable the interrupt */
961 /* Enable the chronometer */
962 /***********************************/
975 /*************************/
976 /* Clear status register */
977 /*************************/
985 } /* if ((b_InterruptEnable == APCI1710_ENABLE) || (b_InterruptEnable == APCI1710_DISABLE)) */
987 /********************************/
988 /* Interrupt parameter is wrong */
989 /********************************/
991 DPRINTK("Interrupt parameter is wrong\n");
993 } /* if ((b_InterruptEnable == APCI1710_ENABLE) || (b_InterruptEnable == APCI1710_DISABLE)) */
994 } /* if ((b_CycleMode == APCI1710_SINGLE) || (b_CycleMode == APCI1710_CONTINUOUS)) */
996 /***********************************************/
997 /* Chronometer acquisition mode cycle is wrong */
998 /***********************************************/
1000 DPRINTK("Chronometer acquisition mode cycle is wrong\n");
1002 } /* if ((b_CycleMode == APCI1710_SINGLE) || (b_CycleMode == APCI1710_CONTINUOUS)) */
1005 case APCI1710_DISABLE:
1007 devpriv->s_ModuleInfo[b_ModulNbr].
1009 b_InterruptMask = 0;
1011 devpriv->s_ModuleInfo[b_ModulNbr].
1015 s_ModuleInfo[b_ModulNbr].
1017 dw_ConfigReg & 0x2F;
1019 /***************************/
1020 /* Disable the interrupt */
1021 /* Disable the chronometer */
1022 /***************************/
1024 outl(devpriv->s_ModuleInfo[b_ModulNbr].
1025 s_ChronoModuleInfo.dw_ConfigReg,
1026 devpriv->s_BoardInfos.
1030 /***************************/
1031 /* Test if continuous mode */
1032 /***************************/
1034 if (devpriv->s_ModuleInfo[b_ModulNbr].
1037 APCI1710_CONTINUOUS) {
1038 /*************************/
1039 /* Clear status register */
1040 /*************************/
1042 outl(0, devpriv->s_BoardInfos.
1049 DPRINTK("Inputs wrong! Enable or Disable chrono\n");
1051 } /* switch ENABLE/DISABLE */
1053 /*******************************/
1054 /* Chronometer not initialised */
1055 /*******************************/
1057 DPRINTK("Chronometer not initialised\n");
1061 /******************************************/
1062 /* The module is not a Chronometer module */
1063 /******************************************/
1065 DPRINTK("The module is not a Chronometer module\n");
1069 /***********************/
1070 /* Module number error */
1071 /***********************/
1073 DPRINTK("Module number error\n");
1077 return i_ReturnValue;
1081 +----------------------------------------------------------------------------+
1082 | Function Name :INT i_APCI1710_InsnReadChrono(struct comedi_device *dev,struct comedi_subdevice *s,
1083 struct comedi_insn *insn,unsigned int *data) |
1084 +----------------------------------------------------------------------------+
1085 | Task : Read functions for Timer |
1086 +----------------------------------------------------------------------------+
1087 | Input Parameters :
1088 +----------------------------------------------------------------------------+
1089 | Output Parameters : - |
1090 +----------------------------------------------------------------------------+
1092 +----------------------------------------------------------------------------+
1095 int i_APCI1710_InsnReadChrono(struct comedi_device *dev, struct comedi_subdevice *s,
1096 struct comedi_insn *insn, unsigned int *data)
1098 struct addi_private *devpriv = dev->private;
1099 unsigned char b_ReadType;
1100 int i_ReturnValue = insn->n;
1102 b_ReadType = CR_CHAN(insn->chanspec);
1104 switch (b_ReadType) {
1105 case APCI1710_CHRONO_PROGRESS_STATUS:
1106 i_ReturnValue = i_APCI1710_GetChronoProgressStatus(dev,
1107 (unsigned char) CR_AREF(insn->chanspec), (unsigned char *) &data[0]);
1110 case APCI1710_CHRONO_READVALUE:
1111 i_ReturnValue = i_APCI1710_ReadChronoValue(dev,
1112 (unsigned char) CR_AREF(insn->chanspec),
1113 (unsigned int) insn->unused[0],
1114 (unsigned char *) &data[0], (unsigned int *) &data[1]);
1117 case APCI1710_CHRONO_CONVERTVALUE:
1118 i_ReturnValue = i_APCI1710_ConvertChronoValue(dev,
1119 (unsigned char) CR_AREF(insn->chanspec),
1120 (unsigned int) insn->unused[0],
1121 (unsigned int *) &data[0],
1122 (unsigned char *) &data[1],
1123 (unsigned char *) &data[2],
1124 (unsigned int *) &data[3],
1125 (unsigned int *) &data[4], (unsigned int *) &data[5]);
1128 case APCI1710_CHRONO_READINTERRUPT:
1129 printk("In Chrono Read Interrupt\n");
1131 data[0] = devpriv->s_InterruptParameters.
1132 s_FIFOInterruptParameters[devpriv->
1133 s_InterruptParameters.ui_Read].b_OldModuleMask;
1134 data[1] = devpriv->s_InterruptParameters.
1135 s_FIFOInterruptParameters[devpriv->
1136 s_InterruptParameters.ui_Read].ul_OldInterruptMask;
1137 data[2] = devpriv->s_InterruptParameters.
1138 s_FIFOInterruptParameters[devpriv->
1139 s_InterruptParameters.ui_Read].ul_OldCounterLatchValue;
1141 /**************************/
1142 /* Increment the read FIFO */
1143 /***************************/
1146 s_InterruptParameters.
1147 ui_Read = (devpriv->
1148 s_InterruptParameters.
1149 ui_Read + 1) % APCI1710_SAVE_INTERRUPT;
1153 printk("ReadType Parameter wrong\n");
1156 if (i_ReturnValue >= 0)
1157 i_ReturnValue = insn->n;
1158 return i_ReturnValue;
1163 +----------------------------------------------------------------------------+
1164 | Function Name : _INT_ i_APCI1710_GetChronoProgressStatus |
1165 | (unsigned char_ b_BoardHandle, |
1166 | unsigned char_ b_ModulNbr, |
1167 | unsigned char *_ pb_ChronoStatus) |
1168 +----------------------------------------------------------------------------+
1169 | Task : Return the chronometer status (pb_ChronoStatus) from |
1170 | selected chronometer module (b_ModulNbr). |
1171 +----------------------------------------------------------------------------+
1172 | Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
1173 | unsigned char_ b_ModulNbr : Selected module number (0 to 3) |
1174 +----------------------------------------------------------------------------+
1175 | Output Parameters : PULONG_ pb_ChronoStatus : Return the chronometer |
1177 | 0 : Measurement not started.|
1178 | No start signal occur. |
1179 | 1 : Measurement started. |
1180 | A start signal occur. |
1181 | 2 : Measurement stopped. |
1182 | A stop signal occur. |
1183 | The measurement is |
1185 | 3: A overflow occur. You |
1186 | must change the base |
1187 | timing witch the |
1189 | "i_APCI1710_InitChrono" |
1190 +----------------------------------------------------------------------------+
1191 | Return Value : 0: No error |
1192 | -1: The handle parameter of the board is wrong |
1193 | -2: Module selection wrong |
1194 | -3: The module is not a Chronometer module |
1195 | -4: Chronometer not initialised see function |
1196 | "i_APCI1710_InitChrono" |
1197 +----------------------------------------------------------------------------+
1200 int i_APCI1710_GetChronoProgressStatus(struct comedi_device *dev,
1201 unsigned char b_ModulNbr, unsigned char *pb_ChronoStatus)
1203 struct addi_private *devpriv = dev->private;
1204 int i_ReturnValue = 0;
1205 unsigned int dw_Status;
1207 /**************************/
1208 /* Test the module number */
1209 /**************************/
1211 if (b_ModulNbr < 4) {
1212 /***********************/
1213 /* Test if chronometer */
1214 /***********************/
1216 if ((devpriv->s_BoardInfos.
1217 dw_MolduleConfiguration[b_ModulNbr] &
1218 0xFFFF0000UL) == APCI1710_CHRONOMETER) {
1219 /***********************************/
1220 /* Test if chronometer initialised */
1221 /***********************************/
1224 s_ModuleInfo[b_ModulNbr].
1225 s_ChronoModuleInfo.b_ChronoInit == 1) {
1227 dw_Status = inl(devpriv->s_BoardInfos.
1228 ui_Address + 8 + (64 * b_ModulNbr));
1230 /********************/
1231 /* Test if overflow */
1232 /********************/
1234 if ((dw_Status & 8) == 8) {
1235 /******************/
1236 /* Overflow occur */
1237 /******************/
1239 *pb_ChronoStatus = 3;
1240 } /* if ((dw_Status & 8) == 8) */
1242 /*******************************/
1243 /* Test if measurement stopped */
1244 /*******************************/
1246 if ((dw_Status & 2) == 2) {
1247 /***********************/
1248 /* A stop signal occur */
1249 /***********************/
1251 *pb_ChronoStatus = 2;
1252 } /* if ((dw_Status & 2) == 2) */
1254 /*******************************/
1255 /* Test if measurement started */
1256 /*******************************/
1258 if ((dw_Status & 1) == 1) {
1259 /************************/
1260 /* A start signal occur */
1261 /************************/
1263 *pb_ChronoStatus = 1;
1264 } /* if ((dw_Status & 1) == 1) */
1266 /***************************/
1267 /* Measurement not started */
1268 /***************************/
1270 *pb_ChronoStatus = 0;
1271 } /* if ((dw_Status & 1) == 1) */
1272 } /* if ((dw_Status & 2) == 2) */
1273 } /* if ((dw_Status & 8) == 8) */
1275 /*******************************/
1276 /* Chronometer not initialised */
1277 /*******************************/
1278 DPRINTK("Chronometer not initialised\n");
1282 /******************************************/
1283 /* The module is not a Chronometer module */
1284 /******************************************/
1285 DPRINTK("The module is not a Chronometer module\n");
1289 /***********************/
1290 /* Module number error */
1291 /***********************/
1292 DPRINTK("Module number error\n");
1296 return i_ReturnValue;
1300 +----------------------------------------------------------------------------+
1301 | Function Name : _INT_ i_APCI1710_ReadChronoValue |
1302 | (unsigned char_ b_BoardHandle, |
1303 | unsigned char_ b_ModulNbr, |
1304 | unsigned int_ ui_TimeOut, |
1305 | unsigned char *_ pb_ChronoStatus, |
1306 | PULONG_ pul_ChronoValue) |
1307 +----------------------------------------------------------------------------+
1308 | Task : Return the chronometer status (pb_ChronoStatus) and the|
1309 | timing value (pul_ChronoValue) after a stop signal |
1310 | occur from selected chronometer module (b_ModulNbr). |
1311 | This function are only avaible if you have disabled |
1312 | the interrupt functionality. See function |
1313 | "i_APCI1710_EnableChrono" and the Interrupt mask |
1314 | description chapter. |
1315 | You can test the chronometer status witch the |
1316 | "i_APCI1710_GetChronoProgressStatus" function. |
1318 | The returned value from pul_ChronoValue parameter is |
1319 | not real measured timing. |
1320 | You must used the "i_APCI1710_ConvertChronoValue" |
1321 | function or make this operation for calculate the |
1324 | Timing = pul_ChronoValue * pul_RealTimingInterval. |
1326 | pul_RealTimingInterval is the returned parameter from |
1327 | "i_APCI1710_InitChrono" function and the time unity is |
1328 | the b_TimingUnit from "i_APCI1710_InitChrono" function|
1329 +----------------------------------------------------------------------------+
1330 | Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
1331 | unsigned char_ b_ModulNbr : Selected module number (0 to 3) |
1332 +----------------------------------------------------------------------------+
1333 | Output Parameters : PULONG_ pb_ChronoStatus : Return the chronometer |
1335 | 0 : Measurement not started.|
1336 | No start signal occur. |
1337 | 1 : Measurement started. |
1338 | A start signal occur. |
1339 | 2 : Measurement stopped. |
1340 | A stop signal occur. |
1341 | The measurement is |
1343 | 3: A overflow occur. You |
1344 | must change the base |
1345 | timing witch the |
1347 | "i_APCI1710_InitChrono" |
1348 | unsigned int * pul_ChronoValue : Chronometer timing value. |
1349 +----------------------------------------------------------------------------+
1350 | Return Value : 0: No error |
1351 | -1: The handle parameter of the board is wrong |
1352 | -2: Module selection wrong |
1353 | -3: The module is not a Chronometer module |
1354 | -4: Chronometer not initialised see function |
1355 | "i_APCI1710_InitChrono" |
1356 | -5: Timeout parameter is wrong (0 to 65535) |
1357 | -6: Interrupt routine installed. You can not read |
1358 | directly the chronometer measured timing. |
1359 +----------------------------------------------------------------------------+
1362 int i_APCI1710_ReadChronoValue(struct comedi_device *dev,
1363 unsigned char b_ModulNbr,
1364 unsigned int ui_TimeOut, unsigned char *pb_ChronoStatus, unsigned int *pul_ChronoValue)
1366 struct addi_private *devpriv = dev->private;
1367 int i_ReturnValue = 0;
1368 unsigned int dw_Status;
1369 unsigned int dw_TimeOut = 0;
1371 /**************************/
1372 /* Test the module number */
1373 /**************************/
1375 if (b_ModulNbr < 4) {
1376 /***********************/
1377 /* Test if chronometer */
1378 /***********************/
1380 if ((devpriv->s_BoardInfos.
1381 dw_MolduleConfiguration[b_ModulNbr] &
1382 0xFFFF0000UL) == APCI1710_CHRONOMETER) {
1383 /***********************************/
1384 /* Test if chronometer initialised */
1385 /***********************************/
1388 s_ModuleInfo[b_ModulNbr].
1389 s_ChronoModuleInfo.b_ChronoInit == 1) {
1390 /*****************************/
1391 /* Test the timout parameter */
1392 /*****************************/
1394 if (ui_TimeOut <= 65535UL) {
1397 /*******************/
1398 /* Read the status */
1399 /*******************/
1407 /********************/
1408 /* Test if overflow */
1409 /********************/
1411 if ((dw_Status & 8) == 8) {
1412 /******************/
1413 /* Overflow occur */
1414 /******************/
1416 *pb_ChronoStatus = 3;
1418 /***************************/
1419 /* Test if continuous mode */
1420 /***************************/
1427 APCI1710_CONTINUOUS)
1429 /*************************/
1430 /* Clear status register */
1431 /*************************/
1433 outl(0, devpriv->s_BoardInfos.ui_Address + 36 + (64 * b_ModulNbr));
1437 } /* if ((dw_Status & 8) == 8) */
1439 /*******************************/
1440 /* Test if measurement stopped */
1441 /*******************************/
1443 if ((dw_Status & 2) ==
1445 /***********************/
1446 /* A stop signal occur */
1447 /***********************/
1452 /***************************/
1453 /* Test if continnous mode */
1454 /***************************/
1462 APCI1710_CONTINUOUS)
1464 /*************************/
1465 /* Clear status register */
1466 /*************************/
1468 outl(0, devpriv->s_BoardInfos.ui_Address + 36 + (64 * b_ModulNbr));
1471 } /* if ((dw_Status & 2) == 2) */
1473 /*******************************/
1474 /* Test if measurement started */
1475 /*******************************/
1477 if ((dw_Status & 1) == 1) {
1478 /************************/
1479 /* A start signal occur */
1480 /************************/
1485 } /* if ((dw_Status & 1) == 1) */
1487 /***************************/
1488 /* Measurement not started */
1489 /***************************/
1494 } /* if ((dw_Status & 1) == 1) */
1495 } /* if ((dw_Status & 2) == 2) */
1496 } /* if ((dw_Status & 8) == 8) */
1498 if (dw_TimeOut == ui_TimeOut) {
1505 /*************************/
1506 /* Increment the timeout */
1507 /*************************/
1516 /*****************************/
1517 /* Test if stop signal occur */
1518 /*****************************/
1520 if (*pb_ChronoStatus == 2) {
1521 /**********************************/
1522 /* Read the measured timing value */
1523 /**********************************/
1531 if (*pul_ChronoValue != 0) {
1537 /*************************/
1538 /* Test if timeout occur */
1539 /*************************/
1541 if ((*pb_ChronoStatus != 3)
1544 && (ui_TimeOut != 0)) {
1549 *pb_ChronoStatus = 4;
1554 /******************************/
1555 /* Timeout parameter is wrong */
1556 /******************************/
1557 DPRINTK("Timeout parameter is wrong\n");
1561 /*******************************/
1562 /* Chronometer not initialised */
1563 /*******************************/
1564 DPRINTK("Chronometer not initialised\n");
1568 /******************************************/
1569 /* The module is not a Chronometer module */
1570 /******************************************/
1571 DPRINTK("The module is not a Chronometer module\n");
1575 /***********************/
1576 /* Module number error */
1577 /***********************/
1578 DPRINTK("Module number error\n");
1582 return i_ReturnValue;
1586 +----------------------------------------------------------------------------+
1587 | Function Name : _INT_ i_APCI1710_ConvertChronoValue |
1588 | (unsigned char_ b_BoardHandle, |
1589 | unsigned char_ b_ModulNbr, |
1590 | ULONG_ ul_ChronoValue, |
1591 | PULONG_ pul_Hour, |
1592 | unsigned char *_ pb_Minute, |
1593 | unsigned char *_ pb_Second, |
1594 | unsigned int *_ pui_MilliSecond, |
1595 | unsigned int *_ pui_MicroSecond, |
1596 | unsigned int *_ pui_NanoSecond) |
1597 +----------------------------------------------------------------------------+
1598 | Task : Convert the chronometer measured timing |
1599 | (ul_ChronoValue) in to h, mn, s, ms, µs, ns. |
1600 +----------------------------------------------------------------------------+
1601 | Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
1602 | unsigned char_ b_ModulNbr : Selected module number (0 to 3)|
1603 | ULONG_ ul_ChronoValue : Measured chronometer timing |
1605 | See"i_APCI1710_ReadChronoValue"|
1606 +----------------------------------------------------------------------------+
1607 | Output Parameters : PULONG_ pul_Hour : Chronometer timing hour |
1608 | unsigned char *_ pb_Minute : Chronometer timing minute |
1609 | unsigned char *_ pb_Second : Chronometer timing second |
1610 | unsigned int *_ pui_MilliSecond : Chronometer timing mini |
1612 | unsigned int *_ pui_MicroSecond : Chronometer timing micro |
1614 | unsigned int *_ pui_NanoSecond : Chronometer timing nano |
1616 +----------------------------------------------------------------------------+
1617 | Return Value : 0: No error |
1618 | -1: The handle parameter of the board is wrong |
1619 | -2: Module selection wrong |
1620 | -3: The module is not a Chronometer module |
1621 | -4: Chronometer not initialised see function |
1622 | "i_APCI1710_InitChrono" |
1623 +----------------------------------------------------------------------------+
1626 int i_APCI1710_ConvertChronoValue(struct comedi_device *dev,
1627 unsigned char b_ModulNbr,
1628 unsigned int ul_ChronoValue,
1629 unsigned int *pul_Hour,
1630 unsigned char *pb_Minute,
1631 unsigned char *pb_Second,
1632 unsigned int *pui_MilliSecond, unsigned int *pui_MicroSecond, unsigned int *pui_NanoSecond)
1634 struct addi_private *devpriv = dev->private;
1635 int i_ReturnValue = 0;
1639 double d_MilliSecond;
1640 double d_MicroSecond;
1641 double d_NanoSecond;
1643 /**************************/
1644 /* Test the module number */
1645 /**************************/
1647 if (b_ModulNbr < 4) {
1648 /***********************/
1649 /* Test if chronometer */
1650 /***********************/
1652 if ((devpriv->s_BoardInfos.
1653 dw_MolduleConfiguration[b_ModulNbr] &
1654 0xFFFF0000UL) == APCI1710_CHRONOMETER) {
1655 /***********************************/
1656 /* Test if chronometer initialised */
1657 /***********************************/
1660 s_ModuleInfo[b_ModulNbr].
1661 s_ChronoModuleInfo.b_ChronoInit == 1) {
1664 d_Hour = (double)ul_ChronoValue *(double)
1665 devpriv->s_ModuleInfo[b_ModulNbr].
1666 s_ChronoModuleInfo.d_TimingInterval;
1669 s_ModuleInfo[b_ModulNbr].
1670 s_ChronoModuleInfo.b_TimingUnit) {
1672 d_Hour = d_Hour / (double)1000.0;
1675 d_Hour = d_Hour / (double)1000.0;
1678 d_Hour = d_Hour / (double)1000.0;
1681 d_Hour = d_Hour / (double)60.0;
1684 /**********************/
1685 /* Calculate the hour */
1686 /**********************/
1688 d_Hour = d_Hour / (double)60.0;
1689 *pul_Hour = (unsigned int) d_Hour;
1691 /************************/
1692 /* Calculate the minute */
1693 /************************/
1695 d_Minute = d_Hour - *pul_Hour;
1696 d_Minute = d_Minute * 60;
1697 *pb_Minute = (unsigned char) d_Minute;
1699 /************************/
1700 /* Calculate the second */
1701 /************************/
1703 d_Second = d_Minute - *pb_Minute;
1704 d_Second = d_Second * 60;
1705 *pb_Second = (unsigned char) d_Second;
1707 /*****************************/
1708 /* Calculate the mini second */
1709 /*****************************/
1711 d_MilliSecond = d_Second - *pb_Second;
1712 d_MilliSecond = d_MilliSecond * 1000;
1713 *pui_MilliSecond = (unsigned int) d_MilliSecond;
1715 /******************************/
1716 /* Calculate the micro second */
1717 /******************************/
1722 d_MicroSecond = d_MicroSecond * 1000;
1723 *pui_MicroSecond = (unsigned int) d_MicroSecond;
1725 /******************************/
1726 /* Calculate the micro second */
1727 /******************************/
1732 d_NanoSecond = d_NanoSecond * 1000;
1733 *pui_NanoSecond = (unsigned int) d_NanoSecond;
1739 /*******************************/
1740 /* Chronometer not initialised */
1741 /*******************************/
1742 DPRINTK("Chronometer not initialised\n");
1746 /******************************************/
1747 /* The module is not a Chronometer module */
1748 /******************************************/
1749 DPRINTK("The module is not a Chronometer module\n");
1753 /***********************/
1754 /* Module number error */
1755 /***********************/
1756 DPRINTK("Module number error\n");
1760 return i_ReturnValue;
1764 +----------------------------------------------------------------------------+
1765 | Function Name : int i_APCI1710_InsnBitsChronoDigitalIO(struct comedi_device *dev,struct comedi_subdevice *s,
1766 struct comedi_insn *insn,unsigned int *data) |
1767 +----------------------------------------------------------------------------+
1768 | Task : Sets the output witch has been passed with the |
1769 | parameter b_Channel. Setting an output means setting an|
1771 +----------------------------------------------------------------------------+
1772 | Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
1773 | unsigned char_ b_ModulNbr : Selected module number (0 to 3)|
1774 | unsigned char_ b_OutputChannel : Selection from digital output |
1775 | CR_CHAN() channel (0 to 2) |
1779 +----------------------------------------------------------------------------+
1780 | Output Parameters : - |
1781 +----------------------------------------------------------------------------+
1782 | Return Value : 0: No error |
1783 | -1: The handle parameter of the board is wrong |
1784 | -2: Module selection wrong |
1785 | -3: The module is not a Chronometer module |
1786 | -4: The selected digital output is wrong |
1787 | -5: Chronometer not initialised see function |
1788 | "i_APCI1710_InitChrono" |
1789 +----------------------------------------------------------------------------+
1793 +----------------------------------------------------------------------------+
1794 | Function Name : _INT_ i_APCI1710_SetChronoChlOff |
1795 | (unsigned char_ b_BoardHandle, |
1796 | unsigned char_ b_ModulNbr, |
1797 | unsigned char_ b_OutputChannel) |
1798 +----------------------------------------------------------------------------+
1799 | Task : Resets the output witch has been passed with the |
1800 | parameter b_Channel. Resetting an output means setting |
1802 +----------------------------------------------------------------------------+
1803 | Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710
1804 data[0] : Chl ON, Chl OFF , Chl Read , Port Read
1806 | unsigned char_ b_ModulNbr CR_AREF : Selected module number (0 to 3)|
1807 | unsigned char_ b_OutputChannel CR_CHAN : Selection from digital output |
1808 | channel (0 to 2) |
1812 +----------------------------------------------------------------------------+
1813 | Output Parameters : - |
1814 +----------------------------------------------------------------------------+
1815 | Return Value : 0: No error |
1816 | -1: The handle parameter of the board is wrong |
1817 | -2: Module selection wrong |
1818 | -3: The module is not a Chronometer module |
1819 | -4: The selected digital output is wrong |
1820 | -5: Chronometer not initialised see function |
1821 | "i_APCI1710_InitChrono" |
1822 +----------------------------------------------------------------------------+
1826 +----------------------------------------------------------------------------+
1827 | Function Name : _INT_ i_APCI1710_ReadChronoChlValue |
1828 | (unsigned char_ b_BoardHandle, |
1829 | unsigned char_ b_ModulNbr, |
1830 | unsigned char_ b_InputChannel, |
1831 | unsigned char *_ pb_ChannelStatus) |
1832 +----------------------------------------------------------------------------+
1833 | Task : Return the status from selected digital input |
1834 | (b_InputChannel) from selected chronometer |
1835 | module (b_ModulNbr). |
1836 +----------------------------------------------------------------------------+
1837 | Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
1838 | unsigned char_ b_ModulNbr : Selected module number (0 to 3)|
1839 | unsigned char_ b_InputChannel : Selection from digital input |
1840 | channel (0 to 2) |
1841 | CR_CHAN() 0 : Channel E |
1844 +----------------------------------------------------------------------------+
1845 | Output Parameters : unsigned char *_ pb_ChannelStatus : Digital input channel status.|
1846 | data[0] 0 : Channel is not active |
1847 | 1 : Channel is active |
1848 +----------------------------------------------------------------------------+
1849 | Return Value : 0: No error |
1850 | -1: The handle parameter of the board is wrong |
1851 | -2: Module selection wrong |
1852 | -3: The module is not a Chronometer module |
1853 | -4: The selected digital input is wrong |
1854 | -5: Chronometer not initialised see function |
1855 | "i_APCI1710_InitChrono" |
1856 +----------------------------------------------------------------------------+
1860 +----------------------------------------------------------------------------+
1861 | Function Name : _INT_ i_APCI1710_ReadChronoPortValue |
1862 | (unsigned char_ b_BoardHandle, |
1863 | unsigned char_ b_ModulNbr, |
1864 | unsigned char *_ pb_PortValue) |
1865 +----------------------------------------------------------------------------+
1866 | Task : Return the status from digital inputs port from |
1867 | selected (b_ModulNbr) chronometer module. |
1868 +----------------------------------------------------------------------------+
1869 | Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
1870 | unsigned char_ b_ModulNbr : Selected module number (0 to 3)|
1871 +----------------------------------------------------------------------------+
1872 | Output Parameters : unsigned char *_ pb_PortValue : Digital inputs port status.
1874 +----------------------------------------------------------------------------+
1875 | Return Value : 0: No error |
1876 | -1: The handle parameter of the board is wrong |
1877 | -2: Module selection wrong |
1878 | -3: The module is not a Chronometer module |
1879 | -4: Chronometer not initialised see function |
1880 | "i_APCI1710_InitChrono" |
1881 +----------------------------------------------------------------------------+
1884 int i_APCI1710_InsnBitsChronoDigitalIO(struct comedi_device *dev,
1885 struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
1887 struct addi_private *devpriv = dev->private;
1888 int i_ReturnValue = 0;
1889 unsigned char b_ModulNbr, b_OutputChannel, b_InputChannel, b_IOType;
1890 unsigned int dw_Status;
1891 unsigned char *pb_ChannelStatus;
1892 unsigned char *pb_PortValue;
1894 b_ModulNbr = CR_AREF(insn->chanspec);
1895 i_ReturnValue = insn->n;
1896 b_IOType = (unsigned char) data[0];
1898 /**************************/
1899 /* Test the module number */
1900 /**************************/
1902 if (b_ModulNbr < 4) {
1903 /***********************/
1904 /* Test if chronometer */
1905 /***********************/
1907 if ((devpriv->s_BoardInfos.
1908 dw_MolduleConfiguration[b_ModulNbr] &
1909 0xFFFF0000UL) == APCI1710_CHRONOMETER) {
1910 /***********************************/
1911 /* Test if chronometer initialised */
1912 /***********************************/
1914 if (devpriv->s_ModuleInfo[b_ModulNbr].
1915 s_ChronoModuleInfo.b_ChronoInit == 1) {
1916 /***********************************/
1917 /* Test the digital output channel */
1918 /***********************************/
1921 case APCI1710_CHRONO_SET_CHANNELOFF:
1924 (unsigned char) CR_CHAN(insn->chanspec);
1925 if (b_OutputChannel <= 2) {
1927 outl(0, devpriv->s_BoardInfos.
1929 (b_OutputChannel * 4) +
1931 } /* if ((b_OutputChannel >= 0) && (b_OutputChannel <= 2)) */
1933 /****************************************/
1934 /* The selected digital output is wrong */
1935 /****************************************/
1937 DPRINTK("The selected digital output is wrong\n");
1940 } /* if ((b_OutputChannel >= 0) && (b_OutputChannel <= 2)) */
1944 case APCI1710_CHRONO_SET_CHANNELON:
1947 (unsigned char) CR_CHAN(insn->chanspec);
1948 if (b_OutputChannel <= 2) {
1950 outl(1, devpriv->s_BoardInfos.
1952 (b_OutputChannel * 4) +
1954 } /* if ((b_OutputChannel >= 0) && (b_OutputChannel <= 2)) */
1956 /****************************************/
1957 /* The selected digital output is wrong */
1958 /****************************************/
1960 DPRINTK("The selected digital output is wrong\n");
1963 } /* if ((b_OutputChannel >= 0) && (b_OutputChannel <= 2)) */
1967 case APCI1710_CHRONO_READ_CHANNEL:
1968 /**********************************/
1969 /* Test the digital input channel */
1970 /**********************************/
1971 pb_ChannelStatus = (unsigned char *) &data[0];
1973 (unsigned char) CR_CHAN(insn->chanspec);
1975 if (b_InputChannel <= 2) {
1984 (unsigned char) (((dw_Status >>
1987 } /* if ((b_InputChannel >= 0) && (b_InputChannel <= 2)) */
1989 /***************************************/
1990 /* The selected digital input is wrong */
1991 /***************************************/
1993 DPRINTK("The selected digital input is wrong\n");
1995 } /* if ((b_InputChannel >= 0) && (b_InputChannel <= 2)) */
1999 case APCI1710_CHRONO_READ_PORT:
2001 pb_PortValue = (unsigned char *) &data[0];
2004 inl(devpriv->s_BoardInfos.
2009 (unsigned char) ((dw_Status & 0x7) ^ 7);
2013 /*******************************/
2014 /* Chronometer not initialised */
2015 /*******************************/
2017 DPRINTK("Chronometer not initialised\n");
2021 /******************************************/
2022 /* The module is not a Chronometer module */
2023 /******************************************/
2025 DPRINTK("The module is not a Chronometer module\n");
2029 /***********************/
2030 /* Module number error */
2031 /***********************/
2033 DPRINTK("Module number error\n");
2037 return i_ReturnValue;