Nordic Thingy:52
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
GPIO extender

GPIO extender API. More...

Modules

 GPIO extender LED driver
 GPIO extender LED driver API.
 
 SX1509 GPIO extender driver
 SX1509 GPIO extender API.
 

Data Structures

struct  drv_ext_gpio_init_t
 GPIO extender driver configuration. More...
 

Macros

#define DRV_EXT_GPIO_NUM_PINS_TOTAL   (DRV_EXT_GPIO_PIN_HIGHEST_ID + 1)
 Number of pins total.
 
#define DRV_EXT_GPIO_PIN_HIGHEST_ID   DRV_SX1509_DATA_PIN15_Pos
 Highest pin ID.
 

Enumerations

enum  { DRV_EXT_GPIO_STATUS_CODE_SUCCESS = NRF_SUCCESS, DRV_EXT_GPIO_STATUS_CODE_INVALID_PARAM, DRV_EXT_GPIO_STATUS_CODE_INVALID_PIN }
 The GPIO extender status codes. More...
 
enum  drv_ext_gpio_pin_dir_t { DRV_EXT_GPIO_PIN_DIR_OUTPUT, DRV_EXT_GPIO_PIN_DIR_INPUT }
 Pin direction definitions. More...
 
enum  drv_ext_gpio_pin_drive_type_t { DRV_EXT_GPIO_PIN_DRIVE_PUSHPULL, DRV_EXT_GPIO_PIN_DRIVE_OPENDRAIN }
 Push-pull or open drain operation. More...
 
enum  drv_ext_gpio_pin_input_buf_t { DRV_EXT_GPIO_PIN_INPUT_BUF_ENABLED, DRV_EXT_GPIO_PIN_INPUT_BUF_DISABLED }
 Connection of input buffer. More...
 
enum  drv_ext_gpio_pin_pull_t { DRV_EXT_GPIO_PIN_NOPULL, DRV_EXT_GPIO_PIN_PULLDOWN, DRV_EXT_GPIO_PIN_PULLUP }
 Pin to be pulled down, up, or no-pull. More...
 
enum  drv_ext_gpio_pin_slew_rate_t { DRV_EXT_GPIO_PIN_INCREASED_SLEWRATE_DISABLED, DRV_EXT_GPIO_PIN_INCREASED_SLEWRATE_ENABLED }
 Regular or increased slew rate. More...
 

Functions

uint32_t drv_ext_gpio_cfg (uint32_t pin_number, drv_ext_gpio_pin_dir_t dir, drv_ext_gpio_pin_input_buf_t input_buf, drv_ext_gpio_pin_pull_t pull_config, drv_ext_gpio_pin_drive_type_t drive_type, drv_ext_gpio_pin_slew_rate_t slew_rate)
 Pin configuration function. More...
 
uint32_t drv_ext_gpio_cfg_input (uint32_t pin_number, drv_ext_gpio_pin_pull_t pull_config)
 Function for configuring the given GPIO pin number as input with given initial value set, hiding inner details. More...
 
uint32_t drv_ext_gpio_cfg_output (uint32_t pin_number)
 Function for configuring the given GPIO pin_number as output with given initial value set, hiding inner details. More...
 
uint32_t drv_ext_gpio_init (drv_ext_gpio_init_t const *const p_init, bool on_init_reset)
 Function for initializing the GPIO extender. More...
 
uint32_t drv_ext_gpio_pin_clear (uint32_t pin_number)
 Function for clearing a GPIO pin. More...
 
uint32_t drv_ext_gpio_pin_dir_modify (uint32_t pin_number, drv_ext_gpio_pin_dir_t direction)
 Function for setting the direction of a GPIO pin. More...
 
uint32_t drv_ext_gpio_pin_drive_type_modify (uint32_t pin_number, drv_ext_gpio_pin_drive_type_t drive_type)
 Function for setting the drive type a given GPIO pin. More...
 
uint32_t drv_ext_gpio_pin_input_buffer_modify (uint32_t pin_number, drv_ext_gpio_pin_input_buf_t input_buf)
 Function for enabling and disabling the input buffer. More...
 
uint32_t drv_ext_gpio_pin_read (uint32_t pin_number, uint32_t *const p_pin)
 Function for reading the input level of a GPIO pin. More...
 
uint32_t drv_ext_gpio_pin_set (uint32_t pin_number)
 Function for setting a GPIO pin. More...
 
uint32_t drv_ext_gpio_pin_slew_rate_modify (uint32_t pin_number, drv_ext_gpio_pin_slew_rate_t slew_rate)
 Function for enabling or disabling increased slew rate for a given GPIO pin. More...
 
