beginnings of scxi convenience library from Caleb Tennis
authorFrank Mori Hess <fmhess@speakeasy.net>
Sun, 29 Feb 2004 16:52:17 +0000 (16:52 +0000)
committerFrank Mori Hess <fmhess@speakeasy.net>
Sun, 29 Feb 2004 16:52:17 +0000 (16:52 +0000)
Makefile.am
configure.ac
include/Makefile.am
include/comedilib_scxi.h [new file with mode: 0644]
scxi/Makefile.am [new file with mode: 0644]
scxi/scxi.c [new file with mode: 0644]

index 3e2c4c85d82355336b9afae2be769dd1c8e44dd3..67c057847cfa2fe0b84fff679e1b343739f36416 100644 (file)
@@ -1,6 +1,6 @@
 
 SUBDIRS = lib comedi_calibrate comedi_config man testing demo doc swig \
-       include etc
+       include etc scxi
 
 #pkgconfigdir = $(libdir)/pkgconfig
 #pkgconfig_DATA = comedilib.pc
index 4f51e874779e1629fece533bcf095ab952b2df10..3f0cb76a40dae42aed9a87d6712489b76ba0bb6c 100644 (file)
@@ -44,8 +44,8 @@ AS_COMPILER_FLAG([-fno-strict-aliasing],[PYTHON_QUIET="$PYTHON_QUIET -fno-strict
 AS_COMPILER_FLAG([-Wno-unused-function],[PYTHON_QUIET="$PYTHON_QUIET -Wno-unused-function"], true )
 AC_SUBST(PYTHON_QUIET)
 
-AC_ARG_ENABLE([ruby-binding],[  --disable-ruby-binding Disable building of Ruby binding],
-       [ENABLE_RUBY=$enableval],[ENABLE_RUBY="yes"])
+AC_ARG_ENABLE([ruby-binding], [  --disable-ruby-binding        Disable building of Ruby binding],
+       [ENABLE_RUBY=$enableval], [ENABLE_RUBY="yes"])
 AC_PATH_PROG(RUBY, ruby, no)
 if test "$RUBY" != "no" ; then
        RUBY_INC_DIR=`$RUBY -e "require 'rbconfig'; c = ::Config::CONFIG; print c[['archdir']];"`
@@ -65,6 +65,10 @@ if test "$RUBY_SO_DIR" != "" ; then
 fi
 AC_SUBST(RUBY_CONFIG_OPTIONS)
 
+AC_ARG_ENABLE([scxi], [  --enable-scxi  Enable SCXI convenience library],
+       [ENABLE_SCXI=$enableval], [ENABLE_SCXI="no"])
+AM_CONDITIONAL(BUILD_SCXI, [test "$ENABLE_SCXI" == "yes"])
+
 AC_PATH_PROG(DOCBOOK2MAN, docbook2man, no)
 if test "$DOCBOOK2MAN" = "no" ; then
   AC_MSG_WARN([docbook2man not found, will not be able to rebuild man pages])
@@ -110,6 +114,7 @@ demo/Makefile
 include/Makefile
 lib/Makefile
 man/Makefile
+scxi/Makefile
 swig/Makefile
 swig/python/Makefile
 swig/ruby/Makefile
index 1c6be9891149c81992bc8bb0f77811140a75283b..efd2b439c45d68e376a00cd755be2a2292d1dfa6 100644 (file)
@@ -1,5 +1,5 @@
 
-EXTRA_DIST = comedi.h comedilib.h
+EXTRA_DIST = comedi.h comedilib.h comedilib_scxi.h
 
-include_HEADERS = comedi.h comedilib.h
+include_HEADERS = comedi.h comedilib.h comedilib_scxi.h
 
diff --git a/include/comedilib_scxi.h b/include/comedilib_scxi.h
new file mode 100644 (file)
index 0000000..4af4484
--- /dev/null
@@ -0,0 +1,63 @@
+#include <comedilib.h>
+
+#define SLOT0_INTERVAL  1200
+#define FAST_INTERVAL   1200
+#define MEDIUM_INTERVAL 10000
+#define SLOW_INTERVAL   30000
+
+#define SCXI_LINE_MOSI 0
+#define SCXI_LINE_DA   1
+#define SCXI_LINE_SS   2
+#define SCXI_LINE_MISO 4
+
+#define SCXI_DIO_NONE 0
+#define SCXI_DIO_DO   1
+#define SCXI_DIO_DI   2
+
+#define SCXI_AIO_NONE 0
+#define SCXI_AIO_AO   1
+#define SCXI_AIO_AI   2
+
+struct scxi_board_struct {
+       unsigned int device_id;
+       char name[12];
+       int modclass;
+       unsigned int clock_interval;
+       int dio_type, aio_type, channels, status_reg, data_reg;
+       int config_reg, eeprom_reg, gain_reg;
+};
+
+typedef struct scxi_board_struct scxi_board_t;
+
+const scxi_board_t scxi_boards[] = {
+       { 0, "unknown\0", 2, SLOW_INTERVAL, 0, 0, 0, 0, 0, 0, 0, 0 },
+       { 0xffffffff, "empty\0", 2, SLOW_INTERVAL, 0, 0, 0, 0, 0, 0, 0, 0 },
+       { 0x06, "SCXI-1100\0", 1, FAST_INTERVAL, SCXI_DIO_NONE, SCXI_AIO_AI, 32,
+               0x00, 0x00, 0x00, 0x00, 0x00 },
+       { 0x1e, "SCXI-1102\0", 2, FAST_INTERVAL, SCXI_DIO_NONE, SCXI_AIO_AI, 32,
+               0x02, 0x05, 0x01, 0x03, 0x04 },
+       //{ 0x14, "SCXI-1124\0", 2, SLOW_INTERVAL, SCXI_DIO_NONE, SCXI_AIO_AO, 6,
+       //      0x02, 0x08, 0x00, 0x03, 0x00 },
+};
+
+#define n_scxi_boards ((sizeof(scxi_boards)/sizeof(scxi_boards[0])))
+
+struct scxi_module_struct {
+       comedi_t *dev;
+       unsigned int board;
+       unsigned int dio_subdev, ser_subdev;
+       unsigned int chassis, slot;
+};
+
+typedef struct scxi_module_struct scxi_mod_t;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int comedi_scxi_serial_readwrite(comedi_t *it, unsigned char out_bits, unsigned char *in_bits);
+int comedi_scxi_serial_config(comedi_t *it, unsigned int clock_interval);
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/scxi/Makefile.am b/scxi/Makefile.am
new file mode 100644 (file)
index 0000000..ba1823a
--- /dev/null
@@ -0,0 +1,11 @@
+
+if BUILD_SCXI
+lib_LTLIBRARIES = libscxi.la
+else
+lib_LTLIBRARIES =
+endif
+
+libscxi_la_SOURCES = scxi.c
+libscxi_la_CFLAGS = $(COMEDILIB_CFLAGS) -D_REENTRANT
+libscxi_la_LDFLAGS = -release $(VERSION) -Wl
+libscxi_la_LIBADD = -lcomedi
diff --git a/scxi/scxi.c b/scxi/scxi.c
new file mode 100644 (file)
index 0000000..7c47034
--- /dev/null
@@ -0,0 +1,43 @@
+#include "comedilib_scxi.h"
+
+int comedi_scxi_serial_config(comedi_t *it, unsigned int clock_interval)
+{
+       comedi_insn insn;
+       lsampl_t data[2];
+
+       memset(&insn,0,sizeof(insn));
+       insn.insn = INSN_CONFIG;
+       insn.n = 2;
+       insn.data = &data[0];
+       insn.subdev = comedi_find_subdevice_by_type(it, COMEDI_SUBD_SERIAL, 0);
+       data[0]=INSN_CONFIG_SERIAL_CLOCK;
+       data[1]=clock_interval;
+
+       return comedi_do_insn(it,&insn);
+}
+
+int comedi_scxi_serial_readwrite(comedi_t *it, unsigned char out_bits, unsigned char *in_bits)
+{
+       int ret;
+       comedi_insn insn;
+       lsampl_t data[2];
+
+       memset(&insn,0,sizeof(insn));
+
+       insn.insn = INSN_CONFIG;
+       insn.n = 2;
+       insn.data = data;
+       insn.subdev = comedi_find_subdevice_by_type(it, COMEDI_SUBD_SERIAL, 0);
+
+       data[0]=INSN_CONFIG_BIDIRECTIONAL_DATA;
+       data[1]=out_bits;
+
+       ret = comedi_do_insn(it,&insn);
+
+       if(ret<0) return ret;
+
+       if(in_bits)
+               *in_bits = data[1];
+
+       return 0;
+}