Microchip® Advanced Software Framework

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Ioport_service_group

IOPORT Modes

For details on these please see the megaRF Manual.

Data Structures

struct  PORT_struct
 

Typedefs

typedef uint8_t ioport_mode_t
 
typedef uint16_t ioport_pin_t
 
typedef uint8_t ioport_port_mask_t
 
typedef uint8_t ioport_port_t
 
typedef uint8_t pin_mask_t
 A pin mask. More...
 
typedef uint8_t port_id_t
 A port id. More...
 
typedef uint16_t port_pin_flags_t
 Pin configuration flags. More...
 
typedef uint8_t port_pin_t
 A PORT pin. More...
 
typedef struct PORT_struct PORT_t
 

Functions

static __always_inline void arch_ioport_disable_pin (ioport_pin_t pin)
 
static __always_inline void arch_ioport_disable_port (ioport_port_t port, ioport_port_mask_t mask)
 
static __always_inline void arch_ioport_enable_pin (ioport_pin_t pin)
 
static __always_inline void arch_ioport_enable_port (ioport_port_t port, ioport_port_mask_t mask)
 
static __always_inline bool arch_ioport_get_pin_level (ioport_pin_t pin)
 : Get pin level of pin. More...
 
static __always_inline
ioport_port_mask_t 
arch_ioport_get_port_level (ioport_port_t port, ioport_port_mask_t mask)
 : Get multiple pins level of single port. More...
 
static __always_inline void arch_ioport_init (void)
 
static __always_inline PORT_tarch_ioport_pin_to_base (ioport_pin_t pin)
 : To get the base address of port number from defined pin More...
 
static __always_inline
ioport_port_mask_t 
arch_ioport_pin_to_mask (ioport_pin_t pin)
 : To get the 8-bit pin mask for pin More...
 
static __always_inline
ioport_port_t 
arch_ioport_pin_to_port_id (uint8_t pin)
 : To get the port number from pin nuber More...
 
static __always_inline PORT_tarch_ioport_port_to_base (uint8_t port)
 : To get the base address of port number More...
 
static __always_inline void arch_ioport_set_pin_dir (ioport_pin_t pin, enum ioport_direction dir)
 : Set pin direction as input or output. More...
 
static __always_inline void arch_ioport_set_pin_level (ioport_pin_t pin, bool level)
 : Set pin level to high or low. More...
 
static __always_inline void arch_ioport_set_pin_mode (ioport_pin_t pin, ioport_mode_t mode)
 Set multiple pin modes in a single GPIO port, such as pull-up, pull-down, etc. More...
 
static __always_inline void arch_ioport_set_pin_sense_mode (ioport_pin_t pin, enum ioport_sense pin_sense)
 : To configure a single GPIO pin for trigger modes: sense the edge/level/both trigger. More...
 
static __always_inline void arch_ioport_set_port_dir (ioport_port_t port, ioport_port_mask_t mask, enum ioport_direction dir)
 : Set port direction as input or output. More...
 
static __always_inline void arch_ioport_set_port_level (ioport_port_t port, ioport_port_mask_t mask, enum ioport_value level)
 : Set port multiple pins level to high or low. More...
 
static __always_inline void arch_ioport_set_port_mode (ioport_port_t port, ioport_port_mask_t mask, ioport_mode_t mode)
 Set multiple pin modes in a single GPIO port, such as pull-up, pull-down, etc. More...
 
static __always_inline void arch_ioport_set_port_sense_mode (ioport_port_t port, ioport_port_mask_t mask, enum ioport_sense pin_sense)
 : To configure a multiple pins for trigger modes: sense the edge/ level/both trigger. More...
 
static __always_inline void arch_ioport_toggle_pin_level (ioport_pin_t pin)
 : To toggle the pin More...
 
static __always_inline void arch_ioport_toggle_port_level (ioport_port_t port, ioport_port_mask_t mask)
 : To toggle the multiple pins on a single port. More...
 
static __always_inline void ioport_configure_group (port_id_t port, pin_mask_t pin_mask, port_pin_flags_t flags)
 Configure a group of I/O pins on a specified port number. More...
 
static __always_inline void ioport_configure_pin (port_pin_t pin, port_pin_flags_t flags)
 Select the port function for a single pin. More...
 
