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

driver ina219 header file More...

#include <stdio.h>
#include <stdint.h>
#include <string.h>
Include dependency graph for driver_ina219.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  ina219_handle_s
 ina219 handle structure definition More...
struct  ina219_info_s
 ina219 information structure definition More...

Macros

#define DRIVER_INA219_LINK_INIT(HANDLE, STRUCTURE)
 initialize ina219_handle_t structure
#define DRIVER_INA219_LINK_IIC_INIT(HANDLE, FUC)
 link iic_init function
#define DRIVER_INA219_LINK_IIC_DEINIT(HANDLE, FUC)
 link iic_deinit function
#define DRIVER_INA219_LINK_IIC_READ(HANDLE, FUC)
 link iic_read function
#define DRIVER_INA219_LINK_IIC_WRITE(HANDLE, FUC)
 link iic_write function
#define DRIVER_INA219_LINK_DELAY_MS(HANDLE, FUC)
 link delay_ms function
#define DRIVER_INA219_LINK_DEBUG_PRINT(HANDLE, FUC)
 link debug_print function

Typedefs

typedef struct ina219_handle_s ina219_handle_t
 ina219 handle structure definition
typedef struct ina219_info_s ina219_info_t
 ina219 information structure definition

Enumerations

enum  ina219_address_t {
  INA219_ADDRESS_0 = (0x40 << 1) , INA219_ADDRESS_1 = (0x41 << 1) , INA219_ADDRESS_2 = (0x42 << 1) , INA219_ADDRESS_3 = (0x43 << 1) ,
  INA219_ADDRESS_4 = (0x44 << 1) , INA219_ADDRESS_5 = (0x45 << 1) , INA219_ADDRESS_6 = (0x46 << 1) , INA219_ADDRESS_7 = (0x47 << 1) ,
  INA219_ADDRESS_8 = (0x48 << 1) , INA219_ADDRESS_9 = (0x49 << 1) , INA219_ADDRESS_A = (0x4A << 1) , INA219_ADDRESS_B = (0x4B << 1) ,
  INA219_ADDRESS_C = (0x4C << 1) , INA219_ADDRESS_D = (0x4D << 1) , INA219_ADDRESS_E = (0x4E << 1) , INA219_ADDRESS_F = (0x4F << 1)
}
 ina219 address enumeration definition More...
enum  ina219_bus_voltage_range_t { INA219_BUS_VOLTAGE_RANGE_16V = 0 , INA219_BUS_VOLTAGE_RANGE_32V = 1 }
 ina219 bus voltage enumeration definition More...
enum  ina219_pga_t { INA219_PGA_40_MV = 0 , INA219_PGA_80_MV = 1 , INA219_PGA_160_MV = 2 , INA219_PGA_320_MV = 3 }
 ina219 pga enumeration definition More...
enum  ina219_adc_mode_t {
  INA219_ADC_MODE_9_BIT_1_SAMPLES = 0x0 , INA219_ADC_MODE_10_BIT_1_SAMPLES = 0x1 , INA219_ADC_MODE_11_BIT_1_SAMPLES = 0x2 , INA219_ADC_MODE_12_BIT_1_SAMPLES = 0x3 ,
  INA219_ADC_MODE_12_BIT_2_SAMPLES = 0x9 , INA219_ADC_MODE_12_BIT_4_SAMPLES = 0xA , INA219_ADC_MODE_12_BIT_8_SAMPLES = 0xB , INA219_ADC_MODE_12_BIT_16_SAMPLES = 0xC ,
  INA219_ADC_MODE_12_BIT_32_SAMPLES = 0xD , INA219_ADC_MODE_12_BIT_64_SAMPLES = 0xE , INA219_ADC_MODE_12_BIT_128_SAMPLES = 0xF
}
 ina219 adc mode enumeration definition More...
enum  ina219_mode_t {
  INA219_MODE_POWER_DOWN = 0x0 , INA219_MODE_SHUNT_VOLTAGE_TRIGGERED = 0x1 , INA219_MODE_BUS_VOLTAGE_TRIGGERED = 0x2 , INA219_MODE_SHUNT_BUS_VOLTAGE_TRIGGERED = 0x3 ,
  INA219_MODE_ADC_OFF = 0x4 , INA219_MODE_SHUNT_VOLTAGE_CONTINUOUS = 0x5 , INA219_MODE_BUS_VOLTAGE_CONTINUOUS = 0x6 , INA219_MODE_SHUNT_BUS_VOLTAGE_CONTINUOUS = 0x7
}
 ina219 mode enumeration definition More...

Functions

uint8_t ina219_info (ina219_info_t *info)
 get chip's information
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_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_init (ina219_handle_t *handle)
 initialize the chip
uint8_t ina219_deinit (ina219_handle_t *handle)
 close the chip
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_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_set_calibration (ina219_handle_t *handle, uint16_t data)
 set the calibration
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_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

Detailed Description

driver ina219 header 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.h.