Macros | Enumerations | Functions
Common IOPORT API

Macros

#define IOPORT_CREATE_PIN(port, pin)   ((IOPORT_ ## port) * 32 + (pin))
 Create IOPORT pin number. More...
 

Enumerations

enum  ioport_direction { IOPORT_DIR_INPUT, IOPORT_DIR_OUTPUT }
 IOPORT pin directions. More...
 
enum  ioport_sense { IOPORT_SENSE_BOTHEDGES, IOPORT_SENSE_RISING, IOPORT_SENSE_FALLING }
 
enum  ioport_value { IOPORT_PIN_LEVEL_LOW, IOPORT_PIN_LEVEL_HIGH }
 IOPORT levels. More...
 

Functions

static void ioport_disable_pin (ioport_pin_t pin)
 Disable IOPORT pin, based on a pin created with IOPORT_CREATE_PIN(). More...
 
static void ioport_disable_port (ioport_port_t port, ioport_port_mask_t mask)
 Disable multiple pins in a single IOPORT port. More...
 
static void ioport_enable_pin (ioport_pin_t pin)
 Enable an IOPORT pin, based on a pin created with IOPORT_CREATE_PIN(). More...
 
static void ioport_enable_port (ioport_port_t port, ioport_port_mask_t mask)
 Enable multiple pins in a single IOPORT port. More...
 
static bool ioport_get_pin_level (ioport_pin_t pin)
 Get current value of an IOPORT pin, which has been configured as an input. More...
 
static ioport_port_mask_t ioport_get_port_level (ioport_pin_t port, ioport_port_mask_t mask)
 Get current value of several IOPORT pins in a single port, which have been configured as an inputs. More...
 
static void ioport_init (void)
 Initializes the IOPORT service, ready for use. More...
 
static ioport_port_mask_t ioport_pin_to_mask (ioport_pin_t pin)
 Convert a pin ID into a bitmask mask for the given pin on its port. More...
 
static ioport_port_t ioport_pin_to_port_id (ioport_pin_t pin)
 Convert a pin ID into a its port ID. More...
 
static void ioport_reset_pin_mode (ioport_pin_t pin)
 Reset pin mode configuration for a single IOPORT pin. More...
 
static void ioport_reset_port_mode (ioport_port_t port, ioport_port_mask_t mask)
 Reset multiple pin modes in a specified IOPORT port to defaults. More...
 
static void ioport_set_pin_dir (ioport_pin_t pin, enum ioport_direction dir)
 Set direction for a single IOPORT pin. More...
 
static void ioport_set_pin_level (ioport_pin_t pin, bool level)
 Set an IOPORT pin to a specified logical value. More...
 
static void ioport_set_pin_mode (ioport_pin_t pin, ioport_mode_t mode)
 Set pin mode for one single IOPORT pin. More...
 
static void ioport_set_pin_sense_mode (ioport_pin_t pin, enum ioport_sense pin_sense)
 Set the pin sense mode of a single IOPORT pin. More...
 
static void ioport_set_port_dir (ioport_port_t port, ioport_port_mask_t mask, enum ioport_direction dir)
 Set I/O direction for a group of pins in a single IOPORT. More...
 
static void ioport_set_port_level (ioport_port_t port, ioport_port_mask_t mask, enum ioport_value level)
 Set a group of IOPORT pins in a single port to a specified logical value. More...
 
static void ioport_set_port_mode (ioport_port_t port, ioport_port_mask_t mask, ioport_mode_t mode)
 Set multiple pin modes in a single IOPORT port, such as pull-up, pull-down, etc. configuration. More...
 
static void ioport_set_port_sense_mode (ioport_port_t port, ioport_port_mask_t mask, enum ioport_sense pin_sense)
 Set the pin sense mode of a multiple IOPORT pins on a single port. More...
 
static void ioport_toggle_pin_level (ioport_pin_t pin)
 Toggle the value of an IOPORT pin, which has previously configured as an output. More...
 