static __always_inline void ioport_configure_port_pin (void *port, pin_mask_t pin_mask, port_pin_flags_t flags)
 Configure the IO PORT pin function for a set of pins on a port. More...
 
static __always_inline bool ioport_get_value (port_pin_t pin)
 Read the current state of a PORT pin. More...
 
static __always_inline PORT_tioport_id_pin_to_port (port_id_t port)
 : To get the port address pointer from port number More...
 
static __always_inline bool ioport_pin_is_high (port_pin_t pin)
 Read the current state of a PORT pin and test high level. More...
 
static __always_inline bool ioport_pin_is_low (port_pin_t pin)
 Read the current state of a PORT pin and test high level. More...
 
static __always_inline PORT_tioport_pin_to_port (port_pin_t pin)
 : To get the port address pointer from pin More...
 
static __always_inline void ioport_set_group_high (port_id_t port_id, pin_mask_t port_mask)
 Drives a group of I/O pin of a port to high level. More...
 
static __always_inline void ioport_set_group_low (port_id_t port_id, pin_mask_t port_mask)
 Drives a group of I/O pin of a port to low level. More...
 
static __always_inline void ioport_set_pin_high (port_pin_t pin)
 Drive a PORT pin to a high level. More...
 
static __always_inline void ioport_set_pin_low (port_pin_t pin)
 Drive a PORT pin to a low level. More...
 
static __always_inline void ioport_set_value (port_pin_t pin, bool value)
 Drive a PORT pin to a given state. More...
 
static __always_inline void ioport_tgl_group (port_id_t port_id, pin_mask_t port_mask)
 Toggles a group of I/O pin of a port. More...
 
static __always_inline void ioport_toggle_pin (port_pin_t pin)
 Toggle the current state of a PORT pin. More...
 

Variables

volatile uint8_t PORT_struct::DIR
 
volatile uint8_t PORT_struct::PINCRL
 
volatile uint8_t PORT_struct::PORTDATA
 

IOPORT Mode bit definitions

#define IOPORT_MODE_PULLDOWN   (0x01)
 
#define IOPORT_MODE_PULLUP   (0x00)
 

Initial Output State Flags

#define IOPORT_INIT_LOW   0 << 1
 
#define IOPORT_INIT_HIGH   1 << 1
 

Output and Pull Configuration Flags

#define IOPORT_PULL_DOWN   (0 << 2)
 
#define IOPORT_PULL_UP   (1 << 2)
 

#define IOPORT_INIT_HIGH   1 << 1
#define IOPORT_INIT_LOW   0 << 1

Initial Output State Low

Referenced by main().

#define IOPORT_MODE_PULLDOWN   (0x01)
#define IOPORT_MODE_PULLUP   (0x00)
#define IOPORT_PULL_DOWN   (0 << 2)

Pull-Down (when input)

#define IOPORT_PULL_UP   (1 << 2)

Pull-Up (when input)

Referenced by ext_int_init(), ext_int_pcint_init(), and ioport_configure_port_pin().

typedef uint8_t ioport_mode_t
typedef uint16_t ioport_pin_t
typedef uint8_t ioport_port_mask_t
typedef uint8_t ioport_port_t
typedef uint8_t pin_mask_t

A pin mask.

This type is used to describe the port pin mask on the part.

typedef uint8_t port_id_t

A port id.

This type is used to describe the port id on the part (0 is PORTA).

typedef uint16_t port_pin_flags_t

Pin configuration flags.

This is a bitmask containing configuration flags for the pins that shall be configured.

typedef uint8_t port_pin_t

A PORT pin.

This type is used to describe the PORT pins on the part.

typedef struct PORT_struct PORT_t

static __always_inline void arch_ioport_disable_pin ( ioport_pin_t  pin)
static

Referenced by ioport_disable_pin().

static __always_inline void arch_ioport_disable_port ( ioport_port_t  port,
ioport_port_mask_t  mask 
)
static

Referenced by ioport_disable_port().

static __always_inline void arch_ioport_enable_pin ( ioport_pin_t  pin)
static

Referenced by ioport_enable_pin().

static __always_inline void arch_ioport_enable_port ( ioport_port_t  port,
ioport_port_mask_t  mask 
)
static

Referenced by ioport_enable_port().

static __always_inline bool arch_ioport_get_pin_level ( ioport_pin_t  pin)
static

: Get pin level of pin.

