staging: comedi: remove FSF address from boilerplate text
[deliverable/linux.git] / drivers / staging / comedi / drivers / addi-data / hwdrv_apci035.c
CommitLineData
c995fe94
ADG
1/**
2@verbatim
3
4Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module.
5
356cdbcb
BP
6 ADDI-DATA GmbH
7 Dieselstrasse 3
8 D-77833 Ottersweier
9 Tel: +19(0)7223/9493-0
10 Fax: +49(0)7223/9493-92
25417922 11 http://www.addi-data.com
356cdbcb 12 info@addi-data.com
c995fe94
ADG
13
14This 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.
15
16This 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.
17
c995fe94
ADG
18@endverbatim
19*/
20/*
21
22 +-----------------------------------------------------------------------+
23 | (C) ADDI-DATA GmbH Dieselstraße 3 D-77833 Ottersweier |
24 +-----------------------------------------------------------------------+
25 | Tel : +49 (0) 7223/9493-0 | email : info@addi-data.com |
26 | Fax : +49 (0) 7223/9493-92 | Internet : http://www.addi-data.com |
27 +-------------------------------+---------------------------------------+
28 | Project : APCI-035 | Compiler : GCC |
29 | Module name : hwdrv_apci035.c | Version : 2.96 |
30 +-------------------------------+---------------------------------------+
31 | Project manager: Eric Stolz | Date : 02/12/2002 |
32 +-------------------------------+---------------------------------------+
6cd5a9a3 33 | Description : Hardware Layer Access For APCI-035 |
c995fe94
ADG
34 +-----------------------------------------------------------------------+
35 | UPDATES |
36 +----------+-----------+------------------------------------------------+
37 | Date | Author | Description of updates |
38 +----------+-----------+------------------------------------------------+
39 | | | |
40 | | | |
41 | | | |
42 +----------+-----------+------------------------------------------------+
43*/
44
9b2b9a34
HS
45/* Card Specific information */
46#define APCI035_ADDRESS_RANGE 255
47
48/* Timer / Watchdog Related Defines */
49#define APCI035_TCW_SYNC_ENABLEDISABLE 0
50#define APCI035_TCW_RELOAD_VALUE 4
51#define APCI035_TCW_TIMEBASE 8
52#define APCI035_TCW_PROG 12
53#define APCI035_TCW_TRIG_STATUS 16
54#define APCI035_TCW_IRQ 20
55#define APCI035_TCW_WARN_TIMEVAL 24
56#define APCI035_TCW_WARN_TIMEBASE 28
57
58#define ADDIDATA_TIMER 0
59/* #define ADDIDATA_WATCHDOG 1 */
60
61#define APCI035_TW1 0
62#define APCI035_TW2 32
63#define APCI035_TW3 64
64#define APCI035_TW4 96
65
66#define APCI035_AI_OFFSET 0
67#define APCI035_TEMP 128
68#define APCI035_ALR_SEQ 4
69#define APCI035_START_STOP_INDEX 8
70#define APCI035_ALR_START_STOP 12
71#define APCI035_ALR_IRQ 16
72#define APCI035_EOS 20
73#define APCI035_CHAN_NO 24
74#define APCI035_CHAN_VAL 28
75#define APCI035_CONV_TIME_TIME_BASE 36
76#define APCI035_RELOAD_CONV_TIME_VAL 32
77#define APCI035_DELAY_TIME_TIME_BASE 44
78#define APCI035_RELOAD_DELAY_TIME_VAL 40
79#define ENABLE_EXT_TRIG 1
80#define ENABLE_EXT_GATE 2
81#define ENABLE_EXT_TRIG_GATE 3
82
83#define ANALOG_INPUT 0
84#define TEMPERATURE 1
85#define RESISTANCE 2
86
87#define ADDIDATA_GREATER_THAN_TEST 0
88#define ADDIDATA_LESS_THAN_TEST 1
89
90#define APCI035_MAXVOLT 2.5
91
92#define ADDIDATA_UNIPOLAR 1
93#define ADDIDATA_BIPOLAR 2
94
9b2b9a34
HS
95/* ANALOG INPUT RANGE */
96static struct comedi_lrange range_apci035_ai = {
97 8, {
98 BIP_RANGE(10),
99 BIP_RANGE(5),
100 BIP_RANGE(2),
101 BIP_RANGE(1),
102 UNI_RANGE(10),
103 UNI_RANGE(5),
104 UNI_RANGE(2),
105 UNI_RANGE(1)
106 }
107};
108
08b93e7b
GKH
109static int i_WatchdogNbr = 0;
110static int i_Temp = 0;
111static int i_Flag = 1;
c995fe94
ADG
112/*
113+----------------------------------------------------------------------------+
114| Function Name : int i_APCI035_ConfigTimerWatchdog |
34c43922 115| (struct comedi_device *dev,struct comedi_subdevice *s, |
90035c08 116| struct comedi_insn *insn,unsigned int *data) |
c995fe94
ADG
117+----------------------------------------------------------------------------+
118| Task : Configures The Timer , Counter or Watchdog |
119+----------------------------------------------------------------------------+
71b5f4f1 120| Input Parameters : struct comedi_device *dev : Driver handle |
117102b0 121| unsigned int *data : Data Pointer contains |
c995fe94
ADG
122| configuration parameters as below |
123| |
124| data[0] : 0 Configure As Timer |
125| 1 Configure As Watchdog |
356cdbcb 126| data[1] : Watchdog number
c995fe94
ADG
127| data[2] : Time base Unit |
128| data[3] : Reload Value |
356cdbcb
BP
129| data[4] : External Trigger |
130| 1:Enable
131| 0:Disable
132| data[5] :External Trigger Level
133| 00 Trigger Disabled
134| 01 Trigger Enabled (Low level)
135| 10 Trigger Enabled (High Level)
136| 11 Trigger Enabled (High/Low level)
137| data[6] : External Gate |
138| 1:Enable
139| 0:Disable
140| data[7] : External Gate level
141| 00 Gate Disabled
142| 01 Gate Enabled (Low level)
143| 10 Gate Enabled (High Level)
144| data[8] :Warning Relay
145| 1: ENABLE
146| 0: DISABLE
147| data[9] :Warning Delay available
148| data[10] :Warning Relay Time unit
149| data[11] :Warning Relay Time Reload value
150| data[12] :Reset Relay
151| 1 : ENABLE
152| 0 : DISABLE
153| data[13] :Interrupt
154| 1 : ENABLE
155| 0 : DISABLE
156|
c995fe94
ADG
157|
158+----------------------------------------------------------------------------+
159| Output Parameters : -- |
160+----------------------------------------------------------------------------+
161| Return Value : TRUE : No error occur |
162| : FALSE : Error occur. Return the error |
163| |
164+----------------------------------------------------------------------------+
165*/
dcd7ef33
HS
166static int i_APCI035_ConfigTimerWatchdog(struct comedi_device *dev,
167 struct comedi_subdevice *s,
168 struct comedi_insn *insn,
169 unsigned int *data)
c995fe94 170{
843690b7 171 struct addi_private *devpriv = dev->private;
117102b0
BP
172 unsigned int ui_Status = 0;
173 unsigned int ui_Command = 0;
174 unsigned int ui_Mode = 0;
843690b7 175
c995fe94
ADG
176 i_Temp = 0;
177 devpriv->tsk_Current = current;
178 devpriv->b_TimerSelectMode = data[0];
179 i_WatchdogNbr = data[1];
180 if (data[0] == 0) {
181 ui_Mode = 2;
182 } else {
183 ui_Mode = 0;
184 }
2696fb57 185/* ui_Command = inl(devpriv->iobase+((i_WatchdogNbr-1)*32)+12); */
c995fe94 186 ui_Command = 0;
2696fb57 187/* ui_Command = ui_Command & 0xFFFFF9FEUL; */
c995fe94
ADG
188 outl(ui_Command, devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12);
189 ui_Command = 0;
190 ui_Command = inl(devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12);
191/************************/
192/* Set the reload value */
193/************************/
194 outl(data[3], devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 4);
195/*********************/
196/* Set the time unit */
197/*********************/
198 outl(data[2], devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 8);
199 if (data[0] == ADDIDATA_TIMER) {
200
201 /******************************/
202 /* Set the mode : */
203 /* - Disable the hardware */
204 /* - Disable the counter mode */
205 /* - Disable the warning */
206 /* - Disable the reset */
207 /* - Enable the timer mode */
208 /* - Set the timer mode */
209 /******************************/
210
211 ui_Command =
212 (ui_Command & 0xFFF719E2UL) | ui_Mode << 13UL | 0x10UL;
213
2696fb57 214 } /* if (data[0] == ADDIDATA_TIMER) */
c995fe94
ADG
215 else {
216 if (data[0] == ADDIDATA_WATCHDOG) {
217
218 /******************************/
219 /* Set the mode : */
220 /* - Disable the hardware */
221 /* - Disable the counter mode */
222 /* - Disable the warning */
223 /* - Disable the reset */
224 /* - Disable the timer mode */
225 /******************************/
226
227 ui_Command = ui_Command & 0xFFF819E2UL;
228
229 } else {
230 printk("\n The parameter for Timer/watchdog selection is in error\n");
231 return -EINVAL;
232 }
233 }
234 outl(ui_Command, devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12);
235 ui_Command = 0;
236 ui_Command = inl(devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12);
237/********************************/
238/* Disable the hardware trigger */
239/********************************/
240 ui_Command = ui_Command & 0xFFFFF89FUL;
241 if (data[4] == ADDIDATA_ENABLE) {
242 /**********************************/
243 /* Set the hardware trigger level */
244 /**********************************/
245 ui_Command = ui_Command | (data[5] << 5);
246 }
247 outl(ui_Command, devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12);
248 ui_Command = 0;
249 ui_Command = inl(devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12);
250/*****************************/
251/* Disable the hardware gate */
252/*****************************/
253 ui_Command = ui_Command & 0xFFFFF87FUL;
254 if (data[6] == ADDIDATA_ENABLE) {
255/*******************************/
256/* Set the hardware gate level */
257/*******************************/
258 ui_Command = ui_Command | (data[7] << 7);
259 }
260 outl(ui_Command, devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12);
261 ui_Command = 0;
262 ui_Command = inl(devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12);
263/*******************************/
264/* Disable the hardware output */
265/*******************************/
266 ui_Command = ui_Command & 0xFFFFF9FBUL;
267/*********************************/
268/* Set the hardware output level */
269/*********************************/
270 ui_Command = ui_Command | (data[8] << 2);
271 outl(ui_Command, devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12);
272 if (data[9] == ADDIDATA_ENABLE) {
273 /************************/
274 /* Set the reload value */
275 /************************/
276 outl(data[11],
277 devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 24);
278 /**********************/
279 /* Set the time unite */
280 /**********************/
281 outl(data[10],
282 devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 28);
283 }
284
285 ui_Command = 0;
286 ui_Command = inl(devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12);
287 /*******************************/
288 /* Disable the hardware output */
289 /*******************************/
290 ui_Command = ui_Command & 0xFFFFF9F7UL;
291 /*********************************/
292 /* Set the hardware output level */
293 /*********************************/
294 ui_Command = ui_Command | (data[12] << 3);
295 outl(ui_Command, devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12);
296 /*************************************/
297 /** Enable the watchdog interrupt **/
298 /*************************************/
299 ui_Command = 0;
300 ui_Command = inl(devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12);
301/*******************************/
302/* Set the interrupt selection */
303/*******************************/
304 ui_Status = inl(devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 16);
305
306 ui_Command = (ui_Command & 0xFFFFF9FDUL) | (data[13] << 1);
307 outl(ui_Command, devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12);
308
309 return insn->n;
310}
311
312/*
313+----------------------------------------------------------------------------+
314| Function Name : int i_APCI035_StartStopWriteTimerWatchdog |
34c43922 315| (struct comedi_device *dev,struct comedi_subdevice *s, |
90035c08 316| struct comedi_insn *insn,unsigned int *data) |
c995fe94
ADG
317+----------------------------------------------------------------------------+
318| Task : Start / Stop The Selected Timer , or Watchdog |
319+----------------------------------------------------------------------------+
71b5f4f1 320| Input Parameters : struct comedi_device *dev : Driver handle |
117102b0 321| unsigned int *data : Data Pointer contains |
c995fe94
ADG
322| configuration parameters as below |
323| |
324| data[0] : 0 - Stop Selected Timer/Watchdog |
325| 1 - Start Selected Timer/Watchdog |
326| 2 - Trigger Selected Timer/Watchdog |
327| 3 - Stop All Timer/Watchdog |
328| 4 - Start All Timer/Watchdog |
329| 5 - Trigger All Timer/Watchdog |
330| |
331+----------------------------------------------------------------------------+
332| Output Parameters : -- |
333+----------------------------------------------------------------------------+
334| Return Value : TRUE : No error occur |
335| : FALSE : Error occur. Return the error |
336| |
337+----------------------------------------------------------------------------+
338*/
dcd7ef33
HS
339static int i_APCI035_StartStopWriteTimerWatchdog(struct comedi_device *dev,
340 struct comedi_subdevice *s,
341 struct comedi_insn *insn,
342 unsigned int *data)
c995fe94 343{
843690b7 344 struct addi_private *devpriv = dev->private;
117102b0 345 unsigned int ui_Command = 0;
74b894e5 346 int i_Count = 0;
843690b7 347
c995fe94
ADG
348 if (data[0] == 1) {
349 ui_Command =
350 inl(devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12);
351 /**********************/
352 /* Start the hardware */
353 /**********************/
354 ui_Command = (ui_Command & 0xFFFFF9FFUL) | 0x1UL;
355 outl(ui_Command,
356 devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12);
2696fb57 357 } /* if (data[0]==1) */
c995fe94
ADG
358 if (data[0] == 2) {
359 ui_Command =
360 inl(devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12);
361 /***************************/
362 /* Set the trigger command */
363 /***************************/
364 ui_Command = (ui_Command & 0xFFFFF9FFUL) | 0x200UL;
365 outl(ui_Command,
366 devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12);
367 }
368
2696fb57 369 if (data[0] == 0) /* Stop The Watchdog */
c995fe94 370 {
2696fb57 371 /* Stop The Watchdog */
c995fe94 372 ui_Command = 0;
2696fb57
BP
373/*
374* ui_Command = inl(devpriv->iobase+((i_WatchdogNbr-1)*32)+12);
375* ui_Command = ui_Command & 0xFFFFF9FEUL;
376*/
c995fe94
ADG
377 outl(ui_Command,
378 devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12);
2696fb57
BP
379 } /* if (data[1]==0) */
380 if (data[0] == 3) /* stop all Watchdogs */
c995fe94
ADG
381 {
382 ui_Command = 0;
383 for (i_Count = 1; i_Count <= 4; i_Count++) {
384 if (devpriv->b_TimerSelectMode == ADDIDATA_WATCHDOG) {
385 ui_Command = 0x2UL;
386 } else {
387 ui_Command = 0x10UL;
388 }
389 i_WatchdogNbr = i_Count;
390 outl(ui_Command,
391 devpriv->iobase + ((i_WatchdogNbr - 1) * 32) +
392 0);
393 }
394
395 }
2696fb57 396 if (data[0] == 4) /* start all Watchdogs */
c995fe94
ADG
397 {
398 ui_Command = 0;
399 for (i_Count = 1; i_Count <= 4; i_Count++) {
400 if (devpriv->b_TimerSelectMode == ADDIDATA_WATCHDOG) {
401 ui_Command = 0x1UL;
402 } else {
403 ui_Command = 0x8UL;
404 }
405 i_WatchdogNbr = i_Count;
406 outl(ui_Command,
407 devpriv->iobase + ((i_WatchdogNbr - 1) * 32) +
408 0);
409 }
410 }
2696fb57 411 if (data[0] == 5) /* trigger all Watchdogs */
c995fe94
ADG
412 {
413 ui_Command = 0;
414 for (i_Count = 1; i_Count <= 4; i_Count++) {
415 if (devpriv->b_TimerSelectMode == ADDIDATA_WATCHDOG) {
416 ui_Command = 0x4UL;
417 } else {
418 ui_Command = 0x20UL;
419 }
420
421 i_WatchdogNbr = i_Count;
422 outl(ui_Command,
423 devpriv->iobase + ((i_WatchdogNbr - 1) * 32) +
424 0);
425 }
426 i_Temp = 1;
427 }
428 return insn->n;
429}
430
431/*
432+----------------------------------------------------------------------------+
433| Function Name : int i_APCI035_ReadTimerWatchdog |
34c43922 434| (struct comedi_device *dev,struct comedi_subdevice *s, |
90035c08 435| struct comedi_insn *insn,unsigned int *data) |
c995fe94
ADG
436+----------------------------------------------------------------------------+
437| Task : Read The Selected Timer , Counter or Watchdog |
438+----------------------------------------------------------------------------+
71b5f4f1 439| Input Parameters : struct comedi_device *dev : Driver handle |
117102b0 440| unsigned int *data : Data Pointer contains |
c995fe94
ADG
441| configuration parameters as below |
442| |
443| |
444+----------------------------------------------------------------------------+
445| Output Parameters : data[0] : software trigger status
356cdbcb
BP
446| data[1] : hardware trigger status
447| data[2] : Software clear status
448| data[3] : Overflow status
449| data[4] : Timer actual value
450|
c995fe94
ADG
451
452+----------------------------------------------------------------------------+
453| Return Value : TRUE : No error occur |
454| : FALSE : Error occur. Return the error |
455| |
456+----------------------------------------------------------------------------+
457*/
dcd7ef33
HS
458static int i_APCI035_ReadTimerWatchdog(struct comedi_device *dev,
459 struct comedi_subdevice *s,
460 struct comedi_insn *insn,
461 unsigned int *data)
c995fe94 462{
843690b7 463 struct addi_private *devpriv = dev->private;
2696fb57 464 unsigned int ui_Status = 0; /* Status register */
843690b7 465
c995fe94 466 i_WatchdogNbr = insn->unused[0];
356cdbcb
BP
467
468 /******************/
c995fe94 469 /* Get the status */
356cdbcb
BP
470 /******************/
471
c995fe94 472 ui_Status = inl(devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 16);
356cdbcb
BP
473
474 /***********************************/
c995fe94 475 /* Get the software trigger status */
356cdbcb
BP
476 /***********************************/
477
c995fe94 478 data[0] = ((ui_Status >> 1) & 1);
356cdbcb 479 /***********************************/
c995fe94 480 /* Get the hardware trigger status */
356cdbcb 481 /***********************************/
c995fe94 482 data[1] = ((ui_Status >> 2) & 1);
356cdbcb 483 /*********************************/
c995fe94 484 /* Get the software clear status */
356cdbcb 485 /*********************************/
c995fe94 486 data[2] = ((ui_Status >> 3) & 1);
356cdbcb 487 /***************************/
c995fe94 488 /* Get the overflow status */
356cdbcb 489 /***************************/
c995fe94
ADG
490 data[3] = ((ui_Status >> 0) & 1);
491 if (devpriv->b_TimerSelectMode == ADDIDATA_TIMER) {
492 data[4] = inl(devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 0);
493
2696fb57 494 } /* if (devpriv->b_TimerSelectMode==ADDIDATA_TIMER) */
c995fe94
ADG
495
496 return insn->n;
497}
498
499/*
500+----------------------------------------------------------------------------+
74b894e5 501| Function Name : int i_APCI035_ConfigAnalogInput |
34c43922 502| (struct comedi_device *dev,struct comedi_subdevice *s, |
90035c08 503| struct comedi_insn *insn,unsigned int *data) |
c995fe94
ADG
504+----------------------------------------------------------------------------+
505| Task : Configures The Analog Input Subdevice |
506+----------------------------------------------------------------------------+
71b5f4f1 507| Input Parameters : struct comedi_device *dev : Driver handle |
34c43922 508| struct comedi_subdevice *s : Subdevice Pointer |
90035c08 509| struct comedi_insn *insn : Insn Structure Pointer |
790c5541 510| unsigned int *data : Data Pointer contains |
c995fe94
ADG
511| configuration parameters as below |
512| data[0] : Warning delay value
513| |
514+----------------------------------------------------------------------------+
515| Output Parameters : -- |
516+----------------------------------------------------------------------------+
517| Return Value : TRUE : No error occur |
518| : FALSE : Error occur. Return the error |
519| |
520+----------------------------------------------------------------------------+
521*/
dcd7ef33
HS
522static int i_APCI035_ConfigAnalogInput(struct comedi_device *dev,
523 struct comedi_subdevice *s,
524 struct comedi_insn *insn,
525 unsigned int *data)
c995fe94 526{
843690b7
HS
527 struct addi_private *devpriv = dev->private;
528
c995fe94
ADG
529 devpriv->tsk_Current = current;
530 outl(0x200 | 0, devpriv->iobase + 128 + 0x4);
531 outl(0, devpriv->iobase + 128 + 0);
532/********************************/
533/* Initialise the warning value */
534/********************************/
535 outl(0x300 | 0, devpriv->iobase + 128 + 0x4);
536 outl((data[0] << 8), devpriv->iobase + 128 + 0);
537 outl(0x200000UL, devpriv->iobase + 128 + 12);
538
539 return insn->n;
540}
541
542/*
543+----------------------------------------------------------------------------+
544| Function Name : int i_APCI035_ReadAnalogInput |
34c43922 545| (struct comedi_device *dev,struct comedi_subdevice *s, |
90035c08 546| struct comedi_insn *insn,unsigned int *data) |
c995fe94
ADG
547+----------------------------------------------------------------------------+
548| Task : Read value of the selected channel |
549+----------------------------------------------------------------------------+
71b5f4f1 550| Input Parameters : struct comedi_device *dev : Driver handle |
117102b0
BP
551| unsigned int ui_NoOfChannels : No Of Channels To read |
552| unsigned int *data : Data Pointer to read status |
c995fe94
ADG
553+----------------------------------------------------------------------------+
554| Output Parameters : -- |
555| data[0] : Digital Value Of Input |
556| |
557+----------------------------------------------------------------------------+
558| Return Value : TRUE : No error occur |
559| : FALSE : Error occur. Return the error |
560| |
561+----------------------------------------------------------------------------+
562*/
dcd7ef33
HS
563static int i_APCI035_ReadAnalogInput(struct comedi_device *dev,
564 struct comedi_subdevice *s,
565 struct comedi_insn *insn,
566 unsigned int *data)
c995fe94 567{
843690b7 568 struct addi_private *devpriv = dev->private;
117102b0 569 unsigned int ui_CommandRegister = 0;
843690b7 570
c995fe94
ADG
571/******************/
572/* Set the start */
573/******************/
574 ui_CommandRegister = 0x80000;
575 /******************************/
576 /* Write the command register */
577 /******************************/
578 outl(ui_CommandRegister, devpriv->iobase + 128 + 8);
579
580/***************************************/
581/* Read the digital value of the input */
582/***************************************/
583 data[0] = inl(devpriv->iobase + 128 + 28);
584 return insn->n;
585}
586
587/*
588+----------------------------------------------------------------------------+
71b5f4f1 589| Function Name : int i_APCI035_Reset(struct comedi_device *dev) |
c995fe94
ADG
590| |
591+----------------------------------------------------------------------------+
592| Task :Resets the registers of the card |
593+----------------------------------------------------------------------------+
594| Input Parameters : |
595+----------------------------------------------------------------------------+
596| Output Parameters : -- |
597+----------------------------------------------------------------------------+
598| Return Value : |
599| |
600+----------------------------------------------------------------------------+
601*/
dcd7ef33 602static int i_APCI035_Reset(struct comedi_device *dev)
c995fe94 603{
843690b7 604 struct addi_private *devpriv = dev->private;
74b894e5 605 int i_Count = 0;
843690b7 606
c995fe94
ADG
607 for (i_Count = 1; i_Count <= 4; i_Count++) {
608 i_WatchdogNbr = i_Count;
2696fb57 609 outl(0x0, devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 0); /* stop all timers */
c995fe94 610 }
2696fb57 611 outl(0x0, devpriv->iobase + 128 + 12); /* Disable the warning delay */
c995fe94
ADG
612
613 return 0;
614}
615
616/*
617+----------------------------------------------------------------------------+
618| Function Name : static void v_APCI035_Interrupt |
619| (int irq , void *d) |
620+----------------------------------------------------------------------------+
621| Task : Interrupt processing Routine |
622+----------------------------------------------------------------------------+
623| Input Parameters : int irq : irq number |
624| void *d : void pointer |
625+----------------------------------------------------------------------------+
626| Output Parameters : -- |
627+----------------------------------------------------------------------------+
628| Return Value : TRUE : No error occur |
629| : FALSE : Error occur. Return the error |
630| |
631+----------------------------------------------------------------------------+
632*/
633static void v_APCI035_Interrupt(int irq, void *d)
634{
71b5f4f1 635 struct comedi_device *dev = d;
843690b7 636 struct addi_private *devpriv = dev->private;
117102b0
BP
637 unsigned int ui_StatusRegister1 = 0;
638 unsigned int ui_StatusRegister2 = 0;
639 unsigned int ui_ReadCommand = 0;
640 unsigned int ui_ChannelNumber = 0;
641 unsigned int ui_DigitalTemperature = 0;
843690b7 642
c995fe94
ADG
643 if (i_Temp == 1) {
644 i_WatchdogNbr = i_Flag;
645 i_Flag = i_Flag + 1;
646 }
647 /**************************************/
648 /* Read the interrupt status register of temperature Warning */
649 /**************************************/
650 ui_StatusRegister1 = inl(devpriv->iobase + 128 + 16);
651 /**************************************/
652 /* Read the interrupt status register for Watchdog/timer */
653 /**************************************/
654
655 ui_StatusRegister2 =
656 inl(devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 20);
657
2696fb57 658 if ((((ui_StatusRegister1) & 0x8) == 0x8)) /* Test if warning relay interrupt */
c995fe94
ADG
659 {
660 /**********************************/
661 /* Disable the temperature warning */
662 /**********************************/
663 ui_ReadCommand = inl(devpriv->iobase + 128 + 12);
664 ui_ReadCommand = ui_ReadCommand & 0xFFDF0000UL;
665 outl(ui_ReadCommand, devpriv->iobase + 128 + 12);
666 /***************************/
667 /* Read the channel number */
668 /***************************/
669 ui_ChannelNumber = inl(devpriv->iobase + 128 + 60);
670 /**************************************/
671 /* Read the digital temperature value */
672 /**************************************/
673 ui_DigitalTemperature = inl(devpriv->iobase + 128 + 60);
2696fb57
BP
674 send_sig(SIGIO, devpriv->tsk_Current, 0); /* send signal to the sample */
675 } /* if (((ui_StatusRegister1 & 0x8) == 0x8)) */
c995fe94
ADG
676
677 else {
678 if ((ui_StatusRegister2 & 0x1) == 0x1) {
2696fb57 679 send_sig(SIGIO, devpriv->tsk_Current, 0); /* send signal to the sample */
c995fe94 680 }
2696fb57 681 } /* else if (((ui_StatusRegister1 & 0x8) == 0x8)) */
c995fe94
ADG
682
683 return;
684}
This page took 0.417518 seconds and 5 git commands to generate.