nRF5 SDK v17.1.0
Macros | Enumerations | Functions

Module for configuring and using PCAL6408A GPIO expander. More...

Macros

#define PCAL6408A_BASE_ADDRESS_FIRST   0x20u
 First possible expander address.
 
#define PCAL6408A_BASE_ADDRESS_SECOND   0x21u
 Second possible expander address.
 
#define PCAL6408A_INSTANCES_DEF_START(pcal6408a_inst_name, instance_count)   static pcal6408a_instance_t pcal6408a_inst_name[instance_count]
 Macro that defines expander module. More...
 
#define PIN_NUM_CONVERT(pin_num, instance_num)   (pin_num + instance_num * PCAL6408A_INNER_PIN_COUNT)
 Macro that converts absolute pin number to pin number dependent on number of expander. More...
 

Enumerations

enum  pcal6408a_registers_t {
  PCAL6408A_REG_INPUT_PORT = 0x00,
  PCAL6408A_REG_OUTPUT_PORT = 0x01,
  PCAL6408A_REG_POLARITY_INVERSION = 0x02,
  PCAL6408A_REG_CONFIGURATION = 0x03,
  PCAL6408A_REG_OUTPUT_DRIVE_STRENGTH_0 = 0x40,
  PCAL6408A_REG_OUTPUT_DRIVE_STRENGTH_1 = 0x41,
  PCAL6408A_REG_INPUT_LATCH = 0x42,
  PCAL6408A_REG_PULL_UP_DOWN_ENABLE = 0x43,
  PCAL6408A_REG_PULL_UP_DOWN_SELECT = 0x44,
  PCAL6408A_REG_INTERRUPT_MASK = 0x45,
  PCAL6408A_REG_INTERRUPT_STATUS = 0x46,
  PCAL6408A_REG_OUTPUT_PORT_CONFIGURATION = 0x4F
}
 Device registers.
 
enum  pcal6408a_pin_dir_t {
  PCAL6408A_PIN_DIR_OUTPUT,
  PCAL6408A_PIN_DIR_INPUT
}
 Enumerator used for setting the direction of a pin. More...
 
enum  pcal6408a_port_dir_t {
  PCAL6408A_PORT_DIR_OUTPUT = 0x00,
  PCAL6408A_PORT_DIR_INPUT = 0xFF
}
 Enumerator used for setting the direction of a port. More...
 
enum  pcal6408a_pin_set_t {
  PCAL6408A_PIN_CLR,
  PCAL6408A_PIN_SET
}
 Enumerator used for setting the state of a pin configured as an output. More...
 
enum  pcal6408a_pin_pull_t {
  PCAL6408A_PIN_NOPULL,
  PCAL6408A_PIN_PULLDOWN,
  PCAL6408A_PIN_PULLUP
}
 Enumerator used for selecting the pin to be pulled down or up. More...
 
enum  pcal6408a_port_op_t {
  PCAL6408A_PORT_WRITE,
  PCAL6408A_PORT_CLEAR,
  PCAL6408A_PORT_SET
}
 Enumerator used for selecting the operation for a port. More...
 
enum  pcal6408a_pin_drive_strength_t {
  PCAL6408A_PIN_25_DRIVE_STRENGTH,
  PCAL6408A_PIN_50_DRIVE_STRENGTH,
  PCAL6408A_PIN_75_DRIVE_STRENGTH,
  PCAL6408A_PIN_100_DRIVE_STRENGTH
}
 Enumerator used for setting the drive strength of a pin. More...
 
enum  pcal6408a_port_io_stage_t {
  PCAL6408A_PORT_PUSH_PULL,
  PCAL6408A_PORT_OPEN_DRAIN
}
 Enumerator used for setting push-pull or open-drain I/O stage for a port. More...
 

Functions

void pcal6408a_init (pcal6408a_instance_t *p_instances, uint8_t count)
 Function initialising expander module. More...
 
ret_code_t pcal6408a_add_instance (nrf_twi_sensor_t *p_twi_sensor, uint8_t sensor_address)
 Function adding expander instance. More...
 
