nrfx 2.5
Macros | Enumerations | Functions
GPIO HAL

Hardware access layer for managing the GPIO peripheral. More...

Macros

#define NRF_GPIO_LATCH_PRESENT
 Symbol indicating whether the functionality of latching GPIO state change is present.
 
#define NRF_GPIO_PIN_MAP(port, pin)   (((port) << 5) | ((pin) & 0x1F))
 Macro for mapping port and pin numbers to values understandable for nrf_gpio functions.
 

Enumerations

enum  nrf_gpio_pin_dir_t {
  NRF_GPIO_PIN_DIR_INPUT = GPIO_PIN_CNF_DIR_Input,
  NRF_GPIO_PIN_DIR_OUTPUT = GPIO_PIN_CNF_DIR_Output
}
 Pin direction definitions. More...
 
enum  nrf_gpio_pin_input_t {
  NRF_GPIO_PIN_INPUT_CONNECT = GPIO_PIN_CNF_INPUT_Connect,
  NRF_GPIO_PIN_INPUT_DISCONNECT = GPIO_PIN_CNF_INPUT_Disconnect
}
 Connection of input buffer. More...
 
enum  nrf_gpio_pin_pull_t {
  NRF_GPIO_PIN_NOPULL = GPIO_PIN_CNF_PULL_Disabled,
  NRF_GPIO_PIN_PULLDOWN = GPIO_PIN_CNF_PULL_Pulldown,
  NRF_GPIO_PIN_PULLUP = GPIO_PIN_CNF_PULL_Pullup
}
 Enumerator used for selecting the pin to be pulled down or up at the time of pin configuration. More...
 
enum  nrf_gpio_pin_drive_t {
  NRF_GPIO_PIN_S0S1 = GPIO_PIN_CNF_DRIVE_S0S1,
  NRF_GPIO_PIN_H0S1 = GPIO_PIN_CNF_DRIVE_H0S1,
  NRF_GPIO_PIN_S0H1 = GPIO_PIN_CNF_DRIVE_S0H1,
  NRF_GPIO_PIN_H0H1 = GPIO_PIN_CNF_DRIVE_H0H1,
  NRF_GPIO_PIN_D0S1 = GPIO_PIN_CNF_DRIVE_D0S1,
  NRF_GPIO_PIN_D0H1 = GPIO_PIN_CNF_DRIVE_D0H1,
  NRF_GPIO_PIN_S0D1 = GPIO_PIN_CNF_DRIVE_S0D1,
  NRF_GPIO_PIN_H0D1 = GPIO_PIN_CNF_DRIVE_H0D1,
  NRF_GPIO_PIN_E0S1 = GPIO_PIN_CNF_DRIVE_E0S1,
  NRF_GPIO_PIN_S0E1 = GPIO_PIN_CNF_DRIVE_S0E1,
  NRF_GPIO_PIN_E0E1 = GPIO_PIN_CNF_DRIVE_E0E1,
  NRF_GPIO_PIN_E0H1 = GPIO_PIN_CNF_DRIVE_E0H1,
  NRF_GPIO_PIN_H0E1 = GPIO_PIN_CNF_DRIVE_H0E1,
  NRF_GPIO_PIN_D0E1 = GPIO_PIN_CNF_DRIVE_D0E1,
  NRF_GPIO_PIN_E0D1 = GPIO_PIN_CNF_DRIVE_E0D1
}
 Enumerator used for selecting output drive mode. More...
 
enum  nrf_gpio_pin_sense_t {
  NRF_GPIO_PIN_NOSENSE = GPIO_PIN_CNF_SENSE_Disabled,
  NRF_GPIO_PIN_SENSE_LOW = GPIO_PIN_CNF_SENSE_Low,
  NRF_GPIO_PIN_SENSE_HIGH = GPIO_PIN_CNF_SENSE_High
}
 Enumerator used for selecting the pin to sense high or low level on the pin input. More...
 
