You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

87 lines
2.3 KiB

////////////////////////////////////////////////////////////////////////////
///@copyright Copyright (c) 2018, 传控科技 All rights reserved.
///-------------------------------------------------------------------------
/// @file bsp_drv.c
/// @brief bsp @ driver config
///-------------------------------------------------------------------------
/// @version 1.0
/// @author CC
/// @date 20180331
/// @note cc_AS_stc02
//////////////////////////////////////////////////////////////////////////////
#include "asp_para.h"
///#include "common.h"
#include "../bsp/bsp_config.h"
#include "msp_uart0.h"
#include "msp_eeprom.h"
/*********
v3.3
AA 38 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
#e2p read success
00 00 00 00 00 00 00 00 00 00
AA 38 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
#e2p read success
00 00 00 00 00 00 00 00 00 00
AA 38 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
#e2p read success
00 00 00 00 00 00 00 00 00 00
AA 38 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
#e2p read success
00 00 00 00 00 00 00 00 00 00
8ADC_SAMPLEADC_SAMPLEADC_SAMPLEADC_SAMPLE4E320 F408 2088 FA90 0000BC90 1502
**********/
TS_eeprom_param_ eep_param;
U8 L1_para_read(U8 *buf,U8 *len)
{
U8 dlen = 0;
L0_Iap_Read_array(EEP_PARAM_ADDR, (U8*)&eep_param, 2 + EEPROM_PARAM_DATA_MAX + 2);
/// L0_uartN_uchexArray(0,(u8 *)&eep_param,20);
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])
{
/// if()
//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_para_write(U8 *buf, U8 len)
{
U8 dlen = len;
eep_param.filter = EEPROM_PARAM_FILTER;////fxime
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);
L0_uart0_uc('&');
return 0;
}