GPIO

group npmx_gpio

GPIO peripheral driver.

Enums

enum npmx_gpio_mode_t

Configuration for GPIO mode selection.

Values:

enumerator NPMX_GPIO_MODE_INPUT

GPI Input.

enumerator NPMX_GPIO_MODE_INPUT_OVERRIDE_1

GPI Logic1.

enumerator NPMX_GPIO_MODE_INPUT_OVERRIDE_0

GPI Logic0.

enumerator NPMX_GPIO_MODE_INPUT_RISING_EDGE

GPI Rising Edge Event.

enumerator NPMX_GPIO_MODE_INPUT_FALLING_EDGE

GPI Falling Edge Event.

enumerator NPMX_GPIO_MODE_OUTPUT_IRQ

GPO Interrupt.

enumerator NPMX_GPIO_MODE_OUTPUT_RESET

GPO Reset.

enumerator NPMX_GPIO_MODE_OUTPUT_PLW

GPO PwrLossWarn.

enumerator NPMX_GPIO_MODE_OUTPUT_OVERRIDE_1

GPO Logic1.

enumerator NPMX_GPIO_MODE_OUTPUT_OVERRIDE_0

GPO Logic0.

enumerator NPMX_GPIO_MODE_COUNT

GPIO modes count.

enumerator NPMX_GPIO_MODE_INVALID

Invalid GPIO mode.

enum npmx_gpio_drive_t

Configuration for GPIO drive current.

Values:

enumerator NPMX_GPIO_DRIVE_1_MA

1 mA.

enumerator NPMX_GPIO_DRIVE_6_MA

6 mA.

enumerator NPMX_GPIO_DRIVE_COUNT

GPIO drive currents count.

enumerator NPMX_GPIO_DRIVE_MIN

Minimum current.

enumerator NPMX_GPIO_DRIVE_DEFAULT

Default current.

enumerator NPMX_GPIO_DRIVE_MAX

Maximum current.

enumerator NPMX_GPIO_DRIVE_INVALID

Invalid current.

enum npmx_gpio_pull_t

Configuration for GPIO pull resistors. By default, all GPIOs are in NPMX_GPIO_PULL_DOWN mode.

Values:

enumerator NPMX_GPIO_PULL_DOWN

GPIO pull-down enable.

enumerator NPMX_GPIO_PULL_UP

GPIO pull-up enable.

enumerator NPMX_GPIO_PULL_NONE

GPIO pull-down and pull-up disable.

enumerator NPMX_GPIO_PULL_COUNT

GPIO pull configs count.

enumerator NPMX_GPIO_PULL_INVALID

Invalid GPIO pull configuration.

Functions

npmx_gpio_t *npmx_gpio_get(npmx_instance_t *p_pmic, uint8_t idx)

Function for returning GPIO instance based on index.

Parameters:
  • p_pmic[in] Pointer to the PMIC instance.

  • idx[in] Index of the GPIO instance.

Returns:

Pointer to the GPIO instance.

npmx_gpio_drive_t npmx_gpio_drive_convert(uint32_t milliamperes)

Function for converting milliamperes to npmx_gpio_drive_t enumeration.

Parameters:
  • milliamperes[in] Current in milliamperes to be converted into npmx_gpio_drive_t enumeration.

Returns:

Result of conversion. NPMX_GPIO_DRIVE_INVALID if given current is not represented in enumeration.

bool npmx_gpio_drive_convert_to_ma(npmx_gpio_drive_t enum_value, uint32_t *p_val)

Function for converting npmx_gpio_drive_t enumeration to milliamperes.

Parameters:
  • enum_value[in] Current defined as npmx_gpio_drive_t enumeration to be converted into milliamperes.

  • p_val[out] Pointer to the variable that stores the conversion result.

Return values:
  • true – Conversion is valid.

  • false – Conversion is invalid - an invalid argument was passed to the function.

npmx_error_t npmx_gpio_config_set(npmx_gpio_t const *p_instance, npmx_gpio_config_t const *p_config)

Function for configuring GPIO.

Parameters:
  • p_instance[in] Pointer to the GPIO instance.

  • p_config[in] Pointer to the configuration of GPIO to be applied.

Return values:
  • NPMX_SUCCESS – Operation performed successfully.

  • NPMX_ERROR_IO – Error using IO bus line.

npmx_error_t npmx_gpio_config_get(npmx_gpio_t const *p_instance, npmx_gpio_config_t *p_config)

Function for reading GPIO configuration.

Parameters:
  • p_instance[in] Pointer to the GPIO instance.

  • p_config[out] Pointer to the configuration of GPIO.

Return values:
  • NPMX_SUCCESS – Operation performed successfully.

  • NPMX_ERROR_IO – Error using IO bus line.

npmx_error_t npmx_gpio_mode_set(npmx_gpio_t const *p_instance, npmx_gpio_mode_t mode)

Function for setting GPIO mode.

Parameters:
  • p_instance[in] Pointer to the GPIO instance.

  • mode[in] Mode of GPIO to set.

Return values:
  • NPMX_SUCCESS – Operation performed successfully.

  • NPMX_ERROR_IO – Error using IO bus line.

npmx_error_t npmx_gpio_mode_get(npmx_gpio_t const *p_instance, npmx_gpio_mode_t *p_mode)

Function for reading GPIO mode.

Parameters:
  • p_instance[in] Pointer to the GPIO instance.

  • p_mode[out] Pointer to mode of GPIO.

Return values:
  • NPMX_SUCCESS – Operation performed successfully.

  • NPMX_ERROR_IO – Error using IO bus line.

npmx_error_t npmx_gpio_status_check(npmx_gpio_t const *p_instance, bool *p_status)

Function for checking GPIO status of specified GPIO pin.

Parameters:
  • p_instance[in] Pointer to the GPIO instance.

  • p_status[out] Pointer to the status of GPIO. True if specified GPIO is in a high state, false otherwise.

Return values:
  • NPMX_SUCCESS – Operation performed successfully.

  • NPMX_ERROR_IO – Error using IO bus line.

struct npmx_gpio_t
#include <npmx_gpio.h>

Data structure of the GPIO driver instance.

Public Members

npmx_backend_t *p_backend

Pointer to backend instance.

uint8_t hw_index

Hardware index of GPIO instance.

struct npmx_gpio_config_t
#include <npmx_gpio.h>

Configuration structure for GPIO.

Public Members

npmx_gpio_mode_t mode

Configuration for GPIO mode selection.

npmx_gpio_drive_t drive

GPIO drive current.

npmx_gpio_pull_t pull

GPIO pull mode.

bool open_drain

Enable GPIO open drain.

bool debounce

Enable GPIO debounce.