Parameters
pin. the pin number defined by IOPORT_CREATE_PIN
Returns
: level high/low

References arch_ioport_pin_to_base(), arch_ioport_pin_to_mask(), and PORT_struct::PINCRL.

Referenced by ioport_get_pin_level(), ioport_get_value(), ioport_pin_is_high(), and ioport_pin_is_low().

static __always_inline ioport_port_mask_t arch_ioport_get_port_level ( ioport_port_t  port,
ioport_port_mask_t  mask 
)
static

: Get multiple pins level of single port.

Parameters
portGPIO port to configure e.g. IOPORT_PORTB
maskPin mask of pins to read data.
Returns
: 8 bit value based on level voltage on pins.

References arch_ioport_port_to_base(), and PORT_struct::PINCRL.

Referenced by ioport_get_port_level().

static __always_inline void arch_ioport_init ( void  )
static

Referenced by ioport_init().

static __always_inline PORT_t* arch_ioport_pin_to_base ( ioport_pin_t  pin)
static

: To get the base address of port number from defined pin

Parameters
pin. the pin number defined by IOPORT_CREATE_PIN

References arch_ioport_port_to_base().

Referenced by arch_ioport_get_pin_level(), arch_ioport_set_pin_dir(), arch_ioport_set_pin_mode(), arch_ioport_toggle_pin_level(), ioport_configure_pin(), and ioport_pin_to_port().

static __always_inline ioport_port_mask_t arch_ioport_pin_to_mask ( ioport_pin_t  pin)
static

: To get the 8-bit pin mask for pin

Parameters
pin. the pin number defined by IOPORT_CREATE_PIN

Referenced by arch_ioport_get_pin_level(), arch_ioport_set_pin_dir(), arch_ioport_set_pin_level(), arch_ioport_set_pin_mode(), arch_ioport_toggle_pin_level(), ioport_configure_pin(), and ioport_pin_to_mask().

static __always_inline ioport_port_t arch_ioport_pin_to_port_id ( uint8_t  pin)
inlinestatic

: To get the port number from pin nuber

Parameters
pin. the pin number defined by IOPORT_CREATE_PIN

Referenced by arch_ioport_set_pin_sense_mode(), and ioport_pin_to_port_id().

static __always_inline PORT_t* arch_ioport_port_to_base ( uint8_t  port)
static
static __always_inline void arch_ioport_set_pin_dir ( ioport_pin_t  pin,
enum ioport_direction  dir 
)
static

: Set pin direction as input or output.

Parameters
pin. the pin number defined by IOPORT_CREATE_PIN
maskPin mask of pins to configure
modedir, ioport_direction

References arch_ioport_pin_to_base(), arch_ioport_pin_to_mask(), PORT_struct::DIR, IOPORT_DIR_INPUT, and IOPORT_DIR_OUTPUT.

Referenced by ioport_set_pin_dir().

static __always_inline void arch_ioport_set_pin_level ( ioport_pin_t  pin,
bool  level 
)
static

: Set pin level to high or low.

Parameters
pin. the pin number defined by IOPORT_CREATE_PIN
level high/low

References arch_ioport_pin_to_mask(), arch_ioport_port_to_base(), and PORT_struct::PORTDATA.

Referenced by ioport_set_pin_high(), ioport_set_pin_level(), ioport_set_pin_low(), and ioport_set_value().

static __always_inline void arch_ioport_set_pin_mode ( ioport_pin_t  pin,
ioport_mode_t  mode 
)
static

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

configuration.

Parameters
pin. the pin number defined by IOPORT_CREATE_PIN
maskPin mask of pins to configure
modeMode masks to configure for the specified pins (IOPORT Modes)

References arch_ioport_pin_to_base(), arch_ioport_pin_to_mask(), IOPORT_MODE_PULLDOWN, IOPORT_MODE_PULLUP, and PORT_struct::PORTDATA.

Referenced by ioport_reset_pin_mode(), and ioport_set_pin_mode().

static __always_inline void arch_ioport_set_pin_sense_mode ( ioport_pin_t  pin,
enum ioport_sense  pin_sense 
)
static

: To configure a single GPIO pin for trigger modes: sense the edge/level/both trigger.

Parameters
pin. the pin number defined by IOPORT_CREATE_PIN
pin_sense,referto .

References arch_ioport_pin_to_port_id(), cpu_irq_restore(), and cpu_irq_save().