ret_code_t pcal6408a_cfg_write (uint8_t instance_num)
 Function for writing current configuration to expander. More...
 
ret_code_t pcal6408a_cfg_read (uint8_t instance_num)
 Function for reading current configuration of expander. More...
 
ret_code_t pcal6408a_pin_cfg_reg_set (pcal6408a_registers_t reg_addr, uint32_t pin, uint8_t value)
 Function for setting register configuration of a single pin. More...
 
uint8_t pcal6408a_pin_cfg_reg_get (pcal6408a_registers_t reg_addr, uint32_t pin)
 Function for getting register configuration of a single pin. More...
 
ret_code_t pcal6408a_port_cfg_reg_set (pcal6408a_registers_t reg_addr, uint32_t port, uint8_t mask, pcal6408a_port_op_t flag)
 Function for setting register configuration of a port. More...
 
uint8_t pcal6408a_port_cfg_reg_get (pcal6408a_registers_t reg_addr, uint32_t port)
 Function for getting register configuration of a port. More...
 
ret_code_t pcal6408a_pin_data_update (nrf_twi_sensor_reg_cb_t user_cb)
 Function for updating pin data. More...
 
ret_code_t pcal6408a_int_status_update (nrf_twi_sensor_reg_cb_t user_cb)
 Function for updating interrupt status data. More...
 
__STATIC_INLINE ret_code_t pcal6408a_pin_cfg_polarity_inversion (uint32_t pin_number, bool state)
 Function for setting polarity inversion of a given pin. More...
 
__STATIC_INLINE ret_code_t pcal6408a_pin_cfg_interrupt (uint32_t pin_number, bool state)
 Function for setting interrupt of a given pin. More...
 
__STATIC_INLINE ret_code_t pcal6408a_pin_cfg_latch (uint32_t pin_number, bool state)
 Function for setting input latch of a given pin. More...
 
ret_code_t pcal6408a_pin_cfg_drive_strength (uint32_t pin_number, pcal6408a_pin_drive_strength_t drive_strength_config)
 Function for setting drive strength for a given pin. More...
 
__STATIC_INLINE ret_code_t pcal6408a_port_cfg_polarity_inversion (uint32_t port_number, uint8_t polarity_mask, pcal6408a_port_op_t flag)
 Function for setting polarity inversion of a given port. More...
 
__STATIC_INLINE ret_code_t pcal6408a_port_cfg_interrupt (uint32_t port_number, uint8_t interrupt_mask, pcal6408a_port_op_t flag)
 Function for setting interrupt of a given port. More...
 
__STATIC_INLINE ret_code_t pcal6408a_port_cfg_latch (uint32_t port_number, uint8_t latch_mask, pcal6408a_port_op_t flag)
 Function for setting input latch of a given port. More...
 
ret_code_t pcal6408a_port_cfg_drive_strength (uint32_t port_number, uint16_t drive_strength_mask, pcal6408a_port_op_t flag)
 Function for setting drive strength for a given port. More...
 
__STATIC_INLINE ret_code_t pcal6408a_port_cfg_io_stage (uint32_t port_number, pcal6408a_port_io_stage_t io_stage_config)
 Function for selecting push-pull or open-drain I/O stage for the given port. More...
 
__STATIC_INLINE ret_code_t pcal6408a_pin_cfg_output (uint32_t pin_number)
 Function for configuring the given pin number as output. More...
 
ret_code_t pcal6408a_pin_cfg_input (uint32_t pin_number, pcal6408a_pin_pull_t pull_config)
 Function for configuring the given pin number as input. More...
 
__STATIC_INLINE ret_code_t pcal6408a_pin_set (uint32_t pin_number)
 Function for setting a pin. More...
 
__STATIC_INLINE ret_code_t pcal6408a_pin_clear (uint32_t pin_number)
 Function for clearing a pin. More...
 
ret_code_t pcal6408a_range_cfg_output (uint32_t pin_range_start, uint32_t pin_range_end)
 Function for configuring the pin range as outputs. More...
 
