beautypg.com

2 programming, 1 s826_safecontrolwrite, 2 s826_safecontrolread – Sensoray 826 User Manual

Page 72: Programming, S826_safecontrolwrite, S826_safecontrolread

background image

These API functions write to SWE protected registers:

S826_DacRangeWrite and S826_DacDataWrite (when safemode argument = '1')

S826_DioOutputSourceWrite, S826_DioSafeWrite, and S826_DioSafeEnablesWrite

S826_WatchdogConfigWrite, S826_WatchdogEnableWrite

S826_SafeControlWrite

S826_VirtualSafeWrite and S826_VirtualSafeEnablesWrite

10.2

Programming

10.2.1 S826_SafeControlWrite

The S826_SafeControlWrite function programs the board's fail-safe configuration and state.

int S826_SafeControlWrite(
uint board, // board identifier
uint settings, // safemode settings
uint mode // write mode
);

Parameters

board

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

settings

Safemode configuration and state bits:

31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10

9

8

7

6

5

4

3

2

1

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

XSF

0

SAF

0

Bit

Function

XSF

DIO47 trigger enable. Programmed to '0' upon reset.
When '1', a low level (0 volts) on the DIO channel 47 header pin will set the SAF bit. When '0', DIO47 will not affect
the SAF bit. When XSF=1, a thread can block on DIO47 falling edge events to receive notification when safemode is
triggered. Alternatively,the program can poll SAF.

SAF

Safemode state. Programmed to '0' upon reset.
'1' = safemode active, '0' = runmode active. This can be written by the application program. This bit can also be set by
DIO47 when XSF=1, or by a timeout event on watchdog Timer0.

mode

Write mode: 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

This function should only be called when the SWE bit is set (see S826_SafeWrenWrite). The function will fail without
notification (return S826_ERR_OK) if SWE=0 (see Section 10.1.1).

10.2.2 S826_SafeControlRead

The S826_SafeControlRead function returns the board's fail-safe configuration and state.

826 Instruction Manual

67

Safemode Controller