return;
}
+/* Programs 8254 counter chip. I don't know if this works for 8253.
+ * base_address is the lowest io address for the chip (the address of counter 0).
+ * counter_number is the counter you want to load (0,1 or 2)
+ * count is the number to load into the counter.
+ * You probably want to use mode 2.
+ * FMH
+ */
+static inline int i8254_load(unsigned int base_address,
+ unsigned int counter_number, unsigned int count, unsigned int mode)
+{
+ unsigned char byte;
+ static const int counter_control = 3;
+
+ if(counter_number > 2) return -1;
+ if(count > 0xffff) return -1;
+ if(mode > 5) return -1;
+ if(mode == 2 && count == 1) return -1;
+
+ byte = counter_number << 6;
+ byte |= 0x30; // load low then high byte
+ byte |= (mode << 1); // set counter mode
+ outb(byte, base_address + counter_control);
+ byte = count & 0xff; // lsb of counter value
+ outb(byte, base_address + counter_number);
+ byte = (count >> 8) & 0xff; // msb of counter value
+ outb(byte, base_address + counter_number);
+
+ return 0;
+}
#endif
#define DAS1800_BURST_LENGTH 0x8
#define DAS1800_BURST_RATE 0x9
#define DAS1800_QRAM_ADDRESS 0xa
-#define DAS1800_COUNTER(a) (0xc + a)
-#define DAS1800_COUNTER_CONTROL 0xf
+#define DAS1800_COUNTER 0xc
#define IOBASE2 0x400 //offset of additional ioports used on 'ao' cards
static int das1800_do_wbits(comedi_device *dev, comedi_subdevice *s, comedi_insn *insn, lsampl_t *data);
int das1800_set_frequency(comedi_device *dev);
-int das1800_load_counter(comedi_device *dev, unsigned int counterNumber, unsigned int counterValue, unsigned int mode);
unsigned int burst_convert_arg(unsigned int convert_arg, int round_mode);
unsigned int suggest_transfer_size(comedi_device *dev, unsigned long ns);
if(cmd.stop_src == TRIG_EXT)
{
// load counter 0 in mode 0
- das1800_load_counter(dev, 0, cmd.stop_arg, 0);
+ i8254_load(dev->iobase + DAS1800_COUNTER, 0, cmd.stop_arg, 0);
}
return 0;
int err = 0;
// counter 1, mode 2
- if(das1800_load_counter(dev, 1, devpriv->divisor1, 2)) err++;
+ if(i8254_load(dev->iobase + DAS1800_COUNTER, 1, devpriv->divisor1, 2)) err++;
// counter 2, mode 2
- if(das1800_load_counter(dev, 2, devpriv->divisor2, 2)) err++;
+ if(i8254_load(dev->iobase + DAS1800_COUNTER, 2, devpriv->divisor2, 2)) err++;
if(err)
return -1;
return 0;
}
-/* programs onboard intel 82c54 counter chip */
-int das1800_load_counter(comedi_device *dev, unsigned int counterNumber, unsigned int counterValue, unsigned int mode)
-{
- unsigned char byte;
-
- if(counterNumber > 2) return -1;
- if(counterValue == 1 || counterValue > 0xffff) return -1;
- if(mode > 5) return -1;
-
- byte = counterNumber << 6;
- byte = byte | 0x30; // load low then high byte
- byte = byte | (mode << 1); // set counter mode
- outb(byte, dev->iobase + DAS1800_COUNTER_CONTROL);
- byte = counterValue & 0xff; // lsb of counter value
- outb(byte, dev->iobase + DAS1800_COUNTER(counterNumber));
- byte = counterValue >> 8; // msb of counter value
- outb(byte, dev->iobase + DAS1800_COUNTER(counterNumber));
- return 0;
-}
-
/* converts requested conversion timing to timing compatible with
* hardware, used only when card is in 'burst mode'
*/
#define CONV_CONTROL 0xa0
#define SCAN_LIMITS 0xc0
#define ID 0xe0
+#define DAS800_8254 4
#define DAS800_STATUS2 7
#define STATUS2_HCEN 0x80
#define STATUS2_INTE 0X20
static int das800_do_wbits(comedi_device *dev, comedi_subdevice *s, comedi_insn *insn, lsampl_t *data);
int das800_probe(comedi_device *dev);
int das800_set_frequency(comedi_device *dev);
-int das800_load_counter(unsigned int counterNumber, unsigned int counterValue, comedi_device *dev);
/* checks and probes das-800 series board type */
int das800_probe(comedi_device *dev)
{
int err = 0;
- if(das800_load_counter(1, devpriv->divisor1, dev)) err++;
- if(das800_load_counter(2, devpriv->divisor2, dev)) err++;
+ if(i8254_load(dev->iobase + DAS800_8254, 1, devpriv->divisor1, 2)) err++;
+ if(i8254_load(dev->iobase + DAS800_8254, 2, devpriv->divisor2, 2)) err++;
if(err)
return -1;
return 0;
}
-
-int das800_load_counter(unsigned int counterNumber, unsigned int counterValue, comedi_device *dev)
-{
- unsigned char byte;
-
- if(counterNumber > 2) return -1;
- if(counterValue == 1 || counterValue > 0xffff) return -1;
-
- byte = counterNumber << 6;
- byte = byte | 0x30; // load low then high byte
- byte = byte | 0x4; // set counter mode 2
- outb(byte, dev->iobase + 0x7);
- byte = counterValue & 0xff; // lsb of counter value
- outb(byte, dev->iobase + 0x4 + counterNumber);
- byte = counterValue >> 8; // msb of counter value
- outb(byte, dev->iobase + 0x4 + counterNumber);
- return 0;
-}