Add channel-specific arm, disarm, and reset wrappers.

The comedi_arm(), comedi_disarm(), and comedi_reset() functions always
set the channel number in the corresponding configuration instructions
to 0, as they assume the channel number will be ignored by the driver.
Some drivers do in fact use the channel number in these configuration
instructions.  Add additional wrapper functions comedi_arm_channel(),
comedi_disarm_channel(), and comedi_reset_channel() to allow the channel
number to be specified.
This commit is contained in:
Ian Abbott 2016-03-10 11:20:18 +00:00
parent 2062d615ff
commit ac2ce44520
4 changed files with 117 additions and 22 deletions

View file

@ -6,14 +6,39 @@ Param: unsigned int subdevice
Param: unsigned int source
Status: alpha
Description:
This function arms a subdevice. It may, for example, arm a counter
to begin counting. The <parameter class="function">source</parameter>
parameter specifies
what source should trigger the subdevice to begin. The possible
sources are driver-dependant. This function is only useable
on subdevices that provide support for the
<constant>INSN_CONFIG_ARM</constant> configuration
instruction.
This function arms a subdevice. It may, for example, arm a counter to
begin counting. The <parameter class="function">source</parameter>
parameter specifies what source should trigger the subdevice to begin.
The possible sources are driver-dependant. This function is only
useable on subdevices that provide support for the
<constant>INSN_CONFIG_ARM</constant> configuration instruction.
Some subdevices treat this as an instruction to arm a specific channel.
For those subdevices, this function will arm channel
<literal>0</literal> and <function><link
linkend="func-ref-comedi-arm-channel">comedi_arm_channel</link></function>
should be called instead of this one to specify the channel.
Returns:
<literal>0</literal> on success, <literal>-1</literal> on error.
Function: comedi_arm_channel -- arm a subdevice channel
Retval: int
Param: comedi_t * device
Param: unsigned int subdevice
Param: unsigned int channel
Param: unsigned int source
Status: alpha
Description:
This function arms a specified channel of a subdevice. It may, for
example, arm a counter to begin counting. The <parameter
class="function">source</parameter> parameter specifies what source
should trigger the subdevice to begin. The possible sources are
driver-dependant. This function is only useable on subdevices that
provide support for the <constant>INSN_CONFIG_ARM</constant>
configuration instruction. Some subdevices treat this as an
instruction to arm the whole subdevice and ignore the specified
channel. For such subdevices, <function><link
linkend="func-ref-comedi-arm">comedi_arm</link></function> is normally
called instead.
Returns:
<literal>0</literal> on success, <literal>-1</literal> on error.
@ -26,7 +51,30 @@ Description:
This function disarms a subdevice. It may, for example, stop a counter
counting. This function is only useable on subdevices that provide
support for the <constant>INSN_CONFIG_DISARM</constant> configuration
instruction.
instruction. Some subdevices treat this as an instruction to disarm a
specific channel. For those subdevices, this function will disarm
channel <literal>0</literal> and <function><link
linkend="func-ref-comedi-disarm-channel">comedi_disarm_channel</link></function>
should be called instead of this one to specify the channel.
Returns:
<literal>0</literal> on success, <literal>-1</literal> on error.
Function: comedi_disarm_channel -- disarm a subdevice channel
Retval: int
Param: comedi_t * device
Param: unsigned int subdevice
Param: unsigned int channel
Status: alpha
Description:
This function disarms a specified channel of a subdevice. It may, for
example, stop a counter counting. This function is only useable on
subdevices that provide support for the
<constant>INSN_CONFIG_DISARM</constant> configuration instruction.
Some subdevices treat this as an instruction to disarm the whole
subdevice and ignore the specified channel. For such subdevices,
<function><link
linkend="func-ref-comedi-disarm">comedi_disarm</link></function> is
normally called instead.
Returns:
<literal>0</literal> on success, <literal>-1</literal> on error.
@ -141,10 +189,30 @@ Param: comedi_t * device
Param: unsigned int subdevice
Status: alpha
Description:
This function resets a subdevice. It is only useable
on subdevices that provide support for the
<constant>INSN_CONFIG_RESET</constant> configuration
instruction.
This function resets a subdevice. It is only useable on subdevices
that provide support for the <constant>INSN_CONFIG_RESET</constant>
configuration instruction. Some subdevices treat this as an
instruction to reset a specific channel. For those subdevices, this
function will reset channel <literal>0</literal> and <function><link
linkend="func-ref-comedi-reset-channel">comedi_reset_channel</link></function>
should be called instead of this one to specify the channel.
Returns:
<literal>0</literal> on success, <literal>-1</literal> on error.
Function: comedi_reset_channel -- reset a subdevice channel
Retval: int
Param: comedi_t * device
Param: unsigned int subdevice
Param: unsigned int channel
Status: alpha
Description:
This function resets a specified channel of a subdevice. It is only
useable on subdevices that provide support for the
<constant>INSN_CONFIG_RESET</constant> configuration instruction. Some
subdevices treat this as an instruction to reset the whole subdevice
and ignore the specified channel. For such subdevices, <function><link
linkend="func-ref-comedi-reset">comedi_reset</link></function> is
normally called instead.
Returns:
<literal>0</literal> on success, <literal>-1</literal> on error.

