Defines

gpio.c File Reference

GPIO software driver interface for AVR UC3. More...

#include "gpio.h"

Go to the source code of this file.

Defines

#define GPIO   AVR32_GPIO
 GPIO module instance.

Functions

Peripheral Bus Interface

int gpio_enable_module (const gpio_map_t gpiomap, uint32_t size)
 Enables specific module modes for a set of pins.
int gpio_enable_module_pin (uint32_t pin, uint32_t function)
 Enables a specific module mode for a pin.
void gpio_enable_gpio (const gpio_map_t gpiomap, uint32_t size)
 Enables the GPIO mode of a set of pins.
void gpio_enable_gpio_pin (uint32_t pin)
 Enables the GPIO mode of a pin.
void gpio_enable_pin_pull_up (uint32_t pin)
 Enables the pull-up resistor of a pin.
void gpio_disable_pin_pull_up (uint32_t pin)
 Disables the pull-up resistor of a pin.
void gpio_configure_pin (uint32_t pin, uint32_t flags)
 Configuration functionality on a pin.
void gpio_configure_group (uint32_t port, uint32_t mask, uint32_t flags)
 Configuration functionality on a port.
int gpio_get_pin_value (uint32_t pin)
 Returns the value of a pin.
int gpio_get_gpio_pin_output_value (uint32_t pin)
 Returns the output value set for a GPIO pin.
int gpio_get_gpio_open_drain_pin_output_value (uint32_t pin)
 Returns the output value set for a GPIO pin using open drain.
void gpio_set_gpio_pin (uint32_t pin)
 Drives a GPIO pin to 1.
void gpio_set_pin_high (uint32_t pin)
 Drives a GPIO pin to 1.
void gpio_set_group_high (uint32_t port, uint32_t mask)
 Drives a GPIO port to 1.
void gpio_set_pin_low (uint32_t pin)
 Drives a GPIO pin to 0.
void gpio_clr_gpio_pin (uint32_t pin)
 Drives a GPIO pin to 0.
void gpio_set_group_low (uint32_t port, uint32_t mask)
 Drives a GPIO port to 0.
void gpio_tgl_gpio_pin (uint32_t pin)
 Toggles a GPIO pin.
void gpio_toggle_pin (uint32_t pin)
 Toggles a GPIO pin.
void gpio_toggle_group (uint32_t port, uint32_t mask)
 Toggles a GPIO group.
void gpio_set_gpio_open_drain_pin (uint32_t pin)
 Drives a GPIO pin to 1 using open drain.
void gpio_clr_gpio_open_drain_pin (uint32_t pin)
 Drives a GPIO pin to 0 using open drain.
void gpio_tgl_gpio_open_drain_pin (uint32_t pin)
 Toggles a GPIO pin using open drain.
void gpio_enable_pin_glitch_filter (uint32_t pin)
 Enables the glitch filter of a pin.
void gpio_disable_pin_glitch_filter (uint32_t pin)
 Disables the glitch filter of a pin.
static int gpio_configure_edge_detector (uint32_t pin, uint32_t mode)
 Configure the edge detector of an input pin.
int gpio_enable_pin_interrupt (uint32_t pin, uint32_t mode)
 Enables the interrupt of a pin with the specified settings.
void gpio_disable_pin_interrupt (uint32_t pin)
 Disables the interrupt of a pin.
int gpio_get_pin_interrupt_flag (uint32_t pin)
 Gets the interrupt flag of a pin.
void gpio_clear_pin_interrupt_flag (uint32_t pin)
 Clears the interrupt flag of a pin.

Detailed Description

GPIO software driver interface for AVR UC3.

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

Definition in file gpio.c.


Define Documentation

#define GPIO   AVR32_GPIO

Function Documentation

void gpio_clear_pin_interrupt_flag ( uint32_t  pin  ) 

Clears the interrupt flag of a pin.

Parameters:
pin The pin number.

Definition at line 605 of file gpio.c.

References GPIO.

{
  volatile avr32_gpio_port_t *gpio_port = &GPIO.port[pin >> 5];
  gpio_port->ifrc = 1 << (pin & 0x1F);
}

void gpio_clr_gpio_open_drain_pin ( uint32_t  pin  ) 

Drives a GPIO pin to 0 using open drain.

Parameters:
pin The pin number.

Definition at line 502 of file gpio.c.

References GPIO.

