doc/dio_funcref.txt: Some DocBook mark-up changes.
[comedilib.git] / include / comedilib.h
index 81ef65e399bc7effcbc478004b3205d13a464cc4..0f9bbcace3db7f94a6c4cf6d504d1fe7c01ca360 100644 (file)
@@ -6,7 +6,7 @@
     Copyright (C) 1998-2002 David A. Schleef <ds@schleef.org>
 
     This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
+    it under the terms of the GNU Lesser General Public License as published by
     the Free Software Foundation; either version 2 of the License, or
     (at your option) any later version.
 
@@ -26,6 +26,7 @@
 #define _COMEDILIB_H
 
 #include <comedi.h>
+#include <comedilib_version.h>
 #include <sys/ioctl.h>
 #include <fcntl.h>
 #include <stdio.h>
 extern "C" {
 #endif
 
+/* Macros for swig to %include this file. */
+#ifdef SWIG
+#define SWIG_OUTPUT(x)  OUTPUT
+#define SWIG_INPUT(x)   INPUT
+#define SWIG_INOUT(x)   INOUT
+#else
+#define SWIG_OUTPUT(x)  x
+#define SWIG_INPUT(x)   x
+#define SWIG_INOUT(x)   x
+#endif
+
 typedef struct comedi_t_struct comedi_t;
 
 typedef struct{
@@ -71,7 +83,7 @@ int comedi_close(comedi_t *it);
 /* logging */
 int comedi_loglevel(int loglevel);
 void comedi_perror(const char *s);
-char *comedi_strerror(int errnum);
+const char *comedi_strerror(int errnum);
 int comedi_errno(void);
 int comedi_fileno(comedi_t *it);
 
@@ -82,8 +94,8 @@ enum comedi_oor_behavior comedi_set_global_oor_behavior(enum comedi_oor_behavior
 int comedi_get_n_subdevices(comedi_t *it);
 #define COMEDI_VERSION_CODE(a,b,c) (((a)<<16) | ((b)<<8) | (c))
 int comedi_get_version_code(comedi_t *it);
-char *comedi_get_driver_name(comedi_t *it);
-char *comedi_get_board_name(comedi_t *it);
+const char *comedi_get_driver_name(comedi_t *it);
+const char *comedi_get_board_name(comedi_t *it);
 int comedi_get_read_subdevice(comedi_t *dev);
 int comedi_get_write_subdevice(comedi_t *dev);
 
@@ -130,38 +142,44 @@ int comedi_sampl_from_phys(sampl_t *dest,int dst_stride,double *src,
 
 /* syncronous stuff */
 int comedi_data_read(comedi_t *it,unsigned int subd,unsigned int chan,
-       unsigned int range,unsigned int aref,lsampl_t *data);
+       unsigned int range,unsigned int aref,lsampl_t *SWIG_OUTPUT(data));
 int comedi_data_read_n(comedi_t *it,unsigned int subd,unsigned int chan,
-       unsigned int range,unsigned int aref,lsampl_t *data, unsigned int n);
+       unsigned int range,unsigned int aref,lsampl_t *SWIG_OUTPUT(data), unsigned int n);
 int comedi_data_read_hint(comedi_t *it,unsigned int subd,unsigned int chan,
        unsigned int range,unsigned int aref);
 int comedi_data_read_delayed(comedi_t *it,unsigned int subd,unsigned int chan,
-       unsigned int range,unsigned int aref,lsampl_t *data, unsigned int nano_sec);
+       unsigned int range,unsigned int aref,lsampl_t *SWIG_OUTPUT(data), unsigned int nano_sec);
 int comedi_data_write(comedi_t *it,unsigned int subd,unsigned int chan,
        unsigned int range,unsigned int aref,lsampl_t data);
 int comedi_dio_config(comedi_t *it,unsigned int subd,unsigned int chan,
        unsigned int dir);
+int comedi_dio_get_config(comedi_t *it,unsigned int subd,unsigned int chan,
+       unsigned int *SWIG_OUTPUT(dir));
 int comedi_dio_read(comedi_t *it,unsigned int subd,unsigned int chan,
-       unsigned int *bit);
+       unsigned int *SWIG_OUTPUT(bit));
 int comedi_dio_write(comedi_t *it,unsigned int subd,unsigned int chan,
        unsigned int bit);
+int comedi_dio_bitfield2(comedi_t *it,unsigned int subd,
+       unsigned int write_mask, unsigned int *SWIG_INOUT(bits), unsigned int base_channel);
+/* Should be moved to _COMEDILIB_DEPRECATED once bindings for other languages are updated
+ * to use comedi_dio_bitfield2() instead.*/
 int comedi_dio_bitfield(comedi_t *it,unsigned int subd,
-       unsigned int write_mask, unsigned int *bits);
+       unsigned int write_mask, unsigned int *SWIG_INOUT(bits));
 
 /* slowly varying stuff */
 int comedi_sv_init(comedi_sv_t *it,comedi_t *dev,unsigned int subd,unsigned int chan);
 int comedi_sv_update(comedi_sv_t *it);
