#ifndef __INA226_H__ #define __INA226_H__ #include "delay.h" #include "iic.h" #include "config.h" // 寄存器地址定义 #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 // I²C地址(A0/A1接地) #define INA226_ADDR 0x80 // 函数声明 void INA226_Init(uint16_t r_shunt, float max_current); void INA226_WriteReg(uint8_t reg, uint16_t value); uint16_t INA226_ReadReg(uint8_t reg); float INA226_ReadShuntVoltage(void); float INA226_ReadBusVoltage(void); float INA226_ReadCurrent(void); float INA226_ReadPower(void); #endif