#include "common.h" //#include "../tpc/tpc_uart.h" #include "../bsp/bsp_cs1232.h" #include "../msp/msp_eeprom.h" #include "../msp/msp_id.h" #include "c_crc.h" struct global_param G; struct ts_eeprom_param eep_param; struct ts_eeprom_enc eep_enc; #define EEP_SECTOR_SIZE 0x200 #define EEP_PARAM_ADDR (EEP_SECTOR_SIZE * 1) #define EEP_ENC_ADDR (EEP_SECTOR_SIZE * 0) U8 L1_eeprom_read(U8 *buf,U8 *len) { U8 dlen = 0; L0_Iap_Read_array(EEP_PARAM_ADDR, (U8*)&eep_param, 2 + EEPROM_PARAM_DATA_MAX + 2); if(eep_param.filter == EEPROM_PARAM_FILTER) { dlen = eep_param.len - 2; crc16(eep_param.crc,(U8*)&eep_param,2+dlen); if(eep_param.crc[0] == eep_param.buf[dlen] && eep_param.crc[1] == eep_param.buf[dlen+1]) { L0_uart0_uc('#'); //Lc_buf_copy_uc((U8*)&G.p,(U8*)eep_param.buf,dlen); Lc_buf_copy_uc(buf,(U8*)eep_param.buf,dlen);//防止dlen>sizeof(G.P)引起的内存错误 *len = dlen; return 0; } } return 1; } U8 L1_eeprom_write(U8 *buf, U8 len) { U8 dlen = len; eep_param.filter = EEPROM_PARAM_FILTER; eep_param.len = dlen + 2; Lc_buf_copy_uc((U8*)eep_param.buf,buf,dlen); crc16(eep_param.crc, &eep_param, 2+dlen); eep_param.buf[dlen] = eep_param.crc[0]; eep_param.buf[dlen+1] = eep_param.crc[1]; L0_Iap_Erase(EEP_PARAM_ADDR); L0_Iap_Program_array(EEP_PARAM_ADDR, (U8*)&eep_param, 2 + dlen + 2); return 0; } int L3_mcu_id_ok(void) { U8 i = 0,crc[2]; U32 enc_key; //1.获取MCU_ID L0_id_get_rom(G.e.mcu_id); for(i=0;i= weight) { break; } } if(i