Discrete Input/Output (D I/O) API

The Discrete (Digital) Input/Output API encompasses the needed software to control and monitor the digital inputs and outputs on the ARCS board. Each of the discrete I/Os are individually programmable to be inputs or outputs. The discrete set are written to as words, although each individual I/O can be accessed as an individual bit also.

Example Use


In the following example, two Discrete I/O channels are initialized and used as discrete outputs.
int ii, flag = 0;
unsigned int numDioChannels = 2;
setNumDios (numDioChannels);
for (ii=0; ii<numDioChannels; ii++)
setDioWordConfig (ii, 0xffff);
for (ii=0; ii<numDioChannels; ii++)
{
if (flag)
setDioWord (ii, 0xaaaa);
else
setDioWord (ii, 0x5555);
}

Method Index

o setNumDios ()
o getNumDios ()
o setDioWordWidth ()
o getDioWordWidth ()
o setDioWordConfig ()
o getDioWordConfig ()
o makeDioBitOutput ()
o makeDioBitInput ()
o getDioBitConfig ()
o setDioBit()
o clrDioBit()
o setDioWord ()
o getDioBit()
o getDioWord ()

Methods

setNumDios
int setNumDios(unsigned int noWords)
Sets the total number of discrete input/outputs.
Parameters
noWords: Total number words of discrete input/outputs. The width of each word is set by setDioWosetDioWordWidth"> setDioWordWidth).
Returns
0: if successful
-1: failure
getNumDios
unsigned int getNumDios ();
Returns the total number of discrete input/outputs in terms of number of words. The width of the words may be obtained by using getDioWordWidth
Returns
Total number words of discrete I/Os.
setDioWordWidth
void setDioWordWidth (unsigned int word, unsigned int width);
Sets the width of the discrete I/O (in terms of number of bits).
Parameters:
word: the word number of the selected discrete I/O word (starting from 0)
width: width (in terms of bits) of the selected discrete I/O word
getDioWordWidth
unsigned int getDioWordWidth (unsigned int word);
Gives the width of the word (in terms of number of bits).
Parameters
word: the word number of the selected discrete I/O word (starting from 0)
Returns
Width of discrete I/O word in number of bits.
setDioWordConfig
void setDioWordConfig (unsigned int word, unsigned int mask);
Sets discrete input/output for a complete word (1=output, 0=input)
Parameters
word: the word number of the selected discrete I/O word (starting from 0)
mask: the selection mask for the selected discreite I/O word (for each bit, 1=output, 0=input)
getDioWordConfig
unsigned int getDioWordConfig (unsigned int word);
Gives the current configuration of the Discrete I/O channels
Parameters
word: the word number of the selected discrete I/O word (starting from 0)
Returns
current discrete I/O mask for the selected word (for each bit, 1=output, 0=input)
makeDioBitOutput
unsigned int makeDioBitOutput (unsigned int word, unsigned int bit);
Set a specified bit in the discrete I/O word to igned int word, unsigned int bit);
Set a specified bit in the discrete I/O word to be a discrete output.
Parameters
word: the word number of the selected discrete I/O word (starting from 0)
bit: the bit number in the selected discrete I/O word
Returns
current discrete I/O mask for the selected word (for each bit, 1=output, 0=input)
makeDioBitInput
unsigned int makeDioBitInput (unsigned int word, unsigned int bit);
Set a specified bit in the discrete I/O word to be a discrete input.
Parameters
word: the word number of the selected discrete I/O word (starting from 0)
bit: the bit number in the selected discrete I/O word
Returns
current discrete I/O mask for the selected word (for each bit, 1=output, 0=input)
getDioBitConfig
unsigned int getDioBitConfig (unsigned int word, unsigned int bit);
Get the input/output specification of a bit bit in the selected discrete I/O word
Parameters
word: the word number of the selected discrete I/O word (starting from 0)
bit: the bit number in the selected discrete I/O word
Returns
0: the selected DI/O channel is an input
nonzero: the selected DI/O channel is an output
setDioBit
unsigned int setDioBit(unsigned int ioBit
unsigned int setDioBit(unsigned int word, unsigned int bit);
If the selected bit in the selected D I/O word is an output, this function sets the output to high. Otherwise, the function has no effect.
Parameters
word: the word number of the selected discrete I/O word (starting from 0)
bit: the bit number in the selected discrete I/O word
Returns
0: successful completion
DioOutOfRangeError: specified D I/O bit or word is out of range
clrDioBit
unsigned int clrDioBit(unsigned int word, unsigned int bit);
If the selected bit in the selected D I/O word is an output, this function sets the output to low. Otherwise, the function has no effect.
Parameters
word: the word number of the selected discrete I/O word (starting from 0)
bit: the bit number in the selected discrete I/O word
Returns
0: successful completion
DioOutOfRangeError: specified D I/O bit or word is out of range
setDioWord
unsigned int setDioWord (unsigned int word, unsigned int value);
Sets the output bits in the selected D I/O word according to the parameter value . This function has no effect on the input bits.
Parameters
word: the word number of the selected discrete I/O word (starting from 0)
value: specified value for the selected D I/O word
Returns
0: successful completion
DioOutOfRangeError: specified D I/O bit or word is out of range
getDioBit getDioBit
unsigned int getDioBit(unsigned int word, unsigned int bit);
Get the value of the selected bit in the selected D I/O word. If the bit is a discrete input, this function reads the current value. If the bit is a discrete output, this function reads the value that has been most recently set.
Parameters
word: the word number of the selected discrete I/O word (starting from 0)
bit: the bit number in the selected discrete I/O word
Returns
0: successful completion
DioOutOfRangeError: specified D I/O bit or word is out of range
getDioWord
unsigned int getDioWord (unsigned int word);
Gets the value in the selected D I/O word.
Parameters
word: the word number of the selected discrete I/O word (starting from 0)
Returns
value in the selected D I/O word.
DioOutOfRangeError: specified D I/O bit or word is out of range

Last modified: Mon Feb 15 00:02:37 Eastern Standard Time 1999 me 1999