50 static int i_TimerCounter1Init = 0;
51 static int i_TimerCounter2Init = 0;
52 static int i_WatchdogCounter3Init = 0;
53 static int i_Event1Status = 0, i_Event2Status = 0;
54 static int i_TimerCounterWatchdogInterrupt = 0;
55 static int i_Logic = 0, i_CounterLogic = 0;
56 static int i_InterruptMask = 0;
57 static int i_InputChannel = 0;
58 static int i_TimerCounter1Enabled = 0, i_TimerCounter2Enabled = 0,
59 i_WatchdogCounter3Enabled = 0;
144 int i_PatternPolarity = 0, i_PatternTransition = 0, i_PatternMask = 0;
145 int i_MaxChannel = 0, i_Count = 0, i_EventMask = 0;
146 int i_PatternTransitionCount = 0, i_RegValue;
167 printk(
"\nThe specified port event does not exist\n");
182 printk(
"\nThe specified interrupt logic does not exist\n");
187 for (i_Count = i_MaxChannel, i = 0; i_Count > 0; i_Count--, i++) {
188 i_EventMask = data[2 +
i];
189 switch (i_EventMask) {
192 i_PatternMask | (1 << (i_MaxChannel - i_Count));
196 i_PatternMask | (1 << (i_MaxChannel - i_Count));
198 i_PatternPolarity | (1 << (i_MaxChannel -
203 i_PatternMask | (1 << (i_MaxChannel - i_Count));
204 i_PatternTransition =
205 i_PatternTransition | (1 << (i_MaxChannel -
210 i_PatternMask | (1 << (i_MaxChannel - i_Count));
212 i_PatternPolarity | (1 << (i_MaxChannel -
214 i_PatternTransition =
215 i_PatternTransition | (1 << (i_MaxChannel -
219 i_PatternTransition =
220 i_PatternTransition | (1 << (i_MaxChannel -
226 printk(
"\nThe option indicated in the event mask does not exist\n");
245 && i_PatternTransition != 0) {
249 printk(
"\nTransition error on an OR PRIORITY logic\n");
259 for (i_Count = 0; i_Count < 8; i_Count++) {
260 i_PatternTransitionCount =
261 i_PatternTransitionCount +
262 ((i_PatternTransition >>
267 if (i_PatternTransitionCount > 1) {
271 printk(
"\n Transition error on an AND logic\n");
294 outb(i_PatternPolarity,
315 outb(i_PatternTransition,
342 i_RegValue = (i_RegValue & 0xF9) | data[1] | 0x9;
365 printk(
"\nThe choice for interrupt logic does not exist\n");
410 i_RegValue = i_RegValue & 0xF9;
419 i_PatternMask = (i_PatternMask | 0xC0);
420 i_PatternPolarity = (i_PatternPolarity | 0xC0);
421 i_PatternTransition = (i_PatternTransition | 0xC0);
429 outb(i_PatternPolarity,
439 outb(i_PatternTransition,
471 i_RegValue = (i_RegValue & 0xF9) | 4;
493 printk(
"\nThe choice for interrupt logic does not exist\n");
523 static int i_APCI1500_StartStopInputEvent(
struct comedi_device *dev,
528 int i_Event1InterruptStatus = 0, i_Event2InterruptStatus =
536 if (data[1] == 1 || data[1] == 2) {
545 if (i_Event1Status == 1) {
577 i_Event1InterruptStatus = 1;
597 printk(
"\nEvent 1 not initialised\n");
603 if (i_Event2Status == 1) {
645 i_Event2InterruptStatus = 1;
648 printk(
"\nEvent 2 not initialised\n");
654 printk(
"\nThe port parameter is in error\n");
665 if (data[1] == 1 || data[1] == 2) {
674 if (i_Event1Status == 1) {
706 i_Event1InterruptStatus = 0;
709 printk(
"\nEvent 1 not initialised\n");
717 if (i_Event2Status == 1) {
749 i_Event2InterruptStatus = 0;
752 printk(
"\nEvent 2 not initialised\n");
759 printk(
"\nThe port parameter is in error\n");
764 printk(
"\nThe option of START/STOP logic does not exist\n");
790 static int i_APCI1500_Initialisation(
struct comedi_device *dev,
964 static int i_APCI1500_ReadMoreDigitalInput(
struct comedi_device *dev,
969 unsigned int ui_PortValue = data[1];
970 unsigned int ui_Mask = 0;
971 unsigned int ui_Channel;
972 unsigned int ui_TmpValue = 0;
977 if (ui_Channel <= 15) {
981 *data = (ui_TmpValue >> ui_Channel) & 0x1;
984 printk(
"\nThe channel specification are in error\n");
992 switch (ui_Channel) {
995 *data = (*data >> (2 * ui_PortValue)) & ui_Mask;
999 *data = (*data >> (4 * ui_PortValue)) & ui_Mask;
1003 *data = (*data >> (8 * ui_PortValue)) & ui_Mask;
1009 printk(
"\nSpecified channel cannot be read \n");
1015 printk(
"\nThe specified functionality does not exist\n");
1049 static int i_APCI1500_ConfigDigitalOutputErrorInterrupt(
struct comedi_device *dev,
1054 devpriv->b_OutputMemoryStatus = data[0];
1077 static int i_APCI1500_WriteDigitalOutput(
struct comedi_device *dev,
1082 static unsigned int ui_Temp = 0;
1083 unsigned int ui_Temp1;
1087 if (!
devpriv->b_OutputMemoryStatus) {
1093 data[0] = (data[0] << ui_NoOfChannel) | ui_Temp;
1099 switch (ui_NoOfChannel) {
1104 data[2])) | ui_Temp;
1110 data[2])) | ui_Temp;
1116 data[2])) | ui_Temp;
1120 data[0] = data[0] | ui_Temp;
1134 printk(
"\nSpecified channel not supported\n");
1141 data[0] = ~data[0] & 0x1;
1143 ui_Temp1 = ui_Temp1 << ui_NoOfChannel;
1144 ui_Temp = ui_Temp | ui_Temp1;
1146 (data[0] << ui_NoOfChannel) ^
1148 data[0] = data[0] & ui_Temp;
1155 switch (ui_NoOfChannel) {
1158 data[0] = ~data[0] & 0x3;
1161 ui_Temp1 << 2 * data[2];
1162 ui_Temp = ui_Temp | ui_Temp1;
1167 0xffffffff) & ui_Temp;
1171 data[0] = ~data[0] & 0xf;
1174 ui_Temp1 << 4 * data[2];
1175 ui_Temp = ui_Temp | ui_Temp1;
1180 0xffffffff) & ui_Temp;
1184 data[0] = ~data[0] & 0xff;
1187 ui_Temp1 << 8 * data[2];
1188 ui_Temp = ui_Temp | ui_Temp1;
1193 0xffffffff) & ui_Temp;
1201 " chan spec wrong");
1211 printk(
"\nSpecified channel not supported\n");
1216 printk(
"\nSpecified functionality does not exist\n");
1272 static int i_APCI1500_ConfigCounterTimerWatchdog(
struct comedi_device *dev,
1277 int i_TimerCounterMode, i_MasterConfiguration;
1282 if (data[0] == 0 || data[0] == 1 || data[0] == 2) {
1287 printk(
"\nThe option for input clock selection does not exist\n");
1303 printk(
"\nThis choice is not a timer nor a counter\n");
1316 printk(
"\nThis option for single/continuous mode does not exist\n");
1320 i_TimerCounterMode = data[2] | data[4] | 7;
1325 if ((data[3] >= 0) && (data[3] <= 65535)) {
1338 outb(i_TimerCounterMode,
1370 data[3] = data[3] >> 8;
1387 i_MasterConfiguration =
1395 i_MasterConfiguration =
1396 i_MasterConfiguration | 0x40;
1408 outb(i_MasterConfiguration,
1443 printk(
"\nError in selection of interrupt enable or disable\n");
1448 printk(
"\nError in selection of reload value\n");
1451 i_TimerCounterWatchdogInterrupt = data[7];
1452 i_TimerCounter1Init = 1;
1464 printk(
"\nThis choice is not a timer nor a counter\n");
1477 printk(
"\nThis option for single/continuous mode does not exist\n");
1490 printk(
"\nThis choice for software or hardware trigger does not exist\n");
1503 printk(
"\nThis choice for software or hardware gate does not exist\n");
1507 i_TimerCounterMode = data[2] | data[4] | data[5] | data[6] | 7;
1513 if ((data[3] >= 0) && (data[3] <= 65535)) {
1526 outb(i_TimerCounterMode,
1558 data[3] = data[3] >> 8;
1575 i_MasterConfiguration =
1583 i_MasterConfiguration =
1584 i_MasterConfiguration | 0x20;
1596 outb(i_MasterConfiguration,
1631 printk(
"\nError in selection of interrupt enable or disable\n");
1636 printk(
"\nError in selection of reload value\n");
1639 i_TimerCounterWatchdogInterrupt = data[7];
1640 i_TimerCounter2Init = 1;
1652 printk(
"\nThis choice is not a watchdog nor a counter\n");
1665 printk(
"\nThis option for single/continuous mode does not exist\n");
1678 printk(
"\nThis choice for software or hardware gate does not exist\n");
1692 i_TimerCounterMode = data[2] | data[4] | 0x54;
1695 i_TimerCounterMode = data[2] | data[4] | data[6] | 7;
1701 if ((data[3] >= 0) && (data[3] <= 65535)) {
1714 outb(i_TimerCounterMode,
1746 data[3] = data[3] >> 8;
1763 i_MasterConfiguration =
1771 i_MasterConfiguration =
1772 i_MasterConfiguration | 0x10;
1784 outb(i_MasterConfiguration,
1826 printk(
"\nError in selection of interrupt enable or disable\n");
1831 printk(
"\nError in selection of reload value\n");
1834 i_TimerCounterWatchdogInterrupt = data[7];
1835 i_WatchdogCounter3Init = 1;
1839 printk(
"\nThe specified counter\timer option does not exist\n");
1841 i_CounterLogic = data[2];
1873 static int i_APCI1500_StartStopTriggerTimerCounterWatchdog(
struct comedi_device *dev,
1878 int i_CommandAndStatusValue;
1884 if (i_TimerCounter1Init == 1) {
1885 if (i_TimerCounterWatchdogInterrupt == 1) {
1886 i_CommandAndStatusValue = 0xC4;
1889 i_CommandAndStatusValue = 0xE4;
1894 i_TimerCounter1Enabled = 1;
1901 outb(i_CommandAndStatusValue,
1906 printk(
"\nCounter/Timer1 not configured\n");
1926 i_TimerCounter1Enabled = 0;
1930 if (i_TimerCounter1Init == 1) {
1931 if (i_TimerCounter1Enabled == 1) {
1936 i_CommandAndStatusValue = 0x6;
1943 i_CommandAndStatusValue = 0x2;
1952 outb(i_CommandAndStatusValue,
1957 printk(
"\nCounter/Timer1 not configured\n");
1963 printk(
"\nThe specified option for start/stop/trigger does not exist\n");
1971 if (i_TimerCounter2Init == 1) {
1972 if (i_TimerCounterWatchdogInterrupt == 1) {
1973 i_CommandAndStatusValue = 0xC4;
1976 i_CommandAndStatusValue = 0xE4;
1981 i_TimerCounter2Enabled = 1;
1988 outb(i_CommandAndStatusValue,
1993 printk(
"\nCounter/Timer2 not configured\n");
2013 i_TimerCounter2Enabled = 0;
2016 if (i_TimerCounter2Init == 1) {
2017 if (i_TimerCounter2Enabled == 1) {
2022 i_CommandAndStatusValue = 0x6;
2029 i_CommandAndStatusValue = 0x2;
2038 outb(i_CommandAndStatusValue,
2043 printk(
"\nCounter/Timer2 not configured\n");
2048 printk(
"\nThe specified option for start/stop/trigger does not exist\n");
2055 if (i_WatchdogCounter3Init == 1) {
2057 if (i_TimerCounterWatchdogInterrupt == 1) {
2058 i_CommandAndStatusValue = 0xC4;
2061 i_CommandAndStatusValue = 0xE4;
2066 i_WatchdogCounter3Enabled = 1;
2073 outb(i_CommandAndStatusValue,
2079 printk(
"\nWatchdog/Counter3 not configured\n");
2099 i_WatchdogCounter3Enabled = 0;
2105 if (i_WatchdogCounter3Init == 1) {
2106 if (i_WatchdogCounter3Enabled == 1) {
2111 i_CommandAndStatusValue = 0x6;
2118 i_CommandAndStatusValue = 0x2;
2127 outb(i_CommandAndStatusValue,
2132 printk(
"\nCounter3 not configured\n");
2138 if (i_WatchdogCounter3Init == 1) {
2151 printk(
"\nWatchdog 3 not configured\n");
2156 printk(
"\nWrong choice of watchdog/counter3\n");
2161 printk(
"\nThe specified option for start/stop/trigger does not exist\n");
2166 printk(
"\nThe specified choice for counter/watchdog/timer does not exist\n");
2196 static int i_APCI1500_ReadCounterTimerWatchdog(
struct comedi_device *dev,
2201 int i_CommandAndStatusValue;
2205 if (i_TimerCounter1Init == 1) {
2206 if (i_TimerCounter1Enabled == 1) {
2211 i_CommandAndStatusValue = 0xC;
2218 i_CommandAndStatusValue = 0x8;
2227 outb(i_CommandAndStatusValue,
2240 data[0] = data[0] << 8;
2241 data[0] = data[0] & 0xff00;
2250 printk(
"\nTimer/Counter1 not configured\n");
2256 if (i_TimerCounter2Init == 1) {
2257 if (i_TimerCounter2Enabled == 1) {
2262 i_CommandAndStatusValue = 0xC;
2269 i_CommandAndStatusValue = 0x8;
2278 outb(i_CommandAndStatusValue,
2291 data[0] = data[0] << 8;
2292 data[0] = data[0] & 0xff00;
2301 printk(
"\nTimer/Counter2 not configured\n");
2307 if (i_WatchdogCounter3Init == 1) {
2308 if (i_WatchdogCounter3Enabled == 1) {
2313 i_CommandAndStatusValue = 0xC;
2320 i_CommandAndStatusValue = 0x8;
2329 outb(i_CommandAndStatusValue,
2342 data[0] = data[0] << 8;
2343 data[0] = data[0] & 0xff00;
2352 printk(
"\nWatchdogCounter3 not configured\n");
2357 printk(
"\nThe choice of timer/counter/watchdog does not exist\n");
2386 static int i_APCI1500_ReadInterruptMask(
struct comedi_device *dev,
2391 data[0] = i_InterruptMask;
2392 data[1] = i_InputChannel;
2393 i_InterruptMask = 0;
2419 static int i_APCI1500_ConfigureInterrupt(
struct comedi_device *dev,
2424 unsigned int ui_Status;
2437 printk(
"\nThe parameter passed to driver is in error for enabling the voltage interrupt\n");
2496 i_RegValue = (i_RegValue & 0x0F) | 0x20;
2510 i_RegValue = (i_RegValue & 0x0F) | 0x20;
2525 i_RegValue = (i_RegValue & 0x0F) | 0x20;
2540 i_RegValue = (i_RegValue & 0x0F) | 0x20;
2555 i_RegValue = (i_RegValue & 0x0F) | 0x20;
2572 ui_Status =
inl(
devpriv->i_IobaseAmcc + 0x10);
2573 ui_Status =
inl(
devpriv->i_IobaseAmcc + 0x38);
2596 static void v_APCI1500_Interrupt(
int irq,
void *
d)
2600 unsigned int ui_InterruptStatus = 0;
2602 i_InterruptMask = 0;
2607 ui_InterruptStatus =
inl(
devpriv->i_IobaseAmcc + 0x38);
2612 if ((ui_InterruptStatus & 0x800000) == 0x800000) {
2632 if ((i_RegValue & 0x60) == 0x60) {
2642 i_RegValue = (i_RegValue & 0x0F) | 0x20;
2646 i_InterruptMask = i_InterruptMask | 1;
2665 i_InputChannel = 1 + (i_RegValue >> 1);
2680 if ((i_RegValue & 0x60) == 0x60) {
2690 i_RegValue = (i_RegValue & 0x0F) | 0x20;
2702 i_RegValue = i_RegValue & 0xC0;
2714 if (i_RegValue & 0x80) {
2716 i_InterruptMask | 0x40;
2719 if (i_RegValue & 0x40) {
2721 i_InterruptMask | 0x80;
2725 i_InterruptMask = i_InterruptMask | 2;
2736 if ((i_RegValue & 0x60) == 0x60) {
2746 i_RegValue = (i_RegValue & 0x0F) | 0x20;
2750 i_InterruptMask = i_InterruptMask | 4;
2759 if ((i_RegValue & 0x60) == 0x60) {
2769 i_RegValue = (i_RegValue & 0x0F) | 0x20;
2773 i_InterruptMask = i_InterruptMask | 8;
2783 if ((i_RegValue & 0x60) == 0x60) {
2793 i_RegValue = (i_RegValue & 0x0F) | 0x20;
2798 i_InterruptMask = i_InterruptMask | 0x10;
2801 i_InterruptMask = i_InterruptMask | 0x20;
2821 printk(
"\nInterrupt from unknown source\n");
2843 int i_DummyRead = 0;
2844 i_TimerCounter1Init = 0;
2845 i_TimerCounter2Init = 0;
2846 i_WatchdogCounter3Init = 0;
2849 i_TimerCounterWatchdogInterrupt = 0;
2852 i_InterruptMask = 0;
2854 i_TimerCounter1Enabled = 0;
2855 i_TimerCounter2Enabled = 0;
2856 i_WatchdogCounter3Enabled = 0;