# include/gpio/portmux_gpio.h File Reference

GPIO portmux interface. More...

`#include <gpio/portmux_gpio_regs.h>`

Include dependency graph for portmux_gpio.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

## Defines
#define | PORTMUX_GPIO_VER(major, minor) (((major) << 8) | (minor))
| Encode a GPIO portmux version number.
## Typedefs
typedef uint32_t | pin_mask_t
| A bitmask representing a set of pins on a port.
typedef unsigned int | gpio_pin_t
| A GPIO pin.
## Functions
void | portmux_select_peripheral (void *port, pin_mask_t pin_mask, enum portmux_function func, unsigned long flags)
| Select a peripheral function for a set of pins.
void | portmux_select_gpio (void *port, pin_mask_t pin_mask, unsigned long flags)
| Select the GPIO function for a set of pins.
static void | portmux_select_gpio_pin (gpio_pin_t pin, unsigned long flags)
| Select the GPIO function for a single pin.
void | gpio_set_value_noninline (gpio_pin_t pin, bool value)
| Drive a GPIO pin to a given state (non-constant pin version).
bool | gpio_get_value_noninline (gpio_pin_t pin)
| Read the current state of a GPIO pin (non-constant pin version).
static __always_inline void | gpio_set_value (gpio_pin_t pin, bool value)
| Drive a GPIO pin to a given state.
static __always_inline bool | gpio_get_value (gpio_pin_t pin)
| Read the current state of a GPIO pin.
static uint32_t | gpio_get_int_flag (gpio_pin_t pin)
| Read interrupt flag for given GPIO pin.
static uint32_t | gpio_int_is_pending (gpio_pin_t pin)
| Check if GPIO pin interrupt is pending.
static void | gpio_clear_int_flag (gpio_pin_t pin)
| Clear interrupt flag for give GPIO pin.
static bool | gpio_get_int_mask (gpio_pin_t pin)
| Get interrupt mask for given GPIO pin.
static void | gpio_enable_interrupt (gpio_pin_t pin)
| Enable interrupt for given GPIO pin.
static void | gpio_disable_interrupt (gpio_pin_t pin)
| Disable interrupt for given GPIO pin.

## Detailed Description

GPIO portmux interface.

- Compiler: IAR EWAVR32 and GNU GCC for AVR32
- Supported devices: All AVR32 devices with a GPIO module
- AppNote:

Author:
  Atmel Corporation: http://www.atmel.com
  Support and FAQ: http://support.atmel.no/

Definition in file portmux_gpio.h.

## Define Documentation

#define PORTMUX_GPIO_VER | ( | major,
|  | minor |  | ) | (((major) << 8) | (minor))

Encode a GPIO portmux version number.

Parameters:

  | major | The major version number of the module.
  | minor | The minor version number.

Returns:
  An encoded version number which can be used to compare two version numbers numerically. A higher major number will always yield a numerically larger code. If the major number is the same, a higher minor number will yield a numerically larger code.

Definition at line 73 of file portmux_gpio.h.

Referenced by portmux_gpio_version(), portmux_select_gpio(), and portmux_select_peripheral().

## Typedef Documentation

typedef unsigned int gpio_pin_t

A GPIO pin.

This type is used to describe the GPIO pins on the part.

Definition at line 60 of file portmux_gpio.h.

typedef uint32_t pin_mask_t

A bitmask representing a set of pins on a port.

Starting from pin 0 as the LSB, each bit in the mask corresponds to a pin on some port. Each '1' bit includes the corresponding pin in the set.

Definition at line 53 of file portmux_gpio.h.

## Function Documentation

static void gpio_clear_int_flag | ( | gpio_pin_t | pin | ) | `[inline, static]`

Clear interrupt flag for give GPIO pin.

Parameters:

  | pin | A number identifying the pin.

Definition at line 224 of file portmux_gpio.h.

References gpio_write_reg.

Referenced by gpio_priv_irq_group_interrupt().

static void gpio_disable_interrupt | ( | gpio_pin_t | pin | ) | `[inline, static]`

Disable interrupt for given GPIO pin.

Parameters:

  | pin | A number identifying the pin.

Definition at line 256 of file portmux_gpio.h.

References gpio_write_reg.

static void gpio_enable_interrupt | ( | gpio_pin_t | pin | ) | `[inline, static]`

Enable interrupt for given GPIO pin.

Parameters:

  | pin | A number identifying the pin.

Definition at line 246 of file portmux_gpio.h.

References gpio_write_reg.

static uint32_t gpio_get_int_flag | ( | gpio_pin_t | pin | ) | `[inline, static]`

Read interrupt flag for given GPIO pin.

