MODE_MULT_CHAN_DOWN,
};
-static const int labpc_plus_is_unipolar[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 1, 1, 1, 1, 1, 1, 1, 1,
-};
-
static const int labpc_plus_ai_gain_bits[] = {
0x00, 0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70,
0x00, 0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70,
}
};
-const int labpc_1200_is_unipolar[] = {
- 0, 0, 0, 0, 0, 0, 0,
- 1, 1, 1, 1, 1, 1, 1,
-};
-EXPORT_SYMBOL_GPL(labpc_1200_is_unipolar);
-
const int labpc_1200_ai_gain_bits[] = {
0x00, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70,
0x00, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70,
};
EXPORT_SYMBOL_GPL(range_labpc_1200_ai);
-#define AO_RANGE_IS_UNIPOLAR 0x1
static const struct comedi_lrange range_labpc_ao = {
2, {
BIP_RANGE(5),
.has_ao = 1,
.ai_range_table = &range_labpc_1200_ai,
.ai_range_code = labpc_1200_ai_gain_bits,
- .ai_range_is_unipolar = labpc_1200_is_unipolar,
.ai_scan_up = 1,
}, {
.name = "lab-pc-1200ai",
.register_layout = labpc_1200_layout,
.ai_range_table = &range_labpc_1200_ai,
.ai_range_code = labpc_1200_ai_gain_bits,
- .ai_range_is_unipolar = labpc_1200_is_unipolar,
.ai_scan_up = 1,
}, {
.name = "lab-pc+",
.has_ao = 1,
.ai_range_table = &range_labpc_plus_ai,
.ai_range_code = labpc_plus_ai_gain_bits,
- .ai_range_is_unipolar = labpc_plus_is_unipolar,
},
#ifdef CONFIG_COMEDI_PCI_DRIVERS
{
.has_ao = 1,
.ai_range_table = &range_labpc_1200_ai,
.ai_range_code = labpc_1200_ai_gain_bits,
- .ai_range_is_unipolar = labpc_1200_is_unipolar,
.ai_scan_up = 1,
.has_mmio = 1,
},
/* 2 bytes per sample */
static const int sample_size = 2;
+static bool labpc_range_is_unipolar(struct comedi_subdevice *s,
+ unsigned int range)
+{
+ const struct comedi_lrange *lrange = s->range_table;
+ const struct comedi_krange *krange = &lrange->range[range];
+
+ if (krange->min < 0)
+ return false;
+ else
+ return true;
+}
+
static void labpc_clear_adc_fifo(const struct comedi_device *dev)
{
struct labpc_private *devpriv = dev->private;
else
devpriv->cmd6 &= ~ADC_COMMON_BIT;
/* bipolar or unipolar range? */
- if (board->ai_range_is_unipolar[range])
+ if (labpc_range_is_unipolar(s, range))
devpriv->cmd6 |= ADC_UNIP_BIT;
else
devpriv->cmd6 &= ~ADC_UNIP_BIT;
else
devpriv->cmd6 &= ~ADC_COMMON_BIT;
/* bipolar or unipolar range? */
- if (board->ai_range_is_unipolar[range])
+ if (labpc_range_is_unipolar(s, range))
devpriv->cmd6 |= ADC_UNIP_BIT;
else
devpriv->cmd6 &= ~ADC_UNIP_BIT;
/* set range */
if (board->register_layout == labpc_1200_layout) {
range = CR_RANGE(insn->chanspec);
- if (range & AO_RANGE_IS_UNIPOLAR)
+ if (labpc_range_is_unipolar(s, range))
devpriv->cmd6 |= DAC_UNIP_BIT(channel);
else
devpriv->cmd6 &= ~DAC_UNIP_BIT(channel);