53 #include "../comedidev.h"
55 #include <asm/div64.h>
78 static const int nano_per_micro = 1000;
89 static short fake_sawtooth(
struct comedi_device *
dev,
unsigned int range_index,
90 unsigned long current_time)
105 value = current_time;
106 value *= binary_amplitude * 2;
108 value -= binary_amplitude;
110 return offset +
value;
114 unsigned int range_index,
115 unsigned long current_time)
129 if (current_time < devpriv->usec_period / 2)
132 return offset +
value;
135 static short fake_flatline(
struct comedi_device *dev,
unsigned int range_index,
136 unsigned long current_time)
143 unsigned int range,
unsigned long current_time)
151 return fake_sawtooth(dev, range, current_time);
154 return fake_squarewave(dev, range, current_time);
160 return fake_flatline(dev, range, current_time);
168 static void waveform_ai_interrupt(
unsigned long arg)
176 unsigned long elapsed_time;
177 unsigned int num_scans;
183 1000000 * (now.tv_sec - devpriv->
last.tv_sec) + now.tv_usec -
184 devpriv->
last.tv_usec;
192 for (i = 0; i < num_scans; i++) {
247 err |= cfc_check_trigger_is_unique(cmd->
convert_src);
248 err |= cfc_check_trigger_is_unique(cmd->
stop_src);
314 nano_per_micro * ((tmp +
315 (nano_per_micro / 2)) / nano_per_micro);
323 nano_per_micro * ((tmp +
324 (nano_per_micro / 2)) / nano_per_micro);
343 "commands at RT priority not supported in this driver");
386 for (i = 0; i < insn->
n; i++)
399 for (i = 0; i < insn->
n; i++)
410 int amplitude = it->
options[0];
417 ret = alloc_private(dev,
sizeof(*devpriv));
445 s->
do_cmd = waveform_ai_cmd;
447 s->
cancel = waveform_ai_cancel;
464 for (i = 0; i < s->
n_chan; i++)
468 devpriv->
timer.function = waveform_ai_interrupt;
469 devpriv->
timer.data = (
unsigned long)dev;
472 "%s: %i microvolt, %li microsecond waveform attached\n",
488 .driver_name =
"comedi_test",
490 .attach = waveform_attach,
491 .detach = waveform_detach,