enum  nrf_gpio_pin_mcusel_t {
  NRF_GPIO_PIN_MCUSEL_APP = GPIO_PIN_CNF_MCUSEL_AppMCU,
  NRF_GPIO_PIN_MCUSEL_NETWORK = GPIO_PIN_CNF_MCUSEL_NetworkMCU,
  NRF_GPIO_PIN_MCUSEL_PERIPHERAL = GPIO_PIN_CNF_MCUSEL_Peripheral,
  NRF_GPIO_PIN_MCUSEL_TND = GPIO_PIN_CNF_MCUSEL_TND
}
 Enumerator used for selecting the MCU/Subsystem to control the specified pin. More...
 

Functions

NRF_STATIC_INLINE void nrf_gpio_range_cfg_output (uint32_t pin_range_start, uint32_t pin_range_end)
 Function for configuring the GPIO pin range as output pins with normal drive strength. This function can be used to configure pin range as simple output with gate driving GPIO_PIN_CNF_DRIVE_S0S1 (normal cases). More...
 
NRF_STATIC_INLINE void nrf_gpio_range_cfg_input (uint32_t pin_range_start, uint32_t pin_range_end, nrf_gpio_pin_pull_t pull_config)
 Function for configuring the GPIO pin range as input pins with given initial value set, hiding inner details. This function can be used to configure pin range as simple input. More...
 
NRF_STATIC_INLINE void nrf_gpio_cfg (uint32_t pin_number, nrf_gpio_pin_dir_t dir, nrf_gpio_pin_input_t input, nrf_gpio_pin_pull_t pull, nrf_gpio_pin_drive_t drive, nrf_gpio_pin_sense_t sense)
 Pin configuration function. More...
 
NRF_STATIC_INLINE void nrf_gpio_cfg_output (uint32_t pin_number)
 Function for configuring the given GPIO pin number as output, hiding inner details. This function can be used to configure a pin as simple output with gate driving GPIO_PIN_CNF_DRIVE_S0S1 (normal cases). More...
 
NRF_STATIC_INLINE void nrf_gpio_cfg_input (uint32_t pin_number, nrf_gpio_pin_pull_t pull_config)
 Function for configuring the given GPIO pin number as input, hiding inner details. This function can be used to configure a pin as simple input. More...
 
NRF_STATIC_INLINE void nrf_gpio_cfg_default (uint32_t pin_number)
 Function for resetting pin configuration to its default state. More...
 
NRF_STATIC_INLINE void nrf_gpio_cfg_watcher (uint32_t pin_number)
 Function for configuring the given GPIO pin number as a watcher. Only input is connected. More...
 
NRF_STATIC_INLINE void nrf_gpio_input_disconnect (uint32_t pin_number)
 Function for disconnecting input for the given GPIO. More...
 
NRF_STATIC_INLINE void nrf_gpio_cfg_sense_input (uint32_t pin_number, nrf_gpio_pin_pull_t pull_config, nrf_gpio_pin_sense_t sense_config)
 Function for configuring the given GPIO pin number as input, hiding inner details. This function can be used to configure pin range as simple input. Sense capability on the pin is configurable and input is connected to buffer so that the GPIO->IN register is readable. More...
 
NRF_STATIC_INLINE void nrf_gpio_cfg_sense_set (uint32_t pin_number, nrf_gpio_pin_sense_t sense_config)
 Function for configuring sense level for the given GPIO. More...
 
NRF_STATIC_INLINE void nrf_gpio_pin_dir_set (uint32_t pin_number, nrf_gpio_pin_dir_t direction)
 Function for setting the direction for a GPIO pin. More...
 
NRF_STATIC_INLINE void nrf_gpio_pin_set (uint32_t pin_number)
 Function for setting a GPIO pin. More...
 
NRF_STATIC_INLINE void nrf_gpio_pin_clear (uint32_t pin_number)
 Function for clearing a GPIO pin. More...
 
