drivers: gpio_sx1509b: add support for pin validation
Add the common config structure as a prefix of the driver-specific config structure and use the devicetree GPIO pin counts to initialize it. Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
This commit is contained in:
parent
63141c1a31
commit
a8ba5fb1a5
2 changed files with 8 additions and 0 deletions
|
@ -19,6 +19,8 @@
|
||||||
#include <logging/log.h>
|
#include <logging/log.h>
|
||||||
LOG_MODULE_REGISTER(sx1509b, CONFIG_GPIO_LOG_LEVEL);
|
LOG_MODULE_REGISTER(sx1509b, CONFIG_GPIO_LOG_LEVEL);
|
||||||
|
|
||||||
|
#include "gpio_utils.h"
|
||||||
|
|
||||||
/* Number of pins supported by the device */
|
/* Number of pins supported by the device */
|
||||||
#define NUM_PINS 16
|
#define NUM_PINS 16
|
||||||
|
|
||||||
|
@ -52,6 +54,8 @@ struct sx1509b_drv_data {
|
||||||
|
|
||||||
/** Configuration data */
|
/** Configuration data */
|
||||||
struct sx1509b_config {
|
struct sx1509b_config {
|
||||||
|
/* gpio_driver_config needs to be first */
|
||||||
|
struct gpio_driver_config common;
|
||||||
const char *i2c_master_dev_name;
|
const char *i2c_master_dev_name;
|
||||||
u16_t i2c_slave_addr;
|
u16_t i2c_slave_addr;
|
||||||
};
|
};
|
||||||
|
@ -474,6 +478,9 @@ static const struct gpio_driver_api api_table = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct sx1509b_config sx1509b_cfg = {
|
static const struct sx1509b_config sx1509b_cfg = {
|
||||||
|
.common = {
|
||||||
|
.port_pin_mask = GPIO_PORT_PIN_MASK_FROM_NGPIOS(DT_INST_0_SEMTECH_SX1509B_NGPIOS),
|
||||||
|
},
|
||||||
.i2c_master_dev_name = DT_INST_0_SEMTECH_SX1509B_BUS_NAME,
|
.i2c_master_dev_name = DT_INST_0_SEMTECH_SX1509B_BUS_NAME,
|
||||||
.i2c_slave_addr = DT_INST_0_SEMTECH_SX1509B_BASE_ADDRESS,
|
.i2c_slave_addr = DT_INST_0_SEMTECH_SX1509B_BASE_ADDRESS,
|
||||||
};
|
};
|
||||||
|
|
|
@ -151,6 +151,7 @@
|
||||||
#define DT_INST_0_SEMTECH_SX1509B_BUS_NAME ""
|
#define DT_INST_0_SEMTECH_SX1509B_BUS_NAME ""
|
||||||
#define DT_INST_0_SEMTECH_SX1509B_INIT_OUT_LOW 0
|
#define DT_INST_0_SEMTECH_SX1509B_INIT_OUT_LOW 0
|
||||||
#define DT_INST_0_SEMTECH_SX1509B_INIT_OUT_HIGH 0
|
#define DT_INST_0_SEMTECH_SX1509B_INIT_OUT_HIGH 0
|
||||||
|
#define DT_INST_0_SEMTECH_SX1509B_NGPIOS 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef DT_INST_0_ST_LSM6DSL_LABEL
|
#ifndef DT_INST_0_ST_LSM6DSL_LABEL
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue