Microchip® Advanced Software Framework

pio.h File Reference

Parallel Input/Output (PIO) Controller driver for SAM.

Copyright (c) 2011-2018 Microchip Technology Inc. and its subsidiaries.

#include "compiler.h"

Macros

#define PIO_DEBOUNCE   (1u << 3)
 
#define PIO_DEFAULT   (0u << 0)
 
#define PIO_DEGLITCH   (1u << 1)
 
#define PIO_DELTA   ((uint32_t) PIOB - (uint32_t) PIOA)
 
#define PIO_IT_AIME   (1u << 4)
 
#define PIO_IT_EDGE   (1u << 6)
 
#define PIO_IT_FALL_EDGE   (0 | PIO_IT_EDGE | PIO_IT_AIME)
 
#define PIO_IT_HIGH_LEVEL   (PIO_IT_RE_OR_HL | 0 | PIO_IT_AIME)
 
#define PIO_IT_LOW_LEVEL   (0 | 0 | PIO_IT_AIME)
 
#define PIO_IT_RE_OR_HL   (1u << 5)
 
#define PIO_IT_RISE_EDGE   (PIO_IT_RE_OR_HL | PIO_IT_EDGE | PIO_IT_AIME)
 
#define PIO_OPENDRAIN   (1u << 2)
 
#define PIO_PULLUP   (1u << 0)
 
#define PIO_TYPE_Msk   (0xFu << PIO_TYPE_Pos)
 
#define PIO_TYPE_NOT_A_PIN   (0x0u << PIO_TYPE_Pos)
 
#define PIO_TYPE_PIO_INPUT   (0x5u << PIO_TYPE_Pos)
 
#define PIO_TYPE_PIO_OUTPUT_0   (0x6u << PIO_TYPE_Pos)
 
#define PIO_TYPE_PIO_OUTPUT_1   (0x7u << PIO_TYPE_Pos)
 
#define PIO_TYPE_PIO_PERIPH_A   (0x1u << PIO_TYPE_Pos)
 
#define PIO_TYPE_PIO_PERIPH_B   (0x2u << PIO_TYPE_Pos)
 
#define PIO_TYPE_PIO_PERIPH_C   (0x3u << PIO_TYPE_Pos)
 
#define PIO_TYPE_PIO_PERIPH_D   (0x4u << PIO_TYPE_Pos)
 
#define PIO_TYPE_Pos   27
 

Typedefs

typedef enum _pio_type pio_type_t
 

Enumerations

enum  _pio_type {
  PIO_NOT_A_PIN = PIO_TYPE_NOT_A_PIN,
  PIO_PERIPH_A = PIO_TYPE_PIO_PERIPH_A,
  PIO_PERIPH_B = PIO_TYPE_PIO_PERIPH_B,
  PIO_INPUT = PIO_TYPE_PIO_INPUT,
  PIO_OUTPUT_0 = PIO_TYPE_PIO_OUTPUT_0,
  PIO_OUTPUT_1 = PIO_TYPE_PIO_OUTPUT_1
}
 

Functions

void pio_clear (Pio *p_pio, const uint32_t ul_mask)
 Set a low output level on all the PIOs defined in ul_mask. More...
 
uint32_t pio_configure (Pio *p_pio, const pio_type_t ul_type, const uint32_t ul_mask, const uint32_t ul_attribute)
 Perform complete pin(s) configuration; general attributes and PIO init if necessary. More...
 
void pio_configure_interrupt (Pio *p_pio, const uint32_t ul_mask, const uint32_t ul_attr)
 Configure the given interrupt source. More...
 
uint32_t pio_configure_pin (uint32_t ul_pin, const uint32_t ul_flags)
 Perform complete pin(s) configuration; general attributes and PIO init if necessary. More...
 
uint32_t pio_configure_pin_group (Pio *p_pio, uint32_t ul_mask, const uint32_t ul_flags)
 Perform complete pin(s) configuration; general attributes and PIO init if necessary. More...
 
void pio_disable_interrupt (Pio *p_pio, const uint32_t ul_mask)
 Disable a given interrupt source, with no added side effects. More...
 
void pio_disable_output_write (Pio *p_pio, const uint32_t ul_mask)
 Disable PIO output write. More...
 
void pio_disable_pin_interrupt (uint32_t pin)
 Disable interrupt for a GPIO pin. More...
 
void pio_enable_interrupt (Pio *p_pio, const uint32_t ul_mask)
 Enable the given interrupt source. More...
 
void pio_enable_output_write (Pio *p_pio, const uint32_t ul_mask)
 Enable PIO output write for synchronous data output. More...
 
void pio_enable_pin_interrupt (uint32_t pin)
 Enable interrupt for a GPIO pin. More...
 
uint32_t pio_get (Pio *p_pio, const pio_type_t ul_type, const uint32_t ul_mask)
 Return 1 if one or more PIOs of the given Pin instance currently have a high level; otherwise returns 0. More...
 
uint32_t pio_get_interrupt_mask (const Pio *p_pio)
 Read PIO interrupt mask. More...
 
uint32_t pio_get_interrupt_status (const Pio *p_pio)
 Read and clear PIO interrupt status. More...
 
uint32_t pio_get_multi_driver_status (const Pio *p_pio)
 Get multi-driver status. More...
 
uint32_t pio_get_output_data_status (const Pio *p_pio, const uint32_t ul_mask)
 Return 1 if one or more PIOs of the given Pin are configured to output a high level (even if they are not output). More...
 
