|
|
|
#include "app_config.h"
|
|
|
|
#include "../bsp/cs1232.h"
|
|
|
|
#include "../bsp/chipid.h"
|
|
|
|
#include "../msp/eeprom.h"
|
|
|
|
#include "../clib/clib.h"
|
|
|
|
GlobalParam G;
|
|
|
|
GlobalRegister R;
|
|
|
|
|
|
|
|
void L3_param_init(void)
|
|
|
|
{
|
|
|
|
G.debug = 1;
|
|
|
|
//station模式状态
|
|
|
|
G.st_status = 0; //0:none 1:wifi_ok 2:tcp_connect_ok
|
|
|
|
//station模式sid
|
|
|
|
Lc_strcpy(G.st_sid,"ccsens");
|
|
|
|
//station模式pwd
|
|
|
|
Lc_strcpy(G.st_pwd,"ccsens123");
|
|
|
|
//ap模式状态
|
|
|
|
G.ap_status = 0;//0: none 1: ap_ok 2:tcp_server_ok
|
|
|
|
//ap模式sid
|
|
|
|
Lc_strcpy(G.ap_sid,"cc_pen_ap");
|
|
|
|
//ap模式pwd
|
|
|
|
Lc_strcpy(G.ap_pwd,"ccsens123");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//读取reg内容,写入iap
|
|
|
|
void L3_reg_2_iap(void)
|
|
|
|
{
|
|
|
|
#if 0
|
|
|
|
iapData.slaver_id = R.p.slaver_id;
|
|
|
|
iapData.adc_ch_status = R.p.adc_ch_status;
|
|
|
|
iapData.weight_max = R.p.weight_max;
|
|
|
|
iapData.lmd = R.p.lmd;
|
|
|
|
iapData.adc_blur_mid = R.p.adc_blur_mid;
|
|
|
|
iapData.adc_blur_avg = R.p.adc_blur_avg;
|
|
|
|
iapData.adc_blur_shift[0] = R.p.adc_blur_shift[0];
|
|
|
|
iapData.adc_blur_shift[1] = R.p.adc_blur_shift[1];
|
|
|
|
iapData.adc_blur_shift[2] = R.p.adc_blur_shift[2];
|
|
|
|
iapData.adc_blur_threshold[0] = R.p.adc_blur_threshold[0];
|
|
|
|
iapData.adc_blur_threshold[1] = R.p.adc_blur_threshold[1];
|
|
|
|
//写入eeprom
|
|
|
|
if(L1_eep_write_block(D_EEP_PARAM_IN_SECTOR, D_EEP_PARAM_IN_BLOCK, (U8*)&iapData,sizeof(IapData),TRUE) == 0)
|
|
|
|
{
|
|
|
|
L0_uart0_sendstr("e2p write success");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
if(L1_eep_write_block(D_EEP_PARAM_IN_SECTOR, D_EEP_PARAM_IN_BLOCK, D_EEP_SECTOR_BLOCK_SIZE, (U8*)&R.p,sizeof(R.p),TRUE) == 0)
|
|
|
|
{
|
|
|
|
L0_uart0_sendstr("e2p write success");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
L0_uart0_sendstr("e2p write failed");
|
|
|
|
}
|
|
|
|
|
|
|
|
//读取iap内容,写入reg
|
|
|
|
void L3_iap_2_reg(void)
|
|
|
|
{
|
|
|
|
#if 0
|
|
|
|
if(L1_eep_read_block(D_EEP_PARAM_IN_SECTOR, D_EEP_PARAM_IN_BLOCK, (U8*)&iapData, NULL) == 1)
|
|
|
|
{
|
|
|
|
L0_uart0_sendstr("e2p read failed");
|
|
|
|
}
|
|
|
|
L0_uart0_sendstr("e2p read success");
|
|
|
|
R.p.slaver_id = iapData.slaver_id;
|
|
|
|
R.p.adc_ch_status = iapData.adc_ch_status;
|
|
|
|
R.p.weight_max = iapData.weight_max ;
|
|
|
|
R.p.lmd = iapData.lmd;
|
|
|
|
R.p.adc_blur_mid = iapData.adc_blur_mid;
|
|
|
|
R.p.adc_blur_avg = iapData.adc_blur_avg;
|
|
|
|
R.p.adc_blur_shift[0] = iapData.adc_blur_shift[0];
|
|
|
|
R.p.adc_blur_shift[1] = iapData.adc_blur_shift[1];
|
|
|
|
R.p.adc_blur_shift[2] = iapData.adc_blur_shift[2];
|
|
|
|
R.p.adc_blur_threshold[0] = iapData.adc_blur_threshold[0];
|
|
|
|
R.p.adc_blur_threshold[1] = iapData.adc_blur_threshold[1];
|
|
|
|
#endif
|
|
|
|
if(L1_eep_read_block(D_EEP_PARAM_IN_SECTOR, D_EEP_PARAM_IN_BLOCK, D_EEP_SECTOR_BLOCK_SIZE, (U8*)&R.p, NULL) == 0)
|
|
|
|
{
|
|
|
|
L0_uart0_sendstr("e2p read success");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
L0_uart0_sendstr("e2p read failed");
|
|
|
|
}
|
|
|
|
|
|
|
|
void L3_reg_reset(void)
|
|
|
|
{
|
|
|
|
R.p.adc_ch_status = ADC_status_ch2_Ready | ADC_status_ch3_Ready | ADC_status_ch4_Ready; //修改采集通道
|
|
|
|
R.p.slaver_id = D_UART0_485_SLAVER_ID;
|
|
|
|
R.p.weight_max = 500; //500kg
|
|
|
|
R.p.lmd = 2; //2mv/v
|
|
|
|
R.p.adc_blur_mid = 1;
|
|
|
|
R.p.adc_blur_avg = 6;
|
|
|
|
R.p.adc_blur_shift[0] = 0;
|
|
|
|
R.p.adc_blur_shift[1] = 2;
|
|
|
|
R.p.adc_blur_shift[2] = 4;
|
|
|
|
R.p.adc_blur_threshold[0] = 1600; //g
|
|
|
|
R.p.adc_blur_threshold[1] = 700; //g
|
|
|
|
}
|
|
|
|
|
|
|
|
void L3_reg_init(void)
|
|
|
|
{
|
|
|
|
//R.reserved1 = R.reserved2 = R.reserved3 = 0x55;
|
|
|
|
//R.zero = 0;
|
|
|
|
//R.status_eep_save = 0;
|
|
|
|
L3_reg_reset();
|
|
|
|
L3_iap_2_reg();
|
|
|
|
}
|
|
|
|
|