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...
 
struct  port_input_event_config
 Port input event configuration structure. More...
 

Macros

Driver Feature Definition

Define port features set according to different device family.

#define FEATURE_PORT_INPUT_EVENT
 Event input control feature support for PORT group. More...
 
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_input_event {
  PORT_INPUT_EVENT_0 = 0,
  PORT_INPUT_EVENT_1 = 1,
  PORT_INPUT_EVENT_2 = 2,
  PORT_INPUT_EVENT_3 = 3
}
 Port input event. More...
 
enum  port_input_event_action {
  PORT_INPUT_EVENT_ACTION_OUT = 0,
  PORT_INPUT_EVENT_ACTION_SET,
  PORT_INPUT_EVENT_ACTION_CLR,
  PORT_INPUT_EVENT_ACTION_TGL
}
 Port input event action. More...
 
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...
 
Port Input Event
static enum status_code port_enable_input_event (const uint8_t gpio_pin, const enum port_input_event n)
 Enable the port event input. More...
 
static enum status_code port_disable_input_event (const uint8_t gpio_pin, const enum port_input_event n)
 Disable the port event input. More...
 
static void port_input_event_get_config_defaults (struct port_input_event_config *const config)
 Retrieve the default configuration for port input event. More...
 
static enum status_code port_input_event_set_config (const enum port_input_event n, struct port_input_event_config *const config)
 Configure port input event. More...