72 if ((
readl(
devpriv->dw_AiBase + 8) & 0x80000UL) == 0x80000UL)
106 static int i_APCI3XXX_AnalogInputConfigOperatingMode(
struct comedi_device *dev,
112 unsigned char b_TimeBase = 0;
113 unsigned char b_SingleDiff = 0;
114 unsigned int dw_ReloadValue = 0;
115 unsigned int dw_TestReloadValue = 0;
126 b_SingleDiff = (
unsigned char) data[1];
132 b_TimeBase = (
unsigned char) data[2];
138 dw_ReloadValue = (
unsigned int) data[3];
144 if ((
this_board->b_AvailableConvertUnit & (1 << b_TimeBase)) !=
150 if (dw_ReloadValue <= 65535) {
151 dw_TestReloadValue = dw_ReloadValue;
153 if (b_TimeBase == 1) {
155 dw_TestReloadValue * 1000
UL;
157 if (b_TimeBase == 2) {
159 dw_TestReloadValue * 1000000
UL;
166 if (dw_TestReloadValue >=
168 ui_MinAcquisitiontimeNs) {
173 && (
devpriv->s_EeParameters.i_NbrAiChannel == 0))
181 printk(
"Single/Diff selection error\n");
188 if (i_APCI3XXX_TestConversionStarted(dev) == 0) {
190 ui_EocEosConversionTime
195 b_EocEosConversionTimeBase
210 writel((
unsigned int)b_TimeBase,
223 printk(
"Any conversion started\n");
233 printk(
"Single/Diff selection error\n");
241 printk(
"Convert time value selection error\n");
249 printk(
"Convert time value selection error\n");
257 printk(
"Convert time base unity selection error\n");
265 printk(
"Buffer size error\n");
266 i_ReturnValue = -101;
295 static int i_APCI3XXX_InsnConfigAnalogInput(
struct comedi_device *dev,
300 int i_ReturnValue = insn->
n;
307 switch ((
unsigned char) data[0]) {
310 i_APCI3XXX_AnalogInputConfigOperatingMode(dev,
315 i_ReturnValue = -100;
316 printk(
"Config command error %d\n", data[0]);
324 printk(
"Buffer size error\n");
325 i_ReturnValue = -101;
356 static int i_APCI3XXX_InsnReadAnalogInput(
struct comedi_device *dev,
361 int i_ReturnValue = insn->
n;
364 unsigned int dw_Temp = 0;
365 unsigned int dw_Configuration = 0;
366 unsigned int dw_AcquisitionCpt = 0;
367 unsigned char b_Interrupt = 0;
373 if (
devpriv->b_AiInitialisation) {
378 if (((b_Channel < devpriv->s_EeParameters.i_NbrAiChannel)
380 || ((b_Channel <
this_board->i_NbrAiChannelDiff)
386 if (b_Configuration > 7) {
392 printk(
"Channel %d range %d selection error\n",
393 b_Channel, b_Configuration);
401 printk(
"Channel %d selection error\n", b_Channel);
408 if (i_ReturnValue >= 0) {
413 if ((b_Interrupt != 0) || ((b_Interrupt == 0)
414 && (insn->
n >= 1))) {
419 if (i_APCI3XXX_TestConversionStarted(dev) == 0) {
431 dw_Temp = dw_Temp & 0xFFFFFEF0
UL;
444 (b_Configuration & 3) |
445 ((
unsigned int) (b_Configuration >> 2)
462 writel((
unsigned int) b_Channel,
488 devpriv->ui_AiNbrofChannels = 1;
494 if (b_Interrupt == 0) {
495 for (dw_AcquisitionCpt = 0;
498 dw_AcquisitionCpt++) {
511 dw_Temp = dw_Temp & 1;
512 }
while (dw_Temp != 1);
518 data[dw_AcquisitionCpt] = (
unsigned int)
readl(
devpriv->dw_AiBase + 28);
532 printk(
"Any conversion started\n");
540 printk(
"Buffer size error\n");
541 i_ReturnValue = -101;
549 printk(
"Operating mode not configured\n");
571 static void v_APCI3XXX_Interrupt(
int irq,
void *
d)
574 unsigned char b_CopyCpt = 0;
575 unsigned int dw_Status = 0;
582 if ( (dw_Status & 0x2UL) == 0x2UL) {
593 if (
devpriv->b_EocEosInterrupt == 1) {
599 b_CopyCpt <
devpriv->ui_AiNbrofChannels;
601 devpriv->ui_AiReadData[b_CopyCpt] =
609 devpriv->b_EocEosInterrupt = 2;
649 static int i_APCI3XXX_InsnWriteAnalogOutput(
struct comedi_device *dev,
656 unsigned int dw_Status = 0;
657 int i_ReturnValue = insn->
n;
668 if (b_Channel < devpriv->s_EeParameters.i_NbrAoChannel) {
684 writel((data[0] << 8) | b_Channel,
693 }
while ((dw_Status & 0x100) != 0x100);
700 printk(
"Channel %d range %d selection error\n",
709 printk(
"Channel %d selection error\n", b_Channel);
716 printk(
"Buffer size error\n");
717 i_ReturnValue = -101;
753 static int i_APCI3XXX_InsnConfigInitTTLIO(
struct comedi_device *dev,
758 int i_ReturnValue = insn->
n;
759 unsigned char b_Command = 0;
770 b_Command = (
unsigned char) data[0];
787 printk(
"Buffer size error\n");
788 i_ReturnValue = -101;
795 printk(
"Command selection error\n");
796 i_ReturnValue = -100;
803 printk(
"Buffer size error\n");
804 i_ReturnValue = -101;
811 if ((i_ReturnValue >= 0)
817 if ((data[1] == 0) || (data[1] == 0xFF)) {
822 devpriv->ul_TTLPortConfiguration[0] =
823 devpriv->ul_TTLPortConfiguration[0] | data[1];
829 printk(
"Port 2 direction selection error\n");
838 if (i_ReturnValue >= 0) {
882 static int i_APCI3XXX_InsnBitsTTLIO(
struct comedi_device *dev,
887 int i_ReturnValue = insn->
n;
888 unsigned char b_ChannelCpt = 0;
889 unsigned int dw_ChannelMask = 0;
890 unsigned int dw_BitMask = 0;
891 unsigned int dw_Status = 0;
902 dw_ChannelMask = data[0];
903 dw_BitMask = data[1];
909 if (((dw_ChannelMask & 0XFF00FF00) == 0) &&
910 (((
devpriv->ul_TTLPortConfiguration[0] & 0xFF) == 0xFF)
911 || (((
devpriv->ul_TTLPortConfiguration[0] &
913 && ((dw_ChannelMask & 0XFF0000) ==
919 if (dw_ChannelMask) {
924 if (dw_ChannelMask & 0xFF) {
931 for (b_ChannelCpt = 0; b_ChannelCpt < 8;
933 if ((dw_ChannelMask >>
938 (0xFF - (1 << b_ChannelCpt))) | (dw_BitMask & (1 << b_ChannelCpt));
949 if (dw_ChannelMask & 0xFF0000) {
950 dw_BitMask = dw_BitMask >> 16;
951 dw_ChannelMask = dw_ChannelMask >> 16;
959 for (b_ChannelCpt = 0; b_ChannelCpt < 8;
961 if ((dw_ChannelMask >>
966 (0xFF - (1 << b_ChannelCpt))) | (dw_BitMask & (1 << b_ChannelCpt));
984 data[1] = data[1] | (
inl(
devpriv->iobase + 64) << 8);
990 if ((
devpriv->ul_TTLPortConfiguration[0] & 0xFF) == 0) {
1004 printk(
"Channel mask error\n");
1012 printk(
"Buffer size error\n");
1013 i_ReturnValue = -101;
1038 static int i_APCI3XXX_InsnReadTTLIO(
struct comedi_device *dev,
1044 int i_ReturnValue = insn->
n;
1045 unsigned int *pls_ReadData =
data;
1056 if (b_Channel < 8) {
1062 pls_ReadData[0] = (pls_ReadData[0] >> b_Channel) & 1;
1068 if ((b_Channel > 7) && (b_Channel < 16)) {
1075 (pls_ReadData[0] >> (b_Channel -
1082 if ((b_Channel > 15) && (b_Channel < 24)) {
1087 if ((
devpriv->ul_TTLPortConfiguration[0]
1094 (b_Channel - 16)) & 1;
1101 (b_Channel - 16)) & 1;
1109 printk(
"Channel %d selection error\n",
1119 printk(
"Buffer size error\n");
1120 i_ReturnValue = -101;
1152 static int i_APCI3XXX_InsnWriteTTLIO(
struct comedi_device *dev,
1157 int i_ReturnValue = insn->
n;
1159 unsigned char b_State = 0;
1160 unsigned int dw_Status = 0;
1167 b_State = (
unsigned char) data[0];
1173 if (b_Channel < 8) {
1180 (dw_Status & (0xFF -
1181 (1 << b_Channel))) | ((b_State & 1) <<
1189 if ((b_Channel > 15) && (b_Channel < 24)) {
1194 if ((
devpriv->ul_TTLPortConfiguration[0] & 0xFF)
1202 (dw_Status & (0xFF -
1205 ((b_State & 1) << (b_Channel -
1214 printk(
"Channel %d selection error\n",
1223 printk(
"Channel %d selection error\n",
1232 printk(
"Buffer size error\n");
1233 i_ReturnValue = -101;
1265 static int i_APCI3XXX_InsnReadDigitalInput(
struct comedi_device *dev,
1270 int i_ReturnValue = insn->
n;
1272 unsigned int dw_Temp = 0;
1278 if (b_Channel <= devpriv->s_EeParameters.i_NbrDiChannel) {
1285 *data = (dw_Temp >> b_Channel) & 1;
1291 printk(
"Buffer size error\n");
1292 i_ReturnValue = -101;
1299 printk(
"Channel selection error\n");
1325 static int i_APCI3XXX_InsnBitsDigitalInput(
struct comedi_device *dev,
1330 int i_ReturnValue = insn->
n;
1331 unsigned int dw_Temp = 0;
1339 *data = dw_Temp & 0xf;
1345 printk(
"Buffer size error\n");
1346 i_ReturnValue = -101;
1380 static int i_APCI3XXX_InsnBitsDigitalOutput(
struct comedi_device *dev,
1385 int i_ReturnValue = insn->
n;
1386 unsigned char b_ChannelCpt = 0;
1387 unsigned int dw_ChannelMask = 0;
1388 unsigned int dw_BitMask = 0;
1389 unsigned int dw_Status = 0;
1400 dw_ChannelMask = data[0];
1401 dw_BitMask = data[1];
1407 if ((dw_ChannelMask & 0XFFFFFFF0) == 0) {
1412 if (dw_ChannelMask & 0xF) {
1419 for (b_ChannelCpt = 0; b_ChannelCpt < 4;
1421 if ((dw_ChannelMask >> b_ChannelCpt) &
1425 (1 << b_ChannelCpt))) | (dw_BitMask & (1 << b_ChannelCpt));
1442 printk(
"Channel mask error\n");
1450 printk(
"Buffer size error\n");
1451 i_ReturnValue = -101;
1478 static int i_APCI3XXX_InsnWriteDigitalOutput(
struct comedi_device *dev,
1483 int i_ReturnValue = insn->
n;
1485 unsigned char b_State = 0;
1486 unsigned int dw_Status = 0;
1497 if (b_Channel < devpriv->s_EeParameters.i_NbrDoChannel) {
1502 b_State = (
unsigned char) data[0];
1512 (1 << b_Channel))) | ((b_State & 1) <<
1520 printk(
"Channel selection error\n");
1528 printk(
"Buffer size error\n");
1529 i_ReturnValue = -101;
1555 static int i_APCI3XXX_InsnReadDigitalOutput(
struct comedi_device *dev,
1560 int i_ReturnValue = insn->
n;
1562 unsigned int dw_Status = 0;
1573 if (b_Channel < devpriv->s_EeParameters.i_NbrDoChannel) {
1580 dw_Status = (dw_Status >> b_Channel) & 1;
1587 printk(
"Channel selection error\n");
1595 printk(
"Buffer size error\n");
1596 i_ReturnValue = -101;
1617 unsigned char b_Cpt = 0;
1629 devpriv->b_EocEosInterrupt = 0;
1653 for (b_Cpt = 0; b_Cpt < 16; b_Cpt++) {