View file

@ -286,8 +286,14 @@ lsampl_t comedi_from_physical(double data,
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_arm_channel(comedi_t *device, unsigned subdevice, unsigned channel,
unsigned source);
int comedi_disarm(comedi_t *device, unsigned subdevice);
int comedi_disarm_channel(comedi_t *device, unsigned subdevice,
unsigned channel);
int comedi_reset(comedi_t *device, unsigned subdevice);
int comedi_reset_channel(comedi_t *device, unsigned subdevice,
unsigned channel);
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));

View file

@ -26,8 +26,8 @@
#include "libinternal.h"
EXPORT_ALIAS_DEFAULT(_comedi_reset,comedi_reset,0.9.0);
int _comedi_reset(comedi_t *device, unsigned subdevice)
EXPORT_ALIAS_DEFAULT(_comedi_reset_channel,comedi_reset_channel,0.11.0);
int _comedi_reset_channel(comedi_t *device, unsigned subdevice, unsigned channel)
{
comedi_insn insn;
lsampl_t data[1];
@ -35,7 +35,7 @@ int _comedi_reset(comedi_t *device, unsigned subdevice)
memset(&insn, 0, sizeof(comedi_insn));
insn.insn = INSN_CONFIG;
insn.subdev = subdevice;
insn.chanspec = 0;
insn.chanspec = channel;
insn.data = data;
insn.n = sizeof(data) / sizeof(data[0]);
data[0] = INSN_CONFIG_RESET;
@ -44,8 +44,14 @@ int _comedi_reset(comedi_t *device, unsigned subdevice)
else return -1;
}
EXPORT_ALIAS_DEFAULT(_comedi_arm,comedi_arm,0.9.0);
int _comedi_arm(comedi_t *device, unsigned subdevice, unsigned target)
EXPORT_ALIAS_DEFAULT(_comedi_reset,comedi_reset,0.9.0);
int _comedi_reset(comedi_t *device, unsigned subdevice)
{
return _comedi_reset_channel(device, subdevice, 0);
}
EXPORT_ALIAS_DEFAULT(_comedi_arm_channel,comedi_arm_channel,0.11.0);
int _comedi_arm_channel(comedi_t *device, unsigned subdevice, unsigned channel, unsigned target)
{
comedi_insn insn;
lsampl_t data[2];
@ -53,7 +59,7 @@ int _comedi_arm(comedi_t *device, unsigned subdevice, unsigned target)
memset(&insn, 0, sizeof(comedi_insn));
insn.insn = INSN_CONFIG;
insn.subdev = subdevice;
insn.chanspec = 0;
insn.chanspec = channel;
insn.data = data;
insn.n = sizeof(data) / sizeof(data[0]);
data[0] = INSN_CONFIG_ARM;
@ -63,8 +69,14 @@ int _comedi_arm(comedi_t *device, unsigned subdevice, unsigned target)
else return -1;
}
EXPORT_ALIAS_DEFAULT(_comedi_disarm,comedi_disarm,0.11.0);
int _comedi_disarm(comedi_t *device, unsigned subdevice)
EXPORT_ALIAS_DEFAULT(_comedi_arm,comedi_arm,0.9.0);
int _comedi_arm(comedi_t *device, unsigned subdevice, unsigned target)
{
return _comedi_arm_channel(device, subdevice, 0, target);
}
EXPORT_ALIAS_DEFAULT(_comedi_disarm_channel,comedi_disarm_channel,0.11.0);
int _comedi_disarm_channel(comedi_t *device, unsigned subdevice, unsigned channel)
{
comedi_insn insn;
lsampl_t data[1];
@ -72,7 +84,7 @@ int _comedi_disarm(comedi_t *device, unsigned subdevice)
memset(&insn, 0, sizeof(comedi_insn));
insn.insn = INSN_CONFIG;
insn.subdev = subdevice;
insn.chanspec = 0;
insn.chanspec = channel;
insn.data = data;
insn.n = sizeof(data) / sizeof(data[0]);
data[0] = INSN_CONFIG_DISARM;
@ -81,6 +93,12 @@ int _comedi_disarm(comedi_t *device, unsigned subdevice)
else return -1;
}
EXPORT_ALIAS_DEFAULT(_comedi_disarm,comedi_disarm,0.11.0);
int _comedi_disarm(comedi_t *device, unsigned subdevice)
{
return _comedi_disarm_channel(device, subdevice, 0);
}
EXPORT_ALIAS_DEFAULT(_comedi_get_clock_source,comedi_get_clock_source,0.10.0);
int _comedi_get_clock_source(comedi_t *device, unsigned subdevice, unsigned channel, unsigned *clock, unsigned *period_ns)
{

View file

@ -119,5 +119,8 @@ v0.10.0 {
v0.11.0 {
global:
comedi_arm_channel;
comedi_disarm;
comedi_disarm_channel;
comedi_reset_channel;
} v0.10.0;