NRF_STATIC_INLINE void nrf_gpio_pin_toggle (uint32_t pin_number)
 Function for toggling a GPIO pin. More...
 
NRF_STATIC_INLINE void nrf_gpio_pin_write (uint32_t pin_number, uint32_t value)
 Function for writing a value to a GPIO pin. More...
 
NRF_STATIC_INLINE uint32_t nrf_gpio_pin_read (uint32_t pin_number)
 Function for reading the input level of a GPIO pin. More...
 
NRF_STATIC_INLINE uint32_t nrf_gpio_pin_out_read (uint32_t pin_number)
 Function for reading the output level of a GPIO pin. More...
 
NRF_STATIC_INLINE nrf_gpio_pin_sense_t nrf_gpio_pin_sense_get (uint32_t pin_number)
 Function for reading the sense configuration of a GPIO pin. More...
 
NRF_STATIC_INLINE nrf_gpio_pin_dir_t nrf_gpio_pin_dir_get (uint32_t pin_number)
 Function for reading the direction configuration of a GPIO pin. More...
 
NRF_STATIC_INLINE nrf_gpio_pin_input_t nrf_gpio_pin_input_get (uint32_t pin_number)
 Function for reading the status of GPIO pin input buffer. More...
 
NRF_STATIC_INLINE nrf_gpio_pin_pull_t nrf_gpio_pin_pull_get (uint32_t pin_number)
 Function for reading the pull configuration of a GPIO pin. More...
 
NRF_STATIC_INLINE void nrf_gpio_port_dir_output_set (NRF_GPIO_Type *p_reg, uint32_t out_mask)
 Function for setting output direction on the selected pins on the given port. More...
 
NRF_STATIC_INLINE void nrf_gpio_port_dir_input_set (NRF_GPIO_Type *p_reg, uint32_t in_mask)
 Function for setting input direction on selected pins on a given port. More...
 
NRF_STATIC_INLINE void nrf_gpio_port_dir_write (NRF_GPIO_Type *p_reg, uint32_t dir_mask)
 Function for writing the direction configuration of the GPIO pins in the given port. More...
 
NRF_STATIC_INLINE uint32_t nrf_gpio_port_dir_read (NRF_GPIO_Type const *p_reg)
 Function for reading the direction configuration of a GPIO port. More...
 
NRF_STATIC_INLINE uint32_t nrf_gpio_port_in_read (NRF_GPIO_Type const *p_reg)
 Function for reading the input signals of the GPIO pins on the given port. More...
 
NRF_STATIC_INLINE uint32_t nrf_gpio_port_out_read (NRF_GPIO_Type const *p_reg)
 Function for reading the output signals of the GPIO pins on the given port. More...
 
NRF_STATIC_INLINE void nrf_gpio_port_out_write (NRF_GPIO_Type *p_reg, uint32_t value)
 Function for writing the GPIO pins output on a given port. More...
 
NRF_STATIC_INLINE void nrf_gpio_port_out_set (NRF_GPIO_Type *p_reg, uint32_t set_mask)
 Function for setting high level on selected the GPIO pins on the given port. More...
 
NRF_STATIC_INLINE void nrf_gpio_port_out_clear (NRF_GPIO_Type *p_reg, uint32_t clr_mask)
 Function for setting low level on selected the GPIO pins on the given port. More...
 
NRF_STATIC_INLINE void nrf_gpio_ports_read (uint32_t start_port, uint32_t length, uint32_t *p_masks)
 Function for reading pin state of multiple consecutive ports. More...
 
NRF_STATIC_INLINE void nrf_gpio_latches_read (uint32_t start_port, uint32_t length, uint32_t *p_masks)
 Function for reading latch state of multiple consecutive ports. More...
 
NRF_STATIC_INLINE void nrf_gpio_latches_read_and_clear (uint32_t start_port, uint32_t length, uint32_t *p_masks)
 Function for reading and immediate clearing latch state of multiple consecutive ports. More...
 