Referenced by ioport_set_pin_sense_mode().

static __always_inline void arch_ioport_set_port_dir ( ioport_port_t  port,
ioport_port_mask_t  mask,
enum ioport_direction  dir 
)
static

: Set port direction as input or output.

Parameters
portGPIO port to configure e.g. IOPORT_PORTB
maskPin mask of pins to configure
modedir, ioport_direction

References arch_ioport_port_to_base(), PORT_struct::DIR, IOPORT_DIR_INPUT, and IOPORT_DIR_OUTPUT.

Referenced by ioport_set_port_dir().

static __always_inline void arch_ioport_set_port_level ( ioport_port_t  port,
ioport_port_mask_t  mask,
enum ioport_value  level 
)
static

: Set port multiple pins level to high or low.

Parameters
portGPIO port to configure e.g. IOPORT_PORTB
mask Pin mask of pins to configure.
level high/low

References arch_ioport_port_to_base(), and PORT_struct::PORTDATA.

Referenced by ioport_set_group_high(), ioport_set_group_low(), and ioport_set_port_level().

static __always_inline void arch_ioport_set_port_mode ( ioport_port_t  port,
ioport_port_mask_t  mask,
ioport_mode_t  mode 
)
static

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

configuration.

Parameters
portGPIO port to configure e.g. IOPORT_PORTB
maskPin mask of pins to configure
modeMode masks to configure for the specified pins (IOPORT Modes)

References arch_ioport_port_to_base(), IOPORT_MODE_PULLDOWN, IOPORT_MODE_PULLUP, and PORT_struct::PORTDATA.

Referenced by ioport_reset_port_mode(), and ioport_set_port_mode().

static __always_inline void arch_ioport_set_port_sense_mode ( ioport_port_t  port,
ioport_port_mask_t  mask,
enum ioport_sense  pin_sense 
)
static

: To configure a multiple pins for trigger modes: sense the edge/ level/both trigger.

Parameters
pin. the pin number defined by IOPORT_CREATE_PIN
pin_sense,referto .

References cpu_irq_restore(), and cpu_irq_save().

Referenced by ioport_set_port_sense_mode().

static __always_inline void arch_ioport_toggle_pin_level ( ioport_pin_t  pin)
static

: To toggle the pin

Parameters
pin. the pin number defined by IOPORT_CREATE_PIN

References arch_ioport_pin_to_base(), arch_ioport_pin_to_mask(), and PORT_struct::PINCRL.

Referenced by ioport_toggle_pin(), and ioport_toggle_pin_level().

static __always_inline void arch_ioport_toggle_port_level ( ioport_port_t  port,
ioport_port_mask_t  mask 
)
static

: To toggle the multiple pins on a single port.

Parameters
portGPIO port to toggle e.g. IOPORT_PORTB
maskPin mask of pins to read data.

References arch_ioport_port_to_base(), and PORT_struct::PINCRL.

Referenced by ioport_tgl_group(), and ioport_toggle_port_level().

static __always_inline void ioport_configure_group ( port_id_t  port,
pin_mask_t  pin_mask,
port_pin_flags_t  flags 
)
inlinestatic

Configure a group of I/O pins on a specified port number.

Parameters
portThe port number
pin_maskThe pin mask to configure
flagsBitmask of flags specifying additional configuration parameters.

References arch_ioport_port_to_base(), and ioport_configure_port_pin().

static __always_inline void ioport_configure_pin ( port_pin_t  pin,
port_pin_flags_t  flags 
)
inlinestatic

Select the port function for a single pin.

Parameters
pin. the pin number defined by IOPORT_CREATE_PIN
flagsBitmask of flags specifying additional configuration parameters.

References arch_ioport_pin_to_base(), arch_ioport_pin_to_mask(), and ioport_configure_port_pin().

Referenced by board_init(), ext_int_init(), ext_int_pcint_init(), main(), and run_interrupt_trigger_test().

static __always_inline void ioport_configure_port_pin ( void *  port,
pin_mask_t  pin_mask,
port_pin_flags_t  flags 
)
inlinestatic

Configure the IO PORT pin function for a set of pins on a port.

Parameters
portPointer to the port
pin_maskMask containing the pins that should be configured
flagsBitmask of flags specifying additional configuration parameters.

