PORT Driver

Collaboration diagram for PORT Driver:

Modules

 Port_driver_internals_group

Defines

#define CREATE_GPIO_PIN(port, pin)   ((PORT_##port) + (pin))
 Create a GPIO number.

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.
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.

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.

Detailed Description

This is a driver implementation for the I/O ports peripheral. The I/O ports peripheral can be found on XMEGA devices and it controls and configures the I/O pins.


Define Documentation

#define CREATE_GPIO_PIN ( port,
pin   )     ((PORT_##port) + (pin))

Create a GPIO number.

This macro creates a GPIO pin number from a pin on a port. The GPIO pin number can be used with the functions provided from this driver.

Parameters:
port Port name e.g. PORTA.
pin Pin number on the port, valid values are 0 to 7.

Definition at line 133 of file port.h.

#define PORT_BOTHEDGES   (0 << 0)

Sense Both Edges.

Definition at line 92 of file port.h.

#define PORT_BUSKEEPER   (1 << 3)

Bus Keeper.

Definition at line 102 of file port.h.

#define PORT_DIR_INPUT   (0 << 8)

Pin is Input.

Definition at line 80 of file port.h.

Referenced by gfx_setup_interface().

#define PORT_DIR_OUTPUT   (1 << 8)

Pin is Output.

Definition at line 81 of file port.h.

Referenced by board_spi_init_select(), gfx_setup_interface(), and port_select_gpio().

#define PORT_FALLING   (2 << 0)

Sense Falling Edge.

Definition at line 94 of file port.h.

#define PORT_INIT_HIGH   (1 << 9)

Initial Ouptput State is Low.

Definition at line 87 of file port.h.

Referenced by board_spi_init_select(), gfx_setup_interface(), and port_select_gpio().

#define PORT_INIT_LOW   (0 << 9)

Initial Ouptput State is High.

Definition at line 86 of file port.h.

#define PORT_INPUT_DISABLE   (7 << 0)

Input Buffer Disabled.

Definition at line 96 of file port.h.

#define PORT_INV_DISABLE   (0 << 6)

I/O is Not Inverted.

Definition at line 114 of file port.h.

#define PORT_INV_ENABLED   (1 << 6)

I/O is Inverted.

Definition at line 113 of file port.h.

#define PORT_LEVEL   (3 << 0)

Sense Low Level.

Definition at line 95 of file port.h.

#define PORT_PULL_DOWN   (2 << 3)

Pull-Down (when input).

Definition at line 103 of file port.h.

#define PORT_PULL_UP   (3 << 3)

Pull-Up (when input).

Definition at line 104 of file port.h.

#define PORT_RISING   (1 << 0)

Sense Risign Edge.

Definition at line 93 of file port.h.

#define PORT_SRL_DISABLED   (0 << 7)

Slew Rate Limit Disabled.

Definition at line 120 of file port.h.

#define PORT_SRL_ENABLED   (1 << 7)

Slew Rate Limit Enabled.

Definition at line 119 of file port.h.

#define PORT_TOTEM   (0 << 3)

Normal push/pull output.

Definition at line 101 of file port.h.

#define PORT_WIRED_AND   (5 << 3)

Wired AND.

Definition at line 106 of file port.h.

#define PORT_WIRED_AND_PULL_UP   (7 << 3)

Wired AND and Pull-Up.

Definition at line 108 of file port.h.

#define PORT_WIRED_OR   (4 << 3)

Wired OR.

Definition at line 105 of file port.h.

#define PORT_WIRED_OR_PULL_DOWN   (6 << 3)

Wired OR and Pull-Down.

Definition at line 107 of file port.h.


Typedef Documentation

A GPIO pin.

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

Definition at line 68 of file port.h.

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 61 of file port.h.

Pin configuration flags.

This is a bitmask containing configuration flags for the pins that shall be configured.

Definition at line 76 of file port.h.


Function Documentation

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 268 of file port.h.

References gpio_get_value_noninline(), and is_constant.

static pin_mask_t gpio_pin_to_mask ( gpio_pin_t  pin  )  [inline, static]

Generate port pin mask form GPIO pin number.

Parameters:
pin GPIO pin number.
Returns:
Pin mask.

Definition at line 158 of file port.h.

Referenced by gpio_toggle_value(), and port_select_gpio_pin().

static void* gpio_pin_to_port ( gpio_pin_t  pin  )  [inline, static]

Create a pointer to a port from a GPIO pin number.

It is assumed that all ports are lined up after PORTA in the memory map like it is described in the XMEGA A manual. Otherwise we have to do a switch case here.

Parameters:
pin GPIO pin number. This number can be generated by the macro CREATE_GPIO_PIN.
Returns:
Pointer to the port on which the pin is located.

Definition at line 146 of file port.h.

Referenced by gpio_toggle_value(), and port_select_gpio_pin().

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 253 of file port.h.

References gpio_set_value_noninline(), and is_constant.

Referenced by board_spi_deselect_device(), board_spi_select_device(), and gfx_reset_display().

static __always_inline void gpio_toggle_value ( gpio_pin_t  pin  )  [static]

Toggle the current state of a GPIO pin.

Parameters:
pin A number identifying the pin to act on.

Definition at line 281 of file port.h.

References gpio_pin_to_mask(), gpio_pin_to_port(), and port_write_reg.

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.

Parameters:
port Pointer to the port
pin_mask Mask containing the pins that should be configured
flags Bitmask of flags specifying additional configuration parameters.

Definition at line 42 of file port.c.

References PORT_DIR_OUTPUT, PORT_INIT_HIGH, and port_write_reg.

Referenced by port_select_gpio_pin().

static void port_select_gpio_pin ( gpio_pin_t  pin,
port_pin_flags_t  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 181 of file port.h.

References gpio_pin_to_mask(), gpio_pin_to_port(), and port_select_gpio().

Referenced by board_spi_init_select(), and gfx_setup_interface().

Generated on Thu Apr 29 14:10:01 2010 for display-demo by  doxygen 1.6.3