NRF_STATIC_INLINE uint32_t nrf_gpio_pin_latch_get (uint32_t pin_number)
 Function for reading latch state of single pin. More...
 
NRF_STATIC_INLINE void nrf_gpio_pin_latch_clear (uint32_t pin_number)
 Function for clearing latch state of a single pin. More...
 
NRF_STATIC_INLINE void nrf_gpio_pin_mcu_select (uint32_t pin_number, nrf_gpio_pin_mcusel_t mcu)
 Function for selecting the MCU to control a GPIO pin. More...
 
NRF_STATIC_INLINE bool nrf_gpio_pin_present_check (uint32_t pin_number)
 Function for checking if provided pin is present on the MCU. More...
 
NRF_STATIC_INLINE uint32_t nrf_gpio_pin_port_number_extract (uint32_t *p_pin)
 Function for extracting port number and the relative pin number from the absolute pin number. More...
 
NRF_STATIC_INLINE NRF_GPIO_Type * nrf_gpio_pin_port_decode (uint32_t *p_pin)
 Function for extracting port and the relative pin number from the absolute pin number. More...
 

Detailed Description

Hardware access layer for managing the GPIO peripheral.

Enumeration Type Documentation

◆ nrf_gpio_pin_dir_t

Pin direction definitions.

Enumerator
NRF_GPIO_PIN_DIR_INPUT 

Input.

NRF_GPIO_PIN_DIR_OUTPUT 

Output.

◆ nrf_gpio_pin_drive_t

Enumerator used for selecting output drive mode.

Enumerator
NRF_GPIO_PIN_S0S1 

Standard '0', standard '1'.

NRF_GPIO_PIN_H0S1 

High drive '0', standard '1'.

NRF_GPIO_PIN_S0H1 

Standard '0', high drive '1'.

NRF_GPIO_PIN_H0H1 

High drive '0', high drive '1'.

NRF_GPIO_PIN_D0S1 

Disconnect '0' standard '1'.

NRF_GPIO_PIN_D0H1 

Disconnect '0', high drive '1'.

NRF_GPIO_PIN_S0D1 

Standard '0', disconnect '1'.

NRF_GPIO_PIN_H0D1 

High drive '0', disconnect '1'.

NRF_GPIO_PIN_E0S1 

Extra high drive '0', standard '1'.

NRF_GPIO_PIN_S0E1 

Standard '0', extra high drive '1'.

NRF_GPIO_PIN_E0E1 

Extra high drive '0', extra high drive '1'.

NRF_GPIO_PIN_E0H1 

Extra high drive '0', high drive '1'.

NRF_GPIO_PIN_H0E1 

High drive '0', extra high drive '1'.

NRF_GPIO_PIN_D0E1 

Disconnect '0', extra high drive '1'.

NRF_GPIO_PIN_E0D1 

Extra high drive '0', disconnect '1'.

◆ nrf_gpio_pin_input_t

Connection of input buffer.

Enumerator
NRF_GPIO_PIN_INPUT_CONNECT 

Connect input buffer.

NRF_GPIO_PIN_INPUT_DISCONNECT 

Disconnect input buffer.

◆ nrf_gpio_pin_mcusel_t

Enumerator used for selecting the MCU/Subsystem to control the specified pin.

Enumerator
NRF_GPIO_PIN_MCUSEL_APP 

Pin controlled by Application MCU.

NRF_GPIO_PIN_MCUSEL_NETWORK 

Pin controlled by Network MCU.

NRF_GPIO_PIN_MCUSEL_PERIPHERAL 

Pin controlled by dedicated peripheral.

NRF_GPIO_PIN_MCUSEL_TND 

Pin controlled by Trace and Debug Subsystem.

◆ nrf_gpio_pin_pull_t

Enumerator used for selecting the pin to be pulled down or up at the time of pin configuration.

Enumerator
NRF_GPIO_PIN_NOPULL 

Pin pull-up resistor disabled.

NRF_GPIO_PIN_PULLDOWN 

Pin pull-down resistor enabled.

