staging: comedi: addi_apci_1710: delete driver

This driver is seriously broken and most of it does not "work" with
the comedi API. Just remove it.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
H Hartley Sweeten 2013-07-24 11:13:53 -07:00 committed by Greg Kroah-Hartman
parent c1f00be048
commit 3b4cb6717d
11 changed files with 0 additions and 19569 deletions

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,866 +0,0 @@
/**
@verbatim
Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module.
ADDI-DATA GmbH
Dieselstrasse 3
D-77833 Ottersweier
Tel: +19(0)7223/9493-0
Fax: +49(0)7223/9493-92
http://www.addi-data.com
info@addi-data.com
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.
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.
@endverbatim
*/
/*
+-----------------------------------------------------------------------+
| (C) ADDI-DATA GmbH Dieselstraße 3 D-77833 Ottersweier |
+-----------------------------------------------------------------------+
| Tel : +49 (0) 7223/9493-0 | email : info@addi-data.com |
| Fax : +49 (0) 7223/9493-92 | Internet : http://www.addi-data.com |
+-----------------------------------------------------------------------+
| Project : API APCI1710 | Compiler : gcc |
| Module name : Inp_CPT.C | Version : 2.96 |
+-------------------------------+---------------------------------------+
| Project manager: Eric Stolz | Date : 02/12/2002 |
+-----------------------------------------------------------------------+
| Description : APCI-1710 pulse encoder module |
| |
| |
+-----------------------------------------------------------------------+
| UPDATES |
+-----------------------------------------------------------------------+
| Date | Author | Description of updates |
+----------+-----------+------------------------------------------------+
| | | |
|----------|-----------|------------------------------------------------|
| 08/05/00 | Guinot C | - 0400/0228 All Function in RING 0 |
| | | available |
+-----------------------------------------------------------------------+
*/
#define APCI1710_SINGLE 0
#define APCI1710_CONTINUOUS 1
#define APCI1710_PULSEENCODER_READ 0
#define APCI1710_PULSEENCODER_WRITE 1
/*
+----------------------------------------------------------------------------+
| Function Name : _INT_ i_APCI1710_InitPulseEncoder |
| (unsigned char_ b_BoardHandle, |
| unsigned char_ b_ModulNbr, |
| unsigned char_ b_PulseEncoderNbr, |
| unsigned char_ b_InputLevelSelection, |
| unsigned char_ b_TriggerOutputAction, |
| ULONG_ ul_StartValue) |
+----------------------------------------------------------------------------+
| Task : Configure the pulse encoder operating mode selected via|
| b_ModulNbr and b_PulseEncoderNbr. The pulse encoder |
| after each pulse decrement the counter value from 1. |
| |
| You must calling this function be for you call any |
| other function witch access of pulse encoders. |
+----------------------------------------------------------------------------+
| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710|
| unsigned char_ b_ModulNbr : Module number to |
| configure (0 to 3) |
| unsigned char_ b_PulseEncoderNbr : Pulse encoder selection |
| (0 to 3) |
| unsigned char_ b_InputLevelSelection : Input level selection |
| (0 or 1) |
| 0 : Set pulse encoder|
| count the the low|
| level pulse. |
| 1 : Set pulse encoder|
| count the the |
| high level pulse.|
| unsigned char_ b_TriggerOutputAction : Digital TRIGGER output |
| action |
| 0 : No action |
| 1 : Set the trigger |
| output to "1" |
| (high) after the |
| passage from 1 to|
| 0 from pulse |
| encoder. |
| 2 : Set the trigger |
| output to "0" |
| (low) after the |
| passage from 1 to|
| 0 from pulse |
| encoder |
| ULONG_ ul_StartValue : Pulse encoder start value|
| (1 to 4294967295)
b_ModulNbr =(unsigned char) CR_AREF(insn->chanspec);
b_PulseEncoderNbr =(unsigned char) data[0];
b_InputLevelSelection =(unsigned char) data[1];
b_TriggerOutputAction =(unsigned char) data[2];
ul_StartValue =(unsigned int) data[3];
|
+----------------------------------------------------------------------------+
| Output Parameters : - |
+----------------------------------------------------------------------------+
| Return Value : 0: No error |
| -1: The handle parameter of the board is wrong |
| -2: The module is not a pulse encoder module |
| -3: Pulse encoder selection is wrong |
| -4: Input level selection is wrong |
| -5: Digital TRIGGER output action selection is wrong |
| -6: Pulse encoder start value is wrong |
+----------------------------------------------------------------------------+
*/
static int i_APCI1710_InsnConfigInitPulseEncoder(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned int *data)
{
struct addi_private *devpriv = dev->private;
int i_ReturnValue = 0;
unsigned int dw_IntRegister;
unsigned char b_ModulNbr;
unsigned char b_PulseEncoderNbr;
unsigned char b_InputLevelSelection;
unsigned char b_TriggerOutputAction;
unsigned int ul_StartValue;
b_ModulNbr = (unsigned char) CR_AREF(insn->chanspec);
b_PulseEncoderNbr = (unsigned char) data[0];
b_InputLevelSelection = (unsigned char) data[1];
b_TriggerOutputAction = (unsigned char) data[2];
ul_StartValue = (unsigned int) data[3];
i_ReturnValue = insn->n;
/***********************************/
/* Test the selected module number */
/***********************************/
if (b_ModulNbr <= 3) {
/*************************/
/* Test if pulse encoder */
/*************************/
if ((devpriv->s_BoardInfos.
dw_MolduleConfiguration[b_ModulNbr] &
APCI1710_PULSE_ENCODER) ==
APCI1710_PULSE_ENCODER) {
/******************************************/
/* Test the selected pulse encoder number */
/******************************************/
if (b_PulseEncoderNbr <= 3) {
/************************/
/* Test the input level */
/************************/
if ((b_InputLevelSelection == 0)
|| (b_InputLevelSelection == 1)) {
/*******************************************/
/* Test the ouput TRIGGER action selection */
/*******************************************/
if ((b_TriggerOutputAction <= 2)
|| (b_PulseEncoderNbr > 0)) {
if (ul_StartValue > 1) {
dw_IntRegister =
inl(devpriv->
s_BoardInfos.
ui_Address +
20 +
(64 * b_ModulNbr));
/***********************/
/* Set the start value */
/***********************/
outl(ul_StartValue,
devpriv->
s_BoardInfos.
ui_Address +
(b_PulseEncoderNbr
* 4) +
(64 * b_ModulNbr));
/***********************/
/* Set the input level */
/***********************/
devpriv->
s_ModuleInfo
[b_ModulNbr].
s_PulseEncoderModuleInfo.
dw_SetRegister =
(devpriv->
s_ModuleInfo
[b_ModulNbr].
s_PulseEncoderModuleInfo.
dw_SetRegister &
(0xFFFFFFFFUL -
(1UL << (8 + b_PulseEncoderNbr)))) | ((1UL & (~b_InputLevelSelection)) << (8 + b_PulseEncoderNbr));
/*******************************/
/* Test if output trigger used */
/*******************************/
if ((b_TriggerOutputAction > 0) && (b_PulseEncoderNbr > 1)) {
/****************************/
/* Enable the output action */
/****************************/
devpriv->
s_ModuleInfo
[b_ModulNbr].
s_PulseEncoderModuleInfo.
dw_SetRegister
=
devpriv->
s_ModuleInfo
[b_ModulNbr].
s_PulseEncoderModuleInfo.
dw_SetRegister
| (1UL
<< (4 + b_PulseEncoderNbr));
/*********************************/
/* Set the output TRIGGER action */
/*********************************/
devpriv->
s_ModuleInfo
[b_ModulNbr].
s_PulseEncoderModuleInfo.
dw_SetRegister
=
(devpriv->
s_ModuleInfo
[b_ModulNbr].
s_PulseEncoderModuleInfo.
dw_SetRegister
&
(0xFFFFFFFFUL
-
(1UL << (12 + b_PulseEncoderNbr)))) | ((1UL & (b_TriggerOutputAction - 1)) << (12 + b_PulseEncoderNbr));
} else {
/*****************************/
/* Disable the output action */
/*****************************/
devpriv->
s_ModuleInfo
[b_ModulNbr].
s_PulseEncoderModuleInfo.
dw_SetRegister
=
devpriv->
s_ModuleInfo
[b_ModulNbr].
s_PulseEncoderModuleInfo.
dw_SetRegister
&
(0xFFFFFFFFUL
-
(1UL << (4 + b_PulseEncoderNbr)));
}
/*************************/
/* Set the configuration */
/*************************/
outl(devpriv->
s_ModuleInfo
[b_ModulNbr].
s_PulseEncoderModuleInfo.
dw_SetRegister,
devpriv->
s_BoardInfos.
ui_Address +
20 +
(64 * b_ModulNbr));
devpriv->
s_ModuleInfo
[b_ModulNbr].
s_PulseEncoderModuleInfo.
s_PulseEncoderInfo
[b_PulseEncoderNbr].
b_PulseEncoderInit
= 1;
} else {
/**************************************/
/* Pulse encoder start value is wrong */
/**************************************/
DPRINTK("Pulse encoder start value is wrong\n");
i_ReturnValue = -6;
}
} else {
/****************************************************/
/* Digital TRIGGER output action selection is wrong */
/****************************************************/
DPRINTK("Digital TRIGGER output action selection is wrong\n");
i_ReturnValue = -5;
}
} else {
/**********************************/
/* Input level selection is wrong */
/**********************************/
DPRINTK("Input level selection is wrong\n");
i_ReturnValue = -4;
}
} else {
/************************************/
/* Pulse encoder selection is wrong */
/************************************/
DPRINTK("Pulse encoder selection is wrong\n");
i_ReturnValue = -3;
}
} else {
/********************************************/
/* The module is not a pulse encoder module */
/********************************************/
DPRINTK("The module is not a pulse encoder module\n");
i_ReturnValue = -2;
}
} else {
/********************************************/
/* The module is not a pulse encoder module */
/********************************************/
DPRINTK("The module is not a pulse encoder module\n");
i_ReturnValue = -2;
}
return i_ReturnValue;
}
/*
+----------------------------------------------------------------------------+
| Function Name : _INT_ i_APCI1710_EnablePulseEncoder |
| (unsigned char_ b_BoardHandle, |
| unsigned char_ b_ModulNbr, |
| unsigned char_ b_PulseEncoderNbr, |
| unsigned char_ b_CycleSelection, |
| unsigned char_ b_InterruptHandling) |
+----------------------------------------------------------------------------+
| Task : Enableor disable the selected pulse encoder (b_PulseEncoderNbr) |
| from selected module (b_ModulNbr). Each input pulse |
| decrement the pulse encoder counter value from 1. |
| If you enabled the interrupt (b_InterruptHandling), a |
| interrupt is generated when the pulse encoder has run |
| down. |
+----------------------------------------------------------------------------+
| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710|
| unsigned char_ b_ModulNbr : Module number to |
| configure (0 to 3) |
| unsigned char_ b_PulseEncoderNbr : Pulse encoder selection |
| (0 to 3) |
| unsigned char_ b_CycleSelection : APCI1710_CONTINUOUS: |
| Each time the |
| counting value is set|
| on "0", the pulse |
| encoder load the |
| start value after |
| the next pulse. |
| APCI1710_SINGLE: |
| If the counter is set|
| on "0", the pulse |
| encoder is stopped. |
| unsigned char_ b_InterruptHandling : Interrupts can be |
| generated, when the pulse|
| encoder has run down. |
| With this parameter the |
| user decides if |
| interrupts are used or |
| not. |
| APCI1710_ENABLE: |
| Interrupts are enabled |
| APCI1710_DISABLE: |
| Interrupts are disabled
b_ModulNbr =(unsigned char) CR_AREF(insn->chanspec);
b_Action =(unsigned char) data[0];
b_PulseEncoderNbr =(unsigned char) data[1];
b_CycleSelection =(unsigned char) data[2];
b_InterruptHandling =(unsigned char) data[3];|
+----------------------------------------------------------------------------+
| Output Parameters : - |
+----------------------------------------------------------------------------+
| Return Value : 0: No error |
| -1: The handle parameter of the board is wrong |
| -2: Module selection is wrong |
| -3: Pulse encoder selection is wrong |
| -4: Pulse encoder not initialised. |
| See function "i_APCI1710_InitPulseEncoder" |
| -5: Cycle selection mode is wrong |
| -6: Interrupt handling mode is wrong |
| -7: Interrupt routine not installed. |
| See function "i_APCI1710_SetBoardIntRoutineX" |
+----------------------------------------------------------------------------+
*/
static int i_APCI1710_InsnWriteEnableDisablePulseEncoder(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned int *data)
{
struct addi_private *devpriv = dev->private;
int i_ReturnValue = 0;
unsigned char b_ModulNbr;
unsigned char b_PulseEncoderNbr;
unsigned char b_CycleSelection;
unsigned char b_InterruptHandling;
unsigned char b_Action;
i_ReturnValue = insn->n;
b_ModulNbr = (unsigned char) CR_AREF(insn->chanspec);
b_Action = (unsigned char) data[0];
b_PulseEncoderNbr = (unsigned char) data[1];
b_CycleSelection = (unsigned char) data[2];
b_InterruptHandling = (unsigned char) data[3];
/***********************************/
/* Test the selected module number */
/***********************************/
if (b_ModulNbr <= 3) {
/******************************************/
/* Test the selected pulse encoder number */
/******************************************/
if (b_PulseEncoderNbr <= 3) {
/*************************************/
/* Test if pulse encoder initialised */
/*************************************/
if (devpriv->s_ModuleInfo[b_ModulNbr].
s_PulseEncoderModuleInfo.
s_PulseEncoderInfo[b_PulseEncoderNbr].
b_PulseEncoderInit == 1) {
switch (b_Action) {
case APCI1710_ENABLE:
/****************************/
/* Test the cycle selection */
/****************************/
if (b_CycleSelection ==
APCI1710_CONTINUOUS
|| b_CycleSelection ==
APCI1710_SINGLE) {
/*******************************/
/* Test the interrupt handling */
/*******************************/
if (b_InterruptHandling ==
APCI1710_ENABLE
|| b_InterruptHandling
== APCI1710_DISABLE) {
/******************************/
/* Test if interrupt not used */
/******************************/
if (b_InterruptHandling
==
APCI1710_DISABLE)
{
/*************************/
/* Disable the interrupt */
/*************************/
devpriv->
s_ModuleInfo
[b_ModulNbr].
s_PulseEncoderModuleInfo.
dw_SetRegister
=
devpriv->
s_ModuleInfo
[b_ModulNbr].
s_PulseEncoderModuleInfo.
dw_SetRegister
&
(0xFFFFFFFFUL
-
(1UL << b_PulseEncoderNbr));
} else {
/************************/
/* Enable the interrupt */
/************************/
devpriv->
s_ModuleInfo
[b_ModulNbr].
s_PulseEncoderModuleInfo.
dw_SetRegister
=
devpriv->
s_ModuleInfo
[b_ModulNbr].
s_PulseEncoderModuleInfo.
dw_SetRegister
| (1UL
<<
b_PulseEncoderNbr);
devpriv->tsk_Current = current; /* Save the current process task structure */
}
if (i_ReturnValue >= 0) {
/***********************************/
/* Enable or disable the interrupt */
/***********************************/
outl(devpriv->
s_ModuleInfo
[b_ModulNbr].
s_PulseEncoderModuleInfo.
dw_SetRegister,
devpriv->
s_BoardInfos.
ui_Address
+ 20 +
(64 * b_ModulNbr));
/****************************/
/* Enable the pulse encoder */
/****************************/
devpriv->
s_ModuleInfo
[b_ModulNbr].
s_PulseEncoderModuleInfo.
dw_ControlRegister
=
devpriv->
s_ModuleInfo
[b_ModulNbr].
s_PulseEncoderModuleInfo.
dw_ControlRegister
| (1UL
<<
b_PulseEncoderNbr);
/**********************/
/* Set the cycle mode */
/**********************/
devpriv->
s_ModuleInfo
[b_ModulNbr].
s_PulseEncoderModuleInfo.
dw_ControlRegister
=
(devpriv->
s_ModuleInfo
[b_ModulNbr].
s_PulseEncoderModuleInfo.
dw_ControlRegister
&
(0xFFFFFFFFUL
-
(1 << (b_PulseEncoderNbr + 4)))) | ((b_CycleSelection & 1UL) << (4 + b_PulseEncoderNbr));
/****************************/
/* Enable the pulse encoder */
/****************************/
outl(devpriv->
s_ModuleInfo
[b_ModulNbr].
s_PulseEncoderModuleInfo.
dw_ControlRegister,
devpriv->
s_BoardInfos.
ui_Address
+ 16 +
(64 * b_ModulNbr));
}
} else {
/************************************/
/* Interrupt handling mode is wrong */
/************************************/
DPRINTK("Interrupt handling mode is wrong\n");
i_ReturnValue = -6;
}
} else {
/*********************************/
/* Cycle selection mode is wrong */
/*********************************/
DPRINTK("Cycle selection mode is wrong\n");
i_ReturnValue = -5;
}
break;
case APCI1710_DISABLE:
devpriv->s_ModuleInfo[b_ModulNbr].
s_PulseEncoderModuleInfo.
dw_ControlRegister =
devpriv->
s_ModuleInfo[b_ModulNbr].
s_PulseEncoderModuleInfo.
dw_ControlRegister &
(0xFFFFFFFFUL -
(1UL << b_PulseEncoderNbr));
/*****************************/
/* Disable the pulse encoder */
/*****************************/
outl(devpriv->s_ModuleInfo[b_ModulNbr].
s_PulseEncoderModuleInfo.
dw_ControlRegister,
devpriv->s_BoardInfos.
ui_Address + 16 +
(64 * b_ModulNbr));
break;
} /* switch End */
} else {
/*********************************/
/* Pulse encoder not initialised */
/*********************************/
DPRINTK("Pulse encoder not initialised\n");
i_ReturnValue = -4;
}
} else {
/************************************/
/* Pulse encoder selection is wrong */
/************************************/
DPRINTK("Pulse encoder selection is wrong\n");
i_ReturnValue = -3;
}
} else {
/*****************************/
/* Module selection is wrong */
/*****************************/
DPRINTK("Module selection is wrong\n");
i_ReturnValue = -2;
}
return i_ReturnValue;
}
/*
+----------------------------------------------------------------------------+
| Function Name : _INT_ i_APCI1710_ReadPulseEncoderStatus |
| (unsigned char_ b_BoardHandle, |
| unsigned char_ b_ModulNbr, |
| unsigned char_ b_PulseEncoderNbr, |
| unsigned char *_ pb_Status) |
+----------------------------------------------------------------------------+
| Task APCI1710_PULSEENCODER_READ : Reads the pulse encoder status
and valuefrom selected pulse |
| encoder (b_PulseEncoderNbr) from selected module |
| (b_ModulNbr). |
+----------------------------------------------------------------------------+
unsigned char b_Type; data[0]
APCI1710_PULSEENCODER_WRITE
Writes a 32-bit value (ul_WriteValue) into the selected|
| pulse encoder (b_PulseEncoderNbr) from selected module |
| (b_ModulNbr). This operation set the new start pulse |
| encoder value.
APCI1710_PULSEENCODER_READ
| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710|
| CRAREF() unsigned char_ b_ModulNbr : Module number to |
| configure (0 to 3) |
| data[1] unsigned char_ b_PulseEncoderNbr : Pulse encoder selection |
| (0 to 3)
APCI1710_PULSEENCODER_WRITE
data[2] ULONG_ ul_WriteValue : 32-bit value to be |
| written |
+----------------------------------------------------------------------------+
| Output Parameters : unsigned char *_ pb_Status : Pulse encoder status. |
| 0 : No overflow occur|
| 1 : Overflow occur
PULONG_ pul_ReadValue : Pulse encoder value | |
+----------------------------------------------------------------------------+
| Return Value : 0: No error |
| -1: The handle parameter of the board is wrong |
| -2: Module selection is wrong |
| -3: Pulse encoder selection is wrong |
| -4: Pulse encoder not initialised. |
| See function "i_APCI1710_InitPulseEncoder" |
+----------------------------------------------------------------------------+
*/
/*_INT_ i_APCI1710_ReadPulseEncoderStatus (unsigned char_ b_BoardHandle,
unsigned char_ b_ModulNbr,
unsigned char_ b_PulseEncoderNbr,
unsigned char *_ pb_Status)
*/
static int i_APCI1710_InsnBitsReadWritePulseEncoder(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned int *data)
{
struct addi_private *devpriv = dev->private;
int i_ReturnValue = 0;
unsigned int dw_StatusRegister;
unsigned char b_ModulNbr;
unsigned char b_PulseEncoderNbr;
unsigned char *pb_Status;
unsigned char b_Type;
unsigned int *pul_ReadValue;
unsigned int ul_WriteValue;
i_ReturnValue = insn->n;
b_ModulNbr = (unsigned char) CR_AREF(insn->chanspec);
b_Type = (unsigned char) data[0];
b_PulseEncoderNbr = (unsigned char) data[1];
pb_Status = (unsigned char *) &data[0];
pul_ReadValue = (unsigned int *) &data[1];
/***********************************/
/* Test the selected module number */
/***********************************/
if (b_ModulNbr <= 3) {
/******************************************/
/* Test the selected pulse encoder number */
/******************************************/
if (b_PulseEncoderNbr <= 3) {
/*************************************/
/* Test if pulse encoder initialised */
/*************************************/
if (devpriv->s_ModuleInfo[b_ModulNbr].
s_PulseEncoderModuleInfo.
s_PulseEncoderInfo[b_PulseEncoderNbr].
b_PulseEncoderInit == 1) {
switch (b_Type) {
case APCI1710_PULSEENCODER_READ:
/****************************/
/* Read the status register */
/****************************/
dw_StatusRegister =
inl(devpriv->s_BoardInfos.
ui_Address + 16 +
(64 * b_ModulNbr));
devpriv->s_ModuleInfo[b_ModulNbr].
s_PulseEncoderModuleInfo.
dw_StatusRegister = devpriv->
s_ModuleInfo[b_ModulNbr].
s_PulseEncoderModuleInfo.
dw_StatusRegister |
dw_StatusRegister;
*pb_Status =
(unsigned char) (devpriv->
s_ModuleInfo[b_ModulNbr].
s_PulseEncoderModuleInfo.
dw_StatusRegister >> (1 +
b_PulseEncoderNbr)) & 1;
devpriv->s_ModuleInfo[b_ModulNbr].
s_PulseEncoderModuleInfo.
dw_StatusRegister =
devpriv->
s_ModuleInfo[b_ModulNbr].
s_PulseEncoderModuleInfo.
dw_StatusRegister &
(0xFFFFFFFFUL - (1 << (1 +
b_PulseEncoderNbr)));
/******************/
/* Read the value */
/******************/
*pul_ReadValue =
inl(devpriv->s_BoardInfos.
ui_Address +
(4 * b_PulseEncoderNbr) +
(64 * b_ModulNbr));
break;
case APCI1710_PULSEENCODER_WRITE:
ul_WriteValue = (unsigned int) data[2];
/*******************/
/* Write the value */
/*******************/
outl(ul_WriteValue,
devpriv->s_BoardInfos.
ui_Address +
(4 * b_PulseEncoderNbr) +
(64 * b_ModulNbr));
} /* end of switch */
} else {
/*********************************/
/* Pulse encoder not initialised */
/*********************************/
DPRINTK("Pulse encoder not initialised\n");
i_ReturnValue = -4;
}
} else {
/************************************/
/* Pulse encoder selection is wrong */
/************************************/
DPRINTK("Pulse encoder selection is wrong\n");
i_ReturnValue = -3;
}
} else {
/*****************************/
/* Module selection is wrong */
/*****************************/
DPRINTK("Module selection is wrong\n");
i_ReturnValue = -2;
}
return i_ReturnValue;
}
static int i_APCI1710_InsnReadInterruptPulseEncoder(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned int *data)
{
struct addi_private *devpriv = dev->private;
data[0] = devpriv->s_InterruptParameters.
s_FIFOInterruptParameters[devpriv->
s_InterruptParameters.ui_Read].b_OldModuleMask;
data[1] = devpriv->s_InterruptParameters.
s_FIFOInterruptParameters[devpriv->
s_InterruptParameters.ui_Read].ul_OldInterruptMask;
data[2] = devpriv->s_InterruptParameters.
s_FIFOInterruptParameters[devpriv->
s_InterruptParameters.ui_Read].ul_OldCounterLatchValue;
/***************************/
/* Increment the read FIFO */
/***************************/
devpriv->s_InterruptParameters.
ui_Read = (devpriv->
s_InterruptParameters.ui_Read + 1) % APCI1710_SAVE_INTERRUPT;
return insn->n;
}

