Digital Output Pins

Description

General-purpose digital output pins

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

When the SCIF driver is initialized, the pins are by configured to operate in digital output mode, with initial output value as specified per resource I/O usage.

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 gpioSetOutput() . For a name XYZ:
    • If selecting accessed by constant , a single constant AUXIO_O_XYZ is created automatically
    • If selecting accessed by look-up table , a data structure member cfg.pAuxioOXyz[] is created automatically
  • The label is displayed in the I/O Mapping Panel , and is also used in automatically generated code documentation

Output Drive Strength

Output drive strength is configurable per resource I/O usage, with the same options as in the SDK-provided PIN or GPIO driver.

See the device datasheet to find which I/O pins have high-drive capability.

Examples

Changing Pin Output

// Set a single pin. Using a constant as parameter is fast (1 instruction cycle) because all calculations
// can be done at compile-time and the iobset instruction can be used.
gpioSetOutput(AUXIO_O_LED);

// Clear an array of pins. Using a variable as parameter is slower (10 instruction cycles) because
// all calculations must be done at run-time and the iobclr instruction cannot be used.
for (U16 n = 0; n < LED_COUNT; n++) {
    gpioClearOutput(cfg.pAuxioOLeds[n]);
}

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 …
gpioGenPulseTrain() Generates a pulse train with specified polarity and active/inactive duration on the specified AUX I/O 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 …
gpioWaitForLevel() Waits forever for the specified level on the specified GPIO pin. More …
gpioWaitForLevelUs() Waits for the specified level on the specified I/O pin, or until the specified number of microseconds have elapsed. 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)

gpioGenPulseTrain

Prototype: gpioGenPulseTrain(#auxio, #polarity, #activeDuration, #inactiveDuration, count)

Generates a pulse train with specified polarity and active/inactive duration on the specified AUX I/O pin.

Parameter value(s)

  • #auxio : The GPIO pin to be pulsed (index of AUX I/O pin)
  • #polarity : The value of the pulse (1 = high, 0 = low) during the active phase
  • #activeDuration : Duration of the active phase, in number of 12 MHz periods (1 to 256)
  • #inactiveDuration : Duration of the inactive phase, in number of 12 MHz periods (3 to 256)
  • count : Length of the pulse train in number of pulses (1 to 65535)

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)

gpioWaitForLevel

Prototype: gpioWaitForLevel(auxio, #level)

Waits forever for the specified level on the specified GPIO pin.

Parameter value(s)

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

gpioWaitForLevelUs

Prototype: gpioWaitForLevelUs(auxio, #level, timeout)

Waits for the specified level on the specified I/O pin, or until the specified number of microseconds have elapsed.

Parameter value(s)

  • auxio : The GPIO pin to be cleared (index of AUX I/O pin)
  • #level : GPIO level to wait for
  • timeout : Timeout value in microseconds (1-65535)