NRF_GPIO_PIN_PULLUP 

Pin pull-up resistor enabled.

◆ nrf_gpio_pin_sense_t

Enumerator used for selecting the pin to sense high or low level on the pin input.

Enumerator
NRF_GPIO_PIN_NOSENSE 

Pin sense level disabled.

NRF_GPIO_PIN_SENSE_LOW 

Pin sense low level.

NRF_GPIO_PIN_SENSE_HIGH 

Pin sense high level.

Function Documentation

◆ nrf_gpio_cfg()

NRF_STATIC_INLINE void nrf_gpio_cfg ( uint32_t  pin_number,
nrf_gpio_pin_dir_t  dir,
nrf_gpio_pin_input_t  input,
nrf_gpio_pin_pull_t  pull,
nrf_gpio_pin_drive_t  drive,
nrf_gpio_pin_sense_t  sense 
)

Pin configuration function.

The main pin configuration function. This function allows to set any aspect in PIN_CNF register.

Parameters
pin_numberSpecifies the pin number.
dirPin direction.
inputConnect or disconnect the input buffer.
pullPull configuration.
driveDrive configuration.
sensePin sensing mechanism.

◆ nrf_gpio_cfg_default()

NRF_STATIC_INLINE void nrf_gpio_cfg_default ( uint32_t  pin_number)

Function for resetting pin configuration to its default state.

Parameters
pin_numberSpecifies the pin number.

◆ nrf_gpio_cfg_input()

NRF_STATIC_INLINE void nrf_gpio_cfg_input ( uint32_t  pin_number,
nrf_gpio_pin_pull_t  pull_config 
)

Function for configuring the given GPIO pin number as input, hiding inner details. This function can be used to configure a pin as simple input.

Note
Sense capability on the pin is disabled and input is connected to buffer so that the GPIO->IN register is readable.
Parameters
pin_numberSpecifies the pin number.
pull_configState of the pin range pull resistor (no pull, pulled down, or pulled high).

◆ nrf_gpio_cfg_output()

NRF_STATIC_INLINE void nrf_gpio_cfg_output ( uint32_t  pin_number)

Function for configuring the given GPIO pin number as output, hiding inner details. This function can be used to configure a pin as simple output with gate driving GPIO_PIN_CNF_DRIVE_S0S1 (normal cases).

Note
Sense capability on the pin is disabled and input is disconnected from the buffer as the pins are configured as output.
Parameters
pin_numberSpecifies the pin number.

◆ nrf_gpio_cfg_sense_input()

NRF_STATIC_INLINE void nrf_gpio_cfg_sense_input ( uint32_t  pin_number,
nrf_gpio_pin_pull_t  pull_config,
nrf_gpio_pin_sense_t  sense_config 
)

Function for configuring the given GPIO pin number as input, hiding inner details. This function can be used to configure pin range as simple input. Sense capability on the pin is configurable and input is connected to buffer so that the GPIO->IN register is readable.

Parameters
pin_numberSpecifies the pin number.
pull_configState of the pin pull resistor (no pull, pulled down, or pulled high).
sense_configSense level of the pin (no sense, sense low, or sense high).

◆ nrf_gpio_cfg_sense_set()

NRF_STATIC_INLINE void nrf_gpio_cfg_sense_set ( uint32_t  pin_number,
nrf_gpio_pin_sense_t  sense_config 
)

Function for configuring sense level for the given GPIO.

Parameters
pin_numberSpecifies the pin number.
sense_configSense configuration.

◆ nrf_gpio_cfg_watcher()

NRF_STATIC_INLINE void nrf_gpio_cfg_watcher ( uint32_t  pin_number)

Function for configuring the given GPIO pin number as a watcher. Only input is connected.

Parameters
pin_numberSpecifies the pin number.

◆ nrf_gpio_input_disconnect()

NRF_STATIC_INLINE void nrf_gpio_input_disconnect ( uint32_t  pin_number)