File diff suppressed because it is too large Load diff

View file

@ -1,845 +0,0 @@
/**
@verbatim
Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module.
ADDI-DATA GmbH
Dieselstrasse 3
D-77833 Ottersweier
Tel: +19(0)7223/9493-0
Fax: +49(0)7223/9493-92
http://www.addi-data.com
info@addi-data.com
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.
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.
@endverbatim
*/
/*
+-----------------------------------------------------------------------+
| (C) ADDI-DATA GmbH Dieselstraße 3 D-77833 Ottersweier |
+-----------------------------------------------------------------------+
| Tel : +49 (0) 7223/9493-0 | email : info@addi-data.com |
| Fax : +49 (0) 7223/9493-92 | Internet : http://www.addi-data.com |
+-----------------------------------------------------------------------+
| Project : API APCI1710 | Compiler : gcc |
| Module name : SSI.C | Version : 2.96 |
+-------------------------------+---------------------------------------+
| Project manager: Eric Stolz | Date : 02/12/2002 |
+-----------------------------------------------------------------------+
| Description : APCI-1710 SSI counter module |
+-----------------------------------------------------------------------+
| several changes done by S. Weber in 1998 and C. Guinot in 2000 |
+-----------------------------------------------------------------------+
*/
#define APCI1710_30MHZ 30
#define APCI1710_33MHZ 33
#define APCI1710_40MHZ 40
#define APCI1710_BINARY_MODE 0x1
#define APCI1710_GRAY_MODE 0x0
#define APCI1710_SSI_READ1VALUE 1
#define APCI1710_SSI_READALLVALUE 2
#define APCI1710_SSI_SET_CHANNELON 0
#define APCI1710_SSI_SET_CHANNELOFF 1
#define APCI1710_SSI_READ_1CHANNEL 2
#define APCI1710_SSI_READ_ALLCHANNEL 3
/*
+----------------------------------------------------------------------------+
| Function Name : _INT_ i_APCI1710_InitSSI |
| (unsigned char_ b_BoardHandle, |
| unsigned char_ b_ModulNbr, |
| unsigned char_ b_SSIProfile, |
| unsigned char_ b_PositionTurnLength, |
| unsigned char_ b_TurnCptLength, |
| unsigned char_ b_PCIInputClock, |
| ULONG_ ul_SSIOutputClock, |
| unsigned char_ b_SSICountingMode) |
+----------------------------------------------------------------------------+
| Task : Configure the SSI operating mode from selected module |
| (b_ModulNbr). You must calling this function be for you|
| call any other function witch access of SSI. |
+----------------------------------------------------------------------------+
| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710|
| unsigned char_ b_ModulNbr : Module number to |
| configure (0 to 3) |
| unsigned char_ b_SSIProfile : Selection from SSI |
| profile length (2 to 32).|
| unsigned char_ b_PositionTurnLength : Selection from SSI |
| position data length |
| (1 to 31). |
| unsigned char_ b_TurnCptLength : Selection from SSI turn |
| counter data length |
| (1 to 31). |
| unsigned char b_PCIInputClock : Selection from PCI bus |
| clock |
| - APCI1710_30MHZ : |
| The PC have a PCI bus |
| clock from 30 MHz |
| - APCI1710_33MHZ : |
| The PC have a PCI bus |
| clock from 33 MHz |
| ULONG_ ul_SSIOutputClock : Selection from SSI output|
| clock. |
| From 229 to 5 000 000 Hz|
| for 30 MHz selection. |
| From 252 to 5 000 000 Hz|
| for 33 MHz selection. |
| unsigned char b_SSICountingMode : SSI counting mode |
| selection |
| - APCI1710_BINARY_MODE : |
| Binary counting mode. |
| - APCI1710_GRAY_MODE : |
| Gray counting mode.
b_ModulNbr = CR_AREF(insn->chanspec);
b_SSIProfile = (unsigned char) data[0];
b_PositionTurnLength= (unsigned char) data[1];
b_TurnCptLength = (unsigned char) data[2];
b_PCIInputClock = (unsigned char) data[3];
ul_SSIOutputClock = (unsigned int) data[4];
b_SSICountingMode = (unsigned char) data[5]; |
+----------------------------------------------------------------------------+
| Output Parameters : - |
+----------------------------------------------------------------------------+
| Return Value : 0: No error |
| -1: The handle parameter of the board is wrong |
| -2: The module parameter is wrong |
| -3: The module is not a SSI module |
| -4: The selected SSI profile length is wrong |
| -5: The selected SSI position data length is wrong |
| -6: The selected SSI turn counter data length is wrong |
| -7: The selected PCI input clock is wrong |
| -8: The selected SSI output clock is wrong |
| -9: The selected SSI counting mode parameter is wrong |
+----------------------------------------------------------------------------+
*/
static int i_APCI1710_InsnConfigInitSSI(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned int *data)
{
struct addi_private *devpriv = dev->private;
int i_ReturnValue = 0;
unsigned int ui_TimerValue;
unsigned char b_ModulNbr, b_SSIProfile, b_PositionTurnLength, b_TurnCptLength,
b_PCIInputClock, b_SSICountingMode;
unsigned int ul_SSIOutputClock;
b_ModulNbr = CR_AREF(insn->chanspec);
b_SSIProfile = (unsigned char) data[0];
b_PositionTurnLength = (unsigned char) data[1];
b_TurnCptLength = (unsigned char) data[2];
b_PCIInputClock = (unsigned char) data[3];
ul_SSIOutputClock = (unsigned int) data[4];
b_SSICountingMode = (unsigned char) data[5];
i_ReturnValue = insn->n;
/**************************/
/* Test the module number */
/**************************/
if (b_ModulNbr < 4) {
/***********************/
/* Test if SSI counter */
/***********************/
if ((devpriv->s_BoardInfos.
dw_MolduleConfiguration[b_ModulNbr] &
0xFFFF0000UL) == APCI1710_SSI_COUNTER) {
/*******************************/
/* Test the SSI profile length */
/*******************************/
/* CG 22/03/00 b_SSIProfile >= 2 anstatt b_SSIProfile > 2 */
if (b_SSIProfile >= 2 && b_SSIProfile < 33) {
/*************************************/
/* Test the SSI position data length */
/*************************************/
if (b_PositionTurnLength > 0
&& b_PositionTurnLength < 32) {
/*****************************************/
/* Test the SSI turn counter data length */
/*****************************************/
if (b_TurnCptLength > 0
&& b_TurnCptLength < 32) {
/***************************/
/* Test the profile length */
/***************************/
if ((b_TurnCptLength +
b_PositionTurnLength)
<= b_SSIProfile) {
/****************************/
/* Test the PCI input clock */
/****************************/
if (b_PCIInputClock ==
APCI1710_30MHZ
||
b_PCIInputClock
==
APCI1710_33MHZ)
{
/*************************/
/* Test the output clock */
/*************************/
if ((b_PCIInputClock == APCI1710_30MHZ && (ul_SSIOutputClock > 228 && ul_SSIOutputClock <= 5000000UL)) || (b_PCIInputClock == APCI1710_33MHZ && (ul_SSIOutputClock > 251 && ul_SSIOutputClock <= 5000000UL))) {
if (b_SSICountingMode == APCI1710_BINARY_MODE || b_SSICountingMode == APCI1710_GRAY_MODE) {
/**********************/
/* Save configuration */
/**********************/
devpriv->
s_ModuleInfo
[b_ModulNbr].
s_SSICounterInfo.
b_SSIProfile
=
b_SSIProfile;
devpriv->
s_ModuleInfo
[b_ModulNbr].
s_SSICounterInfo.
b_PositionTurnLength
=
b_PositionTurnLength;
devpriv->
s_ModuleInfo
[b_ModulNbr].
s_SSICounterInfo.
b_TurnCptLength
=
b_TurnCptLength;
/*********************************/
/* Initialise the profile length */
/*********************************/
if (b_SSICountingMode == APCI1710_BINARY_MODE) {
outl(b_SSIProfile + 1, devpriv->s_BoardInfos.ui_Address + 4 + (64 * b_ModulNbr));
} else {
outl(b_SSIProfile, devpriv->s_BoardInfos.ui_Address + 4 + (64 * b_ModulNbr));
}
/******************************/
/* Calculate the output clock */
/******************************/
ui_TimerValue
=
(unsigned int)
(
((unsigned int) (b_PCIInputClock) * 500000UL) / ul_SSIOutputClock);
/************************/
/* Initialise the timer */
/************************/
outl(ui_TimerValue, devpriv->s_BoardInfos.ui_Address + (64 * b_ModulNbr));
/********************************/
/* Initialise the counting mode */
/********************************/
outl(7 * b_SSICountingMode, devpriv->s_BoardInfos.ui_Address + 12 + (64 * b_ModulNbr));
devpriv->
s_ModuleInfo
[b_ModulNbr].
s_SSICounterInfo.
b_SSIInit
=
1;
} else {
/*****************************************************/
/* The selected SSI counting mode parameter is wrong */
/*****************************************************/
DPRINTK("The selected SSI counting mode parameter is wrong\n");
i_ReturnValue
=
-9;
}
} else {
/******************************************/
/* The selected SSI output clock is wrong */
/******************************************/
DPRINTK("The selected SSI output clock is wrong\n");
i_ReturnValue
=
-8;
}
} else {
/*****************************************/
/* The selected PCI input clock is wrong */
/*****************************************/
DPRINTK("The selected PCI input clock is wrong\n");
i_ReturnValue =
-7;
}
} else {
/********************************************/
/* The selected SSI profile length is wrong */
/********************************************/
DPRINTK("The selected SSI profile length is wrong\n");
i_ReturnValue = -4;
}
} else {
/******************************************************/
/* The selected SSI turn counter data length is wrong */
/******************************************************/
DPRINTK("The selected SSI turn counter data length is wrong\n");
i_ReturnValue = -6;
}
} else {
/**************************************************/
/* The selected SSI position data length is wrong */
/**************************************************/
DPRINTK("The selected SSI position data length is wrong\n");
i_ReturnValue = -5;
}
} else {
/********************************************/
/* The selected SSI profile length is wrong */
/********************************************/
DPRINTK("The selected SSI profile length is wrong\n");
i_ReturnValue = -4;
}
} else {
/**********************************/
/* The module is not a SSI module */
/**********************************/
DPRINTK("The module is not a SSI module\n");
i_ReturnValue = -3;
}
} else {
/***********************/
/* Module number error */
/***********************/
DPRINTK("Module number error\n");
i_ReturnValue = -2;
}
return i_ReturnValue;
}
/*
+----------------------------------------------------------------------------+
| Function Name : _INT_ i_APCI1710_Read1SSIValue |
| (unsigned char_ b_BoardHandle, |
| unsigned char_ b_ModulNbr, |
| unsigned char_ b_SelectedSSI, |
| PULONG_ pul_Position, |
| PULONG_ pul_TurnCpt)
int i_APCI1710_ReadSSIValue(struct comedi_device *dev,struct comedi_subdevice *s,
struct comedi_insn *insn,unsigned int *data) |
+----------------------------------------------------------------------------+
| Task :
Read the selected SSI counter (b_SelectedSSI) from |
| selected module (b_ModulNbr).
or Read all SSI counter (b_SelectedSSI) from |
| selected module (b_ModulNbr). |
+----------------------------------------------------------------------------+
| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710|
| unsigned char_ b_ModulNbr : Module number to |
| configure (0 to 3) |
| unsigned char_ b_SelectedSSI : Selection from SSI |
| counter (0 to 2)
b_ModulNbr = (unsigned char) CR_AREF(insn->chanspec);
b_SelectedSSI = (unsigned char) CR_CHAN(insn->chanspec); (in case of single ssi)
b_ReadType = (unsigned char) CR_RANGE(insn->chanspec);
|
+----------------------------------------------------------------------------+
| Output Parameters : PULONG_ pul_Position : SSI position in the turn |
| PULONG_ pul_TurnCpt : Number of turns
pul_Position = (unsigned int *) &data[0];
pul_TurnCpt = (unsigned int *) &data[1]; |
+----------------------------------------------------------------------------+
| Return Value : 0: No error |
| -1: The handle parameter of the board is wrong |
| -2: The module parameter is wrong |
| -3: The module is not a SSI module |
| -4: SSI not initialised see function |
| "i_APCI1710_InitSSI" |
| -5: The selected SSI is wrong |
+----------------------------------------------------------------------------+
*/
static int i_APCI1710_InsnReadSSIValue(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned int *data)
{
struct addi_private *devpriv = dev->private;
int i_ReturnValue = 0;
unsigned char b_Cpt;
unsigned char b_Length;
unsigned char b_Schift;
unsigned char b_SSICpt;
unsigned int dw_And;
unsigned int dw_And1;
unsigned int dw_And2;
unsigned int dw_StatusReg;
unsigned int dw_CounterValue;
unsigned char b_ModulNbr;
unsigned char b_SelectedSSI;
unsigned char b_ReadType;
unsigned int *pul_Position;
unsigned int *pul_TurnCpt;
unsigned int *pul_Position1;
unsigned int *pul_TurnCpt1;
i_ReturnValue = insn->n;
pul_Position1 = (unsigned int *) &data[0];
/* For Read1 */
pul_TurnCpt1 = (unsigned int *) &data[1];
/* For Read all */
pul_Position = (unsigned int *) &data[0]; /* 0-2 */
pul_TurnCpt = (unsigned int *) &data[3]; /* 3-5 */
b_ModulNbr = (unsigned char) CR_AREF(insn->chanspec);
b_SelectedSSI = (unsigned char) CR_CHAN(insn->chanspec);
b_ReadType = (unsigned char) CR_RANGE(insn->chanspec);
/**************************/
/* Test the module number */
/**************************/
if (b_ModulNbr < 4) {
/***********************/
/* Test if SSI counter */
/***********************/
if ((devpriv->s_BoardInfos.
dw_MolduleConfiguration[b_ModulNbr] &
0xFFFF0000UL) == APCI1710_SSI_COUNTER) {
/***************************/
/* Test if SSI initialised */
/***************************/
if (devpriv->s_ModuleInfo[b_ModulNbr].
s_SSICounterInfo.b_SSIInit == 1) {
switch (b_ReadType) {
case APCI1710_SSI_READ1VALUE:
/****************************************/
/* Test the selected SSI counter number */
/****************************************/
if (b_SelectedSSI < 3) {
/************************/
/* Start the conversion */
/************************/
outl(0, devpriv->s_BoardInfos.
ui_Address + 8 +
(64 * b_ModulNbr));
do {
/*******************/
/* Read the status */
/*******************/
dw_StatusReg =
inl(devpriv->
s_BoardInfos.
ui_Address +
(64 * b_ModulNbr));
} while ((dw_StatusReg & 0x1)
!= 0);
/******************************/
/* Read the SSI counter value */
/******************************/
dw_CounterValue =
inl(devpriv->
s_BoardInfos.
ui_Address + 4 +
(b_SelectedSSI * 4) +
(64 * b_ModulNbr));
b_Length =
devpriv->
s_ModuleInfo
[b_ModulNbr].
s_SSICounterInfo.
b_SSIProfile / 2;
if ((b_Length * 2) !=
devpriv->
s_ModuleInfo
[b_ModulNbr].
s_SSICounterInfo.
b_SSIProfile) {
b_Length++;
}
b_Schift =
b_Length -
devpriv->
s_ModuleInfo
[b_ModulNbr].
s_SSICounterInfo.
b_PositionTurnLength;
*pul_Position1 =
dw_CounterValue >>
b_Schift;
dw_And = 1;
for (b_Cpt = 0;
b_Cpt <
devpriv->
s_ModuleInfo
[b_ModulNbr].
s_SSICounterInfo.
b_PositionTurnLength;
b_Cpt++) {
dw_And = dw_And * 2;
}
*pul_Position1 =
*pul_Position1 &
((dw_And) - 1);
*pul_TurnCpt1 =
dw_CounterValue >>
b_Length;
dw_And = 1;
for (b_Cpt = 0;
b_Cpt <
devpriv->
s_ModuleInfo
[b_ModulNbr].
s_SSICounterInfo.
b_TurnCptLength;
b_Cpt++) {
dw_And = dw_And * 2;
}
*pul_TurnCpt1 =
*pul_TurnCpt1 &
((dw_And) - 1);
} else {
/*****************************/
/* The selected SSI is wrong */
/*****************************/
DPRINTK("The selected SSI is wrong\n");
i_ReturnValue = -5;
}
break;
case APCI1710_SSI_READALLVALUE:
dw_And1 = 1;
for (b_Cpt = 0;
b_Cpt <
devpriv->
s_ModuleInfo[b_ModulNbr].
s_SSICounterInfo.
b_PositionTurnLength; b_Cpt++) {
dw_And1 = dw_And1 * 2;
}
dw_And2 = 1;
for (b_Cpt = 0;
b_Cpt <
devpriv->
s_ModuleInfo[b_ModulNbr].
s_SSICounterInfo.
b_TurnCptLength; b_Cpt++) {
dw_And2 = dw_And2 * 2;
}
/************************/
/* Start the conversion */
/************************/
outl(0, devpriv->s_BoardInfos.
ui_Address + 8 +
(64 * b_ModulNbr));
do {
/*******************/
/* Read the status */
/*******************/
dw_StatusReg =
inl(devpriv->
s_BoardInfos.
ui_Address +
(64 * b_ModulNbr));
} while ((dw_StatusReg & 0x1) != 0);
for (b_SSICpt = 0; b_SSICpt < 3;
b_SSICpt++) {
/******************************/
/* Read the SSI counter value */
/******************************/
dw_CounterValue =
inl(devpriv->
s_BoardInfos.
ui_Address + 4 +
(b_SSICpt * 4) +
(64 * b_ModulNbr));
b_Length =
devpriv->
s_ModuleInfo
[b_ModulNbr].
s_SSICounterInfo.
b_SSIProfile / 2;
if ((b_Length * 2) !=
devpriv->
s_ModuleInfo
[b_ModulNbr].
s_SSICounterInfo.
b_SSIProfile) {
b_Length++;
}
b_Schift =
b_Length -
devpriv->
s_ModuleInfo
[b_ModulNbr].
s_SSICounterInfo.
b_PositionTurnLength;
pul_Position[b_SSICpt] =
dw_CounterValue >>
b_Schift;
pul_Position[b_SSICpt] =
pul_Position[b_SSICpt] &
((dw_And1) - 1);
pul_TurnCpt[b_SSICpt] =
dw_CounterValue >>
b_Length;
pul_TurnCpt[b_SSICpt] =
pul_TurnCpt[b_SSICpt] &
((dw_And2) - 1);
}
break;
default:
printk("Read Type Inputs Wrong\n");
} /* switch ending */
} else {
/***********************/
/* SSI not initialised */
/***********************/
DPRINTK("SSI not initialised\n");
i_ReturnValue = -4;
}
} else {
/**********************************/
/* The module is not a SSI module */
/**********************************/
DPRINTK("The module is not a SSI module\n");
i_ReturnValue = -3;
}
} else {
/***********************/
/* Module number error */
/***********************/
DPRINTK("Module number error\n");
i_ReturnValue = -2;
}
return i_ReturnValue;
}
/*
+----------------------------------------------------------------------------+
| Function Name : _INT_ i_APCI1710_ReadSSI1DigitalInput |
| (unsigned char_ b_BoardHandle, |
| unsigned char_ b_ModulNbr, |
| unsigned char_ b_InputChannel, |
| unsigned char *_ pb_ChannelStatus) |
+----------------------------------------------------------------------------+
| Task :
(0) Set the digital output from selected SSI module |
| (b_ModuleNbr) ON
(1) Set the digital output from selected SSI module |
| (b_ModuleNbr) OFF
(2)Read the status from selected SSI digital input |
| (b_InputChannel)
(3)Read the status from all SSI digital inputs from |
| selected SSI module (b_ModulNbr) |
+----------------------------------------------------------------------------+
| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710|
| unsigned char_ b_ModulNbr CR_AREF : Module number to |
| configure (0 to 3) |
| unsigned char_ b_InputChannel CR_CHAN : Selection from digital |
| data[0] which IOTYPE input ( 0 to 2) |
+----------------------------------------------------------------------------+
| Output Parameters : unsigned char *_ pb_ChannelStatus : Digital input channel |
| data[0] status |
| 0 : Channle is not active|
| 1 : Channle is active |
+----------------------------------------------------------------------------+
| Return Value : 0: No error |
| -1: The handle parameter of the board is wrong |
| -2: The module parameter is wrong |
| -3: The module is not a SSI module |
| -4: The selected SSI digital input is wrong |
+----------------------------------------------------------------------------+
*/
static int i_APCI1710_InsnBitsSSIDigitalIO(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned int *data)
{
struct addi_private *devpriv = dev->private;
int i_ReturnValue = 0;
unsigned int dw_StatusReg;
unsigned char b_ModulNbr;
unsigned char b_InputChannel;
unsigned char *pb_ChannelStatus;
unsigned char *pb_InputStatus;
unsigned char b_IOType;
i_ReturnValue = insn->n;
b_ModulNbr = (unsigned char) CR_AREF(insn->chanspec);
b_IOType = (unsigned char) data[0];
/**************************/
/* Test the module number */
/**************************/
if (b_ModulNbr < 4) {
/***********************/
/* Test if SSI counter */
/***********************/
if ((devpriv->s_BoardInfos.
dw_MolduleConfiguration[b_ModulNbr] &
0xFFFF0000UL) == APCI1710_SSI_COUNTER) {
switch (b_IOType) {
case APCI1710_SSI_SET_CHANNELON:
/*****************************/
/* Set the digital output ON */
/*****************************/
outl(1, devpriv->s_BoardInfos.ui_Address + 16 +
(64 * b_ModulNbr));
break;
case APCI1710_SSI_SET_CHANNELOFF:
/******************************/
/* Set the digital output OFF */
/******************************/
outl(0, devpriv->s_BoardInfos.ui_Address + 16 +
(64 * b_ModulNbr));
break;
case APCI1710_SSI_READ_1CHANNEL:
/******************************************/
/* Test the digital imnput channel number */
/******************************************/
b_InputChannel = (unsigned char) CR_CHAN(insn->chanspec);
pb_ChannelStatus = (unsigned char *) &data[0];
if (b_InputChannel <= 2) {
/**************************/
/* Read all digital input */
/**************************/
dw_StatusReg =
inl(devpriv->s_BoardInfos.
ui_Address + (64 * b_ModulNbr));
*pb_ChannelStatus =
(unsigned char) (((~dw_StatusReg) >> (4 +
b_InputChannel))
& 1);
} else {
/********************************/
/* Selected digital input error */
/********************************/
DPRINTK("Selected digital input error\n");
i_ReturnValue = -4;
}
break;
case APCI1710_SSI_READ_ALLCHANNEL:
/**************************/
/* Read all digital input */
/**************************/
pb_InputStatus = (unsigned char *) &data[0];
dw_StatusReg =
inl(devpriv->s_BoardInfos.ui_Address +
(64 * b_ModulNbr));
*pb_InputStatus =
(unsigned char) (((~dw_StatusReg) >> 4) & 7);
break;
default:
printk("IO type wrong\n");
} /* switch end */
} else {
/**********************************/
/* The module is not a SSI module */
/**********************************/
DPRINTK("The module is not a SSI module\n");
i_ReturnValue = -3;
}
} else {
/***********************/
/* Module number error */
/***********************/
DPRINTK("Module number error\n");
i_ReturnValue = -2;
}
return i_ReturnValue;
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,237 +0,0 @@
#include <linux/module.h>
#include <linux/pci.h>
#include <linux/interrupt.h>
#include <asm/i387.h>
#include "../comedidev.h"
#include "comedi_fc.h"
#include "amcc_s5933.h"
#define APCI1710_SAVE_INTERRUPT 1
union str_ModuleInfo {
/* Incremental counter infos */
struct {
union {
struct {
unsigned char b_ModeRegister1;
unsigned char b_ModeRegister2;
unsigned char b_ModeRegister3;
unsigned char b_ModeRegister4;
} s_ByteModeRegister;
unsigned int dw_ModeRegister1_2_3_4;
} s_ModeRegister;
struct {
unsigned int b_IndexInit:1;
unsigned int b_CounterInit:1;
unsigned int b_ReferenceInit:1;
unsigned int b_IndexInterruptOccur:1;
unsigned int b_CompareLogicInit:1;
unsigned int b_FrequencyMeasurementInit:1;
unsigned int b_FrequencyMeasurementEnable:1;
} s_InitFlag;
} s_SiemensCounterInfo;
/* SSI infos */
struct {
unsigned char b_SSIProfile;
unsigned char b_PositionTurnLength;
unsigned char b_TurnCptLength;
unsigned char b_SSIInit;
} s_SSICounterInfo;
/* TTL I/O infos */
struct {
unsigned char b_TTLInit;
unsigned char b_PortConfiguration[4];
} s_TTLIOInfo;
/* Digital I/O infos */
struct {
unsigned char b_DigitalInit;
unsigned char b_ChannelAMode;
unsigned char b_ChannelBMode;
unsigned char b_OutputMemoryEnabled;
unsigned int dw_OutputMemory;
} s_DigitalIOInfo;
/* 82X54 timer infos */
struct {
struct {
unsigned char b_82X54Init;
unsigned char b_InputClockSelection;
unsigned char b_InputClockLevel;
unsigned char b_OutputLevel;
unsigned char b_HardwareGateLevel;
unsigned int dw_ConfigurationWord;
} s_82X54TimerInfo[3];
unsigned char b_InterruptMask;
} s_82X54ModuleInfo;
/* Chronometer infos */
struct {
unsigned char b_ChronoInit;
unsigned char b_InterruptMask;
unsigned char b_PCIInputClock;
unsigned char b_TimingUnit;
unsigned char b_CycleMode;
double d_TimingInterval;
unsigned int dw_ConfigReg;
} s_ChronoModuleInfo;
/* Pulse encoder infos */
struct {
struct {
unsigned char b_PulseEncoderInit;
} s_PulseEncoderInfo[4];
unsigned int dw_SetRegister;
unsigned int dw_ControlRegister;
unsigned int dw_StatusRegister;
} s_PulseEncoderModuleInfo;
/* Tor conter infos */
struct {
struct {
unsigned char b_TorCounterInit;
unsigned char b_TimingUnit;
unsigned char b_InterruptEnable;
double d_TimingInterval;
unsigned int ul_RealTimingInterval;
} s_TorCounterInfo[2];
unsigned char b_PCIInputClock;
} s_TorCounterModuleInfo;
/* PWM infos */
struct {
struct {
unsigned char b_PWMInit;
unsigned char b_TimingUnit;
unsigned char b_InterruptEnable;
double d_LowTiming;
double d_HighTiming;
unsigned int ul_RealLowTiming;
unsigned int ul_RealHighTiming;
} s_PWMInfo[2];
unsigned char b_ClockSelection;
} s_PWMModuleInfo;
/* CDA infos */
struct {
unsigned char b_CDAEnable;
unsigned char b_FctSelection;
} s_CDAModuleInfo;
};
struct addi_private {
/* Pointer to the current process */
struct task_struct *tsk_Current;
struct {
unsigned int ui_Address;
unsigned char b_BoardVersion;
unsigned int dw_MolduleConfiguration[4];
} s_BoardInfos;
struct {
unsigned int ul_InterruptOccur;
unsigned int ui_Read;
unsigned int ui_Write;
struct {
unsigned char b_OldModuleMask;
unsigned int ul_OldInterruptMask;
unsigned int ul_OldCounterLatchValue;
} s_FIFOInterruptParameters[APCI1710_SAVE_INTERRUPT];
} s_InterruptParameters;
union str_ModuleInfo s_ModuleInfo[4];
};
static void fpu_begin(void)
{
kernel_fpu_begin();
}
static void fpu_end(void)
{
kernel_fpu_end();
}
#include "addi-data/hwdrv_APCI1710.c"
static irqreturn_t v_ADDI_Interrupt(int irq, void *d)
{
v_APCI1710_Interrupt(irq, d);
return IRQ_RETVAL(1);
}
static int apci1710_auto_attach(struct comedi_device *dev,
unsigned long context_unused)
{
struct pci_dev *pcidev = comedi_to_pci_dev(dev);
struct addi_private *devpriv;
int ret;
devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv));
if (!devpriv)
return -ENOMEM;
ret = comedi_pci_enable(dev);
if (ret)
return ret;
devpriv->s_BoardInfos.ui_Address = pci_resource_start(pcidev, 2);
if (pcidev->irq > 0) {
ret = request_irq(pcidev->irq, v_ADDI_Interrupt, IRQF_SHARED,
dev->board_name, dev);
if (ret == 0)
dev->irq = pcidev->irq;
}
i_ADDI_AttachPCI1710(dev);
i_APCI1710_Reset(dev);
return 0;
}
static void apci1710_detach(struct comedi_device *dev)
{
if (dev->iobase)
i_APCI1710_Reset(dev);
if (dev->irq)
free_irq(dev->irq, dev);
comedi_pci_disable(dev);
}
static struct comedi_driver apci1710_driver = {
.driver_name = "addi_apci_1710",
.module = THIS_MODULE,
.auto_attach = apci1710_auto_attach,
.detach = apci1710_detach,
};
static int apci1710_pci_probe(struct pci_dev *dev,
const struct pci_device_id *id)
{
return comedi_pci_auto_config(dev, &apci1710_driver, id->driver_data);
}
static DEFINE_PCI_DEVICE_TABLE(apci1710_pci_table) = {
{ PCI_DEVICE(PCI_VENDOR_ID_AMCC, APCI1710_BOARD_DEVICE_ID) },
{ 0 }
};
MODULE_DEVICE_TABLE(pci, apci1710_pci_table);
static struct pci_driver apci1710_pci_driver = {
.name = "addi_apci_1710",
.id_table = apci1710_pci_table,
.probe = apci1710_pci_probe,
.remove = comedi_pci_auto_unconfig,
};
module_comedi_pci_driver(apci1710_driver, apci1710_pci_driver);
MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
MODULE_LICENSE("GPL");