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 +-----------------------------------------------------------------------+
54 #define APCI1710_16BIT_COUNTER 0x10
55 #define APCI1710_32BIT_COUNTER 0x0
56 #define APCI1710_QUADRUPLE_MODE 0x0
57 #define APCI1710_DOUBLE_MODE 0x3
58 #define APCI1710_SIMPLE_MODE 0xF
59 #define APCI1710_DIRECT_MODE 0x80
60 #define APCI1710_HYSTERESIS_ON 0x60
61 #define APCI1710_HYSTERESIS_OFF 0x0
62 #define APCI1710_INCREMENT 0x60
63 #define APCI1710_DECREMENT 0x0
64 #define APCI1710_LATCH_COUNTER 0x1
65 #define APCI1710_CLEAR_COUNTER 0x0
66 #define APCI1710_LOW 0x0
67 #define APCI1710_HIGH 0x1
69 /*********************/
70 /* Version 0600-0229 */
71 /*********************/
72 #define APCI1710_HIGH_EDGE_CLEAR_COUNTER 0x0
73 #define APCI1710_HIGH_EDGE_LATCH_COUNTER 0x1
74 #define APCI1710_LOW_EDGE_CLEAR_COUNTER 0x2
75 #define APCI1710_LOW_EDGE_LATCH_COUNTER 0x3
76 #define APCI1710_HIGH_EDGE_LATCH_AND_CLEAR_COUNTER 0x4
77 #define APCI1710_LOW_EDGE_LATCH_AND_CLEAR_COUNTER 0x5
78 #define APCI1710_SOURCE_0 0x0
79 #define APCI1710_SOURCE_1 0x1
81 #define APCI1710_30MHZ 30
82 #define APCI1710_33MHZ 33
83 #define APCI1710_40MHZ 40
85 #define APCI1710_ENABLE_LATCH_INT 0x80
86 #define APCI1710_DISABLE_LATCH_INT (~APCI1710_ENABLE_LATCH_INT)
88 #define APCI1710_INDEX_LATCH_COUNTER 0x10
89 #define APCI1710_INDEX_AUTO_MODE 0x8
90 #define APCI1710_ENABLE_INDEX 0x4
91 #define APCI1710_DISABLE_INDEX (~APCI1710_ENABLE_INDEX)
92 #define APCI1710_ENABLE_LATCH_AND_CLEAR 0x8
93 #define APCI1710_DISABLE_LATCH_AND_CLEAR (~APCI1710_ENABLE_LATCH_AND_CLEAR)
94 #define APCI1710_SET_LOW_INDEX_LEVEL 0x4
95 #define APCI1710_SET_HIGH_INDEX_LEVEL (~APCI1710_SET_LOW_INDEX_LEVEL)
96 #define APCI1710_INVERT_INDEX_RFERENCE 0x2
97 #define APCI1710_DEFAULT_INDEX_RFERENCE (~APCI1710_INVERT_INDEX_RFERENCE)
99 #define APCI1710_ENABLE_INDEX_INT 0x1
100 #define APCI1710_DISABLE_INDEX_INT (~APCI1710_ENABLE_INDEX_INT)
102 #define APCI1710_ENABLE_FREQUENCY 0x4
103 #define APCI1710_DISABLE_FREQUENCY (~APCI1710_ENABLE_FREQUENCY)
105 #define APCI1710_ENABLE_FREQUENCY_INT 0x8
106 #define APCI1710_DISABLE_FREQUENCY_INT (~APCI1710_ENABLE_FREQUENCY_INT)
108 #define APCI1710_ENABLE_40MHZ_FREQUENCY 0x40
109 #define APCI1710_DISABLE_40MHZ_FREQUENCY (~APCI1710_ENABLE_40MHZ_FREQUENCY)
111 #define APCI1710_ENABLE_40MHZ_FILTER 0x80
112 #define APCI1710_DISABLE_40MHZ_FILTER (~APCI1710_ENABLE_40MHZ_FILTER)
114 #define APCI1710_ENABLE_COMPARE_INT 0x2
115 #define APCI1710_DISABLE_COMPARE_INT (~APCI1710_ENABLE_COMPARE_INT)
117 #define APCI1710_ENABLE_INDEX_ACTION 0x20
118 #define APCI1710_DISABLE_INDEX_ACTION (~APCI1710_ENABLE_INDEX_ACTION)
119 #define APCI1710_REFERENCE_HIGH 0x40
120 #define APCI1710_REFERENCE_LOW (~APCI1710_REFERENCE_HIGH)
122 #define APCI1710_TOR_GATE_LOW 0x40
123 #define APCI1710_TOR_GATE_HIGH (~APCI1710_TOR_GATE_LOW)
126 #define APCI1710_INCCPT_INITCOUNTER 100
127 #define APCI1710_INCCPT_COUNTERAUTOTEST 101
128 #define APCI1710_INCCPT_INITINDEX 102
129 #define APCI1710_INCCPT_INITREFERENCE 103
130 #define APCI1710_INCCPT_INITEXTERNALSTROBE 104
131 #define APCI1710_INCCPT_INITCOMPARELOGIC 105
132 #define APCI1710_INCCPT_INITFREQUENCYMEASUREMENT 106
135 #define APCI1710_INCCPT_READLATCHREGISTERSTATUS 200
136 #define APCI1710_INCCPT_READLATCHREGISTERVALUE 201
137 #define APCI1710_INCCPT_READ16BITCOUNTERVALUE 202
138 #define APCI1710_INCCPT_READ32BITCOUNTERVALUE 203
139 #define APCI1710_INCCPT_GETINDEXSTATUS 204
140 #define APCI1710_INCCPT_GETREFERENCESTATUS 205
141 #define APCI1710_INCCPT_GETUASSTATUS 206
142 #define APCI1710_INCCPT_GETCBSTATUS 207
143 #define APCI1710_INCCPT_GET16BITCBSTATUS 208
144 #define APCI1710_INCCPT_GETUDSTATUS 209
145 #define APCI1710_INCCPT_GETINTERRUPTUDLATCHEDSTATUS 210
146 #define APCI1710_INCCPT_READFREQUENCYMEASUREMENT 211
147 #define APCI1710_INCCPT_READINTERRUPT 212
150 #define APCI1710_INCCPT_CLEARCOUNTERVALUE 300
151 #define APCI1710_INCCPT_CLEARALLCOUNTERVALUE 301
152 #define APCI1710_INCCPT_SETINPUTFILTER 302
153 #define APCI1710_INCCPT_LATCHCOUNTER 303
154 #define APCI1710_INCCPT_SETINDEXANDREFERENCESOURCE 304
155 #define APCI1710_INCCPT_SETDIGITALCHLON 305
156 #define APCI1710_INCCPT_SETDIGITALCHLOFF 306
159 #define APCI1710_INCCPT_ENABLELATCHINTERRUPT 400
160 #define APCI1710_INCCPT_DISABLELATCHINTERRUPT 401
161 #define APCI1710_INCCPT_WRITE16BITCOUNTERVALUE 402
162 #define APCI1710_INCCPT_WRITE32BITCOUNTERVALUE 403
163 #define APCI1710_INCCPT_ENABLEINDEX 404
164 #define APCI1710_INCCPT_DISABLEINDEX 405
165 #define APCI1710_INCCPT_ENABLECOMPARELOGIC 406
166 #define APCI1710_INCCPT_DISABLECOMPARELOGIC 407
167 #define APCI1710_INCCPT_ENABLEFREQUENCYMEASUREMENT 408
168 #define APCI1710_INCCPT_DISABLEFREQUENCYMEASUREMENT 409
171 +----------------------------------------------------------------------------+
172 | Function Name : _INT_ i_APCI1710_InitCounter |
173 | (unsigned char_ b_BoardHandle, |
174 | unsigned char_ b_ModulNbr, |
175 | unsigned char_ b_CounterRange, |
176 | unsigned char_ b_FirstCounterModus, |
177 | unsigned char_ b_FirstCounterOption, |
178 | unsigned char_ b_SecondCounterModus, |
179 | unsigned char_ b_SecondCounterOption) |
180 +----------------------------------------------------------------------------+
181 | Task : Configure the counter operating mode from selected |
182 | module (b_ModulNbr). You must calling this function be |
183 | for you call any other function witch access of |
188 | +------------------------------------+-----------------------------------+ |
189 | | Parameter Passed value | Description | |
190 | |------------------------------------+-----------------------------------| |
191 | |b_ModulNbr APCI1710_16BIT_COUNTER | The module is configured for | |
192 | | | two 16-bit counter. | |
193 | | | - b_FirstCounterModus and | |
194 | | | b_FirstCounterOption | |
195 | | | configure the first 16 bit | |
197 | | | - b_SecondCounterModus and | |
198 | | | b_SecondCounterOption | |
199 | | | configure the second 16 bit | |
201 | |------------------------------------+-----------------------------------| |
202 | |b_ModulNbr APCI1710_32BIT_COUNTER | The module is configured for one | |
203 | | | 32-bit counter. | |
204 | | | - b_FirstCounterModus and | |
205 | | | b_FirstCounterOption | |
206 | | | configure the 32 bit counter. | |
207 | | | - b_SecondCounterModus and | |
208 | | | b_SecondCounterOption | |
209 | | | are not used and have no | |
210 | | | importance. | |
211 | +------------------------------------+-----------------------------------+ |
213 | Counter operating mode |
214 | ---------------------- |
216 | +--------------------+-------------------------+-------------------------+ |
217 | | Parameter | Passed value | Description | |
218 | |--------------------+-------------------------+-------------------------| |
219 | |b_FirstCounterModus | APCI1710_QUADRUPLE_MODE | In the quadruple mode, | |
220 | | or | | the edge analysis | |
221 | |b_SecondCounterModus| | circuit generates a | |
222 | | | | counting pulse from | |
223 | | | | each edge of 2 signals | |
224 | | | | which are phase shifted | |
225 | | | | in relation to each | |
227 | |--------------------+-------------------------+-------------------------| |
228 | |b_FirstCounterModus | APCI1710_DOUBLE_MODE | Functions in the same | |
229 | | or | | way as the quadruple | |
230 | |b_SecondCounterModus| | mode, except that only | |
231 | | | | two of the four edges | |
232 | | | | are analysed per | |
234 | |--------------------+-------------------------+-------------------------| |
235 | |b_FirstCounterModus | APCI1710_SIMPLE_MODE | Functions in the same | |
236 | | or | | way as the quadruple | |
237 | |b_SecondCounterModus| | mode, except that only | |
238 | | | | one of the four edges | |
239 | | | | is analysed per | |
241 | |--------------------+-------------------------+-------------------------| |
242 | |b_FirstCounterModus | APCI1710_DIRECT_MODE | In the direct mode the | |
243 | | or | | both edge analysis | |
244 | |b_SecondCounterModus| | circuits are inactive. | |
245 | | | | The inputs A, B in the | |
246 | | | | 32-bit mode or A, B and | |
247 | | | | C, D in the 16-bit mode | |
248 | | | | represent, each, one | |
249 | | | | clock pulse gate circuit| |
250 | | | | There by frequency and | |
251 | | | | pulse duration | |
252 | | | | measurements can be | |
253 | | | | performed. | |
254 | +--------------------+-------------------------+-------------------------+ |
258 | If you have configured the module for two 16-bit counter, a mixed |
259 | mode with a counter in quadruple/double/single mode |
260 | and the other counter in direct mode is not possible! |
263 | Counter operating option for quadruple/double/simple mode |
264 | --------------------------------------------------------- |
266 | +----------------------+-------------------------+------------------------+|
267 | | Parameter | Passed value | Description ||
268 | |----------------------+-------------------------+------------------------||
269 | |b_FirstCounterOption | APCI1710_HYSTERESIS_ON | In both edge analysis ||
270 | | or | | circuits is available ||
271 | |b_SecondCounterOption | | one hysteresis circuit.||
272 | | | | It suppresses each ||
273 | | | | time the first counting||
274 | | | | pulse after a change ||
275 | | | | of rotation. ||
276 | |----------------------+-------------------------+------------------------||
277 | |b_FirstCounterOption | APCI1710_HYSTERESIS_OFF | The first counting ||
278 | | or | | pulse is not suppress ||
279 | |b_SecondCounterOption | | after a change of ||
281 | +----------------------+-------------------------+------------------------+|
285 | This option are only avaible if you have selected the direct mode. |
288 | Counter operating option for direct mode |
289 | ---------------------------------------- |
291 | +----------------------+--------------------+----------------------------+ |
292 | | Parameter | Passed value | Description | |
293 | |----------------------+--------------------+----------------------------| |
294 | |b_FirstCounterOption | APCI1710_INCREMENT | The counter increment for | |
295 | | or | | each counting pulse | |
296 | |b_SecondCounterOption | | | |
297 | |----------------------+--------------------+----------------------------| |
298 | |b_FirstCounterOption | APCI1710_DECREMENT | The counter decrement for | |
299 | | or | | each counting pulse | |
300 | |b_SecondCounterOption | | | |
301 | +----------------------+--------------------+----------------------------+ |
303 +----------------------------------------------------------------------------+
304 | Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710|
305 | unsigned char_ b_ModulNbr : Module number to |
306 | configure (0 to 3) |
307 | unsigned char_ b_CounterRange : Selection form counter |
309 | unsigned char_ b_FirstCounterModus : First counter operating |
311 | unsigned char_ b_FirstCounterOption : First counter option. |
312 | unsigned char_ b_SecondCounterModus : Second counter operating |
314 | unsigned char_ b_SecondCounterOption : Second counter option. |
315 +----------------------------------------------------------------------------+
316 | Output Parameters : - |
317 +----------------------------------------------------------------------------+
318 | Return Value : 0: No error |
319 | -1: The handle parameter of the board is wrong |
320 | -2: The module is not a counter module |
321 | -3: The selected counter range is wrong. |
322 | -4: The selected first counter operating mode is wrong. |
323 | -5: The selected first counter operating option is wrong|
324 | -6: The selected second counter operating mode is wrong.|
325 | -7: The selected second counter operating option is |
327 +----------------------------------------------------------------------------+
329 static int i_APCI1710_InitCounter(struct comedi_device *dev,
330 unsigned char b_ModulNbr,
331 unsigned char b_CounterRange,
332 unsigned char b_FirstCounterModus,
333 unsigned char b_FirstCounterOption,
334 unsigned char b_SecondCounterModus,
335 unsigned char b_SecondCounterOption)
337 struct addi_private *devpriv = dev->private;
338 int i_ReturnValue = 0;
340 /*******************************/
341 /* Test if incremental counter */
342 /*******************************/
344 if ((devpriv->s_BoardInfos.
345 dw_MolduleConfiguration[b_ModulNbr] & 0xFFFF0000UL) ==
346 APCI1710_INCREMENTAL_COUNTER) {
347 /**************************/
348 /* Test the counter range */
349 /**************************/
351 if (b_CounterRange == APCI1710_16BIT_COUNTER
352 || b_CounterRange == APCI1710_32BIT_COUNTER) {
353 /********************************/
354 /* Test the first counter modus */
355 /********************************/
357 if (b_FirstCounterModus == APCI1710_QUADRUPLE_MODE ||
358 b_FirstCounterModus == APCI1710_DOUBLE_MODE ||
359 b_FirstCounterModus == APCI1710_SIMPLE_MODE ||
360 b_FirstCounterModus == APCI1710_DIRECT_MODE) {
361 /*********************************/
362 /* Test the first counter option */
363 /*********************************/
365 if ((b_FirstCounterModus == APCI1710_DIRECT_MODE
366 && (b_FirstCounterOption ==
368 || b_FirstCounterOption
369 == APCI1710_DECREMENT))
370 || (b_FirstCounterModus !=
372 && (b_FirstCounterOption ==
373 APCI1710_HYSTERESIS_ON
374 || b_FirstCounterOption
376 APCI1710_HYSTERESIS_OFF)))
378 /**************************/
379 /* Test if 16-bit counter */
380 /**************************/
382 if (b_CounterRange ==
383 APCI1710_16BIT_COUNTER) {
384 /*********************************/
385 /* Test the second counter modus */
386 /*********************************/
388 if ((b_FirstCounterModus !=
391 (b_SecondCounterModus
393 APCI1710_QUADRUPLE_MODE
401 APCI1710_SIMPLE_MODE))
402 || (b_FirstCounterModus
408 APCI1710_DIRECT_MODE))
410 /**********************************/
411 /* Test the second counter option */
412 /**********************************/
414 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))) {
418 /*********************************************************/
419 /* The selected second counter operating option is wrong */
420 /*********************************************************/
422 DPRINTK("The selected second counter operating option is wrong\n");
427 /*******************************************************/
428 /* The selected second counter operating mode is wrong */
429 /*******************************************************/
431 DPRINTK("The selected second counter operating mode is wrong\n");
436 /********************************************************/
437 /* The selected first counter operating option is wrong */
438 /********************************************************/
440 DPRINTK("The selected first counter operating option is wrong\n");
444 /******************************************************/
445 /* The selected first counter operating mode is wrong */
446 /******************************************************/
447 DPRINTK("The selected first counter operating mode is wrong\n");
451 /***************************************/
452 /* The selected counter range is wrong */
453 /***************************************/
455 DPRINTK("The selected counter range is wrong\n");
459 /*************************/
460 /* Test if a error occur */
461 /*************************/
463 if (i_ReturnValue == 0) {
464 /**************************/
465 /* Test if 16-Bit counter */
466 /**************************/
468 if (b_CounterRange == APCI1710_32BIT_COUNTER) {
470 s_ModuleInfo[b_ModulNbr].
471 s_SiemensCounterInfo.
474 b_ModeRegister1 = b_CounterRange |
475 b_FirstCounterModus |
476 b_FirstCounterOption;
479 s_ModuleInfo[b_ModulNbr].
480 s_SiemensCounterInfo.
483 b_ModeRegister1 = b_CounterRange |
484 (b_FirstCounterModus & 0x5) |
485 (b_FirstCounterOption & 0x20) |
486 (b_SecondCounterModus & 0xA) |
487 (b_SecondCounterOption & 0x40);
489 /***********************/
490 /* Test if direct mode */
491 /***********************/
493 if (b_FirstCounterModus == APCI1710_DIRECT_MODE) {
495 s_ModuleInfo[b_ModulNbr].
496 s_SiemensCounterInfo.
499 b_ModeRegister1 = devpriv->
500 s_ModuleInfo[b_ModulNbr].
501 s_SiemensCounterInfo.
505 APCI1710_DIRECT_MODE;
509 /***************************/
510 /* Write the configuration */
511 /***************************/
513 outl(devpriv->s_ModuleInfo[b_ModulNbr].
514 s_SiemensCounterInfo.
516 dw_ModeRegister1_2_3_4,
517 devpriv->s_BoardInfos.
518 ui_Address + 20 + (64 * b_ModulNbr));
521 s_ModuleInfo[b_ModulNbr].
522 s_SiemensCounterInfo.
523 s_InitFlag.b_CounterInit = 1;
526 /**************************************/
527 /* The module is not a counter module */
528 /**************************************/
530 DPRINTK("The module is not a counter module\n");
534 return i_ReturnValue;
538 +----------------------------------------------------------------------------+
539 | Function Name : _INT_ i_APCI1710_CounterAutoTest |
540 | (unsigned char_ b_BoardHandle, |
541 | unsigned char *_ pb_TestStatus) |
542 +----------------------------------------------------------------------------+
543 | Task : A test mode is intended for testing the component and |
544 | the connected periphery. All the 8-bit counter chains |
545 | are operated internally as down counters. |
546 | Independently from the external signals, |
547 | all the four 8-bit counter chains are decremented in |
548 | parallel by each negative clock pulse edge of CLKX. |
550 | Counter auto test conclusion |
551 | ---------------------------- |
552 | +-----------------+-----------------------------+ |
553 | | pb_TestStatus | Error description | |
555 | |-----------------+-----------------------------| |
556 | | 0000 | No error detected | |
557 | |-----------------|-----------------------------| |
558 | | 0001 | Error detected of counter 0 | |
559 | |-----------------|-----------------------------| |
560 | | 0010 | Error detected of counter 1 | |
561 | |-----------------|-----------------------------| |
562 | | 0100 | Error detected of counter 2 | |
563 | |-----------------|-----------------------------| |
564 | | 1000 | Error detected of counter 3 | |
565 | +-----------------+-----------------------------+ |
566 +----------------------------------------------------------------------------+
567 | Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | |
568 +----------------------------------------------------------------------------+
569 | Output Parameters : unsigned char *_ pb_TestStatus : Auto test conclusion. See table|
570 +----------------------------------------------------------------------------+
571 | Return Value : 0: No error |
572 | -1: The handle parameter of the board is wrong |
573 | -2: No counter module found |
574 +----------------------------------------------------------------------------+
576 static int i_APCI1710_CounterAutoTest(struct comedi_device *dev,
577 unsigned char *pb_TestStatus)
579 struct addi_private *devpriv = dev->private;
580 unsigned char b_ModulCpt = 0;
581 int i_ReturnValue = 0;
582 unsigned int dw_LathchValue;
586 /********************************/
587 /* Test if counter module found */
588 /********************************/
590 if ((devpriv->s_BoardInfos.
591 dw_MolduleConfiguration[0] & 0xFFFF0000UL) ==
592 APCI1710_INCREMENTAL_COUNTER
593 || (devpriv->s_BoardInfos.
594 dw_MolduleConfiguration[1] & 0xFFFF0000UL) ==
595 APCI1710_INCREMENTAL_COUNTER
596 || (devpriv->s_BoardInfos.
597 dw_MolduleConfiguration[2] & 0xFFFF0000UL) ==
598 APCI1710_INCREMENTAL_COUNTER
599 || (devpriv->s_BoardInfos.
600 dw_MolduleConfiguration[3] & 0xFFFF0000UL) ==
601 APCI1710_INCREMENTAL_COUNTER) {
602 for (b_ModulCpt = 0; b_ModulCpt < 4; b_ModulCpt++) {
603 /*******************************/
604 /* Test if incremental counter */
605 /*******************************/
607 if ((devpriv->s_BoardInfos.
608 dw_MolduleConfiguration[b_ModulCpt] &
610 APCI1710_INCREMENTAL_COUNTER) {
615 outl(3, devpriv->s_BoardInfos.
616 ui_Address + 16 + (64 * b_ModulCpt));
618 /*********************/
619 /* Tatch the counter */
620 /*********************/
622 outl(1, devpriv->s_BoardInfos.
623 ui_Address + (64 * b_ModulCpt));
625 /************************/
626 /* Read the latch value */
627 /************************/
629 dw_LathchValue = inl(devpriv->s_BoardInfos.
630 ui_Address + 4 + (64 * b_ModulCpt));
632 if ((dw_LathchValue & 0xFF) !=
633 ((dw_LathchValue >> 8) & 0xFF)
634 && (dw_LathchValue & 0xFF) !=
635 ((dw_LathchValue >> 16) & 0xFF)
636 && (dw_LathchValue & 0xFF) !=
637 ((dw_LathchValue >> 24) & 0xFF)) {
639 *pb_TestStatus | (1 <<
647 outl(0, devpriv->s_BoardInfos.
648 ui_Address + 16 + (64 * b_ModulCpt));
652 /***************************/
653 /* No counter module found */
654 /***************************/
656 DPRINTK("No counter module found\n");
660 return i_ReturnValue;
664 +----------------------------------------------------------------------------+
665 | Function Name : _INT_ i_APCI1710_InitIndex (unsigned char_ b_BoardHandle, |
666 | unsigned char_ b_ModulNbr, |
667 | unsigned char_ b_ReferenceAction, |
668 | unsigned char_ b_IndexOperation, |
669 | unsigned char_ b_AutoMode, |
670 | unsigned char_ b_InterruptEnable) |
671 +----------------------------------------------------------------------------+
672 | Task : Initialise the index corresponding to the selected |
673 | module (b_ModulNbr). If a INDEX flag occur, you have |
674 | the possibility to clear the 32-Bit counter or to latch|
675 | the current 32-Bit value in to the first latch |
676 | register. The b_IndexOperation parameter give the |
677 | possibility to choice the INDEX action. |
678 | If you have enabled the automatic mode, each INDEX |
679 | action is cleared automatically, else you must read |
680 | the index status ("i_APCI1710_ReadIndexStatus") |
681 | after each INDEX action. |
687 | +------------------------+------------------------------------+ |
688 | | b_IndexOperation | Operation | |
689 | |------------------------+------------------------------------| |
690 | |APCI1710_LATCH_COUNTER | After a index signal, the counter | |
691 | | | value (32-Bit) is latched in to | |
692 | | | the first latch register | |
693 | |------------------------|------------------------------------| |
694 | |APCI1710_CLEAR_COUNTER | After a index signal, the counter | |
695 | | | value is cleared (32-Bit) | |
696 | +------------------------+------------------------------------+ |
697 +----------------------------------------------------------------------------+
698 | Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
699 | unsigned char_ b_ModulNbr : Module number to configure |
701 | unsigned char_ b_ReferenceAction : Determine if the reference |
702 | must set or no for the |
703 | acceptance from index |
704 | APCI1710_ENABLE : |
705 | Reference must be set for |
706 | accepted the index |
707 | APCI1710_DISABLE : |
708 | Reference have not |
710 | unsigned char_ b_IndexOperation : Index operating mode. |
712 | unsigned char_ b_AutoMode : Enable or disable the |
713 | automatic index reset. |
714 | APCI1710_ENABLE : |
715 | Enable the automatic mode |
716 | APCI1710_DISABLE : |
717 | Disable the automatic mode |
718 | unsigned char_ b_InterruptEnable : Enable or disable the |
720 | APCI1710_ENABLE : |
721 | Enable the interrupt |
722 | APCI1710_DISABLE : |
723 | Disable the interrupt |
724 +----------------------------------------------------------------------------+
725 | Output Parameters : - |
726 +----------------------------------------------------------------------------+
727 | Return Value : 0: No error |
728 | -1: The handle parameter of the board is wrong |
729 | -2: No counter module found |
730 | -3: Counter not initialised see function |
731 | "i_APCI1710_InitCounter" |
732 | -4 The reference action parameter is wrong |
733 | -5: The index operating mode parameter is wrong |
734 | -6: The auto mode parameter is wrong |
735 | -7: Interrupt parameter is wrong |
736 | -8: Interrupt function not initialised. |
737 | See function "i_APCI1710_SetBoardIntRoutineX" |
738 +----------------------------------------------------------------------------+
740 static int i_APCI1710_InitIndex(struct comedi_device *dev,
741 unsigned char b_ModulNbr,
742 unsigned char b_ReferenceAction,
743 unsigned char b_IndexOperation,
744 unsigned char b_AutoMode,
745 unsigned char b_InterruptEnable)
747 struct addi_private *devpriv = dev->private;
748 int i_ReturnValue = 0;
750 /**************************/
751 /* Test the module number */
752 /**************************/
754 if (b_ModulNbr < 4) {
755 /*******************************/
756 /* Test if counter initialised */
757 /*******************************/
760 s_ModuleInfo[b_ModulNbr].
761 s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) {
762 /********************************/
763 /* Test the reference parameter */
764 /********************************/
766 if (b_ReferenceAction == APCI1710_ENABLE ||
767 b_ReferenceAction == APCI1710_DISABLE) {
768 /****************************/
769 /* Test the index parameter */
770 /****************************/
772 if (b_IndexOperation ==
773 APCI1710_HIGH_EDGE_LATCH_COUNTER
774 || b_IndexOperation ==
775 APCI1710_LOW_EDGE_LATCH_COUNTER
776 || b_IndexOperation ==
777 APCI1710_HIGH_EDGE_CLEAR_COUNTER
778 || b_IndexOperation ==
779 APCI1710_LOW_EDGE_CLEAR_COUNTER
780 || b_IndexOperation ==
781 APCI1710_HIGH_EDGE_LATCH_AND_CLEAR_COUNTER
782 || b_IndexOperation ==
783 APCI1710_LOW_EDGE_LATCH_AND_CLEAR_COUNTER)
785 /********************************/
786 /* Test the auto mode parameter */
787 /********************************/
789 if (b_AutoMode == APCI1710_ENABLE ||
790 b_AutoMode == APCI1710_DISABLE)
792 /***************************/
793 /* Test the interrupt mode */
794 /***************************/
796 if (b_InterruptEnable ==
798 || b_InterruptEnable ==
801 /************************************/
802 /* Makte the configuration commando */
803 /************************************/
805 if (b_ReferenceAction ==
811 s_SiemensCounterInfo.
819 s_SiemensCounterInfo.
824 APCI1710_ENABLE_INDEX_ACTION;
829 s_SiemensCounterInfo.
837 s_SiemensCounterInfo.
842 APCI1710_DISABLE_INDEX_ACTION;
845 /****************************************/
846 /* Test if low level latch or/and clear */
847 /****************************************/
849 if (b_IndexOperation ==
850 APCI1710_LOW_EDGE_LATCH_COUNTER
854 APCI1710_LOW_EDGE_CLEAR_COUNTER
858 APCI1710_LOW_EDGE_LATCH_AND_CLEAR_COUNTER)
860 /*************************************/
861 /* Set the index level to low (DQ26) */
862 /*************************************/
867 s_SiemensCounterInfo.
875 s_SiemensCounterInfo.
880 APCI1710_SET_LOW_INDEX_LEVEL;
882 /**************************************/
883 /* Set the index level to high (DQ26) */
884 /**************************************/
889 s_SiemensCounterInfo.
897 s_SiemensCounterInfo.
902 APCI1710_SET_HIGH_INDEX_LEVEL;
905 /***********************************/
906 /* Test if latch and clear counter */
907 /***********************************/
909 if (b_IndexOperation ==
910 APCI1710_HIGH_EDGE_LATCH_AND_CLEAR_COUNTER
914 APCI1710_LOW_EDGE_LATCH_AND_CLEAR_COUNTER)
916 /***************************************/
917 /* Set the latch and clear flag (DQ27) */
918 /***************************************/
923 s_SiemensCounterInfo.
931 s_SiemensCounterInfo.
936 APCI1710_ENABLE_LATCH_AND_CLEAR;
937 } /* if (b_IndexOperation == APCI1710_HIGH_EDGE_LATCH_AND_CLEAR_COUNTER || b_IndexOperation == APCI1710_LOW_EDGE_LATCH_AND_CLEAR_COUNTER) */
939 /*****************************************/
940 /* Clear the latch and clear flag (DQ27) */
941 /*****************************************/
946 s_SiemensCounterInfo.
954 s_SiemensCounterInfo.
959 APCI1710_DISABLE_LATCH_AND_CLEAR;
961 /*************************/
962 /* Test if latch counter */
963 /*************************/
965 if (b_IndexOperation == APCI1710_HIGH_EDGE_LATCH_COUNTER || b_IndexOperation == APCI1710_LOW_EDGE_LATCH_COUNTER) {
966 /*********************************/
967 /* Enable the latch from counter */
968 /*********************************/
973 s_SiemensCounterInfo.
981 s_SiemensCounterInfo.
986 APCI1710_INDEX_LATCH_COUNTER;
988 /*********************************/
989 /* Enable the clear from counter */
990 /*********************************/
995 s_SiemensCounterInfo.
1003 s_SiemensCounterInfo.
1008 (~APCI1710_INDEX_LATCH_COUNTER);
1010 } /* // if (b_IndexOperation == APCI1710_HIGH_EDGE_LATCH_AND_CLEAR_COUNTER || b_IndexOperation == APCI1710_LOW_EDGE_LATCH_AND_CLEAR_COUNTER) */
1018 s_SiemensCounterInfo.
1026 s_SiemensCounterInfo.
1031 APCI1710_INDEX_AUTO_MODE;
1036 s_SiemensCounterInfo.
1044 s_SiemensCounterInfo.
1049 (~APCI1710_INDEX_AUTO_MODE);
1052 if (b_InterruptEnable ==
1058 s_SiemensCounterInfo.
1066 s_SiemensCounterInfo.
1071 APCI1710_ENABLE_INDEX_INT;
1076 s_SiemensCounterInfo.
1084 s_SiemensCounterInfo.
1089 APCI1710_DISABLE_INDEX_INT;
1095 s_SiemensCounterInfo.
1100 /********************************/
1101 /* Interrupt parameter is wrong */
1102 /********************************/
1103 DPRINTK("Interrupt parameter is wrong\n");
1107 /************************************/
1108 /* The auto mode parameter is wrong */
1109 /************************************/
1111 DPRINTK("The auto mode parameter is wrong\n");
1115 /***********************************************/
1116 /* The index operating mode parameter is wrong */
1117 /***********************************************/
1119 DPRINTK("The index operating mode parameter is wrong\n");
1123 /*******************************************/
1124 /* The reference action parameter is wrong */
1125 /*******************************************/
1127 DPRINTK("The reference action parameter is wrong\n");
1131 /****************************************/
1132 /* Counter not initialised see function */
1133 /* "i_APCI1710_InitCounter" */
1134 /****************************************/
1136 DPRINTK("Counter not initialised\n");
1140 /*************************************************/
1141 /* The selected module number parameter is wrong */
1142 /*************************************************/
1144 DPRINTK("The selected module number parameter is wrong\n");
1148 return i_ReturnValue;
1152 +----------------------------------------------------------------------------+
1153 | Function Name : _INT_ i_APCI1710_InitReference |
1154 | (unsigned char_ b_BoardHandle, |
1155 | unsigned char_ b_ModulNbr, |
1156 | unsigned char_ b_ReferenceLevel) |
1157 +----------------------------------------------------------------------------+
1158 | Task : Initialise the reference corresponding to the selected |
1159 | module (b_ModulNbr). |
1163 | +--------------------+-------------------------+ |
1164 | | b_ReferenceLevel | Operation | |
1165 | +--------------------+-------------------------+ |
1166 | | APCI1710_LOW | Reference occur if "0" | |
1167 | |--------------------|-------------------------| |
1168 | | APCI1710_HIGH | Reference occur if "1" | |
1169 | +--------------------+-------------------------+ |
1170 +----------------------------------------------------------------------------+
1171 | Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
1172 | unsigned char_ b_ModulNbr : Module number to configure |
1174 | unsigned char_ b_ReferenceLevel : Reference level. |
1175 +----------------------------------------------------------------------------+
1176 | Output Parameters : - |
1177 +----------------------------------------------------------------------------+
1178 | Return Value : 0: No error |
1179 | -1: The handle parameter of the board is wrong |
1180 | -2: The selected module number parameter is wrong |
1181 | -3: Counter not initialised see function |
1182 | "i_APCI1710_InitCounter" |
1183 | -4: Reference level parameter is wrong |
1184 +----------------------------------------------------------------------------+
1186 static int i_APCI1710_InitReference(struct comedi_device *dev,
1187 unsigned char b_ModulNbr,
1188 unsigned char b_ReferenceLevel)
1190 struct addi_private *devpriv = dev->private;
1191 int i_ReturnValue = 0;
1193 /**************************/
1194 /* Test the module number */
1195 /**************************/
1197 if (b_ModulNbr < 4) {
1198 /*******************************/
1199 /* Test if counter initialised */
1200 /*******************************/
1203 s_ModuleInfo[b_ModulNbr].
1204 s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) {
1205 /**************************************/
1206 /* Test the reference level parameter */
1207 /**************************************/
1209 if (b_ReferenceLevel == 0 || b_ReferenceLevel == 1) {
1210 if (b_ReferenceLevel == 1) {
1212 s_ModuleInfo[b_ModulNbr].
1213 s_SiemensCounterInfo.
1216 b_ModeRegister2 = devpriv->
1217 s_ModuleInfo[b_ModulNbr].
1218 s_SiemensCounterInfo.
1222 APCI1710_REFERENCE_HIGH;
1225 s_ModuleInfo[b_ModulNbr].
1226 s_SiemensCounterInfo.
1229 b_ModeRegister2 = devpriv->
1230 s_ModuleInfo[b_ModulNbr].
1231 s_SiemensCounterInfo.
1235 APCI1710_REFERENCE_LOW;
1238 outl(devpriv->s_ModuleInfo[b_ModulNbr].
1239 s_SiemensCounterInfo.
1241 dw_ModeRegister1_2_3_4,
1242 devpriv->s_BoardInfos.ui_Address + 20 +
1246 s_ModuleInfo[b_ModulNbr].
1247 s_SiemensCounterInfo.
1248 s_InitFlag.b_ReferenceInit = 1;
1250 /**************************************/
1251 /* Reference level parameter is wrong */
1252 /**************************************/
1254 DPRINTK("Reference level parameter is wrong\n");
1258 /****************************************/
1259 /* Counter not initialised see function */
1260 /* "i_APCI1710_InitCounter" */
1261 /****************************************/
1263 DPRINTK("Counter not initialised\n");
1267 /*************************************************/
1268 /* The selected module number parameter is wrong */
1269 /*************************************************/
1271 DPRINTK("The selected module number parameter is wrong\n");
1275 return i_ReturnValue;
1279 +----------------------------------------------------------------------------+
1280 | Function Name : _INT_ i_APCI1710_InitExternalStrobe |
1281 | (unsigned char_ b_BoardHandle, |
1282 | unsigned char_ b_ModulNbr, |
1283 | unsigned char_ b_ExternalStrobe, |
1284 | unsigned char_ b_ExternalStrobeLevel) |
1285 +----------------------------------------------------------------------------+
1286 | Task : Initialises the external strobe level corresponding to |
1287 | the selected module (b_ModulNbr). |
1288 +----------------------------------------------------------------------------+
1289 | Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
1290 | unsigned char_ b_ModulNbr : Module number to configure |
1292 | unsigned char_ b_ExternalStrobe : External strobe selection |
1293 | 0 : External strobe A |
1294 | 1 : External strobe B |
1295 | unsigned char_ b_ExternalStrobeLevel : External strobe level |
1297 | External latch occurs if "0" |
1299 | External latch occurs if "1" |
1300 +----------------------------------------------------------------------------+
1301 | Output Parameters : - |
1302 +----------------------------------------------------------------------------+
1303 | Return Value : 0: No error |
1304 | -1: The handle parameter of the board is wrong |
1305 | -2: The selected module number is wrong |
1306 | -3: Counter not initialised. |
1307 | See function "i_APCI1710_InitCounter" |
1308 | -4: External strobe selection is wrong |
1309 | -5: External strobe level parameter is wrong |
1310 +----------------------------------------------------------------------------+
1312 static int i_APCI1710_InitExternalStrobe(struct comedi_device *dev,
1313 unsigned char b_ModulNbr,
1314 unsigned char b_ExternalStrobe,
1315 unsigned char b_ExternalStrobeLevel)
1317 struct addi_private *devpriv = dev->private;
1318 int i_ReturnValue = 0;
1320 /**************************/
1321 /* Test the module number */
1322 /**************************/
1324 if (b_ModulNbr < 4) {
1325 /*******************************/
1326 /* Test if counter initialised */
1327 /*******************************/
1330 s_ModuleInfo[b_ModulNbr].
1331 s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) {
1332 /**************************************/
1333 /* Test the external strobe selection */
1334 /**************************************/
1336 if (b_ExternalStrobe == 0 || b_ExternalStrobe == 1) {
1337 /******************/
1338 /* Test the level */
1339 /******************/
1341 if ((b_ExternalStrobeLevel == APCI1710_HIGH) ||
1342 ((b_ExternalStrobeLevel == APCI1710_LOW
1345 dw_MolduleConfiguration
1354 s_ModuleInfo[b_ModulNbr].
1355 s_SiemensCounterInfo.
1358 b_ModeRegister4 = (devpriv->
1359 s_ModuleInfo[b_ModulNbr].
1360 s_SiemensCounterInfo.
1363 b_ModeRegister4 & (0xFF -
1364 (0x10 << b_ExternalStrobe))) | ((b_ExternalStrobeLevel ^ 1) << (4 + b_ExternalStrobe));
1366 /********************************************/
1367 /* External strobe level parameter is wrong */
1368 /********************************************/
1370 DPRINTK("External strobe level parameter is wrong\n");
1373 } /* if (b_ExternalStrobe == 0 || b_ExternalStrobe == 1) */
1375 /**************************************/
1376 /* External strobe selection is wrong */
1377 /**************************************/
1379 DPRINTK("External strobe selection is wrong\n");
1381 } /* if (b_ExternalStrobe == 0 || b_ExternalStrobe == 1) */
1383 /****************************************/
1384 /* Counter not initialised see function */
1385 /* "i_APCI1710_InitCounter" */
1386 /****************************************/
1388 DPRINTK("Counter not initialised\n");
1392 /*************************************************/
1393 /* The selected module number parameter is wrong */
1394 /*************************************************/
1396 DPRINTK("The selected module number parameter is wrong\n");
1400 return i_ReturnValue;
1404 +----------------------------------------------------------------------------+
1405 | Function Name : _INT_ i_APCI1710_InitCompareLogic |
1406 | (unsigned char_ b_BoardHandle, |
1407 | unsigned char_ b_ModulNbr, |
1408 | unsigned int_ ui_CompareValue) |
1409 +----------------------------------------------------------------------------+
1410 | Task : Set the 32-Bit compare value. At that moment that the |
1411 | incremental counter arrive to the compare value |
1412 | (ui_CompareValue) a interrupt is generated. |
1413 +----------------------------------------------------------------------------+
1414 | Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
1415 | unsigned char_ b_ModulNbr : Module number to configure |
1417 | unsigned int_ ui_CompareValue : 32-Bit compare value |
1418 +----------------------------------------------------------------------------+
1419 | Output Parameters : -
1420 +----------------------------------------------------------------------------+
1421 | Return Value : 0: No error |
1422 | -1: The handle parameter of the board is wrong |
1423 | -2: No counter module found |
1424 | -3: Counter not initialised see function |
1425 | "i_APCI1710_InitCounter" |
1426 +----------------------------------------------------------------------------+
1428 static int i_APCI1710_InitCompareLogic(struct comedi_device *dev,
1429 unsigned char b_ModulNbr,
1430 unsigned int ui_CompareValue)
1432 struct addi_private *devpriv = dev->private;
1433 int i_ReturnValue = 0;
1435 /**************************/
1436 /* Test the module number */
1437 /**************************/
1439 if (b_ModulNbr < 4) {
1440 /*******************************/
1441 /* Test if counter initialised */
1442 /*******************************/
1445 s_ModuleInfo[b_ModulNbr].
1446 s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) {
1448 outl(ui_CompareValue, devpriv->s_BoardInfos.
1449 ui_Address + 28 + (64 * b_ModulNbr));
1452 s_ModuleInfo[b_ModulNbr].
1453 s_SiemensCounterInfo.
1454 s_InitFlag.b_CompareLogicInit = 1;
1456 /****************************************/
1457 /* Counter not initialised see function */
1458 /* "i_APCI1710_InitCounter" */
1459 /****************************************/
1461 DPRINTK("Counter not initialised\n");
1465 /*************************************************/
1466 /* The selected module number parameter is wrong */
1467 /*************************************************/
1469 DPRINTK("The selected module number parameter is wrong\n");
1473 return i_ReturnValue;
1477 +----------------------------------------------------------------------------+
1478 | Function Name : _INT_ i_APCI1710_InitFrequencyMeasurement |
1479 | (unsigned char_ b_BoardHandle, |
1480 | unsigned char_ b_ModulNbr, |
1481 | unsigned char_ b_PCIInputClock, |
1482 | unsigned char_ b_TimingUnity, |
1483 | ULONG_ ul_TimingInterval, |
1484 | PULONG_ pul_RealTimingInterval) |
1485 +----------------------------------------------------------------------------+
1486 | Task : Sets the time for the frequency measurement. |
1487 | Configures the selected TOR incremental counter of the |
1488 | selected module (b_ModulNbr). The ul_TimingInterval and|
1489 | ul_TimingUnity determine the time base for the |
1490 | measurement. The pul_RealTimingInterval returns the |
1491 | real time value. You must call up this function before |
1492 | you call up any other function which gives access to |
1493 | the frequency measurement. |
1494 +----------------------------------------------------------------------------+
1495 | Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
1496 | unsigned char_ b_ModulNbr : Number of the module to be |
1497 | configured (0 to 3) |
1498 | unsigned char_ b_PCIInputClock : Selection of the PCI bus |
1500 | - APCI1710_30MHZ : |
1501 | The PC has a PCI bus clock |
1503 | - APCI1710_33MHZ : |
1504 | The PC has a PCI bus clock |
1506 | unsigned char_ b_TimingUnity : Base time unit (0 to 2) |
1510 | ULONG_ ul_TimingInterval: Base time value. |
1511 +----------------------------------------------------------------------------+
1512 | Output Parameters : PULONG_ pul_RealTimingInterval : Real base time value. |
1513 +----------------------------------------------------------------------------+
1514 | Return Value : 0: No error |
1515 | -1: The handle parameter of the board is wrong |
1516 | -2: The selected module number is wrong |
1517 | -3: Counter not initialised see function |
1518 | "i_APCI1710_InitCounter" |
1519 | -4: The selected PCI input clock is wrong |
1520 | -5: Timing unity selection is wrong |
1521 | -6: Base timing selection is wrong |
1522 | -7: 40MHz quartz not on board |
1523 +----------------------------------------------------------------------------+
1525 static int i_APCI1710_InitFrequencyMeasurement(struct comedi_device *dev,
1526 unsigned char b_ModulNbr,
1527 unsigned char b_PCIInputClock,
1528 unsigned char b_TimingUnity,
1529 unsigned int ul_TimingInterval,
1530 unsigned int *pul_RealTimingInterval)
1532 struct addi_private *devpriv = dev->private;
1533 int i_ReturnValue = 0;
1534 unsigned int ul_TimerValue = 0;
1535 double d_RealTimingInterval;
1536 unsigned int dw_Status = 0;
1538 /**************************/
1539 /* Test the module number */
1540 /**************************/
1542 if (b_ModulNbr < 4) {
1543 /*******************************/
1544 /* Test if counter initialised */
1545 /*******************************/
1548 s_ModuleInfo[b_ModulNbr].
1549 s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) {
1550 /**************************/
1551 /* Test the PCI bus clock */
1552 /**************************/
1554 if ((b_PCIInputClock == APCI1710_30MHZ) ||
1555 (b_PCIInputClock == APCI1710_33MHZ) ||
1556 (b_PCIInputClock == APCI1710_40MHZ)) {
1557 /************************/
1558 /* Test the timing unit */
1559 /************************/
1561 if (b_TimingUnity <= 2) {
1562 /**********************************/
1563 /* Test the base timing selection */
1564 /**********************************/
1566 if (((b_PCIInputClock == APCI1710_30MHZ)
1567 && (b_TimingUnity == 0)
1568 && (ul_TimingInterval >=
1570 && (ul_TimingInterval <=
1572 || ((b_PCIInputClock ==
1574 && (b_TimingUnity == 1)
1575 && (ul_TimingInterval >=
1577 && (ul_TimingInterval <=
1579 || ((b_PCIInputClock ==
1581 && (b_TimingUnity == 2)
1582 && (ul_TimingInterval >=
1584 && (ul_TimingInterval <=
1586 || ((b_PCIInputClock ==
1588 && (b_TimingUnity == 0)
1589 && (ul_TimingInterval >=
1591 && (ul_TimingInterval <=
1593 || ((b_PCIInputClock ==
1595 && (b_TimingUnity == 1)
1596 && (ul_TimingInterval >=
1598 && (ul_TimingInterval <=
1600 || ((b_PCIInputClock ==
1602 && (b_TimingUnity == 2)
1603 && (ul_TimingInterval >=
1605 && (ul_TimingInterval <=
1607 || ((b_PCIInputClock ==
1609 && (b_TimingUnity == 0)
1610 && (ul_TimingInterval >=
1612 && (ul_TimingInterval <=
1614 || ((b_PCIInputClock ==
1616 && (b_TimingUnity == 1)
1617 && (ul_TimingInterval >=
1619 && (ul_TimingInterval <=
1621 || ((b_PCIInputClock ==
1623 && (b_TimingUnity == 2)
1624 && (ul_TimingInterval >=
1626 && (ul_TimingInterval <=
1628 /**********************/
1629 /* Test if 40MHz used */
1630 /**********************/
1632 if (b_PCIInputClock ==
1634 /******************************/
1635 /* Test if firmware >= Rev1.5 */
1636 /******************************/
1638 if ((devpriv->s_BoardInfos.dw_MolduleConfiguration[b_ModulNbr] & 0xFFFF) >= 0x3135) {
1639 /*********************************/
1640 /* Test if 40MHz quartz on board */
1641 /*********************************/
1643 /*INPDW (ps_APCI1710Variable->
1644 s_Board [b_BoardHandle].
1646 ui_Address + 36 + (64 * b_ModulNbr), &dw_Status); */
1655 /******************************/
1656 /* Test the quartz flag (DQ0) */
1657 /******************************/
1659 if ((dw_Status & 1) != 1) {
1660 /*****************************/
1661 /* 40MHz quartz not on board */
1662 /*****************************/
1664 DPRINTK("40MHz quartz not on board\n");
1670 /*****************************/
1671 /* 40MHz quartz not on board */
1672 /*****************************/
1673 DPRINTK("40MHz quartz not on board\n");
1677 } /* if (b_PCIInputClock == APCI1710_40MHZ) */
1679 /***************************/
1680 /* Test if not error occur */
1681 /***************************/
1683 if (i_ReturnValue == 0) {
1684 /****************************/
1685 /* Test the INC_CPT version */
1686 /****************************/
1688 if ((devpriv->s_BoardInfos.dw_MolduleConfiguration[b_ModulNbr] & 0xFFFF) >= 0x3131) {
1690 /**********************/
1691 /* Test if 40MHz used */
1692 /**********************/
1694 if (b_PCIInputClock == APCI1710_40MHZ) {
1695 /*********************************/
1696 /* Enable the 40MHz quarz (DQ30) */
1697 /*********************************/
1702 s_SiemensCounterInfo.
1710 s_SiemensCounterInfo.
1715 APCI1710_ENABLE_40MHZ_FREQUENCY;
1716 } /* if (b_PCIInputClock == APCI1710_40MHZ) */
1718 /**********************************/
1719 /* Disable the 40MHz quarz (DQ30) */
1720 /**********************************/
1725 s_SiemensCounterInfo.
1733 s_SiemensCounterInfo.
1738 APCI1710_DISABLE_40MHZ_FREQUENCY;
1740 } /* if (b_PCIInputClock == APCI1710_40MHZ) */
1742 /********************************/
1743 /* Calculate the division fator */
1744 /********************************/
1747 switch (b_TimingUnity) {
1754 /******************/
1755 /* Timer 0 factor */
1756 /******************/
1763 (0.00025 * b_PCIInputClock));
1765 /*******************/
1766 /* Round the value */
1767 /*******************/
1769 if ((double)((double)ul_TimingInterval * (0.00025 * (double)b_PCIInputClock)) >= ((double)((double)ul_TimerValue + 0.5))) {
1777 /*****************************/
1778 /* Calculate the real timing */
1779 /*****************************/
1781 *pul_RealTimingInterval
1786 (0.00025 * (double)b_PCIInputClock));
1787 d_RealTimingInterval
1797 if ((double)((double)ul_TimerValue / (0.00025 * (double)b_PCIInputClock)) >= (double)((double)*pul_RealTimingInterval + 0.5)) {
1798 *pul_RealTimingInterval
1800 *pul_RealTimingInterval
1824 /******************/
1825 /* Timer 0 factor */
1826 /******************/
1833 (0.25 * b_PCIInputClock));
1835 /*******************/
1836 /* Round the value */
1837 /*******************/
1839 if ((double)((double)ul_TimingInterval * (0.25 * (double)b_PCIInputClock)) >= ((double)((double)ul_TimerValue + 0.5))) {
1847 /*****************************/
1848 /* Calculate the real timing */
1849 /*****************************/
1851 *pul_RealTimingInterval
1856 (0.25 * (double)b_PCIInputClock));
1857 d_RealTimingInterval
1869 if ((double)((double)ul_TimerValue / (0.25 * (double)b_PCIInputClock)) >= (double)((double)*pul_RealTimingInterval + 0.5)) {
1870 *pul_RealTimingInterval
1872 *pul_RealTimingInterval
1896 /******************/
1897 /* Timer 0 factor */
1898 /******************/
1908 /*******************/
1909 /* Round the value */
1910 /*******************/
1912 if ((double)((double)ul_TimingInterval * (250.0 * (double)b_PCIInputClock)) >= ((double)((double)ul_TimerValue + 0.5))) {
1920 /*****************************/
1921 /* Calculate the real timing */
1922 /*****************************/
1924 *pul_RealTimingInterval
1929 (250.0 * (double)b_PCIInputClock));
1930 d_RealTimingInterval
1940 if ((double)((double)ul_TimerValue / (250.0 * (double)b_PCIInputClock)) >= (double)((double)*pul_RealTimingInterval + 0.5)) {
1941 *pul_RealTimingInterval
1943 *pul_RealTimingInterval
1963 /*************************/
1964 /* Write the timer value */
1965 /*************************/
1967 outl(ul_TimerValue, devpriv->s_BoardInfos.ui_Address + 32 + (64 * b_ModulNbr));
1969 /*******************************/
1970 /* Set the initialisation flag */
1971 /*******************************/
1976 s_SiemensCounterInfo.
1978 b_FrequencyMeasurementInit
1981 /***************************/
1982 /* Counter not initialised */
1983 /***************************/
1985 DPRINTK("Counter not initialised\n");
1989 } /* if (i_ReturnValue == 0) */
1991 /**********************************/
1992 /* Base timing selection is wrong */
1993 /**********************************/
1995 DPRINTK("Base timing selection is wrong\n");
1999 /***********************************/
2000 /* Timing unity selection is wrong */
2001 /***********************************/
2003 DPRINTK("Timing unity selection is wrong\n");
2007 /*****************************************/
2008 /* The selected PCI input clock is wrong */
2009 /*****************************************/
2011 DPRINTK("The selected PCI input clock is wrong\n");
2015 /****************************************/
2016 /* Counter not initialised see function */
2017 /* "i_APCI1710_InitCounter" */
2018 /****************************************/
2020 DPRINTK("Counter not initialised\n");
2024 /*************************************************/
2025 /* The selected module number parameter is wrong */
2026 /*************************************************/
2028 DPRINTK("The selected module number parameter is wrong\n");
2032 return i_ReturnValue;
2036 * Configuration function for INC_CPT
2038 static int i_APCI1710_InsnConfigINCCPT(struct comedi_device *dev,
2039 struct comedi_subdevice *s,
2040 struct comedi_insn *insn,
2043 struct addi_private *devpriv = dev->private;
2044 unsigned int ui_ConfigType;
2045 int i_ReturnValue = 0;
2047 ui_ConfigType = CR_CHAN(insn->chanspec);
2049 printk("\nINC_CPT");
2051 devpriv->tsk_Current = current; /* Save the current process task structure */
2052 switch (ui_ConfigType) {
2053 case APCI1710_INCCPT_INITCOUNTER:
2054 i_ReturnValue = i_APCI1710_InitCounter(dev,
2055 CR_AREF(insn->chanspec),
2056 (unsigned char) data[0],
2057 (unsigned char) data[1],
2058 (unsigned char) data[2], (unsigned char) data[3], (unsigned char) data[4]);
2061 case APCI1710_INCCPT_COUNTERAUTOTEST:
2062 i_ReturnValue = i_APCI1710_CounterAutoTest(dev,
2063 (unsigned char *) &data[0]);
2066 case APCI1710_INCCPT_INITINDEX:
2067 i_ReturnValue = i_APCI1710_InitIndex(dev,
2068 CR_AREF(insn->chanspec),
2069 (unsigned char) data[0],
2070 (unsigned char) data[1], (unsigned char) data[2], (unsigned char) data[3]);
2073 case APCI1710_INCCPT_INITREFERENCE:
2074 i_ReturnValue = i_APCI1710_InitReference(dev,
2075 CR_AREF(insn->chanspec), (unsigned char) data[0]);
2078 case APCI1710_INCCPT_INITEXTERNALSTROBE:
2079 i_ReturnValue = i_APCI1710_InitExternalStrobe(dev,
2080 CR_AREF(insn->chanspec),
2081 (unsigned char) data[0], (unsigned char) data[1]);
2084 case APCI1710_INCCPT_INITCOMPARELOGIC:
2085 i_ReturnValue = i_APCI1710_InitCompareLogic(dev,
2086 CR_AREF(insn->chanspec), (unsigned int) data[0]);
2089 case APCI1710_INCCPT_INITFREQUENCYMEASUREMENT:
2090 i_ReturnValue = i_APCI1710_InitFrequencyMeasurement(dev,
2091 CR_AREF(insn->chanspec),
2092 (unsigned char) data[0],
2093 (unsigned char) data[1], (unsigned int) data[2], (unsigned int *) &data[0]);
2097 printk("Insn Config : Config Parameter Wrong\n");
2101 if (i_ReturnValue >= 0)
2102 i_ReturnValue = insn->n;
2103 return i_ReturnValue;
2107 +----------------------------------------------------------------------------+
2108 | Function Name : _INT_ i_APCI1710_ClearCounterValue |
2109 | (unsigned char_ b_BoardHandle, |
2110 | unsigned char_ b_ModulNbr) |
2111 +----------------------------------------------------------------------------+
2112 | Task : Clear the counter value from selected module |
2114 +----------------------------------------------------------------------------+
2115 | Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
2116 | unsigned char_ b_ModulNbr : Module number to configure |
2118 +----------------------------------------------------------------------------+
2119 | Output Parameters : - |
2120 +----------------------------------------------------------------------------+
2121 | Return Value : 0: No error |
2122 | -1: The handle parameter of the board is wrong |
2123 | -2: The selected module number parameter is wrong |
2124 | -3: Counter not initialised see function |
2125 | "i_APCI1710_InitCounter" |
2126 +----------------------------------------------------------------------------+
2128 static int i_APCI1710_ClearCounterValue(struct comedi_device *dev,
2129 unsigned char b_ModulNbr)
2131 struct addi_private *devpriv = dev->private;
2132 int i_ReturnValue = 0;
2134 /**************************/
2135 /* Test the module number */
2136 /**************************/
2138 if (b_ModulNbr < 4) {
2139 /*******************************/
2140 /* Test if counter initialised */
2141 /*******************************/
2144 s_ModuleInfo[b_ModulNbr].
2145 s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) {
2146 /*********************/
2147 /* Clear the counter */
2148 /*********************/
2150 outl(1, devpriv->s_BoardInfos.
2151 ui_Address + 16 + (64 * b_ModulNbr));
2153 /****************************************/
2154 /* Counter not initialised see function */
2155 /* "i_APCI1710_InitCounter" */
2156 /****************************************/
2158 DPRINTK("Counter not initialised\n");
2162 /*************************************************/
2163 /* The selected module number parameter is wrong */
2164 /*************************************************/
2166 DPRINTK("The selected module number parameter is wrong\n");
2170 return i_ReturnValue;
2174 +----------------------------------------------------------------------------+
2175 | Function Name : _INT_ i_APCI1710_ClearAllCounterValue |
2176 | (unsigned char_ b_BoardHandle) |
2177 +----------------------------------------------------------------------------+
2178 | Task : Clear all counter value. |
2179 +----------------------------------------------------------------------------+
2180 | Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
2181 +----------------------------------------------------------------------------+
2182 | Output Parameters : - |
2183 +----------------------------------------------------------------------------+
2184 | Return Value : 0: No error |
2185 | -1: The handle parameter of the board is wrong |
2186 | -2: No counter module found |
2187 +----------------------------------------------------------------------------+
2189 static int i_APCI1710_ClearAllCounterValue(struct comedi_device *dev)
2191 struct addi_private *devpriv = dev->private;
2192 unsigned char b_ModulCpt = 0;
2193 int i_ReturnValue = 0;
2195 /********************************/
2196 /* Test if counter module found */
2197 /********************************/
2199 if ((devpriv->s_BoardInfos.
2200 dw_MolduleConfiguration[0] & 0xFFFF0000UL) ==
2201 APCI1710_INCREMENTAL_COUNTER
2202 || (devpriv->s_BoardInfos.
2203 dw_MolduleConfiguration[1] & 0xFFFF0000UL) ==
2204 APCI1710_INCREMENTAL_COUNTER
2205 || (devpriv->s_BoardInfos.
2206 dw_MolduleConfiguration[2] & 0xFFFF0000UL) ==
2207 APCI1710_INCREMENTAL_COUNTER
2208 || (devpriv->s_BoardInfos.
2209 dw_MolduleConfiguration[3] & 0xFFFF0000UL) ==
2210 APCI1710_INCREMENTAL_COUNTER) {
2211 for (b_ModulCpt = 0; b_ModulCpt < 4; b_ModulCpt++) {
2212 /*******************************/
2213 /* Test if incremental counter */
2214 /*******************************/
2216 if ((devpriv->s_BoardInfos.
2217 dw_MolduleConfiguration[b_ModulCpt] &
2219 APCI1710_INCREMENTAL_COUNTER) {
2220 /*********************/
2221 /* Clear the counter */
2222 /*********************/
2224 outl(1, devpriv->s_BoardInfos.
2225 ui_Address + 16 + (64 * b_ModulCpt));
2229 /***************************/
2230 /* No counter module found */
2231 /***************************/
2233 DPRINTK("No counter module found\n");
2237 return i_ReturnValue;
2241 +----------------------------------------------------------------------------+
2242 | Function Name : _INT_ i_APCI1710_SetInputFilter |
2243 | (unsigned char_ b_BoardHandle, |
2244 | unsigned char_ b_Module, |
2245 | unsigned char_ b_PCIInputClock, |
2246 | unsigned char_ b_Filter) |
2247 +----------------------------------------------------------------------------+
2248 | Task : Disable or enable the software filter from selected |
2249 | module (b_ModulNbr). b_Filter determine the filter time|
2250 +----------------------------------------------------------------------------+
2251 | Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
2252 | unsigned char_ b_ModulNbr : Number of the module to be |
2253 | configured (0 to 3) |
2254 | unsigned char_ b_PCIInputClock : Selection of the PCI bus |
2256 | - APCI1710_30MHZ : |
2257 | The PC has a PCI bus clock |
2259 | - APCI1710_33MHZ : |
2260 | The PC has a PCI bus clock |
2262 | - APCI1710_40MHZ : |
2263 | The APCI1710 has a 40MHz |
2265 | unsigned char_ b_Filter : Filter selection |
2269 | 0: Software filter not used |
2270 | 1: Filter from 266ns (3.750000MHz) |
2271 | 2: Filter from 400ns (2.500000MHz) |
2272 | 3: Filter from 533ns (1.876170MHz) |
2273 | 4: Filter from 666ns (1.501501MHz) |
2274 | 5: Filter from 800ns (1.250000MHz) |
2275 | 6: Filter from 933ns (1.071800MHz) |
2276 | 7: Filter from 1066ns (0.938080MHz) |
2277 | 8: Filter from 1200ns (0.833333MHz) |
2278 | 9: Filter from 1333ns (0.750000MHz) |
2279 | 10: Filter from 1466ns (0.682100MHz) |
2280 | 11: Filter from 1600ns (0.625000MHz) |
2281 | 12: Filter from 1733ns (0.577777MHz) |
2282 | 13: Filter from 1866ns (0.535900MHz) |
2283 | 14: Filter from 2000ns (0.500000MHz) |
2284 | 15: Filter from 2133ns (0.468800MHz) |
2288 | 0: Software filter not used |
2289 | 1: Filter from 242ns (4.125000MHz) |
2290 | 2: Filter from 363ns (2.754820MHz) |
2291 | 3: Filter from 484ns (2.066115MHz) |
2292 | 4: Filter from 605ns (1.652892MHz) |
2293 | 5: Filter from 726ns (1.357741MHz) |
2294 | 6: Filter from 847ns (1.180637MHz) |
2295 | 7: Filter from 968ns (1.033055MHz) |
2296 | 8: Filter from 1089ns (0.918273MHz) |
2297 | 9: Filter from 1210ns (0.826446MHz) |
2298 | 10: Filter from 1331ns (0.751314MHz) |
2299 | 11: Filter from 1452ns (0.688705MHz) |
2300 | 12: Filter from 1573ns (0.635727MHz) |
2301 | 13: Filter from 1694ns (0.590318MHz) |
2302 | 14: Filter from 1815ns (0.550964MHz) |
2303 | 15: Filter from 1936ns (0.516528MHz) |
2307 | 0: Software filter not used |
2308 | 1: Filter from 200ns (5.000000MHz) |
2309 | 2: Filter from 300ns (3.333333MHz) |
2310 | 3: Filter from 400ns (2.500000MHz) |
2311 | 4: Filter from 500ns (2.000000MHz) |
2312 | 5: Filter from 600ns (1.666666MHz) |
2313 | 6: Filter from 700ns (1.428500MHz) |
2314 | 7: Filter from 800ns (1.250000MHz) |
2315 | 8: Filter from 900ns (1.111111MHz) |
2316 | 9: Filter from 1000ns (1.000000MHz) |
2317 | 10: Filter from 1100ns (0.909090MHz) |
2318 | 11: Filter from 1200ns (0.833333MHz) |
2319 | 12: Filter from 1300ns (0.769200MHz) |
2320 | 13: Filter from 1400ns (0.714200MHz) |
2321 | 14: Filter from 1500ns (0.666666MHz) |
2322 | 15: Filter from 1600ns (0.625000MHz) |
2323 +----------------------------------------------------------------------------+
2324 | Output Parameters : - |
2325 +----------------------------------------------------------------------------+
2326 | Return Value : 0: No error |
2327 | -1: The handle parameter of the board is wrong |
2328 | -2: The selected module number is wrong |
2329 | -3: The module is not a counter module |
2330 | -4: The selected PCI input clock is wrong |
2331 | -5: The selected filter value is wrong |
2332 | -6: 40MHz quartz not on board |
2333 +----------------------------------------------------------------------------+
2335 static int i_APCI1710_SetInputFilter(struct comedi_device *dev,
2336 unsigned char b_ModulNbr,
2337 unsigned char b_PCIInputClock,
2338 unsigned char b_Filter)
2340 struct addi_private *devpriv = dev->private;
2341 int i_ReturnValue = 0;
2342 unsigned int dw_Status = 0;
2344 /**************************/
2345 /* Test the module number */
2346 /**************************/
2348 if (b_ModulNbr < 4) {
2349 /*******************************/
2350 /* Test if incremental counter */
2351 /*******************************/
2353 if ((devpriv->s_BoardInfos.
2354 dw_MolduleConfiguration[b_ModulNbr] &
2355 0xFFFF0000UL) == APCI1710_INCREMENTAL_COUNTER) {
2356 /******************************/
2357 /* Test if firmware >= Rev1.5 */
2358 /******************************/
2360 if ((devpriv->s_BoardInfos.
2361 dw_MolduleConfiguration[b_ModulNbr] &
2362 0xFFFF) >= 0x3135) {
2363 /**************************/
2364 /* Test the PCI bus clock */
2365 /**************************/
2367 if ((b_PCIInputClock == APCI1710_30MHZ) ||
2368 (b_PCIInputClock == APCI1710_33MHZ) ||
2369 (b_PCIInputClock == APCI1710_40MHZ)) {
2370 /*************************/
2371 /* Test the filter value */
2372 /*************************/
2374 if (b_Filter < 16) {
2375 /**********************/
2376 /* Test if 40MHz used */
2377 /**********************/
2379 if (b_PCIInputClock ==
2381 /*********************************/
2382 /* Test if 40MHz quartz on board */
2383 /*********************************/
2392 /******************************/
2393 /* Test the quartz flag (DQ0) */
2394 /******************************/
2396 if ((dw_Status & 1) !=
2398 /*****************************/
2399 /* 40MHz quartz not on board */
2400 /*****************************/
2402 DPRINTK("40MHz quartz not on board\n");
2406 } /* if (b_PCIInputClock == APCI1710_40MHZ) */
2408 /***************************/
2409 /* Test if error not occur */
2410 /***************************/
2412 if (i_ReturnValue == 0) {
2413 /**********************/
2414 /* Test if 40MHz used */
2415 /**********************/
2417 if (b_PCIInputClock ==
2420 /*********************************/
2421 /* Enable the 40MHz quarz (DQ31) */
2422 /*********************************/
2427 s_SiemensCounterInfo.
2435 s_SiemensCounterInfo.
2440 APCI1710_ENABLE_40MHZ_FILTER;
2442 } /* if (b_PCIInputClock == APCI1710_40MHZ) */
2444 /**********************************/
2445 /* Disable the 40MHz quarz (DQ31) */
2446 /**********************************/
2451 s_SiemensCounterInfo.
2459 s_SiemensCounterInfo.
2464 APCI1710_DISABLE_40MHZ_FILTER;
2466 } /* if (b_PCIInputClock == APCI1710_40MHZ) */
2468 /************************/
2469 /* Set the filter value */
2470 /************************/
2475 s_SiemensCounterInfo.
2483 s_SiemensCounterInfo.
2495 s_SiemensCounterInfo.
2503 s_SiemensCounterInfo.
2512 /***************************/
2513 /* Write the configuration */
2514 /***************************/
2519 s_SiemensCounterInfo.
2521 dw_ModeRegister1_2_3_4,
2527 } /* if (i_ReturnValue == 0) */
2528 } /* if (b_Filter < 16) */
2530 /**************************************/
2531 /* The selected filter value is wrong */
2532 /**************************************/
2534 DPRINTK("The selected filter value is wrong\n");
2536 } /* if (b_Filter < 16) */
2537 } /* if ((b_PCIInputClock == APCI1710_30MHZ) || (b_PCIInputClock == APCI1710_33MHZ) || (b_PCIInputClock == APCI1710_40MHZ)) */
2539 /*****************************************/
2540 /* The selected PCI input clock is wrong */
2541 /*****************************************/
2543 DPRINTK("The selected PCI input clock is wrong\n");
2545 } /* if ((b_PCIInputClock == APCI1710_30MHZ) || (b_PCIInputClock == APCI1710_33MHZ) || (b_PCIInputClock == APCI1710_40MHZ)) */
2547 /**************************************/
2548 /* The module is not a counter module */
2549 /**************************************/
2551 DPRINTK("The module is not a counter module\n");
2555 /**************************************/
2556 /* The module is not a counter module */
2557 /**************************************/
2559 DPRINTK("The module is not a counter module\n");
2563 /*************************************************/
2564 /* The selected module number parameter is wrong */
2565 /*************************************************/
2567 DPRINTK("The selected module number parameter is wrong\n");
2571 return i_ReturnValue;
2575 +----------------------------------------------------------------------------+
2576 | Function Name : _INT_ i_APCI1710_LatchCounter (unsigned char_ b_BoardHandle, |
2577 | unsigned char_ b_ModulNbr, |
2578 | unsigned char_ b_LatchReg) |
2579 +----------------------------------------------------------------------------+
2580 | Task : Latch the courant value from selected module |
2581 | (b_ModulNbr) in to the selected latch register |
2583 +----------------------------------------------------------------------------+
2584 | Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
2585 | unsigned char_ b_ModulNbr : Module number to configure |
2587 | unsigned char_ b_LatchReg : Selected latch register |
2588 | 0 : for the first latch register |
2589 | 1 : for the second latch register |
2590 +----------------------------------------------------------------------------+
2591 | Output Parameters : - |
2592 +----------------------------------------------------------------------------+
2593 | Return Value : 0: No error |
2594 | -1: The handle parameter of the board is wrong |
2595 | -2: No counter module found |
2596 | -3: Counter not initialised see function |
2597 | "i_APCI1710_InitCounter" |
2598 | -4: The selected latch register parameter is wrong |
2599 +----------------------------------------------------------------------------+
2601 static int i_APCI1710_LatchCounter(struct comedi_device *dev,
2602 unsigned char b_ModulNbr,
2603 unsigned char b_LatchReg)
2605 struct addi_private *devpriv = dev->private;
2606 int i_ReturnValue = 0;
2608 /**************************/
2609 /* Test the module number */
2610 /**************************/
2612 if (b_ModulNbr < 4) {
2613 /*******************************/
2614 /* Test if counter initialised */
2615 /*******************************/
2618 s_ModuleInfo[b_ModulNbr].
2619 s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) {
2620 /*************************************/
2621 /* Test the latch register parameter */
2622 /*************************************/
2624 if (b_LatchReg < 2) {
2625 /*********************/
2626 /* Tatch the counter */
2627 /*********************/
2629 outl(1 << (b_LatchReg * 4),
2630 devpriv->s_BoardInfos.ui_Address +
2633 /**************************************************/
2634 /* The selected latch register parameter is wrong */
2635 /**************************************************/
2637 DPRINTK("The selected latch register parameter is wrong\n");
2641 /****************************************/
2642 /* Counter not initialised see function */
2643 /* "i_APCI1710_InitCounter" */
2644 /****************************************/
2646 DPRINTK("Counter not initialised\n");
2650 /*************************************************/
2651 /* The selected module number parameter is wrong */
2652 /*************************************************/
2654 DPRINTK("The selected module number parameter is wrong\n");
2658 return i_ReturnValue;
2662 +----------------------------------------------------------------------------+
2663 | Function Name : _INT_ i_APCI1710_SetIndexAndReferenceSource |
2664 | (unsigned char_ b_BoardHandle, |
2665 | unsigned char_ b_ModulNbr, |
2666 | unsigned char_ b_SourceSelection) |
2667 +----------------------------------------------------------------------------+
2668 | Task : Determine the hardware source for the index and the |
2669 | reference logic. Per default the index logic is |
2670 | connected to the difference input C and the reference |
2671 | logic is connected to the 24V input E |
2672 +----------------------------------------------------------------------------+
2673 | Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
2674 | unsigned char_ b_ModulNbr : Module number to configure |
2676 | unsigned char_ b_SourceSelection : APCI1710_SOURCE_0 : |
2677 | The index logic is connected |
2678 | to the difference input C and|
2679 | the reference logic is |
2680 | connected to the 24V input E.|
2681 | This is the default |
2683 | APCI1710_SOURCE_1 : |
2684 | The reference logic is |
2685 | connected to the difference |
2686 | input C and the index logic |
2687 | is connected to the 24V |
2689 +----------------------------------------------------------------------------+
2690 | Output Parameters : - |
2691 +----------------------------------------------------------------------------+
2692 | Return Value : 0: No error |
2693 | -1: The handle parameter of the board is wrong |
2694 | -2: The selected module number is wrong |
2695 | -3: The module is not a counter module. |
2696 | -4: The source selection is wrong |
2697 +----------------------------------------------------------------------------+
2699 static int i_APCI1710_SetIndexAndReferenceSource(struct comedi_device *dev,
2700 unsigned char b_ModulNbr,
2701 unsigned char b_SourceSelection)
2703 struct addi_private *devpriv = dev->private;
2704 int i_ReturnValue = 0;
2706 /**************************/
2707 /* Test the module number */
2708 /**************************/
2710 if (b_ModulNbr < 4) {
2711 /*******************************/
2712 /* Test if incremental counter */
2713 /*******************************/
2715 if ((devpriv->s_BoardInfos.
2716 dw_MolduleConfiguration[b_ModulNbr] &
2717 0xFFFF0000UL) == APCI1710_INCREMENTAL_COUNTER) {
2718 /******************************/
2719 /* Test if firmware >= Rev1.5 */
2720 /******************************/
2722 if ((devpriv->s_BoardInfos.
2723 dw_MolduleConfiguration[b_ModulNbr] &
2724 0xFFFF) >= 0x3135) {
2725 /*****************************/
2726 /* Test the source selection */
2727 /*****************************/
2729 if (b_SourceSelection == APCI1710_SOURCE_0 ||
2730 b_SourceSelection == APCI1710_SOURCE_1)
2732 /******************************************/
2733 /* Test if invert the index and reference */
2734 /******************************************/
2736 if (b_SourceSelection ==
2737 APCI1710_SOURCE_1) {
2738 /********************************************/
2739 /* Invert index and reference source (DQ25) */
2740 /********************************************/
2745 s_SiemensCounterInfo.
2752 s_SiemensCounterInfo.
2756 APCI1710_INVERT_INDEX_RFERENCE;
2758 /****************************************/
2759 /* Set the default configuration (DQ25) */
2760 /****************************************/
2765 s_SiemensCounterInfo.
2772 s_SiemensCounterInfo.
2776 APCI1710_DEFAULT_INDEX_RFERENCE;
2778 } /* if (b_SourceSelection == APCI1710_SOURCE_0 ||b_SourceSelection == APCI1710_SOURCE_1) */
2780 /*********************************/
2781 /* The source selection is wrong */
2782 /*********************************/
2784 DPRINTK("The source selection is wrong\n");
2786 } /* if (b_SourceSelection == APCI1710_SOURCE_0 ||b_SourceSelection == APCI1710_SOURCE_1) */
2788 /**************************************/
2789 /* The module is not a counter module */
2790 /**************************************/
2792 DPRINTK("The module is not a counter module\n");
2796 /**************************************/
2797 /* The module is not a counter module */
2798 /**************************************/
2800 DPRINTK("The module is not a counter module\n");
2804 /***************************************/
2805 /* The selected module number is wrong */
2806 /***************************************/
2808 DPRINTK("The selected module number is wrong\n");
2812 return i_ReturnValue;
2816 +----------------------------------------------------------------------------+
2817 | Function Name : _INT_ i_APCI1710_SetDigitalChlOn |
2818 | (unsigned char_ b_BoardHandle, |
2819 | unsigned char_ b_ModulNbr) |
2820 +----------------------------------------------------------------------------+
2821 | Task : Sets the digital output H Setting an output means |
2822 | setting an ouput high. |
2823 +----------------------------------------------------------------------------+
2824 | Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
2825 | unsigned char_ b_ModulNbr : Number of the module to be |
2826 | configured (0 to 3) |
2827 +----------------------------------------------------------------------------+
2828 | Output Parameters : - |
2829 +----------------------------------------------------------------------------+
2830 | Return Value : 0: No error |
2831 | -1: The handle parameter of the board is wrong |
2832 | -2: The selected module number is wrong |
2833 | -3: Counter not initialised see function |
2834 | "i_APCI1710_InitCounter" |
2835 +----------------------------------------------------------------------------+
2837 static int i_APCI1710_SetDigitalChlOn(struct comedi_device *dev,
2838 unsigned char b_ModulNbr)
2840 struct addi_private *devpriv = dev->private;
2841 int i_ReturnValue = 0;
2843 /**************************/
2844 /* Test the module number */
2845 /**************************/
2847 if (b_ModulNbr < 4) {
2848 /*******************************/
2849 /* Test if counter initialised */
2850 /*******************************/
2853 s_ModuleInfo[b_ModulNbr].
2854 s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) {
2856 s_ModuleInfo[b_ModulNbr].
2857 s_SiemensCounterInfo.
2860 b_ModeRegister3 = devpriv->
2861 s_ModuleInfo[b_ModulNbr].
2862 s_SiemensCounterInfo.
2864 s_ByteModeRegister.b_ModeRegister3 | 0x10;
2866 /*********************/
2867 /* Set the output On */
2868 /*********************/
2870 outl(devpriv->s_ModuleInfo[b_ModulNbr].
2871 s_SiemensCounterInfo.
2873 dw_ModeRegister1_2_3_4, devpriv->s_BoardInfos.
2874 ui_Address + 20 + (64 * b_ModulNbr));
2876 /****************************************/
2877 /* Counter not initialised see function */
2878 /* "i_APCI1710_InitCounter" */
2879 /****************************************/
2881 DPRINTK("Counter not initialised\n");
2885 /*************************************************/
2886 /* The selected module number parameter is wrong */
2887 /*************************************************/
2889 DPRINTK("The selected module number parameter is wrong\n");
2893 return i_ReturnValue;
2897 +----------------------------------------------------------------------------+
2898 | Function Name : _INT_ i_APCI1710_SetDigitalChlOff |
2899 | (unsigned char_ b_BoardHandle, |
2900 | unsigned char_ b_ModulNbr) |
2901 +----------------------------------------------------------------------------+
2902 | Task : Resets the digital output H. Resetting an output means |
2903 | setting an ouput low. |
2904 +----------------------------------------------------------------------------+
2905 | Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
2906 | unsigned char_ b_ModulNbr : Number of the module to be |
2907 | configured (0 to 3) |
2908 +----------------------------------------------------------------------------+
2909 | Output Parameters : - |
2910 +----------------------------------------------------------------------------+
2911 | Return Value : 0: No error |
2912 | -1: The handle parameter of the board is wrong |
2913 | -2: The selected module number is wrong |
2914 | -3: Counter not initialised see function |
2915 | "i_APCI1710_InitCounter" |
2916 +----------------------------------------------------------------------------+
2918 static int i_APCI1710_SetDigitalChlOff(struct comedi_device *dev,
2919 unsigned char b_ModulNbr)
2921 struct addi_private *devpriv = dev->private;
2922 int i_ReturnValue = 0;
2924 /**************************/
2925 /* Test the module number */
2926 /**************************/
2928 if (b_ModulNbr < 4) {
2929 /*******************************/
2930 /* Test if counter initialised */
2931 /*******************************/
2934 s_ModuleInfo[b_ModulNbr].
2935 s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) {
2937 s_ModuleInfo[b_ModulNbr].
2938 s_SiemensCounterInfo.
2941 b_ModeRegister3 = devpriv->
2942 s_ModuleInfo[b_ModulNbr].
2943 s_SiemensCounterInfo.
2945 s_ByteModeRegister.b_ModeRegister3 & 0xEF;
2947 /**********************/
2948 /* Set the output Off */
2949 /**********************/
2951 outl(devpriv->s_ModuleInfo[b_ModulNbr].
2952 s_SiemensCounterInfo.
2954 dw_ModeRegister1_2_3_4, devpriv->s_BoardInfos.
2955 ui_Address + 20 + (64 * b_ModulNbr));
2957 /****************************************/
2958 /* Counter not initialised see function */
2959 /* "i_APCI1710_InitCounter" */
2960 /****************************************/
2962 DPRINTK("Counter not initialised\n");
2966 /*************************************************/
2967 /* The selected module number parameter is wrong */
2968 /*************************************************/
2970 DPRINTK("The selected module number parameter is wrong\n");
2974 return i_ReturnValue;
2978 * Set & Clear Functions for INC_CPT
2980 static int i_APCI1710_InsnBitsINCCPT(struct comedi_device *dev,
2981 struct comedi_subdevice *s,
2982 struct comedi_insn *insn,
2985 struct addi_private *devpriv = dev->private;
2986 unsigned int ui_BitsType;
2987 int i_ReturnValue = 0;
2989 ui_BitsType = CR_CHAN(insn->chanspec);
2990 devpriv->tsk_Current = current; /* Save the current process task structure */
2992 switch (ui_BitsType) {
2993 case APCI1710_INCCPT_CLEARCOUNTERVALUE:
2994 i_ReturnValue = i_APCI1710_ClearCounterValue(dev,
2995 (unsigned char) CR_AREF(insn->chanspec));
2998 case APCI1710_INCCPT_CLEARALLCOUNTERVALUE:
2999 i_ReturnValue = i_APCI1710_ClearAllCounterValue(dev);
3002 case APCI1710_INCCPT_SETINPUTFILTER:
3003 i_ReturnValue = i_APCI1710_SetInputFilter(dev,
3004 (unsigned char) CR_AREF(insn->chanspec),
3005 (unsigned char) data[0], (unsigned char) data[1]);
3008 case APCI1710_INCCPT_LATCHCOUNTER:
3009 i_ReturnValue = i_APCI1710_LatchCounter(dev,
3010 (unsigned char) CR_AREF(insn->chanspec), (unsigned char) data[0]);
3013 case APCI1710_INCCPT_SETINDEXANDREFERENCESOURCE:
3014 i_ReturnValue = i_APCI1710_SetIndexAndReferenceSource(dev,
3015 (unsigned char) CR_AREF(insn->chanspec), (unsigned char) data[0]);
3018 case APCI1710_INCCPT_SETDIGITALCHLON:
3019 i_ReturnValue = i_APCI1710_SetDigitalChlOn(dev,
3020 (unsigned char) CR_AREF(insn->chanspec));
3023 case APCI1710_INCCPT_SETDIGITALCHLOFF:
3024 i_ReturnValue = i_APCI1710_SetDigitalChlOff(dev,
3025 (unsigned char) CR_AREF(insn->chanspec));
3029 printk("Bits Config Parameter Wrong\n");
3032 if (i_ReturnValue >= 0)
3033 i_ReturnValue = insn->n;
3034 return i_ReturnValue;
3038 +----------------------------------------------------------------------------+
3039 | Function Name : _INT_ i_APCI1710_EnableLatchInterrupt |
3040 | (unsigned char_ b_BoardHandle, |
3041 | unsigned char_ b_ModulNbr) |
3042 +----------------------------------------------------------------------------+
3043 | Task : Enable the latch interrupt from selected module |
3044 | (b_ModulNbr). Each software or hardware latch occur a |
3046 +----------------------------------------------------------------------------+
3047 | Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
3048 | unsigned char_ b_ModulNbr : Module number to configure |
3050 +----------------------------------------------------------------------------+
3051 | Output Parameters : - |
3052 +----------------------------------------------------------------------------+
3053 | Return Value : 0: No error |
3054 | -1: The handle parameter of the board is wrong |
3055 | -2: No counter module found |
3056 | -3: Counter not initialised see function |
3057 | "i_APCI1710_InitCounter" |
3058 | -4: Interrupt routine not installed see function |
3059 | "i_APCI1710_SetBoardIntRoutine" |
3060 +----------------------------------------------------------------------------+
3062 static int i_APCI1710_EnableLatchInterrupt(struct comedi_device *dev,
3063 unsigned char b_ModulNbr)
3065 struct addi_private *devpriv = dev->private;
3066 int i_ReturnValue = 0;
3068 /**************************/
3069 /* Test the module number */
3070 /**************************/
3072 if (b_ModulNbr < 4) {
3073 /*******************************/
3074 /* Test if counter initialised */
3075 /*******************************/
3077 if (devpriv->s_ModuleInfo[b_ModulNbr].
3078 s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) {
3080 /********************/
3081 /* Enable interrupt */
3082 /********************/
3084 devpriv->s_ModuleInfo[b_ModulNbr].
3085 s_SiemensCounterInfo.
3088 b_ModeRegister2 = devpriv->
3089 s_ModuleInfo[b_ModulNbr].
3090 s_SiemensCounterInfo.
3093 b_ModeRegister2 | APCI1710_ENABLE_LATCH_INT;
3095 /***************************/
3096 /* Write the configuration */
3097 /***************************/
3099 outl(devpriv->s_ModuleInfo[b_ModulNbr].
3100 s_SiemensCounterInfo.
3102 dw_ModeRegister1_2_3_4, devpriv->s_BoardInfos.
3103 ui_Address + 20 + (64 * b_ModulNbr));
3105 /****************************************/
3106 /* Counter not initialised see function */
3107 /* "i_APCI1710_InitCounter" */
3108 /****************************************/
3110 DPRINTK("Counter not initialised\n");
3114 /*************************************************/
3115 /* The selected module number parameter is wrong */
3116 /*************************************************/
3118 DPRINTK("The selected module number parameter is wrong\n");
3122 return i_ReturnValue;
3126 +----------------------------------------------------------------------------+
3127 | Function Name : _INT_ i_APCI1710_DisableLatchInterrupt |
3128 | (unsigned char_ b_BoardHandle, |
3129 | unsigned char_ b_ModulNbr) |
3130 +----------------------------------------------------------------------------+
3131 | Task : Disable the latch interrupt from selected module |
3133 +----------------------------------------------------------------------------+
3134 | Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
3135 | unsigned char_ b_ModulNbr : Module number to configure |
3137 +----------------------------------------------------------------------------+
3138 | Output Parameters : - |
3139 +----------------------------------------------------------------------------+
3140 | Return Value : 0: No error |
3141 | -1: The handle parameter of the board is wrong |
3142 | -2: No counter module found |
3143 | -3: Counter not initialised see function |
3144 | "i_APCI1710_InitCounter" |
3145 | -4: Interrupt routine not installed see function |
3146 | "i_APCI1710_SetBoardIntRoutine" |
3147 +----------------------------------------------------------------------------+
3149 static int i_APCI1710_DisableLatchInterrupt(struct comedi_device *dev,
3150 unsigned char b_ModulNbr)
3152 struct addi_private *devpriv = dev->private;
3153 int i_ReturnValue = 0;
3155 /**************************/
3156 /* Test the module number */
3157 /**************************/
3159 if (b_ModulNbr < 4) {
3160 /*******************************/
3161 /* Test if counter initialised */
3162 /*******************************/
3165 s_ModuleInfo[b_ModulNbr].
3166 s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) {
3168 /***************************/
3169 /* Write the configuration */
3170 /***************************/
3172 outl(devpriv->s_ModuleInfo[b_ModulNbr].
3173 s_SiemensCounterInfo.
3175 dw_ModeRegister1_2_3_4 &
3176 ((APCI1710_DISABLE_LATCH_INT << 8) | 0xFF),
3177 devpriv->s_BoardInfos.ui_Address + 20 +
3182 /*********************/
3183 /* Disable interrupt */
3184 /*********************/
3187 s_ModuleInfo[b_ModulNbr].
3188 s_SiemensCounterInfo.
3191 b_ModeRegister2 = devpriv->
3192 s_ModuleInfo[b_ModulNbr].
3193 s_SiemensCounterInfo.
3196 b_ModeRegister2 & APCI1710_DISABLE_LATCH_INT;
3199 /****************************************/
3200 /* Counter not initialised see function */
3201 /* "i_APCI1710_InitCounter" */
3202 /****************************************/
3204 DPRINTK("Counter not initialised\n");
3208 /*************************************************/
3209 /* The selected module number parameter is wrong */
3210 /*************************************************/
3212 DPRINTK("The selected module number parameter is wrong\n");
3216 return i_ReturnValue;
3220 +----------------------------------------------------------------------------+
3221 | Function Name : _INT_ i_APCI1710_Write16BitCounterValue |
3222 | (unsigned char_ b_BoardHandle |
3223 | unsigned char_ b_ModulNbr, |
3224 | unsigned char_ b_SelectedCounter, |
3225 | unsigned int_ ui_WriteValue) |
3226 +----------------------------------------------------------------------------+
3227 | Task : Write a 16-Bit value (ui_WriteValue) in to the selected|
3228 | 16-Bit counter (b_SelectedCounter) from selected module|
3230 +----------------------------------------------------------------------------+
3231 | Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
3232 | unsigned char_ b_ModulNbr : Module number to configure |
3234 | unsigned char_ b_SelectedCounter : Selected 16-Bit counter |
3236 | unsigned int_ ui_WriteValue : 16-Bit write value |
3237 +----------------------------------------------------------------------------+
3238 | Output Parameters : - |
3239 +----------------------------------------------------------------------------+
3240 | Return Value : 0: No error |
3241 | -1: The handle parameter of the board is wrong |
3242 | -2: No counter module found |
3243 | -3: Counter not initialised see function |
3244 | "i_APCI1710_InitCounter" |
3245 | -4: The selected 16-Bit counter parameter is wrong |
3246 +----------------------------------------------------------------------------+
3248 static int i_APCI1710_Write16BitCounterValue(struct comedi_device *dev,
3249 unsigned char b_ModulNbr,
3250 unsigned char b_SelectedCounter,
3251 unsigned int ui_WriteValue)
3253 struct addi_private *devpriv = dev->private;
3254 int i_ReturnValue = 0;
3256 /**************************/
3257 /* Test the module number */
3258 /**************************/
3260 if (b_ModulNbr < 4) {
3261 /*******************************/
3262 /* Test if counter initialised */
3263 /*******************************/
3266 s_ModuleInfo[b_ModulNbr].
3267 s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) {
3268 /******************************/
3269 /* Test the counter selection */
3270 /******************************/
3272 if (b_SelectedCounter < 2) {
3273 /*******************/
3274 /* Write the value */
3275 /*******************/
3277 outl((unsigned int) ((unsigned int) (ui_WriteValue) << (16 *
3278 b_SelectedCounter)),
3279 devpriv->s_BoardInfos.ui_Address + 8 +
3280 (b_SelectedCounter * 4) +
3283 /**************************************************/
3284 /* The selected 16-Bit counter parameter is wrong */
3285 /**************************************************/
3287 DPRINTK("The selected 16-Bit counter parameter is wrong\n");
3291 /****************************************/
3292 /* Counter not initialised see function */
3293 /* "i_APCI1710_InitCounter" */
3294 /****************************************/
3296 DPRINTK("Counter not initialised\n");
3300 /*************************************************/
3301 /* The selected module number parameter is wrong */
3302 /*************************************************/
3304 DPRINTK("The selected module number parameter is wrong\n");
3308 return i_ReturnValue;
3312 +----------------------------------------------------------------------------+
3313 | Function Name : _INT_ i_APCI1710_Write32BitCounterValue |
3314 | (unsigned char_ b_BoardHandle |
3315 | unsigned char_ b_ModulNbr, |
3316 | ULONG_ ul_WriteValue) |
3317 +----------------------------------------------------------------------------+
3318 | Task : Write a 32-Bit value (ui_WriteValue) in to the selected|
3319 | module (b_ModulNbr). |
3320 +----------------------------------------------------------------------------+
3321 | Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
3322 | unsigned char_ b_ModulNbr : Module number to configure |
3324 | ULONG_ ul_WriteValue : 32-Bit write value |
3325 +----------------------------------------------------------------------------+
3326 | Output Parameters : - |
3327 +----------------------------------------------------------------------------+
3328 | Return Value : 0: No error |
3329 | -1: The handle parameter of the board is wrong |
3330 | -2: No counter module found |
3331 | -3: Counter not initialised see function |
3332 | "i_APCI1710_InitCounter" |
3333 +----------------------------------------------------------------------------+
3335 static int i_APCI1710_Write32BitCounterValue(struct comedi_device *dev,
3336 unsigned char b_ModulNbr,
3337 unsigned int ul_WriteValue)
3339 struct addi_private *devpriv = dev->private;
3340 int i_ReturnValue = 0;
3342 /**************************/
3343 /* Test the module number */
3344 /**************************/
3346 if (b_ModulNbr < 4) {
3347 /*******************************/
3348 /* Test if counter initialised */
3349 /*******************************/
3352 s_ModuleInfo[b_ModulNbr].
3353 s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) {
3354 /*******************/
3355 /* Write the value */
3356 /*******************/
3358 outl(ul_WriteValue, devpriv->s_BoardInfos.
3359 ui_Address + 4 + (64 * b_ModulNbr));
3361 /****************************************/
3362 /* Counter not initialised see function */
3363 /* "i_APCI1710_InitCounter" */
3364 /****************************************/
3366 DPRINTK("Counter not initialised\n");
3370 /*************************************************/
3371 /* The selected module number parameter is wrong */
3372 /*************************************************/
3374 DPRINTK("The selected module number parameter is wrong\n");
3378 return i_ReturnValue;
3382 +----------------------------------------------------------------------------+
3383 | Function Name : _INT_ i_APCI1710_EnableIndex (unsigned char_ b_BoardHandle, |
3384 | unsigned char_ b_ModulNbr) |
3385 +----------------------------------------------------------------------------+
3386 | Task : Enable the INDEX actions |
3387 +----------------------------------------------------------------------------+
3388 | Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
3389 | unsigned char_ b_ModulNbr : Module number to configure |
3391 +----------------------------------------------------------------------------+
3392 | Output Parameters : - |
3393 +----------------------------------------------------------------------------+
3394 | Return Value : 0: No error |
3395 | -1: The handle parameter of the board is wrong |
3396 | -2: No counter module found |
3397 | -3: Counter not initialised see function |
3398 | "i_APCI1710_InitCounter" |
3399 | -4: Index not initialised see function |
3400 | "i_APCI1710_InitIndex" |
3401 +----------------------------------------------------------------------------+
3403 static int i_APCI1710_EnableIndex(struct comedi_device *dev,
3404 unsigned char b_ModulNbr)
3406 struct addi_private *devpriv = dev->private;
3407 int i_ReturnValue = 0;
3408 unsigned int ul_InterruptLatchReg;
3410 /**************************/
3411 /* Test the module number */
3412 /**************************/
3414 if (b_ModulNbr < 4) {
3415 /*******************************/
3416 /* Test if counter initialised */
3417 /*******************************/
3420 s_ModuleInfo[b_ModulNbr].
3421 s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) {
3422 /*****************************/
3423 /* Test if index initialised */
3424 /*****************************/
3427 s_ModuleInfo[b_ModulNbr].
3428 s_SiemensCounterInfo.s_InitFlag.b_IndexInit) {
3430 s_ModuleInfo[b_ModulNbr].
3431 s_SiemensCounterInfo.
3434 b_ModeRegister2 = devpriv->
3435 s_ModuleInfo[b_ModulNbr].
3436 s_SiemensCounterInfo.
3439 b_ModeRegister2 | APCI1710_ENABLE_INDEX;
3441 ul_InterruptLatchReg =
3442 inl(devpriv->s_BoardInfos.ui_Address +
3443 24 + (64 * b_ModulNbr));
3445 outl(devpriv->s_ModuleInfo[b_ModulNbr].
3446 s_SiemensCounterInfo.
3448 dw_ModeRegister1_2_3_4,
3449 devpriv->s_BoardInfos.ui_Address + 20 +
3452 /*************************************************************/
3453 /* Index not initialised see function "i_APCI1710_InitIndex" */
3454 /*************************************************************/
3456 DPRINTK("Index not initialised \n");
3460 /****************************************/
3461 /* Counter not initialised see function */
3462 /* "i_APCI1710_InitCounter" */
3463 /****************************************/
3465 DPRINTK("Counter not initialised\n");
3469 /*************************************************/
3470 /* The selected module number parameter is wrong */
3471 /*************************************************/
3473 DPRINTK("The selected module number parameter is wrong\n");
3477 return i_ReturnValue;
3481 +----------------------------------------------------------------------------+
3482 | Function Name : _INT_ i_APCI1710_DisableIndex (unsigned char_ b_BoardHandle, |
3483 | unsigned char_ b_ModulNbr) |
3484 +----------------------------------------------------------------------------+
3485 | Task : Disable the INDEX actions |
3486 +----------------------------------------------------------------------------+
3487 | Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
3488 | unsigned char_ b_ModulNbr : Module number to configure |
3490 +----------------------------------------------------------------------------+
3491 | Output Parameters : - |
3492 +----------------------------------------------------------------------------+
3493 | Return Value : 0: No error |
3494 | -1: The handle parameter of the board is wrong |
3495 | -2: No counter module found |
3496 | -3: Counter not initialised see function |
3497 | "i_APCI1710_InitCounter" |
3498 | -4: Index not initialised see function |
3499 | "i_APCI1710_InitIndex" |
3500 +----------------------------------------------------------------------------+
3502 static int i_APCI1710_DisableIndex(struct comedi_device *dev,
3503 unsigned char b_ModulNbr)
3505 struct addi_private *devpriv = dev->private;
3506 int i_ReturnValue = 0;
3508 /**************************/
3509 /* Test the module number */
3510 /**************************/
3512 if (b_ModulNbr < 4) {
3513 /*******************************/
3514 /* Test if counter initialised */
3515 /*******************************/
3518 s_ModuleInfo[b_ModulNbr].
3519 s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) {
3520 /*****************************/
3521 /* Test if index initialised */
3522 /*****************************/
3525 s_ModuleInfo[b_ModulNbr].
3526 s_SiemensCounterInfo.s_InitFlag.b_IndexInit) {
3528 s_ModuleInfo[b_ModulNbr].
3529 s_SiemensCounterInfo.
3532 b_ModeRegister2 = devpriv->
3533 s_ModuleInfo[b_ModulNbr].
3534 s_SiemensCounterInfo.
3538 APCI1710_DISABLE_INDEX;
3540 outl(devpriv->s_ModuleInfo[b_ModulNbr].
3541 s_SiemensCounterInfo.
3543 dw_ModeRegister1_2_3_4,
3544 devpriv->s_BoardInfos.ui_Address + 20 +
3547 /*************************************************************/
3548 /* Index not initialised see function "i_APCI1710_InitIndex" */
3549 /*************************************************************/
3551 DPRINTK("Index not initialised \n");
3555 /****************************************/
3556 /* Counter not initialised see function */
3557 /* "i_APCI1710_InitCounter" */
3558 /****************************************/
3560 DPRINTK("Counter not initialised\n");
3564 /*************************************************/
3565 /* The selected module number parameter is wrong */
3566 /*************************************************/
3568 DPRINTK("The selected module number parameter is wrong\n");
3572 return i_ReturnValue;
3576 +----------------------------------------------------------------------------+
3577 | Function Name : _INT_ i_APCI1710_EnableCompareLogic |
3578 | (unsigned char_ b_BoardHandle, |
3579 | unsigned char_ b_ModulNbr) |
3580 +----------------------------------------------------------------------------+
3581 | Task : Enable the 32-Bit compare logic. At that moment that |
3582 | the incremental counter arrive to the compare value a |
3583 | interrupt is generated. |
3584 +----------------------------------------------------------------------------+
3585 | Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
3586 | unsigned char_ b_ModulNbr : Module number to configure |
3588 +----------------------------------------------------------------------------+
3589 | Output Parameters : -
3590 +----------------------------------------------------------------------------+
3591 | Return Value : 0: No error |
3592 | -1: The handle parameter of the board is wrong |
3593 | -2: No counter module found |
3594 | -3: Counter not initialised see function |
3595 | "i_APCI1710_InitCounter" |
3596 | -4: Compare logic not initialised. |
3597 | See function "i_APCI1710_InitCompareLogic" |
3598 | -5: Interrupt function not initialised. |
3599 | See function "i_APCI1710_SetBoardIntRoutineX" |
3600 +----------------------------------------------------------------------------+
3602 static int i_APCI1710_EnableCompareLogic(struct comedi_device *dev,
3603 unsigned char b_ModulNbr)
3605 struct addi_private *devpriv = dev->private;
3606 int i_ReturnValue = 0;
3608 /**************************/
3609 /* Test the module number */
3610 /**************************/
3612 if (b_ModulNbr < 4) {
3613 /*******************************/
3614 /* Test if counter initialised */
3615 /*******************************/
3618 s_ModuleInfo[b_ModulNbr].
3619 s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) {
3620 /*************************************/
3621 /* Test if compare logic initialised */
3622 /*************************************/
3625 s_ModuleInfo[b_ModulNbr].
3626 s_SiemensCounterInfo.
3627 s_InitFlag.b_CompareLogicInit == 1) {
3629 s_ModuleInfo[b_ModulNbr].
3630 s_SiemensCounterInfo.
3633 b_ModeRegister3 = devpriv->
3634 s_ModuleInfo[b_ModulNbr].
3635 s_SiemensCounterInfo.
3639 APCI1710_ENABLE_COMPARE_INT;
3641 /***************************/
3642 /* Write the configuration */
3643 /***************************/
3645 outl(devpriv->s_ModuleInfo[b_ModulNbr].
3646 s_SiemensCounterInfo.
3648 dw_ModeRegister1_2_3_4,
3649 devpriv->s_BoardInfos.ui_Address + 20 +
3652 /*********************************/
3653 /* Compare logic not initialised */
3654 /*********************************/
3656 DPRINTK("Compare logic not initialised\n");
3660 /****************************************/
3661 /* Counter not initialised see function */
3662 /* "i_APCI1710_InitCounter" */
3663 /****************************************/
3665 DPRINTK("Counter not initialised\n");
3669 /*************************************************/
3670 /* The selected module number parameter is wrong */
3671 /*************************************************/
3673 DPRINTK("The selected module number parameter is wrong\n");
3677 return i_ReturnValue;
3681 +----------------------------------------------------------------------------+
3682 | Function Name : _INT_ i_APCI1710_DisableCompareLogic |
3683 | (unsigned char_ b_BoardHandle, |
3684 | unsigned char_ b_ModulNbr) |
3685 +----------------------------------------------------------------------------+
3686 | Task : Disable the 32-Bit compare logic.
3687 +----------------------------------------------------------------------------+
3688 | Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
3689 | unsigned char_ b_ModulNbr : Module number to configure |
3691 +----------------------------------------------------------------------------+
3692 | Output Parameters : -
3693 +----------------------------------------------------------------------------+
3694 | Return Value : 0: No error |
3695 | -1: The handle parameter of the board is wrong |
3696 | -2: No counter module found |
3697 | -3: Counter not initialised see function |
3698 | "i_APCI1710_InitCounter" |
3699 | -4: Compare logic not initialised. |
3700 | See function "i_APCI1710_InitCompareLogic" |
3701 +----------------------------------------------------------------------------+
3703 static int i_APCI1710_DisableCompareLogic(struct comedi_device *dev,
3704 unsigned char b_ModulNbr)
3706 struct addi_private *devpriv = dev->private;
3707 int i_ReturnValue = 0;
3709 /**************************/
3710 /* Test the module number */
3711 /**************************/
3713 if (b_ModulNbr < 4) {
3714 /*******************************/
3715 /* Test if counter initialised */
3716 /*******************************/
3719 s_ModuleInfo[b_ModulNbr].
3720 s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) {
3721 /*************************************/
3722 /* Test if compare logic initialised */
3723 /*************************************/
3726 s_ModuleInfo[b_ModulNbr].
3727 s_SiemensCounterInfo.
3728 s_InitFlag.b_CompareLogicInit == 1) {
3730 s_ModuleInfo[b_ModulNbr].
3731 s_SiemensCounterInfo.
3734 b_ModeRegister3 = devpriv->
3735 s_ModuleInfo[b_ModulNbr].
3736 s_SiemensCounterInfo.
3740 APCI1710_DISABLE_COMPARE_INT;
3742 /***************************/
3743 /* Write the configuration */
3744 /***************************/
3746 outl(devpriv->s_ModuleInfo[b_ModulNbr].
3747 s_SiemensCounterInfo.
3749 dw_ModeRegister1_2_3_4,
3750 devpriv->s_BoardInfos.ui_Address + 20 +
3753 /*********************************/
3754 /* Compare logic not initialised */
3755 /*********************************/
3757 DPRINTK("Compare logic not initialised\n");
3761 /****************************************/
3762 /* Counter not initialised see function */
3763 /* "i_APCI1710_InitCounter" */
3764 /****************************************/
3766 DPRINTK("Counter not initialised\n");
3770 /*************************************************/
3771 /* The selected module number parameter is wrong */
3772 /*************************************************/
3774 DPRINTK("The selected module number parameter is wrong\n");
3778 return i_ReturnValue;
3782 +----------------------------------------------------------------------------+
3783 | Function Name : _INT_ i_APCI1710_EnableFrequencyMeasurement |
3784 | (unsigned char_ b_BoardHandle, |
3785 | unsigned char_ b_ModulNbr, |
3786 | unsigned char_ b_InterruptEnable) |
3787 +----------------------------------------------------------------------------+
3788 | Task : Enables the frequency measurement function |
3789 +----------------------------------------------------------------------------+
3790 | Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
3791 | unsigned char_ b_ModulNbr : Number of the module to be |
3792 | configured (0 to 3) |
3793 | unsigned char_ b_InterruptEnable: Enable or disable the |
3795 | APCI1710_ENABLE: |
3796 | Enable the interrupt |
3797 | APCI1710_DISABLE: |
3798 | Disable the interrupt |
3799 +----------------------------------------------------------------------------+
3800 | Output Parameters : - |
3801 +----------------------------------------------------------------------------+
3802 | Return Value : 0: No error |
3803 | -1: The handle parameter of the board is wrong |
3804 | -2: The selected module number is wrong |
3805 | -3: Counter not initialised see function |
3806 | "i_APCI1710_InitCounter" |
3807 | -4: Frequency measurement logic not initialised. |
3808 | See function "i_APCI1710_InitFrequencyMeasurement" |
3809 | -5: Interrupt parameter is wrong |
3810 | -6: Interrupt function not initialised. |
3811 +----------------------------------------------------------------------------+
3813 static int i_APCI1710_EnableFrequencyMeasurement(struct comedi_device *dev,
3814 unsigned char b_ModulNbr,
3815 unsigned char b_InterruptEnable)
3817 struct addi_private *devpriv = dev->private;
3818 int i_ReturnValue = 0;
3820 /**************************/
3821 /* Test the module number */
3822 /**************************/
3824 if (b_ModulNbr < 4) {
3825 /*******************************/
3826 /* Test if counter initialised */
3827 /*******************************/
3830 s_ModuleInfo[b_ModulNbr].
3831 s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) {
3832 /********************************************/
3833 /* Test if frequency measurement initialised */
3834 /********************************************/
3837 s_ModuleInfo[b_ModulNbr].
3838 s_SiemensCounterInfo.
3839 s_InitFlag.b_FrequencyMeasurementInit == 1) {
3840 /***************************/
3841 /* Test the interrupt mode */
3842 /***************************/
3844 if ((b_InterruptEnable == APCI1710_DISABLE) ||
3845 (b_InterruptEnable == APCI1710_ENABLE))
3848 /************************************/
3849 /* Enable the frequency measurement */
3850 /************************************/
3853 s_ModuleInfo[b_ModulNbr].
3854 s_SiemensCounterInfo.
3857 b_ModeRegister3 = devpriv->
3858 s_ModuleInfo[b_ModulNbr].
3859 s_SiemensCounterInfo.
3863 APCI1710_ENABLE_FREQUENCY;
3865 /*********************************************/
3866 /* Disable or enable the frequency interrupt */
3867 /*********************************************/
3870 s_ModuleInfo[b_ModulNbr].
3871 s_SiemensCounterInfo.
3874 b_ModeRegister3 = (devpriv->
3875 s_ModuleInfo[b_ModulNbr].
3876 s_SiemensCounterInfo.
3880 APCI1710_DISABLE_FREQUENCY_INT)
3881 | (b_InterruptEnable << 3);
3883 /***************************/
3884 /* Write the configuration */
3885 /***************************/
3887 outl(devpriv->s_ModuleInfo[b_ModulNbr].
3888 s_SiemensCounterInfo.
3890 dw_ModeRegister1_2_3_4,
3891 devpriv->s_BoardInfos.
3896 s_ModuleInfo[b_ModulNbr].
3897 s_SiemensCounterInfo.
3899 b_FrequencyMeasurementEnable =
3902 /********************************/
3903 /* Interrupt parameter is wrong */
3904 /********************************/
3906 DPRINTK("Interrupt parameter is wrong\n");
3910 /***********************************************/
3911 /* Frequency measurement logic not initialised */
3912 /***********************************************/
3914 DPRINTK("Frequency measurement logic not initialised\n");
3918 /****************************************/
3919 /* Counter not initialised see function */
3920 /* "i_APCI1710_InitCounter" */
3921 /****************************************/
3923 DPRINTK("Counter not initialised\n");
3927 /*************************************************/
3928 /* The selected module number parameter is wrong */
3929 /*************************************************/
3931 DPRINTK("The selected module number parameter is wrong\n");
3935 return i_ReturnValue;
3939 +----------------------------------------------------------------------------+
3940 | Function Name : _INT_ i_APCI1710_DisableFrequencyMeasurement |
3941 | (unsigned char_ b_BoardHandle, |
3942 | unsigned char_ b_ModulNbr) |
3943 +----------------------------------------------------------------------------+
3944 | Task : Disables the frequency measurement function |
3945 +----------------------------------------------------------------------------+
3946 | Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
3947 | unsigned char_ b_ModulNbr : Number of the module to be |
3948 | configured (0 to 3) |
3949 +----------------------------------------------------------------------------+
3950 | Output Parameters : - |
3951 +----------------------------------------------------------------------------+
3952 | Return Value : 0: No error |
3953 | -1: The handle parameter of the board is wrong |
3954 | -2: The selected module number is wrong |
3955 | -3: Counter not initialised see function |
3956 | "i_APCI1710_InitCounter" |
3957 | -4: Frequency measurement logic not initialised. |
3958 | See function "i_APCI1710_InitFrequencyMeasurement" |
3959 +----------------------------------------------------------------------------+
3961 static int i_APCI1710_DisableFrequencyMeasurement(struct comedi_device *dev,
3962 unsigned char b_ModulNbr)
3964 struct addi_private *devpriv = dev->private;
3965 int i_ReturnValue = 0;
3967 /**************************/
3968 /* Test the module number */
3969 /**************************/
3971 if (b_ModulNbr < 4) {
3972 /*******************************/
3973 /* Test if counter initialised */
3974 /*******************************/
3977 s_ModuleInfo[b_ModulNbr].
3978 s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) {
3979 /********************************************/
3980 /* Test if frequency measurement initialised */
3981 /********************************************/
3984 s_ModuleInfo[b_ModulNbr].
3985 s_SiemensCounterInfo.
3986 s_InitFlag.b_FrequencyMeasurementInit == 1) {
3987 /*************************************/
3988 /* Disable the frequency measurement */
3989 /*************************************/
3992 s_ModuleInfo[b_ModulNbr].
3993 s_SiemensCounterInfo.
3996 b_ModeRegister3 = devpriv->
3997 s_ModuleInfo[b_ModulNbr].
3998 s_SiemensCounterInfo.
4002 APCI1710_DISABLE_FREQUENCY
4003 /* Begin CG 29/06/01 CG 1100/0231 -> 0701/0232 Frequence measure IRQ must be cleared */
4004 & APCI1710_DISABLE_FREQUENCY_INT;
4005 /* End CG 29/06/01 CG 1100/0231 -> 0701/0232 Frequence measure IRQ must be cleared */
4007 /***************************/
4008 /* Write the configuration */
4009 /***************************/
4011 outl(devpriv->s_ModuleInfo[b_ModulNbr].
4012 s_SiemensCounterInfo.
4014 dw_ModeRegister1_2_3_4,
4015 devpriv->s_BoardInfos.ui_Address + 20 +
4018 /*************************************/
4019 /* Disable the frequency measurement */
4020 /*************************************/
4023 s_ModuleInfo[b_ModulNbr].
4024 s_SiemensCounterInfo.
4026 b_FrequencyMeasurementEnable = 0;
4028 /***********************************************/
4029 /* Frequency measurement logic not initialised */
4030 /***********************************************/
4032 DPRINTK("Frequency measurement logic not initialised\n");
4036 /****************************************/
4037 /* Counter not initialised see function */
4038 /* "i_APCI1710_InitCounter" */
4039 /****************************************/
4041 DPRINTK("Counter not initialised\n");
4045 /*************************************************/
4046 /* The selected module number parameter is wrong */
4047 /*************************************************/
4049 DPRINTK("The selected module number parameter is wrong\n");
4053 return i_ReturnValue;
4057 * Enable Disable functions for INC_CPT
4059 static int i_APCI1710_InsnWriteINCCPT(struct comedi_device *dev,
4060 struct comedi_subdevice *s,
4061 struct comedi_insn *insn,
4064 struct addi_private *devpriv = dev->private;
4065 unsigned int ui_WriteType;
4066 int i_ReturnValue = 0;
4068 ui_WriteType = CR_CHAN(insn->chanspec);
4069 devpriv->tsk_Current = current; /* Save the current process task structure */
4071 switch (ui_WriteType) {
4072 case APCI1710_INCCPT_ENABLELATCHINTERRUPT:
4073 i_ReturnValue = i_APCI1710_EnableLatchInterrupt(dev,
4074 (unsigned char) CR_AREF(insn->chanspec));
4077 case APCI1710_INCCPT_DISABLELATCHINTERRUPT:
4078 i_ReturnValue = i_APCI1710_DisableLatchInterrupt(dev,
4079 (unsigned char) CR_AREF(insn->chanspec));
4082 case APCI1710_INCCPT_WRITE16BITCOUNTERVALUE:
4083 i_ReturnValue = i_APCI1710_Write16BitCounterValue(dev,
4084 (unsigned char) CR_AREF(insn->chanspec),
4085 (unsigned char) data[0], (unsigned int) data[1]);
4088 case APCI1710_INCCPT_WRITE32BITCOUNTERVALUE:
4089 i_ReturnValue = i_APCI1710_Write32BitCounterValue(dev,
4090 (unsigned char) CR_AREF(insn->chanspec), (unsigned int) data[0]);
4094 case APCI1710_INCCPT_ENABLEINDEX:
4095 i_APCI1710_EnableIndex(dev, (unsigned char) CR_AREF(insn->chanspec));
4098 case APCI1710_INCCPT_DISABLEINDEX:
4099 i_ReturnValue = i_APCI1710_DisableIndex(dev,
4100 (unsigned char) CR_AREF(insn->chanspec));
4103 case APCI1710_INCCPT_ENABLECOMPARELOGIC:
4104 i_ReturnValue = i_APCI1710_EnableCompareLogic(dev,
4105 (unsigned char) CR_AREF(insn->chanspec));
4108 case APCI1710_INCCPT_DISABLECOMPARELOGIC:
4109 i_ReturnValue = i_APCI1710_DisableCompareLogic(dev,
4110 (unsigned char) CR_AREF(insn->chanspec));
4113 case APCI1710_INCCPT_ENABLEFREQUENCYMEASUREMENT:
4114 i_ReturnValue = i_APCI1710_EnableFrequencyMeasurement(dev,
4115 (unsigned char) CR_AREF(insn->chanspec), (unsigned char) data[0]);
4118 case APCI1710_INCCPT_DISABLEFREQUENCYMEASUREMENT:
4119 i_ReturnValue = i_APCI1710_DisableFrequencyMeasurement(dev,
4120 (unsigned char) CR_AREF(insn->chanspec));
4124 printk("Write Config Parameter Wrong\n");
4127 if (i_ReturnValue >= 0)
4128 i_ReturnValue = insn->n;
4129 return i_ReturnValue;
4133 +----------------------------------------------------------------------------+
4134 | Function Name : _INT_ i_APCI1710_ReadLatchRegisterStatus |
4135 | (unsigned char_ b_BoardHandle, |
4136 | unsigned char_ b_ModulNbr, |
4137 | unsigned char_ b_LatchReg, |
4138 | unsigned char *_ pb_LatchStatus) |
4139 +----------------------------------------------------------------------------+
4140 | Task : Read the latch register status from selected module |
4141 | (b_ModulNbr) and selected latch register (b_LatchReg). |
4142 +----------------------------------------------------------------------------+
4143 | Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
4144 | unsigned char_ b_ModulNbr : Module number to configure |
4146 | unsigned char_ b_LatchReg : Selected latch register |
4147 | 0 : for the first latch register |
4148 | 1 : for the second latch register |
4149 +----------------------------------------------------------------------------+
4150 | Output Parameters : unsigned char *_ pb_LatchStatus : Latch register status. |
4151 | 0 : No latch occur |
4152 | 1 : A software latch occur |
4153 | 2 : A hardware latch occur |
4154 | 3 : A software and hardware |
4156 +----------------------------------------------------------------------------+
4157 | Return Value : 0: No error |
4158 | -1: The handle parameter of the board is wrong |
4159 | -2: No counter module found |
4160 | -3: Counter not initialised see function |
4161 | "i_APCI1710_InitCounter" |
4162 | -4: The selected latch register parameter is wrong |
4163 +----------------------------------------------------------------------------+
4165 static int i_APCI1710_ReadLatchRegisterStatus(struct comedi_device *dev,
4166 unsigned char b_ModulNbr,
4167 unsigned char b_LatchReg,
4168 unsigned char *pb_LatchStatus)
4170 struct addi_private *devpriv = dev->private;
4171 int i_ReturnValue = 0;
4172 unsigned int dw_LatchReg;
4174 /**************************/
4175 /* Test the module number */
4176 /**************************/
4178 if (b_ModulNbr < 4) {
4179 /*******************************/
4180 /* Test if counter initialised */
4181 /*******************************/
4184 s_ModuleInfo[b_ModulNbr].
4185 s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) {
4186 /*************************************/
4187 /* Test the latch register parameter */
4188 /*************************************/
4190 if (b_LatchReg < 2) {
4191 dw_LatchReg = inl(devpriv->s_BoardInfos.
4192 ui_Address + (64 * b_ModulNbr));
4195 (unsigned char) ((dw_LatchReg >> (b_LatchReg *
4198 /**************************************************/
4199 /* The selected latch register parameter is wrong */
4200 /**************************************************/
4202 DPRINTK("The selected latch register parameter is wrong\n");
4206 /****************************************/
4207 /* Counter not initialised see function */
4208 /* "i_APCI1710_InitCounter" */
4209 /****************************************/
4211 DPRINTK("Counter not initialised\n");
4215 /*************************************************/
4216 /* The selected module number parameter is wrong */
4217 /*************************************************/
4219 DPRINTK("The selected module number parameter is wrong\n");
4223 return i_ReturnValue;
4227 +----------------------------------------------------------------------------+
4228 | Function Name : _INT_ i_APCI1710_ReadLatchRegisterValue |
4229 | (unsigned char_ b_BoardHandle,|
4230 | unsigned char_ b_ModulNbr, |
4231 | unsigned char_ b_LatchReg, |
4232 | PULONG_ pul_LatchValue) |
4233 +----------------------------------------------------------------------------+
4234 | Task : Read the latch register value from selected module |
4235 | (b_ModulNbr) and selected latch register (b_LatchReg). |
4236 +----------------------------------------------------------------------------+
4237 | Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
4238 | unsigned char_ b_ModulNbr : Module number to configure |
4240 | unsigned char_ b_LatchReg : Selected latch register |
4241 | 0 : for the first latch register |
4242 | 1 : for the second latch register |
4243 +----------------------------------------------------------------------------+
4244 | Output Parameters : PULONG_ pul_LatchValue : Latch register value |
4245 +----------------------------------------------------------------------------+
4246 | Return Value : 0: No error |
4247 | -1: The handle parameter of the board is wrong |
4248 | -2: No counter module found |
4249 | -3: Counter not initialised see function |
4250 | "i_APCI1710_InitCounter" |
4251 | -4: The selected latch register parameter is wrong |
4252 +----------------------------------------------------------------------------+
4254 static int i_APCI1710_ReadLatchRegisterValue(struct comedi_device *dev,
4255 unsigned char b_ModulNbr,
4256 unsigned char b_LatchReg,
4257 unsigned int *pul_LatchValue)
4259 struct addi_private *devpriv = dev->private;
4260 int i_ReturnValue = 0;
4262 /**************************/
4263 /* Test the module number */
4264 /**************************/
4266 if (b_ModulNbr < 4) {
4267 /*******************************/
4268 /* Test if counter initialised */
4269 /*******************************/
4272 s_ModuleInfo[b_ModulNbr].
4273 s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) {
4274 /*************************************/
4275 /* Test the latch register parameter */
4276 /*************************************/
4278 if (b_LatchReg < 2) {
4279 *pul_LatchValue = inl(devpriv->s_BoardInfos.
4280 ui_Address + ((b_LatchReg + 1) * 4) +
4284 /**************************************************/
4285 /* The selected latch register parameter is wrong */
4286 /**************************************************/
4288 DPRINTK("The selected latch register parameter is wrong\n");
4292 /****************************************/
4293 /* Counter not initialised see function */
4294 /* "i_APCI1710_InitCounter" */
4295 /****************************************/
4297 DPRINTK("Counter not initialised\n");
4301 /*************************************************/
4302 /* The selected module number parameter is wrong */
4303 /*************************************************/
4305 DPRINTK("The selected module number parameter is wrong\n");
4309 return i_ReturnValue;
4313 +----------------------------------------------------------------------------+
4314 | Function Name : _INT_ i_APCI1710_Read16BitCounterValue |
4315 | (unsigned char_ b_BoardHandle, |
4316 | unsigned char_ b_ModulNbr, |
4317 | unsigned char_ b_SelectedCounter, |
4318 | unsigned int *_ pui_CounterValue) |
4319 +----------------------------------------------------------------------------+
4320 | Task : Latch the selected 16-Bit counter (b_SelectedCounter) |
4321 | from selected module (b_ModulNbr) in to the first |
4322 | latch register and return the latched value. |
4323 +----------------------------------------------------------------------------+
4324 | Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
4325 | unsigned char_ b_ModulNbr : Module number to configure |
4327 | unsigned char_ b_SelectedCounter : Selected 16-Bit counter |
4329 +----------------------------------------------------------------------------+
4330 | Output Parameters : unsigned int *_ pui_CounterValue : 16-Bit counter value |
4331 +----------------------------------------------------------------------------+
4332 | Return Value : 0: No error |
4333 | -1: The handle parameter of the board is wrong |
4334 | -2: No counter module found |
4335 | -3: Counter not initialised see function |
4336 | "i_APCI1710_InitCounter" |
4337 | -4: The selected 16-Bit counter parameter is wrong |
4338 +----------------------------------------------------------------------------+
4340 static int i_APCI1710_Read16BitCounterValue(struct comedi_device *dev,
4341 unsigned char b_ModulNbr,
4342 unsigned char b_SelectedCounter,
4343 unsigned int *pui_CounterValue)
4345 struct addi_private *devpriv = dev->private;
4346 int i_ReturnValue = 0;
4347 unsigned int dw_LathchValue = 0;
4349 /**************************/
4350 /* Test the module number */
4351 /**************************/
4353 if (b_ModulNbr < 4) {
4354 /*******************************/
4355 /* Test if counter initialised */
4356 /*******************************/
4359 s_ModuleInfo[b_ModulNbr].
4360 s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) {
4361 /******************************/
4362 /* Test the counter selection */
4363 /******************************/
4365 if (b_SelectedCounter < 2) {
4366 /*********************/
4367 /* Latch the counter */
4368 /*********************/
4370 outl(1, devpriv->s_BoardInfos.
4371 ui_Address + (64 * b_ModulNbr));
4373 /************************/
4374 /* Read the latch value */
4375 /************************/
4377 dw_LathchValue = inl(devpriv->s_BoardInfos.
4378 ui_Address + 4 + (64 * b_ModulNbr));
4381 (unsigned int) ((dw_LathchValue >> (16 *
4382 b_SelectedCounter)) &
4385 /**************************************************/
4386 /* The selected 16-Bit counter parameter is wrong */
4387 /**************************************************/
4389 DPRINTK("The selected 16-Bit counter parameter is wrong\n");
4393 /****************************************/
4394 /* Counter not initialised see function */
4395 /* "i_APCI1710_InitCounter" */
4396 /****************************************/
4398 DPRINTK("Counter not initialised\n");
4402 /*************************************************/
4403 /* The selected module number parameter is wrong */
4404 /*************************************************/
4406 DPRINTK("The selected module number parameter is wrong\n");
4410 return i_ReturnValue;
4414 +----------------------------------------------------------------------------+
4415 | Function Name : _INT_ i_APCI1710_Read32BitCounterValue |
4416 | (unsigned char_ b_BoardHandle, |
4417 | unsigned char_ b_ModulNbr, |
4418 | PULONG_ pul_CounterValue) |
4419 +----------------------------------------------------------------------------+
4420 | Task : Latch the 32-Bit counter from selected module |
4421 | (b_ModulNbr) in to the first latch register and return |
4422 | the latched value. |
4423 +----------------------------------------------------------------------------+
4424 | Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
4425 | unsigned char_ b_ModulNbr : Module number to configure |
4427 +----------------------------------------------------------------------------+
4428 | Output Parameters : PULONG_ pul_CounterValue : 32-Bit counter value |
4429 +----------------------------------------------------------------------------+
4430 | Return Value : 0: No error |
4431 | -1: The handle parameter of the board is wrong |
4432 | -2: No counter module found |
4433 | -3: Counter not initialised see function |
4434 | "i_APCI1710_InitCounter" |
4435 +----------------------------------------------------------------------------+
4437 static int i_APCI1710_Read32BitCounterValue(struct comedi_device *dev,
4438 unsigned char b_ModulNbr,
4439 unsigned int *pul_CounterValue)
4441 struct addi_private *devpriv = dev->private;
4442 int i_ReturnValue = 0;
4444 /**************************/
4445 /* Test the module number */
4446 /**************************/
4448 if (b_ModulNbr < 4) {
4449 /*******************************/
4450 /* Test if counter initialised */
4451 /*******************************/
4454 s_ModuleInfo[b_ModulNbr].
4455 s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) {
4456 /*********************/
4457 /* Tatch the counter */
4458 /*********************/
4460 outl(1, devpriv->s_BoardInfos.
4461 ui_Address + (64 * b_ModulNbr));
4463 /************************/
4464 /* Read the latch value */
4465 /************************/
4467 *pul_CounterValue = inl(devpriv->s_BoardInfos.
4468 ui_Address + 4 + (64 * b_ModulNbr));
4470 /****************************************/
4471 /* Counter not initialised see function */
4472 /* "i_APCI1710_InitCounter" */
4473 /****************************************/
4475 DPRINTK("Counter not initialised\n");
4479 /*************************************************/
4480 /* The selected module number parameter is wrong */
4481 /*************************************************/
4483 DPRINTK("The selected module number parameter is wrong\n");
4487 return i_ReturnValue;
4491 +----------------------------------------------------------------------------+
4492 | Function Name : _INT_ i_APCI1710_GetIndexStatus (unsigned char_ b_BoardHandle,|
4493 | unsigned char_ b_ModulNbr, |
4494 | unsigned char *_ pb_IndexStatus)|
4495 +----------------------------------------------------------------------------+
4496 | Task : Return the index status |
4497 +----------------------------------------------------------------------------+
4498 | Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
4499 | unsigned char_ b_ModulNbr : Module number to configure |
4501 +----------------------------------------------------------------------------+
4502 | Output Parameters : unsigned char *_ pb_IndexStatus : 0 : No INDEX occur |
4503 | 1 : A INDEX occur |
4504 +----------------------------------------------------------------------------+
4505 | Return Value : 0: No error |
4506 | -1: The handle parameter of the board is wrong |
4507 | -2: No counter module found |
4508 | -3: Counter not initialised see function |
4509 | "i_APCI1710_InitCounter" |
4510 | -4: Index not initialised see function |
4511 | "i_APCI1710_InitIndex" |
4512 +----------------------------------------------------------------------------+
4514 static int i_APCI1710_GetIndexStatus(struct comedi_device *dev,
4515 unsigned char b_ModulNbr,
4516 unsigned char *pb_IndexStatus)
4518 struct addi_private *devpriv = dev->private;
4519 int i_ReturnValue = 0;
4520 unsigned int dw_StatusReg = 0;
4522 /**************************/
4523 /* Test the module number */
4524 /**************************/
4526 if (b_ModulNbr < 4) {
4527 /*******************************/
4528 /* Test if counter initialised */
4529 /*******************************/
4532 s_ModuleInfo[b_ModulNbr].
4533 s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) {
4534 /*****************************/
4535 /* Test if index initialised */
4536 /*****************************/
4539 s_ModuleInfo[b_ModulNbr].
4540 s_SiemensCounterInfo.s_InitFlag.b_IndexInit) {
4541 dw_StatusReg = inl(devpriv->s_BoardInfos.
4542 ui_Address + 12 + (64 * b_ModulNbr));
4544 *pb_IndexStatus = (unsigned char) (dw_StatusReg & 1);
4546 /*************************************************************/
4547 /* Index not initialised see function "i_APCI1710_InitIndex" */
4548 /*************************************************************/
4550 DPRINTK("Index not initialised\n");
4554 /****************************************/
4555 /* Counter not initialised see function */
4556 /* "i_APCI1710_InitCounter" */
4557 /****************************************/
4559 DPRINTK("Counter not initialised\n");
4563 /*************************************************/
4564 /* The selected module number parameter is wrong */
4565 /*************************************************/
4567 DPRINTK("The selected module number parameter is wrong\n");
4571 return i_ReturnValue;
4575 +----------------------------------------------------------------------------+
4576 | Function Name : _INT_ i_APCI1710_GetReferenceStatus |
4577 | (unsigned char_ b_BoardHandle, |
4578 | unsigned char_ b_ModulNbr, |
4579 | unsigned char *_ pb_ReferenceStatus) |
4580 +----------------------------------------------------------------------------+
4581 | Task : Return the reference status |
4582 +----------------------------------------------------------------------------+
4583 | Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
4584 | unsigned char_ b_ModulNbr : Module number to configure |
4586 +----------------------------------------------------------------------------+
4587 | Output Parameters : unsigned char *_ pb_ReferenceStatus : 0 : No REFERENCE occur |
4588 | 1 : A REFERENCE occur |
4589 +----------------------------------------------------------------------------+
4590 | Return Value : 0: No error |
4591 | -1: The handle parameter of the board is wrong |
4592 | -2: No counter module found |
4593 | -3: Counter not initialised see function |
4594 | "i_APCI1710_InitCounter" |
4595 | -4: Reference not initialised see function |
4596 | "i_APCI1710_InitReference" |
4597 +----------------------------------------------------------------------------+
4599 static int i_APCI1710_GetReferenceStatus(struct comedi_device *dev,
4600 unsigned char b_ModulNbr,
4601 unsigned char *pb_ReferenceStatus)
4603 struct addi_private *devpriv = dev->private;
4604 int i_ReturnValue = 0;
4605 unsigned int dw_StatusReg = 0;
4607 /**************************/
4608 /* Test the module number */
4609 /**************************/
4611 if (b_ModulNbr < 4) {
4612 /*******************************/
4613 /* Test if counter initialised */
4614 /*******************************/
4617 s_ModuleInfo[b_ModulNbr].
4618 s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) {
4619 /*********************************/
4620 /* Test if reference initialised */
4621 /*********************************/
4624 s_ModuleInfo[b_ModulNbr].
4625 s_SiemensCounterInfo.
4626 s_InitFlag.b_ReferenceInit) {
4627 dw_StatusReg = inl(devpriv->s_BoardInfos.
4628 ui_Address + 24 + (64 * b_ModulNbr));
4630 *pb_ReferenceStatus =
4631 (unsigned char) (~dw_StatusReg & 1);
4633 /*********************************************************************/
4634 /* Reference not initialised see function "i_APCI1710_InitReference" */
4635 /*********************************************************************/
4637 DPRINTK("Reference not initialised\n");
4641 /****************************************/
4642 /* Counter not initialised see function */
4643 /* "i_APCI1710_InitCounter" */
4644 /****************************************/
4646 DPRINTK("Counter not initialised\n");
4650 /*************************************************/
4651 /* The selected module number parameter is wrong */
4652 /*************************************************/
4654 DPRINTK("The selected module number parameter is wrong\n");
4658 return i_ReturnValue;
4662 +----------------------------------------------------------------------------+
4663 | Function Name : _INT_ i_APCI1710_GetUASStatus |
4664 | (unsigned char_ b_BoardHandle, |
4665 | unsigned char_ b_ModulNbr, |
4666 | unsigned char *_ pb_UASStatus) |
4667 +----------------------------------------------------------------------------+
4668 | Task : Return the error signal (UAS) status |
4669 +----------------------------------------------------------------------------+
4670 | Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
4671 | unsigned char_ b_ModulNbr : Module number to configure |
4673 +----------------------------------------------------------------------------+
4674 | Output Parameters : unsigned char *_ pb_UASStatus : 0 : UAS is low "0" |
4675 | 1 : UAS is high "1" |
4676 +----------------------------------------------------------------------------+
4677 | Return Value : 0: No error |
4678 | -1: The handle parameter of the board is wrong |
4679 | -2: No counter module found |
4680 | -3: Counter not initialised see function |
4681 | "i_APCI1710_InitCounter" |
4682 +----------------------------------------------------------------------------+
4684 static int i_APCI1710_GetUASStatus(struct comedi_device *dev,
4685 unsigned char b_ModulNbr,
4686 unsigned char *pb_UASStatus)
4688 struct addi_private *devpriv = dev->private;
4689 int i_ReturnValue = 0;
4690 unsigned int dw_StatusReg = 0;
4692 /**************************/
4693 /* Test the module number */
4694 /**************************/
4696 if (b_ModulNbr < 4) {
4697 /*******************************/
4698 /* Test if counter initialised */
4699 /*******************************/
4702 s_ModuleInfo[b_ModulNbr].
4703 s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) {
4704 dw_StatusReg = inl(devpriv->s_BoardInfos.
4705 ui_Address + 24 + (64 * b_ModulNbr));
4707 *pb_UASStatus = (unsigned char) ((dw_StatusReg >> 1) & 1);
4709 /****************************************/
4710 /* Counter not initialised see function */
4711 /* "i_APCI1710_InitCounter" */
4712 /****************************************/
4714 DPRINTK("Counter not initialised\n");
4718 /*************************************************/
4719 /* The selected module number parameter is wrong */
4720 /*************************************************/
4722 DPRINTK("The selected module number parameter is wrong\n");
4727 return i_ReturnValue;
4731 +----------------------------------------------------------------------------+
4732 | Function Name : _INT_ i_APCI1710_GetCBStatus |
4733 | (unsigned char_ b_BoardHandle, |
4734 | unsigned char_ b_ModulNbr, |
4735 | unsigned char *_ pb_CBStatus) |
4736 +----------------------------------------------------------------------------+
4737 | Task : Return the counter overflow status |
4738 +----------------------------------------------------------------------------+
4739 | Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
4740 | unsigned char_ b_ModulNbr : Module number to configure |
4742 +----------------------------------------------------------------------------+
4743 | Output Parameters : unsigned char *_ pb_CBStatus : 0 : Counter no overflow |
4744 | 1 : Counter overflow |
4745 +----------------------------------------------------------------------------+
4746 | Return Value : 0: No error |
4747 | -1: The handle parameter of the board is wrong |
4748 | -2: No counter module found |
4749 | -3: Counter not initialised see function |
4750 | "i_APCI1710_InitCounter" |
4751 +----------------------------------------------------------------------------+
4753 static int i_APCI1710_GetCBStatus(struct comedi_device *dev,
4754 unsigned char b_ModulNbr,
4755 unsigned char *pb_CBStatus)
4757 struct addi_private *devpriv = dev->private;
4758 int i_ReturnValue = 0;
4759 unsigned int dw_StatusReg = 0;
4761 /**************************/
4762 /* Test the module number */
4763 /**************************/
4765 if (b_ModulNbr < 4) {
4766 /*******************************/
4767 /* Test if counter initialised */
4768 /*******************************/
4771 s_ModuleInfo[b_ModulNbr].
4772 s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) {
4773 dw_StatusReg = inl(devpriv->s_BoardInfos.
4774 ui_Address + 16 + (64 * b_ModulNbr));
4776 *pb_CBStatus = (unsigned char) (dw_StatusReg & 1);
4779 /****************************************/
4780 /* Counter not initialised see function */
4781 /* "i_APCI1710_InitCounter" */
4782 /****************************************/
4784 DPRINTK("Counter not initialised\n");
4788 /*************************************************/
4789 /* The selected module number parameter is wrong */
4790 /*************************************************/
4792 DPRINTK("The selected module number parameter is wrong\n");
4796 return i_ReturnValue;
4800 +----------------------------------------------------------------------------+
4801 | Function Name : _INT_ i_APCI1710_Get16BitCBStatus |
4802 | (unsigned char_ b_BoardHandle, |
4803 | unsigned char_ b_ModulNbr, |
4804 | unsigned char *_ pb_CBStatusCounter0, |
4805 | unsigned char *_ pb_CBStatusCounter1) |
4806 +----------------------------------------------------------------------------+
4807 | Task : Returns the counter overflow (counter initialised to |
4808 | 2*16-bit) status from selected incremental counter |
4810 +----------------------------------------------------------------------------+
4811 | Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
4812 | unsigned char_ b_ModulNbr : Module number to configure |
4814 +----------------------------------------------------------------------------+
4815 | Output Parameters : unsigned char *_ pb_CBStatusCounter0 : 0 : No overflow occur for |
4816 | the first 16-bit |
4818 | 1 : Overflow occur for the|
4819 | first 16-bit counter |
4820 | unsigned char *_ pb_CBStatusCounter1 : 0 : No overflow occur for |
4821 | the second 16-bit |
4823 | 1 : Overflow occur for the|
4824 | second 16-bit counter |
4825 +----------------------------------------------------------------------------+
4826 | Return Value : 0: No error |
4827 | -1: The handle parameter of the board is wrong |
4828 | -2: No counter module found |
4829 | -3: Counter not initialised see function |
4830 | "i_APCI1710_InitCounter" |
4831 | -4: Counter not initialised to 2*16-bit mode. |
4832 | See function "i_APCI1710_InitCounter" |
4833 | -5: Firmware revision error |
4834 +----------------------------------------------------------------------------+
4836 static int i_APCI1710_Get16BitCBStatus(struct comedi_device *dev,
4837 unsigned char b_ModulNbr,
4838 unsigned char *pb_CBStatusCounter0,
4839 unsigned char *pb_CBStatusCounter1)
4841 struct addi_private *devpriv = dev->private;
4842 int i_ReturnValue = 0;
4843 unsigned int dw_StatusReg = 0;
4845 /**************************/
4846 /* Test the module number */
4847 /**************************/
4849 if (b_ModulNbr < 4) {
4850 /*******************************/
4851 /* Test if counter initialised */
4852 /*******************************/
4855 s_ModuleInfo[b_ModulNbr].
4856 s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) {
4857 /*************************/
4858 /* Test if 2*16-Bit mode */
4859 /*************************/
4861 if ((devpriv->s_ModuleInfo[b_ModulNbr].
4862 s_SiemensCounterInfo.
4865 b_ModeRegister1 & 0x10) == 0x10) {
4866 /*****************************/
4867 /* Test the Firmware version */
4868 /*****************************/
4870 if ((devpriv->s_BoardInfos.
4871 dw_MolduleConfiguration
4872 [b_ModulNbr] & 0xFFFF) >=
4875 inl(devpriv->s_BoardInfos.
4879 *pb_CBStatusCounter1 =
4880 (unsigned char) ((dw_StatusReg >> 0) &
4882 *pb_CBStatusCounter0 =
4883 (unsigned char) ((dw_StatusReg >> 1) &
4885 } /* if ((ps_APCI1710Variable->s_Board [b_BoardHandle].s_BoardInfos.dw_MolduleConfiguration [b_ModulNbr] & 0xFFFF) >= 0x3136) */
4887 /****************************/
4888 /* Firmware revision error */
4889 /****************************/
4892 } /* if ((ps_APCI1710Variable->s_Board [b_BoardHandle].s_BoardInfos.dw_MolduleConfiguration [b_ModulNbr] & 0xFFFF) >= 0x3136) */
4893 } /* if ((ps_APCI1710Variable->s_Board [b_BoardHandle].s_ModuleInfo [b_ModulNbr].s_SiemensCounterInfo.s_ModeRegister.s_ByteModeRegister.b_ModeRegister1 & 0x10) == 0x10) */
4895 /********************************************/
4896 /* Counter not initialised to 2*16-bit mode */
4897 /* "i_APCI1710_InitCounter" */
4898 /********************************************/
4900 DPRINTK("Counter not initialised\n");
4902 } /* if ((ps_APCI1710Variable->s_Board [b_BoardHandle].s_ModuleInfo [b_ModulNbr].s_SiemensCounterInfo.s_ModeRegister.s_ByteModeRegister.b_ModeRegister1 & 0x10) == 0x10) */
4903 } /* if (ps_APCI1710Variable->s_Board [b_BoardHandle].s_ModuleInfo [b_ModulNbr].s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) */
4905 /****************************************/
4906 /* Counter not initialised see function */
4907 /* "i_APCI1710_InitCounter" */
4908 /****************************************/
4910 DPRINTK("Counter not initialised\n");
4912 } /* if (ps_APCI1710Variable->s_Board [b_BoardHandle].s_ModuleInfo [b_ModulNbr].s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) */
4913 } /* if (b_ModulNbr < 4) */
4915 /*************************************************/
4916 /* The selected module number parameter is wrong */
4917 /*************************************************/
4919 DPRINTK("The selected module number parameter is wrong\n");
4921 } /* if (b_ModulNbr < 4) */
4923 return i_ReturnValue;
4927 +----------------------------------------------------------------------------+
4928 | Function Name : _INT_ i_APCI1710_GetUDStatus |
4929 | (unsigned char_ b_BoardHandle, |
4930 | unsigned char_ b_ModulNbr, |
4931 | unsigned char *_ pb_UDStatus) |
4932 +----------------------------------------------------------------------------+
4933 | Task : Return the counter progress status |
4934 +----------------------------------------------------------------------------+
4935 | Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
4936 | unsigned char_ b_ModulNbr : Module number to configure |
4938 +----------------------------------------------------------------------------+
4939 | Output Parameters : unsigned char *_ pb_UDStatus : 0 : Counter progress in the |
4940 | selected mode down |
4941 | 1 : Counter progress in the |
4942 | selected mode up |
4943 +----------------------------------------------------------------------------+
4944 | Return Value : 0: No error |
4945 | -1: The handle parameter of the board is wrong |
4946 | -2: No counter module found |
4947 | -3: Counter not initialised see function |
4948 | "i_APCI1710_InitCounter" |
4949 +----------------------------------------------------------------------------+
4951 static int i_APCI1710_GetUDStatus(struct comedi_device *dev,
4952 unsigned char b_ModulNbr,
4953 unsigned char *pb_UDStatus)
4955 struct addi_private *devpriv = dev->private;
4956 int i_ReturnValue = 0;
4957 unsigned int dw_StatusReg = 0;
4959 /**************************/
4960 /* Test the module number */
4961 /**************************/
4963 if (b_ModulNbr < 4) {
4964 /*******************************/
4965 /* Test if counter initialised */
4966 /*******************************/
4969 s_ModuleInfo[b_ModulNbr].
4970 s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) {
4971 dw_StatusReg = inl(devpriv->s_BoardInfos.
4972 ui_Address + 24 + (64 * b_ModulNbr));
4974 *pb_UDStatus = (unsigned char) ((dw_StatusReg >> 2) & 1);
4977 /****************************************/
4978 /* Counter not initialised see function */
4979 /* "i_APCI1710_InitCounter" */
4980 /****************************************/
4982 DPRINTK("Counter not initialised\n");
4986 /*************************************************/
4987 /* The selected module number parameter is wrong */
4988 /*************************************************/
4990 DPRINTK("The selected module number parameter is wrong\n");
4994 return i_ReturnValue;
4998 +----------------------------------------------------------------------------+
4999 | Function Name : _INT_ i_APCI1710_GetInterruptUDLatchedStatus |
5000 | (unsigned char_ b_BoardHandle, |
5001 | unsigned char_ b_ModulNbr, |
5002 | unsigned char *_ pb_UDStatus) |
5003 +----------------------------------------------------------------------------+
5004 | Task : Return the counter progress latched status after a |
5005 | index interrupt occur. |
5006 +----------------------------------------------------------------------------+
5007 | Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
5008 | unsigned char_ b_ModulNbr : Module number to configure |
5010 +----------------------------------------------------------------------------+
5011 | Output Parameters : unsigned char *_ pb_UDStatus : 0 : Counter progress in the |
5012 | selected mode down |
5013 | 1 : Counter progress in the |
5014 | selected mode up |
5015 | 2 : No index interrupt occur |
5016 +----------------------------------------------------------------------------+
5017 | Return Value : 0: No error |
5018 | -1: The handle parameter of the board is wrong |
5019 | -2: No counter module found |
5020 | -3: Counter not initialised see function |
5021 | "i_APCI1710_InitCounter" |
5022 | -4: Interrupt function not initialised. |
5023 | See function "i_APCI1710_SetBoardIntRoutineX" |
5024 +----------------------------------------------------------------------------+
5026 static int i_APCI1710_GetInterruptUDLatchedStatus(struct comedi_device *dev,
5027 unsigned char b_ModulNbr,
5028 unsigned char *pb_UDStatus)
5030 struct addi_private *devpriv = dev->private;
5031 int i_ReturnValue = 0;
5032 unsigned int dw_StatusReg = 0;
5034 /**************************/
5035 /* Test the module number */
5036 /**************************/
5038 if (b_ModulNbr < 4) {
5039 /*******************************/
5040 /* Test if counter initialised */
5041 /*******************************/
5044 s_ModuleInfo[b_ModulNbr].
5045 s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) {
5046 /*********************************/
5047 /* Test if index interrupt occur */
5048 /*********************************/
5051 s_ModuleInfo[b_ModulNbr].
5052 s_SiemensCounterInfo.
5053 s_InitFlag.b_IndexInterruptOccur == 1) {
5055 s_ModuleInfo[b_ModulNbr].
5056 s_SiemensCounterInfo.
5057 s_InitFlag.b_IndexInterruptOccur = 0;
5059 dw_StatusReg = inl(devpriv->s_BoardInfos.
5060 ui_Address + 12 + (64 * b_ModulNbr));
5062 *pb_UDStatus = (unsigned char) ((dw_StatusReg >> 1) & 1);
5064 /****************************/
5065 /* No index interrupt occur */
5066 /****************************/
5071 /****************************************/
5072 /* Counter not initialised see function */
5073 /* "i_APCI1710_InitCounter" */
5074 /****************************************/
5076 DPRINTK("Counter not initialised\n");
5080 /*************************************************/
5081 /* The selected module number parameter is wrong */
5082 /*************************************************/
5084 DPRINTK("The selected module number parameter is wrong\n");
5088 return i_ReturnValue;
5092 +----------------------------------------------------------------------------+
5093 | Function Name : _INT_ i_APCI1710_ReadFrequencyMeasurement |
5094 | (unsigned char_ b_BoardHandle, |
5095 | unsigned char_ b_ModulNbr, |
5096 | unsigned char *_ pb_Status, |
5097 | PULONG_ pul_ReadValue) |
5098 +----------------------------------------------------------------------------+
5099 | Task : Returns the status (pb_Status) and the number of |
5100 | increments in the set time. |
5101 | See function " i_APCI1710_InitFrequencyMeasurement " |
5102 +----------------------------------------------------------------------------+
5103 | Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 |
5104 | unsigned char_ b_ModulNbr : Number of the module to be |
5105 | configured (0 to 3) |
5106 +----------------------------------------------------------------------------+
5107 | Output Parameters : unsigned char *_ pb_Status : Returns the frequency |
5108 | measurement status |
5109 | 0 : Counting cycle not |
5111 | 1 : Counting cycle started. |
5112 | 2 : Counting cycle stopped. |
5113 | The measurement cycle is |
5115 | unsigned char *_ pb_UDStatus : 0 : Counter progress in the |
5116 | selected mode down |
5117 | 1 : Counter progress in the |
5118 | selected mode up |
5119 | PULONG_ pul_ReadValue : Return the number of |
5120 | increments in the defined |
5122 +----------------------------------------------------------------------------+
5123 | Return Value : 0: No error |
5124 | -1: The handle parameter of the board is wrong |
5125 | -2: The selected module number is wrong |
5126 | -3: Counter not initialised see function |
5127 | "i_APCI1710_InitCounter" |
5128 | -4: Frequency measurement logic not initialised. |
5129 | See function "i_APCI1710_InitFrequencyMeasurement" |
5130 +----------------------------------------------------------------------------+
5132 static int i_APCI1710_ReadFrequencyMeasurement(struct comedi_device *dev,
5133 unsigned char b_ModulNbr,
5134 unsigned char *pb_Status,
5135 unsigned char *pb_UDStatus,
5136 unsigned int *pul_ReadValue)
5138 struct addi_private *devpriv = dev->private;
5139 int i_ReturnValue = 0;
5140 unsigned int ui_16BitValue;
5141 unsigned int dw_StatusReg;
5143 /**************************/
5144 /* Test the module number */
5145 /**************************/
5147 if (b_ModulNbr < 4) {
5148 /*******************************/
5149 /* Test if counter initialised */
5150 /*******************************/
5153 s_ModuleInfo[b_ModulNbr].
5154 s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) {
5155 /********************************************/
5156 /* Test if frequency measurement initialised */
5157 /********************************************/
5160 s_ModuleInfo[b_ModulNbr].
5161 s_SiemensCounterInfo.
5162 s_InitFlag.b_FrequencyMeasurementInit == 1) {
5163 /******************/
5164 /* Test if enable */
5165 /******************/
5168 s_ModuleInfo[b_ModulNbr].
5169 s_SiemensCounterInfo.
5171 b_FrequencyMeasurementEnable == 1) {
5172 /*******************/
5173 /* Read the status */
5174 /*******************/
5177 inl(devpriv->s_BoardInfos.
5181 /**************************/
5182 /* Test if frequency stop */
5183 /**************************/
5185 if (dw_StatusReg & 1) {
5188 (unsigned char) ((dw_StatusReg >>
5191 /******************/
5192 /* Read the value */
5193 /******************/
5201 if (*pb_UDStatus == 0) {
5202 /*************************/
5203 /* Test the counter mode */
5204 /*************************/
5206 if ((devpriv->s_ModuleInfo[b_ModulNbr].s_SiemensCounterInfo.s_ModeRegister.s_ByteModeRegister.b_ModeRegister1 & APCI1710_16BIT_COUNTER) == APCI1710_16BIT_COUNTER) {
5207 /****************************************/
5208 /* Test if 16-bit counter 1 pulse occur */
5209 /****************************************/
5211 if ((*pul_ReadValue & 0xFFFFU) != 0) {
5230 /****************************************/
5231 /* Test if 16-bit counter 2 pulse occur */
5232 /****************************************/
5234 if ((*pul_ReadValue & 0xFFFF0000UL) != 0) {
5251 (0xFFFFU - ui_16BitValue) << 16);
5254 if (*pul_ReadValue != 0) {
5263 if (*pb_UDStatus == 1) {
5264 /****************************************/
5265 /* Test if 16-bit counter 2 pulse occur */
5266 /****************************************/
5268 if ((*pul_ReadValue & 0xFFFF0000UL) != 0) {
5285 (0xFFFFU - ui_16BitValue) << 16);
5290 /****************************************/
5291 /* Test if 16-bit counter 1 pulse occur */
5292 /****************************************/
5294 if ((*pul_ReadValue & 0xFFFFU) != 0) {
5324 /***********************************************/
5325 /* Frequency measurement logic not initialised */
5326 /***********************************************/
5328 DPRINTK("Frequency measurement logic not initialised\n");
5332 /****************************************/
5333 /* Counter not initialised see function */
5334 /* "i_APCI1710_InitCounter" */
5335 /****************************************/
5337 DPRINTK("Counter not initialised\n");
5341 /*************************************************/
5342 /* The selected module number parameter is wrong */
5343 /*************************************************/
5345 DPRINTK("The selected module number parameter is wrong\n");
5349 return i_ReturnValue;
5352 * Read and Get functions for INC_CPT
5354 static int i_APCI1710_InsnReadINCCPT(struct comedi_device *dev,
5355 struct comedi_subdevice *s,
5356 struct comedi_insn *insn,
5359 struct addi_private *devpriv = dev->private;
5360 unsigned int ui_ReadType;
5361 int i_ReturnValue = 0;
5363 ui_ReadType = CR_CHAN(insn->chanspec);
5365 devpriv->tsk_Current = current; /* Save the current process task structure */
5366 switch (ui_ReadType) {
5367 case APCI1710_INCCPT_READLATCHREGISTERSTATUS:
5368 i_ReturnValue = i_APCI1710_ReadLatchRegisterStatus(dev,
5369 (unsigned char) CR_AREF(insn->chanspec),
5370 (unsigned char) CR_RANGE(insn->chanspec), (unsigned char *) &data[0]);
5373 case APCI1710_INCCPT_READLATCHREGISTERVALUE:
5374 i_ReturnValue = i_APCI1710_ReadLatchRegisterValue(dev,
5375 (unsigned char) CR_AREF(insn->chanspec),
5376 (unsigned char) CR_RANGE(insn->chanspec), (unsigned int *) &data[0]);
5377 printk("Latch Register Value %d\n", data[0]);
5380 case APCI1710_INCCPT_READ16BITCOUNTERVALUE:
5381 i_ReturnValue = i_APCI1710_Read16BitCounterValue(dev,
5382 (unsigned char) CR_AREF(insn->chanspec),
5383 (unsigned char) CR_RANGE(insn->chanspec), (unsigned int *) &data[0]);
5386 case APCI1710_INCCPT_READ32BITCOUNTERVALUE:
5387 i_ReturnValue = i_APCI1710_Read32BitCounterValue(dev,
5388 (unsigned char) CR_AREF(insn->chanspec), (unsigned int *) &data[0]);
5391 case APCI1710_INCCPT_GETINDEXSTATUS:
5392 i_ReturnValue = i_APCI1710_GetIndexStatus(dev,
5393 (unsigned char) CR_AREF(insn->chanspec), (unsigned char *) &data[0]);
5396 case APCI1710_INCCPT_GETREFERENCESTATUS:
5397 i_ReturnValue = i_APCI1710_GetReferenceStatus(dev,
5398 (unsigned char) CR_AREF(insn->chanspec), (unsigned char *) &data[0]);
5401 case APCI1710_INCCPT_GETUASSTATUS:
5402 i_ReturnValue = i_APCI1710_GetUASStatus(dev,
5403 (unsigned char) CR_AREF(insn->chanspec), (unsigned char *) &data[0]);
5406 case APCI1710_INCCPT_GETCBSTATUS:
5407 i_ReturnValue = i_APCI1710_GetCBStatus(dev,
5408 (unsigned char) CR_AREF(insn->chanspec), (unsigned char *) &data[0]);
5411 case APCI1710_INCCPT_GET16BITCBSTATUS:
5412 i_ReturnValue = i_APCI1710_Get16BitCBStatus(dev,
5413 (unsigned char) CR_AREF(insn->chanspec),
5414 (unsigned char *) &data[0], (unsigned char *) &data[1]);
5417 case APCI1710_INCCPT_GETUDSTATUS:
5418 i_ReturnValue = i_APCI1710_GetUDStatus(dev,
5419 (unsigned char) CR_AREF(insn->chanspec), (unsigned char *) &data[0]);
5423 case APCI1710_INCCPT_GETINTERRUPTUDLATCHEDSTATUS:
5424 i_ReturnValue = i_APCI1710_GetInterruptUDLatchedStatus(dev,
5425 (unsigned char) CR_AREF(insn->chanspec), (unsigned char *) &data[0]);
5428 case APCI1710_INCCPT_READFREQUENCYMEASUREMENT:
5429 i_ReturnValue = i_APCI1710_ReadFrequencyMeasurement(dev,
5430 (unsigned char) CR_AREF(insn->chanspec),
5431 (unsigned char *) &data[0],
5432 (unsigned char *) &data[1], (unsigned int *) &data[2]);
5435 case APCI1710_INCCPT_READINTERRUPT:
5436 data[0] = devpriv->s_InterruptParameters.
5437 s_FIFOInterruptParameters[devpriv->
5438 s_InterruptParameters.ui_Read].b_OldModuleMask;
5439 data[1] = devpriv->s_InterruptParameters.
5440 s_FIFOInterruptParameters[devpriv->
5441 s_InterruptParameters.ui_Read].ul_OldInterruptMask;
5442 data[2] = devpriv->s_InterruptParameters.
5443 s_FIFOInterruptParameters[devpriv->
5444 s_InterruptParameters.ui_Read].ul_OldCounterLatchValue;
5446 /**************************/
5447 /* Increment the read FIFO */
5448 /***************************/
5451 s_InterruptParameters.
5452 ui_Read = (devpriv->s_InterruptParameters.
5453 ui_Read + 1) % APCI1710_SAVE_INTERRUPT;
5458 printk("ReadType Parameter wrong\n");
5461 if (i_ReturnValue >= 0)
5462 i_ReturnValue = insn->n;
5463 return i_ReturnValue;