{
  volatile avr32_gpio_port_t *gpio_port = &GPIO.port[pin >> 5];

  gpio_port->ovrc  = 1 << (pin & 0x1F); // Value to be driven on the I/O line: 0.
  gpio_port->oders = 1 << (pin & 0x1F); // The GPIO output driver is enabled for that pin.
  gpio_port->gpers = 1 << (pin & 0x1F); // The GPIO module controls that pin.
}

void gpio_clr_gpio_pin ( uint32_t  pin  ) 

Drives a GPIO pin to 0.

Parameters:
pin The pin number.

Definition at line 459 of file gpio.c.

References GPIO.

{
  volatile avr32_gpio_port_t *gpio_port = &GPIO.port[pin >> 5];
  gpio_port->ovrc  = 1 << (pin & 0x1F); // Value to be driven on the I/O line: 0.
  gpio_port->oders = 1 << (pin & 0x1F); // The GPIO output driver is enabled for that pin.
  gpio_port->gpers = 1 << (pin & 0x1F); // The GPIO module controls that pin.  
}

static int gpio_configure_edge_detector ( uint32_t  pin,
uint32_t  mode 
) [static]

Configure the edge detector of an input pin.

Parameters:
pin The pin number.
mode The edge detection mode (GPIO_PIN_CHANGE, GPIO_RISING_EDGE or GPIO_FALLING_EDGE).
Returns:
GPIO_SUCCESS or GPIO_INVALID_ARGUMENT.

Definition at line 543 of file gpio.c.

References GPIO, GPIO_FALLING_EDGE, GPIO_PIN_CHANGE, and GPIO_RISING_EDGE.

Referenced by gpio_enable_pin_interrupt().

{
  volatile avr32_gpio_port_t *gpio_port = &GPIO.port[pin >> 5];
  
  // Configure the edge detector.
  switch (mode)
  {
  case GPIO_PIN_CHANGE:
    gpio_port->imr0c = 1 << (pin & 0x1F);
    gpio_port->imr1c = 1 << (pin & 0x1F);
    break;

  case GPIO_RISING_EDGE:
    gpio_port->imr0s = 1 << (pin & 0x1F);
    gpio_port->imr1c = 1 << (pin & 0x1F);
    break;

  case GPIO_FALLING_EDGE:
    gpio_port->imr0c = 1 << (pin & 0x1F);
    gpio_port->imr1s = 1 << (pin & 0x1F);
    break;

  default:
    return GPIO_INVALID_ARGUMENT;
  }

  return GPIO_SUCCESS;
}

void gpio_configure_group ( uint32_t  port,
uint32_t  mask,
uint32_t  flags 
)

Configuration functionality on a port.

Parameters:
port The port number.
mask The mask.
flags The configuration.

Definition at line 336 of file gpio.c.

References GPIO, GPIO_BOTHEDGES, GPIO_DIR_OUTPUT, GPIO_DRIVE_HIGH, GPIO_DRIVE_LOW, GPIO_FALLING, GPIO_INIT_HIGH, GPIO_INTERRUPT, GPIO_OPEN_DRAIN, GPIO_PULL_DOWN, GPIO_PULL_UP, and GPIO_RISING.