uint32_t drv_ext_gpio_pin_toggle (uint32_t pin_number)
 Function for toggling a GPIO pin. More...
 
uint32_t drv_ext_gpio_pin_write (uint32_t pin_number, uint32_t value)
 Function for writing a value to a GPIO pin. More...
 
uint32_t drv_ext_gpio_pins_clear (uint32_t pin_mask)
 Function for clearing GPIO pins. More...
 
uint32_t drv_ext_gpio_pins_read (uint32_t *const p_pins)
 Function for reading the input level of all GPIO pins. More...
 
uint32_t drv_ext_gpio_pins_set (uint32_t pin_mask)
 Function for setting GPIO pins. More...
 
uint32_t drv_ext_gpio_pins_toggle (uint32_t pin_mask)
 Function for toggling GPIO pins. More...
 
uint32_t drv_ext_gpio_reset (void)
 Function for resetting all the registers of the GPIO extender to their default values. More...
 

Detailed Description

GPIO extender API.

Enumeration Type Documentation

anonymous enum

The GPIO extender status codes.

Enumerator
DRV_EXT_GPIO_STATUS_CODE_SUCCESS 

Successfull.

DRV_EXT_GPIO_STATUS_CODE_INVALID_PARAM 

Invalid parameters.

DRV_EXT_GPIO_STATUS_CODE_INVALID_PIN 

Invalid GPIO pin or pin mask selected.

Pin direction definitions.

Enumerator
DRV_EXT_GPIO_PIN_DIR_OUTPUT 

Output.

DRV_EXT_GPIO_PIN_DIR_INPUT 

Input.

Push-pull or open drain operation.

Enumerator
DRV_EXT_GPIO_PIN_DRIVE_PUSHPULL 

Standard push-pull operation.

DRV_EXT_GPIO_PIN_DRIVE_OPENDRAIN 

Open drain.

Connection of input buffer.

Enumerator
DRV_EXT_GPIO_PIN_INPUT_BUF_ENABLED 

Connect input buffer.

DRV_EXT_GPIO_PIN_INPUT_BUF_DISABLED 

Disconnect input buffer.

Pin to be pulled down, up, or no-pull.

Enumerator
DRV_EXT_GPIO_PIN_NOPULL 

No pin pullup or pulldown.

DRV_EXT_GPIO_PIN_PULLDOWN 

Pin pulldown resistor enabled.

DRV_EXT_GPIO_PIN_PULLUP 

Pin pullup resistor enabled.

Regular or increased slew rate.

Enumerator
DRV_EXT_GPIO_PIN_INCREASED_SLEWRATE_DISABLED 

No slew rate alteration.

DRV_EXT_GPIO_PIN_INCREASED_SLEWRATE_ENABLED 

Increased slew rate.

Function Documentation

uint32_t drv_ext_gpio_cfg ( uint32_t  pin_number,
drv_ext_gpio_pin_dir_t  dir,
drv_ext_gpio_pin_input_buf_t  input_buf,
drv_ext_gpio_pin_pull_t  pull_config,
drv_ext_gpio_pin_drive_type_t  drive_type,
drv_ext_gpio_pin_slew_rate_t  slew_rate 
)

Pin configuration function.

Note
The main pin configuration function. This function allows to set any aspect in PIN_CNF register.
Parameters
[in]pin_numberSpecifies the pin number (Allowed values: 0 to DRV_EXT_GPIO_PIN_HIGHEST_ID).
[in]dirPin direction.
[in]inputConnect or disconnect input buffer.
[in]pullPull configuration.
[in]drivetype Push-pull or open drain.
[in]slew_rateNormal or increased slew rate.
Returns
DRV_EXT_GPIO_STATUS_CODE_SUCCESS If the call was successful.
DRV_EXT_GPIO_STATUS_CODE_INVALID_PARAM Invalid parameters supplied.
DRV_EXT_GPIO_STATUS_CODE_INVALID_PIN Pin number not available.
Other codes from the underlying driver.
uint32_t drv_ext_gpio_cfg_input ( uint32_t  pin_number,
drv_ext_gpio_pin_pull_t  pull_config 
)

Function for configuring the given GPIO pin number as input with given initial value set, hiding inner details.

Parameters
[in]pin_numberThe pin number (allowed values 0-DRV_EXT_GPIO_PIN_HIGHEST_ID).
[in]pull_configState of the pin range pull resistor (no pull, pulled down, or pulled high).
Returns
DRV_EXT_GPIO_STATUS_CODE_SUCCESS If the call was successful.
DRV_EXT_GPIO_STATUS_CODE_INVALID_PARAM Invalid parameters supplied.
DRV_EXT_GPIO_STATUS_CODE_INVALID_PIN Pin number not available.
Other codes from the underlying driver.
uint32_t drv_ext_gpio_cfg_output ( uint32_t  pin_number)

