beautypg.com

1 s826_diooutputwrite, 2 s826_diooutputread, S826_diooutputwrite – Sensoray 826 User Manual

Page 56: S826_diooutputread, S826_diooutputwrite)

background image

Although the DIO functions read or write values for all 48 DIO channels, the physical read or write operation is performed
in steps; channels 0 to 23 first, as a group, and then channels 24 to 47 as another group. As a result, reads and writes do not
sample or update all channels simultaneously. In general, channels 0 to 23 are sampled or updated concurrently as a group,
and channels 24 to 47 are sampled or updated concurrently as a separate group.

8.3.1 S826_DioOutputWrite

The S826_DioOutputWrite function programs the DIO output registers.

int S826_DioOutputWrite(
uint board, // board identifier
uint data[2], // pointer to DIO data
uint mode // 0=write, 1=clear bits, 2=set bits
);

Parameters

board

826 board number. This must match the settings of the board's dip switches as described in section 2.2.

data

Pointer to data array (see Section 8.3).

mode

Write mode for data: 0 = write, 1 = clear bits, 2 = set bits (see “Atomic Read-Modify-Write”).

Return Values

If the function succeeds, the return value is zero.

If the function fails, the return value is an error code.

Remarks

In mode zero, this function will unconditionally write new values to all DIO output registers. In modes one and two, the
function will selectively clear or set any arbitrary combination of output registers; data bits that contain logic '1'
indicate DIO output registers that are to be modified, while all other output registers will remain unchanged. Modes one
and two can be used to ensure thread-safe operation as they atomically set or clear the specified bits.

8.3.2 S826_DioOutputRead

The S826_DioOutputRead function reads the programmed states of all DIO output registers.

int S826_DioOutputRead(
uint board, // board identifier
uint data[2] // pointer to data buffer
);

Parameters

board

826 board number. This must match the settings of the board's dip switches as described in section 2.2.

data

Pointer to a buffer (see Section 8.3) that will receive the output register states.

Return Values

If the function succeeds, the return value is zero.

If the function fails, the return value is an error code.

826 Instruction Manual

51

Digital I/O