Parameters:

  | pin | A number identifying the pin.

Return values:

  | 0 | No interrupt flag set
  | non-zero | Interrupt flag set

Definition at line 194 of file portmux_gpio.h.

References gpio_read_reg.

static bool gpio_get_int_mask | ( | gpio_pin_t | pin | ) | `[inline, static]`

Get interrupt mask for given GPIO pin.

Parameters:

  | pin | A number identifying the pin.

Definition at line 234 of file portmux_gpio.h.

References gpio_read_reg.

static __always_inline bool gpio_get_value | ( | gpio_pin_t | pin | ) | `[static]`

Read the current state of a GPIO pin.

Parameters:

  | pin | A number identifying the pin to read.

Return values:

  | true | The pin is currently high (close to Vdd)
  | false | The pin is currently low (close to Vss)

Definition at line 178 of file portmux_gpio.h.

References gpio_get_value_noninline(), and is_constant.

Here is the call graph for this function:

bool gpio_get_value_noninline | ( | gpio_pin_t | pin | ) |

Read the current state of a GPIO pin (non-constant pin version).

Parameters:

  | pin | A number identifying the pin to read.

Return values:

  | true | The pin is currently high (close to Vdd)
  | false | The pin is currently low (close to Vss)

Definition at line 183 of file portmux_gpio.c.

Referenced by gpio_get_value().

static uint32_t gpio_int_is_pending | ( | gpio_pin_t | pin | ) | `[inline, static]`

Check if GPIO pin interrupt is pending.

Check if both interrupt is enabled and interrupt flag is set.

Parameters:

  | pin | A number identifying the pin.

Return values:

  | 0 | No interrupt is pending
  | non-zero | Interrupt is pending

Definition at line 211 of file portmux_gpio.h.

References gpio_read_reg.

Referenced by gpio_priv_irq_group_interrupt().

static __always_inline void gpio_set_value | ( | gpio_pin_t | pin,
|  | bool | value |
| ) |  |  | `[static]`

Drive a GPIO pin to a given state.

This function will only have an effect if pin is configured as an output.

Parameters:

  | pin | A number identifying the pin to act on.
  | value | The desired state of the pin. true means drive the pin high (towards Vdd), while false means drive the pin low (towards Vss).

Definition at line 162 of file portmux_gpio.h.

References gpio_set_value_noninline(), and is_constant.

Referenced by led_activate(), and led_deactivate().

Here is the call graph for this function:

void gpio_set_value_noninline | ( | gpio_pin_t | pin,
|  | bool | value |
| ) |  |  |

Drive a GPIO pin to a given state (non-constant pin version).

This function will only have an effect if pin is configured as an output.

Parameters:

  | pin | A number identifying the pin to act on.
  | value | The desired state of the pin. true means drive the pin high (towards Vdd), while false means drive the pin low (towards Vss).

Definition at line 170 of file portmux_gpio.c.

Referenced by gpio_set_value().

void portmux_select_gpio | ( | void * | port,
|  | pin_mask_t | pin_mask,
|  | unsigned long | flags |
| ) |  |  |

Select the GPIO function for a set of pins.

Parameters:

  | port | The GPIO port to which the pins belong.
  | pin_mask | Bitmask of pins on port to be configured.
  | flags | Bitmask of flags specifying additional configuration parameters.

Definition at line 105 of file portmux_gpio.c.

References gpio_write_reg, PORTMUX_GPIO_VER, and portmux_gpio_version().

Referenced by portmux_select_gpio_pin().

Here is the call graph for this function:

static void portmux_select_gpio_pin | ( | gpio_pin_t | pin,
|  | unsigned long | flags |
| ) |  |  | `[inline, static]`

Select the GPIO function for a single pin.

Parameters:

  | pin | The pin to configure
  | flags | Bitmask of flags specifying additional configuration parameters.

Definition at line 123 of file portmux_gpio.h.

References portmux_select_gpio().

Referenced by portmux_enable_spi_cs().

Here is the call graph for this function:

void portmux_select_peripheral | ( | void * | port,
|  | pin_mask_t | pin_mask,
|  | enum portmux_function | func,
|  | unsigned long | flags |
| ) |  |  |

Select a peripheral function for a set of pins.

Parameters:

  | port | The GPIO port to which the pins belong.
  | pin_mask | Bitmask of pins on port to be configured.
  | func | The peripheral function to which the pins are to be assigned.
  | flags | Bitmask of flags specifying additional configuration parameters.

Definition at line 56 of file portmux_gpio.c.

References gpio_write_reg, PORTMUX_GPIO_VER, and portmux_gpio_version().

Referenced by portmux_enable_usbb().

Here is the call graph for this function: