Commit | Line | Data |
---|---|---|
15d8826a GKH |
1 | /* |
2 | * Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module. | |
3 | * | |
4 | * ADDI-DATA GmbH | |
5 | * Dieselstrasse 3 | |
6 | * D-77833 Ottersweier | |
7 | * Tel: +19(0)7223/9493-0 | |
8 | * Fax: +49(0)7223/9493-92 | |
9 | * http://www.addi-data-com | |
10 | * info@addi-data.com | |
11 | * | |
12 | * This program is free software; you can redistribute it and/or modify it | |
13 | * under the terms of the GNU General Public License as published by the Free | |
14 | * Software Foundation; either version 2 of the License, or (at your option) | |
15 | * any later version. | |
16 | */ | |
17 | ||
18 | #define APCI1710_16BIT_COUNTER 0x10 | |
19 | #define APCI1710_32BIT_COUNTER 0x0 | |
20 | #define APCI1710_QUADRUPLE_MODE 0x0 | |
21 | #define APCI1710_DOUBLE_MODE 0x3 | |
22 | #define APCI1710_SIMPLE_MODE 0xF | |
23 | #define APCI1710_DIRECT_MODE 0x80 | |
24 | #define APCI1710_HYSTERESIS_ON 0x60 | |
25 | #define APCI1710_HYSTERESIS_OFF 0x0 | |
26 | #define APCI1710_INCREMENT 0x60 | |
27 | #define APCI1710_DECREMENT 0x0 | |
28 | #define APCI1710_LATCH_COUNTER 0x1 | |
29 | #define APCI1710_CLEAR_COUNTER 0x0 | |
30 | #define APCI1710_LOW 0x0 | |
31 | #define APCI1710_HIGH 0x1 | |
c995fe94 ADG |
32 | |
33 | /*********************/ | |
34 | /* Version 0600-0229 */ | |
35 | /*********************/ | |
15d8826a GKH |
36 | #define APCI1710_HIGH_EDGE_CLEAR_COUNTER 0x0 |
37 | #define APCI1710_HIGH_EDGE_LATCH_COUNTER 0x1 | |
38 | #define APCI1710_LOW_EDGE_CLEAR_COUNTER 0x2 | |
39 | #define APCI1710_LOW_EDGE_LATCH_COUNTER 0x3 | |
40 | #define APCI1710_HIGH_EDGE_LATCH_AND_CLEAR_COUNTER 0x4 | |
41 | #define APCI1710_LOW_EDGE_LATCH_AND_CLEAR_COUNTER 0x5 | |
c995fe94 ADG |
42 | #define APCI1710_SOURCE_0 0x0 |
43 | #define APCI1710_SOURCE_1 0x1 | |
44 | ||
15d8826a GKH |
45 | #define APCI1710_30MHZ 30 |
46 | #define APCI1710_33MHZ 33 | |
47 | #define APCI1710_40MHZ 40 | |
c995fe94 ADG |
48 | |
49 | #define APCI1710_ENABLE_LATCH_INT 0x80 | |
50 | #define APCI1710_DISABLE_LATCH_INT (~APCI1710_ENABLE_LATCH_INT) | |
51 | ||
15d8826a GKH |
52 | #define APCI1710_INDEX_LATCH_COUNTER 0x10 |
53 | #define APCI1710_INDEX_AUTO_MODE 0x8 | |
54 | #define APCI1710_ENABLE_INDEX 0x4 | |
55 | #define APCI1710_DISABLE_INDEX (~APCI1710_ENABLE_INDEX) | |
56 | #define APCI1710_ENABLE_LATCH_AND_CLEAR 0x8 | |
57 | #define APCI1710_DISABLE_LATCH_AND_CLEAR (~APCI1710_ENABLE_LATCH_AND_CLEAR) | |
c995fe94 | 58 | #define APCI1710_SET_LOW_INDEX_LEVEL 0x4 |
15d8826a | 59 | #define APCI1710_SET_HIGH_INDEX_LEVEL (~APCI1710_SET_LOW_INDEX_LEVEL) |
c995fe94 ADG |
60 | #define APCI1710_INVERT_INDEX_RFERENCE 0x2 |
61 | #define APCI1710_DEFAULT_INDEX_RFERENCE (~APCI1710_INVERT_INDEX_RFERENCE) | |
62 | ||
15d8826a GKH |
63 | #define APCI1710_ENABLE_INDEX_INT 0x1 |
64 | #define APCI1710_DISABLE_INDEX_INT (~APCI1710_ENABLE_INDEX_INT) | |
c995fe94 | 65 | |
15d8826a GKH |
66 | #define APCI1710_ENABLE_FREQUENCY 0x4 |
67 | #define APCI1710_DISABLE_FREQUENCY (~APCI1710_ENABLE_FREQUENCY) | |
c995fe94 | 68 | |
15d8826a GKH |
69 | #define APCI1710_ENABLE_FREQUENCY_INT 0x8 |
70 | #define APCI1710_DISABLE_FREQUENCY_INT (~APCI1710_ENABLE_FREQUENCY_INT) | |
c995fe94 ADG |
71 | |
72 | #define APCI1710_ENABLE_40MHZ_FREQUENCY 0x40 | |
73 | #define APCI1710_DISABLE_40MHZ_FREQUENCY (~APCI1710_ENABLE_40MHZ_FREQUENCY) | |
74 | ||
75 | #define APCI1710_ENABLE_40MHZ_FILTER 0x80 | |
76 | #define APCI1710_DISABLE_40MHZ_FILTER (~APCI1710_ENABLE_40MHZ_FILTER) | |
77 | ||
15d8826a GKH |
78 | #define APCI1710_ENABLE_COMPARE_INT 0x2 |
79 | #define APCI1710_DISABLE_COMPARE_INT (~APCI1710_ENABLE_COMPARE_INT) | |
80 | ||
81 | #define APCI1710_ENABLE_INDEX_ACTION 0x20 | |
82 | #define APCI1710_DISABLE_INDEX_ACTION (~APCI1710_ENABLE_INDEX_ACTION) | |
83 | #define APCI1710_REFERENCE_HIGH 0x40 | |
84 | #define APCI1710_REFERENCE_LOW (~APCI1710_REFERENCE_HIGH) | |
85 | ||
86 | #define APCI1710_TOR_GATE_LOW 0x40 | |
87 | #define APCI1710_TOR_GATE_HIGH (~APCI1710_TOR_GATE_LOW) | |
88 | ||
89 | /* INSN CONFIG */ | |
90 | #define APCI1710_INCCPT_INITCOUNTER 100 | |
91 | #define APCI1710_INCCPT_COUNTERAUTOTEST 101 | |
92 | #define APCI1710_INCCPT_INITINDEX 102 | |
93 | #define APCI1710_INCCPT_INITREFERENCE 103 | |
94 | #define APCI1710_INCCPT_INITEXTERNALSTROBE 104 | |
95 | #define APCI1710_INCCPT_INITCOMPARELOGIC 105 | |
96 | #define APCI1710_INCCPT_INITFREQUENCYMEASUREMENT 106 | |
97 | ||
98 | /* INSN READ */ | |
99 | #define APCI1710_INCCPT_READLATCHREGISTERSTATUS 200 | |
100 | #define APCI1710_INCCPT_READLATCHREGISTERVALUE 201 | |
101 | #define APCI1710_INCCPT_READ16BITCOUNTERVALUE 202 | |
102 | #define APCI1710_INCCPT_READ32BITCOUNTERVALUE 203 | |
103 | #define APCI1710_INCCPT_GETINDEXSTATUS 204 | |
104 | #define APCI1710_INCCPT_GETREFERENCESTATUS 205 | |
105 | #define APCI1710_INCCPT_GETUASSTATUS 206 | |
106 | #define APCI1710_INCCPT_GETCBSTATUS 207 | |
107 | #define APCI1710_INCCPT_GET16BITCBSTATUS 208 | |
108 | #define APCI1710_INCCPT_GETUDSTATUS 209 | |
109 | #define APCI1710_INCCPT_GETINTERRUPTUDLATCHEDSTATUS 210 | |
110 | #define APCI1710_INCCPT_READFREQUENCYMEASUREMENT 211 | |
111 | #define APCI1710_INCCPT_READINTERRUPT 212 | |
112 | ||
113 | /* INSN BITS */ | |
114 | #define APCI1710_INCCPT_CLEARCOUNTERVALUE 300 | |
115 | #define APCI1710_INCCPT_CLEARALLCOUNTERVALUE 301 | |
116 | #define APCI1710_INCCPT_SETINPUTFILTER 302 | |
117 | #define APCI1710_INCCPT_LATCHCOUNTER 303 | |
118 | #define APCI1710_INCCPT_SETINDEXANDREFERENCESOURCE 304 | |
119 | #define APCI1710_INCCPT_SETDIGITALCHLON 305 | |
120 | #define APCI1710_INCCPT_SETDIGITALCHLOFF 306 | |
121 | ||
122 | /* INSN WRITE */ | |
123 | #define APCI1710_INCCPT_ENABLELATCHINTERRUPT 400 | |
124 | #define APCI1710_INCCPT_DISABLELATCHINTERRUPT 401 | |
125 | #define APCI1710_INCCPT_WRITE16BITCOUNTERVALUE 402 | |
126 | #define APCI1710_INCCPT_WRITE32BITCOUNTERVALUE 403 | |
127 | #define APCI1710_INCCPT_ENABLEINDEX 404 | |
128 | #define APCI1710_INCCPT_DISABLEINDEX 405 | |
129 | #define APCI1710_INCCPT_ENABLECOMPARELOGIC 406 | |
130 | #define APCI1710_INCCPT_DISABLECOMPARELOGIC 407 | |
131 | #define APCI1710_INCCPT_ENABLEFREQUENCYMEASUREMENT 408 | |
132 | #define APCI1710_INCCPT_DISABLEFREQUENCYMEASUREMENT 409 | |
c995fe94 ADG |
133 | |
134 | /************ Main Functions *************/ | |
34c43922 | 135 | INT i_APCI1710_InsnConfigINCCPT(struct comedi_device *dev, struct comedi_subdevice *s, |
90035c08 | 136 | struct comedi_insn *insn, unsigned int * data); |
c995fe94 | 137 | |
34c43922 | 138 | INT i_APCI1710_InsnBitsINCCPT(struct comedi_device *dev, struct comedi_subdevice * s, |
90035c08 | 139 | struct comedi_insn *insn, unsigned int * data); |
c995fe94 | 140 | |
34c43922 | 141 | INT i_APCI1710_InsnWriteINCCPT(struct comedi_device *dev, struct comedi_subdevice * s, |
90035c08 | 142 | struct comedi_insn *insn, unsigned int * data); |
c995fe94 | 143 | |
34c43922 | 144 | INT i_APCI1710_InsnReadINCCPT(struct comedi_device *dev, struct comedi_subdevice * s, |
90035c08 | 145 | struct comedi_insn *insn, unsigned int * data); |
c995fe94 ADG |
146 | |
147 | /*********** Supplementary Functions********/ | |
148 | ||
15d8826a | 149 | /* INSN CONFIG */ |
71b5f4f1 | 150 | INT i_APCI1710_InitCounter(struct comedi_device *dev, |
15d8826a GKH |
151 | BYTE b_ModulNbr, |
152 | BYTE b_CounterRange, | |
153 | BYTE b_FirstCounterModus, | |
154 | BYTE b_FirstCounterOption, | |
155 | BYTE b_SecondCounterModus, | |
156 | BYTE b_SecondCounterOption); | |
c995fe94 | 157 | |
71b5f4f1 | 158 | INT i_APCI1710_CounterAutoTest(struct comedi_device *dev, PBYTE pb_TestStatus); |
c995fe94 | 159 | |
71b5f4f1 | 160 | INT i_APCI1710_InitIndex(struct comedi_device *dev, |
15d8826a GKH |
161 | BYTE b_ModulNbr, |
162 | BYTE b_ReferenceAction, | |
163 | BYTE b_IndexOperation, BYTE b_AutoMode, | |
164 | BYTE b_InterruptEnable); | |
c995fe94 | 165 | |
71b5f4f1 | 166 | INT i_APCI1710_InitReference(struct comedi_device *dev, |
15d8826a | 167 | BYTE b_ModulNbr, BYTE b_ReferenceLevel); |
c995fe94 | 168 | |
71b5f4f1 | 169 | INT i_APCI1710_InitExternalStrobe(struct comedi_device *dev, |
15d8826a GKH |
170 | BYTE b_ModulNbr, BYTE b_ExternalStrobe, |
171 | BYTE b_ExternalStrobeLevel); | |
c995fe94 | 172 | |
71b5f4f1 | 173 | INT i_APCI1710_InitCompareLogic(struct comedi_device *dev, |
15d8826a | 174 | BYTE b_ModulNbr, UINT ui_CompareValue); |
c995fe94 | 175 | |
71b5f4f1 | 176 | INT i_APCI1710_InitFrequencyMeasurement(struct comedi_device *dev, |
15d8826a GKH |
177 | BYTE b_ModulNbr, |
178 | BYTE b_PCIInputClock, | |
179 | BYTE b_TimingUnity, | |
180 | ULONG ul_TimingInterval, | |
181 | PULONG pul_RealTimingInterval); | |
c995fe94 | 182 | |
15d8826a | 183 | /* INSN BITS */ |
71b5f4f1 | 184 | INT i_APCI1710_ClearCounterValue(struct comedi_device *dev, BYTE b_ModulNbr); |
c995fe94 | 185 | |
71b5f4f1 | 186 | INT i_APCI1710_ClearAllCounterValue(struct comedi_device *dev); |
c995fe94 | 187 | |
71b5f4f1 | 188 | INT i_APCI1710_SetInputFilter(struct comedi_device *dev, |
15d8826a GKH |
189 | BYTE b_ModulNbr, BYTE b_PCIInputClock, |
190 | BYTE b_Filter); | |
c995fe94 | 191 | |
71b5f4f1 | 192 | INT i_APCI1710_LatchCounter(struct comedi_device *dev, |
15d8826a | 193 | BYTE b_ModulNbr, BYTE b_LatchReg); |
c995fe94 | 194 | |
71b5f4f1 | 195 | INT i_APCI1710_SetIndexAndReferenceSource(struct comedi_device *dev, |
15d8826a GKH |
196 | BYTE b_ModulNbr, |
197 | BYTE b_SourceSelection); | |
c995fe94 | 198 | |
71b5f4f1 | 199 | INT i_APCI1710_SetDigitalChlOn(struct comedi_device *dev, BYTE b_ModulNbr); |
c995fe94 | 200 | |
71b5f4f1 | 201 | INT i_APCI1710_SetDigitalChlOff(struct comedi_device *dev, BYTE b_ModulNbr); |
c995fe94 | 202 | |
15d8826a | 203 | /* INSN WRITE */ |
71b5f4f1 | 204 | INT i_APCI1710_EnableLatchInterrupt(struct comedi_device *dev, BYTE b_ModulNbr); |
c995fe94 | 205 | |
71b5f4f1 | 206 | INT i_APCI1710_DisableLatchInterrupt(struct comedi_device *dev, BYTE b_ModulNbr); |
c995fe94 | 207 | |
71b5f4f1 | 208 | INT i_APCI1710_Write16BitCounterValue(struct comedi_device *dev, |
15d8826a GKH |
209 | BYTE b_ModulNbr, BYTE b_SelectedCounter, |
210 | UINT ui_WriteValue); | |
c995fe94 | 211 | |
71b5f4f1 | 212 | INT i_APCI1710_Write32BitCounterValue(struct comedi_device *dev, |
15d8826a | 213 | BYTE b_ModulNbr, ULONG ul_WriteValue); |
c995fe94 | 214 | |
71b5f4f1 | 215 | INT i_APCI1710_EnableIndex(struct comedi_device *dev, BYTE b_ModulNbr); |
c995fe94 | 216 | |
71b5f4f1 | 217 | INT i_APCI1710_DisableIndex(struct comedi_device *dev, BYTE b_ModulNbr); |
c995fe94 | 218 | |
71b5f4f1 | 219 | INT i_APCI1710_EnableCompareLogic(struct comedi_device *dev, BYTE b_ModulNbr); |
c995fe94 | 220 | |
71b5f4f1 | 221 | INT i_APCI1710_DisableCompareLogic(struct comedi_device *dev, BYTE b_ModulNbr); |
c995fe94 | 222 | |
71b5f4f1 | 223 | INT i_APCI1710_EnableFrequencyMeasurement(struct comedi_device *dev, |
15d8826a GKH |
224 | BYTE b_ModulNbr, |
225 | BYTE b_InterruptEnable); | |
c995fe94 | 226 | |
71b5f4f1 | 227 | INT i_APCI1710_DisableFrequencyMeasurement(struct comedi_device *dev, |
15d8826a | 228 | BYTE b_ModulNbr); |
c995fe94 | 229 | |
15d8826a | 230 | /* INSN READ */ |
71b5f4f1 | 231 | INT i_APCI1710_ReadLatchRegisterStatus(struct comedi_device *dev, |
15d8826a GKH |
232 | BYTE b_ModulNbr, BYTE b_LatchReg, |
233 | PBYTE pb_LatchStatus); | |
c995fe94 | 234 | |
71b5f4f1 | 235 | INT i_APCI1710_ReadLatchRegisterValue(struct comedi_device *dev, |
15d8826a GKH |
236 | BYTE b_ModulNbr, BYTE b_LatchReg, |
237 | PULONG pul_LatchValue); | |
c995fe94 | 238 | |
71b5f4f1 | 239 | INT i_APCI1710_Read16BitCounterValue(struct comedi_device *dev, |
15d8826a GKH |
240 | BYTE b_ModulNbr, BYTE b_SelectedCounter, |
241 | PUINT pui_CounterValue); | |
c995fe94 | 242 | |
71b5f4f1 | 243 | INT i_APCI1710_Read32BitCounterValue(struct comedi_device *dev, |
15d8826a | 244 | BYTE b_ModulNbr, PULONG pul_CounterValue); |
c995fe94 | 245 | |
71b5f4f1 | 246 | INT i_APCI1710_GetIndexStatus(struct comedi_device *dev, |
15d8826a | 247 | BYTE b_ModulNbr, PBYTE pb_IndexStatus); |
c995fe94 | 248 | |
71b5f4f1 | 249 | INT i_APCI1710_GetReferenceStatus(struct comedi_device *dev, |
15d8826a | 250 | BYTE b_ModulNbr, PBYTE pb_ReferenceStatus); |
c995fe94 | 251 | |
71b5f4f1 | 252 | INT i_APCI1710_GetUASStatus(struct comedi_device *dev, |
15d8826a | 253 | BYTE b_ModulNbr, PBYTE pb_UASStatus); |
c995fe94 | 254 | |
71b5f4f1 | 255 | INT i_APCI1710_GetCBStatus(struct comedi_device *dev, |
15d8826a | 256 | BYTE b_ModulNbr, PBYTE pb_CBStatus); |
c995fe94 | 257 | |
71b5f4f1 | 258 | INT i_APCI1710_Get16BitCBStatus(struct comedi_device *dev, |
15d8826a GKH |
259 | BYTE b_ModulNbr, PBYTE pb_CBStatusCounter0, |
260 | PBYTE pb_CBStatusCounter1); | |
c995fe94 | 261 | |
71b5f4f1 | 262 | INT i_APCI1710_GetUDStatus(struct comedi_device *dev, |
15d8826a | 263 | BYTE b_ModulNbr, PBYTE pb_UDStatus); |
c995fe94 | 264 | |
71b5f4f1 | 265 | INT i_APCI1710_GetInterruptUDLatchedStatus(struct comedi_device *dev, |
15d8826a | 266 | BYTE b_ModulNbr, PBYTE pb_UDStatus); |
c995fe94 | 267 | |
71b5f4f1 | 268 | INT i_APCI1710_ReadFrequencyMeasurement(struct comedi_device *dev, |
15d8826a GKH |
269 | BYTE b_ModulNbr, |
270 | PBYTE pb_Status, PBYTE pb_UDStatus, | |
271 | PULONG pul_ReadValue); |