|
|
@ -5,103 +5,106 @@ |
|
|
|
|
|
|
|
GlobalParam G; |
|
|
|
GlobalRegister R; |
|
|
|
int i; |
|
|
|
|
|
|
|
void L3_param_init(void) |
|
|
|
{ |
|
|
|
#if 0 |
|
|
|
int i; |
|
|
|
for(i=0;i<D_ch_max_num;i++) |
|
|
|
{ |
|
|
|
G.weight[i] = 0; |
|
|
|
} |
|
|
|
G.allweight = 0; |
|
|
|
G._total_weight = 0; |
|
|
|
G._total_zweight = 0; |
|
|
|
|
|
|
|
//L3_eeprom_read_param();
|
|
|
|
#endif |
|
|
|
} |
|
|
|
// void L3_param_init(void)
|
|
|
|
// {
|
|
|
|
// #if 0
|
|
|
|
// G.xx = 0;
|
|
|
|
// //L3_eeprom_read_param();
|
|
|
|
// #endif
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
//读取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"); |
|
|
|
} |
|
|
|
// 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"); |
|
|
|
} |
|
|
|
// //读取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_UART4_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
|
|
|
|
R.slave_id = 0x01; |
|
|
|
R.low_power_mode = 0; |
|
|
|
R.func_btn = 0; |
|
|
|
R.nfc.nfc_no[0] = 0; |
|
|
|
R.nfc.nfc_no[1] = 0; |
|
|
|
for(i=0;i<4;i++){ |
|
|
|
R.rfids[i].rfid_no[0] = 0; |
|
|
|
R.rfids[i].rfid_no[1] = 0; |
|
|
|
R.rfids[i].rssi = 0; |
|
|
|
R.rfids[i].ant = 0; |
|
|
|
}; |
|
|
|
|
|
|
|
//for test
|
|
|
|
// R.slave_id = 0x01;
|
|
|
|
// R.low_power_mode = 0;
|
|
|
|
// R.func_btn = 1;
|
|
|
|
// R.nfc.nfc_no[0] = 0x01;
|
|
|
|
// R.nfc.nfc_no[1] = 0x23;
|
|
|
|
// for(i=0;i<4;i++){
|
|
|
|
// R.rfids[i].rfid_no[0] = 0xA0;
|
|
|
|
// R.rfids[i].rfid_no[1] = 0xB0;
|
|
|
|
// R.rfids[i].rssi = 0x61;
|
|
|
|
// R.rfids[i].ant = i;
|
|
|
|
// };
|
|
|
|
} |
|
|
|
|
|
|
|
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(); |
|
|
|
//L3_iap_2_reg();
|
|
|
|
} |
|
|
|
|
|
|
|