-int comedi_sv_measure(comedi_sv_t *it,double *data);
+int comedi_sv_measure(comedi_sv_t *it,double *SWIG_OUTPUT(data));
 
 /* streaming I/O (commands) */
 
 int comedi_get_cmd_src_mask(comedi_t *dev,unsigned int subdevice,
-       comedi_cmd *cmd);
+       comedi_cmd *SWIG_INOUT(cmd));
 int comedi_get_cmd_generic_timed(comedi_t *dev,unsigned int subdevice,
-       comedi_cmd *cmd,unsigned int ns);
+       comedi_cmd *SWIG_INOUT(cmd), unsigned chanlist_len, unsigned scan_period_ns);
 int comedi_cancel(comedi_t *it,unsigned int subdevice);
 int comedi_command(comedi_t *it,comedi_cmd *cmd);
-int comedi_command_test(comedi_t *it,comedi_cmd *cmd);
+int comedi_command_test(comedi_t *it,comedi_cmd *SWIG_INOUT(cmd));
 int comedi_poll(comedi_t *dev,unsigned int subdevice);
 
 /* buffer control */
@@ -203,6 +221,18 @@ typedef struct
        unsigned int channel;
        unsigned int value;
 } comedi_caldac_t;
+#define COMEDI_MAX_NUM_POLYNOMIAL_COEFFICIENTS 4
+typedef struct
+{
+       double coefficients[COMEDI_MAX_NUM_POLYNOMIAL_COEFFICIENTS];
+       double expansion_origin;
+       unsigned order;
+} comedi_polynomial_t;
+typedef struct
+{
+       comedi_polynomial_t *to_phys;
+       comedi_polynomial_t *from_phys;
+} comedi_softcal_t;
 #define CS_MAX_AREFS_LENGTH 4
 typedef struct
 {
@@ -215,6 +245,7 @@ typedef struct
        unsigned int num_arefs;
        comedi_caldac_t *caldacs;
        unsigned int num_caldacs;
+       comedi_softcal_t soft_calibration;
 } comedi_calibration_setting_t;
 
 typedef struct
@@ -233,7 +264,41 @@ void comedi_cleanup_calibration( comedi_calibration_t *calibration );
 int comedi_apply_calibration( comedi_t *dev, unsigned int subdev, unsigned int channel,
        unsigned int range, unsigned int aref, const char *cal_file_path);
 
-
+/* New stuff to provide conversion between integers and physical values that
+* can support software calibrations. */
+enum comedi_conversion_direction
+{
+       COMEDI_TO_PHYSICAL,
+       COMEDI_FROM_PHYSICAL
+};
+int comedi_get_softcal_converter(
+       unsigned subdevice, unsigned channel, unsigned range,
+       enum comedi_conversion_direction direction,
+       const comedi_calibration_t *calibration, comedi_polynomial_t* SWIG_OUTPUT(polynomial));
+int comedi_get_hardcal_converter(
+       comedi_t *dev, unsigned subdevice, unsigned channel, unsigned range,
+       enum comedi_conversion_direction direction, comedi_polynomial_t* SWIG_OUTPUT(polynomial));
+double comedi_to_physical(lsampl_t data,
+       const comedi_polynomial_t *conversion_polynomial);
+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_arm(comedi_t *device, unsigned subdevice, unsigned source);
+int comedi_reset(comedi_t *device, unsigned subdevice);
+int comedi_get_clock_source(comedi_t *device, unsigned subdevice, unsigned channel, unsigned *SWIG_OUTPUT(clock), unsigned *SWIG_OUTPUT(period_ns));
+int comedi_get_gate_source(comedi_t *device, unsigned subdevice, unsigned channel,
+       unsigned gate, unsigned *SWIG_OUTPUT(source));
+int comedi_get_routing(comedi_t *device, unsigned subdevice, unsigned channel, unsigned *SWIG_OUTPUT(routing));
+int comedi_set_counter_mode(comedi_t *device, unsigned subdevice, unsigned channel, unsigned mode_bits);
+int comedi_set_clock_source(comedi_t *device, unsigned subdevice, unsigned channel, 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 channel, unsigned gate_index, unsigned gate_source);
+int comedi_set_other_source(comedi_t *device, unsigned subdevice, unsigned channel,
+       unsigned other, unsigned source);
+int comedi_set_routing(comedi_t *device, unsigned subdevice, unsigned channel, unsigned routing);
+int comedi_get_hardware_buffer_size(comedi_t *device, unsigned subdevice, enum comedi_io_direction direction);
 
 #endif