From: Frank Mori Hess Date: Fri, 18 Jan 2008 16:37:32 +0000 (+0000) Subject: Added comedi_set_filter() and comedi_set_routing() configuration X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=76791bfeed78109acdee5299718e355c2647f20a;p=comedilib.git Added comedi_set_filter() and comedi_set_routing() configuration instruction wrappers. --- diff --git a/demo/choose_filter.c b/demo/choose_filter.c index 781d1bb..f08db05 100644 --- a/demo/choose_filter.c +++ b/demo/choose_filter.c @@ -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; } diff --git a/demo/choose_routing.c b/demo/choose_routing.c index 845c7a8..830a2bf 100644 --- a/demo/choose_routing.c +++ b/demo/choose_routing.c @@ -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; } diff --git a/doc/extensions_funcref.txt b/doc/extensions_funcref.txt index acc3801..afcb545 100644 --- a/doc/extensions_funcref.txt +++ b/doc/extensions_funcref.txt @@ -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 filter + 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 routing + 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. diff --git a/include/comedilib.h b/include/comedilib.h index 64241c2..009ad85 100644 --- a/include/comedilib.h +++ b/include/comedilib.h @@ -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 diff --git a/lib/insn_config_wrappers.c b/lib/insn_config_wrappers.c index 19fef04..88d4a29 100644 --- a/lib/insn_config_wrappers.c +++ b/lib/insn_config_wrappers.c @@ -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; +} diff --git a/lib/version_script b/lib/version_script index 8a4cf15..d6e116c 100644 --- a/lib/version_script +++ b/lib/version_script @@ -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;