blob: 5cb3a2b9840be36f820f6fbf8340f35ecf9344b0 [file] [log] [blame]
/*
* Copyright (c) 2021 The Chromium OS Authors
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef ZEPHYR_DRIVERS_SENSOR_INA23X_H_
#define ZEPHYR_DRIVERS_SENSOR_INA23X_H_
#include <drivers/gpio.h>
#define INA23X_REG_CONFIG 0x00
#define INA23X_REG_SHUNT_VOLT 0x01
#define INA23X_REG_BUS_VOLT 0x02
#define INA23X_REG_POWER 0x03
#define INA23X_REG_CURRENT 0x04
#define INA23X_REG_CALIB 0x05
#define INA23X_REG_MASK 0x06
#define INA23X_REG_ALERT 0x07
struct ina23x_data {
const struct device *dev;
uint16_t current;
uint16_t bus_voltage;
uint16_t power;
#ifdef CONFIG_INA23X_TRIGGER
const struct device *gpio;
struct gpio_callback gpio_cb;
struct k_work work;
sensor_trigger_handler_t handler_alert;
#endif /* CONFIG_INA23X_TRIGGER */
};
struct ina23x_config {
const struct device *bus;
const uint16_t i2c_slv_addr;
uint16_t config;
uint16_t current_lsb;
uint16_t rshunt;
#ifdef CONFIG_INA23X_TRIGGER
bool trig_enabled;
uint16_t mask;
const struct gpio_dt_spec gpio_alert;
uint16_t alert_limit;
#endif /* CONFIG_INA23X_TRIGGER */
};
int ina23x_trigger_mode_init(const struct device *dev);
int ina23x_trigger_set(const struct device *dev,
const struct sensor_trigger *trig,
sensor_trigger_handler_t handler);
#endif /* ZEPHYR_DRIVERS_SENSOR_INA23X_H_ */