References IOPORT_DIR_OUTPUT, IOPORT_INIT_HIGH, and IOPORT_PULL_UP.

Referenced by ioport_configure_group(), ioport_configure_pin(), run_loopback_syncmode_test(), and usart_init_spi().

static __always_inline bool ioport_get_value ( port_pin_t  pin)
inlinestatic

Read the current state of a PORT pin.

Parameters
pinA number identifying the pin to read.
Return values
trueThe pin is currently high (close to Vdd)
falseThe pin is currently low (close to Vss)

References arch_ioport_get_pin_level().

static __always_inline PORT_t* ioport_id_pin_to_port ( port_id_t  port)
inlinestatic

: To get the port address pointer from port number

Parameters
portGPIO port to toggle e.g. IOPORT_PORTB
Returns
pointer to base address of ports(8 bit)

References arch_ioport_port_to_base().

static __always_inline bool ioport_pin_is_high ( port_pin_t  pin)
inlinestatic

Read the current state of a PORT pin and test high level.

Parameters
pinA number identifying the pin to read.
Return values
trueThe pin is currently high (close to Vdd)
falseThe pin is currently low (close to Vss)

References arch_ioport_get_pin_level().

static __always_inline bool ioport_pin_is_low ( port_pin_t  pin)
inlinestatic

Read the current state of a PORT pin and test high level.

Parameters
pinA number identifying the pin to read.
Return values
trueThe pin is currently high (close to Vdd)
falseThe pin is currently low (close to Vss)

References arch_ioport_get_pin_level().

static __always_inline PORT_t* ioport_pin_to_port ( port_pin_t  pin)
inlinestatic

: To get the port address pointer from pin

Parameters
pin. the pin number defined by IOPORT_CREATE_PIN
Returns
pointer to base address of ports(8 bit)

References arch_ioport_pin_to_base().

Referenced by run_loopback_syncmode_test(), and usart_init_spi().

static __always_inline void ioport_set_group_high ( port_id_t  port_id,
pin_mask_t  port_mask 
)
inlinestatic

Drives a group of I/O pin of a port to high level.

Parameters
port_idThe port number.
port_maskThe mask.

References arch_ioport_set_port_level().

static __always_inline void ioport_set_group_low ( port_id_t  port_id,
pin_mask_t  port_mask 
)
inlinestatic

Drives a group of I/O pin of a port to low level.

Parameters
port_idThe port number.
port_maskThe mask.

References arch_ioport_set_port_level().

static __always_inline void ioport_set_pin_high ( port_pin_t  pin)
inlinestatic

Drive a PORT pin to a high level.

This function will only have an effect if pin is configured as an output.

Parameters
pinA number identifying the pin to act on.

References arch_ioport_set_pin_level().

Referenced by spi_deselect_device(), and usart_spi_deselect_device().

static __always_inline void ioport_set_pin_low ( port_pin_t  pin)
inlinestatic

Drive a PORT pin to a low level.

This function will only have an effect if pin is configured as an output.

Parameters
pin. the pin number defined by IOPORT_CREATE_PIN

References arch_ioport_set_pin_level().

Referenced by spi_select_device(), and usart_spi_select_device().

static __always_inline void ioport_set_value ( port_pin_t  pin,
bool  value 
)
inlinestatic

Drive a PORT pin to a given state.

This function will only have an effect if pin is configured as an output.

Parameters
pinA number identifying the pin to act on.
valueThe desired state of the pin. true means drive the pin high (towards Vdd), while false means drive the pin low (towards Vss).

References arch_ioport_set_pin_level().

Referenced by example_cmp1_int_cb(), and example_cmp3_int_cb().

static __always_inline void ioport_tgl_group ( port_id_t  port_id,
pin_mask_t  port_mask 
)
inlinestatic

Toggles a group of I/O pin of a port.

Parameters
port_idThe port number.
port_maskThe mask.

References arch_ioport_toggle_port_level().

static __always_inline void ioport_toggle_pin ( port_pin_t  pin)
inlinestatic

Toggle the current state of a PORT pin.

Parameters
pinA number identifying the pin to act on.

References arch_ioport_toggle_pin_level().

Referenced by example_backoff_slot_cntr_int_cb(), example_cmp1_int_cb(), example_cmp2_int_cb(), example_cmp3_int_cb(), and example_ovf_int_cb().

volatile uint8_t PORT_struct::DIR