ret_code_t pcal6408a_range_cfg_input (uint32_t pin_range_start, uint32_t pin_range_end, pcal6408a_pin_pull_t pull_config)
 Function for configuring the pin range as inputs. More...
 
__STATIC_INLINE ret_code_t pcal6408a_pin_dir_set (uint32_t pin_number, pcal6408a_pin_dir_t direction)
 Function for setting the direction for a given pin. More...
 
__STATIC_INLINE ret_code_t pcal6408a_pin_toggle (uint32_t pin_number)
 Function for toggling a given pin. More...
 
__STATIC_INLINE ret_code_t pcal6408a_pin_write (uint32_t pin_number, uint8_t value)
 Function for writing a value to a given pin. More...
 
__STATIC_INLINE uint32_t pcal6408a_pin_read (uint32_t pin_number)
 Function for reading the input level of a given pin. More...
 
__STATIC_INLINE ret_code_t pcal6408a_port_dir_set (uint32_t port_number, pcal6408a_port_dir_t direction)
 Function for setting the direction of a port. More...
 
__STATIC_INLINE uint32_t pcal6408a_port_read (uint32_t port_number)
 Function for reading a given port. More...
 
__STATIC_INLINE ret_code_t pcal6408a_port_write (uint32_t port_number, uint8_t value)
 Function for writing to a given port. More...
 
__STATIC_INLINE ret_code_t pcal6408a_port_set (uint32_t port_number, uint8_t set_mask)
 Function for setting individual pins on given port. More...
 
__STATIC_INLINE ret_code_t pcal6408a_port_clear (uint32_t port_number, uint8_t clr_mask)
 Function for clearing individual pins on given port. More...
 

Detailed Description

Module for configuring and using PCAL6408A GPIO expander.

Macro Definition Documentation

#define PCAL6408A_INSTANCES_DEF_START (   pcal6408a_inst_name,
  instance_count 
)    static pcal6408a_instance_t pcal6408a_inst_name[instance_count]

Macro that defines expander module.

Parameters
[in]pcal6408a_inst_nameName of the instance to be created.
[in]instance_countNumber of connected expanders.
#define PIN_NUM_CONVERT (   pin_num,
  instance_num 
)    (pin_num + instance_num * PCAL6408A_INNER_PIN_COUNT)

Macro that converts absolute pin number to pin number dependent on number of expander.

Parameters
[in]pin_numAbsolute pin number ranging from 0 to 7.
[in]instance_numNumber of expander, order is the same as pcal6408a_add_instance calls.

Enumeration Type Documentation

Enumerator used for setting the direction of a pin.

Enumerator
PCAL6408A_PIN_DIR_OUTPUT 

Output.

PCAL6408A_PIN_DIR_INPUT 

Input.

Enumerator used for setting the drive strength of a pin.

Enumerator
PCAL6408A_PIN_25_DRIVE_STRENGTH 

Drive strength set to 25% of current drive capability.

PCAL6408A_PIN_50_DRIVE_STRENGTH 

Drive strength set to 50% of current drive capability.

PCAL6408A_PIN_75_DRIVE_STRENGTH 

Drive strength set to 75% of current drive capability.

PCAL6408A_PIN_100_DRIVE_STRENGTH 

Drive strength set to 100% of current drive capability.

Enumerator used for selecting the pin to be pulled down or up.

Enumerator
PCAL6408A_PIN_NOPULL 

No pull.

PCAL6408A_PIN_PULLDOWN 

Pin pulldown resistor enabled.

PCAL6408A_PIN_PULLUP 

Pin pullup resistor enabled.

Enumerator used for setting the state of a pin configured as an output.

Enumerator
PCAL6408A_PIN_CLR 

Clear.

PCAL6408A_PIN_SET 

Set.

Enumerator used for setting the direction of a port.

Enumerator
PCAL6408A_PORT_DIR_OUTPUT 

Output.

PCAL6408A_PORT_DIR_INPUT 

Input.

Enumerator used for setting push-pull or open-drain I/O stage for a port.

