include/gpio/port.h File Reference

I/O Ports implementation. More...

#include <compiler.h>
#include <types.h>
#include <regs/xmega_port.h>

Go to the source code of this file.

Defines

#define CREATE_GPIO_PIN(port, pin)   ((PORT_##port) + (pin))
 Create a GPIO number.
Input/Output Configuration Flags

#define PORT_DIR_INPUT   (0 << 8)
 Pin is Input.
#define PORT_DIR_OUTPUT   (1 << 8)
 Pin is Output.
Initial Output State Flags

#define PORT_INIT_LOW   (0 << 9)
 Initial Ouptput State is High.
#define PORT_INIT_HIGH   (1 << 9)
 Initial Ouptput State is Low.
Input/Sense Configuration Flags

#define PORT_BOTHEDGES   (0 << 0)
 Sense Both Edges.
#define PORT_RISING   (1 << 0)
 Sense Risign Edge.
#define PORT_FALLING   (2 << 0)
 Sense Falling Edge.
#define PORT_LEVEL   (3 << 0)
 Sense Low Level.
#define PORT_INPUT_DISABLE   (7 << 0)
 Input Buffer Disabled.
Output and Pull Configuration Flags

#define PORT_TOTEM   (0 << 3)
 Normal push/pull output.
#define PORT_BUSKEEPER   (1 << 3)
 Bus Keeper.
#define PORT_PULL_DOWN   (2 << 3)
 Pull-Down (when input).
#define PORT_PULL_UP   (3 << 3)
 Pull-Up (when input).
#define PORT_WIRED_OR   (4 << 3)
 Wired OR.
#define PORT_WIRED_AND   (5 << 3)
 Wired AND.
#define PORT_WIRED_OR_PULL_DOWN   (6 << 3)
 Wired OR and Pull-Down.
#define PORT_WIRED_AND_PULL_UP   (7 << 3)
 Wired AND and Pull-Up.
Inverted I/O Configuration Flags

#define PORT_INV_ENABLED   (1 << 6)
 I/O is Inverted.
#define PORT_INV_DISABLE   (0 << 6)
 I/O is Not Inverted.
Slew Rate Limit Configuration Flags

#define PORT_SRL_ENABLED   (1 << 7)
 Slew Rate Limit Enabled.
#define PORT_SRL_DISABLED   (0 << 7)
 Slew Rate Limit Disabled.
PORT Pin Numbering

For internal use only.

These macros are used to generate GPIO pin numbers for each port with the CREATE_GPIO_PIN macro. Each port has 8 pins so e.g. the first pin on PORTB gets number 8, first pin on PORTC gets 16 ...

#define PORT_PORTA   (0 * 8)
#define PORT_PORTB   (1 * 8)
#define PORT_PORTC   (2 * 8)
#define PORT_PORTD   (3 * 8)
#define PORT_PORTE   (4 * 8)
#define PORT_PORTF   (5 * 8)
#define PORT_PORTG   (6 * 8)
#define PORT_PORTH   (7 * 8)
#define PORT_PORTJ   (8 * 8)
#define PORT_PORTK   (9 * 8)
#define PORT_PORTL   (10 * 8)
#define PORT_PORTM   (11 * 8)
#define PORT_PORTN   (12 * 8)
#define PORT_PORTP   (13 * 8)
#define PORT_PORTQ   (14 * 8)
#define PORT_PORTR   (15 * 8)

Typedefs

typedef uint8_t pin_mask_t
 A bitmask representing a set of pins on a port.
typedef uint16_t gpio_pin_t
 A GPIO pin.
typedef uint16_t port_pin_flags_t
 Pin configuration flags.

Functions

static void * gpio_pin_to_port (gpio_pin_t pin)
 Create a pointer to a port from a GPIO pin number.
static pin_mask_t gpio_pin_to_mask (gpio_pin_t pin)
 Generate port pin mask form GPIO pin number.
void port_select_gpio (void *port, pin_mask_t pin_mask, port_pin_flags_t flags)
 Select the GPIO function for a set of pins on a port.
static void port_select_gpio_pin (gpio_pin_t pin, port_pin_flags_t 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 __always_inline void gpio_toggle_value (gpio_pin_t pin)
 Toggle the current state of a GPIO pin.

Detailed Description

I/O Ports implementation.

Copyright (C) 2009 Atmel Corporation. All rights reserved.

Definition in file port.h.

Generated on Thu Apr 29 14:09:58 2010 for display-demo by  doxygen 1.6.3