2025-03-18 19:34:19 +08:00
|
|
|
|
#ifndef __INA226_H__
|
|
|
|
|
#define __INA226_H__
|
|
|
|
|
|
|
|
|
|
#include "delay.h"
|
|
|
|
|
|
|
|
|
|
#include "config.h"
|
2025-03-18 22:49:46 +08:00
|
|
|
|
#include "iic.h"
|
2025-03-18 19:34:19 +08:00
|
|
|
|
|
|
|
|
|
// 寄存器地址定义
|
2025-03-18 22:49:46 +08:00
|
|
|
|
#define CONFIG_REG 0x00
|
|
|
|
|
#define SHUNT_V_REG 0x01
|
|
|
|
|
#define BUS_V_REG 0x02
|
|
|
|
|
#define POWER_REG 0x03
|
|
|
|
|
#define CURRENT_REG 0x04
|
|
|
|
|
#define CAL_REG 0x05
|
|
|
|
|
#define ID_REG 0xFF
|
2025-03-18 19:34:19 +08:00
|
|
|
|
|
|
|
|
|
// I²C地址(A0/A1接地)
|
2025-03-18 22:49:46 +08:00
|
|
|
|
#define INA226_ADDR 0x80
|
2025-03-18 19:34:19 +08:00
|
|
|
|
|
|
|
|
|
// 函数声明
|
2025-03-19 17:25:17 +08:00
|
|
|
|
void INA226_Init (float r_shunt, float max_current);
|
2025-03-18 22:49:46 +08:00
|
|
|
|
void INA226_WriteReg (uint8_t reg, uint16_t value);
|
|
|
|
|
uint16_t INA226_ReadReg (uint8_t reg);
|
2025-03-18 19:34:19 +08:00
|
|
|
|
|
2025-03-18 22:49:46 +08:00
|
|
|
|
// float INA226_ReadShuntVoltage (void);
|
|
|
|
|
float INA226_ReadBusVoltage (void);
|
|
|
|
|
float INA226_ReadCurrent (void);
|
|
|
|
|
float INA226_ReadPower (void);
|
2025-03-18 19:34:19 +08:00
|
|
|
|
|
|
|
|
|
#endif
|