Function for disconnecting input for the given GPIO.

Parameters
pin_numberSpecifies the pin number.

◆ nrf_gpio_latches_read()

NRF_STATIC_INLINE void nrf_gpio_latches_read ( uint32_t  start_port,
uint32_t  length,
uint32_t *  p_masks 
)

Function for reading latch state of multiple consecutive ports.

Parameters
start_portIndex of the first port to read.
lengthNumber of ports to read.
p_masksPointer to output array where latch states will be stored.

◆ nrf_gpio_latches_read_and_clear()

NRF_STATIC_INLINE void nrf_gpio_latches_read_and_clear ( uint32_t  start_port,
uint32_t  length,
uint32_t *  p_masks 
)

Function for reading and immediate clearing latch state of multiple consecutive ports.

Parameters
start_portIndex of the first port to read and clear.
lengthNumber of ports to read and clear.
p_masksPointer to output array where latch states will be stored.

◆ nrf_gpio_pin_clear()

NRF_STATIC_INLINE void nrf_gpio_pin_clear ( uint32_t  pin_number)

Function for clearing a GPIO pin.

Parameters
pin_numberSpecifies the pin number to clear.

◆ nrf_gpio_pin_dir_get()

NRF_STATIC_INLINE nrf_gpio_pin_dir_t nrf_gpio_pin_dir_get ( uint32_t  pin_number)

Function for reading the direction configuration of a GPIO pin.

Parameters
pin_numberSpecifies the pin number to read.
Returns
Direction configuration.

◆ nrf_gpio_pin_dir_set()

NRF_STATIC_INLINE void nrf_gpio_pin_dir_set ( uint32_t  pin_number,
nrf_gpio_pin_dir_t  direction 
)

Function for setting the direction for a GPIO pin.

Parameters
pin_numberSpecifies the pin number for which to set the direction.
directionSpecifies the direction.

◆ nrf_gpio_pin_input_get()

NRF_STATIC_INLINE nrf_gpio_pin_input_t nrf_gpio_pin_input_get ( uint32_t  pin_number)

Function for reading the status of GPIO pin input buffer.

Parameters
pin_numberPin number to be read.
Return values
Inputbuffer configuration.

◆ nrf_gpio_pin_latch_clear()

NRF_STATIC_INLINE void nrf_gpio_pin_latch_clear ( uint32_t  pin_number)

Function for clearing latch state of a single pin.

Parameters
pin_numberPin number.

◆ nrf_gpio_pin_latch_get()

NRF_STATIC_INLINE uint32_t nrf_gpio_pin_latch_get ( uint32_t  pin_number)

Function for reading latch state of single pin.

Parameters
pin_numberPin number.
Returns
0 if latch is not set. Positive value otherwise.

◆ nrf_gpio_pin_mcu_select()

NRF_STATIC_INLINE void nrf_gpio_pin_mcu_select ( uint32_t  pin_number,
nrf_gpio_pin_mcusel_t  mcu 
)

Function for selecting the MCU to control a GPIO pin.

Parameters
pin_numberPin_number.
mcuMCU to control the pin.

◆ nrf_gpio_pin_out_read()

NRF_STATIC_INLINE uint32_t nrf_gpio_pin_out_read ( uint32_t  pin_number)

Function for reading the output level of a GPIO pin.

Parameters
pin_numberSpecifies the pin number to read.
Returns
0 if the pin output level is low. Positive value if pin output is high.

◆ nrf_gpio_pin_port_decode()

NRF_STATIC_INLINE NRF_GPIO_Type* nrf_gpio_pin_port_decode ( uint32_t *  p_pin)

Function for extracting port and the relative pin number from the absolute pin number.

Parameters
[in,out]p_pinPointer to the absolute pin number overridden by the pin number that is relative to the port.
Returns
Pointer to port register set.

◆ nrf_gpio_pin_port_number_extract()

NRF_STATIC_INLINE uint32_t nrf_gpio_pin_port_number_extract ( uint32_t *  p_pin)