static void ioport_toggle_port_level (ioport_port_t port, ioport_port_mask_t mask)
 Toggle the values of several IOPORT pins located in a single port. More...
 

IOPORT Mode bit definitions

#define IOPORT_MODE_MUX_MASK   (0x7 << 0)
 
#define IOPORT_MODE_MUX_BIT0   ( 1 << 0)
 
#define IOPORT_MODE_MUX_A   ( 0 << 0)
 
#define IOPORT_MODE_MUX_B   ( 1 << 0)
 
#define IOPORT_MODE_PULLUP   ( 1 << 3)
 
#define IOPORT_MODE_OPEN_DRAIN   ( 1 << 5)
 
#define IOPORT_MODE_GLITCH_FILTER   ( 1 << 6)
 
#define IOPORT_MODE_DEBOUNCE   ( 1 << 7)
 

Detailed Description

See Quick start guide for the common IOPORT service.

This is common IOPORT service for GPIO pin configuration and control in a standardized manner across the MEGA, MEGA_RF, XMEGA, UC3 and ARM devices.

Port pin control code is optimized for each platform, and should produce both compact and fast execution times when used with constant values.

Minimal dependencies

This driver depends on the following modules:

IOPORT Modes

For details on these please see the SAM Manual.

Macro Definition Documentation

◆ IOPORT_CREATE_PIN

