beautypg.com

Sensoray 2410 API User Manual

Page 31

background image

Sensoray 24xx Programming Guide

27

Model 2426 Multi-Function I/O Module

7.2.4 s2426_SetDoutMode()

Function:

Program the operating mode of one digital output channel.

Prototype:

BOOL s2426_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:

This function configures the operating mode of one digital output channel. Each channel can operate in either the
Standard mode or PWM mode. In Standard mode, the channel state can be manually programmed by calling

s2426_WriteDout()

. The state is automatically controlled by the I/O module in PWM mode, with duty cycle and

frequency programmed by calling

s2426_WritePwm()

.

Example:

// Configure channel 2 for PWM operation.

u32 err = ERR_NONE;

if

( !s2426_SetDoutMode( sess, &err, 2, DOUT2426_MODE_PWM ) )

printf( "Error: %s\n", s24xx_ErrorText(err) );

7.2.5 s2426_WriteDout()

Function:

Program all digital output channels.

Prototype:

BOOL s2426_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.

Example:

// Program digital outputs to 0x5A17.

u32 err = ERR_NONE;

if

( !s2426_WriteDout( sess, &err, 0x5A17 ) )

printf( "Error: %s\n", s24xx_ErrorText(err) );

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 15.

mode

Channel operating mode:

DOUT2426_MODE_STANDARD
DOUT2426_MODE_PWM

Argument

Description

sess

Session handle obtained from

s24xx_SessionOpen()

.

err

Pointer to error code. See Section 4.3.1 for details.

states

Desired output states. Each bit is associated with one channel. For example, bit 7 is
associated with channel 7. Any bit set to one indicates the associated channel is to be set to
the active state (driven low); zero indicates the channel is to be set to the inactive state
(pulled high).