Digital Input Pins

Description

General-purpose digital input pins, for manual polling

This resource implements a single or an array of digital input pins, supporting manual polling from task code. The pins are mapped in the I/O Mapping Panel .

When the SCIF driver is initialized, the pins are configured to operate in digital input mode, with pull level as specified per resource I/O usage (no pull, pull-down or pull-up).

When the SCIF driver is uninitialized, the pins are returned to the MCU domain GPIO module, with desired pull level (no pull, pull-down or pull-up). Note that the uninitialization does not modify the GPIO module’s output enable settings, and it is assumed that the pins have not been configured as outputs.

Name and Label

A short name and a descriptive label must be specifed for each I/O usage:

  • The name is used for references in task code, for example as parameter to compaSelectGpioRef() . For a name XYZ:
    • If selecting accessed by constant , a single constant AUXIO_I_XYZ is created automatically
    • If selecting accessed by look-up table , a data structure member cfg.pAuxioIXyz[] is created automatically
  • The label is displayed in the I/O Mapping Panel , and is also used in automatically generated code documentation

Examples

Reading Pin Input

// If the signal is high ...
U16 signal;
gpioGetInputValue(AUXIO_I_SIGNAL; signal);
if (signal == 1) {

    ... Do something here ...

}

Procedures Overview

Name Brief description
gpioCfgMode() Changes the mode of a single digital GPIO pin. More …
gpioClearOutput() Clears a single GPIO output pin (to low). More …
gpioDisableInputBuf() Disables the input buffer for a digital GPIO pin. More …
gpioEnableInputBuf() Enables the input buffer for a digital GPIO pin. More …
gpioGetInputValue() Gets the value of a single GPIO input pin. More …
gpioSetOutput() Sets a single GPIO output pin (to high). More …
gpioToggleOutput() Toggles a single GPIO output pin (to low if previously high, or to high if previously low). More …

Constants

Name Description
GPIO_MODE_INPUT GPIO mode: Input
GPIO_MODE_OPEN_DRAIN GPIO mode: Open-drain (can be driven low)
GPIO_MODE_OPEN_SOURCE GPIO mode: Open-source (can be driven high)
GPIO_MODE_OUTPUT GPIO mode: Output

Global Variables

None.

Procedures

gpioCfgMode

Prototype: gpioCfgMode(auxio, mode)

Changes the mode of a single digital GPIO pin. The pin can be configured as output, input/analog, open-drain or open-source.

Use gpioEnableInputBuf() and gpioDisableInputBuf() to control the pin input buffer. The buffer should be disabled when a pin is allowed to float.

Note: For pins with internal pull-up or pull-down, the pull resistor is enabled also in output mode. Driving against a pull resistor increases current consumption.

Note: This procedure is more efficient if the auxio and mode parameters are specifed as constants (rather than variables).

Parameter value(s)

  • auxio : The GPIO pin to be configured (index of AUX I/O pin)
  • mode : New GPIO pin mode (GPIO_MODE_XYZ)

gpioClearOutput

Prototype: gpioClearOutput(auxio)

Clears a single GPIO output pin (to low).

Note: This procedure is more efficient if the auxio parameter is specifed as a constant (rather than a variable).

Parameter value(s)

  • auxio : The GPIO pin to be cleared (index of AUX I/O pin)

gpioDisableInputBuf

Prototype: gpioDisableInputBuf(auxio)

Disables the input buffer for a digital GPIO pin.

The GPIO pin can only be read when the input buffer is enabled.

The input buffer should be disabled when the GPIO pin is floating.

Note: This procedure is more efficient if the auxio parameter is specifed as a constant (rather than a variable).

Parameter value(s)

  • auxio : The GPIO pin to disable input buffer for (index of AUX I/O pin)

gpioEnableInputBuf

Prototype: gpioEnableInputBuf(auxio)

Enables the input buffer for a digital GPIO pin.

The GPIO pin can only be read when the input buffer is enabled.

The input buffer should be disabled when the GPIO pin is floating.

Note: This procedure is more efficient if the auxio parameter is specifed as a constant (rather than a variable).

Parameter value(s)

  • auxio : The GPIO pin to enable input buffer for (index of AUX I/O pin)

gpioGetInputValue

Prototype: gpioGetInputValue(auxio; value)

Gets the value of a single GPIO input pin.

Parameter value(s)

  • auxio : The GPIO pin to be checked (index of AUX I/O pin)

Return value(s)

  • value : The GPIO pin value (1=high, 0=low)

gpioSetOutput

Prototype: gpioSetOutput(auxio)

Sets a single GPIO output pin (to high).

Note: This procedure is more efficient if the auxio parameter is specifed as a constant (rather than a variable).

Parameter value(s)

  • auxio : The GPIO pin to be set (index of AUX I/O pin)

gpioToggleOutput

Prototype: gpioToggleOutput(auxio)

Toggles a single GPIO output pin (to low if previously high, or to high if previously low).

Note: This procedure is more efficient if the auxio parameter is specifed as a constant (rather than a variable).

Parameter value(s)

  • auxio : The GPIO pin to be toggled (index of AUX I/O pin)