41 #include "../comedidev.h"
48 #define DMM32AT_MEMSIZE 0x10
50 #define DMM32AT_CONV 0x00
51 #define DMM32AT_AILSB 0x00
52 #define DMM32AT_AUXDOUT 0x01
53 #define DMM32AT_AIMSB 0x01
54 #define DMM32AT_AILOW 0x02
55 #define DMM32AT_AIHIGH 0x03
57 #define DMM32AT_DACLSB 0x04
58 #define DMM32AT_DACSTAT 0x04
59 #define DMM32AT_DACMSB 0x05
61 #define DMM32AT_FIFOCNTRL 0x07
62 #define DMM32AT_FIFOSTAT 0x07
64 #define DMM32AT_CNTRL 0x08
65 #define DMM32AT_AISTAT 0x08
67 #define DMM32AT_INTCLOCK 0x09
69 #define DMM32AT_CNTRDIO 0x0a
71 #define DMM32AT_AICONF 0x0b
72 #define DMM32AT_AIRBACK 0x0b
74 #define DMM32AT_CLK1 0x0d
75 #define DMM32AT_CLK2 0x0e
76 #define DMM32AT_CLKCT 0x0f
78 #define DMM32AT_DIOA 0x0c
79 #define DMM32AT_DIOB 0x0d
80 #define DMM32AT_DIOC 0x0e
81 #define DMM32AT_DIOCONF 0x0f
86 #define DMM32AT_DACBUSY 0x80
89 #define DMM32AT_FIFORESET 0x02
90 #define DMM32AT_SCANENABLE 0x04
93 #define DMM32AT_RESET 0x20
94 #define DMM32AT_INTRESET 0x08
95 #define DMM32AT_CLKACC 0x00
96 #define DMM32AT_DIOACC 0x01
99 #define DMM32AT_STATUS 0x80
102 #define DMM32AT_ADINT 0x80
103 #define DMM32AT_CLKSEL 0x03
106 #define DMM32AT_FREQ12 0x80
109 #define DMM32AT_RANGE_U10 0x0c
110 #define DMM32AT_RANGE_U5 0x0d
111 #define DMM32AT_RANGE_B10 0x08
112 #define DMM32AT_RANGE_B5 0x00
113 #define DMM32AT_SCINT_20 0x00
114 #define DMM32AT_SCINT_15 0x10
115 #define DMM32AT_SCINT_10 0x20
116 #define DMM32AT_SCINT_5 0x30
119 #define DMM32AT_CLKCT1 0x56
120 #define DMM32AT_CLKCT2 0xb6
123 #define DMM32AT_DIENABLE 0x80
124 #define DMM32AT_DIRA 0x10
125 #define DMM32AT_DIRB 0x02
126 #define DMM32AT_DIRCL 0x01
127 #define DMM32AT_DIRCH 0x08
141 static const unsigned char dmm32at_rangebits[] = {
205 for (i = 0; i < 40000; i++) {
216 for (n = 0; n < insn->
n; n++) {
220 for (i = 0; i < 40000; i++) {
240 d = ((msb ^ 0x0080) << 8) +
lsb;
249 static int dmm32at_ns_to_timer(
unsigned int *
ns,
int round)
261 int start_chan,
gain,
i;
279 err |= cfc_check_trigger_is_unique(cmd->
convert_src);
280 err |= cfc_check_trigger_is_unique(cmd->
stop_src);
293 #define MAX_SCAN_SPEED 1000000
294 #define MIN_SCAN_SPEED 1000000000
392 (start_chan + i) % s->
n_chan) {
394 "entries in chanlist must be consecutive channels, counting upwards\n");
399 "entries in chanlist must all have the same gain\n");
411 static void dmm32at_setaitimer(
struct comedi_device *dev,
unsigned int nansec)
413 unsigned char lo1, lo2, hi2;
414 unsigned short both2;
418 both2 = nansec / 20000;
419 hi2 = (both2 & 0xff00) >> 8;
420 lo2 = both2 & 0x00ff;
446 unsigned char chanlo, chanhi,
status;
482 for (i = 0; i < 40000; i++) {
526 unsigned char intstat;
548 samp = ((msb ^ 0x0080) << 8) +
lsb;
582 for (i = 0; i < insn->
n; i++) {
587 lo = data[
i] & 0x00ff;
589 hi = (data[
i] >> 8) + chan * (1 << 6);
596 for (i = 0; i < 40000; i++) {
622 for (i = 0; i < insn->
n; i++)
633 unsigned char diobits;
638 s->
state &= ~data[0];
639 s->
state |= data[0] & data[1];
650 diobits = (s->
state & 0x00ff0000) >> 16;
654 diobits = (s->
state & 0x0000ff00) >> 8;
658 diobits = (s->
state & 0x000000ff);
680 static int dmm32at_dio_insn_config(
struct comedi_device *dev,
685 unsigned char chanbit;
725 unsigned char aihi, ailo, fifostat, aistat, intstat, airback;
778 ailo, aihi, fifostat);
780 "dmm32at: aistat=0x%02x intstat=0x%02x airback=0x%02x\n",
781 aistat, intstat, airback);
783 if ((ailo != 0x00) || (aihi != 0x1f) || (fifostat != 0x80) ||
784 (aistat != 0x60 || (intstat != 0x00) || airback != 0x0c)) {
801 if (alloc_private(dev,
sizeof(*devpriv)) < 0)
821 s->
do_cmd = dmm32at_ai_cmd;
823 s->
cancel = dmm32at_ai_cancel;
877 .driver_name =
"dmm32at",
879 .attach = dmm32at_attach,
880 .detach = dmm32at_detach,
881 .board_name = &dmm32at_boards[0].
name,