Xmega Application Note


ioport.h File Reference

I/O Ports software driver interface. More...

#include <compiler.h>
Include dependency graph for ioport.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define IOPORT_CREATE_PIN(port, pin)   ((PORT_##port) + (pin))
 Create a PORT pin number.
Input/Sense Configuration Flags

#define IOPORT_BOTHEDGES   (0 << 0)
 Sense Both Edges.
#define IOPORT_FALLING   (2 << 0)
 Sense Falling Edge.
#define IOPORT_INPUT_DISABLE   (7 << 0)
 Input Buffer Disabled.
#define IOPORT_LEVEL   (3 << 0)
 Sense Low Level.
#define IOPORT_RISING   (1 << 0)
 Sense Risign Edge.
Output and Pull Configuration Flags

#define IOPORT_BUSKEEPER   (1 << 3)
 Bus Keeper.
#define IOPORT_PULL_DOWN   (2 << 3)
 Pull-Down (when input).
#define IOPORT_PULL_UP   (3 << 3)
 Pull-Up (when input).
#define IOPORT_TOTEM   (0 << 3)
 Normal push/pull output.
#define IOPORT_WIRED_AND   (5 << 3)
 Wired AND.
#define IOPORT_WIRED_AND_PULL_UP   (7 << 3)
 Wired AND and Pull-Up.
#define IOPORT_WIRED_OR   (4 << 3)
 Wired OR.
#define IOPORT_WIRED_OR_PULL_DOWN   (6 << 3)
 Wired OR and Pull-Down.
Input/Output Configuration Flags

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

#define IOPORT_INIT_HIGH   (1 << 9)
 Initial Ouptput State is High.
#define IOPORT_INIT_LOW   (0 << 9)
 Initial Ouptput State is Low.
Inverted I/O Configuration Flags

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

#define IOPORT_SRL_DISABLED   (0 << 7)
 Slew Rate Limit Disabled.
#define IOPORT_SRL_ENABLED   (1 << 7)
 Slew Rate Limit Enabled.
PORT fields struture offset

For internal use only.

These macros are used to compute the field offset nummber with the PORT_t struture.

#define PORT_DIR   0x00
 Data Direction.
#define PORT_DIRCLR   0x02
 Data Direction Clear.
#define PORT_DIRSET   0x01
 Data Direction Set.
#define PORT_DIRTGL   0x03
 Data Direction Toggle.
#define PORT_IN   0x08
 Data Input Value.
#define PORT_INT0MASK   0x0A
 Interrupt 0 Mask.
#define PORT_INT1MASK   0x0B
 Interrupt 1 Mask.
#define PORT_INTCTRL   0x09
 Interrupt Control.
#define PORT_INTFLAGS   0x0C
 Interrupt Flags.
#define PORT_OUT   0x04
 Data Output Value.
#define PORT_OUTCLR   0x06
 Data Output Value Clear.
#define PORT_OUTSET   0x05
 Data Output Value Set.
#define PORT_OUTTGL   0x07
 Data Output Value Toggle.
#define PORT_PIN0CTRL   0x10
 Pin 0 Configuration.
#define PORT_PIN1CTRL   0x11
 Pin 1 Configuration.
#define PORT_PIN2CTRL   0x12
 Pin 2 Configuration.
#define PORT_PIN3CTRL   0x13
 Pin 3 Configuration.
#define PORT_PIN4CTRL   0x14
 Pin 4 Configuration.
#define PORT_PIN5CTRL   0x15
 Pin 5 Configuration.
#define PORT_PIN6CTRL   0x16
 Pin 6 Configuration.
#define PORT_PIN7CTRL   0x17
 Pin 7 Configuration.
PORT Pin Numbering

For internal use only.

These macros are used to generate PORT pin numbers for each port with the CREATE_PORT_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 uint8_t port_id_t
 A port id.
typedef uint16_t port_pin_flags_t
 Pin configuration flags.
typedef uint8_t port_pin_t
 A PORT pin.

Functions

static void ioport_configure_group (port_id_t port, pin_mask_t pin_mask, port_pin_flags_t flags)
 Configure a group of I/O pins on a specified port number.
static void ioport_configure_pin (port_pin_t pin, port_pin_flags_t flags)
 Select the port function for a single pin.
void ioport_configure_port_pin (void *port, pin_mask_t pin_mask, port_pin_flags_t flags)
 Configure the IO PORT pin function for a set of pins on a port.
static bool ioport_get_value (port_pin_t pin)
 Read the current state of a PORT pin.
static void * ioport_id_pin_to_port (port_id_t port)
 Create a pointer to a port from a PORT id number.
static bool ioport_pin_is_high (port_pin_t pin)
 Read the current state of a PORT pin and test high level.
static bool ioport_pin_is_low (port_pin_t pin)
 Read the current state of a PORT pin and test high level.
static pin_mask_t ioport_pin_to_mask (port_pin_t pin)
 Generate port pin mask form PORT pin number.
static void * ioport_pin_to_port (port_pin_t pin)
 Create a pointer to a port from a PORT pin number.
static void ioport_set_group_high (port_id_t port_id, pin_mask_t port_mask)
 Drives a group of I/O pin of a port to high level.
static void ioport_set_group_low (port_id_t port_id, pin_mask_t port_mask)
 Drives a group of I/O pin of a port to low level.
static void ioport_set_pin_high (port_pin_t pin)
 Drive a PORT pin to a high level.
static void ioport_set_pin_low (port_pin_t pin)
 Drive a PORT pin to a low level.
static void ioport_set_value (port_pin_t pin, bool value)
 Drive a PORT pin to a given state.
static void ioport_tgl_group (port_id_t port_id, pin_mask_t port_mask)
 Toggles a group of I/O pin of a port.
static void ioport_toggle_pin (port_pin_t pin)
 Toggle the current state of a PORT pin.

Detailed Description

I/O Ports software driver interface.

Copyright (c) 2010 Atmel Corporation. All rights reserved.

Definition in file ioport.h.

@DOC_TITLE@
Generated on Fri Oct 22 12:15:25 2010 for AVR1300 Using the Xmega ADC by doxygen 1.6.3