Moved some wrappers for INSN_CONFIG instructions into comedilib.
Will add some reference documentation for the new functions soon.
This commit is contained in:
parent
8e610500f3
commit
4d07ce9969
11 changed files with 214 additions and 209 deletions
|
@ -1,5 +1,5 @@
|
|||
|
||||
AC_INIT([comedilib], [0.8.1])
|
||||
AC_INIT([comedilib], [0.9.0])
|
||||
AC_CANONICAL_TARGET([])
|
||||
|
||||
AC_CONFIG_AUX_DIR([.])
|
||||
|
@ -22,9 +22,9 @@ AM_INIT_AUTOMAKE([-Wall -Werror])
|
|||
# age to 0.
|
||||
#
|
||||
# AS_LIBTOOL arguments are (prefix, current, revision, age)
|
||||
AS_LIBTOOL(COMEDILIB, 8, 1, 8)
|
||||
AS_LIBTOOL(COMEDILIB, 9, 0, 9)
|
||||
#libscxi c:r:a
|
||||
SCXI_SO_VERSION=8:0:8
|
||||
SCXI_SO_VERSION=9:0:9
|
||||
AC_SUBST(SCXI_SO_VERSION)
|
||||
|
||||
AM_CONFIG_HEADER(config.h)
|
||||
|
|
144
demo/common.c
144
demo/common.c
|
@ -142,147 +142,3 @@ void dump_cmd(FILE *out,comedi_cmd *cmd)
|
|||
cmd_src(cmd->stop_src,buf),
|
||||
cmd->stop_arg);
|
||||
}
|
||||
|
||||
int arm(comedi_t *device, unsigned subdevice, lsampl_t source)
|
||||
{
|
||||
comedi_insn insn;
|
||||
lsampl_t data[2];
|
||||
int retval;
|
||||
|
||||
memset(&insn, 0, sizeof(comedi_insn));
|
||||
insn.insn = INSN_CONFIG;
|
||||
insn.subdev = subdevice;
|
||||
insn.chanspec = 0;
|
||||
insn.data = data;
|
||||
insn.n = sizeof(data) / sizeof(data[0]);
|
||||
data[0] = INSN_CONFIG_ARM;
|
||||
data[1] = source;
|
||||
|
||||
retval = comedi_do_insn(device, &insn);
|
||||
if(retval < 0)
|
||||
{
|
||||
fprintf(stderr, "%s: error:\n", __FUNCTION__);
|
||||
comedi_perror("comedi_do_insn");
|
||||
return retval;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* This resets the count to zero and disarms the counter. The counter output
|
||||
is set low. */
|
||||
int reset_counter(comedi_t *device, unsigned subdevice)
|
||||
{
|
||||
comedi_insn insn;
|
||||
lsampl_t data[1];
|
||||
int retval;
|
||||
|
||||
memset(&insn, 0, sizeof(comedi_insn));
|
||||
insn.insn = INSN_CONFIG;
|
||||
insn.subdev = subdevice;
|
||||
insn.chanspec = 0;
|
||||
insn.data = data;
|
||||
insn.n = sizeof(data) / sizeof(data[0]);
|
||||
data[0] = INSN_CONFIG_RESET;
|
||||
|
||||
retval = comedi_do_insn(device, &insn);
|
||||
if(retval < 0)
|
||||
{
|
||||
fprintf(stderr, "%s: error:\n", __FUNCTION__);
|
||||
comedi_perror("comedi_do_insn");
|
||||
return retval;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int set_counter_mode(comedi_t *device, unsigned subdevice, lsampl_t mode_bits)
|
||||
{
|
||||
comedi_insn insn;
|
||||
lsampl_t data[2];
|
||||
int retval;
|
||||
|
||||
memset(&insn, 0, sizeof(comedi_insn));
|
||||
insn.insn = INSN_CONFIG;
|
||||
insn.subdev = subdevice;
|
||||
insn.chanspec = 0;
|
||||
insn.data = data;
|
||||
insn.n = sizeof(data) / sizeof(data[0]);
|
||||
data[0] = INSN_CONFIG_SET_COUNTER_MODE;
|
||||
data[1] = mode_bits;
|
||||
|
||||
retval = comedi_do_insn(device, &insn);
|
||||
if(retval < 0)
|
||||
{
|
||||
fprintf(stderr, "%s: error:\n", __FUNCTION__);
|
||||
comedi_perror("comedi_do_insn");
|
||||
return retval;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int set_clock_source(comedi_t *device, unsigned subdevice, lsampl_t clock, lsampl_t period_ns)
|
||||
{
|
||||
comedi_insn insn;
|
||||
lsampl_t data[3];
|
||||
int retval;
|
||||
|
||||
memset(&insn, 0, sizeof(comedi_insn));
|
||||
insn.insn = INSN_CONFIG;
|
||||
insn.subdev = subdevice;
|
||||
insn.chanspec = 0;
|
||||
insn.data = data;
|
||||
insn.n = sizeof(data) / sizeof(data[0]);
|
||||
data[0] = INSN_CONFIG_SET_CLOCK_SRC;
|
||||
data[1] = clock;
|
||||
data[2] = period_ns;
|
||||
|
||||
retval = comedi_do_insn(device, &insn);
|
||||
if(retval < 0)
|
||||
{
|
||||
fprintf(stderr, "%s: error:\n", __FUNCTION__);
|
||||
comedi_perror("comedi_do_insn");
|
||||
return retval;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int set_gate_source(comedi_t *device, unsigned subdevice, lsampl_t gate_index, lsampl_t gate_source)
|
||||
{
|
||||
comedi_insn insn;
|
||||
lsampl_t data[3];
|
||||
int retval;
|
||||
|
||||
memset(&insn, 0, sizeof(comedi_insn));
|
||||
insn.insn = INSN_CONFIG;
|
||||
insn.subdev = subdevice;
|
||||
insn.chanspec = 0;
|
||||
insn.data = data;
|
||||
insn.n = sizeof(data) / sizeof(data[0]);
|
||||
data[0] = INSN_CONFIG_SET_GATE_SRC;
|
||||
data[1] = gate_index;
|
||||
data[2] = gate_source;
|
||||
|
||||
retval = comedi_do_insn(device, &insn);
|
||||
if(retval < 0)
|
||||
{
|
||||
fprintf(stderr, "%s: error:\n", __FUNCTION__);
|
||||
comedi_perror("comedi_do_insn");
|
||||
return retval;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int comedi_internal_trigger(comedi_t *dev, unsigned int subd, unsigned int trignum)
|
||||
{
|
||||
comedi_insn insn;
|
||||
lsampl_t data[1];
|
||||
|
||||
memset(&insn, 0, sizeof(comedi_insn));
|
||||
insn.insn = INSN_INTTRIG;
|
||||
insn.subdev = subd;
|
||||
insn.data = data;
|
||||
insn.n = 1;
|
||||
|
||||
data[0] = trignum;
|
||||
|
||||
return comedi_do_insn(dev, &insn);
|
||||
}
|
||||
|
|
|
@ -29,13 +29,6 @@ extern void init_parsed_options(struct parsed_options *options);
|
|||
extern int parse_options(struct parsed_options *options, int argc, char *argv[]);
|
||||
extern char *cmd_src(int src,char *buf);
|
||||
extern void dump_cmd(FILE *file,comedi_cmd *cmd);
|
||||
/* some helper functions used primarily for counter demos */
|
||||
extern int arm(comedi_t *device, unsigned subdevice, lsampl_t source);
|
||||
extern int reset_counter(comedi_t *device, unsigned subdevice);
|
||||
extern int set_counter_mode(comedi_t *device, unsigned subdevice, lsampl_t mode_bits);
|
||||
extern int set_clock_source(comedi_t *device, unsigned subdevice, lsampl_t clock, lsampl_t period_ns);
|
||||
extern int set_gate_source(comedi_t *device, unsigned subdevice, lsampl_t gate_index, lsampl_t gate_source);
|
||||
extern int comedi_internal_trigger(comedi_t *dev, unsigned int subd, unsigned int trignum);
|
||||
|
||||
#define sec_to_nsec(x) ((x)*1000000000)
|
||||
#define sec_to_usec(x) ((x)*1000000)
|
||||
|
|
|
@ -73,12 +73,18 @@ int ni_gpct_configure_buffered_event_counting(comedi_t *device, unsigned subdevi
|
|||
static const unsigned gate_pfi_channel = 1;
|
||||
static const unsigned initial_count = 0;
|
||||
|
||||
retval = reset_counter(device, subdevice);
|
||||
retval = comedi_reset(device, subdevice);
|
||||
if(retval < 0) return retval;
|
||||
|
||||
retval = set_gate_source(device, subdevice, 0, NI_GPCT_PFI_GATE_SELECT(gate_pfi_channel) /*| CR_EDGE*/);
|
||||
#if 1
|
||||
// PFI gate select works for e and m series
|
||||
retval = comedi_set_gate_source(device, subdevice, 0, NI_GPCT_PFI_GATE_SELECT(gate_pfi_channel) /*| CR_EDGE*/);
|
||||
#else
|
||||
// gate pin gate select works for 660x
|
||||
retval = comedi_set_gate_source(device, subdevice, 0, NI_GPCT_GATE_PIN_i_GATE_SELECT /*| CR_EDGE*/);
|
||||
#endif
|
||||
if(retval < 0) return retval;
|
||||
retval = set_gate_source(device, subdevice, 1, NI_GPCT_DISABLED_GATE_SELECT | CR_EDGE);
|
||||
retval = comedi_set_gate_source(device, subdevice, 1, NI_GPCT_DISABLED_GATE_SELECT | CR_EDGE);
|
||||
if(retval < 0)
|
||||
{
|
||||
fprintf(stderr, "Failed to set second gate source. This is expected for older boards (e-series, etc.)\n"
|
||||
|
@ -100,7 +106,7 @@ int ni_gpct_configure_buffered_event_counting(comedi_t *device, unsigned subdevi
|
|||
counter_mode |= NI_GPCT_STOP_ON_GATE_BITS;
|
||||
// don't disarm on terminal count or gate signal
|
||||
counter_mode |= NI_GPCT_NO_HARDWARE_DISARM_BITS;
|
||||
retval = set_counter_mode(device, subdevice, counter_mode);
|
||||
retval = comedi_set_counter_mode(device, subdevice, counter_mode);
|
||||
if(retval < 0) return retval;
|
||||
|
||||
/* Set initial counter value by writing to channel 0.*/
|
||||
|
@ -157,7 +163,6 @@ int ni_gpct_send_command(comedi_t *device, unsigned subdevice, unsigned n_counts
|
|||
|
||||
int ni_gpct_read_and_dump_counts(comedi_t *device, unsigned subdevice)
|
||||
{
|
||||
char subdevice_filename[100];
|
||||
int retval;
|
||||
int fd;
|
||||
static const unsigned buffer_size = 1000;
|
||||
|
@ -177,7 +182,7 @@ int ni_gpct_read_and_dump_counts(comedi_t *device, unsigned subdevice)
|
|||
}
|
||||
if(retval < 0)
|
||||
{
|
||||
fprintf(stderr, "error reading from subdevice file \"%s\".\n", subdevice_filename);
|
||||
fprintf(stderr, "error reading from subdevice file.\n");
|
||||
perror("read");
|
||||
return -errno;
|
||||
}
|
||||
|
|
|
@ -27,33 +27,6 @@
|
|||
#include <ctype.h>
|
||||
#include "examples.h"
|
||||
|
||||
int set_other_source(comedi_t *device, unsigned subdevice,
|
||||
lsampl_t index, lsampl_t source)
|
||||
{
|
||||
comedi_insn insn;
|
||||
lsampl_t data[3];
|
||||
int retval;
|
||||
|
||||
memset(&insn, 0, sizeof(comedi_insn));
|
||||
insn.insn = INSN_CONFIG;
|
||||
insn.subdev = subdevice;
|
||||
insn.chanspec = 0;
|
||||
insn.data = data;
|
||||
insn.n = sizeof(data) / sizeof(data[0]);
|
||||
data[0] = INSN_CONFIG_SET_OTHER_SRC;
|
||||
data[1] = index;
|
||||
data[2] = source;
|
||||
|
||||
retval = comedi_do_insn(device, &insn);
|
||||
if(retval < 0)
|
||||
{
|
||||
fprintf(stderr, "%s: error:\n", __FUNCTION__);
|
||||
comedi_perror("comedi_do_insn");
|
||||
return retval;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ni_gpct_start_encoder(comedi_t *device, unsigned subdevice,
|
||||
unsigned int initial_value,
|
||||
int a, int b, int z)
|
||||
|
@ -62,7 +35,7 @@ int ni_gpct_start_encoder(comedi_t *device, unsigned subdevice,
|
|||
lsampl_t counter_mode;
|
||||
|
||||
|
||||
retval = reset_counter(device, subdevice);
|
||||
retval = comedi_reset(device, subdevice);
|
||||
/* set initial counter value by writing to channel 0 */
|
||||
retval = comedi_data_write(device, subdevice, 0, 0, 0, initial_value);
|
||||
/* set "load a" register to initial_value by writing to channel 1 */
|
||||
|
@ -70,11 +43,11 @@ int ni_gpct_start_encoder(comedi_t *device, unsigned subdevice,
|
|||
/* set "load b" register to initial_value by writing to channel 2 */
|
||||
retval = comedi_data_write(device, subdevice, 2, 0, 0, initial_value);
|
||||
|
||||
set_gate_source(device, subdevice, 0, NI_GPCT_DISABLED_GATE_SELECT);
|
||||
set_gate_source(device, subdevice, 1, NI_GPCT_DISABLED_GATE_SELECT);
|
||||
set_other_source(device, subdevice, NI_GPCT_SOURCE_ENCODER_A, a);
|
||||
set_other_source(device, subdevice, NI_GPCT_SOURCE_ENCODER_B, b);
|
||||
set_other_source(device, subdevice, NI_GPCT_SOURCE_ENCODER_Z, z);
|
||||
comedi_set_gate_source(device, subdevice, 0, NI_GPCT_DISABLED_GATE_SELECT);
|
||||
comedi_set_gate_source(device, subdevice, 1, NI_GPCT_DISABLED_GATE_SELECT);
|
||||
comedi_set_other_source(device, subdevice, NI_GPCT_SOURCE_ENCODER_A, a);
|
||||
comedi_set_other_source(device, subdevice, NI_GPCT_SOURCE_ENCODER_B, b);
|
||||
comedi_set_other_source(device, subdevice, NI_GPCT_SOURCE_ENCODER_Z, z);
|
||||
|
||||
counter_mode = (NI_GPCT_COUNTING_MODE_QUADRATURE_X4_BITS |
|
||||
NI_GPCT_COUNTING_DIRECTION_HW_UP_DOWN_BITS);
|
||||
|
@ -82,10 +55,10 @@ int ni_gpct_start_encoder(comedi_t *device, unsigned subdevice,
|
|||
counter_mode |= (NI_GPCT_INDEX_ENABLE_BIT |
|
||||
NI_GPCT_INDEX_PHASE_HIGH_A_HIGH_B_BITS);
|
||||
}
|
||||
retval = set_counter_mode(device, subdevice, counter_mode);
|
||||
retval = comedi_set_counter_mode(device, subdevice, counter_mode);
|
||||
if(retval < 0) return retval;
|
||||
|
||||
retval = arm(device, subdevice, NI_GPCT_ARM_IMMEDIATE);
|
||||
retval = comedi_arm(device, subdevice, NI_GPCT_ARM_IMMEDIATE);
|
||||
if(retval < 0) return retval;
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -42,12 +42,12 @@ int ni_gpct_start_pulse_generator(comedi_t *device, unsigned subdevice, unsigned
|
|||
const unsigned clock_period_ns = 50; /* 20MHz clock */
|
||||
unsigned up_ticks, down_ticks;
|
||||
|
||||
retval = reset_counter(device, subdevice);
|
||||
retval = comedi_reset(device, subdevice);
|
||||
if(retval < 0) return retval;
|
||||
|
||||
retval = set_gate_source(device, subdevice, 0, NI_GPCT_DISABLED_GATE_SELECT | CR_EDGE);
|
||||
retval = comedi_set_gate_source(device, subdevice, 0, NI_GPCT_DISABLED_GATE_SELECT | CR_EDGE);
|
||||
if(retval < 0) return retval;
|
||||
retval = set_gate_source(device, subdevice, 1, NI_GPCT_DISABLED_GATE_SELECT | CR_EDGE);
|
||||
retval = comedi_set_gate_source(device, subdevice, 1, NI_GPCT_DISABLED_GATE_SELECT | CR_EDGE);
|
||||
if(retval < 0)
|
||||
{
|
||||
fprintf(stderr, "Failed to set second gate source. This is expected for older boards (e-series, etc.)\n"
|
||||
|
@ -69,11 +69,11 @@ int ni_gpct_start_pulse_generator(comedi_t *device, unsigned subdevice, unsigned
|
|||
counter_mode |= NI_GPCT_STOP_ON_GATE_BITS;
|
||||
// don't disarm on terminal count or gate signal
|
||||
counter_mode |= NI_GPCT_NO_HARDWARE_DISARM_BITS;
|
||||
retval = set_counter_mode(device, subdevice, counter_mode);
|
||||
retval = comedi_set_counter_mode(device, subdevice, counter_mode);
|
||||
if(retval < 0) return retval;
|
||||
|
||||
/* 20MHz clock */
|
||||
retval = set_clock_source(device, subdevice, NI_GPCT_TIMEBASE_1_CLOCK_SRC_BITS, clock_period_ns);
|
||||
retval = comedi_set_clock_source(device, subdevice, NI_GPCT_TIMEBASE_1_CLOCK_SRC_BITS, clock_period_ns);
|
||||
if(retval < 0) return retval;
|
||||
|
||||
up_ticks = (up_time_ns + clock_period_ns / 2) / clock_period_ns;
|
||||
|
@ -90,7 +90,7 @@ int ni_gpct_start_pulse_generator(comedi_t *device, unsigned subdevice, unsigned
|
|||
comedi_data_write(device, subdevice, 2, 0, 0, up_ticks);
|
||||
if(retval < 0) return retval;
|
||||
|
||||
retval = arm(device, subdevice, NI_GPCT_ARM_IMMEDIATE);
|
||||
retval = comedi_arm(device, subdevice, NI_GPCT_ARM_IMMEDIATE);
|
||||
if(retval < 0) return retval;
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -36,12 +36,12 @@ int ni_gpct_start_simple_event_counting(comedi_t *device, unsigned subdevice)
|
|||
lsampl_t counter_mode;
|
||||
static const unsigned initial_count = 0;
|
||||
|
||||
retval = reset_counter(device, subdevice);
|
||||
retval = comedi_reset(device, subdevice);
|
||||
if(retval < 0) return retval;
|
||||
|
||||
retval = set_gate_source(device, subdevice, 0, NI_GPCT_DISABLED_GATE_SELECT | CR_EDGE);
|
||||
retval = comedi_set_gate_source(device, subdevice, 0, NI_GPCT_GATE_PIN_GATE_SELECT(0) /* NI_GPCT_GATE_PIN_i_GATE_SELECT *//*| CR_EDGE*/);
|
||||
if(retval < 0) return retval;
|
||||
retval = set_gate_source(device, subdevice, 1, NI_GPCT_DISABLED_GATE_SELECT | CR_EDGE);
|
||||
retval = comedi_set_gate_source(device, subdevice, 1, NI_GPCT_DISABLED_GATE_SELECT | CR_EDGE);
|
||||
if(retval < 0)
|
||||
{
|
||||
fprintf(stderr, "Failed to set second gate source. This is expected for older boards (e-series, etc.)\n"
|
||||
|
@ -61,14 +61,14 @@ int ni_gpct_start_simple_event_counting(comedi_t *device, unsigned subdevice)
|
|||
counter_mode |= NI_GPCT_STOP_ON_GATE_BITS;
|
||||
// don't disarm on terminal count or gate signal
|
||||
counter_mode |= NI_GPCT_NO_HARDWARE_DISARM_BITS;
|
||||
retval = set_counter_mode(device, subdevice, counter_mode);
|
||||
retval = comedi_set_counter_mode(device, subdevice, counter_mode);
|
||||
if(retval < 0) return retval;
|
||||
|
||||
/* set initial counter value by writing to channel 0. The "load a" and "load b" registers can be
|
||||
set by writing to channels 1 and 2 respectively. */
|
||||
retval = comedi_data_write(device, subdevice, 0, 0, 0, initial_count);
|
||||
|
||||
retval = arm(device, subdevice, NI_GPCT_ARM_IMMEDIATE);
|
||||
retval = comedi_arm(device, subdevice, NI_GPCT_ARM_IMMEDIATE);
|
||||
if(retval < 0) return retval;
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -271,6 +271,16 @@ double comedi_to_physical(lsampl_t data,
|
|||
lsampl_t comedi_from_physical(double data,
|
||||
const comedi_polynomial_t *conversion_polynomial);
|
||||
|
||||
/* INSN_CONFIG wrappers */
|
||||
int comedi_reset(comedi_t *device, unsigned subdevice);
|
||||
int comedi_arm(comedi_t *device, unsigned subdevice, unsigned target);
|
||||
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_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);
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -13,11 +13,10 @@ MAINTAINERCLEANFILES = calib_lex.c calib_lex.h calib_yacc.c calib_yacc.h
|
|||
libcomedi_la_SOURCES = \
|
||||
buffer.c calib.c cmd.c comedi.c data.c dio.c error.c \
|
||||
filler.c get.c ioctl.c range.c sv.c timed.c timer.c \
|
||||
calib_lex.c calib_yacc.c
|
||||
calib_lex.c calib_yacc.c insn_config_wrappers.c
|
||||
|
||||
libcomedi_la_CFLAGS = $(COMEDILIB_CFLAGS) -D_REENTRANT -DLOCALSTATEDIR=\"\$(localstatedir)\"
|
||||
|
||||
|
||||
libcomedi_la_LDFLAGS = -soname libcomedi \
|
||||
$(COMEDILIB_LT_LDFLAGS) \
|
||||
-Wl,--version-script=$(srcdir)/version_script
|
||||
|
@ -27,4 +26,3 @@ $(srcdir)/calib_yacc.c $(srcdir)/calib_yacc.h: $(srcdir)/calib_yacc.y
|
|||
|
||||
$(srcdir)/calib_lex.c $(srcdir)/calib_lex.h: $(srcdir)/calib_lex.l
|
||||
$(LEX) --header-file=$(srcdir)/calib_lex.h -Pcalib_yy -o$(srcdir)/calib_lex.c $<
|
||||
|
||||
|
|
163
lib/insn_config_wrappers.c
Normal file
163
lib/insn_config_wrappers.c
Normal file
|
@ -0,0 +1,163 @@
|
|||
/*
|
||||
lib/insn_config_wrappers.c
|
||||
wrappers for various INSN_CONFIG instructions
|
||||
|
||||
COMEDILIB - Linux Control and Measurement Device Interface Library
|
||||
Copyright (C) 1997-2001 David A. Schleef <ds@schleef.org>
|
||||
Copyright (C) 2008 Frank Mori Hess <fmhess@users.sourceforge.net>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
USA.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "libinternal.h"
|
||||
|
||||
EXPORT_ALIAS_DEFAULT(_comedi_reset,comedi_reset,0.9.0);
|
||||
int _comedi_reset(comedi_t *device, unsigned subdevice)
|
||||
{
|
||||
comedi_insn insn;
|
||||
lsampl_t data[1];
|
||||
|
||||
memset(&insn, 0, sizeof(comedi_insn));
|
||||
insn.insn = INSN_CONFIG;
|
||||
insn.subdev = subdevice;
|
||||
insn.chanspec = 0;
|
||||
insn.data = data;
|
||||
insn.n = sizeof(data) / sizeof(data[0]);
|
||||
data[0] = INSN_CONFIG_RESET;
|
||||
|
||||
return comedi_do_insn(device, &insn);
|
||||
}
|
||||
|
||||
EXPORT_ALIAS_DEFAULT(_comedi_arm,comedi_arm,0.9.0);
|
||||
int _comedi_arm(comedi_t *device, unsigned subdevice, unsigned target)
|
||||
{
|
||||
comedi_insn insn;
|
||||
lsampl_t data[2];
|
||||
|
||||
memset(&insn, 0, sizeof(comedi_insn));
|
||||
insn.insn = INSN_CONFIG;
|
||||
insn.subdev = subdevice;
|
||||
insn.chanspec = 0;
|
||||
insn.data = data;
|
||||
insn.n = sizeof(data) / sizeof(data[0]);
|
||||
data[0] = INSN_CONFIG_ARM;
|
||||
data[1] = target;
|
||||
|
||||
return comedi_do_insn(device, &insn);
|
||||
}
|
||||
|
||||
EXPORT_ALIAS_DEFAULT(_comedi_set_counter_mode,comedi_set_counter_mode,0.9.0);
|
||||
int _comedi_set_counter_mode(comedi_t *device, unsigned subdevice, unsigned mode_bits)
|
||||
{
|
||||
comedi_insn insn;
|
||||
lsampl_t data[2];
|
||||
|
||||
memset(&insn, 0, sizeof(comedi_insn));
|
||||
insn.insn = INSN_CONFIG;
|
||||
insn.subdev = subdevice;
|
||||
insn.chanspec = 0;
|
||||
insn.data = data;
|
||||
insn.n = sizeof(data) / sizeof(data[0]);
|
||||
data[0] = INSN_CONFIG_SET_COUNTER_MODE;
|
||||
data[1] = mode_bits;
|
||||
|
||||
return comedi_do_insn(device, &insn);
|
||||
}
|
||||
|
||||
EXPORT_ALIAS_DEFAULT(_comedi_set_clock_source,comedi_set_clock_source,0.9.0);
|
||||
int _comedi_set_clock_source(comedi_t *device, unsigned subdevice, unsigned clock, unsigned period_ns)
|
||||
{
|
||||
comedi_insn insn;
|
||||
lsampl_t data[3];
|
||||
|
||||
memset(&insn, 0, sizeof(comedi_insn));
|
||||
insn.insn = INSN_CONFIG;
|
||||
insn.subdev = subdevice;
|
||||
insn.chanspec = 0;
|
||||
insn.data = data;
|
||||
insn.n = sizeof(data) / sizeof(data[0]);
|
||||
data[0] = INSN_CONFIG_SET_CLOCK_SRC;
|
||||
data[1] = clock;
|
||||
data[2] = period_ns;
|
||||
|
||||
return comedi_do_insn(device, &insn);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
comedi_insn insn;
|
||||
lsampl_t data[3];
|
||||
|
||||
memset(&insn, 0, sizeof(comedi_insn));
|
||||
insn.insn = INSN_CONFIG;
|
||||
insn.subdev = subdevice;
|
||||
insn.chanspec = 0;
|
||||
insn.data = data;
|
||||
insn.n = sizeof(data) / sizeof(data[0]);
|
||||
data[0] = INSN_CONFIG_SET_GATE_SRC;
|
||||
data[1] = gate_index;
|
||||
data[2] = gate_source;
|
||||
|
||||
return comedi_do_insn(device, &insn);
|
||||
}
|
||||
|
||||
EXPORT_ALIAS_DEFAULT(_comedi_internal_trigger,comedi_internal_trigger,0.9.0);
|
||||
int comedi_internal_trigger(comedi_t *dev, unsigned subd, unsigned trignum)
|
||||
{
|
||||
comedi_insn insn;
|
||||
lsampl_t data[1];
|
||||
|
||||
memset(&insn, 0, sizeof(comedi_insn));
|
||||
insn.insn = INSN_INTTRIG;
|
||||
insn.subdev = subd;
|
||||
insn.data = data;
|
||||
insn.n = 1;
|
||||
|
||||
data[0] = trignum;
|
||||
|
||||
return comedi_do_insn(dev, &insn);
|
||||
}
|
||||
|
||||
EXPORT_ALIAS_DEFAULT(_comedi_set_other_source,comedi_set_other_source,0.9.0);
|
||||
int _comedi_set_other_source(comedi_t *device, unsigned subdevice,
|
||||
unsigned other, unsigned source)
|
||||
{
|
||||
comedi_insn insn;
|
||||
lsampl_t data[3];
|
||||
int retval;
|
||||
|
||||
memset(&insn, 0, sizeof(comedi_insn));
|
||||
insn.insn = INSN_CONFIG;
|
||||
insn.subdev = subdevice;
|
||||
insn.chanspec = 0;
|
||||
insn.data = data;
|
||||
insn.n = sizeof(data) / sizeof(data[0]);
|
||||
data[0] = INSN_CONFIG_SET_OTHER_SRC;
|
||||
data[1] = other;
|
||||
data[2] = source;
|
||||
|
||||
retval = comedi_do_insn(device, &insn);
|
||||
if(retval < 0)
|
||||
{
|
||||
fprintf(stderr, "%s: error:\n", __FUNCTION__);
|
||||
comedi_perror("comedi_do_insn");
|
||||
return retval;
|
||||
}
|
||||
return 0;
|
||||
}
|
|
@ -96,4 +96,11 @@ v0.8.0 {
|
|||
v0.9.0 {
|
||||
global:
|
||||
comedi_get_cmd_generic_timed;
|
||||
comedi_reset;
|
||||
comedi_arm;
|
||||
comedi_set_counter_mode;
|
||||
comedi_set_clock_source;
|
||||
comedi_set_gate_source;
|
||||
comedi_internal_trigger;
|
||||
comedi_set_other_source;
|
||||
} v0.8.0;
|
||||
|
|
Loading…
Add table
Reference in a new issue