Function for extracting port number and the relative pin number from the absolute pin number.

Parameters
[in,out]p_pinPointer to the absolute pin number overridden by the pin number that is relative to the port.
Returns
Port number.

◆ nrf_gpio_pin_present_check()

NRF_STATIC_INLINE bool nrf_gpio_pin_present_check ( uint32_t  pin_number)

Function for checking if provided pin is present on the MCU.

Parameters
[in]pin_numberNumber of the pin to be checked.
Return values
truePin is present.
falsePin is not present.

◆ nrf_gpio_pin_pull_get()

NRF_STATIC_INLINE nrf_gpio_pin_pull_t nrf_gpio_pin_pull_get ( uint32_t  pin_number)

Function for reading the pull configuration of a GPIO pin.

Parameters
pin_numberSpecifies the pin number to read.
Return values
Pullconfiguration.

◆ nrf_gpio_pin_read()

NRF_STATIC_INLINE uint32_t nrf_gpio_pin_read ( uint32_t  pin_number)

Function for reading the input level of a GPIO pin.

If the value returned by this function is to be valid, the pin's input buffer must be connected.

Parameters
pin_numberSpecifies the pin number to read.
Returns
0 if the pin input level is low. Positive value if the pin is high.

◆ nrf_gpio_pin_sense_get()

NRF_STATIC_INLINE nrf_gpio_pin_sense_t nrf_gpio_pin_sense_get ( uint32_t  pin_number)

Function for reading the sense configuration of a GPIO pin.

Parameters
pin_numberSpecifies the pin number to read.
Returns
Sense configuration.

◆ nrf_gpio_pin_set()

NRF_STATIC_INLINE void nrf_gpio_pin_set ( uint32_t  pin_number)

Function for setting a GPIO pin.

Parameters
pin_numberSpecifies the pin number to be set.

◆ nrf_gpio_pin_toggle()

NRF_STATIC_INLINE void nrf_gpio_pin_toggle ( uint32_t  pin_number)

Function for toggling a GPIO pin.

Parameters
pin_numberSpecifies the pin number to toggle.

◆ nrf_gpio_pin_write()

NRF_STATIC_INLINE void nrf_gpio_pin_write ( uint32_t  pin_number,
uint32_t  value 
)

Function for writing a value to a GPIO pin.

Parameters
pin_numberSpecifies the pin number to write.
valueSpecifies the value to be written to the pin.
  • 0 Clears the pin.
  • >=1 Sets the pin.

◆ nrf_gpio_port_dir_input_set()

NRF_STATIC_INLINE void nrf_gpio_port_dir_input_set ( NRF_GPIO_Type *  p_reg,
uint32_t  in_mask 
)

Function for setting input direction on selected pins on a given port.

Parameters
p_regPointer to the structure of registers of the peripheral.
in_maskMask that specifies the pins to be set as input.

◆ nrf_gpio_port_dir_output_set()

NRF_STATIC_INLINE void nrf_gpio_port_dir_output_set ( NRF_GPIO_Type *  p_reg,
uint32_t  out_mask 
)

Function for setting output direction on the selected pins on the given port.

Parameters
p_regPointer to the structure of registers of the peripheral.
out_maskMask specifying the pins to set as output.

◆ nrf_gpio_port_dir_read()

NRF_STATIC_INLINE uint32_t nrf_gpio_port_dir_read ( NRF_GPIO_Type const *  p_reg)

Function for reading the direction configuration of a GPIO port.

Parameters
p_regPointer to the structure of registers of the peripheral.
Returns
Pin configuration of the current direction settings. Bit set means that the given pin is configured as output.

◆ nrf_gpio_port_dir_write()

NRF_STATIC_INLINE void nrf_gpio_port_dir_write ( NRF_GPIO_Type *  p_reg,
uint32_t  dir_mask 
)

Function for writing the direction configuration of the GPIO pins in the given port.

