Sensoray 2410 API User Manual
Page 20
Sensoray 24xx Programming Guide
16
Model 2410 Digital I/O Module
if
( !s2410_ReadDout( sess, &err, states ) )
printf( "Error: %s\n", s24xx_ErrorText(err) );
else
printf( "driver states: %04x %04x %04x\n", states[2], states[1], states[0] );
6.2.4 s2410_WriteDout()
Function:
Programs the output states of all DIO channels.
Prototype:
BOOL s2410_WriteDout( SESSION sess, u32 *err, u16 *states );
Returns:
True if the operation was successful, otherwise False is returned and
err
will contain the associated error code.
Notes:
This function programs the states of all DIO output drivers of channels that are operating in the Standard output
mode. Note that this has no effect on channels operating in the PWM output mode, as their drivers are
autonomously controlled by PWM generators.
Example:
// Program all DIO output states.
u32 err = ERR_NONE;
u16 states[] = { 0x0123, 0x4567, &0x89AB };
// desired DIO states
if
( !2410_WriteDout( sess, &err, states ) )
printf( "Error: %s\n", s24xx_ErrorText(err) );
6.2.5 s2410_SetDoutMode()
Function:
Program the output operating mode of one DIO channel.
Prototype:
BOOL s2410_SetDoutMode( SESSION sess, u32 *err, u8 chan, u32 mode );
Returns:
True if the operation was successful, otherwise False is returned and
err
will contain the associated error code.
Notes:
Each channel may be independently configured to operate in either Standard mode or PWM mode. When operating
in Standard mode, a channel’s output state can be manually programmed by calling
s2410_WriteDout()
. In PWM
mode, however, the state is automatically controlled by the I/O module, with duty cycle and frequency
programmed by
s2410_WritePwm()
.
Example:
See section 6.2.6.
Argument
Description
sess
Session handle obtained from
s24xx_SessionOpen()
.
err
Pointer to error code. See Section 4.3.1 for details.
states
Pointer to array that contains the desired output states. Each bit has the following
meaning:
1 - active state (driven low by on-board driver).
0 - inactive state (pulled high by on-board driver or driven low by off-board signal).
Argument
Description
sess
Session handle obtained from
s24xx_SessionOpen()
.
err
Pointer to error code. See Section 4.3.1 for details.
chan
Channel number in the range 0 to 47.
mode
Channel operating mode:
DOUT2410_MODE_STANDARD
or
DOUT2410_MODE_PWM
.