Bridle API 4.2.99
A Zephyr based application framework
Loading...
Searching...
No Matches
PCA9555 GPIO Controller (w/regrst)

GPIO controller for an PCA9555 (w/regrst) More...

Data Structures

struct  gpio_pca9555_regrst_config
 Configuration data. More...
struct  gpio_pca9555_regrst_drv_data
 Runtime driver data. More...

Macros

#define REG_INPUT_PORT0   0x00
#define REG_INPUT_PORT1   0x01
#define REG_OUTPUT_PORT0   0x02
#define REG_OUTPUT_PORT1   0x03
#define REG_OUTPUT_DFLT   0xFFFF
#define REG_POL_INV_PORT0   0x04
#define REG_POL_INV_PORT1   0x05
#define REG_POL_INV_DFLT   0x0000
#define REG_CONF_PORT0   0x06
#define REG_CONG_PORT1   0x07
#define REG_CONG_DFLT   0xFFFF
#define PCA_HAS_INTERRUPT   BIT(1)
#define PCA_HAS_RST_DFLTS   BIT(7)
#define GPIO_PCA9555_REGRST_DEVICE_INSTANCE(inst)

Functions

static int read_port_regs (const struct device *dev, uint8_t reg, uint16_t *cache, uint16_t *buf)
 Read both port 0 and port 1 registers of certain register function.
static int write_port_regs (const struct device *dev, uint8_t reg, uint16_t *cache, uint16_t value)
 Write both port 0 and port 1 registers of certain register function.
static int update_input_regs (const struct device *dev, uint16_t *buf)
static int update_output_regs (const struct device *dev, uint16_t value)
static int update_direction_regs (const struct device *dev, uint16_t value)
static int setup_pin_dir (const struct device *dev, uint32_t pin, int flags)
 Setup the pin direction (input or output)
static int gpio_pca9555_regrst_config (const struct device *dev, gpio_pin_t pin, gpio_flags_t flags)
 Configure pin or port.
static int gpio_pca9555_regrst_port_get_raw (const struct device *dev, uint32_t *value)
static int gpio_pca9555_regrst_port_set_masked_raw (const struct device *dev, uint32_t mask, uint32_t value)
static int gpio_pca9555_regrst_port_set_bits_raw (const struct device *dev, uint32_t mask)
static int gpio_pca9555_regrst_port_clear_bits_raw (const struct device *dev, uint32_t mask)
static int gpio_pca9555_regrst_port_toggle_bits (const struct device *dev, uint32_t mask)
static int gpio_pca9555_regrst_pin_interrupt_configure (const struct device *dev, gpio_pin_t pin, enum gpio_int_mode mode, enum gpio_int_trig trig)
static int gpio_pca9555_regrst_reset_defaults (const struct device *dev)
 Reset defaults function of PCA9555.
static int gpio_pca9555_regrst_init (const struct device *dev)
 Initialization function of PCA9555.

Variables

static const struct gpio_driver_api gpio_pca9555_regrst_drv_api_funcs

Detailed Description

GPIO controller for an PCA9555 (w/regrst)

Since
3.4
Version
1.0.0

The GPIO controller for the I2C-based PCA9555 chip with the reset register to defaults feature.

Macro Definition Documentation

◆ GPIO_PCA9555_REGRST_DEVICE_INSTANCE

#define GPIO_PCA9555_REGRST_DEVICE_INSTANCE ( inst)

#include </__w/bridle/bridle/workspace/bridle/drivers/gpio/gpio_pca9555_regrst.c>

