wiki:Docs/Prog/Manual/ApplicationLibraries/lib825ev/IO/SetOutputMask

SetOutputMask

Set the output states of one or more digital outputs to ON or OFF for the main board or a DIO option card.

int SetOutputMask(int bd, uint32 mask, uint32 output);

Parameters

  • bd - 0 for main board or number of digital output card
  • mask - bit mask to specify which outputs will be affected
  • output - bit mask to specify state of outputs

Return Value

  • Returns the result - OK success

Remarks

The main board or option card must already be opened by calling OpenMnBd first. The call does a wait for acknowledgement. If the application is using main board communication events these events may be called during the wait for acknowledgement.

Examples

// Affect outputs 1 - 3 Mask = 1 + 2 + 4 = 7
if(SetOutputMask(MNBD_DEV, 7, 4) == OK)
    DisplayText(0, 0, "Out 3 set to ON 1 and 2 set to OFF");
// Affect outputs 1 - 4 Mask = 1 + 2 + 4 + 8 = 15 decimal = 0x0F hexadecimal
// Set 1 and 2 on = 1 + 2 = 3
if(SetOutputMask(MNBD_DEV, 0x0F, 3) == OK)
    DisplayText(0, 0, "1 and 2 ON  - 3 and 4 OFF");
// Turn on outputs 1 and 3
SetOutputMask(MNBD_DEV, BitToMask(1) | BitToMask(3), ALL_MASK_BITS_ON);
// Turn off outputs 1 and 4
SetOutputMask(MNBD_DEV, BitToMask(1) | BitToMask(4), ALL_MASK_BITS_OFF);
// Turn on output 2 and turn off output 3
SetOutputMask(MNBD_DEV, BitToMask(2) | BitToMask(3), BitToMask(2));

See Also

Last modified 6 years ago Last modified on 09/10/18 10:57:01
Note: See TracWiki for help on using the wiki.