Function for configuring the given GPIO pin_number as output with given initial value set, hiding inner details.

Parameters
[in]pin_numberThe pin number (allowed values 0-DRV_EXT_GPIO_PIN_HIGHEST_ID).
Returns
DRV_EXT_GPIO_STATUS_CODE_SUCCESS If the call was successful.
DRV_EXT_GPIO_STATUS_CODE_INVALID_PIN Pin number not available.
Other codes from the underlying driver.
uint32_t drv_ext_gpio_init ( drv_ext_gpio_init_t const *const  p_init,
bool  on_init_reset 
)

Function for initializing the GPIO extender.

Parameters
[in]drv_ext_gpio_init_tConfiguration struct.
[in]on_init_resetIf true, the IO extender will be reset on init. This will put the IO extender in a known state, but will delete any previous configurations, even from other drivers.
Returns
DRV_EXT_GPIO_STATUS_CODE_SUCCESS If the call was successful.
Other codes from the underlying driver.
uint32_t drv_ext_gpio_pin_clear ( uint32_t  pin_number)

Function for clearing a GPIO pin.

Note
The pin must be configured as an output for this function to have any effect.
Parameters
[in]pin_numberThe pin number (0-DRV_EXT_GPIO_PIN_HIGHEST_ID) to clear.
Returns
DRV_EXT_GPIO_STATUS_CODE_SUCCESS If the call was successful.
DRV_EXT_GPIO_STATUS_CODE_INVALID_PIN Pin number not available.
Other codes from the underlying driver.
uint32_t drv_ext_gpio_pin_dir_modify ( uint32_t  pin_number,
drv_ext_gpio_pin_dir_t  direction 
)

Function for setting the direction of a GPIO pin.

Parameters
[in]pin_numberThe pin number (allowed values 0-DRV_EXT_GPIO_PIN_HIGHEST_ID).
[in]directionThe direction.
Returns
DRV_EXT_GPIO_STATUS_CODE_SUCCESS If the call was successful.
DRV_EXT_GPIO_STATUS_CODE_INVALID_PARAM Invalid parameters supplied.
DRV_EXT_GPIO_STATUS_CODE_INVALID_PIN Pin number not available.
Other codes from the underlying driver.
uint32_t drv_ext_gpio_pin_drive_type_modify ( uint32_t  pin_number,
drv_ext_gpio_pin_drive_type_t  drive_type 
)

Function for setting the drive type a given GPIO pin.

Parameters
[in]pin_numberThe pin number (allowed values 0-DRV_EXT_GPIO_PIN_HIGHEST_ID).
[in]drivetype Pin drive: push-pull or open drain.
Returns
DRV_EXT_GPIO_STATUS_CODE_SUCCESS If the call was successful.
DRV_EXT_GPIO_STATUS_CODE_INVALID_PARAM Invalid parameters supplied.
DRV_EXT_GPIO_STATUS_CODE_INVALID_PIN Pin number not available.
Other codes from the underlying driver.
uint32_t drv_ext_gpio_pin_input_buffer_modify ( uint32_t  pin_number,
drv_ext_gpio_pin_input_buf_t  input_buf 
)

Function for enabling and disabling the input buffer.

Parameters
[in]pin_numberThe pin number (allowed values 0-DRV_EXT_GPIO_PIN_HIGHEST_ID).
[in]inputbuffer Disabled or enabled.
Returns
DRV_EXT_GPIO_STATUS_CODE_SUCCESS If the call was successful.
DRV_EXT_GPIO_STATUS_CODE_INVALID_PARAM Invalid parameters supplied.
DRV_EXT_GPIO_STATUS_CODE_INVALID_PIN Pin number not available.
Other codes from the underlying driver.
uint32_t drv_ext_gpio_pin_read ( uint32_t  pin_number,
uint32_t *const  p_pin 
)

Function for reading the input level of a GPIO pin.

Note
The pin must have input connected for the value returned from this function to be valid.
Parameters
[in]pin_numberThe pin number (0-DRV_EXT_GPIO_PIN_HIGHEST_ID) to read.
[out]p_pinPin value.
Return values
0if the pin input level is low.
1if the pin input level is high.
>1 should never occur.
Returns
DRV_EXT_GPIO_STATUS_CODE_SUCCESS If the call was successful.
DRV_EXT_GPIO_STATUS_CODE_INVALID_PIN Pin number not available.
Other codes from the underlying driver.
uint32_t drv_ext_gpio_pin_set ( uint32_t  pin_number)

Function for setting a GPIO pin.

