|
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. | |
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 CREATE_GPIO_PIN | ( | port, | |||
| pin | ) | ((PORT_##port) + (pin)) |
| #define PORT_DIR_INPUT (0 << 8) |
| #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_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_WIRED_AND_PULL_UP (7 << 3) |
| #define PORT_WIRED_OR_PULL_DOWN (6 << 3) |
| typedef uint16_t gpio_pin_t |
| typedef uint8_t pin_mask_t |
| typedef uint16_t port_pin_flags_t |
| static __always_inline bool gpio_get_value | ( | gpio_pin_t | pin | ) | [static] |
Read the current state of a GPIO pin.
| pin | A number identifying the pin to read. |
| 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.
| pin | GPIO pin number. |
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.
| pin | GPIO pin number. This number can be generated by the macro CREATE_GPIO_PIN. |
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.
| 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.
| 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.
| 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.
| 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().
1.6.3