Enumerator
PCAL6408A_PORT_PUSH_PULL 

Push-pull I/O stage.

PCAL6408A_PORT_OPEN_DRAIN 

Open-drain I/O stage.

Enumerator used for selecting the operation for a port.

Enumerator
PCAL6408A_PORT_WRITE 

Mask is written to the port.

PCAL6408A_PORT_CLEAR 

Positive bits in mask are cleared in port.

PCAL6408A_PORT_SET 

Positive bits in mask are set in port.

Function Documentation

ret_code_t pcal6408a_add_instance ( nrf_twi_sensor_t p_twi_sensor,
uint8_t  sensor_address 
)

Function adding expander instance.

Note
Should be called for every connected expander. Order of calls define order of pins and ports.
Parameters
[in]p_twi_sensorPointer to common sensor instance. NRF_TWI_SENSOR_DEF
[in]sensor_addressAddress of expander on I2C bus.
Return values
NRF_ERROR_MODULE_NOT_INITIALIZEDIf expander module wasn't initialised
NRF_ERROR_STORAGE_FULLIf trying to add more instances than defined.
otherError code from nrf_twi_sensor nrf_twi_sensor_write
ret_code_t pcal6408a_cfg_read ( uint8_t  instance_num)

Function for reading current configuration of expander.

Parameters
[in]instance_numNumber of expander, order is the same as pcal6408a_add_instance calls.
Return values
NRF_ERROR_INVALID_PARAMIf there is no expander with given number.
otherError code from nrf_twi_sensor nrf_twi_sensor_write
ret_code_t pcal6408a_cfg_write ( uint8_t  instance_num)

Function for writing current configuration to expander.

Parameters
[in]instance_numNumber of expander, order is the same as pcal6408a_add_instance calls.
Return values
NRF_ERROR_INVALID_PARAMIf there is no expander with given number.
otherError code from nrf_twi_sensor nrf_twi_sensor_write
void pcal6408a_init ( pcal6408a_instance_t p_instances,
uint8_t  count 
)

Function initialising expander module.

Parameters
[in]p_instancesPointer to expander module.
[in]countNumber of connected expanders.
ret_code_t pcal6408a_int_status_update ( nrf_twi_sensor_reg_cb_t  user_cb)

Function for updating interrupt status data.

Parameters
user_cbFunction to be called after interrupt status update is done.
Returns
Return error code from nrf_twi_sensor nrf_twi_sensor_reg_read
ret_code_t pcal6408a_pin_cfg_drive_strength ( uint32_t  pin_number,
pcal6408a_pin_drive_strength_t  drive_strength_config 
)

Function for setting drive strength for a given pin.

Note
Note that the pin must be configured as an output for this function to have any effect.
Parameters
[in]pin_numberSpecifies the pin number.
[in]drive_strength_configDrive strength of current drive capability (25%, 50%, 75% or 100%) pcal6408a_pin_drive_strength_t
Returns
Error code from pin_cfg_reg_set pcal6408a_pin_cfg_reg_set
ret_code_t pcal6408a_pin_cfg_input ( uint32_t  pin_number,
pcal6408a_pin_pull_t  pull_config 
)

Function for configuring the given pin number as input.

Parameters
[in]pin_numberSpecifies the pin number.
[in]pull_configState of the pin pull resistor (no pull, pulled down, or pulled high) pcal6408a_pin_pull_t
Returns
Error code from pin_cfg_reg_set pcal6408a_pin_cfg_reg_set
__STATIC_INLINE ret_code_t pcal6408a_pin_cfg_interrupt ( uint32_t  pin_number,
bool  state 
)

Function for setting interrupt of a given pin.

Note
Note that the pin must be configured as an input for this function to have any effect.
Parameters
[in]pin_numberSpecifies the pin number.
[in]state
  • true Disables interrupt.
  • false Enables interrupt.
Returns
Error code from pin_cfg_reg_set pcal6408a_pin_cfg_reg_set
__STATIC_INLINE ret_code_t pcal6408a_pin_cfg_latch ( uint32_t  pin_number,
bool  state 
)