Note
The pin must be configured as an output for this function to have any effect.
Parameters
[in]pin_numberThe pin number (0-DRV_EXT_GPIO_PIN_HIGHEST_ID) to set.
Returns
DRV_EXT_GPIO_STATUS_CODE_SUCCESS If the call was successful.
DRV_EXT_GPIO_STATUS_CODE_INVALID_PIN Pin number not available.
Other codes from the underlying driver.
uint32_t drv_ext_gpio_pin_slew_rate_modify ( uint32_t  pin_number,
drv_ext_gpio_pin_slew_rate_t  slew_rate 
)

Function for enabling or disabling increased slew rate for a given GPIO pin.

Parameters
[in]pin_numberThe pin number (allowed values 0-DRV_EXT_GPIO_PIN_HIGHEST_ID).
[in]directionThe direction.
Returns
DRV_EXT_GPIO_STATUS_CODE_SUCCESS If the call was successful.
DRV_EXT_GPIO_STATUS_CODE_INVALID_PARAM Invalid parameters supplied.
DRV_EXT_GPIO_STATUS_CODE_INVALID_PIN Pin number not available.
Other codes from the underlying driver.
uint32_t drv_ext_gpio_pin_toggle ( uint32_t  pin_number)

Function for toggling a GPIO pin.

Note
The pin must be configured as an output for this function to have any effect.
Parameters
[in]pin_numberPin number (0-DRV_EXT_GPIO_PIN_HIGHEST_ID) to toggle.
Returns
DRV_EXT_GPIO_STATUS_CODE_SUCCESS If the call was successful.
DRV_EXT_GPIO_STATUS_CODE_INVALID_PIN Pin number not available.
Other codes from the underlying driver.
uint32_t drv_ext_gpio_pin_write ( uint32_t  pin_number,
uint32_t  value 
)

Function for writing a value to a GPIO pin.

Note
The pin must be configured as an output for this function to have any effect.
Parameters
[in]pin_numberThe pin number (0-DRV_EXT_GPIO_PIN_HIGHEST_ID) to write.
[in]valueSpecifies the value to be written to the pin.
  • 0 clears the pin.
  • >=1 sets the pin.
Returns
DRV_EXT_GPIO_STATUS_CODE_SUCCESS If the call was successful.
DRV_EXT_GPIO_STATUS_CODE_INVALID_PIN Pin number not available.
Other codes from the underlying driver.
uint32_t drv_ext_gpio_pins_clear ( uint32_t  pin_mask)

Function for clearing GPIO pins.

Note
Pins must be configured as outputs for this function to have any effect.
Parameters
[in]pin_maskPins to clear.
Returns
DRV_EXT_GPIO_STATUS_CODE_SUCCESS If the call was successful.
DRV_EXT_GPIO_STATUS_CODE_INVALID_PIN Pin number not available.
Other codes from the underlying driver.
uint32_t drv_ext_gpio_pins_read ( uint32_t *const  p_pins)

Function for reading the input level of all GPIO pins.

Note
The pins must have input connected for the value returned from this function to be valid.
The most significant 16 bits will always be zero, due to 16 pins on the IO extender.
Parameters
[out]p_pinsState of all pins.
Returns
DRV_EXT_GPIO_STATUS_CODE_SUCCESS If the call was successful.
DRV_EXT_GPIO_STATUS_CODE_INVALID_PIN Pin number not available.
Other codes from the underlying driver.
uint32_t drv_ext_gpio_pins_set ( uint32_t  pin_mask)

Function for setting GPIO pins.

Note
Pins must be configured as outputs for this function to have any effect.
Parameters
[in]pin_maskSpecifies the pins to set.
Returns
DRV_EXT_GPIO_STATUS_CODE_SUCCESS If the call was successful.
DRV_EXT_GPIO_STATUS_CODE_INVALID_PIN Pin number not available.
Other codes from the underlying driver.
uint32_t drv_ext_gpio_pins_toggle ( uint32_t  pin_mask)

Function for toggling GPIO pins.

Note
Pins must be configured as outputs for this function to have any effect.
Parameters
[in]pin_maskPins to toggle.
Returns
DRV_EXT_GPIO_STATUS_CODE_SUCCESS If the call was successful.
DRV_EXT_GPIO_STATUS_CODE_INVALID_PIN Pin number not available.
Other codes from the underlying driver.
uint32_t drv_ext_gpio_reset ( void  )

Function for resetting all the registers of the GPIO extender to their default values.

Note
This reset applies to all registers, regardless if they were set by another driver outside of drv_ext_gpio.
Returns
DRV_EXT_GPIO_STATUS_CODE_SUCCESS If the call was successful.
Other codes from the underlying driver.