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.
25 +-----------------------------------------------------------------------+
26 | (C) ADDI-DATA GmbH Dieselstraße 3 D-77833 Ottersweier |
27 +-----------------------------------------------------------------------+
28 | Tel : +49 (0) 7223/9493-0 | email : info@addi-data.com |
29 | Fax : +49 (0) 7223/9493-92 | Internet : http://www.addi-data.com |
30 +-----------------------------------------------------------------------+
31 | Project : API APCI1710 | Compiler : gcc |
32 | Module name : INC_CPT.C | Version : 2.96 |
33 +-------------------------------+---------------------------------------+
34 | Project manager: Eric Stolz | Date : 02/12/2002 |
35 +-----------------------------------------------------------------------+
36 | Description : APCI-1710 incremental counter module |
39 +-----------------------------------------------------------------------+
41 +-----------------------------------------------------------------------+
42 | Date | Author | Description of updates |
43 +----------+-----------+------------------------------------------------+
45 |----------|-----------|------------------------------------------------|
46 | 08/05/00 | Guinot C | - 0400/0228 All Function in RING 0 |
48 +-----------------------------------------------------------------------+
49 | 29/06/01 | Guinot C. | - 1100/0231 -> 0701/0232 |
50 | | | See i_APCI1710_DisableFrequencyMeasurement |
51 +-----------------------------------------------------------------------+
55 +----------------------------------------------------------------------------+
57 +----------------------------------------------------------------------------+
60 #include "APCI1710_INCCPT.h"
63 +----------------------------------------------------------------------------+
64 | Function Name : _INT_ i_APCI1710_InitCounter |
65 | (unsigned char_ b_BoardHandle, |
66 | unsigned char_ b_ModulNbr, |
67 | unsigned char_ b_CounterRange, |
68 | unsigned char_ b_FirstCounterModus, |
69 | unsigned char_ b_FirstCounterOption, |
70 | unsigned char_ b_SecondCounterModus, |
71 | unsigned char_ b_SecondCounterOption) |
72 +----------------------------------------------------------------------------+
73 | Task : Configure the counter operating mode from selected |
74 | module (b_ModulNbr). You must calling this function be |
75 | for you call any other function witch access of |
80 | +------------------------------------+-----------------------------------+ |
81 | | Parameter Passed value | Description | |
82 | |------------------------------------+-----------------------------------| |
83 | |b_ModulNbr APCI1710_16BIT_COUNTER | The module is configured for | |
84 | | | two 16-bit counter. | |
85 | | | - b_FirstCounterModus and | |
86 | | | b_FirstCounterOption | |
87 | | | configure the first 16 bit | |
89 | | | - b_SecondCounterModus and | |
90 | | | b_SecondCounterOption | |
91 | | | configure the second 16 bit | |
93 | |------------------------------------+-----------------------------------| |
94 | |b_ModulNbr APCI1710_32BIT_COUNTER | The module is configured for one | |
95 | | | 32-bit counter. | |
96 | | | - b_FirstCounterModus and | |
97 | | | b_FirstCounterOption | |
98 | | | configure the 32 bit counter. | |
99 | | | - b_SecondCounterModus and | |
100 | | | b_SecondCounterOption | |
101 | | | are not used and have no | |
102 | | | importance. | |
103 | +------------------------------------+-----------------------------------+ |
105 | Counter operating mode |
106 | ---------------------- |
108 | +--------------------+-------------------------+-------------------------+ |
109 | | Parameter | Passed value | Description | |
110 | |--------------------+-------------------------+-------------------------| |
111 | |b_FirstCounterModus | APCI1710_QUADRUPLE_MODE | In the quadruple mode, | |
112 | | or | | the edge analysis | |
113 | |b_SecondCounterModus| | circuit generates a | |
114 | | | | counting pulse from | |
115 | | | | each edge of 2 signals | |
116 | | | | which are phase shifted | |
117 | | | | in relation to each | |
119 | |--------------------+-------------------------+-------------------------| |
120 | |b_FirstCounterModus | APCI1710_DOUBLE_MODE | Functions in the same | |
121 | | or | | way as the quadruple | |
122 | |b_SecondCounterModus| | mode, except that only | |
123 | | | | two of the four edges | |
124 | | | | are analysed per | |
126 | |--------------------+-------------------------+-------------------------| |
127 | |b_FirstCounterModus | APCI1710_SIMPLE_MODE | Functions in the same | |
128 | | or | | way as the quadruple | |
129 | |b_SecondCounterModus| | mode, except that only | |
130 | | | | one of the four edges | |
131 | | | | is analysed per | |
133 | |--------------------+-------------------------+-------------------------| |
134 | |b_FirstCounterModus | APCI1710_DIRECT_MODE | In the direct mode the | |
135 | | or | | both edge analysis | |
136 | |b_SecondCounterModus| | circuits are inactive. | |
137 | | | | The inputs A, B in the | |
138 | | | | 32-bit mode or A, B and | |
139 | | | | C, D in the 16-bit mode | |
140 | | | | represent, each, one | |
141 | | | | clock pulse gate circuit| |
142 | | | | There by frequency and | |
143 | | | | pulse duration | |
144 | | | | measurements can be | |
145 | | | | performed. | |
146 | +--------------------+-------------------------+-------------------------+ |
150 | If you have configured the module for two 16-bit counter, a mixed |
151 | mode with a counter in quadruple/double/single mode |
152 | and the other counter in direct mode is not possible! |
155 | Counter operating option for quadruple/double/simple mode |
156 | --------------------------------------------------------- |
158 | +----------------------+-------------------------+------------------------+|
159 | | Parameter | Passed value | Description ||
160 | |----------------------+-------------------------+------------------------||
161 | |b_FirstCounterOption | APCI1710_HYSTERESIS_ON | In both edge analysis ||
162 | | or | | circuits is available ||
163 | |b_SecondCounterOption | | one hysteresis circuit.||
164 | | | | It suppresses each ||
165 | | | | time the first counting||
166 | | | | pulse after a change ||
167 | | | | of rotation. ||
168 | |----------------------+-------------------------+------------------------||
169 | |b_FirstCounterOption | APCI1710_HYSTERESIS_OFF | The first counting ||
170 | | or | | pulse is not suppress ||
171 | |b_SecondCounterOption | | after a change of ||
173 | +----------------------+-------------------------+------------------------+|
177 | This option are only avaible if you have selected the direct mode. |
180 | Counter operating option for direct mode |
181 | ---------------------------------------- |
183 | +----------------------+--------------------+----------------------------+ |
184 | | Parameter | Passed value | Description | |
185 | |----------------------+--------------------+----------------------------| |
186 | |b_FirstCounterOption | APCI1710_INCREMENT | The counter increment for | |
187 | | or | | each counting pulse | |
188 | |b_SecondCounterOption | | | |
189 | |----------------------+--------------------+----------------------------| |
190 | |b_FirstCounterOption | APCI1710_DECREMENT | The counter decrement for | |
191 | | or | | each counting pulse | |
192 | |b_SecondCounterOption | | | |
193 | +----------------------+--------------------+----------------------------+ |
195 +----------------------------------------------------------------------------+
196 | Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710|
197 | unsigned char_ b_ModulNbr : Module number to |
198 | configure (0 to 3) |
199 | unsigned char_ b_CounterRange : Selection form counter |
201 | unsigned char_ b_FirstCounterModus : First counter operating |
203 | unsigned char_ b_FirstCounterOption : First counter option. |
204 | unsigned char_ b_SecondCounterModus : Second counter operating |
206 | unsigned char_ b_SecondCounterOption : Second counter option. |
207 +----------------------------------------------------------------------------+
208 | Output Parameters : - |
209 +----------------------------------------------------------------------------+
210 | Return Value : 0: No error |
211 | -1: The handle parameter of the board is wrong |
212 | -2: The module is not a counter module |
213 | -3: The selected counter range is wrong. |
214 | -4: The selected first counter operating mode is wrong. |
215 | -5: The selected first counter operating option is wrong|
216 | -6: The selected second counter operating mode is wrong.|
217 | -7: The selected second counter operating option is |
219 +----------------------------------------------------------------------------+
221 static int i_APCI1710_InitCounter(struct comedi_device *dev,
222 unsigned char b_ModulNbr,
223 unsigned char b_CounterRange,
224 unsigned char b_FirstCounterModus,
225 unsigned char b_FirstCounterOption,
226 unsigned char b_SecondCounterModus,
227 unsigned char b_SecondCounterOption)
229 struct addi_private *devpriv = dev->private;
230 int i_ReturnValue = 0;
232 /*******************************/
233 /* Test if incremental counter */
234 /*******************************/
236 if ((devpriv->s_BoardInfos.
237 dw_MolduleConfiguration[b_ModulNbr] & 0xFFFF0000UL) ==
238 APCI1710_INCREMENTAL_COUNTER) {
239 /**************************/
240 /* Test the counter range */
241 /**************************/
243 if (b_CounterRange == APCI1710_16BIT_COUNTER
244 || b_CounterRange == APCI1710_32BIT_COUNTER) {
245 /********************************/
246 /* Test the first counter modus */
247 /********************************/
249 if (b_FirstCounterModus == APCI1710_QUADRUPLE_MODE ||
250 b_FirstCounterModus == APCI1710_DOUBLE_MODE ||
251 b_FirstCounterModus == APCI1710_SIMPLE_MODE ||
252 b_FirstCounterModus == APCI1710_DIRECT_MODE) {
253 /*********************************/
254 /* Test the first counter option */
255 /*********************************/
257 if ((b_FirstCounterModus == APCI1710_DIRECT_MODE
258 && (b_FirstCounterOption ==
260 || b_FirstCounterOption
261 == APCI1710_DECREMENT))
262 || (b_FirstCounterModus !=
264 && (b_FirstCounterOption ==
265 APCI1710_HYSTERESIS_ON
266 || b_FirstCounterOption
268 APCI1710_HYSTERESIS_OFF)))
270 /**************************/
271 /* Test if 16-bit counter */
272 /**************************/
274 if (b_CounterRange ==
275 APCI1710_16BIT_COUNTER) {
276 /*********************************/
277 /* Test the second counter modus */
278 /*********************************/
280 if ((b_FirstCounterModus !=
283 (b_SecondCounterModus
285 APCI1710_QUADRUPLE_MODE
293 APCI1710_SIMPLE_MODE))
294 || (b_FirstCounterModus
300 APCI1710_DIRECT_MODE))
302 /**********************************/
303 /* Test the second counter option */
304 /**********************************/
306 if ((b_SecondCounterModus == APCI1710_DIRECT_MODE && (b_SecondCounterOption == APCI1710_INCREMENT || b_SecondCounterOption == APCI1710_DECREMENT)) || (b_SecondCounterModus != APCI1710_DIRECT_MODE && (b_SecondCounterOption == APCI1710_HYSTERESIS_ON || b_SecondCounterOption == APCI1710_HYSTERESIS_OFF))) {
310 /*********************************************************/
311 /* The selected second counter operating option is wrong */
312 /*********************************************************/
314 DPRINTK("The selected second counter operating option is wrong\n");
319 /*******************************************************/
320 /* The selected second counter operating mode is wrong */
321 /*******************************************************/
323 DPRINTK("The selected second counter operating mode is wrong\n");
328 /********************************************************/
329 /* The selected first counter operating option is wrong */
330 /********************************************************/
332 DPRINTK("The selected first counter operating option is wrong\n");
336 /******************************************************/
337 /* The selected first counter operating mode is wrong */
338 /******************************************************/
339 DPRINTK("The selected first counter operating mode is wrong\n");
343 /***************************************/
344 /* The selected counter range is wrong */
345 /***************************************/
347 DPRINTK("The selected counter range is wrong\n");
351 /*************************/
352 /* Test if a error occur */
353 /*************************/
355 if (i_ReturnValue == 0) {
356 /**************************/
357 /* Test if 16-Bit counter */
358 /**************************/
360 if (b_CounterRange == APCI1710_32BIT_COUNTER) {
362 s_ModuleInfo[b_ModulNbr].
363 s_SiemensCounterInfo.
366 b_ModeRegister1 = b_CounterRange |
367 b_FirstCounterModus |
368 b_FirstCounterOption;
371 s_ModuleInfo[b_ModulNbr].
372 s_SiemensCounterInfo.
375 b_ModeRegister1 = b_CounterRange |
376 (b_FirstCounterModus & 0x5) |
377 (b_FirstCounterOption & 0x20) |
378 (b_SecondCounterModus & 0xA) |
379 (b_SecondCounterOption & 0x40);
381 /***********************/
382 /* Test if direct mode */
383 /***********************/
385 if (b_FirstCounterModus == APCI1710_DIRECT_MODE) {
387 s_ModuleInfo[b_ModulNbr].
388 s_SiemensCounterInfo.
391 b_ModeRegister1 = devpriv->
392 s_ModuleInfo[b_ModulNbr].
393 s_SiemensCounterInfo.
397 APCI1710_DIRECT_MODE;
401 /***************************/
402 /* Write the configuration */
403 /***************************/
405 outl(devpriv->s_ModuleInfo[b_ModulNbr].
406 s_SiemensCounterInfo.
408 dw_ModeRegister1_2_3_4,
409 devpriv->s_BoardInfos.
410 ui_Address + 20 + (64 * b_ModulNbr));
413 s_ModuleInfo[b_ModulNbr].
414 s_SiemensCounterInfo.
415 s_InitFlag.b_CounterInit = 1;
418 /**************************************/
419 /* The module is not a counter module */
420 /**************************************/
422 DPRINTK("The module is not a counter module\n");
426 return i_ReturnValue;
430 +----------------------------------------------------------------------------+
431 | Function Name : _INT_ i_APCI1710_CounterAutoTest |
432 | (unsigned char_ b_BoardHandle, |
433 | unsigned char *_ pb_TestStatus) |
434 +----------------------------------------------------------------------------+
435 | Task : A test mode is intended for testing the component and |
436 | the connected periphery. All the 8-bit counter chains |
437 | are operated internally as down counters. |
438 | Independently from the external signals, |
439 | all the four 8-bit counter chains are decremented in |
440 | parallel by each negative clock pulse edge of CLKX. |
442 | Counter auto test conclusion |
443 | ---------------------------- |
444 | +-----------------+-----------------------------+ |
445 | | pb_TestStatus | Error description | |
447 | |-----------------+-----------------------------| |
448 | | 0000 | No error detected | |
449 | |-----------------|-----------------------------| |
450 | | 0001 | Error detected of counter 0 | |
451 | |-----------------|-----------------------------| |
452 | | 0010 | Error detected of counter 1 | |
453 | |-----------------|-----------------------------| |
454 | | 0100 | Error detected of counter 2 | |
455 | |-----------------|-----------------------------| |
456 | | 1000 | Error detected of counter 3 | |
457 | +-----------------+-----------------------------+ |
458 +----------------------------------------------------------------------------+
459 | Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | |
460 +----------------------------------------------------------------------------+
461 | Output Parameters : unsigned char *_ pb_TestStatus : Auto test conclusion. See table|
462 +----------------------------------------------------------------------------+
463 | Return Value : 0: No error |
464 | -1: The handle parameter of the board is wrong |
465 | -2: No counter module found |
466 +----------------------------------------------------------------------------+
468 static int i_APCI1710_CounterAutoTest(struct comedi_device *dev,
469 unsigned char *pb_TestStatus)
471 struct addi_private *devpriv = dev->private;
472 unsigned char b_ModulCpt = 0;
473 int i_ReturnValue = 0;
474 unsigned int dw_LathchValue;
478 /********************************/
479 /* Test if counter module found */
480 /********************************/
482 if ((devpriv->s_BoardInfos.
483 dw_MolduleConfiguration[0] & 0xFFFF0000UL) ==
484 APCI1710_INCREMENTAL_COUNTER
485 || (devpriv->s_BoardInfos.
486 dw_MolduleConfiguration[1] & 0xFFFF0000UL) ==
487 APCI1710_INCREMENTAL_COUNTER
488 || (devpriv->s_BoardInfos.
489 dw_MolduleConfiguration[2] & 0xFFFF0000UL) ==
490 APCI1710_INCREMENTAL_COUNTER
491 || (devpriv->s_BoardInfos.
492 dw_MolduleConfiguration[3] & 0xFFFF0000UL) ==
493 APCI1710_INCREMENTAL_COUNTER) {
494 for (b_ModulCpt = 0; b_ModulCpt < 4; b_ModulCpt++) {
495 /*******************************/
496 /* Test if incremental counter */
497 /*******************************/
499 if ((devpriv->s_BoardInfos.
500 dw_MolduleConfiguration[b_ModulCpt] &
502 APCI1710_INCREMENTAL_COUNTER) {
507 outl(3, devpriv->s_BoardInfos.
508 ui_Address + 16 + (64 * b_ModulCpt));
510 /*********************/
511 /* Tatch the counter */
512 /*********************/
514 outl(1, devpriv->s_BoardInfos.
515 ui_Address + (64 * b_ModulCpt));
517 /************************/
518 /* Read the latch value */
519 /************************/
521 dw_LathchValue = inl(devpriv->s_BoardInfos.
522 ui_Address + 4 + (64 * b_ModulCpt));
524 if ((dw_LathchValue & 0xFF) !=
525 ((dw_LathchValue >> 8) & 0xFF)
526 && (dw_LathchValue & 0xFF) !=
527 ((dw_LathchValue >> 16) & 0xFF)
528 && (dw_LathchValue & 0xFF) !=
529 ((dw_LathchValue >> 24) & 0xFF)) {
531 *pb_TestStatus | (1 <<
539 outl(0, devpriv->s_BoardInfos.
540 ui_Address + 16 + (64 * b_ModulCpt));
544 /***************************/
545 /* No counter module found */
546 /***************************/
548 DPRINTK("No counter module found\n");
552 return i_ReturnValue;
556 +----------------------------------------------------------------------------+
557 | Function Name : _INT_ i_APCI1710_InitIndex (unsigned char_ b_BoardHandle, |
558 | unsigned char_ b_ModulNbr, |
559 | unsigned char_ b_ReferenceAction, |
560 | unsigned char_ b_IndexOperation, |
561 | unsigned char_ b_AutoMode, |
562 | unsigned char_ b_InterruptEnable) |
563 +----------------------------------------------------------------------------+
564 | Task : Initialise the index corresponding to the selected |
565 | module (b_ModulNbr). If a INDEX flag occur, you have |
566 | the possibility to clear the 32-Bit counter or to latch|
567 | the current 32-Bit value in to the first latch |
568 | register. The b_IndexOperation parameter give the |
569 | possibility to choice the INDEX action. |
570 | If you have enabled the automatic mode, each INDEX |
571 | action is cleared automatically, else you must read |
572 | the index status ("i_APCI1710_ReadIndexStatus") |
573 | after each INDEX action. |
579 | +------------------------+------------------------------------+ |
580 | | b_IndexOperation | Operation | |
581 | |------------------------+------------------------------------| |
582 | |APCI1710_LATCH_COUNTER | After a index signal, the counter | |
583 | | | value (32-Bit) is latched in to | |
584 | | | the first latch register | |
585 | |------------------------|------------------------------------| |
586 | |APCI1710_CLEAR_COUNTER | After a index signal, the counter | |
587 | | | value is cleared (32-Bit) | |
588 | +------------------------+------------------------------------+ |
589 +----------------------------------------------------------------------------+
590 | Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
591 | unsigned char_ b_ModulNbr : Module number to configure |
593 | unsigned char_ b_ReferenceAction : Determine if the reference |
594 | must set or no for the |
595 | acceptance from index |
596 | APCI1710_ENABLE : |
597 | Reference must be set for |
598 | accepted the index |
599 | APCI1710_DISABLE : |
600 | Reference have not |
602 | unsigned char_ b_IndexOperation : Index operating mode. |
604 | unsigned char_ b_AutoMode : Enable or disable the |
605 | automatic index reset. |
606 | APCI1710_ENABLE : |
607 | Enable the automatic mode |
608 | APCI1710_DISABLE : |
609 | Disable the automatic mode |
610 | unsigned char_ b_InterruptEnable : Enable or disable the |
612 | APCI1710_ENABLE : |
613 | Enable the interrupt |
614 | APCI1710_DISABLE : |
615 | Disable the interrupt |
616 +----------------------------------------------------------------------------+
617 | Output Parameters : - |
618 +----------------------------------------------------------------------------+
619 | Return Value : 0: No error |
620 | -1: The handle parameter of the board is wrong |
621 | -2: No counter module found |
622 | -3: Counter not initialised see function |
623 | "i_APCI1710_InitCounter" |
624 | -4 The reference action parameter is wrong |
625 | -5: The index operating mode parameter is wrong |
626 | -6: The auto mode parameter is wrong |
627 | -7: Interrupt parameter is wrong |
628 | -8: Interrupt function not initialised. |
629 | See function "i_APCI1710_SetBoardIntRoutineX" |
630 +----------------------------------------------------------------------------+
632 static int i_APCI1710_InitIndex(struct comedi_device *dev,
633 unsigned char b_ModulNbr,
634 unsigned char b_ReferenceAction,
635 unsigned char b_IndexOperation,
636 unsigned char b_AutoMode,
637 unsigned char b_InterruptEnable)
639 struct addi_private *devpriv = dev->private;
640 int i_ReturnValue = 0;
642 /**************************/
643 /* Test the module number */
644 /**************************/
646 if (b_ModulNbr < 4) {
647 /*******************************/
648 /* Test if counter initialised */
649 /*******************************/
652 s_ModuleInfo[b_ModulNbr].
653 s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) {
654 /********************************/
655 /* Test the reference parameter */
656 /********************************/
658 if (b_ReferenceAction == APCI1710_ENABLE ||
659 b_ReferenceAction == APCI1710_DISABLE) {
660 /****************************/
661 /* Test the index parameter */
662 /****************************/
664 if (b_IndexOperation ==
665 APCI1710_HIGH_EDGE_LATCH_COUNTER
666 || b_IndexOperation ==
667 APCI1710_LOW_EDGE_LATCH_COUNTER
668 || b_IndexOperation ==
669 APCI1710_HIGH_EDGE_CLEAR_COUNTER
670 || b_IndexOperation ==
671 APCI1710_LOW_EDGE_CLEAR_COUNTER
672 || b_IndexOperation ==
673 APCI1710_HIGH_EDGE_LATCH_AND_CLEAR_COUNTER
674 || b_IndexOperation ==
675 APCI1710_LOW_EDGE_LATCH_AND_CLEAR_COUNTER)
677 /********************************/
678 /* Test the auto mode parameter */
679 /********************************/
681 if (b_AutoMode == APCI1710_ENABLE ||
682 b_AutoMode == APCI1710_DISABLE)
684 /***************************/
685 /* Test the interrupt mode */
686 /***************************/
688 if (b_InterruptEnable ==
690 || b_InterruptEnable ==
693 /************************************/
694 /* Makte the configuration commando */
695 /************************************/
697 if (b_ReferenceAction ==
703 s_SiemensCounterInfo.
711 s_SiemensCounterInfo.
716 APCI1710_ENABLE_INDEX_ACTION;
721 s_SiemensCounterInfo.
729 s_SiemensCounterInfo.
734 APCI1710_DISABLE_INDEX_ACTION;
737 /****************************************/
738 /* Test if low level latch or/and clear */
739 /****************************************/
741 if (b_IndexOperation ==
742 APCI1710_LOW_EDGE_LATCH_COUNTER
746 APCI1710_LOW_EDGE_CLEAR_COUNTER
750 APCI1710_LOW_EDGE_LATCH_AND_CLEAR_COUNTER)
752 /*************************************/
753 /* Set the index level to low (DQ26) */
754 /*************************************/
759 s_SiemensCounterInfo.
767 s_SiemensCounterInfo.
772 APCI1710_SET_LOW_INDEX_LEVEL;
774 /**************************************/
775 /* Set the index level to high (DQ26) */
776 /**************************************/
781 s_SiemensCounterInfo.
789 s_SiemensCounterInfo.
794 APCI1710_SET_HIGH_INDEX_LEVEL;
797 /***********************************/
798 /* Test if latch and clear counter */
799 /***********************************/
801 if (b_IndexOperation ==
802 APCI1710_HIGH_EDGE_LATCH_AND_CLEAR_COUNTER
806 APCI1710_LOW_EDGE_LATCH_AND_CLEAR_COUNTER)
808 /***************************************/
809 /* Set the latch and clear flag (DQ27) */
810 /***************************************/
815 s_SiemensCounterInfo.
823 s_SiemensCounterInfo.
828 APCI1710_ENABLE_LATCH_AND_CLEAR;
829 } /* if (b_IndexOperation == APCI1710_HIGH_EDGE_LATCH_AND_CLEAR_COUNTER || b_IndexOperation == APCI1710_LOW_EDGE_LATCH_AND_CLEAR_COUNTER) */
831 /*****************************************/
832 /* Clear the latch and clear flag (DQ27) */
833 /*****************************************/
838 s_SiemensCounterInfo.
846 s_SiemensCounterInfo.
851 APCI1710_DISABLE_LATCH_AND_CLEAR;
853 /*************************/
854 /* Test if latch counter */
855 /*************************/
857 if (b_IndexOperation == APCI1710_HIGH_EDGE_LATCH_COUNTER || b_IndexOperation == APCI1710_LOW_EDGE_LATCH_COUNTER) {
858 /*********************************/
859 /* Enable the latch from counter */
860 /*********************************/
865 s_SiemensCounterInfo.
873 s_SiemensCounterInfo.
878 APCI1710_INDEX_LATCH_COUNTER;
880 /*********************************/
881 /* Enable the clear from counter */
882 /*********************************/
887 s_SiemensCounterInfo.
895 s_SiemensCounterInfo.
900 (~APCI1710_INDEX_LATCH_COUNTER);
902 } /* // if (b_IndexOperation == APCI1710_HIGH_EDGE_LATCH_AND_CLEAR_COUNTER || b_IndexOperation == APCI1710_LOW_EDGE_LATCH_AND_CLEAR_COUNTER) */
910 s_SiemensCounterInfo.
918 s_SiemensCounterInfo.
923 APCI1710_INDEX_AUTO_MODE;
928 s_SiemensCounterInfo.
936 s_SiemensCounterInfo.
941 (~APCI1710_INDEX_AUTO_MODE);
944 if (b_InterruptEnable ==
950 s_SiemensCounterInfo.
958 s_SiemensCounterInfo.
963 APCI1710_ENABLE_INDEX_INT;
968 s_SiemensCounterInfo.
976 s_SiemensCounterInfo.
981 APCI1710_DISABLE_INDEX_INT;
987 s_SiemensCounterInfo.
992 /********************************/
993 /* Interrupt parameter is wrong */
994 /********************************/
995 DPRINTK("Interrupt parameter is wrong\n");
999 /************************************/
1000 /* The auto mode parameter is wrong */
1001 /************************************/
1003 DPRINTK("The auto mode parameter is wrong\n");
1007 /***********************************************/
1008 /* The index operating mode parameter is wrong */
1009 /***********************************************/
1011 DPRINTK("The index operating mode parameter is wrong\n");
1015 /*******************************************/
1016 /* The reference action parameter is wrong */
1017 /*******************************************/
1019 DPRINTK("The reference action parameter is wrong\n");
1023 /****************************************/
1024 /* Counter not initialised see function */
1025 /* "i_APCI1710_InitCounter" */
1026 /****************************************/
1028 DPRINTK("Counter not initialised\n");
1032 /*************************************************/
1033 /* The selected module number parameter is wrong */
1034 /*************************************************/
1036 DPRINTK("The selected module number parameter is wrong\n");
1040 return i_ReturnValue;
1044 +----------------------------------------------------------------------------+
1045 | Function Name : _INT_ i_APCI1710_InitReference |
1046 | (unsigned char_ b_BoardHandle, |
1047 | unsigned char_ b_ModulNbr, |
1048 | unsigned char_ b_ReferenceLevel) |
1049 +----------------------------------------------------------------------------+
1050 | Task : Initialise the reference corresponding to the selected |
1051 | module (b_ModulNbr). |
1055 | +--------------------+-------------------------+ |
1056 | | b_ReferenceLevel | Operation | |
1057 | +--------------------+-------------------------+ |
1058 | | APCI1710_LOW | Reference occur if "0" | |
1059 | |--------------------|-------------------------| |
1060 | | APCI1710_HIGH | Reference occur if "1" | |
1061 | +--------------------+-------------------------+ |
1062 +----------------------------------------------------------------------------+
1063 | Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
1064 | unsigned char_ b_ModulNbr : Module number to configure |
1066 | unsigned char_ b_ReferenceLevel : Reference level. |
1067 +----------------------------------------------------------------------------+
1068 | Output Parameters : - |
1069 +----------------------------------------------------------------------------+
1070 | Return Value : 0: No error |
1071 | -1: The handle parameter of the board is wrong |
1072 | -2: The selected module number parameter is wrong |
1073 | -3: Counter not initialised see function |
1074 | "i_APCI1710_InitCounter" |
1075 | -4: Reference level parameter is wrong |
1076 +----------------------------------------------------------------------------+
1078 static int i_APCI1710_InitReference(struct comedi_device *dev,
1079 unsigned char b_ModulNbr,
1080 unsigned char b_ReferenceLevel)
1082 struct addi_private *devpriv = dev->private;
1083 int i_ReturnValue = 0;
1085 /**************************/
1086 /* Test the module number */
1087 /**************************/
1089 if (b_ModulNbr < 4) {
1090 /*******************************/
1091 /* Test if counter initialised */
1092 /*******************************/
1095 s_ModuleInfo[b_ModulNbr].
1096 s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) {
1097 /**************************************/
1098 /* Test the reference level parameter */
1099 /**************************************/
1101 if (b_ReferenceLevel == 0 || b_ReferenceLevel == 1) {
1102 if (b_ReferenceLevel == 1) {
1104 s_ModuleInfo[b_ModulNbr].
1105 s_SiemensCounterInfo.
1108 b_ModeRegister2 = devpriv->
1109 s_ModuleInfo[b_ModulNbr].
1110 s_SiemensCounterInfo.
1114 APCI1710_REFERENCE_HIGH;
1117 s_ModuleInfo[b_ModulNbr].
1118 s_SiemensCounterInfo.
1121 b_ModeRegister2 = devpriv->
1122 s_ModuleInfo[b_ModulNbr].
1123 s_SiemensCounterInfo.
1127 APCI1710_REFERENCE_LOW;
1130 outl(devpriv->s_ModuleInfo[b_ModulNbr].
1131 s_SiemensCounterInfo.
1133 dw_ModeRegister1_2_3_4,
1134 devpriv->s_BoardInfos.ui_Address + 20 +
1138 s_ModuleInfo[b_ModulNbr].
1139 s_SiemensCounterInfo.
1140 s_InitFlag.b_ReferenceInit = 1;
1142 /**************************************/
1143 /* Reference level parameter is wrong */
1144 /**************************************/
1146 DPRINTK("Reference level parameter is wrong\n");
1150 /****************************************/
1151 /* Counter not initialised see function */
1152 /* "i_APCI1710_InitCounter" */
1153 /****************************************/
1155 DPRINTK("Counter not initialised\n");
1159 /*************************************************/
1160 /* The selected module number parameter is wrong */
1161 /*************************************************/
1163 DPRINTK("The selected module number parameter is wrong\n");
1167 return i_ReturnValue;
1171 +----------------------------------------------------------------------------+
1172 | Function Name : _INT_ i_APCI1710_InitExternalStrobe |
1173 | (unsigned char_ b_BoardHandle, |
1174 | unsigned char_ b_ModulNbr, |
1175 | unsigned char_ b_ExternalStrobe, |
1176 | unsigned char_ b_ExternalStrobeLevel) |
1177 +----------------------------------------------------------------------------+
1178 | Task : Initialises the external strobe level corresponding to |
1179 | the selected module (b_ModulNbr). |
1180 +----------------------------------------------------------------------------+
1181 | Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
1182 | unsigned char_ b_ModulNbr : Module number to configure |
1184 | unsigned char_ b_ExternalStrobe : External strobe selection |
1185 | 0 : External strobe A |
1186 | 1 : External strobe B |
1187 | unsigned char_ b_ExternalStrobeLevel : External strobe level |
1189 | External latch occurs if "0" |
1191 | External latch occurs if "1" |
1192 +----------------------------------------------------------------------------+
1193 | Output Parameters : - |
1194 +----------------------------------------------------------------------------+
1195 | Return Value : 0: No error |
1196 | -1: The handle parameter of the board is wrong |
1197 | -2: The selected module number is wrong |
1198 | -3: Counter not initialised. |
1199 | See function "i_APCI1710_InitCounter" |
1200 | -4: External strobe selection is wrong |
1201 | -5: External strobe level parameter is wrong |
1202 +----------------------------------------------------------------------------+
1204 static int i_APCI1710_InitExternalStrobe(struct comedi_device *dev,
1205 unsigned char b_ModulNbr,
1206 unsigned char b_ExternalStrobe,
1207 unsigned char b_ExternalStrobeLevel)
1209 struct addi_private *devpriv = dev->private;
1210 int i_ReturnValue = 0;
1212 /**************************/
1213 /* Test the module number */
1214 /**************************/
1216 if (b_ModulNbr < 4) {
1217 /*******************************/
1218 /* Test if counter initialised */
1219 /*******************************/
1222 s_ModuleInfo[b_ModulNbr].
1223 s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) {
1224 /**************************************/
1225 /* Test the external strobe selection */
1226 /**************************************/
1228 if (b_ExternalStrobe == 0 || b_ExternalStrobe == 1) {
1229 /******************/
1230 /* Test the level */
1231 /******************/
1233 if ((b_ExternalStrobeLevel == APCI1710_HIGH) ||
1234 ((b_ExternalStrobeLevel == APCI1710_LOW
1237 dw_MolduleConfiguration
1246 s_ModuleInfo[b_ModulNbr].
1247 s_SiemensCounterInfo.
1250 b_ModeRegister4 = (devpriv->
1251 s_ModuleInfo[b_ModulNbr].
1252 s_SiemensCounterInfo.
1255 b_ModeRegister4 & (0xFF -
1256 (0x10 << b_ExternalStrobe))) | ((b_ExternalStrobeLevel ^ 1) << (4 + b_ExternalStrobe));
1258 /********************************************/
1259 /* External strobe level parameter is wrong */
1260 /********************************************/
1262 DPRINTK("External strobe level parameter is wrong\n");
1265 } /* if (b_ExternalStrobe == 0 || b_ExternalStrobe == 1) */
1267 /**************************************/
1268 /* External strobe selection is wrong */
1269 /**************************************/
1271 DPRINTK("External strobe selection is wrong\n");
1273 } /* if (b_ExternalStrobe == 0 || b_ExternalStrobe == 1) */
1275 /****************************************/
1276 /* Counter not initialised see function */
1277 /* "i_APCI1710_InitCounter" */
1278 /****************************************/
1280 DPRINTK("Counter not initialised\n");
1284 /*************************************************/
1285 /* The selected module number parameter is wrong */
1286 /*************************************************/
1288 DPRINTK("The selected module number parameter is wrong\n");
1292 return i_ReturnValue;
1296 +----------------------------------------------------------------------------+
1297 | Function Name : _INT_ i_APCI1710_InitCompareLogic |
1298 | (unsigned char_ b_BoardHandle, |
1299 | unsigned char_ b_ModulNbr, |
1300 | unsigned int_ ui_CompareValue) |
1301 +----------------------------------------------------------------------------+
1302 | Task : Set the 32-Bit compare value. At that moment that the |
1303 | incremental counter arrive to the compare value |
1304 | (ui_CompareValue) a interrupt is generated. |
1305 +----------------------------------------------------------------------------+
1306 | Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
1307 | unsigned char_ b_ModulNbr : Module number to configure |
1309 | unsigned int_ ui_CompareValue : 32-Bit compare value |
1310 +----------------------------------------------------------------------------+
1311 | Output Parameters : -
1312 +----------------------------------------------------------------------------+
1313 | Return Value : 0: No error |
1314 | -1: The handle parameter of the board is wrong |
1315 | -2: No counter module found |
1316 | -3: Counter not initialised see function |
1317 | "i_APCI1710_InitCounter" |
1318 +----------------------------------------------------------------------------+
1320 static int i_APCI1710_InitCompareLogic(struct comedi_device *dev,
1321 unsigned char b_ModulNbr,
1322 unsigned int ui_CompareValue)
1324 struct addi_private *devpriv = dev->private;
1325 int i_ReturnValue = 0;
1327 /**************************/
1328 /* Test the module number */
1329 /**************************/
1331 if (b_ModulNbr < 4) {
1332 /*******************************/
1333 /* Test if counter initialised */
1334 /*******************************/
1337 s_ModuleInfo[b_ModulNbr].
1338 s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) {
1340 outl(ui_CompareValue, devpriv->s_BoardInfos.
1341 ui_Address + 28 + (64 * b_ModulNbr));
1344 s_ModuleInfo[b_ModulNbr].
1345 s_SiemensCounterInfo.
1346 s_InitFlag.b_CompareLogicInit = 1;
1348 /****************************************/
1349 /* Counter not initialised see function */
1350 /* "i_APCI1710_InitCounter" */
1351 /****************************************/
1353 DPRINTK("Counter not initialised\n");
1357 /*************************************************/
1358 /* The selected module number parameter is wrong */
1359 /*************************************************/
1361 DPRINTK("The selected module number parameter is wrong\n");
1365 return i_ReturnValue;
1369 +----------------------------------------------------------------------------+
1370 | Function Name : _INT_ i_APCI1710_InitFrequencyMeasurement |
1371 | (unsigned char_ b_BoardHandle, |
1372 | unsigned char_ b_ModulNbr, |
1373 | unsigned char_ b_PCIInputClock, |
1374 | unsigned char_ b_TimingUnity, |
1375 | ULONG_ ul_TimingInterval, |
1376 | PULONG_ pul_RealTimingInterval) |
1377 +----------------------------------------------------------------------------+
1378 | Task : Sets the time for the frequency measurement. |
1379 | Configures the selected TOR incremental counter of the |
1380 | selected module (b_ModulNbr). The ul_TimingInterval and|
1381 | ul_TimingUnity determine the time base for the |
1382 | measurement. The pul_RealTimingInterval returns the |
1383 | real time value. You must call up this function before |
1384 | you call up any other function which gives access to |
1385 | the frequency measurement. |
1386 +----------------------------------------------------------------------------+
1387 | Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
1388 | unsigned char_ b_ModulNbr : Number of the module to be |
1389 | configured (0 to 3) |
1390 | unsigned char_ b_PCIInputClock : Selection of the PCI bus |
1392 | - APCI1710_30MHZ : |
1393 | The PC has a PCI bus clock |
1395 | - APCI1710_33MHZ : |
1396 | The PC has a PCI bus clock |
1398 | unsigned char_ b_TimingUnity : Base time unit (0 to 2) |
1402 | ULONG_ ul_TimingInterval: Base time value. |
1403 +----------------------------------------------------------------------------+
1404 | Output Parameters : PULONG_ pul_RealTimingInterval : Real base time value. |
1405 +----------------------------------------------------------------------------+
1406 | Return Value : 0: No error |
1407 | -1: The handle parameter of the board is wrong |
1408 | -2: The selected module number is wrong |
1409 | -3: Counter not initialised see function |
1410 | "i_APCI1710_InitCounter" |
1411 | -4: The selected PCI input clock is wrong |
1412 | -5: Timing unity selection is wrong |
1413 | -6: Base timing selection is wrong |
1414 | -7: 40MHz quartz not on board |
1415 +----------------------------------------------------------------------------+
1417 static int i_APCI1710_InitFrequencyMeasurement(struct comedi_device *dev,
1418 unsigned char b_ModulNbr,
1419 unsigned char b_PCIInputClock,
1420 unsigned char b_TimingUnity,
1421 unsigned int ul_TimingInterval,
1422 unsigned int *pul_RealTimingInterval)
1424 struct addi_private *devpriv = dev->private;
1425 int i_ReturnValue = 0;
1426 unsigned int ul_TimerValue = 0;
1427 double d_RealTimingInterval;
1428 unsigned int dw_Status = 0;
1430 /**************************/
1431 /* Test the module number */
1432 /**************************/
1434 if (b_ModulNbr < 4) {
1435 /*******************************/
1436 /* Test if counter initialised */
1437 /*******************************/
1440 s_ModuleInfo[b_ModulNbr].
1441 s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) {
1442 /**************************/
1443 /* Test the PCI bus clock */
1444 /**************************/
1446 if ((b_PCIInputClock == APCI1710_30MHZ) ||
1447 (b_PCIInputClock == APCI1710_33MHZ) ||
1448 (b_PCIInputClock == APCI1710_40MHZ)) {
1449 /************************/
1450 /* Test the timing unit */
1451 /************************/
1453 if (b_TimingUnity <= 2) {
1454 /**********************************/
1455 /* Test the base timing selection */
1456 /**********************************/
1458 if (((b_PCIInputClock == APCI1710_30MHZ)
1459 && (b_TimingUnity == 0)
1460 && (ul_TimingInterval >=
1462 && (ul_TimingInterval <=
1464 || ((b_PCIInputClock ==
1466 && (b_TimingUnity == 1)
1467 && (ul_TimingInterval >=
1469 && (ul_TimingInterval <=
1471 || ((b_PCIInputClock ==
1473 && (b_TimingUnity == 2)
1474 && (ul_TimingInterval >=
1476 && (ul_TimingInterval <=
1478 || ((b_PCIInputClock ==
1480 && (b_TimingUnity == 0)
1481 && (ul_TimingInterval >=
1483 && (ul_TimingInterval <=
1485 || ((b_PCIInputClock ==
1487 && (b_TimingUnity == 1)
1488 && (ul_TimingInterval >=
1490 && (ul_TimingInterval <=
1492 || ((b_PCIInputClock ==
1494 && (b_TimingUnity == 2)
1495 && (ul_TimingInterval >=
1497 && (ul_TimingInterval <=
1499 || ((b_PCIInputClock ==
1501 && (b_TimingUnity == 0)
1502 && (ul_TimingInterval >=
1504 && (ul_TimingInterval <=
1506 || ((b_PCIInputClock ==
1508 && (b_TimingUnity == 1)
1509 && (ul_TimingInterval >=
1511 && (ul_TimingInterval <=
1513 || ((b_PCIInputClock ==
1515 && (b_TimingUnity == 2)
1516 && (ul_TimingInterval >=
1518 && (ul_TimingInterval <=
1520 /**********************/
1521 /* Test if 40MHz used */
1522 /**********************/
1524 if (b_PCIInputClock ==
1526 /******************************/
1527 /* Test if firmware >= Rev1.5 */
1528 /******************************/
1530 if ((devpriv->s_BoardInfos.dw_MolduleConfiguration[b_ModulNbr] & 0xFFFF) >= 0x3135) {
1531 /*********************************/
1532 /* Test if 40MHz quartz on board */
1533 /*********************************/
1535 /*INPDW (ps_APCI1710Variable->
1536 s_Board [b_BoardHandle].
1538 ui_Address + 36 + (64 * b_ModulNbr), &dw_Status); */
1547 /******************************/
1548 /* Test the quartz flag (DQ0) */
1549 /******************************/
1551 if ((dw_Status & 1) != 1) {
1552 /*****************************/
1553 /* 40MHz quartz not on board */
1554 /*****************************/
1556 DPRINTK("40MHz quartz not on board\n");
1562 /*****************************/
1563 /* 40MHz quartz not on board */
1564 /*****************************/
1565 DPRINTK("40MHz quartz not on board\n");
1569 } /* if (b_PCIInputClock == APCI1710_40MHZ) */
1571 /***************************/
1572 /* Test if not error occur */
1573 /***************************/
1575 if (i_ReturnValue == 0) {
1576 /****************************/
1577 /* Test the INC_CPT version */
1578 /****************************/
1580 if ((devpriv->s_BoardInfos.dw_MolduleConfiguration[b_ModulNbr] & 0xFFFF) >= 0x3131) {
1582 /**********************/
1583 /* Test if 40MHz used */
1584 /**********************/
1586 if (b_PCIInputClock == APCI1710_40MHZ) {
1587 /*********************************/
1588 /* Enable the 40MHz quarz (DQ30) */
1589 /*********************************/
1594 s_SiemensCounterInfo.
1602 s_SiemensCounterInfo.
1607 APCI1710_ENABLE_40MHZ_FREQUENCY;
1608 } /* if (b_PCIInputClock == APCI1710_40MHZ) */
1610 /**********************************/
1611 /* Disable the 40MHz quarz (DQ30) */
1612 /**********************************/
1617 s_SiemensCounterInfo.
1625 s_SiemensCounterInfo.
1630 APCI1710_DISABLE_40MHZ_FREQUENCY;
1632 } /* if (b_PCIInputClock == APCI1710_40MHZ) */
1634 /********************************/
1635 /* Calculate the division fator */
1636 /********************************/
1639 switch (b_TimingUnity) {
1646 /******************/
1647 /* Timer 0 factor */
1648 /******************/
1655 (0.00025 * b_PCIInputClock));
1657 /*******************/
1658 /* Round the value */
1659 /*******************/
1661 if ((double)((double)ul_TimingInterval * (0.00025 * (double)b_PCIInputClock)) >= ((double)((double)ul_TimerValue + 0.5))) {
1669 /*****************************/
1670 /* Calculate the real timing */
1671 /*****************************/
1673 *pul_RealTimingInterval
1678 (0.00025 * (double)b_PCIInputClock));
1679 d_RealTimingInterval
1689 if ((double)((double)ul_TimerValue / (0.00025 * (double)b_PCIInputClock)) >= (double)((double)*pul_RealTimingInterval + 0.5)) {
1690 *pul_RealTimingInterval
1692 *pul_RealTimingInterval
1716 /******************/
1717 /* Timer 0 factor */
1718 /******************/
1725 (0.25 * b_PCIInputClock));
1727 /*******************/
1728 /* Round the value */
1729 /*******************/
1731 if ((double)((double)ul_TimingInterval * (0.25 * (double)b_PCIInputClock)) >= ((double)((double)ul_TimerValue + 0.5))) {
1739 /*****************************/
1740 /* Calculate the real timing */
1741 /*****************************/
1743 *pul_RealTimingInterval
1748 (0.25 * (double)b_PCIInputClock));
1749 d_RealTimingInterval
1761 if ((double)((double)ul_TimerValue / (0.25 * (double)b_PCIInputClock)) >= (double)((double)*pul_RealTimingInterval + 0.5)) {
1762 *pul_RealTimingInterval
1764 *pul_RealTimingInterval
1788 /******************/
1789 /* Timer 0 factor */
1790 /******************/
1800 /*******************/
1801 /* Round the value */
1802 /*******************/
1804 if ((double)((double)ul_TimingInterval * (250.0 * (double)b_PCIInputClock)) >= ((double)((double)ul_TimerValue + 0.5))) {
1812 /*****************************/
1813 /* Calculate the real timing */
1814 /*****************************/
1816 *pul_RealTimingInterval
1821 (250.0 * (double)b_PCIInputClock));
1822 d_RealTimingInterval
1832 if ((double)((double)ul_TimerValue / (250.0 * (double)b_PCIInputClock)) >= (double)((double)*pul_RealTimingInterval + 0.5)) {
1833 *pul_RealTimingInterval
1835 *pul_RealTimingInterval
1855 /*************************/
1856 /* Write the timer value */
1857 /*************************/
1859 outl(ul_TimerValue, devpriv->s_BoardInfos.ui_Address + 32 + (64 * b_ModulNbr));
1861 /*******************************/
1862 /* Set the initialisation flag */
1863 /*******************************/
1868 s_SiemensCounterInfo.
1870 b_FrequencyMeasurementInit
1873 /***************************/
1874 /* Counter not initialised */
1875 /***************************/
1877 DPRINTK("Counter not initialised\n");
1881 } /* if (i_ReturnValue == 0) */
1883 /**********************************/
1884 /* Base timing selection is wrong */
1885 /**********************************/
1887 DPRINTK("Base timing selection is wrong\n");
1891 /***********************************/
1892 /* Timing unity selection is wrong */
1893 /***********************************/
1895 DPRINTK("Timing unity selection is wrong\n");
1899 /*****************************************/
1900 /* The selected PCI input clock is wrong */
1901 /*****************************************/
1903 DPRINTK("The selected PCI input clock is wrong\n");
1907 /****************************************/
1908 /* Counter not initialised see function */
1909 /* "i_APCI1710_InitCounter" */
1910 /****************************************/
1912 DPRINTK("Counter not initialised\n");
1916 /*************************************************/
1917 /* The selected module number parameter is wrong */
1918 /*************************************************/
1920 DPRINTK("The selected module number parameter is wrong\n");
1924 return i_ReturnValue;
1928 * Configuration function for INC_CPT
1930 static int i_APCI1710_InsnConfigINCCPT(struct comedi_device *dev,
1931 struct comedi_subdevice *s,
1932 struct comedi_insn *insn,
1935 struct addi_private *devpriv = dev->private;
1936 unsigned int ui_ConfigType;
1937 int i_ReturnValue = 0;
1939 ui_ConfigType = CR_CHAN(insn->chanspec);
1941 printk("\nINC_CPT");
1943 devpriv->tsk_Current = current; /* Save the current process task structure */
1944 switch (ui_ConfigType) {
1945 case APCI1710_INCCPT_INITCOUNTER:
1946 i_ReturnValue = i_APCI1710_InitCounter(dev,
1947 CR_AREF(insn->chanspec),
1948 (unsigned char) data[0],
1949 (unsigned char) data[1],
1950 (unsigned char) data[2], (unsigned char) data[3], (unsigned char) data[4]);
1953 case APCI1710_INCCPT_COUNTERAUTOTEST:
1954 i_ReturnValue = i_APCI1710_CounterAutoTest(dev,
1955 (unsigned char *) &data[0]);
1958 case APCI1710_INCCPT_INITINDEX:
1959 i_ReturnValue = i_APCI1710_InitIndex(dev,
1960 CR_AREF(insn->chanspec),
1961 (unsigned char) data[0],
1962 (unsigned char) data[1], (unsigned char) data[2], (unsigned char) data[3]);
1965 case APCI1710_INCCPT_INITREFERENCE:
1966 i_ReturnValue = i_APCI1710_InitReference(dev,
1967 CR_AREF(insn->chanspec), (unsigned char) data[0]);
1970 case APCI1710_INCCPT_INITEXTERNALSTROBE:
1971 i_ReturnValue = i_APCI1710_InitExternalStrobe(dev,
1972 CR_AREF(insn->chanspec),
1973 (unsigned char) data[0], (unsigned char) data[1]);
1976 case APCI1710_INCCPT_INITCOMPARELOGIC:
1977 i_ReturnValue = i_APCI1710_InitCompareLogic(dev,
1978 CR_AREF(insn->chanspec), (unsigned int) data[0]);
1981 case APCI1710_INCCPT_INITFREQUENCYMEASUREMENT:
1982 i_ReturnValue = i_APCI1710_InitFrequencyMeasurement(dev,
1983 CR_AREF(insn->chanspec),
1984 (unsigned char) data[0],
1985 (unsigned char) data[1], (unsigned int) data[2], (unsigned int *) &data[0]);
1989 printk("Insn Config : Config Parameter Wrong\n");
1993 if (i_ReturnValue >= 0)
1994 i_ReturnValue = insn->n;
1995 return i_ReturnValue;
1999 +----------------------------------------------------------------------------+
2000 | Function Name : _INT_ i_APCI1710_ClearCounterValue |
2001 | (unsigned char_ b_BoardHandle, |
2002 | unsigned char_ b_ModulNbr) |
2003 +----------------------------------------------------------------------------+
2004 | Task : Clear the counter value from selected module |
2006 +----------------------------------------------------------------------------+
2007 | Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
2008 | unsigned char_ b_ModulNbr : Module number to configure |
2010 +----------------------------------------------------------------------------+
2011 | Output Parameters : - |
2012 +----------------------------------------------------------------------------+
2013 | Return Value : 0: No error |
2014 | -1: The handle parameter of the board is wrong |
2015 | -2: The selected module number parameter is wrong |
2016 | -3: Counter not initialised see function |
2017 | "i_APCI1710_InitCounter" |
2018 +----------------------------------------------------------------------------+
2020 static int i_APCI1710_ClearCounterValue(struct comedi_device *dev,
2021 unsigned char b_ModulNbr)
2023 struct addi_private *devpriv = dev->private;
2024 int i_ReturnValue = 0;
2026 /**************************/
2027 /* Test the module number */
2028 /**************************/
2030 if (b_ModulNbr < 4) {
2031 /*******************************/
2032 /* Test if counter initialised */
2033 /*******************************/
2036 s_ModuleInfo[b_ModulNbr].
2037 s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) {
2038 /*********************/
2039 /* Clear the counter */
2040 /*********************/
2042 outl(1, devpriv->s_BoardInfos.
2043 ui_Address + 16 + (64 * b_ModulNbr));
2045 /****************************************/
2046 /* Counter not initialised see function */
2047 /* "i_APCI1710_InitCounter" */
2048 /****************************************/
2050 DPRINTK("Counter not initialised\n");
2054 /*************************************************/
2055 /* The selected module number parameter is wrong */
2056 /*************************************************/
2058 DPRINTK("The selected module number parameter is wrong\n");
2062 return i_ReturnValue;
2066 +----------------------------------------------------------------------------+
2067 | Function Name : _INT_ i_APCI1710_ClearAllCounterValue |
2068 | (unsigned char_ b_BoardHandle) |
2069 +----------------------------------------------------------------------------+
2070 | Task : Clear all counter value. |
2071 +----------------------------------------------------------------------------+
2072 | Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
2073 +----------------------------------------------------------------------------+
2074 | Output Parameters : - |
2075 +----------------------------------------------------------------------------+
2076 | Return Value : 0: No error |
2077 | -1: The handle parameter of the board is wrong |
2078 | -2: No counter module found |
2079 +----------------------------------------------------------------------------+
2081 static int i_APCI1710_ClearAllCounterValue(struct comedi_device *dev)
2083 struct addi_private *devpriv = dev->private;
2084 unsigned char b_ModulCpt = 0;
2085 int i_ReturnValue = 0;
2087 /********************************/
2088 /* Test if counter module found */
2089 /********************************/
2091 if ((devpriv->s_BoardInfos.
2092 dw_MolduleConfiguration[0] & 0xFFFF0000UL) ==
2093 APCI1710_INCREMENTAL_COUNTER
2094 || (devpriv->s_BoardInfos.
2095 dw_MolduleConfiguration[1] & 0xFFFF0000UL) ==
2096 APCI1710_INCREMENTAL_COUNTER
2097 || (devpriv->s_BoardInfos.
2098 dw_MolduleConfiguration[2] & 0xFFFF0000UL) ==
2099 APCI1710_INCREMENTAL_COUNTER
2100 || (devpriv->s_BoardInfos.
2101 dw_MolduleConfiguration[3] & 0xFFFF0000UL) ==
2102 APCI1710_INCREMENTAL_COUNTER) {
2103 for (b_ModulCpt = 0; b_ModulCpt < 4; b_ModulCpt++) {
2104 /*******************************/
2105 /* Test if incremental counter */
2106 /*******************************/
2108 if ((devpriv->s_BoardInfos.
2109 dw_MolduleConfiguration[b_ModulCpt] &
2111 APCI1710_INCREMENTAL_COUNTER) {
2112 /*********************/
2113 /* Clear the counter */
2114 /*********************/
2116 outl(1, devpriv->s_BoardInfos.
2117 ui_Address + 16 + (64 * b_ModulCpt));
2121 /***************************/
2122 /* No counter module found */
2123 /***************************/
2125 DPRINTK("No counter module found\n");
2129 return i_ReturnValue;
2133 +----------------------------------------------------------------------------+
2134 | Function Name : _INT_ i_APCI1710_SetInputFilter |
2135 | (unsigned char_ b_BoardHandle, |
2136 | unsigned char_ b_Module, |
2137 | unsigned char_ b_PCIInputClock, |
2138 | unsigned char_ b_Filter) |
2139 +----------------------------------------------------------------------------+
2140 | Task : Disable or enable the software filter from selected |
2141 | module (b_ModulNbr). b_Filter determine the filter time|
2142 +----------------------------------------------------------------------------+
2143 | Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
2144 | unsigned char_ b_ModulNbr : Number of the module to be |
2145 | configured (0 to 3) |
2146 | unsigned char_ b_PCIInputClock : Selection of the PCI bus |
2148 | - APCI1710_30MHZ : |
2149 | The PC has a PCI bus clock |
2151 | - APCI1710_33MHZ : |
2152 | The PC has a PCI bus clock |
2154 | - APCI1710_40MHZ : |
2155 | The APCI1710 has a 40MHz |
2157 | unsigned char_ b_Filter : Filter selection |
2161 | 0: Software filter not used |
2162 | 1: Filter from 266ns (3.750000MHz) |
2163 | 2: Filter from 400ns (2.500000MHz) |
2164 | 3: Filter from 533ns (1.876170MHz) |
2165 | 4: Filter from 666ns (1.501501MHz) |
2166 | 5: Filter from 800ns (1.250000MHz) |
2167 | 6: Filter from 933ns (1.071800MHz) |
2168 | 7: Filter from 1066ns (0.938080MHz) |
2169 | 8: Filter from 1200ns (0.833333MHz) |
2170 | 9: Filter from 1333ns (0.750000MHz) |
2171 | 10: Filter from 1466ns (0.682100MHz) |
2172 | 11: Filter from 1600ns (0.625000MHz) |
2173 | 12: Filter from 1733ns (0.577777MHz) |
2174 | 13: Filter from 1866ns (0.535900MHz) |
2175 | 14: Filter from 2000ns (0.500000MHz) |
2176 | 15: Filter from 2133ns (0.468800MHz) |
2180 | 0: Software filter not used |
2181 | 1: Filter from 242ns (4.125000MHz) |
2182 | 2: Filter from 363ns (2.754820MHz) |
2183 | 3: Filter from 484ns (2.066115MHz) |
2184 | 4: Filter from 605ns (1.652892MHz) |
2185 | 5: Filter from 726ns (1.357741MHz) |
2186 | 6: Filter from 847ns (1.180637MHz) |
2187 | 7: Filter from 968ns (1.033055MHz) |
2188 | 8: Filter from 1089ns (0.918273MHz) |
2189 | 9: Filter from 1210ns (0.826446MHz) |
2190 | 10: Filter from 1331ns (0.751314MHz) |
2191 | 11: Filter from 1452ns (0.688705MHz) |
2192 | 12: Filter from 1573ns (0.635727MHz) |
2193 | 13: Filter from 1694ns (0.590318MHz) |
2194 | 14: Filter from 1815ns (0.550964MHz) |
2195 | 15: Filter from 1936ns (0.516528MHz) |
2199 | 0: Software filter not used |
2200 | 1: Filter from 200ns (5.000000MHz) |
2201 | 2: Filter from 300ns (3.333333MHz) |
2202 | 3: Filter from 400ns (2.500000MHz) |
2203 | 4: Filter from 500ns (2.000000MHz) |
2204 | 5: Filter from 600ns (1.666666MHz) |
2205 | 6: Filter from 700ns (1.428500MHz) |
2206 | 7: Filter from 800ns (1.250000MHz) |
2207 | 8: Filter from 900ns (1.111111MHz) |
2208 | 9: Filter from 1000ns (1.000000MHz) |
2209 | 10: Filter from 1100ns (0.909090MHz) |
2210 | 11: Filter from 1200ns (0.833333MHz) |
2211 | 12: Filter from 1300ns (0.769200MHz) |
2212 | 13: Filter from 1400ns (0.714200MHz) |
2213 | 14: Filter from 1500ns (0.666666MHz) |
2214 | 15: Filter from 1600ns (0.625000MHz) |
2215 +----------------------------------------------------------------------------+
2216 | Output Parameters : - |
2217 +----------------------------------------------------------------------------+
2218 | Return Value : 0: No error |
2219 | -1: The handle parameter of the board is wrong |
2220 | -2: The selected module number is wrong |
2221 | -3: The module is not a counter module |
2222 | -4: The selected PCI input clock is wrong |
2223 | -5: The selected filter value is wrong |
2224 | -6: 40MHz quartz not on board |
2225 +----------------------------------------------------------------------------+
2227 static int i_APCI1710_SetInputFilter(struct comedi_device *dev,
2228 unsigned char b_ModulNbr,
2229 unsigned char b_PCIInputClock,
2230 unsigned char b_Filter)
2232 struct addi_private *devpriv = dev->private;
2233 int i_ReturnValue = 0;
2234 unsigned int dw_Status = 0;
2236 /**************************/
2237 /* Test the module number */
2238 /**************************/
2240 if (b_ModulNbr < 4) {
2241 /*******************************/
2242 /* Test if incremental counter */
2243 /*******************************/
2245 if ((devpriv->s_BoardInfos.
2246 dw_MolduleConfiguration[b_ModulNbr] &
2247 0xFFFF0000UL) == APCI1710_INCREMENTAL_COUNTER) {
2248 /******************************/
2249 /* Test if firmware >= Rev1.5 */
2250 /******************************/
2252 if ((devpriv->s_BoardInfos.
2253 dw_MolduleConfiguration[b_ModulNbr] &
2254 0xFFFF) >= 0x3135) {
2255 /**************************/
2256 /* Test the PCI bus clock */
2257 /**************************/
2259 if ((b_PCIInputClock == APCI1710_30MHZ) ||
2260 (b_PCIInputClock == APCI1710_33MHZ) ||
2261 (b_PCIInputClock == APCI1710_40MHZ)) {
2262 /*************************/
2263 /* Test the filter value */
2264 /*************************/
2266 if (b_Filter < 16) {
2267 /**********************/
2268 /* Test if 40MHz used */
2269 /**********************/
2271 if (b_PCIInputClock ==
2273 /*********************************/
2274 /* Test if 40MHz quartz on board */
2275 /*********************************/
2284 /******************************/
2285 /* Test the quartz flag (DQ0) */
2286 /******************************/
2288 if ((dw_Status & 1) !=
2290 /*****************************/
2291 /* 40MHz quartz not on board */
2292 /*****************************/
2294 DPRINTK("40MHz quartz not on board\n");
2298 } /* if (b_PCIInputClock == APCI1710_40MHZ) */
2300 /***************************/
2301 /* Test if error not occur */
2302 /***************************/
2304 if (i_ReturnValue == 0) {
2305 /**********************/
2306 /* Test if 40MHz used */
2307 /**********************/
2309 if (b_PCIInputClock ==
2312 /*********************************/
2313 /* Enable the 40MHz quarz (DQ31) */
2314 /*********************************/
2319 s_SiemensCounterInfo.
2327 s_SiemensCounterInfo.
2332 APCI1710_ENABLE_40MHZ_FILTER;
2334 } /* if (b_PCIInputClock == APCI1710_40MHZ) */
2336 /**********************************/
2337 /* Disable the 40MHz quarz (DQ31) */
2338 /**********************************/
2343 s_SiemensCounterInfo.
2351 s_SiemensCounterInfo.
2356 APCI1710_DISABLE_40MHZ_FILTER;
2358 } /* if (b_PCIInputClock == APCI1710_40MHZ) */
2360 /************************/
2361 /* Set the filter value */
2362 /************************/
2367 s_SiemensCounterInfo.
2375 s_SiemensCounterInfo.
2387 s_SiemensCounterInfo.
2395 s_SiemensCounterInfo.
2404 /***************************/
2405 /* Write the configuration */
2406 /***************************/
2411 s_SiemensCounterInfo.
2413 dw_ModeRegister1_2_3_4,
2419 } /* if (i_ReturnValue == 0) */
2420 } /* if (b_Filter < 16) */
2422 /**************************************/
2423 /* The selected filter value is wrong */
2424 /**************************************/
2426 DPRINTK("The selected filter value is wrong\n");
2428 } /* if (b_Filter < 16) */
2429 } /* if ((b_PCIInputClock == APCI1710_30MHZ) || (b_PCIInputClock == APCI1710_33MHZ) || (b_PCIInputClock == APCI1710_40MHZ)) */
2431 /*****************************************/
2432 /* The selected PCI input clock is wrong */
2433 /*****************************************/
2435 DPRINTK("The selected PCI input clock is wrong\n");
2437 } /* if ((b_PCIInputClock == APCI1710_30MHZ) || (b_PCIInputClock == APCI1710_33MHZ) || (b_PCIInputClock == APCI1710_40MHZ)) */
2439 /**************************************/
2440 /* The module is not a counter module */
2441 /**************************************/
2443 DPRINTK("The module is not a counter module\n");
2447 /**************************************/
2448 /* The module is not a counter module */
2449 /**************************************/
2451 DPRINTK("The module is not a counter module\n");
2455 /*************************************************/
2456 /* The selected module number parameter is wrong */
2457 /*************************************************/
2459 DPRINTK("The selected module number parameter is wrong\n");
2463 return i_ReturnValue;
2467 +----------------------------------------------------------------------------+
2468 | Function Name : _INT_ i_APCI1710_LatchCounter (unsigned char_ b_BoardHandle, |
2469 | unsigned char_ b_ModulNbr, |
2470 | unsigned char_ b_LatchReg) |
2471 +----------------------------------------------------------------------------+
2472 | Task : Latch the courant value from selected module |
2473 | (b_ModulNbr) in to the selected latch register |
2475 +----------------------------------------------------------------------------+
2476 | Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
2477 | unsigned char_ b_ModulNbr : Module number to configure |
2479 | unsigned char_ b_LatchReg : Selected latch register |
2480 | 0 : for the first latch register |
2481 | 1 : for the second latch register |
2482 +----------------------------------------------------------------------------+
2483 | Output Parameters : - |
2484 +----------------------------------------------------------------------------+
2485 | Return Value : 0: No error |
2486 | -1: The handle parameter of the board is wrong |
2487 | -2: No counter module found |
2488 | -3: Counter not initialised see function |
2489 | "i_APCI1710_InitCounter" |
2490 | -4: The selected latch register parameter is wrong |
2491 +----------------------------------------------------------------------------+
2493 static int i_APCI1710_LatchCounter(struct comedi_device *dev,
2494 unsigned char b_ModulNbr,
2495 unsigned char b_LatchReg)
2497 struct addi_private *devpriv = dev->private;
2498 int i_ReturnValue = 0;
2500 /**************************/
2501 /* Test the module number */
2502 /**************************/
2504 if (b_ModulNbr < 4) {
2505 /*******************************/
2506 /* Test if counter initialised */
2507 /*******************************/
2510 s_ModuleInfo[b_ModulNbr].
2511 s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) {
2512 /*************************************/
2513 /* Test the latch register parameter */
2514 /*************************************/
2516 if (b_LatchReg < 2) {
2517 /*********************/
2518 /* Tatch the counter */
2519 /*********************/
2521 outl(1 << (b_LatchReg * 4),
2522 devpriv->s_BoardInfos.ui_Address +
2525 /**************************************************/
2526 /* The selected latch register parameter is wrong */
2527 /**************************************************/
2529 DPRINTK("The selected latch register parameter is wrong\n");
2533 /****************************************/
2534 /* Counter not initialised see function */
2535 /* "i_APCI1710_InitCounter" */
2536 /****************************************/
2538 DPRINTK("Counter not initialised\n");
2542 /*************************************************/
2543 /* The selected module number parameter is wrong */
2544 /*************************************************/
2546 DPRINTK("The selected module number parameter is wrong\n");
2550 return i_ReturnValue;
2554 +----------------------------------------------------------------------------+
2555 | Function Name : _INT_ i_APCI1710_SetIndexAndReferenceSource |
2556 | (unsigned char_ b_BoardHandle, |
2557 | unsigned char_ b_ModulNbr, |
2558 | unsigned char_ b_SourceSelection) |
2559 +----------------------------------------------------------------------------+
2560 | Task : Determine the hardware source for the index and the |
2561 | reference logic. Per default the index logic is |
2562 | connected to the difference input C and the reference |
2563 | logic is connected to the 24V input E |
2564 +----------------------------------------------------------------------------+
2565 | Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
2566 | unsigned char_ b_ModulNbr : Module number to configure |
2568 | unsigned char_ b_SourceSelection : APCI1710_SOURCE_0 : |
2569 | The index logic is connected |
2570 | to the difference input C and|
2571 | the reference logic is |
2572 | connected to the 24V input E.|
2573 | This is the default |
2575 | APCI1710_SOURCE_1 : |
2576 | The reference logic is |
2577 | connected to the difference |
2578 | input C and the index logic |
2579 | is connected to the 24V |
2581 +----------------------------------------------------------------------------+
2582 | Output Parameters : - |
2583 +----------------------------------------------------------------------------+
2584 | Return Value : 0: No error |
2585 | -1: The handle parameter of the board is wrong |
2586 | -2: The selected module number is wrong |
2587 | -3: The module is not a counter module. |
2588 | -4: The source selection is wrong |
2589 +----------------------------------------------------------------------------+
2591 static int i_APCI1710_SetIndexAndReferenceSource(struct comedi_device *dev,
2592 unsigned char b_ModulNbr,
2593 unsigned char b_SourceSelection)
2595 struct addi_private *devpriv = dev->private;
2596 int i_ReturnValue = 0;
2598 /**************************/
2599 /* Test the module number */
2600 /**************************/
2602 if (b_ModulNbr < 4) {
2603 /*******************************/
2604 /* Test if incremental counter */
2605 /*******************************/
2607 if ((devpriv->s_BoardInfos.
2608 dw_MolduleConfiguration[b_ModulNbr] &
2609 0xFFFF0000UL) == APCI1710_INCREMENTAL_COUNTER) {
2610 /******************************/
2611 /* Test if firmware >= Rev1.5 */
2612 /******************************/
2614 if ((devpriv->s_BoardInfos.
2615 dw_MolduleConfiguration[b_ModulNbr] &
2616 0xFFFF) >= 0x3135) {
2617 /*****************************/
2618 /* Test the source selection */
2619 /*****************************/
2621 if (b_SourceSelection == APCI1710_SOURCE_0 ||
2622 b_SourceSelection == APCI1710_SOURCE_1)
2624 /******************************************/
2625 /* Test if invert the index and reference */
2626 /******************************************/
2628 if (b_SourceSelection ==
2629 APCI1710_SOURCE_1) {
2630 /********************************************/
2631 /* Invert index and reference source (DQ25) */
2632 /********************************************/
2637 s_SiemensCounterInfo.
2644 s_SiemensCounterInfo.
2648 APCI1710_INVERT_INDEX_RFERENCE;
2650 /****************************************/
2651 /* Set the default configuration (DQ25) */
2652 /****************************************/
2657 s_SiemensCounterInfo.
2664 s_SiemensCounterInfo.
2668 APCI1710_DEFAULT_INDEX_RFERENCE;
2670 } /* if (b_SourceSelection == APCI1710_SOURCE_0 ||b_SourceSelection == APCI1710_SOURCE_1) */
2672 /*********************************/
2673 /* The source selection is wrong */
2674 /*********************************/
2676 DPRINTK("The source selection is wrong\n");
2678 } /* if (b_SourceSelection == APCI1710_SOURCE_0 ||b_SourceSelection == APCI1710_SOURCE_1) */
2680 /**************************************/
2681 /* The module is not a counter module */
2682 /**************************************/
2684 DPRINTK("The module is not a counter module\n");
2688 /**************************************/
2689 /* The module is not a counter module */
2690 /**************************************/
2692 DPRINTK("The module is not a counter module\n");
2696 /***************************************/
2697 /* The selected module number is wrong */
2698 /***************************************/
2700 DPRINTK("The selected module number is wrong\n");
2704 return i_ReturnValue;
2708 +----------------------------------------------------------------------------+
2709 | Function Name : _INT_ i_APCI1710_SetDigitalChlOn |
2710 | (unsigned char_ b_BoardHandle, |
2711 | unsigned char_ b_ModulNbr) |
2712 +----------------------------------------------------------------------------+
2713 | Task : Sets the digital output H Setting an output means |
2714 | setting an ouput high. |
2715 +----------------------------------------------------------------------------+
2716 | Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
2717 | unsigned char_ b_ModulNbr : Number of the module to be |
2718 | configured (0 to 3) |
2719 +----------------------------------------------------------------------------+
2720 | Output Parameters : - |
2721 +----------------------------------------------------------------------------+
2722 | Return Value : 0: No error |
2723 | -1: The handle parameter of the board is wrong |
2724 | -2: The selected module number is wrong |
2725 | -3: Counter not initialised see function |
2726 | "i_APCI1710_InitCounter" |
2727 +----------------------------------------------------------------------------+
2729 static int i_APCI1710_SetDigitalChlOn(struct comedi_device *dev,
2730 unsigned char b_ModulNbr)
2732 struct addi_private *devpriv = dev->private;
2733 int i_ReturnValue = 0;
2735 /**************************/
2736 /* Test the module number */
2737 /**************************/
2739 if (b_ModulNbr < 4) {
2740 /*******************************/
2741 /* Test if counter initialised */
2742 /*******************************/
2745 s_ModuleInfo[b_ModulNbr].
2746 s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) {
2748 s_ModuleInfo[b_ModulNbr].
2749 s_SiemensCounterInfo.
2752 b_ModeRegister3 = devpriv->
2753 s_ModuleInfo[b_ModulNbr].
2754 s_SiemensCounterInfo.
2756 s_ByteModeRegister.b_ModeRegister3 | 0x10;
2758 /*********************/
2759 /* Set the output On */
2760 /*********************/
2762 outl(devpriv->s_ModuleInfo[b_ModulNbr].
2763 s_SiemensCounterInfo.
2765 dw_ModeRegister1_2_3_4, devpriv->s_BoardInfos.
2766 ui_Address + 20 + (64 * b_ModulNbr));
2768 /****************************************/
2769 /* Counter not initialised see function */
2770 /* "i_APCI1710_InitCounter" */
2771 /****************************************/
2773 DPRINTK("Counter not initialised\n");
2777 /*************************************************/
2778 /* The selected module number parameter is wrong */
2779 /*************************************************/
2781 DPRINTK("The selected module number parameter is wrong\n");
2785 return i_ReturnValue;
2789 +----------------------------------------------------------------------------+
2790 | Function Name : _INT_ i_APCI1710_SetDigitalChlOff |
2791 | (unsigned char_ b_BoardHandle, |
2792 | unsigned char_ b_ModulNbr) |
2793 +----------------------------------------------------------------------------+
2794 | Task : Resets the digital output H. Resetting an output means |
2795 | setting an ouput low. |
2796 +----------------------------------------------------------------------------+
2797 | Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
2798 | unsigned char_ b_ModulNbr : Number of the module to be |
2799 | configured (0 to 3) |
2800 +----------------------------------------------------------------------------+
2801 | Output Parameters : - |
2802 +----------------------------------------------------------------------------+
2803 | Return Value : 0: No error |
2804 | -1: The handle parameter of the board is wrong |
2805 | -2: The selected module number is wrong |
2806 | -3: Counter not initialised see function |
2807 | "i_APCI1710_InitCounter" |
2808 +----------------------------------------------------------------------------+
2810 static int i_APCI1710_SetDigitalChlOff(struct comedi_device *dev,
2811 unsigned char b_ModulNbr)
2813 struct addi_private *devpriv = dev->private;
2814 int i_ReturnValue = 0;
2816 /**************************/
2817 /* Test the module number */
2818 /**************************/
2820 if (b_ModulNbr < 4) {
2821 /*******************************/
2822 /* Test if counter initialised */
2823 /*******************************/
2826 s_ModuleInfo[b_ModulNbr].
2827 s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) {
2829 s_ModuleInfo[b_ModulNbr].
2830 s_SiemensCounterInfo.
2833 b_ModeRegister3 = devpriv->
2834 s_ModuleInfo[b_ModulNbr].
2835 s_SiemensCounterInfo.
2837 s_ByteModeRegister.b_ModeRegister3 & 0xEF;
2839 /**********************/
2840 /* Set the output Off */
2841 /**********************/
2843 outl(devpriv->s_ModuleInfo[b_ModulNbr].
2844 s_SiemensCounterInfo.
2846 dw_ModeRegister1_2_3_4, devpriv->s_BoardInfos.
2847 ui_Address + 20 + (64 * b_ModulNbr));
2849 /****************************************/
2850 /* Counter not initialised see function */
2851 /* "i_APCI1710_InitCounter" */
2852 /****************************************/
2854 DPRINTK("Counter not initialised\n");
2858 /*************************************************/
2859 /* The selected module number parameter is wrong */
2860 /*************************************************/
2862 DPRINTK("The selected module number parameter is wrong\n");
2866 return i_ReturnValue;
2870 * Set & Clear Functions for INC_CPT
2872 static int i_APCI1710_InsnBitsINCCPT(struct comedi_device *dev,
2873 struct comedi_subdevice *s,
2874 struct comedi_insn *insn,
2877 struct addi_private *devpriv = dev->private;
2878 unsigned int ui_BitsType;
2879 int i_ReturnValue = 0;
2881 ui_BitsType = CR_CHAN(insn->chanspec);
2882 devpriv->tsk_Current = current; /* Save the current process task structure */
2884 switch (ui_BitsType) {
2885 case APCI1710_INCCPT_CLEARCOUNTERVALUE:
2886 i_ReturnValue = i_APCI1710_ClearCounterValue(dev,
2887 (unsigned char) CR_AREF(insn->chanspec));
2890 case APCI1710_INCCPT_CLEARALLCOUNTERVALUE:
2891 i_ReturnValue = i_APCI1710_ClearAllCounterValue(dev);
2894 case APCI1710_INCCPT_SETINPUTFILTER:
2895 i_ReturnValue = i_APCI1710_SetInputFilter(dev,
2896 (unsigned char) CR_AREF(insn->chanspec),
2897 (unsigned char) data[0], (unsigned char) data[1]);
2900 case APCI1710_INCCPT_LATCHCOUNTER:
2901 i_ReturnValue = i_APCI1710_LatchCounter(dev,
2902 (unsigned char) CR_AREF(insn->chanspec), (unsigned char) data[0]);
2905 case APCI1710_INCCPT_SETINDEXANDREFERENCESOURCE:
2906 i_ReturnValue = i_APCI1710_SetIndexAndReferenceSource(dev,
2907 (unsigned char) CR_AREF(insn->chanspec), (unsigned char) data[0]);
2910 case APCI1710_INCCPT_SETDIGITALCHLON:
2911 i_ReturnValue = i_APCI1710_SetDigitalChlOn(dev,
2912 (unsigned char) CR_AREF(insn->chanspec));
2915 case APCI1710_INCCPT_SETDIGITALCHLOFF:
2916 i_ReturnValue = i_APCI1710_SetDigitalChlOff(dev,
2917 (unsigned char) CR_AREF(insn->chanspec));
2921 printk("Bits Config Parameter Wrong\n");
2924 if (i_ReturnValue >= 0)
2925 i_ReturnValue = insn->n;
2926 return i_ReturnValue;
2930 +----------------------------------------------------------------------------+
2931 | Function Name : _INT_ i_APCI1710_EnableLatchInterrupt |
2932 | (unsigned char_ b_BoardHandle, |
2933 | unsigned char_ b_ModulNbr) |
2934 +----------------------------------------------------------------------------+
2935 | Task : Enable the latch interrupt from selected module |
2936 | (b_ModulNbr). Each software or hardware latch occur a |
2938 +----------------------------------------------------------------------------+
2939 | Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
2940 | unsigned char_ b_ModulNbr : Module number to configure |
2942 +----------------------------------------------------------------------------+
2943 | Output Parameters : - |
2944 +----------------------------------------------------------------------------+
2945 | Return Value : 0: No error |
2946 | -1: The handle parameter of the board is wrong |
2947 | -2: No counter module found |
2948 | -3: Counter not initialised see function |
2949 | "i_APCI1710_InitCounter" |
2950 | -4: Interrupt routine not installed see function |
2951 | "i_APCI1710_SetBoardIntRoutine" |
2952 +----------------------------------------------------------------------------+
2954 static int i_APCI1710_EnableLatchInterrupt(struct comedi_device *dev,
2955 unsigned char b_ModulNbr)
2957 struct addi_private *devpriv = dev->private;
2958 int i_ReturnValue = 0;
2960 /**************************/
2961 /* Test the module number */
2962 /**************************/
2964 if (b_ModulNbr < 4) {
2965 /*******************************/
2966 /* Test if counter initialised */
2967 /*******************************/
2969 if (devpriv->s_ModuleInfo[b_ModulNbr].
2970 s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) {
2972 /********************/
2973 /* Enable interrupt */
2974 /********************/
2976 devpriv->s_ModuleInfo[b_ModulNbr].
2977 s_SiemensCounterInfo.
2980 b_ModeRegister2 = devpriv->
2981 s_ModuleInfo[b_ModulNbr].
2982 s_SiemensCounterInfo.
2985 b_ModeRegister2 | APCI1710_ENABLE_LATCH_INT;
2987 /***************************/
2988 /* Write the configuration */
2989 /***************************/
2991 outl(devpriv->s_ModuleInfo[b_ModulNbr].
2992 s_SiemensCounterInfo.
2994 dw_ModeRegister1_2_3_4, devpriv->s_BoardInfos.
2995 ui_Address + 20 + (64 * b_ModulNbr));
2997 /****************************************/
2998 /* Counter not initialised see function */
2999 /* "i_APCI1710_InitCounter" */
3000 /****************************************/
3002 DPRINTK("Counter not initialised\n");
3006 /*************************************************/
3007 /* The selected module number parameter is wrong */
3008 /*************************************************/
3010 DPRINTK("The selected module number parameter is wrong\n");
3014 return i_ReturnValue;
3018 +----------------------------------------------------------------------------+
3019 | Function Name : _INT_ i_APCI1710_DisableLatchInterrupt |
3020 | (unsigned char_ b_BoardHandle, |
3021 | unsigned char_ b_ModulNbr) |
3022 +----------------------------------------------------------------------------+
3023 | Task : Disable the latch interrupt from selected module |
3025 +----------------------------------------------------------------------------+
3026 | Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
3027 | unsigned char_ b_ModulNbr : Module number to configure |
3029 +----------------------------------------------------------------------------+
3030 | Output Parameters : - |
3031 +----------------------------------------------------------------------------+
3032 | Return Value : 0: No error |
3033 | -1: The handle parameter of the board is wrong |
3034 | -2: No counter module found |
3035 | -3: Counter not initialised see function |
3036 | "i_APCI1710_InitCounter" |
3037 | -4: Interrupt routine not installed see function |
3038 | "i_APCI1710_SetBoardIntRoutine" |
3039 +----------------------------------------------------------------------------+
3041 static int i_APCI1710_DisableLatchInterrupt(struct comedi_device *dev,
3042 unsigned char b_ModulNbr)
3044 struct addi_private *devpriv = dev->private;
3045 int i_ReturnValue = 0;
3047 /**************************/
3048 /* Test the module number */
3049 /**************************/
3051 if (b_ModulNbr < 4) {
3052 /*******************************/
3053 /* Test if counter initialised */
3054 /*******************************/
3057 s_ModuleInfo[b_ModulNbr].
3058 s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) {
3060 /***************************/
3061 /* Write the configuration */
3062 /***************************/
3064 outl(devpriv->s_ModuleInfo[b_ModulNbr].
3065 s_SiemensCounterInfo.
3067 dw_ModeRegister1_2_3_4 &
3068 ((APCI1710_DISABLE_LATCH_INT << 8) | 0xFF),
3069 devpriv->s_BoardInfos.ui_Address + 20 +
3074 /*********************/
3075 /* Disable interrupt */
3076 /*********************/
3079 s_ModuleInfo[b_ModulNbr].
3080 s_SiemensCounterInfo.
3083 b_ModeRegister2 = devpriv->
3084 s_ModuleInfo[b_ModulNbr].
3085 s_SiemensCounterInfo.
3088 b_ModeRegister2 & APCI1710_DISABLE_LATCH_INT;
3091 /****************************************/
3092 /* Counter not initialised see function */
3093 /* "i_APCI1710_InitCounter" */
3094 /****************************************/
3096 DPRINTK("Counter not initialised\n");
3100 /*************************************************/
3101 /* The selected module number parameter is wrong */
3102 /*************************************************/
3104 DPRINTK("The selected module number parameter is wrong\n");
3108 return i_ReturnValue;
3112 +----------------------------------------------------------------------------+
3113 | Function Name : _INT_ i_APCI1710_Write16BitCounterValue |
3114 | (unsigned char_ b_BoardHandle |
3115 | unsigned char_ b_ModulNbr, |
3116 | unsigned char_ b_SelectedCounter, |
3117 | unsigned int_ ui_WriteValue) |
3118 +----------------------------------------------------------------------------+
3119 | Task : Write a 16-Bit value (ui_WriteValue) in to the selected|
3120 | 16-Bit counter (b_SelectedCounter) from selected module|
3122 +----------------------------------------------------------------------------+
3123 | Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
3124 | unsigned char_ b_ModulNbr : Module number to configure |
3126 | unsigned char_ b_SelectedCounter : Selected 16-Bit counter |
3128 | unsigned int_ ui_WriteValue : 16-Bit write value |
3129 +----------------------------------------------------------------------------+
3130 | Output Parameters : - |
3131 +----------------------------------------------------------------------------+
3132 | Return Value : 0: No error |
3133 | -1: The handle parameter of the board is wrong |
3134 | -2: No counter module found |
3135 | -3: Counter not initialised see function |
3136 | "i_APCI1710_InitCounter" |
3137 | -4: The selected 16-Bit counter parameter is wrong |
3138 +----------------------------------------------------------------------------+
3140 static int i_APCI1710_Write16BitCounterValue(struct comedi_device *dev,
3141 unsigned char b_ModulNbr,
3142 unsigned char b_SelectedCounter,
3143 unsigned int ui_WriteValue)
3145 struct addi_private *devpriv = dev->private;
3146 int i_ReturnValue = 0;
3148 /**************************/
3149 /* Test the module number */
3150 /**************************/
3152 if (b_ModulNbr < 4) {
3153 /*******************************/
3154 /* Test if counter initialised */
3155 /*******************************/
3158 s_ModuleInfo[b_ModulNbr].
3159 s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) {
3160 /******************************/
3161 /* Test the counter selection */
3162 /******************************/
3164 if (b_SelectedCounter < 2) {
3165 /*******************/
3166 /* Write the value */
3167 /*******************/
3169 outl((unsigned int) ((unsigned int) (ui_WriteValue) << (16 *
3170 b_SelectedCounter)),
3171 devpriv->s_BoardInfos.ui_Address + 8 +
3172 (b_SelectedCounter * 4) +
3175 /**************************************************/
3176 /* The selected 16-Bit counter parameter is wrong */
3177 /**************************************************/
3179 DPRINTK("The selected 16-Bit counter parameter is wrong\n");
3183 /****************************************/
3184 /* Counter not initialised see function */
3185 /* "i_APCI1710_InitCounter" */
3186 /****************************************/
3188 DPRINTK("Counter not initialised\n");
3192 /*************************************************/
3193 /* The selected module number parameter is wrong */
3194 /*************************************************/
3196 DPRINTK("The selected module number parameter is wrong\n");
3200 return i_ReturnValue;
3204 +----------------------------------------------------------------------------+
3205 | Function Name : _INT_ i_APCI1710_Write32BitCounterValue |
3206 | (unsigned char_ b_BoardHandle |
3207 | unsigned char_ b_ModulNbr, |
3208 | ULONG_ ul_WriteValue) |
3209 +----------------------------------------------------------------------------+
3210 | Task : Write a 32-Bit value (ui_WriteValue) in to the selected|
3211 | module (b_ModulNbr). |
3212 +----------------------------------------------------------------------------+
3213 | Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
3214 | unsigned char_ b_ModulNbr : Module number to configure |
3216 | ULONG_ ul_WriteValue : 32-Bit write value |
3217 +----------------------------------------------------------------------------+
3218 | Output Parameters : - |
3219 +----------------------------------------------------------------------------+
3220 | Return Value : 0: No error |
3221 | -1: The handle parameter of the board is wrong |
3222 | -2: No counter module found |
3223 | -3: Counter not initialised see function |
3224 | "i_APCI1710_InitCounter" |
3225 +----------------------------------------------------------------------------+
3227 static int i_APCI1710_Write32BitCounterValue(struct comedi_device *dev,
3228 unsigned char b_ModulNbr,
3229 unsigned int ul_WriteValue)
3231 struct addi_private *devpriv = dev->private;
3232 int i_ReturnValue = 0;
3234 /**************************/
3235 /* Test the module number */
3236 /**************************/
3238 if (b_ModulNbr < 4) {
3239 /*******************************/
3240 /* Test if counter initialised */
3241 /*******************************/
3244 s_ModuleInfo[b_ModulNbr].
3245 s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) {
3246 /*******************/
3247 /* Write the value */
3248 /*******************/
3250 outl(ul_WriteValue, devpriv->s_BoardInfos.
3251 ui_Address + 4 + (64 * b_ModulNbr));
3253 /****************************************/
3254 /* Counter not initialised see function */
3255 /* "i_APCI1710_InitCounter" */
3256 /****************************************/
3258 DPRINTK("Counter not initialised\n");
3262 /*************************************************/
3263 /* The selected module number parameter is wrong */
3264 /*************************************************/
3266 DPRINTK("The selected module number parameter is wrong\n");
3270 return i_ReturnValue;
3274 +----------------------------------------------------------------------------+
3275 | Function Name : _INT_ i_APCI1710_EnableIndex (unsigned char_ b_BoardHandle, |
3276 | unsigned char_ b_ModulNbr) |
3277 +----------------------------------------------------------------------------+
3278 | Task : Enable the INDEX actions |
3279 +----------------------------------------------------------------------------+
3280 | Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
3281 | unsigned char_ b_ModulNbr : Module number to configure |
3283 +----------------------------------------------------------------------------+
3284 | Output Parameters : - |
3285 +----------------------------------------------------------------------------+
3286 | Return Value : 0: No error |
3287 | -1: The handle parameter of the board is wrong |
3288 | -2: No counter module found |
3289 | -3: Counter not initialised see function |
3290 | "i_APCI1710_InitCounter" |
3291 | -4: Index not initialised see function |
3292 | "i_APCI1710_InitIndex" |
3293 +----------------------------------------------------------------------------+
3295 static int i_APCI1710_EnableIndex(struct comedi_device *dev,
3296 unsigned char b_ModulNbr)
3298 struct addi_private *devpriv = dev->private;
3299 int i_ReturnValue = 0;
3300 unsigned int ul_InterruptLatchReg;
3302 /**************************/
3303 /* Test the module number */
3304 /**************************/
3306 if (b_ModulNbr < 4) {
3307 /*******************************/
3308 /* Test if counter initialised */
3309 /*******************************/
3312 s_ModuleInfo[b_ModulNbr].
3313 s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) {
3314 /*****************************/
3315 /* Test if index initialised */
3316 /*****************************/
3319 s_ModuleInfo[b_ModulNbr].
3320 s_SiemensCounterInfo.s_InitFlag.b_IndexInit) {
3322 s_ModuleInfo[b_ModulNbr].
3323 s_SiemensCounterInfo.
3326 b_ModeRegister2 = devpriv->
3327 s_ModuleInfo[b_ModulNbr].
3328 s_SiemensCounterInfo.
3331 b_ModeRegister2 | APCI1710_ENABLE_INDEX;
3333 ul_InterruptLatchReg =
3334 inl(devpriv->s_BoardInfos.ui_Address +
3335 24 + (64 * b_ModulNbr));
3337 outl(devpriv->s_ModuleInfo[b_ModulNbr].
3338 s_SiemensCounterInfo.
3340 dw_ModeRegister1_2_3_4,
3341 devpriv->s_BoardInfos.ui_Address + 20 +
3344 /*************************************************************/
3345 /* Index not initialised see function "i_APCI1710_InitIndex" */
3346 /*************************************************************/
3348 DPRINTK("Index not initialised \n");
3352 /****************************************/
3353 /* Counter not initialised see function */
3354 /* "i_APCI1710_InitCounter" */
3355 /****************************************/
3357 DPRINTK("Counter not initialised\n");
3361 /*************************************************/
3362 /* The selected module number parameter is wrong */
3363 /*************************************************/
3365 DPRINTK("The selected module number parameter is wrong\n");
3369 return i_ReturnValue;
3373 +----------------------------------------------------------------------------+
3374 | Function Name : _INT_ i_APCI1710_DisableIndex (unsigned char_ b_BoardHandle, |
3375 | unsigned char_ b_ModulNbr) |
3376 +----------------------------------------------------------------------------+
3377 | Task : Disable the INDEX actions |
3378 +----------------------------------------------------------------------------+
3379 | Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
3380 | unsigned char_ b_ModulNbr : Module number to configure |
3382 +----------------------------------------------------------------------------+
3383 | Output Parameters : - |
3384 +----------------------------------------------------------------------------+
3385 | Return Value : 0: No error |
3386 | -1: The handle parameter of the board is wrong |
3387 | -2: No counter module found |
3388 | -3: Counter not initialised see function |
3389 | "i_APCI1710_InitCounter" |
3390 | -4: Index not initialised see function |
3391 | "i_APCI1710_InitIndex" |
3392 +----------------------------------------------------------------------------+
3394 static int i_APCI1710_DisableIndex(struct comedi_device *dev,
3395 unsigned char b_ModulNbr)
3397 struct addi_private *devpriv = dev->private;
3398 int i_ReturnValue = 0;
3400 /**************************/
3401 /* Test the module number */
3402 /**************************/
3404 if (b_ModulNbr < 4) {
3405 /*******************************/
3406 /* Test if counter initialised */
3407 /*******************************/
3410 s_ModuleInfo[b_ModulNbr].
3411 s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) {
3412 /*****************************/
3413 /* Test if index initialised */
3414 /*****************************/
3417 s_ModuleInfo[b_ModulNbr].
3418 s_SiemensCounterInfo.s_InitFlag.b_IndexInit) {
3420 s_ModuleInfo[b_ModulNbr].
3421 s_SiemensCounterInfo.
3424 b_ModeRegister2 = devpriv->
3425 s_ModuleInfo[b_ModulNbr].
3426 s_SiemensCounterInfo.
3430 APCI1710_DISABLE_INDEX;
3432 outl(devpriv->s_ModuleInfo[b_ModulNbr].
3433 s_SiemensCounterInfo.
3435 dw_ModeRegister1_2_3_4,
3436 devpriv->s_BoardInfos.ui_Address + 20 +
3439 /*************************************************************/
3440 /* Index not initialised see function "i_APCI1710_InitIndex" */
3441 /*************************************************************/
3443 DPRINTK("Index not initialised \n");
3447 /****************************************/
3448 /* Counter not initialised see function */
3449 /* "i_APCI1710_InitCounter" */
3450 /****************************************/
3452 DPRINTK("Counter not initialised\n");
3456 /*************************************************/
3457 /* The selected module number parameter is wrong */
3458 /*************************************************/
3460 DPRINTK("The selected module number parameter is wrong\n");
3464 return i_ReturnValue;
3468 +----------------------------------------------------------------------------+
3469 | Function Name : _INT_ i_APCI1710_EnableCompareLogic |
3470 | (unsigned char_ b_BoardHandle, |
3471 | unsigned char_ b_ModulNbr) |
3472 +----------------------------------------------------------------------------+
3473 | Task : Enable the 32-Bit compare logic. At that moment that |
3474 | the incremental counter arrive to the compare value a |
3475 | interrupt is generated. |
3476 +----------------------------------------------------------------------------+
3477 | Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
3478 | unsigned char_ b_ModulNbr : Module number to configure |
3480 +----------------------------------------------------------------------------+
3481 | Output Parameters : -
3482 +----------------------------------------------------------------------------+
3483 | Return Value : 0: No error |
3484 | -1: The handle parameter of the board is wrong |
3485 | -2: No counter module found |
3486 | -3: Counter not initialised see function |
3487 | "i_APCI1710_InitCounter" |
3488 | -4: Compare logic not initialised. |
3489 | See function "i_APCI1710_InitCompareLogic" |
3490 | -5: Interrupt function not initialised. |
3491 | See function "i_APCI1710_SetBoardIntRoutineX" |
3492 +----------------------------------------------------------------------------+
3494 static int i_APCI1710_EnableCompareLogic(struct comedi_device *dev,
3495 unsigned char b_ModulNbr)
3497 struct addi_private *devpriv = dev->private;
3498 int i_ReturnValue = 0;
3500 /**************************/
3501 /* Test the module number */
3502 /**************************/
3504 if (b_ModulNbr < 4) {
3505 /*******************************/
3506 /* Test if counter initialised */
3507 /*******************************/
3510 s_ModuleInfo[b_ModulNbr].
3511 s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) {
3512 /*************************************/
3513 /* Test if compare logic initialised */
3514 /*************************************/
3517 s_ModuleInfo[b_ModulNbr].
3518 s_SiemensCounterInfo.
3519 s_InitFlag.b_CompareLogicInit == 1) {
3521 s_ModuleInfo[b_ModulNbr].
3522 s_SiemensCounterInfo.
3525 b_ModeRegister3 = devpriv->
3526 s_ModuleInfo[b_ModulNbr].
3527 s_SiemensCounterInfo.
3531 APCI1710_ENABLE_COMPARE_INT;
3533 /***************************/
3534 /* Write the configuration */
3535 /***************************/
3537 outl(devpriv->s_ModuleInfo[b_ModulNbr].
3538 s_SiemensCounterInfo.
3540 dw_ModeRegister1_2_3_4,
3541 devpriv->s_BoardInfos.ui_Address + 20 +
3544 /*********************************/
3545 /* Compare logic not initialised */
3546 /*********************************/
3548 DPRINTK("Compare logic not initialised\n");
3552 /****************************************/
3553 /* Counter not initialised see function */
3554 /* "i_APCI1710_InitCounter" */
3555 /****************************************/
3557 DPRINTK("Counter not initialised\n");
3561 /*************************************************/
3562 /* The selected module number parameter is wrong */
3563 /*************************************************/
3565 DPRINTK("The selected module number parameter is wrong\n");
3569 return i_ReturnValue;
3573 +----------------------------------------------------------------------------+
3574 | Function Name : _INT_ i_APCI1710_DisableCompareLogic |
3575 | (unsigned char_ b_BoardHandle, |
3576 | unsigned char_ b_ModulNbr) |
3577 +----------------------------------------------------------------------------+
3578 | Task : Disable the 32-Bit compare logic.
3579 +----------------------------------------------------------------------------+
3580 | Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
3581 | unsigned char_ b_ModulNbr : Module number to configure |
3583 +----------------------------------------------------------------------------+
3584 | Output Parameters : -
3585 +----------------------------------------------------------------------------+
3586 | Return Value : 0: No error |
3587 | -1: The handle parameter of the board is wrong |
3588 | -2: No counter module found |
3589 | -3: Counter not initialised see function |
3590 | "i_APCI1710_InitCounter" |
3591 | -4: Compare logic not initialised. |
3592 | See function "i_APCI1710_InitCompareLogic" |
3593 +----------------------------------------------------------------------------+
3595 static int i_APCI1710_DisableCompareLogic(struct comedi_device *dev,
3596 unsigned char b_ModulNbr)
3598 struct addi_private *devpriv = dev->private;
3599 int i_ReturnValue = 0;
3601 /**************************/
3602 /* Test the module number */
3603 /**************************/
3605 if (b_ModulNbr < 4) {
3606 /*******************************/
3607 /* Test if counter initialised */
3608 /*******************************/
3611 s_ModuleInfo[b_ModulNbr].
3612 s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) {
3613 /*************************************/
3614 /* Test if compare logic initialised */
3615 /*************************************/
3618 s_ModuleInfo[b_ModulNbr].
3619 s_SiemensCounterInfo.
3620 s_InitFlag.b_CompareLogicInit == 1) {
3622 s_ModuleInfo[b_ModulNbr].
3623 s_SiemensCounterInfo.
3626 b_ModeRegister3 = devpriv->
3627 s_ModuleInfo[b_ModulNbr].
3628 s_SiemensCounterInfo.
3632 APCI1710_DISABLE_COMPARE_INT;
3634 /***************************/
3635 /* Write the configuration */
3636 /***************************/
3638 outl(devpriv->s_ModuleInfo[b_ModulNbr].
3639 s_SiemensCounterInfo.
3641 dw_ModeRegister1_2_3_4,
3642 devpriv->s_BoardInfos.ui_Address + 20 +
3645 /*********************************/
3646 /* Compare logic not initialised */
3647 /*********************************/
3649 DPRINTK("Compare logic not initialised\n");
3653 /****************************************/
3654 /* Counter not initialised see function */
3655 /* "i_APCI1710_InitCounter" */
3656 /****************************************/
3658 DPRINTK("Counter not initialised\n");
3662 /*************************************************/
3663 /* The selected module number parameter is wrong */
3664 /*************************************************/
3666 DPRINTK("The selected module number parameter is wrong\n");
3670 return i_ReturnValue;
3674 +----------------------------------------------------------------------------+
3675 | Function Name : _INT_ i_APCI1710_EnableFrequencyMeasurement |
3676 | (unsigned char_ b_BoardHandle, |
3677 | unsigned char_ b_ModulNbr, |
3678 | unsigned char_ b_InterruptEnable) |
3679 +----------------------------------------------------------------------------+
3680 | Task : Enables the frequency measurement function |
3681 +----------------------------------------------------------------------------+
3682 | Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
3683 | unsigned char_ b_ModulNbr : Number of the module to be |
3684 | configured (0 to 3) |
3685 | unsigned char_ b_InterruptEnable: Enable or disable the |
3687 | APCI1710_ENABLE: |
3688 | Enable the interrupt |
3689 | APCI1710_DISABLE: |
3690 | Disable the interrupt |
3691 +----------------------------------------------------------------------------+
3692 | Output Parameters : - |
3693 +----------------------------------------------------------------------------+
3694 | Return Value : 0: No error |
3695 | -1: The handle parameter of the board is wrong |
3696 | -2: The selected module number is wrong |
3697 | -3: Counter not initialised see function |
3698 | "i_APCI1710_InitCounter" |
3699 | -4: Frequency measurement logic not initialised. |
3700 | See function "i_APCI1710_InitFrequencyMeasurement" |
3701 | -5: Interrupt parameter is wrong |
3702 | -6: Interrupt function not initialised. |
3703 +----------------------------------------------------------------------------+
3705 static int i_APCI1710_EnableFrequencyMeasurement(struct comedi_device *dev,
3706 unsigned char b_ModulNbr,
3707 unsigned char b_InterruptEnable)
3709 struct addi_private *devpriv = dev->private;
3710 int i_ReturnValue = 0;
3712 /**************************/
3713 /* Test the module number */
3714 /**************************/
3716 if (b_ModulNbr < 4) {
3717 /*******************************/
3718 /* Test if counter initialised */
3719 /*******************************/
3722 s_ModuleInfo[b_ModulNbr].
3723 s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) {
3724 /********************************************/
3725 /* Test if frequency measurement initialised */
3726 /********************************************/
3729 s_ModuleInfo[b_ModulNbr].
3730 s_SiemensCounterInfo.
3731 s_InitFlag.b_FrequencyMeasurementInit == 1) {
3732 /***************************/
3733 /* Test the interrupt mode */
3734 /***************************/
3736 if ((b_InterruptEnable == APCI1710_DISABLE) ||
3737 (b_InterruptEnable == APCI1710_ENABLE))
3740 /************************************/
3741 /* Enable the frequency measurement */
3742 /************************************/
3745 s_ModuleInfo[b_ModulNbr].
3746 s_SiemensCounterInfo.
3749 b_ModeRegister3 = devpriv->
3750 s_ModuleInfo[b_ModulNbr].
3751 s_SiemensCounterInfo.
3755 APCI1710_ENABLE_FREQUENCY;
3757 /*********************************************/
3758 /* Disable or enable the frequency interrupt */
3759 /*********************************************/
3762 s_ModuleInfo[b_ModulNbr].
3763 s_SiemensCounterInfo.
3766 b_ModeRegister3 = (devpriv->
3767 s_ModuleInfo[b_ModulNbr].
3768 s_SiemensCounterInfo.
3772 APCI1710_DISABLE_FREQUENCY_INT)
3773 | (b_InterruptEnable << 3);
3775 /***************************/
3776 /* Write the configuration */
3777 /***************************/
3779 outl(devpriv->s_ModuleInfo[b_ModulNbr].
3780 s_SiemensCounterInfo.
3782 dw_ModeRegister1_2_3_4,
3783 devpriv->s_BoardInfos.
3788 s_ModuleInfo[b_ModulNbr].
3789 s_SiemensCounterInfo.
3791 b_FrequencyMeasurementEnable =
3794 /********************************/
3795 /* Interrupt parameter is wrong */
3796 /********************************/
3798 DPRINTK("Interrupt parameter is wrong\n");
3802 /***********************************************/
3803 /* Frequency measurement logic not initialised */
3804 /***********************************************/
3806 DPRINTK("Frequency measurement logic not initialised\n");
3810 /****************************************/
3811 /* Counter not initialised see function */
3812 /* "i_APCI1710_InitCounter" */
3813 /****************************************/
3815 DPRINTK("Counter not initialised\n");
3819 /*************************************************/
3820 /* The selected module number parameter is wrong */
3821 /*************************************************/
3823 DPRINTK("The selected module number parameter is wrong\n");
3827 return i_ReturnValue;
3831 +----------------------------------------------------------------------------+
3832 | Function Name : _INT_ i_APCI1710_DisableFrequencyMeasurement |
3833 | (unsigned char_ b_BoardHandle, |
3834 | unsigned char_ b_ModulNbr) |
3835 +----------------------------------------------------------------------------+
3836 | Task : Disables the frequency measurement function |
3837 +----------------------------------------------------------------------------+
3838 | Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
3839 | unsigned char_ b_ModulNbr : Number of the module to be |
3840 | configured (0 to 3) |
3841 +----------------------------------------------------------------------------+
3842 | Output Parameters : - |
3843 +----------------------------------------------------------------------------+
3844 | Return Value : 0: No error |
3845 | -1: The handle parameter of the board is wrong |
3846 | -2: The selected module number is wrong |
3847 | -3: Counter not initialised see function |
3848 | "i_APCI1710_InitCounter" |
3849 | -4: Frequency measurement logic not initialised. |
3850 | See function "i_APCI1710_InitFrequencyMeasurement" |
3851 +----------------------------------------------------------------------------+
3853 static int i_APCI1710_DisableFrequencyMeasurement(struct comedi_device *dev,
3854 unsigned char b_ModulNbr)
3856 struct addi_private *devpriv = dev->private;
3857 int i_ReturnValue = 0;
3859 /**************************/
3860 /* Test the module number */
3861 /**************************/
3863 if (b_ModulNbr < 4) {
3864 /*******************************/
3865 /* Test if counter initialised */
3866 /*******************************/
3869 s_ModuleInfo[b_ModulNbr].
3870 s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) {
3871 /********************************************/
3872 /* Test if frequency measurement initialised */
3873 /********************************************/
3876 s_ModuleInfo[b_ModulNbr].
3877 s_SiemensCounterInfo.
3878 s_InitFlag.b_FrequencyMeasurementInit == 1) {
3879 /*************************************/
3880 /* Disable the frequency measurement */
3881 /*************************************/
3884 s_ModuleInfo[b_ModulNbr].
3885 s_SiemensCounterInfo.
3888 b_ModeRegister3 = devpriv->
3889 s_ModuleInfo[b_ModulNbr].
3890 s_SiemensCounterInfo.
3894 APCI1710_DISABLE_FREQUENCY
3895 /* Begin CG 29/06/01 CG 1100/0231 -> 0701/0232 Frequence measure IRQ must be cleared */
3896 & APCI1710_DISABLE_FREQUENCY_INT;
3897 /* End CG 29/06/01 CG 1100/0231 -> 0701/0232 Frequence measure IRQ must be cleared */
3899 /***************************/
3900 /* Write the configuration */
3901 /***************************/
3903 outl(devpriv->s_ModuleInfo[b_ModulNbr].
3904 s_SiemensCounterInfo.
3906 dw_ModeRegister1_2_3_4,
3907 devpriv->s_BoardInfos.ui_Address + 20 +
3910 /*************************************/
3911 /* Disable the frequency measurement */
3912 /*************************************/
3915 s_ModuleInfo[b_ModulNbr].
3916 s_SiemensCounterInfo.
3918 b_FrequencyMeasurementEnable = 0;
3920 /***********************************************/
3921 /* Frequency measurement logic not initialised */
3922 /***********************************************/
3924 DPRINTK("Frequency measurement logic not initialised\n");
3928 /****************************************/
3929 /* Counter not initialised see function */
3930 /* "i_APCI1710_InitCounter" */
3931 /****************************************/
3933 DPRINTK("Counter not initialised\n");
3937 /*************************************************/
3938 /* The selected module number parameter is wrong */
3939 /*************************************************/
3941 DPRINTK("The selected module number parameter is wrong\n");
3945 return i_ReturnValue;
3949 * Enable Disable functions for INC_CPT
3951 static int i_APCI1710_InsnWriteINCCPT(struct comedi_device *dev,
3952 struct comedi_subdevice *s,
3953 struct comedi_insn *insn,
3956 struct addi_private *devpriv = dev->private;
3957 unsigned int ui_WriteType;
3958 int i_ReturnValue = 0;
3960 ui_WriteType = CR_CHAN(insn->chanspec);
3961 devpriv->tsk_Current = current; /* Save the current process task structure */
3963 switch (ui_WriteType) {
3964 case APCI1710_INCCPT_ENABLELATCHINTERRUPT:
3965 i_ReturnValue = i_APCI1710_EnableLatchInterrupt(dev,
3966 (unsigned char) CR_AREF(insn->chanspec));
3969 case APCI1710_INCCPT_DISABLELATCHINTERRUPT:
3970 i_ReturnValue = i_APCI1710_DisableLatchInterrupt(dev,
3971 (unsigned char) CR_AREF(insn->chanspec));
3974 case APCI1710_INCCPT_WRITE16BITCOUNTERVALUE:
3975 i_ReturnValue = i_APCI1710_Write16BitCounterValue(dev,
3976 (unsigned char) CR_AREF(insn->chanspec),
3977 (unsigned char) data[0], (unsigned int) data[1]);
3980 case APCI1710_INCCPT_WRITE32BITCOUNTERVALUE:
3981 i_ReturnValue = i_APCI1710_Write32BitCounterValue(dev,
3982 (unsigned char) CR_AREF(insn->chanspec), (unsigned int) data[0]);
3986 case APCI1710_INCCPT_ENABLEINDEX:
3987 i_APCI1710_EnableIndex(dev, (unsigned char) CR_AREF(insn->chanspec));
3990 case APCI1710_INCCPT_DISABLEINDEX:
3991 i_ReturnValue = i_APCI1710_DisableIndex(dev,
3992 (unsigned char) CR_AREF(insn->chanspec));
3995 case APCI1710_INCCPT_ENABLECOMPARELOGIC:
3996 i_ReturnValue = i_APCI1710_EnableCompareLogic(dev,
3997 (unsigned char) CR_AREF(insn->chanspec));
4000 case APCI1710_INCCPT_DISABLECOMPARELOGIC:
4001 i_ReturnValue = i_APCI1710_DisableCompareLogic(dev,
4002 (unsigned char) CR_AREF(insn->chanspec));
4005 case APCI1710_INCCPT_ENABLEFREQUENCYMEASUREMENT:
4006 i_ReturnValue = i_APCI1710_EnableFrequencyMeasurement(dev,
4007 (unsigned char) CR_AREF(insn->chanspec), (unsigned char) data[0]);
4010 case APCI1710_INCCPT_DISABLEFREQUENCYMEASUREMENT:
4011 i_ReturnValue = i_APCI1710_DisableFrequencyMeasurement(dev,
4012 (unsigned char) CR_AREF(insn->chanspec));
4016 printk("Write Config Parameter Wrong\n");
4019 if (i_ReturnValue >= 0)
4020 i_ReturnValue = insn->n;
4021 return i_ReturnValue;
4025 +----------------------------------------------------------------------------+
4026 | Function Name : _INT_ i_APCI1710_ReadLatchRegisterStatus |
4027 | (unsigned char_ b_BoardHandle, |
4028 | unsigned char_ b_ModulNbr, |
4029 | unsigned char_ b_LatchReg, |
4030 | unsigned char *_ pb_LatchStatus) |
4031 +----------------------------------------------------------------------------+
4032 | Task : Read the latch register status from selected module |
4033 | (b_ModulNbr) and selected latch register (b_LatchReg). |
4034 +----------------------------------------------------------------------------+
4035 | Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
4036 | unsigned char_ b_ModulNbr : Module number to configure |
4038 | unsigned char_ b_LatchReg : Selected latch register |
4039 | 0 : for the first latch register |
4040 | 1 : for the second latch register |
4041 +----------------------------------------------------------------------------+
4042 | Output Parameters : unsigned char *_ pb_LatchStatus : Latch register status. |
4043 | 0 : No latch occur |
4044 | 1 : A software latch occur |
4045 | 2 : A hardware latch occur |
4046 | 3 : A software and hardware |
4048 +----------------------------------------------------------------------------+
4049 | Return Value : 0: No error |
4050 | -1: The handle parameter of the board is wrong |
4051 | -2: No counter module found |
4052 | -3: Counter not initialised see function |
4053 | "i_APCI1710_InitCounter" |
4054 | -4: The selected latch register parameter is wrong |
4055 +----------------------------------------------------------------------------+
4057 static int i_APCI1710_ReadLatchRegisterStatus(struct comedi_device *dev,
4058 unsigned char b_ModulNbr,
4059 unsigned char b_LatchReg,
4060 unsigned char *pb_LatchStatus)
4062 struct addi_private *devpriv = dev->private;
4063 int i_ReturnValue = 0;
4064 unsigned int dw_LatchReg;
4066 /**************************/
4067 /* Test the module number */
4068 /**************************/
4070 if (b_ModulNbr < 4) {
4071 /*******************************/
4072 /* Test if counter initialised */
4073 /*******************************/
4076 s_ModuleInfo[b_ModulNbr].
4077 s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) {
4078 /*************************************/
4079 /* Test the latch register parameter */
4080 /*************************************/
4082 if (b_LatchReg < 2) {
4083 dw_LatchReg = inl(devpriv->s_BoardInfos.
4084 ui_Address + (64 * b_ModulNbr));
4087 (unsigned char) ((dw_LatchReg >> (b_LatchReg *
4090 /**************************************************/
4091 /* The selected latch register parameter is wrong */
4092 /**************************************************/
4094 DPRINTK("The selected latch register parameter is wrong\n");
4098 /****************************************/
4099 /* Counter not initialised see function */
4100 /* "i_APCI1710_InitCounter" */
4101 /****************************************/
4103 DPRINTK("Counter not initialised\n");
4107 /*************************************************/
4108 /* The selected module number parameter is wrong */
4109 /*************************************************/
4111 DPRINTK("The selected module number parameter is wrong\n");
4115 return i_ReturnValue;
4119 +----------------------------------------------------------------------------+
4120 | Function Name : _INT_ i_APCI1710_ReadLatchRegisterValue |
4121 | (unsigned char_ b_BoardHandle,|
4122 | unsigned char_ b_ModulNbr, |
4123 | unsigned char_ b_LatchReg, |
4124 | PULONG_ pul_LatchValue) |
4125 +----------------------------------------------------------------------------+
4126 | Task : Read the latch register value from selected module |
4127 | (b_ModulNbr) and selected latch register (b_LatchReg). |
4128 +----------------------------------------------------------------------------+
4129 | Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
4130 | unsigned char_ b_ModulNbr : Module number to configure |
4132 | unsigned char_ b_LatchReg : Selected latch register |
4133 | 0 : for the first latch register |
4134 | 1 : for the second latch register |
4135 +----------------------------------------------------------------------------+
4136 | Output Parameters : PULONG_ pul_LatchValue : Latch register value |
4137 +----------------------------------------------------------------------------+
4138 | Return Value : 0: No error |
4139 | -1: The handle parameter of the board is wrong |
4140 | -2: No counter module found |
4141 | -3: Counter not initialised see function |
4142 | "i_APCI1710_InitCounter" |
4143 | -4: The selected latch register parameter is wrong |
4144 +----------------------------------------------------------------------------+
4146 static int i_APCI1710_ReadLatchRegisterValue(struct comedi_device *dev,
4147 unsigned char b_ModulNbr,
4148 unsigned char b_LatchReg,
4149 unsigned int *pul_LatchValue)
4151 struct addi_private *devpriv = dev->private;
4152 int i_ReturnValue = 0;
4154 /**************************/
4155 /* Test the module number */
4156 /**************************/
4158 if (b_ModulNbr < 4) {
4159 /*******************************/
4160 /* Test if counter initialised */
4161 /*******************************/
4164 s_ModuleInfo[b_ModulNbr].
4165 s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) {
4166 /*************************************/
4167 /* Test the latch register parameter */
4168 /*************************************/
4170 if (b_LatchReg < 2) {
4171 *pul_LatchValue = inl(devpriv->s_BoardInfos.
4172 ui_Address + ((b_LatchReg + 1) * 4) +
4176 /**************************************************/
4177 /* The selected latch register parameter is wrong */
4178 /**************************************************/
4180 DPRINTK("The selected latch register parameter is wrong\n");
4184 /****************************************/
4185 /* Counter not initialised see function */
4186 /* "i_APCI1710_InitCounter" */
4187 /****************************************/
4189 DPRINTK("Counter not initialised\n");
4193 /*************************************************/
4194 /* The selected module number parameter is wrong */
4195 /*************************************************/
4197 DPRINTK("The selected module number parameter is wrong\n");
4201 return i_ReturnValue;
4205 +----------------------------------------------------------------------------+
4206 | Function Name : _INT_ i_APCI1710_Read16BitCounterValue |
4207 | (unsigned char_ b_BoardHandle, |
4208 | unsigned char_ b_ModulNbr, |
4209 | unsigned char_ b_SelectedCounter, |
4210 | unsigned int *_ pui_CounterValue) |
4211 +----------------------------------------------------------------------------+
4212 | Task : Latch the selected 16-Bit counter (b_SelectedCounter) |
4213 | from selected module (b_ModulNbr) in to the first |
4214 | latch register and return the latched value. |
4215 +----------------------------------------------------------------------------+
4216 | Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
4217 | unsigned char_ b_ModulNbr : Module number to configure |
4219 | unsigned char_ b_SelectedCounter : Selected 16-Bit counter |
4221 +----------------------------------------------------------------------------+
4222 | Output Parameters : unsigned int *_ pui_CounterValue : 16-Bit counter value |
4223 +----------------------------------------------------------------------------+
4224 | Return Value : 0: No error |
4225 | -1: The handle parameter of the board is wrong |
4226 | -2: No counter module found |
4227 | -3: Counter not initialised see function |
4228 | "i_APCI1710_InitCounter" |
4229 | -4: The selected 16-Bit counter parameter is wrong |
4230 +----------------------------------------------------------------------------+
4232 static int i_APCI1710_Read16BitCounterValue(struct comedi_device *dev,
4233 unsigned char b_ModulNbr,
4234 unsigned char b_SelectedCounter,
4235 unsigned int *pui_CounterValue)
4237 struct addi_private *devpriv = dev->private;
4238 int i_ReturnValue = 0;
4239 unsigned int dw_LathchValue = 0;
4241 /**************************/
4242 /* Test the module number */
4243 /**************************/
4245 if (b_ModulNbr < 4) {
4246 /*******************************/
4247 /* Test if counter initialised */
4248 /*******************************/
4251 s_ModuleInfo[b_ModulNbr].
4252 s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) {
4253 /******************************/
4254 /* Test the counter selection */
4255 /******************************/
4257 if (b_SelectedCounter < 2) {
4258 /*********************/
4259 /* Latch the counter */
4260 /*********************/
4262 outl(1, devpriv->s_BoardInfos.
4263 ui_Address + (64 * b_ModulNbr));
4265 /************************/
4266 /* Read the latch value */
4267 /************************/
4269 dw_LathchValue = inl(devpriv->s_BoardInfos.
4270 ui_Address + 4 + (64 * b_ModulNbr));
4273 (unsigned int) ((dw_LathchValue >> (16 *
4274 b_SelectedCounter)) &
4277 /**************************************************/
4278 /* The selected 16-Bit counter parameter is wrong */
4279 /**************************************************/
4281 DPRINTK("The selected 16-Bit counter parameter is wrong\n");
4285 /****************************************/
4286 /* Counter not initialised see function */
4287 /* "i_APCI1710_InitCounter" */
4288 /****************************************/
4290 DPRINTK("Counter not initialised\n");
4294 /*************************************************/
4295 /* The selected module number parameter is wrong */
4296 /*************************************************/
4298 DPRINTK("The selected module number parameter is wrong\n");
4302 return i_ReturnValue;
4306 +----------------------------------------------------------------------------+
4307 | Function Name : _INT_ i_APCI1710_Read32BitCounterValue |
4308 | (unsigned char_ b_BoardHandle, |
4309 | unsigned char_ b_ModulNbr, |
4310 | PULONG_ pul_CounterValue) |
4311 +----------------------------------------------------------------------------+
4312 | Task : Latch the 32-Bit counter from selected module |
4313 | (b_ModulNbr) in to the first latch register and return |
4314 | the latched value. |
4315 +----------------------------------------------------------------------------+
4316 | Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
4317 | unsigned char_ b_ModulNbr : Module number to configure |
4319 +----------------------------------------------------------------------------+
4320 | Output Parameters : PULONG_ pul_CounterValue : 32-Bit counter value |
4321 +----------------------------------------------------------------------------+
4322 | Return Value : 0: No error |
4323 | -1: The handle parameter of the board is wrong |
4324 | -2: No counter module found |
4325 | -3: Counter not initialised see function |
4326 | "i_APCI1710_InitCounter" |
4327 +----------------------------------------------------------------------------+
4329 static int i_APCI1710_Read32BitCounterValue(struct comedi_device *dev,
4330 unsigned char b_ModulNbr,
4331 unsigned int *pul_CounterValue)
4333 struct addi_private *devpriv = dev->private;
4334 int i_ReturnValue = 0;
4336 /**************************/
4337 /* Test the module number */
4338 /**************************/
4340 if (b_ModulNbr < 4) {
4341 /*******************************/
4342 /* Test if counter initialised */
4343 /*******************************/
4346 s_ModuleInfo[b_ModulNbr].
4347 s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) {
4348 /*********************/
4349 /* Tatch the counter */
4350 /*********************/
4352 outl(1, devpriv->s_BoardInfos.
4353 ui_Address + (64 * b_ModulNbr));
4355 /************************/
4356 /* Read the latch value */
4357 /************************/
4359 *pul_CounterValue = inl(devpriv->s_BoardInfos.
4360 ui_Address + 4 + (64 * b_ModulNbr));
4362 /****************************************/
4363 /* Counter not initialised see function */
4364 /* "i_APCI1710_InitCounter" */
4365 /****************************************/
4367 DPRINTK("Counter not initialised\n");
4371 /*************************************************/
4372 /* The selected module number parameter is wrong */
4373 /*************************************************/
4375 DPRINTK("The selected module number parameter is wrong\n");
4379 return i_ReturnValue;
4383 +----------------------------------------------------------------------------+
4384 | Function Name : _INT_ i_APCI1710_GetIndexStatus (unsigned char_ b_BoardHandle,|
4385 | unsigned char_ b_ModulNbr, |
4386 | unsigned char *_ pb_IndexStatus)|
4387 +----------------------------------------------------------------------------+
4388 | Task : Return the index status |
4389 +----------------------------------------------------------------------------+
4390 | Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
4391 | unsigned char_ b_ModulNbr : Module number to configure |
4393 +----------------------------------------------------------------------------+
4394 | Output Parameters : unsigned char *_ pb_IndexStatus : 0 : No INDEX occur |
4395 | 1 : A INDEX occur |
4396 +----------------------------------------------------------------------------+
4397 | Return Value : 0: No error |
4398 | -1: The handle parameter of the board is wrong |
4399 | -2: No counter module found |
4400 | -3: Counter not initialised see function |
4401 | "i_APCI1710_InitCounter" |
4402 | -4: Index not initialised see function |
4403 | "i_APCI1710_InitIndex" |
4404 +----------------------------------------------------------------------------+
4406 static int i_APCI1710_GetIndexStatus(struct comedi_device *dev,
4407 unsigned char b_ModulNbr,
4408 unsigned char *pb_IndexStatus)
4410 struct addi_private *devpriv = dev->private;
4411 int i_ReturnValue = 0;
4412 unsigned int dw_StatusReg = 0;
4414 /**************************/
4415 /* Test the module number */
4416 /**************************/
4418 if (b_ModulNbr < 4) {
4419 /*******************************/
4420 /* Test if counter initialised */
4421 /*******************************/
4424 s_ModuleInfo[b_ModulNbr].
4425 s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) {
4426 /*****************************/
4427 /* Test if index initialised */
4428 /*****************************/
4431 s_ModuleInfo[b_ModulNbr].
4432 s_SiemensCounterInfo.s_InitFlag.b_IndexInit) {
4433 dw_StatusReg = inl(devpriv->s_BoardInfos.
4434 ui_Address + 12 + (64 * b_ModulNbr));
4436 *pb_IndexStatus = (unsigned char) (dw_StatusReg & 1);
4438 /*************************************************************/
4439 /* Index not initialised see function "i_APCI1710_InitIndex" */
4440 /*************************************************************/
4442 DPRINTK("Index not initialised\n");
4446 /****************************************/
4447 /* Counter not initialised see function */
4448 /* "i_APCI1710_InitCounter" */
4449 /****************************************/
4451 DPRINTK("Counter not initialised\n");
4455 /*************************************************/
4456 /* The selected module number parameter is wrong */
4457 /*************************************************/
4459 DPRINTK("The selected module number parameter is wrong\n");
4463 return i_ReturnValue;
4467 +----------------------------------------------------------------------------+
4468 | Function Name : _INT_ i_APCI1710_GetReferenceStatus |
4469 | (unsigned char_ b_BoardHandle, |
4470 | unsigned char_ b_ModulNbr, |
4471 | unsigned char *_ pb_ReferenceStatus) |
4472 +----------------------------------------------------------------------------+
4473 | Task : Return the reference status |
4474 +----------------------------------------------------------------------------+
4475 | Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
4476 | unsigned char_ b_ModulNbr : Module number to configure |
4478 +----------------------------------------------------------------------------+
4479 | Output Parameters : unsigned char *_ pb_ReferenceStatus : 0 : No REFERENCE occur |
4480 | 1 : A REFERENCE occur |
4481 +----------------------------------------------------------------------------+
4482 | Return Value : 0: No error |
4483 | -1: The handle parameter of the board is wrong |
4484 | -2: No counter module found |
4485 | -3: Counter not initialised see function |
4486 | "i_APCI1710_InitCounter" |
4487 | -4: Reference not initialised see function |
4488 | "i_APCI1710_InitReference" |
4489 +----------------------------------------------------------------------------+
4491 static int i_APCI1710_GetReferenceStatus(struct comedi_device *dev,
4492 unsigned char b_ModulNbr,
4493 unsigned char *pb_ReferenceStatus)
4495 struct addi_private *devpriv = dev->private;
4496 int i_ReturnValue = 0;
4497 unsigned int dw_StatusReg = 0;
4499 /**************************/
4500 /* Test the module number */
4501 /**************************/
4503 if (b_ModulNbr < 4) {
4504 /*******************************/
4505 /* Test if counter initialised */
4506 /*******************************/
4509 s_ModuleInfo[b_ModulNbr].
4510 s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) {
4511 /*********************************/
4512 /* Test if reference initialised */
4513 /*********************************/
4516 s_ModuleInfo[b_ModulNbr].
4517 s_SiemensCounterInfo.
4518 s_InitFlag.b_ReferenceInit) {
4519 dw_StatusReg = inl(devpriv->s_BoardInfos.
4520 ui_Address + 24 + (64 * b_ModulNbr));
4522 *pb_ReferenceStatus =
4523 (unsigned char) (~dw_StatusReg & 1);
4525 /*********************************************************************/
4526 /* Reference not initialised see function "i_APCI1710_InitReference" */
4527 /*********************************************************************/
4529 DPRINTK("Reference not initialised\n");
4533 /****************************************/
4534 /* Counter not initialised see function */
4535 /* "i_APCI1710_InitCounter" */
4536 /****************************************/
4538 DPRINTK("Counter not initialised\n");
4542 /*************************************************/
4543 /* The selected module number parameter is wrong */
4544 /*************************************************/
4546 DPRINTK("The selected module number parameter is wrong\n");
4550 return i_ReturnValue;
4554 +----------------------------------------------------------------------------+
4555 | Function Name : _INT_ i_APCI1710_GetUASStatus |
4556 | (unsigned char_ b_BoardHandle, |
4557 | unsigned char_ b_ModulNbr, |
4558 | unsigned char *_ pb_UASStatus) |
4559 +----------------------------------------------------------------------------+
4560 | Task : Return the error signal (UAS) status |
4561 +----------------------------------------------------------------------------+
4562 | Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
4563 | unsigned char_ b_ModulNbr : Module number to configure |
4565 +----------------------------------------------------------------------------+
4566 | Output Parameters : unsigned char *_ pb_UASStatus : 0 : UAS is low "0" |
4567 | 1 : UAS is high "1" |
4568 +----------------------------------------------------------------------------+
4569 | Return Value : 0: No error |
4570 | -1: The handle parameter of the board is wrong |
4571 | -2: No counter module found |
4572 | -3: Counter not initialised see function |
4573 | "i_APCI1710_InitCounter" |
4574 +----------------------------------------------------------------------------+
4576 static int i_APCI1710_GetUASStatus(struct comedi_device *dev,
4577 unsigned char b_ModulNbr,
4578 unsigned char *pb_UASStatus)
4580 struct addi_private *devpriv = dev->private;
4581 int i_ReturnValue = 0;
4582 unsigned int dw_StatusReg = 0;
4584 /**************************/
4585 /* Test the module number */
4586 /**************************/
4588 if (b_ModulNbr < 4) {
4589 /*******************************/
4590 /* Test if counter initialised */
4591 /*******************************/
4594 s_ModuleInfo[b_ModulNbr].
4595 s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) {
4596 dw_StatusReg = inl(devpriv->s_BoardInfos.
4597 ui_Address + 24 + (64 * b_ModulNbr));
4599 *pb_UASStatus = (unsigned char) ((dw_StatusReg >> 1) & 1);
4601 /****************************************/
4602 /* Counter not initialised see function */
4603 /* "i_APCI1710_InitCounter" */
4604 /****************************************/
4606 DPRINTK("Counter not initialised\n");
4610 /*************************************************/
4611 /* The selected module number parameter is wrong */
4612 /*************************************************/
4614 DPRINTK("The selected module number parameter is wrong\n");
4619 return i_ReturnValue;
4623 +----------------------------------------------------------------------------+
4624 | Function Name : _INT_ i_APCI1710_GetCBStatus |
4625 | (unsigned char_ b_BoardHandle, |
4626 | unsigned char_ b_ModulNbr, |
4627 | unsigned char *_ pb_CBStatus) |
4628 +----------------------------------------------------------------------------+
4629 | Task : Return the counter overflow status |
4630 +----------------------------------------------------------------------------+
4631 | Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
4632 | unsigned char_ b_ModulNbr : Module number to configure |
4634 +----------------------------------------------------------------------------+
4635 | Output Parameters : unsigned char *_ pb_CBStatus : 0 : Counter no overflow |
4636 | 1 : Counter overflow |
4637 +----------------------------------------------------------------------------+
4638 | Return Value : 0: No error |
4639 | -1: The handle parameter of the board is wrong |
4640 | -2: No counter module found |
4641 | -3: Counter not initialised see function |
4642 | "i_APCI1710_InitCounter" |
4643 +----------------------------------------------------------------------------+
4645 static int i_APCI1710_GetCBStatus(struct comedi_device *dev,
4646 unsigned char b_ModulNbr,
4647 unsigned char *pb_CBStatus)
4649 struct addi_private *devpriv = dev->private;
4650 int i_ReturnValue = 0;
4651 unsigned int dw_StatusReg = 0;
4653 /**************************/
4654 /* Test the module number */
4655 /**************************/
4657 if (b_ModulNbr < 4) {
4658 /*******************************/
4659 /* Test if counter initialised */
4660 /*******************************/
4663 s_ModuleInfo[b_ModulNbr].
4664 s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) {
4665 dw_StatusReg = inl(devpriv->s_BoardInfos.
4666 ui_Address + 16 + (64 * b_ModulNbr));
4668 *pb_CBStatus = (unsigned char) (dw_StatusReg & 1);
4671 /****************************************/
4672 /* Counter not initialised see function */
4673 /* "i_APCI1710_InitCounter" */
4674 /****************************************/
4676 DPRINTK("Counter not initialised\n");
4680 /*************************************************/
4681 /* The selected module number parameter is wrong */
4682 /*************************************************/
4684 DPRINTK("The selected module number parameter is wrong\n");
4688 return i_ReturnValue;
4692 +----------------------------------------------------------------------------+
4693 | Function Name : _INT_ i_APCI1710_Get16BitCBStatus |
4694 | (unsigned char_ b_BoardHandle, |
4695 | unsigned char_ b_ModulNbr, |
4696 | unsigned char *_ pb_CBStatusCounter0, |
4697 | unsigned char *_ pb_CBStatusCounter1) |
4698 +----------------------------------------------------------------------------+
4699 | Task : Returns the counter overflow (counter initialised to |
4700 | 2*16-bit) status from selected incremental counter |
4702 +----------------------------------------------------------------------------+
4703 | Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
4704 | unsigned char_ b_ModulNbr : Module number to configure |
4706 +----------------------------------------------------------------------------+
4707 | Output Parameters : unsigned char *_ pb_CBStatusCounter0 : 0 : No overflow occur for |
4708 | the first 16-bit |
4710 | 1 : Overflow occur for the|
4711 | first 16-bit counter |
4712 | unsigned char *_ pb_CBStatusCounter1 : 0 : No overflow occur for |
4713 | the second 16-bit |
4715 | 1 : Overflow occur for the|
4716 | second 16-bit counter |
4717 +----------------------------------------------------------------------------+
4718 | Return Value : 0: No error |
4719 | -1: The handle parameter of the board is wrong |
4720 | -2: No counter module found |
4721 | -3: Counter not initialised see function |
4722 | "i_APCI1710_InitCounter" |
4723 | -4: Counter not initialised to 2*16-bit mode. |
4724 | See function "i_APCI1710_InitCounter" |
4725 | -5: Firmware revision error |
4726 +----------------------------------------------------------------------------+
4728 static int i_APCI1710_Get16BitCBStatus(struct comedi_device *dev,
4729 unsigned char b_ModulNbr,
4730 unsigned char *pb_CBStatusCounter0,
4731 unsigned char *pb_CBStatusCounter1)
4733 struct addi_private *devpriv = dev->private;
4734 int i_ReturnValue = 0;
4735 unsigned int dw_StatusReg = 0;
4737 /**************************/
4738 /* Test the module number */
4739 /**************************/
4741 if (b_ModulNbr < 4) {
4742 /*******************************/
4743 /* Test if counter initialised */
4744 /*******************************/
4747 s_ModuleInfo[b_ModulNbr].
4748 s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) {
4749 /*************************/
4750 /* Test if 2*16-Bit mode */
4751 /*************************/
4753 if ((devpriv->s_ModuleInfo[b_ModulNbr].
4754 s_SiemensCounterInfo.
4757 b_ModeRegister1 & 0x10) == 0x10) {
4758 /*****************************/
4759 /* Test the Firmware version */
4760 /*****************************/
4762 if ((devpriv->s_BoardInfos.
4763 dw_MolduleConfiguration
4764 [b_ModulNbr] & 0xFFFF) >=
4767 inl(devpriv->s_BoardInfos.
4771 *pb_CBStatusCounter1 =
4772 (unsigned char) ((dw_StatusReg >> 0) &
4774 *pb_CBStatusCounter0 =
4775 (unsigned char) ((dw_StatusReg >> 1) &
4777 } /* if ((ps_APCI1710Variable->s_Board [b_BoardHandle].s_BoardInfos.dw_MolduleConfiguration [b_ModulNbr] & 0xFFFF) >= 0x3136) */
4779 /****************************/
4780 /* Firmware revision error */
4781 /****************************/
4784 } /* if ((ps_APCI1710Variable->s_Board [b_BoardHandle].s_BoardInfos.dw_MolduleConfiguration [b_ModulNbr] & 0xFFFF) >= 0x3136) */
4785 } /* if ((ps_APCI1710Variable->s_Board [b_BoardHandle].s_ModuleInfo [b_ModulNbr].s_SiemensCounterInfo.s_ModeRegister.s_ByteModeRegister.b_ModeRegister1 & 0x10) == 0x10) */
4787 /********************************************/
4788 /* Counter not initialised to 2*16-bit mode */
4789 /* "i_APCI1710_InitCounter" */
4790 /********************************************/
4792 DPRINTK("Counter not initialised\n");
4794 } /* if ((ps_APCI1710Variable->s_Board [b_BoardHandle].s_ModuleInfo [b_ModulNbr].s_SiemensCounterInfo.s_ModeRegister.s_ByteModeRegister.b_ModeRegister1 & 0x10) == 0x10) */
4795 } /* if (ps_APCI1710Variable->s_Board [b_BoardHandle].s_ModuleInfo [b_ModulNbr].s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) */
4797 /****************************************/
4798 /* Counter not initialised see function */
4799 /* "i_APCI1710_InitCounter" */
4800 /****************************************/
4802 DPRINTK("Counter not initialised\n");
4804 } /* if (ps_APCI1710Variable->s_Board [b_BoardHandle].s_ModuleInfo [b_ModulNbr].s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) */
4805 } /* if (b_ModulNbr < 4) */
4807 /*************************************************/
4808 /* The selected module number parameter is wrong */
4809 /*************************************************/
4811 DPRINTK("The selected module number parameter is wrong\n");
4813 } /* if (b_ModulNbr < 4) */
4815 return i_ReturnValue;
4819 +----------------------------------------------------------------------------+
4820 | Function Name : _INT_ i_APCI1710_GetUDStatus |
4821 | (unsigned char_ b_BoardHandle, |
4822 | unsigned char_ b_ModulNbr, |
4823 | unsigned char *_ pb_UDStatus) |
4824 +----------------------------------------------------------------------------+
4825 | Task : Return the counter progress status |
4826 +----------------------------------------------------------------------------+
4827 | Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
4828 | unsigned char_ b_ModulNbr : Module number to configure |
4830 +----------------------------------------------------------------------------+
4831 | Output Parameters : unsigned char *_ pb_UDStatus : 0 : Counter progress in the |
4832 | selected mode down |
4833 | 1 : Counter progress in the |
4834 | selected mode up |
4835 +----------------------------------------------------------------------------+
4836 | Return Value : 0: No error |
4837 | -1: The handle parameter of the board is wrong |
4838 | -2: No counter module found |
4839 | -3: Counter not initialised see function |
4840 | "i_APCI1710_InitCounter" |
4841 +----------------------------------------------------------------------------+
4843 static int i_APCI1710_GetUDStatus(struct comedi_device *dev,
4844 unsigned char b_ModulNbr,
4845 unsigned char *pb_UDStatus)
4847 struct addi_private *devpriv = dev->private;
4848 int i_ReturnValue = 0;
4849 unsigned int dw_StatusReg = 0;
4851 /**************************/
4852 /* Test the module number */
4853 /**************************/
4855 if (b_ModulNbr < 4) {
4856 /*******************************/
4857 /* Test if counter initialised */
4858 /*******************************/
4861 s_ModuleInfo[b_ModulNbr].
4862 s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) {
4863 dw_StatusReg = inl(devpriv->s_BoardInfos.
4864 ui_Address + 24 + (64 * b_ModulNbr));
4866 *pb_UDStatus = (unsigned char) ((dw_StatusReg >> 2) & 1);
4869 /****************************************/
4870 /* Counter not initialised see function */
4871 /* "i_APCI1710_InitCounter" */
4872 /****************************************/
4874 DPRINTK("Counter not initialised\n");
4878 /*************************************************/
4879 /* The selected module number parameter is wrong */
4880 /*************************************************/
4882 DPRINTK("The selected module number parameter is wrong\n");
4886 return i_ReturnValue;
4890 +----------------------------------------------------------------------------+
4891 | Function Name : _INT_ i_APCI1710_GetInterruptUDLatchedStatus |
4892 | (unsigned char_ b_BoardHandle, |
4893 | unsigned char_ b_ModulNbr, |
4894 | unsigned char *_ pb_UDStatus) |
4895 +----------------------------------------------------------------------------+
4896 | Task : Return the counter progress latched status after a |
4897 | index interrupt occur. |
4898 +----------------------------------------------------------------------------+
4899 | Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
4900 | unsigned char_ b_ModulNbr : Module number to configure |
4902 +----------------------------------------------------------------------------+
4903 | Output Parameters : unsigned char *_ pb_UDStatus : 0 : Counter progress in the |
4904 | selected mode down |
4905 | 1 : Counter progress in the |
4906 | selected mode up |
4907 | 2 : No index interrupt occur |
4908 +----------------------------------------------------------------------------+
4909 | Return Value : 0: No error |
4910 | -1: The handle parameter of the board is wrong |
4911 | -2: No counter module found |
4912 | -3: Counter not initialised see function |
4913 | "i_APCI1710_InitCounter" |
4914 | -4: Interrupt function not initialised. |
4915 | See function "i_APCI1710_SetBoardIntRoutineX" |
4916 +----------------------------------------------------------------------------+
4918 static int i_APCI1710_GetInterruptUDLatchedStatus(struct comedi_device *dev,
4919 unsigned char b_ModulNbr,
4920 unsigned char *pb_UDStatus)
4922 struct addi_private *devpriv = dev->private;
4923 int i_ReturnValue = 0;
4924 unsigned int dw_StatusReg = 0;
4926 /**************************/
4927 /* Test the module number */
4928 /**************************/
4930 if (b_ModulNbr < 4) {
4931 /*******************************/
4932 /* Test if counter initialised */
4933 /*******************************/
4936 s_ModuleInfo[b_ModulNbr].
4937 s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) {
4938 /*********************************/
4939 /* Test if index interrupt occur */
4940 /*********************************/
4943 s_ModuleInfo[b_ModulNbr].
4944 s_SiemensCounterInfo.
4945 s_InitFlag.b_IndexInterruptOccur == 1) {
4947 s_ModuleInfo[b_ModulNbr].
4948 s_SiemensCounterInfo.
4949 s_InitFlag.b_IndexInterruptOccur = 0;
4951 dw_StatusReg = inl(devpriv->s_BoardInfos.
4952 ui_Address + 12 + (64 * b_ModulNbr));
4954 *pb_UDStatus = (unsigned char) ((dw_StatusReg >> 1) & 1);
4956 /****************************/
4957 /* No index interrupt occur */
4958 /****************************/
4963 /****************************************/
4964 /* Counter not initialised see function */
4965 /* "i_APCI1710_InitCounter" */
4966 /****************************************/
4968 DPRINTK("Counter not initialised\n");
4972 /*************************************************/
4973 /* The selected module number parameter is wrong */
4974 /*************************************************/
4976 DPRINTK("The selected module number parameter is wrong\n");
4980 return i_ReturnValue;
4984 +----------------------------------------------------------------------------+
4985 | Function Name : _INT_ i_APCI1710_ReadFrequencyMeasurement |
4986 | (unsigned char_ b_BoardHandle, |
4987 | unsigned char_ b_ModulNbr, |
4988 | unsigned char *_ pb_Status, |
4989 | PULONG_ pul_ReadValue) |
4990 +----------------------------------------------------------------------------+
4991 | Task : Returns the status (pb_Status) and the number of |
4992 | increments in the set time. |
4993 | See function " i_APCI1710_InitFrequencyMeasurement " |
4994 +----------------------------------------------------------------------------+
4995 | Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
4996 | unsigned char_ b_ModulNbr : Number of the module to be |
4997 | configured (0 to 3) |
4998 +----------------------------------------------------------------------------+
4999 | Output Parameters : unsigned char *_ pb_Status : Returns the frequency |
5000 | measurement status |
5001 | 0 : Counting cycle not |
5003 | 1 : Counting cycle started. |
5004 | 2 : Counting cycle stopped. |
5005 | The measurement cycle is |
5007 | unsigned char *_ pb_UDStatus : 0 : Counter progress in the |
5008 | selected mode down |
5009 | 1 : Counter progress in the |
5010 | selected mode up |
5011 | PULONG_ pul_ReadValue : Return the number of |
5012 | increments in the defined |
5014 +----------------------------------------------------------------------------+
5015 | Return Value : 0: No error |
5016 | -1: The handle parameter of the board is wrong |
5017 | -2: The selected module number is wrong |
5018 | -3: Counter not initialised see function |
5019 | "i_APCI1710_InitCounter" |
5020 | -4: Frequency measurement logic not initialised. |
5021 | See function "i_APCI1710_InitFrequencyMeasurement" |
5022 +----------------------------------------------------------------------------+
5024 static int i_APCI1710_ReadFrequencyMeasurement(struct comedi_device *dev,
5025 unsigned char b_ModulNbr,
5026 unsigned char *pb_Status,
5027 unsigned char *pb_UDStatus,
5028 unsigned int *pul_ReadValue)
5030 struct addi_private *devpriv = dev->private;
5031 int i_ReturnValue = 0;
5032 unsigned int ui_16BitValue;
5033 unsigned int dw_StatusReg;
5035 /**************************/
5036 /* Test the module number */
5037 /**************************/
5039 if (b_ModulNbr < 4) {
5040 /*******************************/
5041 /* Test if counter initialised */
5042 /*******************************/
5045 s_ModuleInfo[b_ModulNbr].
5046 s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) {
5047 /********************************************/
5048 /* Test if frequency measurement initialised */
5049 /********************************************/
5052 s_ModuleInfo[b_ModulNbr].
5053 s_SiemensCounterInfo.
5054 s_InitFlag.b_FrequencyMeasurementInit == 1) {
5055 /******************/
5056 /* Test if enable */
5057 /******************/
5060 s_ModuleInfo[b_ModulNbr].
5061 s_SiemensCounterInfo.
5063 b_FrequencyMeasurementEnable == 1) {
5064 /*******************/
5065 /* Read the status */
5066 /*******************/
5069 inl(devpriv->s_BoardInfos.
5073 /**************************/
5074 /* Test if frequency stop */
5075 /**************************/
5077 if (dw_StatusReg & 1) {
5080 (unsigned char) ((dw_StatusReg >>
5083 /******************/
5084 /* Read the value */
5085 /******************/
5093 if (*pb_UDStatus == 0) {
5094 /*************************/
5095 /* Test the counter mode */
5096 /*************************/
5098 if ((devpriv->s_ModuleInfo[b_ModulNbr].s_SiemensCounterInfo.s_ModeRegister.s_ByteModeRegister.b_ModeRegister1 & APCI1710_16BIT_COUNTER) == APCI1710_16BIT_COUNTER) {
5099 /****************************************/
5100 /* Test if 16-bit counter 1 pulse occur */
5101 /****************************************/
5103 if ((*pul_ReadValue & 0xFFFFU) != 0) {
5122 /****************************************/
5123 /* Test if 16-bit counter 2 pulse occur */
5124 /****************************************/
5126 if ((*pul_ReadValue & 0xFFFF0000UL) != 0) {
5143 (0xFFFFU - ui_16BitValue) << 16);
5146 if (*pul_ReadValue != 0) {
5155 if (*pb_UDStatus == 1) {
5156 /****************************************/
5157 /* Test if 16-bit counter 2 pulse occur */
5158 /****************************************/
5160 if ((*pul_ReadValue & 0xFFFF0000UL) != 0) {
5177 (0xFFFFU - ui_16BitValue) << 16);
5182 /****************************************/
5183 /* Test if 16-bit counter 1 pulse occur */
5184 /****************************************/
5186 if ((*pul_ReadValue & 0xFFFFU) != 0) {
5216 /***********************************************/
5217 /* Frequency measurement logic not initialised */
5218 /***********************************************/
5220 DPRINTK("Frequency measurement logic not initialised\n");
5224 /****************************************/
5225 /* Counter not initialised see function */
5226 /* "i_APCI1710_InitCounter" */
5227 /****************************************/
5229 DPRINTK("Counter not initialised\n");
5233 /*************************************************/
5234 /* The selected module number parameter is wrong */
5235 /*************************************************/
5237 DPRINTK("The selected module number parameter is wrong\n");
5241 return i_ReturnValue;
5244 * Read and Get functions for INC_CPT
5246 static int i_APCI1710_InsnReadINCCPT(struct comedi_device *dev,
5247 struct comedi_subdevice *s,
5248 struct comedi_insn *insn,
5251 struct addi_private *devpriv = dev->private;
5252 unsigned int ui_ReadType;
5253 int i_ReturnValue = 0;
5255 ui_ReadType = CR_CHAN(insn->chanspec);
5257 devpriv->tsk_Current = current; /* Save the current process task structure */
5258 switch (ui_ReadType) {
5259 case APCI1710_INCCPT_READLATCHREGISTERSTATUS:
5260 i_ReturnValue = i_APCI1710_ReadLatchRegisterStatus(dev,
5261 (unsigned char) CR_AREF(insn->chanspec),
5262 (unsigned char) CR_RANGE(insn->chanspec), (unsigned char *) &data[0]);
5265 case APCI1710_INCCPT_READLATCHREGISTERVALUE:
5266 i_ReturnValue = i_APCI1710_ReadLatchRegisterValue(dev,
5267 (unsigned char) CR_AREF(insn->chanspec),
5268 (unsigned char) CR_RANGE(insn->chanspec), (unsigned int *) &data[0]);
5269 printk("Latch Register Value %d\n", data[0]);
5272 case APCI1710_INCCPT_READ16BITCOUNTERVALUE:
5273 i_ReturnValue = i_APCI1710_Read16BitCounterValue(dev,
5274 (unsigned char) CR_AREF(insn->chanspec),
5275 (unsigned char) CR_RANGE(insn->chanspec), (unsigned int *) &data[0]);
5278 case APCI1710_INCCPT_READ32BITCOUNTERVALUE:
5279 i_ReturnValue = i_APCI1710_Read32BitCounterValue(dev,
5280 (unsigned char) CR_AREF(insn->chanspec), (unsigned int *) &data[0]);
5283 case APCI1710_INCCPT_GETINDEXSTATUS:
5284 i_ReturnValue = i_APCI1710_GetIndexStatus(dev,
5285 (unsigned char) CR_AREF(insn->chanspec), (unsigned char *) &data[0]);
5288 case APCI1710_INCCPT_GETREFERENCESTATUS:
5289 i_ReturnValue = i_APCI1710_GetReferenceStatus(dev,
5290 (unsigned char) CR_AREF(insn->chanspec), (unsigned char *) &data[0]);
5293 case APCI1710_INCCPT_GETUASSTATUS:
5294 i_ReturnValue = i_APCI1710_GetUASStatus(dev,
5295 (unsigned char) CR_AREF(insn->chanspec), (unsigned char *) &data[0]);
5298 case APCI1710_INCCPT_GETCBSTATUS:
5299 i_ReturnValue = i_APCI1710_GetCBStatus(dev,
5300 (unsigned char) CR_AREF(insn->chanspec), (unsigned char *) &data[0]);
5303 case APCI1710_INCCPT_GET16BITCBSTATUS:
5304 i_ReturnValue = i_APCI1710_Get16BitCBStatus(dev,
5305 (unsigned char) CR_AREF(insn->chanspec),
5306 (unsigned char *) &data[0], (unsigned char *) &data[1]);
5309 case APCI1710_INCCPT_GETUDSTATUS:
5310 i_ReturnValue = i_APCI1710_GetUDStatus(dev,
5311 (unsigned char) CR_AREF(insn->chanspec), (unsigned char *) &data[0]);
5315 case APCI1710_INCCPT_GETINTERRUPTUDLATCHEDSTATUS:
5316 i_ReturnValue = i_APCI1710_GetInterruptUDLatchedStatus(dev,
5317 (unsigned char) CR_AREF(insn->chanspec), (unsigned char *) &data[0]);
5320 case APCI1710_INCCPT_READFREQUENCYMEASUREMENT:
5321 i_ReturnValue = i_APCI1710_ReadFrequencyMeasurement(dev,
5322 (unsigned char) CR_AREF(insn->chanspec),
5323 (unsigned char *) &data[0],
5324 (unsigned char *) &data[1], (unsigned int *) &data[2]);
5327 case APCI1710_INCCPT_READINTERRUPT:
5328 data[0] = devpriv->s_InterruptParameters.
5329 s_FIFOInterruptParameters[devpriv->
5330 s_InterruptParameters.ui_Read].b_OldModuleMask;
5331 data[1] = devpriv->s_InterruptParameters.
5332 s_FIFOInterruptParameters[devpriv->
5333 s_InterruptParameters.ui_Read].ul_OldInterruptMask;
5334 data[2] = devpriv->s_InterruptParameters.
5335 s_FIFOInterruptParameters[devpriv->
5336 s_InterruptParameters.ui_Read].ul_OldCounterLatchValue;
5338 /**************************/
5339 /* Increment the read FIFO */
5340 /***************************/
5343 s_InterruptParameters.
5344 ui_Read = (devpriv->s_InterruptParameters.
5345 ui_Read + 1) % APCI1710_SAVE_INTERRUPT;
5350 printk("ReadType Parameter wrong\n");
5353 if (i_ReturnValue >= 0)
5354 i_ReturnValue = insn->n;
5355 return i_ReturnValue;