Parameters
p_regPointer to the structure of registers of the peripheral.
dir_maskMask that specifies the direction of pins. Bit set means that the given pin is configured as output.

◆ nrf_gpio_port_in_read()

NRF_STATIC_INLINE uint32_t nrf_gpio_port_in_read ( NRF_GPIO_Type const *  p_reg)

Function for reading the input signals of the GPIO pins on the given port.

Parameters
p_regPointer to the peripheral registers structure.
Returns
Port input values.

◆ nrf_gpio_port_out_clear()

NRF_STATIC_INLINE void nrf_gpio_port_out_clear ( NRF_GPIO_Type *  p_reg,
uint32_t  clr_mask 
)

Function for setting low level on selected the GPIO pins on the given port.

Parameters
p_regPointer to the structure of registers of the peripheral.
clr_maskMask with pins to be set as logical low level.

◆ nrf_gpio_port_out_read()

NRF_STATIC_INLINE uint32_t nrf_gpio_port_out_read ( NRF_GPIO_Type const *  p_reg)

Function for reading the output signals of the GPIO pins on the given port.

Parameters
p_regPointer to the peripheral registers structure.
Returns
Port output values.

◆ nrf_gpio_port_out_set()

NRF_STATIC_INLINE void nrf_gpio_port_out_set ( NRF_GPIO_Type *  p_reg,
uint32_t  set_mask 
)

Function for setting high level on selected the GPIO pins on the given port.

Parameters
p_regPointer to the structure of registers of the peripheral.
set_maskMask with pins to be set as logical high level.

◆ nrf_gpio_port_out_write()

NRF_STATIC_INLINE void nrf_gpio_port_out_write ( NRF_GPIO_Type *  p_reg,
uint32_t  value 
)

Function for writing the GPIO pins output on a given port.

Parameters
p_regPointer to the structure of registers of the peripheral.
valueOutput port mask.

◆ nrf_gpio_ports_read()

NRF_STATIC_INLINE void nrf_gpio_ports_read ( uint32_t  start_port,
uint32_t  length,
uint32_t *  p_masks 
)

Function for reading pin state of multiple consecutive ports.

Parameters
start_portIndex of the first port to read.
lengthNumber of ports to read.
p_masksPointer to output array where port states will be stored.

◆ nrf_gpio_range_cfg_input()

NRF_STATIC_INLINE void nrf_gpio_range_cfg_input ( uint32_t  pin_range_start,
uint32_t  pin_range_end,
nrf_gpio_pin_pull_t  pull_config 
)

Function for configuring the GPIO pin range as input pins with given initial value set, hiding inner details. This function can be used to configure pin range as simple input.

Note
For configuring only one pin as input, use nrf_gpio_cfg_input. Sense capability on the pin is disabled and input is connected to buffer so that the GPIO->IN register is readable.
Parameters
pin_range_startSpecifies the start number (inclusive) in the range of pin numbers to be configured (allowed values 0-30).
pin_range_endSpecifies the end number (inclusive) in the range of pin numbers to be configured (allowed values 0-30).
pull_configState of the pin range pull resistor (no pull, pulled down, or pulled high).

◆ nrf_gpio_range_cfg_output()

NRF_STATIC_INLINE void nrf_gpio_range_cfg_output ( uint32_t  pin_range_start,
uint32_t  pin_range_end 
)

Function for configuring the GPIO pin range as output pins with normal drive strength. This function can be used to configure pin range as simple output with gate driving GPIO_PIN_CNF_DRIVE_S0S1 (normal cases).

Note
For configuring only one pin as output, use nrf_gpio_cfg_output. Sense capability on the pin is disabled and input is disconnected from the buffer as the pins are configured as output.
Parameters
pin_range_startSpecifies the start number (inclusive) in the range of pin numbers to be configured (allowed values 0-30).
pin_range_endSpecifies the end number (inclusive) in the range of pin numbers to be configured (allowed values 0-30).

Documentation feedback | Developer Zone | Subscribe | Updated