Function for setting input latch of a given pin.

Note
Note that the pin must be configured as an input for this function to have any effect.
Parameters
[in]pin_numberSpecifies the pin number.
[in]state
  • true Enables input latch.
  • false Disables input latch.
Returns
Error code from pin_cfg_reg_set pcal6408a_pin_cfg_reg_set
__STATIC_INLINE ret_code_t pcal6408a_pin_cfg_output ( uint32_t  pin_number)

Function for configuring the given pin number as output.

Parameters
[in]pin_numberSpecifies the pin number.
Returns
Error code from pin config set pcal6408a_pin_cfg_reg_set
__STATIC_INLINE ret_code_t pcal6408a_pin_cfg_polarity_inversion ( uint32_t  pin_number,
bool  state 
)

Function for setting polarity inversion of a given pin.

Note
Note that the pin must be configured as an input for this function to have any effect.
Parameters
[in]pin_numberSpecifies the pin number.
[in]state
  • true Enables polarity inversion.
  • false Disables polarity inversion.
Returns
Error code from pin_cfg_reg_set pcal6408a_pin_cfg_reg_set
uint8_t pcal6408a_pin_cfg_reg_get ( pcal6408a_registers_t  reg_addr,
uint32_t  pin 
)

Function for getting register configuration of a single pin.

Parameters
[in]reg_addrRegister address.
[in]pinPin number.
Returns
Pin configuration value
ret_code_t pcal6408a_pin_cfg_reg_set ( pcal6408a_registers_t  reg_addr,
uint32_t  pin,
uint8_t  value 
)

Function for setting register configuration of a single pin.

Parameters
[in]reg_addrRegister address.
[in]pinPin number.
[in]valueValue to set.
Returns
Error code from nrf_twi_sensor nrf_twi_sensor_write
__STATIC_INLINE ret_code_t pcal6408a_pin_clear ( uint32_t  pin_number)

Function for clearing a pin.

Note
Note that the pin must be configured as an output for this function to have any effect.
Parameters
[in]pin_numberSpecifies the pin number to clear.
Returns
Error code from pin_cfg_reg_set pcal6408a_pin_cfg_reg_set
ret_code_t pcal6408a_pin_data_update ( nrf_twi_sensor_reg_cb_t  user_cb)

Function for updating pin data.

Parameters
user_cbFunction to be called after pin data update is done.
Returns
Return error code from nrf_twi_sensor nrf_twi_sensor_reg_read
__STATIC_INLINE ret_code_t pcal6408a_pin_dir_set ( uint32_t  pin_number,
pcal6408a_pin_dir_t  direction 
)

Function for setting the direction for a given pin.

Parameters
[in]pin_numberSpecifies the pin number.
[in]directionSpecifies the direction.
Returns
Error code from pin_cfg_reg_set pcal6408a_pin_cfg_reg_set
__STATIC_INLINE uint32_t pcal6408a_pin_read ( uint32_t  pin_number)

Function for reading the input level of a given pin.

Note
Input data should be updated prior using this function, with pcal6408a_pin_data_update
Parameters
[in]pin_numberSpecifies the pin number.
Returns
Error code from pin_cfg_reg_set pcal6408a_pin_cfg_reg_set
__STATIC_INLINE ret_code_t pcal6408a_pin_set ( uint32_t  pin_number)

Function for setting a pin.

Note
Note that the pin must be configured as an output for this function to have any effect.
Parameters
[in]pin_numberSpecifies the pin number to set.
Returns
Error code from pin_cfg_reg_set pcal6408a_pin_cfg_reg_set
__STATIC_INLINE ret_code_t pcal6408a_pin_toggle ( uint32_t  pin_number)

Function for toggling a given pin.

Note
Note that the pin must be configured as an output for this function to have any effect.
Parameters
[in]pin_numberSpecifies the pin number.
Returns
Error code from pin_cfg_reg_set pcal6408a_pin_cfg_reg_set
__STATIC_INLINE ret_code_t pcal6408a_pin_write ( uint32_t  pin_number,
uint8_t  value 
)

