ATmega specific GPIO implementation. More...
#include <assert.h>Go to the source code of this file.
Defines | |
| #define | CREATE_GPIO_PIN(port, pin) (GPIO_##port * 8 + (pin)) |
| Create a GPIO pin number. | |
GPIO pin configuration flags | |
| #define | GPIO_DIR_INPUT (0 << 0) |
| Set pin as input. | |
| #define | GPIO_DIR_OUTPUT (1 << 0) |
| Set pin as output. | |
| #define | GPIO_PULL_UP (1 << 1) |
| Enable pull-up. | |
| #define | GPIO_INIT_HIGH (1 << 1) |
| Set initial pin state to high. | |
| #define | GPIO_INIT_LOW (0 << 1) |
Typedefs | |
| typedef uint8_t | gpio_pin_t |
| Pin number. | |
Functions | |
| static port_t | gpio_pin_to_port (gpio_pin_t pin) |
| Convert a pin number to a port number. | |
| static uint8_t | gpio_pin_to_mask (gpio_pin_t pin) |
| Generate pin mask from pin number. | |
| static void | gpio_set_gpio_pin (gpio_pin_t pin) |
| Sets a pin to high state. | |
| static void | gpio_clear_gpio_pin (gpio_pin_t pin) |
| Set pin to low state. | |
| static void | gpio_set_value (gpio_pin_t pin, bool value) |
| Set gpio pin value. | |
| static bool | gpio_get_value (gpio_pin_t pin) |
| Read a GPIO pin value. | |
| static __always_inline void | port_select_gpio_pin (gpio_pin_t pin, uint8_t flags) |
| Configures a GPIO pin. | |
ATmega specific GPIO implementation.
Copyright (C) 2009 Atmel Corporation. All rights reserved.
Definition in file gpio_mega.h.
| #define CREATE_GPIO_PIN | ( | port, | |||
| pin | ) | (GPIO_##port * 8 + (pin)) |
Create a GPIO pin number.
This macro generates a pin number that can be used with the GPIO functions For instance to create a pin number for pin 2 on PORTA use the macro with the following parameters: CREATE_GPIO_PIN_NUMBER(PORTA, 2)
| port | Port name, e.g. PORTB. | |
| pin | Pin number on the port. Valid values are 0 to 7. |
Definition at line 88 of file gpio_mega.h.
| #define GPIO_DIR_INPUT (0 << 0) |
Set pin as input.
Definition at line 92 of file gpio_mega.h.
Referenced by board_gpio_set_spi_master_mode().
| #define GPIO_DIR_OUTPUT (1 << 0) |
Set pin as output.
Definition at line 93 of file gpio_mega.h.
Referenced by board_gpio_set_spi_master_mode(), board_spi_init_select(), and port_select_gpio_pin().
| #define GPIO_INIT_HIGH (1 << 1) |
Set initial pin state to high.
Definition at line 95 of file gpio_mega.h.
Referenced by board_spi_init_select(), and port_select_gpio_pin().
| #define GPIO_INIT_LOW (0 << 1) |
Set initial pin state to low
Definition at line 96 of file gpio_mega.h.
| #define GPIO_PULL_UP (1 << 1) |
| typedef uint8_t gpio_pin_t |
Pin number.
A pin number is generated from the port and the pin on the port.
Examples: The first pin on port A has the number 0. The first pin on port B has the number 8.
Definition at line 55 of file gpio_mega.h.
| static void gpio_clear_gpio_pin | ( | gpio_pin_t | pin | ) | [inline, static] |
Set pin to low state.
Low in the sense of Vss.
| pin | Pin number. |
Definition at line 163 of file gpio_mega.h.
References gpio_pin_to_mask(), and gpio_pin_to_port().
Referenced by gpio_set_value().
| static bool gpio_get_value | ( | gpio_pin_t | pin | ) | [inline, static] |
Read a GPIO pin value.
Do not attempt to read a pin directly after you have set it. To get the correct value in this case a nop() instruction needs to be added.
| pin | GPIO pin number. |
Definition at line 240 of file gpio_mega.h.
References gpio_pin_to_mask(), gpio_pin_to_port(), and unhandled_case.
Referenced by board_gpio_is_usb_msc_mode().
| static uint8_t gpio_pin_to_mask | ( | gpio_pin_t | pin | ) | [inline, static] |
Generate pin mask from pin number.
| pin | Pin number |
Definition at line 73 of file gpio_mega.h.
Referenced by gpio_clear_gpio_pin(), gpio_get_value(), gpio_set_gpio_pin(), and port_select_gpio_pin().
| static port_t gpio_pin_to_port | ( | gpio_pin_t | pin | ) | [inline, static] |
Convert a pin number to a port number.
| pin | Pin number |
Definition at line 63 of file gpio_mega.h.
Referenced by gpio_clear_gpio_pin(), gpio_get_value(), gpio_set_gpio_pin(), and port_select_gpio_pin().
| static void gpio_set_gpio_pin | ( | gpio_pin_t | pin | ) | [inline, static] |
Sets a pin to high state.
(High means drive the pin towards Vdd)
| pin | Pin number. |
Definition at line 106 of file gpio_mega.h.
References gpio_pin_to_mask(), and gpio_pin_to_port().
Referenced by gpio_set_value().
| static void gpio_set_value | ( | gpio_pin_t | pin, | |
| bool | value | |||
| ) | [inline, static] |
Set gpio pin value.
| pin | GPIO pin number of the pin. | |
| value | 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 222 of file gpio_mega.h.
References gpio_clear_gpio_pin(), and gpio_set_gpio_pin().
Referenced by board_gpio_mcu_reset(), board_spi_deselect_device(), and board_spi_select_device().
| static __always_inline void port_select_gpio_pin | ( | gpio_pin_t | pin, | |
| uint8_t | flags | |||
| ) | [static] |
Configures a GPIO pin.
| pin | Pin number of the GPIO pin. | |
| flags | Configuration options. |
GPIO_DIR_INPUT: Set GPIO pin as input. GPIO_DIR_OUTPUT: Set GPIO pin as output. GPIO_PULL_UP: Activate the pull up if configured as input. GPIO_INIT_HIGH: Set output initial state as high. GPIO_INIT_LOW: Set output initial state as low.
Definition at line 296 of file gpio_mega.h.
References GPIO_DIR_OUTPUT, GPIO_INIT_HIGH, gpio_pin_to_mask(), gpio_pin_to_port(), and GPIO_PULL_UP.
Referenced by board_gpio_set_spi_master_mode(), and board_spi_init_select().
1.6.3