#define IOPORT_CREATE_PIN (   port,
  pin 
)    ((IOPORT_ ## port) * 32 + (pin))

Create IOPORT pin number.

Create a IOPORT pin number for use with the IOPORT functions.

Parameters
portIOPORT port (e.g. PORTA, PA or PIOA depending on chosen architecture)
pinIOPORT zero-based index of the I/O pin

Definition at line 41 of file ioport_pio.h.

◆ IOPORT_MODE_DEBOUNCE

#define IOPORT_MODE_DEBOUNCE   ( 1 << 7)

Input debounce

Definition at line 87 of file ioport_pio.h.

◆ IOPORT_MODE_GLITCH_FILTER

#define IOPORT_MODE_GLITCH_FILTER   ( 1 << 6)

Glitch filter

Definition at line 86 of file ioport_pio.h.

◆ IOPORT_MODE_MUX_A

#define IOPORT_MODE_MUX_A   ( 0 << 0)

MUX function A

Definition at line 70 of file ioport_pio.h.

◆ IOPORT_MODE_MUX_B

#define IOPORT_MODE_MUX_B   ( 1 << 0)

MUX function B

Definition at line 71 of file ioport_pio.h.

◆ IOPORT_MODE_MUX_BIT0

#define IOPORT_MODE_MUX_BIT0   ( 1 << 0)

MUX BIT0 mask

Definition at line 64 of file ioport_pio.h.

◆ IOPORT_MODE_MUX_MASK

#define IOPORT_MODE_MUX_MASK   (0x7 << 0)

MUX bits mask

Definition at line 63 of file ioport_pio.h.

◆ IOPORT_MODE_OPEN_DRAIN

#define IOPORT_MODE_OPEN_DRAIN   ( 1 << 5)

Open drain

Definition at line 84 of file ioport_pio.h.

◆ IOPORT_MODE_PULLUP

#define IOPORT_MODE_PULLUP   ( 1 << 3)

Pull-up

Definition at line 78 of file ioport_pio.h.

Enumeration Type Documentation

◆ ioport_direction

IOPORT pin directions.

Enumerator
IOPORT_DIR_INPUT 

IOPORT input direction

IOPORT_DIR_OUTPUT 

IOPORT output direction

Definition at line 76 of file ioport.h.

◆ ioport_sense

Enumerator
IOPORT_SENSE_BOTHEDGES 

IOPORT sense both rising and falling edges

IOPORT_SENSE_RISING 

IOPORT sense rising edges

IOPORT_SENSE_FALLING 

IOPORT sense falling edges

Definition at line 112 of file ioport.h.

◆ ioport_value

IOPORT levels.

Enumerator
IOPORT_PIN_LEVEL_LOW 

IOPORT pin value low

IOPORT_PIN_LEVEL_HIGH 

IOPORT pin value high

Definition at line 82 of file ioport.h.

Function Documentation

◆ ioport_disable_pin()

static void ioport_disable_pin ( ioport_pin_t  pin)
inlinestatic

Disable IOPORT pin, based on a pin created with IOPORT_CREATE_PIN().

Parameters
pinIOPORT pin to disable

Definition at line 179 of file ioport.h.

◆ ioport_disable_port()

static void ioport_disable_port ( ioport_port_t  port,
ioport_port_mask_t  mask 
)
inlinestatic

Disable multiple pins in a single IOPORT port.

Parameters
portIOPORT port to disable
maskPin mask of pins to disable

Definition at line 190 of file ioport.h.

◆ ioport_enable_pin()

static void ioport_enable_pin ( ioport_pin_t  pin)
inlinestatic

Enable an IOPORT pin, based on a pin created with IOPORT_CREATE_PIN().

Parameters
pinIOPORT pin to enable

Definition at line 156 of file ioport.h.

◆ ioport_enable_port()

static void ioport_enable_port ( ioport_port_t  port,
ioport_port_mask_t  mask 
)
inlinestatic

Enable multiple pins in a single IOPORT port.

Parameters
portIOPORT port to enable
maskMask of pins within the port to enable

Definition at line 167 of file ioport.h.

◆ ioport_get_pin_level()

static bool ioport_get_pin_level ( ioport_pin_t  pin)
inlinestatic

Get current value of an IOPORT pin, which has been configured as an input.

Parameters
pinIOPORT pin to read
Returns
Current logical value of the specified pin

Definition at line 301 of file ioport.h.

◆ ioport_get_port_level()

static ioport_port_mask_t ioport_get_port_level ( ioport_pin_t  port,
ioport_port_mask_t  mask 
)
inlinestatic

Get current value of several IOPORT pins in a single port, which have been configured as an inputs.

Parameters
portIOPORT port to read
maskPin mask of pins to read
Returns
Logical levels of the specified pins from the read port, returned as a mask.

Definition at line 315 of file ioport.h.

◆ ioport_init()

static void ioport_init ( void  )
inlinestatic

Initializes the IOPORT service, ready for use.

This function must be called before using any other functions in the IOPORT service.

Definition at line 145 of file ioport.h.

◆ ioport_pin_to_mask()

static ioport_port_mask_t ioport_pin_to_mask ( ioport_pin_t  pin)
inlinestatic

Convert a pin ID into a bitmask mask for the given pin on its port.

Parameters
pinIOPORT pin ID to convert
Return values
Bitmaskwith a bit set that corresponds to the given pin ID in its port

Definition at line 387 of file ioport.h.

◆ ioport_pin_to_port_id()

static ioport_port_t ioport_pin_to_port_id ( ioport_pin_t  pin)
inlinestatic

Convert a pin ID into a its port ID.

Parameters
pinIOPORT pin ID to convert
Return values
PortID for the given pin ID

Definition at line 376 of file ioport.h.

◆ ioport_reset_pin_mode()

static void ioport_reset_pin_mode ( ioport_pin_t  pin)
inlinestatic

Reset pin mode configuration for a single IOPORT pin.

Parameters
pinIOPORT pin to configure

Definition at line 239 of file ioport.h.

◆ ioport_reset_port_mode()

static void ioport_reset_port_mode ( ioport_port_t  port,
ioport_port_mask_t  mask 
)
inlinestatic

Reset multiple pin modes in a specified IOPORT port to defaults.

Parameters
portIOPORT port to configure
maskMask of pins whose mode configuration is to be reset

Definition at line 228 of file ioport.h.

◆ ioport_set_pin_dir()

static void ioport_set_pin_dir ( ioport_pin_t  pin,
enum ioport_direction  dir 
)
inlinestatic

Set direction for a single IOPORT pin.

Parameters
pinIOPORT pin to configure
dirDirection to set for the specified pin (ioport_direction)

Definition at line 263 of file ioport.h.

◆ ioport_set_pin_level()

static void ioport_set_pin_level ( ioport_pin_t  pin,
bool  level 
)
inlinestatic

Set an IOPORT pin to a specified logical value.

Parameters
pinIOPORT pin to configure
levelLogical value of the pin

Definition at line 275 of file ioport.h.

◆ ioport_set_pin_mode()

static void ioport_set_pin_mode ( ioport_pin_t  pin,
ioport_mode_t  mode 
)
inlinestatic

Set pin mode for one single IOPORT pin.

Parameters
pinIOPORT pin to configure
modeMode masks to configure for the specified pin (IOPORT Modes)

Definition at line 217 of file ioport.h.

◆ ioport_set_pin_sense_mode()

static void ioport_set_pin_sense_mode ( ioport_pin_t  pin,
enum ioport_sense  pin_sense 
)
inlinestatic

Set the pin sense mode of a single IOPORT pin.

Parameters
pinIOPORT pin to configure
pin_senseEdge to sense for the pin (ioport_sense)

Definition at line 350 of file ioport.h.

◆ ioport_set_port_dir()

static void ioport_set_port_dir ( ioport_port_t  port,
ioport_port_mask_t  mask,
enum ioport_direction  dir 
)
inlinestatic

Set I/O direction for a group of pins in a single IOPORT.

Parameters
portIOPORT port to configure
maskPin mask of pins to configure
dirDirection to set for the specified pins (ioport_direction)

Definition at line 251 of file ioport.h.

◆ ioport_set_port_level()

static void ioport_set_port_level ( ioport_port_t  port,
ioport_port_mask_t  mask,
enum ioport_value  level 
)
inlinestatic

Set a group of IOPORT pins in a single port to a specified logical value.

Parameters
portIOPORT port to write to
maskPin mask of pins to modify
levelLevel of the pins to be modified

Definition at line 288 of file ioport.h.

◆ ioport_set_port_mode()

static void ioport_set_port_mode ( ioport_port_t  port,
ioport_port_mask_t  mask,
ioport_mode_t  mode 
)
inlinestatic

Set multiple pin modes in a single IOPORT port, such as pull-up, pull-down, etc. configuration.

Parameters
portIOPORT port to configure
maskPin mask of pins to configure
modeMode masks to configure for the specified pins (IOPORT Modes)

Definition at line 205 of file ioport.h.

◆ ioport_set_port_sense_mode()

static void ioport_set_port_sense_mode ( ioport_port_t  port,
ioport_port_mask_t  mask,
enum ioport_sense  pin_sense 
)
inlinestatic

Set the pin sense mode of a multiple IOPORT pins on a single port.

Parameters
portIOPORT port to configure
maskBitmask if pins whose edge sense is to be configured
pin_senseEdge to sense for the pins (ioport_sense)

Definition at line 363 of file ioport.h.

◆ ioport_toggle_pin_level()

static void ioport_toggle_pin_level ( ioport_pin_t  pin)
inlinestatic

Toggle the value of an IOPORT pin, which has previously configured as an output.

Parameters
pinIOPORT pin to toggle

Definition at line 327 of file ioport.h.

◆ ioport_toggle_port_level()

static void ioport_toggle_port_level ( ioport_port_t  port,
ioport_port_mask_t  mask 
)
inlinestatic

Toggle the values of several IOPORT pins located in a single port.

Parameters
portIOPORT port to modify
maskPin mask of pins to toggle

Definition at line 338 of file ioport.h.



inertial_sense_ros
Author(s):
autogenerated on Sun Feb 28 2021 03:18:00