uint32_t pio_get_output_write_status (const Pio *p_pio)
 Read PIO output write status. More...
 
Pio * pio_get_pin_group (uint32_t pin)
 Return GPIO port for a GPIO pin. More...
 
uint32_t pio_get_pin_group_id (uint32_t pin)
 Return GPIO port peripheral ID for a GPIO pin. More...
 
uint32_t pio_get_pin_group_mask (uint32_t pin)
 Return GPIO port pin mask for a GPIO pin. More...
 
uint32_t pio_get_pin_value (uint32_t pin)
 Return the value of a pin. More...
 
uint32_t pio_get_writeprotect_status (const Pio *p_pio)
 Read write protect status. More...
 
void pio_pull_up (Pio *p_pio, const uint32_t ul_mask, const uint32_t ul_pull_up_enable)
 Configure PIO internal pull-up. More...
 
void pio_set (Pio *p_pio, const uint32_t ul_mask)
 Set a high output level on all the PIOs defined in ul_mask. More...
 
void pio_set_additional_interrupt_mode (Pio *p_pio, const uint32_t ul_mask, const uint32_t ul_attribute)
 Set additional interrupt mode. More...
 
void pio_set_debounce_filter (Pio *p_pio, const uint32_t ul_mask, const uint32_t ul_cut_off)
 Configure Glitch or Debouncing filter for the specified input(s). More...
 
void pio_set_input (Pio *p_pio, const uint32_t ul_mask, const uint32_t ul_attribute)
 Configure one or more pin(s) or a PIO controller as inputs. More...
 
void pio_set_multi_driver (Pio *p_pio, const uint32_t ul_mask, const uint32_t ul_multi_driver_enable)
 Configure PIO pin multi-driver. More...
 
void pio_set_output (Pio *p_pio, const uint32_t ul_mask, const uint32_t ul_default_level, const uint32_t ul_multidrive_enable, const uint32_t ul_pull_up_enable)
 Configure one or more pin(s) of a PIO controller as outputs, with the given default value. More...
 
void pio_set_peripheral (Pio *p_pio, const pio_type_t ul_type, const uint32_t ul_mask)
 Configure IO of a PIO controller as being controlled by a specific peripheral. More...
 
void pio_set_pin_group_high (Pio *p_pio, uint32_t ul_mask)
 Drive a GPIO port to 1. More...
 
void pio_set_pin_group_low (Pio *p_pio, uint32_t ul_mask)
 Drive a GPIO port to 0. More...
 
void pio_set_pin_high (uint32_t pin)
 Drive a GPIO pin to 1. More...
 
void pio_set_pin_low (uint32_t pin)
 Drive a GPIO pin to 0. More...
 
void pio_set_writeprotect (Pio *p_pio, const uint32_t ul_enable)
 Enable or disable write protect of PIO registers. More...
 
void pio_sync_output_write (Pio *p_pio, const uint32_t ul_mask)
 Synchronously write on output pins. More...
 
void pio_toggle_pin (uint32_t pin)
 Toggle a GPIO pin. More...
 
void pio_toggle_pin_group (Pio *p_pio, uint32_t ul_mask)
 Toggle a GPIO group. More...
 

#define PIO_DEBOUNCE   (1u << 3)

Referenced by pio_set_input().

#define PIO_DEFAULT   (0u << 0)
#define PIO_DEGLITCH   (1u << 1)

Referenced by pio_set_input().

#define PIO_DELTA   ((uint32_t) PIOB - (uint32_t) PIOA)

Referenced by nm_bus_init(), and pio_get_pin_group().

#define PIO_IT_AIME   (1u << 4)
#define PIO_IT_EDGE   (1u << 6)
#define PIO_IT_FALL_EDGE   (0 | PIO_IT_EDGE | PIO_IT_AIME)
#define PIO_IT_HIGH_LEVEL   (PIO_IT_RE_OR_HL | 0 | PIO_IT_AIME)
#define PIO_IT_LOW_LEVEL   (0 | 0 | PIO_IT_AIME)

Referenced by nm_bsp_register_isr().

#define PIO_IT_RE_OR_HL   (1u << 5)
#define PIO_IT_RISE_EDGE   (PIO_IT_RE_OR_HL | PIO_IT_EDGE | PIO_IT_AIME)
#define PIO_OPENDRAIN   (1u << 2)
#define PIO_TYPE_Msk   (0xFu << PIO_TYPE_Pos)
#define PIO_TYPE_NOT_A_PIN   (0x0u << PIO_TYPE_Pos)
#define PIO_TYPE_PIO_INPUT   (0x5u << PIO_TYPE_Pos)
#define PIO_TYPE_PIO_OUTPUT_0   (0x6u << PIO_TYPE_Pos)
#define PIO_TYPE_PIO_OUTPUT_1   (0x7u << PIO_TYPE_Pos)
#define PIO_TYPE_PIO_PERIPH_A   (0x1u << PIO_TYPE_Pos)
#define PIO_TYPE_PIO_PERIPH_B   (0x2u << PIO_TYPE_Pos)
#define PIO_TYPE_PIO_PERIPH_C   (0x3u << PIO_TYPE_Pos)
#define PIO_TYPE_PIO_PERIPH_D   (0x4u << PIO_TYPE_Pos)
#define PIO_TYPE_Pos   27

typedef enum _pio_type pio_type_t

enum _pio_type
Enumerator
PIO_NOT_A_PIN 
PIO_PERIPH_A 
PIO_PERIPH_B 
PIO_INPUT 
PIO_OUTPUT_0 
PIO_OUTPUT_1