/********************************************************************************************************* * 模块名称:IM1253E.h * 摘 要:电能测量芯片驱动应用 * 当前版本:1.0.0 * 作 者:anycrying * 完成日期:2024年04月09日 * 内 容: * 注 意: ********************************************************************************************************** * 取代版本: * 作 者: * 完成日期: * 修改内容: * 修改文件: *********************************************************************************************************/ #ifndef __IM1253E_H #define __IM1253E_H #include "board_cfg.h" #include "stdint.h" //IM1253E寄存器定义 #define V_REG_ADDR 0x0048 //电压 #define I_REG_ADDR 0x0049 //电流 #define W_REG_ADDR 0x004A //有功功率 #define KWh_REG_ADDR 0x004B //有功总电量 #define Q_REG_ADDR 0x004C //功率因数 #define CO2_REG_ADDR 0x004D //二氧化碳排量 #define T_REG_ADDR 0x004E //温度 #define Hz_REG_ADDR 0x004F //频率 #define Ad_Bd_REG_ADDR 0x0004 //地址及波特率 #define V_Unit 0.0001 //电压单位0.0001V #define I_Unit 0.0001 //电流单位0.0001A #define W_Unit 0.0001 //有功功率单位0.0001W #define KWh_Unit 0.0001 //有功总电量0.0001KWh #define Q_Unit 0.001 //功率因数单位0.001 #define CO2_Unit 0.0001 //二氧化碳排量单位0.0001Kg #define T_Unit 0.01 //电压单位0.01℃ #define Hz_Unit 0.01 //电压单位0.01Hz #define Device_addr_IM1253E 0x01 //IM1253E的地址 #define cmd_read_IM1253E 0x03 //读一个或多个寄存器的值 #define cmd_write_IM1253E 0x10 //写一个或多个寄存器的值 /********************************************************************************************************* * 枚举结构体 *********************************************************************************************************/ /********************************************************************************************************* * API函数声明 *********************************************************************************************************/ uint16_t CRC_calculate_function(uint8_t len); void Read_IM1253E_REG(uint8_t dev_addr,uint16_t reg_addr,uint8_t len); void Write_IM1253E_REG(uint8_t dev_addr,uint16_t reg_addr,uint8_t *pt,uint8_t len); #if SUPPORT_STM32_ADC uint32_t read_voltage(uint8_t channel); #endif #endif