{  
  volatile avr32_gpio_port_t *gpio_port = &GPIO.port[port];  

  /* Both pull-up and pull-down set means buskeeper */
#if defined(AVR32_GPIO_200_H_INCLUDED) || defined(AVR32_GPIO_210_H_INCLUDED) || defined(AVR32_GPIO_211_H_INCLUDED)  
    if (flags & GPIO_PULL_DOWN)
            gpio_port->pders = mask;
    else
            gpio_port->pderc = mask;
#endif    
    if (flags & GPIO_PULL_UP)
            gpio_port->puers = mask;
    else
            gpio_port->puerc = mask;

    /* Enable open-drain mode if requested */
#if defined(AVR32_GPIO_200_H_INCLUDED) || defined(AVR32_GPIO_210_H_INCLUDED) || defined(AVR32_GPIO_211_H_INCLUDED)  
            if (flags & GPIO_OPEN_DRAIN)
                    gpio_port->odmers = mask;
            else
                    gpio_port->odmerc = mask;            

            if (flags & GPIO_OPEN_DRAIN)
                    gpio_port->pders = mask;
            else
                    gpio_port->pderc = mask;
#endif 
            
#if defined(AVR32_GPIO_200_H_INCLUDED) || defined(AVR32_GPIO_210_H_INCLUDED) || defined(AVR32_GPIO_211_H_INCLUDED)  
            /* Select drive strength */
            if (flags & GPIO_DRIVE_LOW)
                    gpio_port->odcr0s = mask;
            else
                    gpio_port->odcr0c = mask;
            if (flags & GPIO_DRIVE_HIGH)
                    gpio_port->odcr1s = mask;
            else
                    gpio_port->odcr1c = mask;
#endif

    /* Select interrupt level for group */
    if (flags & GPIO_INTERRUPT) {
            if (flags & GPIO_BOTHEDGES)
            {
                   gpio_port->imr0c = mask;
                   gpio_port->imr1c = mask;
            }
            else if (flags & GPIO_RISING)
            {
                   gpio_port->imr0s = mask;
                   gpio_port->imr1c = mask;
            }
            else if (flags & GPIO_FALLING)
            {
                   gpio_port->imr0c = mask;
                   gpio_port->imr1s = mask;
            }
    }

    /* Select direction and initial pin state */
    if (flags & GPIO_DIR_OUTPUT) {
            if (flags & GPIO_INIT_HIGH)
                    gpio_port->ovrs = mask;
            else
                    gpio_port->ovrc = mask;
            gpio_port->oders = mask;
    } else {
            gpio_port->oderc = mask;
    }
    
    /* Enable GPIO */
    gpio_port->gpers = mask;
}

void gpio_configure_pin ( uint32_t  pin,
uint32_t  flags 
)

Configuration functionality on a pin.

Parameters:
pin The pin number.
flags The configuration.

Definition at line 261 of file gpio.c.

References GPIO, GPIO_BOTHEDGES, GPIO_DIR_OUTPUT, GPIO_DRIVE_HIGH, GPIO_DRIVE_LOW, GPIO_FALLING, GPIO_INIT_HIGH, GPIO_INTERRUPT, GPIO_OPEN_DRAIN, GPIO_PULL_DOWN, GPIO_PULL_UP, and GPIO_RISING.

{  
  volatile avr32_gpio_port_t *gpio_port = &GPIO.port[pin >> 5];  

  /* Both pull-up and pull-down set means buskeeper */
#if defined(AVR32_GPIO_200_H_INCLUDED) || defined(AVR32_GPIO_210_H_INCLUDED) || defined(AVR32_GPIO_211_H_INCLUDED)  
    if (flags & GPIO_PULL_DOWN)
            gpio_port->pders = 1 << (pin & 0x1F);
    else
            gpio_port->pderc = 1 << (pin & 0x1F);
#endif    
    if (flags & GPIO_PULL_UP)
            gpio_port->puers = 1 << (pin & 0x1F);
    else
            gpio_port->puerc = 1 << (pin & 0x1F);

    /* Enable open-drain mode if requested */
#if defined(AVR32_GPIO_200_H_INCLUDED) || defined(AVR32_GPIO_210_H_INCLUDED) || defined(AVR32_GPIO_211_H_INCLUDED)  
            if (flags & GPIO_OPEN_DRAIN)
                    gpio_port->odmers = 1 << (pin & 0x1F);
            else
                    gpio_port->odmerc = 1 << (pin & 0x1F);            

            if (flags & GPIO_OPEN_DRAIN)
                    gpio_port->pders = 1 << (pin & 0x1F);
            else
                    gpio_port->pderc = 1 << (pin & 0x1F);
#endif 
            
#if defined(AVR32_GPIO_200_H_INCLUDED) || defined(AVR32_GPIO_210_H_INCLUDED) || defined(AVR32_GPIO_211_H_INCLUDED)  
            /* Select drive strength */
            if (flags & GPIO_DRIVE_LOW)
                    gpio_port->odcr0s = 1 << (pin & 0x1F);
            else
                    gpio_port->odcr0c = 1 << (pin & 0x1F);
            if (flags & GPIO_DRIVE_HIGH)
                    gpio_port->odcr1s = 1 << (pin & 0x1F);
            else
                    gpio_port->odcr1c = 1 << (pin & 0x1F);
#endif

    /* Select interrupt level for group */
    if (flags & GPIO_INTERRUPT) {
            if (flags & GPIO_BOTHEDGES)
            {
                   gpio_port->imr0c = 1 << (pin & 0x1F);
                   gpio_port->imr1c = 1 << (pin & 0x1F);
            }
            else if (flags & GPIO_RISING)
            {
                   gpio_port->imr0s = 1 << (pin & 0x1F);
                   gpio_port->imr1c = 1 << (pin & 0x1F);
            }
            else if (flags & GPIO_FALLING)
            {
                   gpio_port->imr0c = 1 << (pin & 0x1F);
                   gpio_port->imr1s = 1 << (pin & 0x1F);
            }
    }

    /* Select direction and initial pin state */
    if (flags & GPIO_DIR_OUTPUT) {
            if (flags & GPIO_INIT_HIGH)
                    gpio_port->ovrs = 1 << (pin & 0x1F);
            else
                    gpio_port->ovrc = 1 << (pin & 0x1F);
            gpio_port->oders = 1 << (pin & 0x1F);
    } else {
            gpio_port->oderc = 1 << (pin & 0x1F);
    }

    /* Enable GPIO */
    gpio_port->gpers = 1 << (pin & 0x1F);
}

