The Parallel Input/Output Controller (PIO) manages up to 32 fully programmable input/output lines. Each I/O line may be dedicated as a general-purpose I/O or be assigned to a function of an embedded peripheral. This assures effective optimization of the pins of a product.
Macros | |
#define | FREQ_SLOW_CLOCK_EXT 32768 |
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 ul_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 ul_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 ul_pin) |
Return GPIO port for a GPIO pin. More... | |
uint32_t | pio_get_pin_group_id (uint32_t ul_pin) |
Return GPIO port peripheral ID for a GPIO pin. More... | |
uint32_t | pio_get_pin_group_mask (uint32_t ul_pin) |
Return GPIO port pin mask for a GPIO pin. More... | |
uint32_t | pio_get_pin_value (uint32_t ul_pin) |
Return the value of a pin. More... | |
uint32_t | pio_get_schmitt_trigger (const Pio *p_pio) |
Get PIO pin schmitt trigger status. More... | |
uint32_t | pio_get_writeprotect_status (const Pio *p_pio) |
Read write protect status. More... | |
void | pio_pull_down (Pio *p_pio, const uint32_t ul_mask, const uint32_t ul_pull_down_enable) |
Configure PIO pin internal pull-down. 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 ul_pin) |
Drive a GPIO pin to 1. More... | |
void | pio_set_pin_low (uint32_t ul_pin) |
Drive a GPIO pin to 0. More... | |
void | pio_set_schmitt_trigger (Pio *p_pio, const uint32_t ul_mask) |
Configure PIO pin schmitt trigger. 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 ul_pin) |
Toggle a GPIO pin. More... | |
void | pio_toggle_pin_group (Pio *p_pio, uint32_t ul_mask) |
Toggle a GPIO group. More... | |
#define FREQ_SLOW_CLOCK_EXT 32768 |
Referenced by pio_set_debounce_filter().
void pio_clear | ( | Pio * | p_pio, |
const uint32_t | ul_mask | ||
) |
Set a low output level on all the PIOs defined in ul_mask.
This has no immediate effects on PIOs that are not output, but the PIO controller will save the value if they are changed to outputs.
p_pio | Pointer to a PIO instance. |
ul_mask | Bitmask of one or more pin(s) to configure. |
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.
p_pio | Pointer to a PIO instance. |
ul_type | PIO type. |
ul_mask | Bitmask of one or more pin(s) to configure. |
ul_attribute | Pins attributes. |
References PIO_INPUT, PIO_OPENDRAIN, PIO_OUTPUT_0, PIO_OUTPUT_1, PIO_PERIPH_A, PIO_PERIPH_B, pio_pull_up(), PIO_PULLUP, pio_set_input(), pio_set_output(), and pio_set_peripheral().
void pio_configure_interrupt | ( | Pio * | p_pio, |
const uint32_t | ul_mask, | ||
const uint32_t | ul_attr | ||
) |
Configure the given interrupt source.
Interrupt can be configured to trigger on rising edge, falling edge, high level, low level or simply on level change.
p_pio | Pointer to a PIO instance. |
ul_mask | Interrupt source bit map. |
ul_attr | Interrupt source attributes. |
References PIO_IT_AIME, PIO_IT_EDGE, and PIO_IT_RE_OR_HL.
Referenced by pio_handler_set().
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.
ul_pin | The pin index. |
ul_flags | Pins attributes. |
References p_pio, pio_get_pin_group(), PIO_OPENDRAIN, PIO_PERIPH_A, PIO_PERIPH_B, pio_pull_up(), PIO_PULLUP, pio_set_input(), pio_set_output(), pio_set_peripheral(), PIO_TYPE_Msk, PIO_TYPE_PIO_INPUT, PIO_TYPE_PIO_OUTPUT_0, PIO_TYPE_PIO_OUTPUT_1, PIO_TYPE_PIO_PERIPH_A, PIO_TYPE_PIO_PERIPH_B, PIO_TYPE_PIO_PERIPH_C, and PIO_TYPE_PIO_PERIPH_D.
Referenced by init_chip_pins(), and nm_bsp_register_isr().
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.
p_pio | Pointer to a PIO instance. |
ul_mask | Bitmask of one or more pin(s) to configure. |
ul_flags | Pin(s) attributes. |
References PIO_OPENDRAIN, PIO_PERIPH_A, PIO_PERIPH_B, pio_pull_up(), PIO_PULLUP, pio_set_input(), pio_set_output(), pio_set_peripheral(), PIO_TYPE_Msk, PIO_TYPE_PIO_INPUT, PIO_TYPE_PIO_OUTPUT_0, PIO_TYPE_PIO_OUTPUT_1, PIO_TYPE_PIO_PERIPH_A, PIO_TYPE_PIO_PERIPH_B, PIO_TYPE_PIO_PERIPH_C, and PIO_TYPE_PIO_PERIPH_D.
void pio_disable_interrupt | ( | Pio * | p_pio, |
const uint32_t | ul_mask | ||
) |
Disable a given interrupt source, with no added side effects.
p_pio | Pointer to a PIO instance. |
ul_mask | Interrupt sources bit map. |
Referenced by nm_bsp_interrupt_ctrl(), pio_handler_set_priority(), pio_set_input(), and pio_set_output().
void pio_disable_output_write | ( | Pio * | p_pio, |
const uint32_t | ul_mask | ||
) |
Disable PIO output write.
p_pio | Pointer to a PIO instance. |
ul_mask | Bitmask of one or more pin(s) to configure. |
void pio_disable_pin_interrupt | ( | uint32_t | ul_pin | ) |
Disable interrupt for a GPIO pin.
ul_pin | The pin index. |
References p_pio, and pio_get_pin_group().
void pio_enable_interrupt | ( | Pio * | p_pio, |
const uint32_t | ul_mask | ||
) |
Enable the given interrupt source.
The PIO must be configured as an NVIC interrupt source as well.
p_pio | Pointer to a PIO instance. |
ul_mask | Interrupt sources bit map. |
Referenced by nm_bsp_interrupt_ctrl(), nm_bsp_register_isr(), and pio_handler_set_priority().
void pio_enable_output_write | ( | Pio * | p_pio, |
const uint32_t | ul_mask | ||
) |
Enable PIO output write for synchronous data output.
p_pio | Pointer to a PIO instance. |
ul_mask | Bitmask of one or more pin(s) to configure. |
void pio_enable_pin_interrupt | ( | uint32_t | ul_pin | ) |
Enable interrupt for a GPIO pin.
ul_pin | The pin index. |
References p_pio, and pio_get_pin_group().
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.
This method returns the actual value that is being read on the pin. To return the supposed output value of a pin, use pio_get_output_data_status() instead.
p_pio | Pointer to a PIO instance. |
ul_type | PIO type. |
ul_mask | Bitmask of one or more pin(s) to configure. |
1 | at least one PIO currently has a high level. |
0 | all PIOs have a low level. |
References PIO_OUTPUT_0, and PIO_OUTPUT_1.
uint32_t pio_get_interrupt_mask | ( | const Pio * | p_pio | ) |
Read PIO interrupt mask.
p_pio | Pointer to a PIO instance. |
Referenced by pio_handler_process(), and pio_handler_set_priority().
uint32_t pio_get_interrupt_status | ( | const Pio * | p_pio | ) |
Read and clear PIO interrupt status.
p_pio | Pointer to a PIO instance. |
Referenced by nm_bsp_interrupt_ctrl(), nm_bsp_register_isr(), pio_handler_process(), and pio_handler_set_priority().
uint32_t pio_get_multi_driver_status | ( | const Pio * | p_pio | ) |
Get multi-driver status.
p_pio | Pointer to a PIO instance. |
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).
To get the actual value of the pin, use PIO_Get() instead.
p_pio | Pointer to a PIO instance. |
ul_mask | Bitmask of one or more pin(s). |
1 | At least one PIO is configured to output a high level. |
0 | All PIOs are configured to output a low level. |
uint32_t pio_get_output_write_status | ( | const Pio * | p_pio | ) |
Read PIO output write status.
p_pio | Pointer to a PIO instance. |
Pio* pio_get_pin_group | ( | uint32_t | ul_pin | ) |
Return GPIO port for a GPIO pin.
ul_pin | The pin index. |
References p_pio, and PIO_DELTA.
Referenced by pio_configure_pin(), pio_disable_pin_interrupt(), pio_enable_pin_interrupt(), pio_get_pin_value(), pio_set_pin_high(), pio_set_pin_low(), and pio_toggle_pin().
uint32_t pio_get_pin_group_id | ( | uint32_t | ul_pin | ) |
Return GPIO port peripheral ID for a GPIO pin.
ul_pin | The pin index. |
uint32_t pio_get_pin_group_mask | ( | uint32_t | ul_pin | ) |
Return GPIO port pin mask for a GPIO pin.
ul_pin | The pin index. |
uint32_t pio_get_pin_value | ( | uint32_t | ul_pin | ) |
Return the value of a pin.
ul_pin | The pin number. |
References p_pio, and pio_get_pin_group().
uint32_t pio_get_schmitt_trigger | ( | const Pio * | p_pio | ) |
Get PIO pin schmitt trigger status.
p_pio | Pointer to a PIO instance. |
uint32_t pio_get_writeprotect_status | ( | const Pio * | p_pio | ) |
Read write protect status.
p_pio | Pointer to a PIO instance. |
void pio_pull_down | ( | Pio * | p_pio, |
const uint32_t | ul_mask, | ||
const uint32_t | ul_pull_down_enable | ||
) |
Configure PIO pin internal pull-down.
p_pio | Pointer to a PIO instance. |
ul_mask | Bitmask of one or more pin(s) to configure. |
ul_pull_down_enable | Indicates if the pin(s) internal pull-down shall be configured. |
void pio_pull_up | ( | Pio * | p_pio, |
const uint32_t | ul_mask, | ||
const uint32_t | ul_pull_up_enable | ||
) |
Configure PIO internal pull-up.
p_pio | Pointer to a PIO instance. |
ul_mask | Bitmask of one or more pin(s) to configure. |
ul_pull_up_enable | Indicates if the pin(s) internal pull-up shall be configured. |
Referenced by nm_bsp_register_isr(), pio_configure(), pio_configure_pin(), pio_configure_pin_group(), pio_set_input(), and pio_set_output().
void pio_set | ( | Pio * | p_pio, |
const uint32_t | ul_mask | ||
) |
Set a high output level on all the PIOs defined in ul_mask.
This has no immediate effects on PIOs that are not output, but the PIO controller will save the value if they are changed to outputs.
p_pio | Pointer to a PIO instance. |
ul_mask | Bitmask of one or more pin(s) to configure. |
void pio_set_additional_interrupt_mode | ( | Pio * | p_pio, |
const uint32_t | ul_mask, | ||
const uint32_t | ul_attribute | ||
) |
Set additional interrupt mode.
p_pio | Pointer to a PIO instance. |
ul_mask | Interrupt sources bit map. |
ul_attribute | Pin(s) attributes. |
References PIO_IT_AIME, PIO_IT_EDGE, and PIO_IT_RE_OR_HL.
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).
p_pio | Pointer to a PIO instance. |
ul_mask | Bitmask of one or more pin(s) to configure. |
ul_cut_off | Cuts off frequency for debouncing filter. |
References FREQ_SLOW_CLOCK_EXT.
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.
Optionally, the corresponding internal pull-up(s) and glitch filter(s) can be enabled.
p_pio | Pointer to a PIO instance. |
ul_mask | Bitmask indicating which pin(s) to configure as input(s). |
ul_attribute | PIO attribute(s). |
References PIO_DEBOUNCE, PIO_DEGLITCH, pio_disable_interrupt(), pio_pull_up(), and PIO_PULLUP.
Referenced by pio_configure(), pio_configure_pin(), and pio_configure_pin_group().
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.
p_pio | Pointer to a PIO instance. |
ul_mask | Bitmask of one or more pin(s) to configure. |
ul_multi_driver_enable | Indicates if the pin(s) multi-driver shall be configured. |
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.
Optionally, the multi-drive feature can be enabled on the pin(s).
p_pio | Pointer to a PIO instance. |
ul_mask | Bitmask indicating which pin(s) to configure. |
ul_default_level | Default level on the pin(s). |
ul_multidrive_enable | Indicates if the pin(s) shall be configured as open-drain. |
ul_pull_up_enable | Indicates if the pin shall have its pull-up activated. |
References pio_disable_interrupt(), and pio_pull_up().
Referenced by pio_configure(), pio_configure_pin(), and pio_configure_pin_group().
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.
p_pio | Pointer to a PIO instance. |
ul_type | PIO type. |
ul_mask | Bitmask of one or more pin(s) to configure. |
References PIO_INPUT, PIO_NOT_A_PIN, PIO_OUTPUT_0, PIO_OUTPUT_1, PIO_PERIPH_A, and PIO_PERIPH_B.
Referenced by pio_configure(), pio_configure_pin(), and pio_configure_pin_group().
void pio_set_pin_group_high | ( | Pio * | p_pio, |
uint32_t | ul_mask | ||
) |
Drive a GPIO port to 1.
p_pio | Base address of the PIO port. |
ul_mask | Bitmask of one or more pin(s) to toggle. |
void pio_set_pin_group_low | ( | Pio * | p_pio, |
uint32_t | ul_mask | ||
) |
Drive a GPIO port to 0.
p_pio | Base address of the PIO port. |
ul_mask | Bitmask of one or more pin(s) to toggle. |
void pio_set_pin_high | ( | uint32_t | ul_pin | ) |
Drive a GPIO pin to 1.
ul_pin | The pin index. |
References p_pio, and pio_get_pin_group().
Referenced by init_chip_pins(), and nm_bsp_reset().
void pio_set_pin_low | ( | uint32_t | ul_pin | ) |
Drive a GPIO pin to 0.
ul_pin | The pin index. |
References p_pio, and pio_get_pin_group().
Referenced by nm_bsp_deinit(), and nm_bsp_reset().
void pio_set_schmitt_trigger | ( | Pio * | p_pio, |
const uint32_t | ul_mask | ||
) |
Configure PIO pin schmitt trigger.
By default the Schmitt trigger is active. Disabling the Schmitt Trigger is requested when using the QTouch Library.
p_pio | Pointer to a PIO instance. |
ul_mask | Bitmask of one or more pin(s) to configure. |
void pio_set_writeprotect | ( | Pio * | p_pio, |
const uint32_t | ul_enable | ||
) |
Enable or disable write protect of PIO registers.
p_pio | Pointer to a PIO instance. |
ul_enable | 1 to enable, 0 to disable. |
References PIO_WPMR_WPKEY_PASSWD.
void pio_sync_output_write | ( | Pio * | p_pio, |
const uint32_t | ul_mask | ||
) |
Synchronously write on output pins.
p_pio | Pointer to a PIO instance. |
ul_mask | Bitmask of one or more pin(s) to configure. |
void pio_toggle_pin | ( | uint32_t | ul_pin | ) |
Toggle a GPIO pin.
ul_pin | The pin index. |
References p_pio, and pio_get_pin_group().
void pio_toggle_pin_group | ( | Pio * | p_pio, |
uint32_t | ul_mask | ||
) |
Toggle a GPIO group.
p_pio | Pointer to a PIO instance. |
ul_mask | Bitmask of one or more pin(s) to configure. |