Function for writing a value to a given pin.

Note
Note that the pin must be configured as an output for this function to have any effect.
Parameters
[in]pin_numberSpecifies the pin number.
[in]valueSpecifies the value to be written to the pin.
  • 0 Clears the pin.
  • 1 Sets the pin.
Returns
Error code from pin_cfg_reg_set pcal6408a_pin_cfg_reg_set
ret_code_t pcal6408a_port_cfg_drive_strength ( uint32_t  port_number,
uint16_t  drive_strength_mask,
pcal6408a_port_op_t  flag 
)

Function for setting drive strength for a given port.

Note
Note that this function have an effect only for pins that are configured as an output.
Parameters
[in]port_numberSpecifies the port number.
[in]drive_strength_maskSpecifies the mask. Note that for each pin there are dedicated two adjacent bits.
[in]flagOperation, whether mask should be written into register, values should be cleared or set pcal6408a_port_op_t
Returns
Error code from port_cfg_reg_set pcal6408a_port_cfg_reg_set
__STATIC_INLINE ret_code_t pcal6408a_port_cfg_interrupt ( uint32_t  port_number,
uint8_t  interrupt_mask,
pcal6408a_port_op_t  flag 
)

Function for setting interrupt of a given port.

Note
Note that this function have an effect only for pins that are configured as an input.
Parameters
[in]port_numberSpecifies the port number.
[in]interrupt_maskSpecifies the mask.
[in]flagOperation, whether mask should be written into register, values should be cleared or set pcal6408a_port_op_t
Returns
Error code from port_cfg_reg_set pcal6408a_port_cfg_reg_set
__STATIC_INLINE ret_code_t pcal6408a_port_cfg_io_stage ( uint32_t  port_number,
pcal6408a_port_io_stage_t  io_stage_config 
)

Function for selecting push-pull or open-drain I/O stage for the given port.

Parameters
[in]port_numberSpecifies the port number.
[in]io_stage_configI/O stage of the port (push-pull or open-drain) pcal6408a_port_io_stage_t
Returns
Error code from port_cfg_reg_set pcal6408a_port_cfg_reg_set
__STATIC_INLINE ret_code_t pcal6408a_port_cfg_latch ( uint32_t  port_number,
uint8_t  latch_mask,
pcal6408a_port_op_t  flag 
)

Function for setting input latch of a given port.

Note
Note that this function have an effect only for pins that are configured as an input.
Parameters
[in]port_numberSpecifies the port number.
[in]latch_maskSpecifies the mask.
[in]flagOperation, whether mask should be written into register, values should be cleared or set pcal6408a_port_op_t
Returns
Error code from port_cfg_reg_set pcal6408a_port_cfg_reg_set
__STATIC_INLINE ret_code_t pcal6408a_port_cfg_polarity_inversion ( uint32_t  port_number,
uint8_t  polarity_mask,
pcal6408a_port_op_t  flag 
)

Function for setting polarity inversion of a given port.

Note
Note that this function have an effect only for pins that are configured as an input.
Parameters
[in]port_numberSpecifies the port number.
[in]polarity_maskSpecifies the mask.
[in]flagOperation, whether mask should be written into register, values should be cleared or set pcal6408a_port_op_t
Returns
Error code from port_cfg_reg_set pcal6408a_port_cfg_reg_set
uint8_t pcal6408a_port_cfg_reg_get ( pcal6408a_registers_t  reg_addr,
uint32_t  port 
)

Function for getting register configuration of a port.

Note
When reading input register, it should be updated prior using this function, with pcal6408a_pin_data_update When reading interrupt status register, it should be updated prior using this function, with pcal6408a_int_status_update
Parameters
[in]reg_addrRegister address.
[in]portPort number.
Returns
Register value
ret_code_t pcal6408a_port_cfg_reg_set ( pcal6408a_registers_t  reg_addr,
uint32_t  port,
uint8_t  mask,
pcal6408a_port_op_t  flag 
)