void gpio_disable_pin_glitch_filter ( uint32_t  pin  ) 

Disables the glitch filter of a pin.

Parameters:
pin The pin number.

Definition at line 529 of file gpio.c.

References GPIO.

{
  volatile avr32_gpio_port_t *gpio_port = &GPIO.port[pin >> 5];
  gpio_port->gferc = 1 << (pin & 0x1F);
}

void gpio_disable_pin_interrupt ( uint32_t  pin  ) 

Disables the interrupt of a pin.

Parameters:
pin The pin number.

Definition at line 591 of file gpio.c.

References GPIO.

{
  volatile avr32_gpio_port_t *gpio_port = &GPIO.port[pin >> 5];
  gpio_port->ierc = 1 << (pin & 0x1F);
}

void gpio_disable_pin_pull_up ( uint32_t  pin  ) 

Disables the pull-up resistor of a pin.

Parameters:
pin The pin number.

Definition at line 207 of file gpio.c.

References GPIO.

{
  volatile avr32_gpio_port_t *gpio_port = &GPIO.port[pin >> 5];
  gpio_port->puerc = 1 << (pin & 0x1F);
}

void gpio_enable_gpio ( const gpio_map_t  gpiomap,
uint32_t  size 
)

Enables the GPIO mode of a set of pins.

Parameters:
gpiomap The pin map.
size The number of pins in gpiomap.

Definition at line 150 of file gpio.c.

References gpio_enable_gpio_pin(), and gpio_map_t::pin.

{
  uint32_t i;

  for (i = 0; i < size; i++)
  {
    gpio_enable_gpio_pin(gpiomap->pin);
    gpiomap++;
  }
}

void gpio_enable_gpio_pin ( uint32_t  pin  ) 

Enables the GPIO mode of a pin.

