# DIP Switch
[Libraries]

The DIP Switch subsystem reads values in from the 8 position DIP Switch (0 - 255) on the Application Board. More...

## Functions
int | DipSwitch_SetActive (int state)
| Sets whether the DIP Switch is active.
int | DipSwitch_GetActive ()
| Returns the active state of the DIP Switch.
int | DipSwitch_GetValue ()
| Read the current configuration of the on-board DIP switch.
bool | DipSwitch_GetValueChannel (int channel)
| Read a single channel's value.

## Detailed Description

The DIP Switch subsystem reads values in from the 8 position DIP Switch (0 - 255) on the Application Board.

Mask off the appropriate bits in the value returned from the DIP switch to determine whether a particular channel is on or off.

See the Application Board overview for details.

## Function Documentation

int DipSwitch_GetActive | ( | void |  | ) |

Returns the active state of the DIP Switch.

Returns:
  The active state of the DIP Switch - 1 (active) or 0 (inactive).

Example

      if( DipSwitch_GetActive() )
      {
        // DIP switch is active
      }
      else
      {
        // DIP switch is not active
      }

Definition at line 108 of file dipswitch.c.

int DipSwitch_GetValue | ( | void |  | ) |

Read the current configuration of the on-board DIP switch.

Returns:
  An integer from 0-255 indicating the current configuration of the DIP switch.

Example

      int dip_switch = DipSwitch_GetValue();
      // now dip_switch has a bitmask of all 8 channels of the DIP switch

Definition at line 123 of file dipswitch.c.

bool DipSwitch_GetValueChannel | ( | int | channel | ) |

Read a single channel's value.

This is a convenience function that relies on DipSwitch_GetValue() internally, but extracts the value for a given channel.

Parameters:

  | channel | The channel (0-7) you'd like to read. return true if the channel is on, false if it's off.

See also:
  DipSwitch_GetValue( )

Example

      if(DipSwitch_GetValueChannel(4) )
      {
        // DIP switch channel 4 is on
      }
      else
      {
        // DIP switch channel 4 is off
      }
      // now dip_switch has a bitmask of all 8 channels of the DIP switch

Definition at line 172 of file dipswitch.c.

int DipSwitch_SetActive | ( | int | state | ) |

Sets whether the DIP Switch is active.

Parameters:

  | state | An integer specifying the state of the DIP Switch - 1 (on) or 0 (off).

Returns:
  Zero on success.

Example

      // enable the DIP switch
      DipSwitch_SetActive(1);

Definition at line 68 of file dipswitch.c.