Function for setting register configuration of a port.

Parameters
[in]reg_addrRegister address.
[in]portPort number.
[in]maskMask for the operation.
[in]flagOperation, whether mask should be written into register, values should be cleared or set pcal6408a_port_op_t
Return values
NRF_ERROR_INVALID_PARAMIf there is no port with such number or invalid flag operation.
otherError code from nrf_twi_sensor nrf_twi_sensor_write
__STATIC_INLINE ret_code_t pcal6408a_port_clear ( uint32_t  port_number,
uint8_t  clr_mask 
)

Function for clearing individual pins on given port.

Note
Note that this function have an effect only for pins that are configured as an output.
Parameters
[in]port_numberSpecifies the port number.
[in]clr_maskMask specifying which pins to clear. A bit set to 1 indicates that the corresponding port pin shall be cleared.
Returns
Error code from port_cfg_reg_set pcal6408a_port_cfg_reg_set
__STATIC_INLINE ret_code_t pcal6408a_port_dir_set ( uint32_t  port_number,
pcal6408a_port_dir_t  direction 
)

Function for setting the direction of a port.

Parameters
[in]port_numberSpecifies the port number.
[in]directionSpecifies the direction.
Returns
Error code from port_cfg_reg_set pcal6408a_port_cfg_reg_set
__STATIC_INLINE uint32_t pcal6408a_port_read ( uint32_t  port_number)

Function for reading a given port.

Note
Input data should be updated prior using this function, with pcal6408a_pin_data_update
Parameters
[in]port_numberSpecifies the port number.
Returns
Error code from port_cfg_reg_set pcal6408a_port_cfg_reg_set
__STATIC_INLINE ret_code_t pcal6408a_port_set ( uint32_t  port_number,
uint8_t  set_mask 
)

Function for setting individual pins on given port.

Note
Note that this function have an effect only for pins that are configured as an output.
Parameters
[in]port_numberSpecifies the port number.
[in]set_maskMask specifying which pins to set. A bit set to 1 indicates that the corresponding port pin shall be set.
Returns
Error code from port_cfg_reg_set pcal6408a_port_cfg_reg_set
__STATIC_INLINE ret_code_t pcal6408a_port_write ( uint32_t  port_number,
uint8_t  value 
)

Function for writing to a given port.

Note
Note that this function have an effect only for pins that are configured as an output.
Parameters
[in]port_numberSpecifies the port number.
[in]valueSpecifies the value to be written to the port.
Returns
Error code from port_cfg_reg_set pcal6408a_port_cfg_reg_set
ret_code_t pcal6408a_range_cfg_input ( uint32_t  pin_range_start,
uint32_t  pin_range_end,
pcal6408a_pin_pull_t  pull_config 
)

Function for configuring the pin range as inputs.

Note
For configuring only one pin as an input use pcal6408a_pin_cfg_input.
Parameters
[in]pin_range_startSpecifies the start number (inclusive) in the range of pin numbers to be configured.
[in]pin_range_endSpecifies the end number (inclusive) in the range of pin numbers to be configured.
[in]pull_configState of the pin pull resistor (no pull, pulled down, or pulled high) pcal6408a_pin_pull_t
Return values
NRF_ERROR_INVALID_LENGTHIf start number is greater than end number.
otherError code from port_cfg_reg_set pcal6408a_port_cfg_reg_set
ret_code_t pcal6408a_range_cfg_output ( uint32_t  pin_range_start,
uint32_t  pin_range_end 
)

Function for configuring the pin range as outputs.

Note
For configuring only one pin as an output use pcal6408a_pin_cfg_output.
Parameters
[in]pin_range_startSpecifies the start number (inclusive) in the range of pin numbers to be configured.
[in]pin_range_endSpecifies the end number (inclusive) in the range of pin numbers to be configured.
Return values
NRF_ERROR_INVALID_LENGTHIf start number is greater than end number.
otherError code from port_cfg_reg_set pcal6408a_port_cfg_reg_set

Documentation feedback | Developer Zone | Subscribe | Updated