Parameters:
pin The pin number.
Refer to the product header file `uc3x.h' (where x is the part number; e.g. x = a0512) for pin definitions. E.g., to enable the GPIO mode of PX21, AVR32_PIN_PX21 can be used. Module pins such as AVR32_PWM_3_PIN for PWM channel 3 can also be used to release module pins for GPIO.

Definition at line 162 of file gpio.c.

References GPIO.

Referenced by gpio_enable_gpio().

{
  volatile avr32_gpio_port_t *gpio_port = &GPIO.port[pin >> 5];
  gpio_port->oderc = 1 << (pin & 0x1F);
  gpio_port->gpers = 1 << (pin & 0x1F);
}

int gpio_enable_module ( const gpio_map_t  gpiomap,
uint32_t  size 
)

Enables specific module modes for a set of pins.

Parameters:
gpiomap The pin map.
size The number of pins in gpiomap.
Returns:
GPIO_SUCCESS or GPIO_INVALID_ARGUMENT.

Definition at line 59 of file gpio.c.

References gpio_map_t::function, gpio_enable_module_pin(), and gpio_map_t::pin.

{
  int status = GPIO_SUCCESS;
  uint32_t i;

  for (i = 0; i < size; i++)
  {
    status |= gpio_enable_module_pin(gpiomap->pin, gpiomap->function);
    gpiomap++;
  }

  return status;
}

int gpio_enable_module_pin ( uint32_t  pin,
uint32_t  function 
)

Enables a specific module mode for a pin.

Parameters:
pin The pin number.
Refer to the product header file `uc3x.h' (where x is the part number; e.g. x = a0512) for module pins. E.g., to enable a PWM channel output, the pin number can be AVR32_PWM_3_PIN for PWM channel 3.
function The pin function.
Refer to the product header file `uc3x.h' (where x is the part number; e.g. x = a0512) for module pin functions. E.g., to enable a PWM channel output, the pin function can be AVR32_PWM_3_FUNCTION for PWM channel 3.
Returns:
GPIO_SUCCESS or GPIO_INVALID_ARGUMENT.

Definition at line 74 of file gpio.c.

References GPIO.

Referenced by gpio_enable_module().

{
  volatile avr32_gpio_port_t *gpio_port = &GPIO.port[pin >> 5];

  // Enable the correct function.
  switch (function)
  {
  case 0: // A function.
    gpio_port->pmr0c = 1 << (pin & 0x1F);
    gpio_port->pmr1c = 1 << (pin & 0x1F);
#if defined(AVR32_GPIO_210_H_INCLUDED) || defined(AVR32_GPIO_211_H_INCLUDED)
    gpio_port->pmr2c = 1 << (pin & 0x1F);
#endif
    break;

  case 1: // B function.
    gpio_port->pmr0s = 1 << (pin & 0x1F);
    gpio_port->pmr1c = 1 << (pin & 0x1F);
#if defined(AVR32_GPIO_210_H_INCLUDED) || defined(AVR32_GPIO_211_H_INCLUDED)
    gpio_port->pmr2c = 1 << (pin & 0x1F);
#endif
    break;

  case 2: // C function.
    gpio_port->pmr0c = 1 << (pin & 0x1F);
    gpio_port->pmr1s = 1 << (pin & 0x1F);
#if defined(AVR32_GPIO_210_H_INCLUDED) || defined(AVR32_GPIO_211_H_INCLUDED)
    gpio_port->pmr2c = 1 << (pin & 0x1F);
#endif
    break;

  case 3: // D function.
    gpio_port->pmr0s = 1 << (pin & 0x1F);
    gpio_port->pmr1s = 1 << (pin & 0x1F);
#if defined(AVR32_GPIO_210_H_INCLUDED) || defined(AVR32_GPIO_211_H_INCLUDED)
    gpio_port->pmr2c = 1 << (pin & 0x1F);
#endif
    break;

#if defined(AVR32_GPIO_210_H_INCLUDED) || defined(AVR32_GPIO_211_H_INCLUDED)
  case 4: // E function.
    gpio_port->pmr0c = 1 << (pin & 0x1F);
    gpio_port->pmr1c = 1 << (pin & 0x1F);
    gpio_port->pmr2s = 1 << (pin & 0x1F);
    break;
    
  case 5: // F function.
    gpio_port->pmr0s = 1 << (pin & 0x1F);
    gpio_port->pmr1c = 1 << (pin & 0x1F);
    gpio_port->pmr2s = 1 << (pin & 0x1F);
    break;
    
  case 6: // G function.
    gpio_port->pmr0c = 1 << (pin & 0x1F);
    gpio_port->pmr1s = 1 << (pin & 0x1F);
    gpio_port->pmr2s = 1 << (pin & 0x1F);
    break;
    
  case 7: // H function.
    gpio_port->pmr0s = 1 << (pin & 0x1F);
    gpio_port->pmr1s = 1 << (pin & 0x1F);
    gpio_port->pmr2s = 1 << (pin & 0x1F);
    break;
#endif

  default:
    return GPIO_INVALID_ARGUMENT;
  }

  // Disable GPIO control.
  gpio_port->gperc = 1 << (pin & 0x1F);

  return GPIO_SUCCESS;
}

void gpio_enable_pin_glitch_filter ( uint32_t  pin  ) 

Enables the glitch filter of a pin.

When the glitch filter is enabled, a glitch with duration of less than 1 clock cycle is automatically rejected, while a pulse with duration of 2 clock cycles or more is accepted. For pulse durations between 1 clock cycle and 2 clock cycles, the pulse may or may not be taken into account, depending on the precise timing of its occurrence. Thus for a pulse to be guaranteed visible it must exceed 2 clock cycles, whereas for a glitch to be reliably filtered out, its duration must not exceed 1 clock cycle. The filter introduces 2 clock cycles latency.

Parameters:
pin The pin number.

Definition at line 522 of file gpio.c.

References GPIO.

{
  volatile avr32_gpio_port_t *gpio_port = &GPIO.port[pin >> 5];
  gpio_port->gfers = 1 << (pin & 0x1F);
}

int gpio_enable_pin_interrupt ( uint32_t  pin,
uint32_t  mode 
)

Enables the interrupt of a pin with the specified settings.

Parameters:
pin The pin number.
mode The trigger mode (GPIO_PIN_CHANGE, GPIO_RISING_EDGE or GPIO_FALLING_EDGE).
Returns:
GPIO_SUCCESS or GPIO_INVALID_ARGUMENT.

Definition at line 573 of file gpio.c.

References GPIO, gpio_configure_edge_detector(), and GPIO_INVALID_ARGUMENT.

{
  volatile avr32_gpio_port_t  *gpio_port = &GPIO.port[pin >> 5];

  // Enable the glitch filter.
  gpio_port->gfers = 1 << (pin & 0x1F);

  // Configure the edge detector.
  if(GPIO_INVALID_ARGUMENT == gpio_configure_edge_detector(pin, mode))
    return(GPIO_INVALID_ARGUMENT);

  // Enable interrupt.
  gpio_port->iers = 1 << (pin & 0x1F);

  return GPIO_SUCCESS;
}

void gpio_enable_pin_pull_up ( uint32_t  pin  ) 

Enables the pull-up resistor of a pin.

Parameters:
pin The pin number.

Definition at line 197 of file gpio.c.

References GPIO.

{
  volatile avr32_gpio_port_t *gpio_port = &GPIO.port[pin >> 5];
  gpio_port->puers = 1 << (pin & 0x1F);
#if defined(AVR32_GPIO_200_H_INCLUDED) || defined(AVR32_GPIO_210_H_INCLUDED) || defined(AVR32_GPIO_211_H_INCLUDED)
  gpio_port->pderc = 1 << (pin & 0x1F);
#endif
}

int gpio_get_gpio_open_drain_pin_output_value ( uint32_t  pin  ) 

Returns the output value set for a GPIO pin using open drain.

Parameters:
pin The pin number.
Returns:
The pin output value.
Note:
This function must be used in conjunction with gpio_set_gpio_open_drain_pin, gpio_clr_gpio_open_drain_pin and gpio_tgl_gpio_open_drain_pin.

Definition at line 425 of file gpio.c.

References GPIO.

{
  volatile avr32_gpio_port_t *gpio_port = &GPIO.port[pin >> 5];
  return ((gpio_port->oder >> (pin & 0x1F)) & 1) ^ 1;
}

int gpio_get_gpio_pin_output_value ( uint32_t  pin  ) 

Returns the output value set for a GPIO pin.

Parameters:
pin The pin number.
Returns:
The pin output value.
Note:
This function must be used in conjunction with gpio_set_gpio_pin, gpio_clr_gpio_pin and gpio_tgl_gpio_pin.

Definition at line 418 of file gpio.c.

References GPIO.

{
  volatile avr32_gpio_port_t *gpio_port = &GPIO.port[pin >> 5];
  return (gpio_port->ovr >> (pin & 0x1F)) & 1;
}

int gpio_get_pin_interrupt_flag ( uint32_t  pin  ) 

Gets the interrupt flag of a pin.

Parameters:
pin The pin number.
Returns:
The pin interrupt flag.

Definition at line 598 of file gpio.c.

References GPIO.

{
  volatile avr32_gpio_port_t *gpio_port = &GPIO.port[pin >> 5];
  return (gpio_port->ifr >> (pin & 0x1F)) & 1;
}

int gpio_get_pin_value ( uint32_t  pin  ) 

Returns the value of a pin.

Parameters:
pin The pin number.
Returns:
The pin value.

Definition at line 411 of file gpio.c.

References GPIO.

{
  volatile avr32_gpio_port_t *gpio_port = &GPIO.port[pin >> 5];
  return (gpio_port->pvr >> (pin & 0x1F)) & 1;
}

void gpio_set_gpio_open_drain_pin ( uint32_t  pin  ) 

Drives a GPIO pin to 1 using open drain.

Parameters:
pin The pin number.

Definition at line 493 of file gpio.c.

References GPIO.

{
  volatile avr32_gpio_port_t *gpio_port = &GPIO.port[pin >> 5];

  gpio_port->oderc = 1 << (pin & 0x1F); // The GPIO output driver is disabled for that pin.
  gpio_port->gpers = 1 << (pin & 0x1F); // The GPIO module controls that pin.
}

void gpio_set_gpio_pin ( uint32_t  pin  ) 

Drives a GPIO pin to 1.

Parameters:
pin The pin number.

Definition at line 432 of file gpio.c.

References GPIO.

{
  volatile avr32_gpio_port_t *gpio_port = &GPIO.port[pin >> 5];
  gpio_port->ovrs  = 1 << (pin & 0x1F); // Value to be driven on the I/O line: 1.
  gpio_port->oders = 1 << (pin & 0x1F); // The GPIO output driver is enabled for that pin.
  gpio_port->gpers = 1 << (pin & 0x1F); // The GPIO module controls that pin.
}

void gpio_set_group_high ( uint32_t  port,
uint32_t  mask 
)

Drives a GPIO port to 1.

Parameters:
port The port number.
mask The mask.

Definition at line 446 of file gpio.c.

References GPIO.

{
  volatile avr32_gpio_port_t *gpio_port = &GPIO.port[port];
  gpio_port->ovrs  = mask; // Value to be driven on the I/O group: 1.
}

void gpio_set_group_low ( uint32_t  port,
uint32_t  mask 
)

Drives a GPIO port to 0.

Parameters:
port The port number.
mask The mask.

Definition at line 467 of file gpio.c.

References GPIO.

{
  volatile avr32_gpio_port_t *gpio_port = &GPIO.port[port];
  gpio_port->ovrc  = mask; // Value to be driven on the I/O group: 0.
}

void gpio_set_pin_high ( uint32_t  pin  ) 

Drives a GPIO pin to 1.

Parameters:
pin The pin number.
Note:
The function gpio_configure_pin must be called before.

Definition at line 440 of file gpio.c.

References GPIO.

{
  volatile avr32_gpio_port_t *gpio_port = &GPIO.port[pin >> 5];
  gpio_port->ovrs  = 1 << (pin & 0x1F); // Value to be driven on the I/O line: 1.
}

void gpio_set_pin_low ( uint32_t  pin  ) 

Drives a GPIO pin to 0.

Parameters:
pin The pin number.
Note:
The function gpio_configure_pin must be called before.

Definition at line 453 of file gpio.c.

References GPIO.

{
  volatile avr32_gpio_port_t *gpio_port = &GPIO.port[pin >> 5];
  gpio_port->ovrc  = 1 << (pin & 0x1F); // Value to be driven on the I/O line: 0.
}

void gpio_tgl_gpio_open_drain_pin ( uint32_t  pin  ) 

Toggles a GPIO pin using open drain.

Parameters:
pin The pin number.

Definition at line 512 of file gpio.c.

References GPIO.

{
  volatile avr32_gpio_port_t *gpio_port = &GPIO.port[pin >> 5];

  gpio_port->ovrc  = 1 << (pin & 0x1F); // Value to be driven on the I/O line if the GPIO output driver is enabled: 0.
  gpio_port->odert = 1 << (pin & 0x1F); // The GPIO output driver is toggled for that pin.
  gpio_port->gpers = 1 << (pin & 0x1F); // The GPIO module controls that pin.
}

void gpio_tgl_gpio_pin ( uint32_t  pin  ) 

Toggles a GPIO pin.

Parameters:
pin The pin number.

Definition at line 473 of file gpio.c.

References GPIO.

{
  volatile avr32_gpio_port_t *gpio_port = &GPIO.port[pin >> 5];
  gpio_port->ovrt  = 1 << (pin & 0x1F); // Toggle the I/O line.
  gpio_port->oders = 1 << (pin & 0x1F); // The GPIO output driver is enabled for that pin.
  gpio_port->gpers = 1 << (pin & 0x1F); // The GPIO module controls that pin.
}

void gpio_toggle_group ( uint32_t  port,
uint32_t  mask 
)

Toggles a GPIO group.

Parameters:
port The port number.
mask The mask.

Definition at line 487 of file gpio.c.

References GPIO.

{
  volatile avr32_gpio_port_t *gpio_port = &GPIO.port[port];
  gpio_port->ovrt  = mask; // Toggle the I/O port.
}

void gpio_toggle_pin ( uint32_t  pin  ) 

Toggles a GPIO pin.

Parameters:
pin The pin number.
Note:
The function gpio_configure_pin must be called before.

Definition at line 481 of file gpio.c.

References GPIO.

{
  volatile avr32_gpio_port_t *gpio_port = &GPIO.port[pin >> 5];
  gpio_port->ovrt  = 1 << (pin & 0x1F); // Toggle the I/O line.
}