LibDriver INA219
Loading...
Searching...
No Matches
driver_ina219.c File Reference

driver ina219 source file More...

#include "driver_ina219.h"
#include <math.h>
Include dependency graph for driver_ina219.c:

Go to the source code of this file.

Macros

#define CHIP_NAME   "Texas Instruments INA219"
 chip information definition
#define MANUFACTURER_NAME   "Texas Instruments"
#define SUPPLY_VOLTAGE_MIN   3.0f
#define SUPPLY_VOLTAGE_MAX   5.5f
#define MAX_CURRENT   1.0f
#define TEMPERATURE_MIN   -25.0f
#define TEMPERATURE_MAX   85.0f
#define DRIVER_VERSION   1000
#define INA219_REG_CONF   0x00
 chip register definition
#define INA219_REG_SHUNT_VOLTAGE   0x01
#define INA219_REG_BUS_VOLTAGE   0x02
#define INA219_REG_POWER   0x03
#define INA219_REG_CURRENT   0x04
#define INA219_REG_CALIBRATION   0x05

Functions

uint8_t ina219_set_resistance (ina219_handle_t *handle, double resistance)
 set the resistance
uint8_t ina219_get_resistance (ina219_handle_t *handle, double *resistance)
 get the resistance
uint8_t ina219_set_addr_pin (ina219_handle_t *handle, ina219_address_t addr_pin)
 set the iic address pin
uint8_t ina219_get_addr_pin (ina219_handle_t *handle, ina219_address_t *addr_pin)
 get the iic address pin
uint8_t ina219_soft_reset (ina219_handle_t *handle)
 soft reset the chip
uint8_t ina219_set_bus_voltage_range (ina219_handle_t *handle, ina219_bus_voltage_range_t range)
 set the bus voltage range
uint8_t ina219_get_bus_voltage_range (ina219_handle_t *handle, ina219_bus_voltage_range_t *range)
 get the bus voltage range
uint8_t ina219_set_pga (ina219_handle_t *handle, ina219_pga_t pga)
 set the pga
uint8_t ina219_get_pga (ina219_handle_t *handle, ina219_pga_t *pga)
 get the pga
uint8_t ina219_set_bus_voltage_adc_mode (ina219_handle_t *handle, ina219_adc_mode_t mode)
 set the bus voltage adc mode
uint8_t ina219_get_bus_voltage_adc_mode (ina219_handle_t *handle, ina219_adc_mode_t *mode)
 get the bus voltage adc mode
uint8_t ina219_set_shunt_voltage_adc_mode (ina219_handle_t *handle, ina219_adc_mode_t mode)
 set the shunt voltage adc mode
uint8_t ina219_get_shunt_voltage_adc_mode (ina219_handle_t *handle, ina219_adc_mode_t *mode)
 get the shunt voltage adc mode
uint8_t ina219_set_mode (ina219_handle_t *handle, ina219_mode_t mode)
 set the mode
uint8_t ina219_get_mode (ina219_handle_t *handle, ina219_mode_t *mode)
 get the mode
uint8_t ina219_read_shunt_voltage (ina219_handle_t *handle, int16_t *raw, float *mV)
 read the shunt voltage
uint8_t ina219_read_bus_voltage (ina219_handle_t *handle, uint16_t *raw, float *mV)
 read the bus voltage
uint8_t ina219_read_current (ina219_handle_t *handle, int16_t *raw, float *mA)
 read the current
uint8_t ina219_read_power (ina219_handle_t *handle, uint16_t *raw, float *mW)
 read the power
uint8_t ina219_get_calibration (ina219_handle_t *handle, uint16_t *data)
 get the calibration
uint8_t ina219_calculate_calibration (ina219_handle_t *handle, uint16_t *calibration)
 calculate the calibration
uint8_t ina219_set_calibration (ina219_handle_t *handle, uint16_t data)
 set the calibration
uint8_t ina219_init (ina219_handle_t *handle)
 initialize the chip
uint8_t ina219_deinit (ina219_handle_t *handle)
 close the chip
uint8_t ina219_set_reg (ina219_handle_t *handle, uint8_t reg, uint16_t data)
 set the chip register
uint8_t ina219_get_reg (ina219_handle_t *handle, uint8_t reg, uint16_t *data)
 get the chip register
uint8_t ina219_info (ina219_info_t *info)
 get chip's information

Detailed Description

driver ina219 source file

Copyright (c) 2015 - present LibDriver All rights reserved

The MIT License (MIT)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Version
1.0.0
Author
Shifeng Li
Date
2021-06-13

history

Date Version Author Description
2021/06/13 1.0 Shifeng Li first upload

Definition in file driver_ina219.c.

Macro Definition Documentation

◆ CHIP_NAME

#define CHIP_NAME   "Texas Instruments INA219"

chip information definition

chip name

Definition at line 43 of file driver_ina219.c.

◆ DRIVER_VERSION

#define DRIVER_VERSION   1000

driver version

Definition at line 50 of file driver_ina219.c.

◆ INA219_REG_BUS_VOLTAGE

#define INA219_REG_BUS_VOLTAGE   0x02

bus voltage register

Definition at line 57 of file driver_ina219.c.

◆ INA219_REG_CALIBRATION

#define INA219_REG_CALIBRATION   0x05

calibration register

Definition at line 60 of file driver_ina219.c.

◆ INA219_REG_CONF

#define INA219_REG_CONF   0x00

chip register definition

configuration register

Definition at line 55 of file driver_ina219.c.

◆ INA219_REG_CURRENT

#define INA219_REG_CURRENT   0x04

current register

Definition at line 59 of file driver_ina219.c.

◆ INA219_REG_POWER

#define INA219_REG_POWER   0x03

power register

Definition at line 58 of file driver_ina219.c.

◆ INA219_REG_SHUNT_VOLTAGE

#define INA219_REG_SHUNT_VOLTAGE   0x01

shunt voltage register

Definition at line 56 of file driver_ina219.c.

◆ MANUFACTURER_NAME

#define MANUFACTURER_NAME   "Texas Instruments"

manufacturer name

Definition at line 44 of file driver_ina219.c.

◆ MAX_CURRENT

#define MAX_CURRENT   1.0f

chip max current

Definition at line 47 of file driver_ina219.c.

◆ SUPPLY_VOLTAGE_MAX

#define SUPPLY_VOLTAGE_MAX   5.5f

chip max supply voltage

Definition at line 46 of file driver_ina219.c.

◆ SUPPLY_VOLTAGE_MIN

#define SUPPLY_VOLTAGE_MIN   3.0f

chip min supply voltage

Definition at line 45 of file driver_ina219.c.

◆ TEMPERATURE_MAX

#define TEMPERATURE_MAX   85.0f

chip max operating temperature

Definition at line 49 of file driver_ina219.c.

◆ TEMPERATURE_MIN

#define TEMPERATURE_MIN   -25.0f

chip min operating temperature

Definition at line 48 of file driver_ina219.c.