Microchip® Advanced Software Framework

port.h File Reference

SAM GPIO Port Driver.

Copyright (c) 2012-2020 Microchip Technology Inc. and its subsidiaries.

#include <compiler.h>
#include <pinmux.h>

Data Structures

struct  port_config
 Port pin configuration structure. More...
 

Macros

PORT Alias Macros
#define PORTA   PORT->Group[0]
 Convenience definition for GPIO module group A on the device (if available). More...
 
#define PORTB   PORT->Group[1]
 Convenience definition for GPIO module group B on the device (if available). More...
 
#define PORTC   PORT->Group[2]
 Convenience definition for GPIO module group C on the device (if available). More...
 
#define PORTD   PORT->Group[3]
 Convenience definition for GPIO module group D on the device (if available). More...
 

Enumerations

enum  port_pin_dir {
  PORT_PIN_DIR_INPUT = SYSTEM_PINMUX_PIN_DIR_INPUT,
  PORT_PIN_DIR_OUTPUT = SYSTEM_PINMUX_PIN_DIR_OUTPUT,
  PORT_PIN_DIR_OUTPUT_WTH_READBACK = SYSTEM_PINMUX_PIN_DIR_OUTPUT_WITH_READBACK
}
 Port pin direction configuration enum. More...
 
enum  port_pin_pull {
  PORT_PIN_PULL_NONE = SYSTEM_PINMUX_PIN_PULL_NONE,
  PORT_PIN_PULL_UP = SYSTEM_PINMUX_PIN_PULL_UP,
  PORT_PIN_PULL_DOWN = SYSTEM_PINMUX_PIN_PULL_DOWN
}
 Port pin input pull configuration enum. More...
 

Functions

State Reading/Writing (Physical Group Orientated)
static PortGroup * port_get_group_from_gpio_pin (const uint8_t gpio_pin)
 Retrieves the PORT module group instance from a given GPIO pin number. More...
 
static uint32_t port_group_get_input_level (const PortGroup *const port, const uint32_t mask)
 Retrieves the state of a group of port pins that are configured as inputs. More...
 
static uint32_t port_group_get_output_level (const PortGroup *const port, const uint32_t mask)
 Retrieves the state of a group of port pins that are configured as outputs. More...
 
static void port_group_set_output_level (PortGroup *const port, const uint32_t mask, const uint32_t level_mask)
 Sets the state of a group of port pins that are configured as outputs. More...
 
static void port_group_toggle_output_level (PortGroup *const port, const uint32_t mask)
 Toggles the state of a group of port pins that are configured as an outputs. More...
 
Configuration and Initialization
static void port_get_config_defaults (struct port_config *const config)
 Initializes a Port pin/group configuration structure to defaults. More...
 
void port_pin_set_config (const uint8_t gpio_pin, const struct port_config *const config)
 Writes a Port pin configuration to the hardware module. More...
 
void port_group_set_config (PortGroup *const port, const uint32_t mask, const struct port_config *const config)
 Writes a Port group configuration group to the hardware module. More...
 
State Reading/Writing (Logical Pin Orientated)
static bool port_pin_get_input_level (const uint8_t gpio_pin)
 Retrieves the state of a port pin that is configured as an input. More...
 
static bool port_pin_get_output_level (const uint8_t gpio_pin)
 Retrieves the state of a port pin that is configured as an output. More...
 
static void port_pin_set_output_level (const uint8_t gpio_pin, const bool level)
 Sets the state of a port pin that is configured as an output. More...
 
static void port_pin_toggle_output_level (const uint8_t gpio_pin)
 Toggles the state of a port pin that is configured as an output. More...