Added comedi_set_filter() and comedi_set_routing() configuration
instruction wrappers.
This commit is contained in:
parent
64d656994a
commit
76791bfeed
6 changed files with 89 additions and 24 deletions
|
@ -36,8 +36,6 @@ int main(int argc, char *argv[])
|
|||
int retval;
|
||||
lsampl_t filter_selection;
|
||||
struct parsed_options options;
|
||||
comedi_insn insn;
|
||||
lsampl_t data[2];
|
||||
|
||||
init_parsed_options(&options);
|
||||
parse_options(&options, argc, argv);
|
||||
|
@ -49,16 +47,8 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
filter_selection = options.value;
|
||||
printf("Selecting filter %d on subdevice %d channel %d.\n", filter_selection, options.subdevice, options.channel);
|
||||
memset(&insn, 0, sizeof(comedi_insn));
|
||||
insn.insn = INSN_CONFIG;
|
||||
insn.subdev = options.subdevice;
|
||||
insn.chanspec = options.channel;
|
||||
insn.data = data;
|
||||
insn.n = sizeof(data) / sizeof(data[0]);
|
||||
data[0] = INSN_CONFIG_FILTER;
|
||||
data[1] = filter_selection;
|
||||
|
||||
retval = comedi_do_insn(device, &insn);
|
||||
retval = comedi_set_filter(device, options.subdevice, options.channel, filter_selection);
|
||||
if(retval < 0) comedi_perror("comedi_do_insn");
|
||||
return retval;
|
||||
}
|
||||
|
|
|
@ -36,8 +36,6 @@ int main(int argc, char *argv[])
|
|||
int retval;
|
||||
lsampl_t routing;
|
||||
struct parsed_options options;
|
||||
comedi_insn insn;
|
||||
lsampl_t data[2];
|
||||
|
||||
init_parsed_options(&options);
|
||||
options.freq = 0.;
|
||||
|
@ -54,16 +52,8 @@ int main(int argc, char *argv[])
|
|||
period_ns = 0;
|
||||
routing = options.value;
|
||||
printf("Selecting routing %d for channel %d on subdevice %d.\n", routing, options.channel, options.subdevice);
|
||||
memset(&insn, 0, sizeof(comedi_insn));
|
||||
insn.insn = INSN_CONFIG;
|
||||
insn.subdev = options.subdevice;
|
||||
insn.chanspec = options.channel;
|
||||
insn.data = data;
|
||||
insn.n = sizeof(data) / sizeof(data[0]);
|
||||
data[0] = INSN_CONFIG_SET_ROUTING;
|
||||
data[1] = routing;
|
||||
|
||||
retval = comedi_do_insn(device, &insn);
|
||||
retval = comedi_set_routing(device, options.subdevice, options.channel, routing);
|
||||
if(retval < 0) comedi_perror("comedi_do_insn");
|
||||
return retval;
|
||||
}
|
||||
|
|
|
@ -65,6 +65,29 @@ Description:
|
|||
Returns:
|
||||
0 on success, -1 on error.
|
||||
|
||||
Function: comedi_set_filter -- select a filter for a subdevice
|
||||
Retval: int
|
||||
Param: comedi_t * device
|
||||
Param: unsigned int subdevice
|
||||
Param: unsigned int channel
|
||||
Param: unsigned int filter
|
||||
Status: alpha
|
||||
Description:
|
||||
This function selects a filter for a subdevice. For instance, a digital
|
||||
input subdevice may provide deglitching filters with varying cutoff frequencies.
|
||||
The filters are used to prevent high-frequency
|
||||
noise from causing unwanted transitions on the digital inputs. This function can
|
||||
tell the hardware which deglitching filter to use, or to use none at all.
|
||||
|
||||
The <parameter>filter</parameter>
|
||||
parameter selects which of the subdevice's filters to use, and is driver-dependant.
|
||||
|
||||
This function is only useable
|
||||
on subdevices that provide support for the INSN_CONFIG_FILTER
|
||||
configuration instruction.
|
||||
Returns:
|
||||
0 on success, -1 on error.
|
||||
|
||||
Function: comedi_set_gate_source -- select gate source for a subdevice
|
||||
Retval: int
|
||||
Param: comedi_t * device
|
||||
|
@ -113,3 +136,23 @@ Description:
|
|||
configuration instruction.
|
||||
Returns:
|
||||
0 on success, -1 on error.
|
||||
|
||||
Function: comedi_set_routing -- select a signal for an output
|
||||
Retval: int
|
||||
Param: comedi_t * device
|
||||
Param: unsigned int subdevice
|
||||
Param: unsigned int channel
|
||||
Param: unsigned int routing
|
||||
Status: alpha
|
||||
Description:
|
||||
This function configures a mutiplexed output channel which can
|
||||
output a variety of different signals (such as NI's RTSI and PFI lines).
|
||||
The <parameter>routing</parameter>
|
||||
parameter selects which signal should be routed to appear on the
|
||||
selected output channel, and is driver-dependant.
|
||||
|
||||
This function is only useable
|
||||
on subdevices that provide support for the INSN_CONFIG_SET_ROUTING
|
||||
configuration instruction.
|
||||
Returns:
|
||||
0 on success, -1 on error.
|
||||
|
|
|
@ -271,15 +271,17 @@ double comedi_to_physical(lsampl_t data,
|
|||
lsampl_t comedi_from_physical(double data,
|
||||
const comedi_polynomial_t *conversion_polynomial);
|
||||
|
||||
int comedi_internal_trigger(comedi_t *dev, unsigned subd, unsigned trignum);
|
||||
/* INSN_CONFIG wrappers */
|
||||
int comedi_reset(comedi_t *device, unsigned subdevice);
|
||||
int comedi_arm(comedi_t *device, unsigned subdevice, unsigned source);
|
||||
int comedi_reset(comedi_t *device, unsigned subdevice);
|
||||
int comedi_set_counter_mode(comedi_t *device, unsigned subdevice, unsigned mode_bits);
|
||||
int comedi_set_clock_source(comedi_t *device, unsigned subdevice, unsigned clock, unsigned period_ns);
|
||||
int comedi_set_filter(comedi_t *device, unsigned subdevice, unsigned channel, unsigned filter);
|
||||
int comedi_set_gate_source(comedi_t *device, unsigned subdevice, unsigned gate_index, unsigned gate_source);
|
||||
int comedi_internal_trigger(comedi_t *dev, unsigned subd, unsigned trignum);
|
||||
int comedi_set_other_source(comedi_t *device, unsigned subdevice,
|
||||
unsigned other, unsigned source);
|
||||
int comedi_set_routing(comedi_t *device, unsigned subdevice, unsigned channel, unsigned routing);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -102,6 +102,25 @@ int _comedi_set_clock_source(comedi_t *device, unsigned subdevice, unsigned cloc
|
|||
else return -1;
|
||||
}
|
||||
|
||||
EXPORT_ALIAS_DEFAULT(_comedi_set_filter,comedi_set_filter,0.9.0);
|
||||
int _comedi_set_filter(comedi_t *device, unsigned subdevice, unsigned channel, unsigned filter)
|
||||
{
|
||||
comedi_insn insn;
|
||||
lsampl_t data[2];
|
||||
|
||||
memset(&insn, 0, sizeof(comedi_insn));
|
||||
insn.insn = INSN_CONFIG;
|
||||
insn.subdev = subdevice;
|
||||
insn.chanspec = channel;
|
||||
insn.data = data;
|
||||
insn.n = sizeof(data) / sizeof(data[0]);
|
||||
data[0] = INSN_CONFIG_FILTER;
|
||||
data[1] = filter;
|
||||
|
||||
if(comedi_do_insn(device, &insn) >= 0) return 0;
|
||||
else return -1;
|
||||
}
|
||||
|
||||
EXPORT_ALIAS_DEFAULT(_comedi_set_gate_source,comedi_set_gate_source,0.9.0);
|
||||
int _comedi_set_gate_source(comedi_t *device, unsigned subdevice, unsigned gate_index, unsigned gate_source)
|
||||
{
|
||||
|
@ -168,3 +187,22 @@ int _comedi_set_other_source(comedi_t *device, unsigned subdevice,
|
|||
if(comedi_do_insn(device, &insn) >= 0) return 0;
|
||||
else return -1;
|
||||
}
|
||||
|
||||
EXPORT_ALIAS_DEFAULT(_comedi_set_routing,comedi_set_routing,0.9.0);
|
||||
int _comedi_set_routing(comedi_t *device, unsigned subdevice, unsigned channel, unsigned routing)
|
||||
{
|
||||
comedi_insn insn;
|
||||
lsampl_t data[2];
|
||||
|
||||
memset(&insn, 0, sizeof(comedi_insn));
|
||||
insn.insn = INSN_CONFIG;
|
||||
insn.subdev = subdevice;
|
||||
insn.chanspec = channel;
|
||||
insn.data = data;
|
||||
insn.n = sizeof(data) / sizeof(data[0]);
|
||||
data[0] = INSN_CONFIG_SET_ROUTING;
|
||||
data[1] = routing;
|
||||
|
||||
if(comedi_do_insn(device, &insn) >= 0) return 0;
|
||||
else return -1;
|
||||
}
|
||||
|
|
|
@ -100,7 +100,9 @@ v0.9.0 {
|
|||
comedi_arm;
|
||||
comedi_set_counter_mode;
|
||||
comedi_set_clock_source;
|
||||
comedi_set_filter;
|
||||
comedi_set_gate_source;
|
||||
comedi_internal_trigger;
|
||||
comedi_set_other_source;
|
||||
comedi_set_routing;
|
||||
} v0.8.0;
|
||||
|
|
Loading…
Add table
Reference in a new issue