Value:
static const struct gpio_pca9555_regrst_config \
gpio_pca9555_regrst_##inst##_cfg = { \
.common = { \
.port_pin_mask = GPIO_PORT_PIN_MASK_FROM_DT_INST(inst), \
}, \
.bus = I2C_DT_SPEC_INST_GET(inst), \
.capabilities = \
(DT_INST_PROP(inst, rst_dflts) ? \
IF_ENABLED(CONFIG_GPIO_PCA9555_REGRST_INTERRUPT, ( \
(DT_INST_NODE_HAS_PROP(inst, interrupt_gpios) ? \
)) \
0, \
IF_ENABLED(CONFIG_GPIO_PCA9555_REGRST_INTERRUPT, ( \
.int_gpio = GPIO_DT_SPEC_INST_GET_OR( \
inst, interrupt_gpios, {}), \
)) \
}; \
\
static struct gpio_pca9555_regrst_drv_data \
gpio_pca9555_regrst_##inst##_drvdata = { \
.reg_cache.input = 0x0, \
.reg_cache.output = REG_OUTPUT_DFLT, \
.reg_cache.dir = REG_CONG_DFLT, \
IF_ENABLED(CONFIG_GPIO_PCA9555_REGRST_INTERRUPT, ( \
.interrupt_active = false, \
)) \
}; \
\
DEVICE_DT_INST_DEFINE(inst, \
NULL, \
&gpio_pca9555_regrst_##inst##_drvdata, \
&gpio_pca9555_regrst_##inst##_cfg, \
POST_KERNEL, CONFIG_GPIO_PCA9555_REGRST_INIT_PRIORITY, \
#define REG_CONG_DFLT
Definition gpio_pca9554_regrst.c:54
#define PCA_HAS_INTERRUPT
Definition gpio_pca9554_regrst.c:58
#define REG_OUTPUT_DFLT
Definition gpio_pca9554_regrst.c:50
#define PCA_HAS_RST_DFLTS
Definition gpio_pca9554_regrst.c:59
static const struct gpio_driver_api gpio_pca9555_regrst_drv_api_funcs
Definition gpio_pca9555_regrst.c:558
static int gpio_pca9555_regrst_init(const struct device *dev)
Initialization function of PCA9555.
Definition gpio_pca9555_regrst.c:616
Configuration data.
Definition gpio_pca9555_regrst.c:66

◆ PCA_HAS_INTERRUPT

#define PCA_HAS_INTERRUPT   BIT(1)

◆ PCA_HAS_RST_DFLTS

#define PCA_HAS_RST_DFLTS   BIT(7)

◆ REG_CONF_PORT0

◆ REG_CONG_DFLT

#define REG_CONG_DFLT   0xFFFF

◆ REG_CONG_PORT1

◆ REG_INPUT_PORT0

#define REG_INPUT_PORT0   0x00

◆ REG_INPUT_PORT1

#define REG_INPUT_PORT1   0x01

◆ REG_OUTPUT_DFLT

#define REG_OUTPUT_DFLT   0xFFFF

◆ REG_OUTPUT_PORT0

#define REG_OUTPUT_PORT0   0x02

◆ REG_OUTPUT_PORT1

#define REG_OUTPUT_PORT1   0x03

◆ REG_POL_INV_DFLT

#define REG_POL_INV_DFLT   0x0000

◆ REG_POL_INV_PORT0

#define REG_POL_INV_PORT0   0x04

◆ REG_POL_INV_PORT1

#define REG_POL_INV_PORT1   0x05

Function Documentation

◆ gpio_pca9555_regrst_config()

int gpio_pca9555_regrst_config ( const struct device * dev,
gpio_pin_t pin,
gpio_flags_t flags )
static

#include </__w/bridle/bridle/workspace/bridle/drivers/gpio/gpio_pca9555_regrst.c>

Configure pin or port.

Parameters
devDevice struct of the PCA9555
pinThe pin number
flagsFlags of pin or port
Returns
0 if successful, failed otherwise

◆ gpio_pca9555_regrst_init()

int gpio_pca9555_regrst_init ( const struct device * dev)
static

#include </__w/bridle/bridle/workspace/bridle/drivers/gpio/gpio_pca9555_regrst.c>

Initialization function of PCA9555.

Parameters
devDevice struct
Returns
0 if successful, failed otherwise.

◆ gpio_pca9555_regrst_pin_interrupt_configure()

int gpio_pca9555_regrst_pin_interrupt_configure ( const struct device * dev,
gpio_pin_t pin,
enum gpio_int_mode mode,
enum gpio_int_trig trig )
static

◆ gpio_pca9555_regrst_port_clear_bits_raw()

int gpio_pca9555_regrst_port_clear_bits_raw ( const struct device * dev,
uint32_t mask )
static

◆ gpio_pca9555_regrst_port_get_raw()

int gpio_pca9555_regrst_port_get_raw ( const struct device * dev,
uint32_t * value )
static

◆ gpio_pca9555_regrst_port_set_bits_raw()

int gpio_pca9555_regrst_port_set_bits_raw ( const struct device * dev,
uint32_t mask )
static

◆ gpio_pca9555_regrst_port_set_masked_raw()

int gpio_pca9555_regrst_port_set_masked_raw ( const struct device * dev,
uint32_t mask,
uint32_t value )
static

◆ gpio_pca9555_regrst_port_toggle_bits()

int gpio_pca9555_regrst_port_toggle_bits ( const struct device * dev,
uint32_t mask )
static

◆ gpio_pca9555_regrst_reset_defaults()

int gpio_pca9555_regrst_reset_defaults ( const struct device * dev)
static

#include </__w/bridle/bridle/workspace/bridle/drivers/gpio/gpio_pca9555_regrst.c>

Reset defaults function of PCA9555.

Parameters
devDevice struct
Returns
0 if successful, failed otherwise.

◆ read_port_regs()

int read_port_regs ( const struct device * dev,
uint8_t reg,
uint16_t * cache,
uint16_t * buf )
static

#include </__w/bridle/bridle/workspace/bridle/drivers/gpio/gpio_pca9555_regrst.c>

Read both port 0 and port 1 registers of certain register function.

Given the register in reg, read the pair of port 0 and port 1.

Parameters
devDevice struct of the PCA9555.
regRegister to read (the PORT0 of the pair of registers).
cachePointer to the cache to be updated after successful read.
bufBuffer to read data into.
Returns
0 if successful, failed otherwise.

◆ setup_pin_dir()

int setup_pin_dir ( const struct device * dev,
uint32_t pin,
int flags )
static

#include </__w/bridle/bridle/workspace/bridle/drivers/gpio/gpio_pca9555_regrst.c>

Setup the pin direction (input or output)

Parameters
devDevice struct of the PCA9555
pinThe pin number
flagsFlags of pin or port
Returns
0 if successful, failed otherwise

◆ update_direction_regs()

int update_direction_regs ( const struct device * dev,
uint16_t value )
inlinestatic

◆ update_input_regs()

int update_input_regs ( const struct device * dev,
uint16_t * buf )
inlinestatic

◆ update_output_regs()

int update_output_regs ( const struct device * dev,
uint16_t value )
inlinestatic

◆ write_port_regs()

int write_port_regs ( const struct device * dev,
uint8_t reg,
uint16_t * cache,
uint16_t value )
static

#include </__w/bridle/bridle/workspace/bridle/drivers/gpio/gpio_pca9555_regrst.c>

Write both port 0 and port 1 registers of certain register function.

Given the register in reg, write the pair of port 0 and port 1.

Parameters
devDevice struct of the PCA9555.
regRegister to write into (the PORT0 of the pair of registers).
cachePointer to the cache to be updated after successful write.
valueNew value to set.
Returns
0 if successful, failed otherwise.

Variable Documentation

◆ gpio_pca9555_regrst_drv_api_funcs

const struct gpio_driver_api gpio_pca9555_regrst_drv_api_funcs
static

#include </__w/bridle/bridle/workspace/bridle/drivers/gpio/gpio_pca9555_regrst.c>

Initial value:
= {
.pin_configure = gpio_pca9555_regrst_config,
.pin_interrupt_configure = gpio_pca9555_regrst_pin_interrupt_configure,
}
static int gpio_pca9555_regrst_pin_interrupt_configure(const struct device *dev, gpio_pin_t pin, enum gpio_int_mode mode, enum gpio_int_trig trig)
Definition gpio_pca9555_regrst.c:451
static int gpio_pca9555_regrst_port_toggle_bits(const struct device *dev, uint32_t mask)
Definition gpio_pca9555_regrst.c:368
static int gpio_pca9555_regrst_port_get_raw(const struct device *dev, uint32_t *value)
Definition gpio_pca9555_regrst.c:304
static int gpio_pca9555_regrst_port_clear_bits_raw(const struct device *dev, uint32_t mask)
Definition gpio_pca9555_regrst.c:362
static int gpio_pca9555_regrst_port_set_bits_raw(const struct device *dev, uint32_t mask)
Definition gpio_pca9555_regrst.c:356
static int gpio_pca9555_regrst_port_set_masked_raw(const struct device *dev, uint32_t mask, uint32_t value)
Definition gpio_pca9555_regrst.c:331