unsigned short adcfifothresh; /* ADC FIFO threshold (PCI230+/260+) */
unsigned short adcg; /* ADCG register value */
unsigned char int_en; /* Interrupt enable bits */
- unsigned char ai_bipolar; /* Flag AI range is bipolar */
- unsigned char ao_bipolar; /* Flag AO range is bipolar */
unsigned char ier; /* Copy of interrupt enable register */
unsigned char intr_running; /* Flag set in interrupt routine */
unsigned char res_owner[NUM_RESOURCES]; /* Shared resource owners */
+ bool ai_bipolar:1; /* Flag AI range is bipolar */
+ bool ao_bipolar:1; /* Flag AO range is bipolar */
};
/* PCI230 clock source periods in ns */
/* PCI230 analogue gain bits for each input range. */
static const unsigned char pci230_ai_gain[7] = { 0, 1, 2, 3, 1, 2, 3 };
-/* PCI230 adccon bipolar flag for each analogue input range. */
-static const unsigned char pci230_ai_bipolar[7] = { 1, 1, 1, 1, 0, 0, 0 };
-
/* PCI230 analogue output range table */
static const struct comedi_lrange pci230_ao_range = {
2, {
}
};
-/* PCI230 daccon bipolar flag for each analogue output range. */
-static const unsigned char pci230_ao_bipolar[2] = { 0, 1 };
-
static unsigned short pci230_ai_read(struct comedi_device *dev)
{
const struct pci230_board *thisboard = comedi_board(dev);
adccon = PCI230_ADC_TRIG_Z2CT2 | PCI230_ADC_FIFO_EN;
/* Set Z2-CT2 output low to avoid any false triggers. */
i8254_set_mode(dev->iobase + PCI230_Z2_CT_BASE, 0, 2, I8254_MODE0);
- devpriv->ai_bipolar = pci230_ai_bipolar[range];
+ devpriv->ai_bipolar = comedi_range_is_bipolar(s, range);
if (aref == AREF_DIFF) {
/* Differential. */
gainshift = chan * 2;
* Set range - see analogue output range table; 0 => unipolar 10V,
* 1 => bipolar +/-10V range scale
*/
- devpriv->ao_bipolar = pci230_ao_bipolar[range];
+ devpriv->ao_bipolar = comedi_range_is_bipolar(s, range);
outw(range, devpriv->daqio + PCI230_DACCON);
for (i = 0; i < insn->n; i++) {
* 1 => bipolar +/-10V range scale
*/
range = CR_RANGE(cmd->chanlist[0]);
- devpriv->ao_bipolar = pci230_ao_bipolar[range];
+ devpriv->ao_bipolar = comedi_range_is_bipolar(s, range);
daccon = devpriv->ao_bipolar ? PCI230_DAC_OR_BIP : PCI230_DAC_OR_UNI;
/* Use DAC FIFO for hardware version 2 onwards. */
if (devpriv->hwver >= 2) {
unsigned int prev_chan = 0;
unsigned int prev_range = 0;
unsigned int prev_aref = 0;
- unsigned int prev_polarity = 0;
+ bool prev_bipolar = false;
unsigned int subseq_len = 0;
int i;
unsigned int chan = CR_CHAN(chanspec);
unsigned int range = CR_RANGE(chanspec);
unsigned int aref = CR_AREF(chanspec);
- unsigned int polarity = pci230_ai_bipolar[range];
+ bool bipolar = comedi_range_is_bipolar(s, range);
if (aref == AREF_DIFF && chan >= max_diff_chan) {
dev_dbg(dev->class_dev,
return -EINVAL;
}
- if (polarity != prev_polarity) {
+ if (bipolar != prev_bipolar) {
dev_dbg(dev->class_dev,
"%s: channel sequence ranges must be all bipolar or all unipolar\n",
__func__);
prev_chan = chan;
prev_range = range;
prev_aref = aref;
- prev_polarity = polarity;
+ prev_bipolar = bipolar;
}
if (subseq_len == 0)
}
range = CR_RANGE(cmd->chanlist[0]);
- devpriv->ai_bipolar = pci230_ai_bipolar[range];
+ devpriv->ai_bipolar = comedi_range_is_bipolar(s, range);
if (devpriv->ai_bipolar)
adccon |= PCI230_ADC_IR_BIP;
else