change static inline NI_* to macros
This is a partial sync of the staging tree to comedilib with these benefits: 1. This is first in a series of patches to sync comedilib to the kernel modules in the staging development tree. The point of this series of patches is to make the syncing of the userspace and kernel comedi.h files be visually more easily done. 2. This patch also teaches SWIG out to properly wrap these macros and provide them to the user. 3. The redef of static inline NI_* functions as macro functions eases alternative use of comedi.h as an import source for a new ctypes-based python interface for comedilib.
This commit is contained in:
parent
ba27bddca4
commit
9d4b7367eb
2 changed files with 59 additions and 63 deletions
|
@ -564,17 +564,9 @@ enum i8254_mode {
|
|||
I8254_BINARY = 0
|
||||
};
|
||||
|
||||
static inline unsigned NI_USUAL_PFI_SELECT(unsigned pfi_channel) {
|
||||
if (pfi_channel < 10)
|
||||
return 0x1 + pfi_channel;
|
||||
else
|
||||
return 0xb + pfi_channel;
|
||||
} static inline unsigned NI_USUAL_RTSI_SELECT(unsigned rtsi_channel) {
|
||||
if (rtsi_channel < 7)
|
||||
return 0xb + rtsi_channel;
|
||||
else
|
||||
return 0x1b;
|
||||
}
|
||||
#define NI_USUAL_PFI_SELECT(x) (((x) < 10) ? (0x1 + (x)) : (0xb + (x)))
|
||||
#define NI_USUAL_RTSI_SELECT(x) (((x) < 7) ? (0xb + (x)) : 0x1b)
|
||||
|
||||
/* mode bits for NI general-purpose counters, set with INSN_CONFIG_SET_COUNTER_MODE */
|
||||
#define NI_GPCT_COUNTING_MODE_SHIFT 16
|
||||
#define NI_GPCT_INDEX_PHASE_BITSHIFT 20
|
||||
|
@ -663,15 +655,14 @@ enum ni_gpct_clock_source_bits {
|
|||
NI_GPCT_PRESCALE_X8_CLOCK_SRC_BITS = 0x20000000, /* divide source by 8 */
|
||||
NI_GPCT_INVERT_CLOCK_SRC_BIT = 0x80000000
|
||||
};
|
||||
static inline unsigned NI_GPCT_SOURCE_PIN_CLOCK_SRC_BITS(unsigned n) { /* NI 660x-specific */
|
||||
return 0x10 + n;
|
||||
}
|
||||
static inline unsigned NI_GPCT_RTSI_CLOCK_SRC_BITS(unsigned n) {
|
||||
return 0x18 + n;
|
||||
}
|
||||
static inline unsigned NI_GPCT_PFI_CLOCK_SRC_BITS(unsigned n) { /* no pfi on NI 660x */
|
||||
return 0x20 + n;
|
||||
}
|
||||
|
||||
/* NI 660x-specific */
|
||||
#define NI_GPCT_SOURCE_PIN_CLOCK_SRC_BITS(x) (0x10 + (x))
|
||||
|
||||
#define NI_GPCT_RTSI_CLOCK_SRC_BITS(x) (0x18 + (x))
|
||||
|
||||
/* no pfi on NI 660x */
|
||||
#define NI_GPCT_PFI_CLOCK_SRC_BITS(x) (0x20 + (x))
|
||||
|
||||
/* Possibilities for setting a gate source with
|
||||
INSN_CONFIG_SET_GATE_SRC when using NI general-purpose counters.
|
||||
|
@ -696,18 +687,11 @@ enum ni_gpct_gate_select {
|
|||
we should add them here with an offset of 0x300 when known. */
|
||||
NI_GPCT_DISABLED_GATE_SELECT = 0x8000,
|
||||
};
|
||||
static inline unsigned NI_GPCT_GATE_PIN_GATE_SELECT(unsigned n) {
|
||||
return 0x102 + n;
|
||||
}
|
||||
static inline unsigned NI_GPCT_RTSI_GATE_SELECT(unsigned n) {
|
||||
return NI_USUAL_RTSI_SELECT(n);
|
||||
}
|
||||
static inline unsigned NI_GPCT_PFI_GATE_SELECT(unsigned n) {
|
||||
return NI_USUAL_PFI_SELECT(n);
|
||||
}
|
||||
static inline unsigned NI_GPCT_UP_DOWN_PIN_GATE_SELECT(unsigned n) {
|
||||
return 0x202 + n;
|
||||
}
|
||||
|
||||
#define NI_GPCT_GATE_PIN_GATE_SELECT(x) (0x102 + (x))
|
||||
#define NI_GPCT_RTSI_GATE_SELECT(x) NI_USUAL_RTSI_SELECT(x)
|
||||
#define NI_GPCT_PFI_GATE_SELECT(x) NI_USUAL_PFI_SELECT(x)
|
||||
#define NI_GPCT_UP_DOWN_PIN_GATE_SELECT(x) (0x202 + (x))
|
||||
|
||||
/* Possibilities for setting a source with
|
||||
INSN_CONFIG_SET_OTHER_SRC when using NI general-purpose counters. */
|
||||
|
@ -721,9 +705,8 @@ enum ni_gpct_other_select {
|
|||
// Still unknown, probably only need NI_GPCT_PFI_OTHER_SELECT
|
||||
NI_GPCT_DISABLED_OTHER_SELECT = 0x8000,
|
||||
};
|
||||
static inline unsigned NI_GPCT_PFI_OTHER_SELECT(unsigned n) {
|
||||
return NI_USUAL_PFI_SELECT(n);
|
||||
}
|
||||
|
||||
#define NI_GPCT_PFI_OTHER_SELECT(x) NI_USUAL_PFI_SELECT(x)
|
||||
|
||||
/* start sources for ni general-purpose counters for use with
|
||||
INSN_CONFIG_ARM */
|
||||
|
@ -768,9 +751,8 @@ enum ni_mio_clock_source {
|
|||
NI_MIO_PLL_PXI10_CLOCK = 3,
|
||||
NI_MIO_PLL_RTSI0_CLOCK = 4
|
||||
};
|
||||
static inline unsigned NI_MIO_PLL_RTSI_CLOCK(unsigned rtsi_channel) {
|
||||
return NI_MIO_PLL_RTSI0_CLOCK + rtsi_channel;
|
||||
}
|
||||
|
||||
#define NI_MIO_PLL_RTSI_CLOCK(x) (NI_MIO_PLL_RTSI0_CLOCK + (x))
|
||||
|
||||
/* Signals which can be routed to an NI RTSI pin with INSN_CONFIG_SET_ROUTING.
|
||||
The numbers assigned are not arbitrary, they correspond to the bits required
|
||||
|
@ -787,9 +769,8 @@ enum ni_rtsi_routing {
|
|||
NI_RTSI_OUTPUT_RTSI_BRD_0 = 8,
|
||||
NI_RTSI_OUTPUT_RTSI_OSC = 12 /* pre-m-series always have RTSI clock on line 7 */
|
||||
};
|
||||
static inline unsigned NI_RTSI_OUTPUT_RTSI_BRD(unsigned n) {
|
||||
return NI_RTSI_OUTPUT_RTSI_BRD_0 + n;
|
||||
}
|
||||
|
||||
#define NI_RTSI_OUTPUT_RTSI_BRD(x) (NI_RTSI_OUTPUT_RTSI_BRD_0 + (x))
|
||||
|
||||
/* Signals which can be routed to an NI PFI pin on an m-series board
|
||||
with INSN_CONFIG_SET_ROUTING. These numbers are also returned
|
||||
|
@ -823,9 +804,8 @@ enum ni_pfi_routing {
|
|||
NI_PFI_OUTPUT_CDI_SAMPLE = 29,
|
||||
NI_PFI_OUTPUT_CDO_UPDATE = 30
|
||||
};
|
||||
static inline unsigned NI_PFI_OUTPUT_RTSI(unsigned rtsi_channel) {
|
||||
return NI_PFI_OUTPUT_RTSI0 + rtsi_channel;
|
||||
}
|
||||
|
||||
#define NI_PFI_OUTPUT_RTSI(x) (NI_PFI_OUTPUT_RTSI0 + (x))
|
||||
|
||||
/* Signals which can be routed to output on a NI PFI pin on a 660x board
|
||||
with INSN_CONFIG_SET_ROUTING. The numbers assigned are
|
||||
|
@ -840,12 +820,9 @@ enum ni_660x_pfi_routing {
|
|||
|
||||
/* NI External Trigger lines. These values are not arbitrary, but are related to
|
||||
the bits required to program the board (offset by 1 for historical reasons). */
|
||||
static inline unsigned NI_EXT_PFI(unsigned pfi_channel) {
|
||||
return NI_USUAL_PFI_SELECT(pfi_channel) - 1;
|
||||
}
|
||||
static inline unsigned NI_EXT_RTSI(unsigned rtsi_channel) {
|
||||
return NI_USUAL_RTSI_SELECT(rtsi_channel) - 1;
|
||||
}
|
||||
|
||||
#define NI_EXT_PFI(x) (NI_USUAL_PFI_SELECT(x) - 1)
|
||||
#define NI_EXT_RTSI(x) (NI_USUAL_RTSI_SELECT(x) - 1)
|
||||
|
||||
/* status bits for INSN_CONFIG_GET_COUNTER_STATUS */
|
||||
enum comedi_counter_status_flags {
|
||||
|
@ -869,23 +846,15 @@ enum ni_m_series_cdio_scan_begin_src {
|
|||
NI_CDIO_SCAN_BEGIN_SRC_FREQ_OUT = 32,
|
||||
NI_CDIO_SCAN_BEGIN_SRC_DIO_CHANGE_DETECT_IRQ = 33
|
||||
};
|
||||
static inline unsigned NI_CDIO_SCAN_BEGIN_SRC_PFI(unsigned pfi_channel) {
|
||||
return NI_USUAL_PFI_SELECT(pfi_channel);
|
||||
}
|
||||
static inline unsigned NI_CDIO_SCAN_BEGIN_SRC_RTSI(unsigned
|
||||
rtsi_channel) {
|
||||
return NI_USUAL_RTSI_SELECT(rtsi_channel);
|
||||
}
|
||||
|
||||
#define NI_CDIO_SCAN_BEGIN_SRC_PFI(x) NI_USUAL_PFI_SELECT(x)
|
||||
#define NI_CDIO_SCAN_BEGIN_SRC_RTSI(x) NI_USUAL_RTSI_SELECT(x)
|
||||
|
||||
/* scan_begin_src for scan_begin_arg==TRIG_EXT with analog output command
|
||||
on NI boards. These scan begin sources can also be bitwise-or'd with
|
||||
CR_INVERT to change polarity. */
|
||||
static inline unsigned NI_AO_SCAN_BEGIN_SRC_PFI(unsigned pfi_channel) {
|
||||
return NI_USUAL_PFI_SELECT(pfi_channel);
|
||||
}
|
||||
static inline unsigned NI_AO_SCAN_BEGIN_SRC_RTSI(unsigned rtsi_channel) {
|
||||
return NI_USUAL_RTSI_SELECT(rtsi_channel);
|
||||
}
|
||||
#define NI_AO_SCAN_BEGIN_SRC_PFI(x) NI_USUAL_PFI_SELECT(x)
|
||||
#define NI_AO_SCAN_BEGIN_SRC_RTSI(x) NI_USUAL_RTSI_SELECT(x)
|
||||
|
||||
/* Bits for setting a clock source with
|
||||
* INSN_CONFIG_SET_CLOCK_SRC when using NI frequency output subdevice. */
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#define SWIG_USE_OLD_TYPEMAPS
|
||||
%{
|
||||
#include "comedilib.h"
|
||||
#include "comedi.h"
|
||||
%}
|
||||
%include "carrays.i"
|
||||
%include "typemaps.i"
|
||||
|
@ -64,6 +65,32 @@ static unsigned int cr_aref(unsigned int a){
|
|||
#define NI_GPCT_INVERT_CLOCK_SRC_BIT 0x80000000U
|
||||
%}
|
||||
|
||||
// Give swig prototype for each of these macros so they can be properly wrapped.
|
||||
unsigned int CR_PACK(unsigned int chan, unsigned int rng, unsigned int aref);
|
||||
unsigned int CR_PACK_FLAGS(unsigned int chan, unsigned int rng, unsigned int aref, unsigned int flags);
|
||||
unsigned int CR_CHAN(unsigned int chan);
|
||||
unsigned int CR_RANGE(unsigned int chan);
|
||||
unsigned int CR_AREF(unsigned int chan);
|
||||
unsigned int NI_USUAL_PFI_SELECT(unsigned int pfi_channel);
|
||||
unsigned int NI_USUAL_RTSI_SELECT(unsigned int rtsi_channel);
|
||||
unsigned int NI_GPCT_SOURCE_PIN_CLOCK_SRC_BITS(unsigned int n);
|
||||
unsigned int NI_GPCT_RTSI_CLOCK_SRC_BITS(unsigned int n);
|
||||
unsigned int NI_GPCT_PFI_CLOCK_SRC_BITS(unsigned int n);
|
||||
unsigned int NI_GPCT_GATE_PIN_GATE_SELECT(unsigned int n);
|
||||
unsigned int NI_GPCT_RTSI_GATE_SELECT(unsigned int n);
|
||||
unsigned int NI_GPCT_PFI_GATE_SELECT(unsigned int n);
|
||||
unsigned int NI_GPCT_UP_DOWN_PIN_GATE_SELECT(unsigned int n);
|
||||
unsigned int NI_GPCT_PFI_OTHER_SELECT(unsigned int n);
|
||||
unsigned int NI_MIO_PLL_RTSI_CLOCK(unsigned int rtsi_channel);
|
||||
unsigned int NI_RTSI_OUTPUT_RTSI_BRD(unsigned int n);
|
||||
unsigned int NI_PFI_OUTPUT_RTSI(unsigned int rtsi_channel);
|
||||
unsigned int NI_EXT_PFI(unsigned int pfi_channel);
|
||||
unsigned int NI_EXT_RTSI(unsigned int rtsi_channel);
|
||||
unsigned int NI_CDIO_SCAN_BEGIN_SRC_PFI(unsigned int pfi_channel);
|
||||
unsigned int NI_CDIO_SCAN_BEGIN_SRC_RTSI(unsigned int rtsi_channel);
|
||||
unsigned int NI_AO_SCAN_BEGIN_SRC_PFI(unsigned int pfi_channel);
|
||||
unsigned int NI_AO_SCAN_BEGIN_SRC_RTSI(unsigned int rtsi_channel);
|
||||
|
||||
#ifdef SWIGRUBY
|
||||
%typemap(argout) comedi_cmd *INOUT(VALUE info) {
|
||||
$result = output_helper($result, $arg);
|
||||
|
|
Loading…
Add table
Reference in a new issue