#include "uart.h" #include "addr.h" #include "debug_printf.h" #include "bl24c512.h" #include "WaterMetermanager.h" #include "Led.h" #include "keywd.h" #include "update.h" #include "Flash.h" #include "PHY.h" #include "rtc_ext.h" #include "hbframe.h" #define DATA_INVALID 0xFF //无效 #define DATA_VALID 0xAA //有效 #define REPORT_SUCESS_FLAG 0xBB //上报成功 #define REPORT_READY_FLAG 0xFF //未上报的状态 #define DATA_VALID_POS 0 #define DATA_COUNT_POS 1 #define DATA_RPFLAG_POS 3 #define DATA_YEARFLAG_POS 4 #define DATA_MONTHFLAG_POS 5 #define DATA_DAYFLAG_POS 6 #define DATA_HOURFLAG_POS 7 #define DATA_CRCFLAG_POS 8 #define DATA_CRC_LEN 8 //未用 extern bool I2C_eeprom_write_buf(u16 startAddr, u8 * buf, u16 length); extern bool I2C_eeprom_read_buf(u16 addr, u8 * buf, u16 length); #pragma pack(1) struct datacount_struct { u8 valid; //0 u16 count; //1 u8 rpflag; //3 u8 year; //4 u8 month; //5 u8 day; //6 u8 hour; //7 u8 crc; //8 }; #pragma pack() static u16 count = 0; static u16 rpcount = 0; static u16 rphistroycount = 0; static u16 index_rphistroycount = 0; static struct datacount_struct datacount[DATA_COUNT_MAX]; u16 datacount_getcurcount() { return count; } //得到当前上报索引值 u16 datacount_getrpcurcount() { return rpcount; } //得到历史上报索引值 u16 datacount_getrphistroycount() { return rphistroycount; } //判断当前数据抄成功 bool datacount_dlsucess(u8 year,u8 month,u8 day,u8 hour) { u16 i = 0; for(i=0;i=0x21 ) { if(datacount[i].month <= 0x12 && datacount[i].day <= 0x31 && datacount[i].hour <= 0x24) //数据有效 { rphistroycount = i; index_rphistroycount++; return true; } } } index_rphistroycount++; } index_rphistroycount = 0; return false; } void datacount_read() { u16 i = 0; u8 valid= 0; I2C_eeprom_read_buf(0,(u8*)&datacount[0],sizeof(datacount)); for(i = 0;i