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.
608 lines
17 KiB
608 lines
17 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 "app_weight.h"
|
|
#include "app_config.h"
|
|
#include "debug_drv.h"
|
|
#include "msp_eeprom.h"
|
|
|
|
#define D_0kg 0
|
|
#define D_20kg 200///0x00c8
|
|
#define D_85kg 850////0x0352
|
|
|
|
/*
|
|
#define D_Rsensor_out_D_0kg 0x18D9
|
|
#define D_Rsensor_out_D_20kg 0x1B8B
|
|
#define D_Rsensor_out_D_85kg 0x244D
|
|
*/
|
|
|
|
#define D_Rsensor_out_D_0kg 0x18D9
|
|
#define D_Rsensor_out_D_20kg 0x1c2c
|
|
#define D_Rsensor_out_D_85kg 0x26f9
|
|
|
|
|
|
|
|
|
|
///#define D_20kg 190
|
|
///cc 2023/04/06--6:41:48 西安方块 传感器 根据传感器调配 程序应该专门数据结构
|
|
|
|
|
|
///cc 2023/04/06--7:50:26 应该是tst_weight.out6的值
|
|
///cc 2023/04/09--8:11:50 adc改为out 因为到了weight这一层 已经不合适用adc,adc的和值 输出out给了weight来做运算
|
|
|
|
TS_weight_SPara_ ts_weight_SPara =
|
|
{
|
|
'W',//0 1 u8 rev1;
|
|
'E',//1 2 u8 rev2;
|
|
D_0kg ,D_Rsensor_out_D_0kg,
|
|
D_20kg,D_Rsensor_out_D_20kg,
|
|
D_85kg,D_Rsensor_out_D_85kg,
|
|
|
|
//2 3 TS_weight_point_ zerows[3]; ///4x3=12 手工清零后的参数, 没有清零或者出错恢复到和出厂设置一样,需要实时保存
|
|
'A',//3 4 u8 rev3;
|
|
' ',//4 5 u8 rev4;
|
|
|
|
};
|
|
TS_TASK_weight_ tst_weight;
|
|
|
|
|
|
#define D_task_WEIGHT_add 12
|
|
#define D_task_WEIGHT_CAL 13
|
|
#define D_task_WEIGHT_get 14
|
|
#define D_task_WEIGHT_zero 15
|
|
///#define D_task_WEIGHT_CAL 124
|
|
|
|
#define D_task_WEIGHT_out 45
|
|
#define D_task_WEIGHT_Sline 11
|
|
#define D_task_WEIGHT_getADC 22
|
|
///#define D_task_WEIGHT_CAL 33
|
|
////#define D_task_WEIGHT_Sline
|
|
|
|
|
|
|
|
void L2_task_weight_init(u8 openclose)
|
|
{
|
|
if(openclose)
|
|
{
|
|
L0_ADS1213_INIT(D_ADS1213_GAIN_128);
|
|
L2_task_adc_init(0);
|
|
L2_task_adc_init(1);
|
|
L2_task_adc_init(2);
|
|
L2_task_adc_init(3);
|
|
|
|
}else
|
|
{
|
|
tst_weight.pSPara = &ts_weight_SPara;
|
|
}
|
|
/*
|
|
L2_task_adc_SAinit(0,&S.sd.ADC_shiftaverage_a,&S.sd.ADC_shiftaverage_b);
|
|
L2_task_adc_SAinit(1,&S.sd.ADC_shiftaverage_a,&S.sd.ADC_shiftaverage_b);
|
|
L2_task_adc_SAinit(2,&S.sd.ADC_shiftaverage_a,&S.sd.ADC_shiftaverage_b);
|
|
L2_task_adc_SAinit(3,&S.sd.ADC_shiftaverage_a,&S.sd.ADC_shiftaverage_b);
|
|
|
|
|
|
|
|
|
|
ts_adc_samples[0].offset = S.sd.offset[0];
|
|
ts_adc_samples[1].offset = S.sd.offset[1];
|
|
ts_adc_samples[2].offset = S.sd.offset[2];
|
|
ts_adc_samples[3].offset = S.sd.offset[3];
|
|
|
|
|
|
*/
|
|
|
|
|
|
}
|
|
|
|
void L3_task_weight_init(void)
|
|
{
|
|
//显示任务初始化
|
|
L1_task_reg_clear(&tst_weight.task);
|
|
L3_task_s_go(tst_weight,D_task_init);
|
|
L2_task_weight_init(1);
|
|
///Lc_buf_from_const_uc(U8 * d, const U8 * s, U16 num)
|
|
///tst_weight.pSPara->ts_WPoint
|
|
}
|
|
|
|
#define D_debug_ch D_Wch2
|
|
///L3_task_weight_handler(&tst_weight);
|
|
void L3_task_weight_handler(TS_TASK_weight_ *s)
|
|
{
|
|
L2_task_adc_sample(&ts_adc_samples[D_Wch1]);
|
|
|
|
L2_task_adc_sample(&ts_adc_samples[D_Wch2]);
|
|
|
|
L2_task_adc_sample(&ts_adc_samples[D_Wch3]);
|
|
|
|
L2_task_adc_sample(&ts_adc_samples[D_Wch4]);
|
|
|
|
TTSS_Task_init():
|
|
L0_waitFree_uartN(0);
|
|
|
|
/*
|
|
printf("\r\nR.sd.zeroout= %d = 0x%4x offset %d = 0x%4x", R.sd.zeroout, R.sd.zeroout,ts_adc_samples[0].offset,ts_adc_samples[0].offset);
|
|
printf("\r\nR.sd.zeroout= %d = 0x%4x offset %d = 0x%4x", R.sd.zeroout, R.sd.zeroout,ts_adc_samples[1].offset,ts_adc_samples[1].offset);
|
|
printf("\r\nR.sd.zeroout= %d = 0x%4x offset %d = 0x%4x", R.sd.zeroout, R.sd.zeroout,ts_adc_samples[2].offset,ts_adc_samples[2].offset);
|
|
printf("\r\nR.sd.zeroout= %d = 0x%4x offset %d = 0x%4x", R.sd.zeroout, R.sd.zeroout,ts_adc_samples[3].offset,ts_adc_samples[3].offset);
|
|
|
|
printf('4');
|
|
|
|
*/
|
|
s->slow = 0;
|
|
s->zero = 0;s->kgx10_zero = 0;
|
|
printfs(" L3_task_weight_handler ");
|
|
|
|
L2_task_go(D_task_WEIGHT_get);
|
|
TTSS_Task_step(D_task_WEIGHT_get):
|
|
if(1 == ts_adc_samples[D_Wch4].ok)
|
|
{//
|
|
ts_adc_samples[0].ok = 0;
|
|
ts_adc_samples[1].ok = 0;
|
|
ts_adc_samples[2].ok = 0;
|
|
ts_adc_samples[3].ok = 0;
|
|
s->slow ++;
|
|
// L0_uart0_uc('%');
|
|
L2_task_go(D_task_WEIGHT_Sline);
|
|
}
|
|
TTSS_Task_step(D_task_WEIGHT_Sline):
|
|
if (s->slow >= 1)////采样减速
|
|
{s->slow = 0;
|
|
///调用asp——adc中的输出 out3
|
|
/************/
|
|
///cc 2023/04/06--8:9:18 选择使用哪一条滤波线
|
|
|
|
ts_adc_samples[0].out5 = ts_adc_samples[0].ts_SAa.out4_shift;
|
|
ts_adc_samples[1].out5 = ts_adc_samples[1].ts_SAa.out4_shift;
|
|
ts_adc_samples[2].out5 = ts_adc_samples[2].ts_SAa.out4_shift;
|
|
ts_adc_samples[3].out5 = ts_adc_samples[3].ts_SAa.out4_shift;
|
|
|
|
L2_task_go(D_task_WEIGHT_getADC);
|
|
}else
|
|
{
|
|
L2_task_go(D_task_WEIGHT_get);
|
|
}
|
|
//L2_task_go(D_task_WEIGHT_getADC);
|
|
TTSS_Task_step(D_task_WEIGHT_getADC):
|
|
|
|
|
|
////四个传感器相加后平均
|
|
tst_weight.sum32 = ts_adc_samples[0].out5;
|
|
tst_weight.sum32 += ts_adc_samples[1].out5;
|
|
tst_weight.sum32 += ts_adc_samples[2].out5;
|
|
tst_weight.sum32 += ts_adc_samples[3].out5;
|
|
|
|
tst_weight.out6 = tst_weight.sum32 >>2;
|
|
|
|
L2_task_go(D_task_WEIGHT_CAL);
|
|
TTSS_Task_step(D_task_WEIGHT_CAL):
|
|
|
|
tst_weight.adc32 = tst_weight.out6;
|
|
|
|
L3_task_weight_cal();
|
|
|
|
L2_task_go(D_task_WEIGHT_out);
|
|
TTSS_Task_step(D_task_WEIGHT_out):
|
|
if(tst_weight.kgx10 > tst_weight.kgx10_zero)
|
|
{
|
|
s->kgx10_out = s->kgx10 - s->kgx10_zero;
|
|
}else
|
|
{
|
|
s->kgx10_out = 0 ;
|
|
}
|
|
//// D_LED1_REV(); L4_weight_out(); D_LED1_REV();
|
|
|
|
|
|
|
|
/// L4_weight_print();///需要调试的时候打开!!!!!!!!!!!!!!!
|
|
L2_task_Tdelay_go(D_Tdelay_200ms, D_task_WEIGHT_get);
|
|
/// L2_task_go(D_task_WEIGHT_get);
|
|
TTSS_Task_step(D_task_WEIGHT_zero):
|
|
|
|
|
|
L2_task_go(D_task_WEIGHT_get);
|
|
TTSS_Task_end();
|
|
}
|
|
|
|
|
|
void L3_task_weight_cal(void)
|
|
{
|
|
if(tst_weight.adc32 <= (vU32)S.weight_SPara.ts_WPoint[1].adc)
|
|
{
|
|
if(tst_weight.adc32 <= (vU32)S.weight_SPara.ts_WPoint[0].adc )
|
|
{
|
|
tst_weight.adc32 = (vU32)S.weight_SPara.ts_WPoint[0].adc;
|
|
}
|
|
///0-0-40KG
|
|
tst_weight.t32a = (tst_weight.adc32-(vU32)S.weight_SPara.ts_WPoint[0].adc);////有可能<0
|
|
tst_weight.t32b = (vU32)(S.weight_SPara.ts_WPoint[1].adc-S.weight_SPara.ts_WPoint[0].adc);
|
|
tst_weight.t32a *= (vU32)(S.weight_SPara.ts_WPoint[1].kg - S.weight_SPara.ts_WPoint[0].kg);
|
|
tst_weight.t32a /= tst_weight.t32b;
|
|
|
|
}else
|
|
{ ///40KG 80KG
|
|
tst_weight.t32a = (vU32)(tst_weight.adc32-S.weight_SPara.ts_WPoint[1].adc);////有可能大于b
|
|
tst_weight.t32b = (vU32)(S.weight_SPara.ts_WPoint[2].adc-S.weight_SPara.ts_WPoint[1].adc);
|
|
tst_weight.t32a *= (vU32)(S.weight_SPara.ts_WPoint[2].kg-S.weight_SPara.ts_WPoint[1].kg) ;
|
|
tst_weight.t32a /= tst_weight.t32b;
|
|
tst_weight.t32a += (vU32)S.weight_SPara.ts_WPoint[1].kg;
|
|
|
|
}
|
|
tst_weight.kgx10 = (vU16)tst_weight.t32a;
|
|
}
|
|
|
|
/*
|
|
|
|
#define D_0kg 0
|
|
#define D_20kg 200///0x00c8
|
|
#define D_85kg 850////0x0352
|
|
|
|
#define D_Rsensor_out_D_0kg 0x18D9
|
|
#define D_Rsensor_out_D_20kg 0x1B8B
|
|
#define D_Rsensor_out_D_85kg 0x244D
|
|
|
|
*/
|
|
|
|
void L3_weight_ONdebug(u8 filter)//// ON listen function
|
|
{
|
|
if(filter == pd->filter)
|
|
{
|
|
///filter num d1 d2 d3 ....dn
|
|
////FE 08 11 22 33 44 55 66 77 88
|
|
///printf("\r\nDdebug:FD R1 R2 R3 R4 R5 R6 ocr FD->");
|
|
///printf4("22 ch:(%2X)-%2X S %2X=%2X\r\n",(int)pd->R1,(int)pd->R2,(int)pd->R3,(int)pd->ocr);
|
|
L1_uartD_Arrayhex((u8*)pd,9);
|
|
switch (pd->ocr)
|
|
{
|
|
case 0x20:
|
|
////选择一个砝码,发送0x12指令,然后读取的数据 和砝码的重量使用 20 21 22参数来
|
|
///fx R1 R2 R3R4 R5R6 ocr
|
|
///Fe ch 00 2233 4455 20 0x2233 kg= 0x4455 adc
|
|
///Fe 00 00 0000 18D9 20
|
|
///Fe 01 00 00c8 1c2c 20
|
|
///Fe 02 00 0352 26f9 20
|
|
/// 0352 26f9
|
|
///00c8 1c2c
|
|
///Fe 22 33 44 55 21
|
|
///Fe 22 33 44 55 22
|
|
if(pd->R1 < 3)
|
|
ts_weight_SPara.ts_WPoint[pd->R1].kg = D_2uc_u16(pd->R3,pd->R4);
|
|
ts_weight_SPara.ts_WPoint[pd->R1].adc = D_2uc_u16(pd->R5,pd->R6);
|
|
|
|
printf5("\r\nset %d: %4x(%6d) %4x(%6d)\r\n",(int)pd->R1,
|
|
ts_weight_SPara.ts_WPoint[pd->R1].kg,ts_weight_SPara.ts_WPoint[pd->R1].kg,
|
|
ts_weight_SPara.ts_WPoint[pd->R1].adc,ts_weight_SPara.ts_WPoint[pd->R1].adc); {
|
|
|
|
}
|
|
|
|
L3_R_2_S();
|
|
L0_Iap_Program_array(D_EEP_BASE,D_struct2U8(S),D_S_LEN);
|
|
break;
|
|
case 0x35: ///// '5'///
|
|
////选择一个砝码,发送0x12指令,然后读取的数据 和砝码的重量使用 20 21 22参数来
|
|
///fx R1 R2 R3R4 R5R6 ocr
|
|
///Fe ch 00 2233 4455 35 kg= 0x2233
|
|
|
|
////校准20kg 输入 Fe 01 00 00 c8 02 00 35
|
|
///Fe 01 00 00 c8 02 00 35 kg= 0x00c8=200d///需要校准的重量的 20kg 200d=0xc8
|
|
///校准20kg 输入 Fe 01 00 00 c8 02 00 35
|
|
|
|
/// Fe 00 00 00 00 01 00 35 校准零点 不需要上电即可
|
|
/// Fe 01 00 00 c8 02 00 35 20kg 放置20kg 然后输入
|
|
/// Fe 02 00 01 d6 03 00 35 47kg 10个3kg砝码实际是27kg+20kg
|
|
////如果需要上位机设置 需要在上位机的串口 加上D4 D代表chuandi
|
|
if(pd->R1 < 3)
|
|
{
|
|
ts_weight_SPara.ts_WPoint[pd->R1].kg = D_2uc_u16(pd->R3,pd->R4);
|
|
ts_weight_SPara.ts_WPoint[pd->R1].adc = tst_weight.adc32;////使用当前采样值
|
|
|
|
printf5("\r\nset %d: %4x(%6d) %4x(%6d)\r\n",(int)pd->R1,
|
|
ts_weight_SPara.ts_WPoint[pd->R1].kg,ts_weight_SPara.ts_WPoint[pd->R1].kg,
|
|
ts_weight_SPara.ts_WPoint[pd->R1].adc,ts_weight_SPara.ts_WPoint[pd->R1].adc);
|
|
}
|
|
|
|
L3_R_2_S();
|
|
L0_Iap_Program_array(D_EEP_BASE,D_struct2U8(S),D_S_LEN);
|
|
break;
|
|
|
|
case 0x21: /// 清零指令 把当前的重量值作为0点; 可以在pad上配置参数
|
|
////Fe 223344556677 21
|
|
|
|
L4_weight_print();
|
|
tst_weight.kgx10_zero = tst_weight.kgx10;
|
|
printf2("\r\n kgx10_zero= %4x(%4d)",tst_weight.kgx10_zero,tst_weight.kgx10_zero);
|
|
break;
|
|
|
|
case 0x23:
|
|
///Fe 11 22 33 44 55 66 23
|
|
TTSS_run_times(3)
|
|
{
|
|
printf5("\r\n%d: %4x(%4d ) %4x(%6d)\r\n",(int)tst_v.i,
|
|
ts_weight_SPara.ts_WPoint[tst_v.i].kg,ts_weight_SPara.ts_WPoint[tst_v.i].kg,
|
|
ts_weight_SPara.ts_WPoint[tst_v.i].adc,ts_weight_SPara.ts_WPoint[tst_v.i].adc);
|
|
}
|
|
break;
|
|
|
|
case 0x32: ///读取当前的重量和传感器数值
|
|
///Fe 223344556677 12
|
|
printfs("\r\n ");
|
|
L4_weight_print();
|
|
break;
|
|
|
|
case 0x33: ///读取当前的重量和传感器数值 hex
|
|
///Fe 223344556677 12
|
|
D_LED1_REV();
|
|
L4_weight_out();
|
|
D_LED1_REV();
|
|
break;
|
|
|
|
default:
|
|
printfs(" pp error\r\n ");
|
|
break;
|
|
};
|
|
printfs("333");
|
|
}
|
|
}
|
|
void L4_weight_print(void)
|
|
{
|
|
L1_uartD_ushex(ts_adc_samples[0].out1_adc);L1_uartD_uc(' ');
|
|
L1_uartD_ushex(ts_adc_samples[1].out1_adc);L1_uartD_uc(' ');
|
|
L1_uartD_ushex(ts_adc_samples[2].out1_adc);L1_uartD_uc(' ');
|
|
L1_uartD_ushex(ts_adc_samples[3].out1_adc);L1_uartD_uc(' ');
|
|
|
|
/* L1_uartD_uc('|');L1_uartD_uc(' ');
|
|
L1_uartD_ushex(ts_adc_samples[0].out2_offset);L1_uartD_uc(' ');////调整偏移量后的值
|
|
L1_uartD_ushex(ts_adc_samples[1].out2_offset);L1_uartD_uc(' ');
|
|
L1_uartD_ushex(ts_adc_samples[2].out2_offset);L1_uartD_uc(' ');
|
|
L1_uartD_ushex(ts_adc_samples[3].out2_offset);L1_uartD_uc(' ');
|
|
|
|
L1_uartD_ushex(ts_adc_samples[0].out5);L1_uartD_uc(' ');////调整偏移量后的值
|
|
L1_uartD_ushex(ts_adc_samples[1].out5);L1_uartD_uc(' ');
|
|
L1_uartD_ushex(ts_adc_samples[2].out5);L1_uartD_uc(' ');
|
|
L1_uartD_ushex(ts_adc_samples[3].out5);L1_uartD_uc(' ');
|
|
|
|
*/
|
|
|
|
L1_uartD_uc('|');L1_uartD_uc(' ');
|
|
L1_uartD_ushex((vU16)tst_weight.adc32); L1_uartD_uc(' ');///参与运算的值
|
|
printf2(" (%d)%4x ", tst_weight.kgx10,tst_weight.kgx10);
|
|
printf2("out (%d)%4x\r\n", tst_weight.kgx10_out,tst_weight.kgx10_out);
|
|
}
|
|
|
|
TS_weight_out_ ts_weight_out;
|
|
|
|
|
|
void L4_weight_out(void)
|
|
{
|
|
ts_weight_out.fx = 0x55;
|
|
ts_weight_out.sensor_adc[0]=ts_adc_samples[0].out1_adc;
|
|
ts_weight_out.sensor_adc[1]=ts_adc_samples[1].out1_adc;
|
|
ts_weight_out.sensor_adc[2]=ts_adc_samples[2].out1_adc;
|
|
ts_weight_out.sensor_adc[3]=ts_adc_samples[3].out1_adc;
|
|
ts_weight_out.kgx10_out = tst_weight.kgx10_out;
|
|
ts_weight_out.adc32= tst_weight.adc32;////采样值用作校准时使用
|
|
ts_weight_out.ocr =0x33;
|
|
#if 0
|
|
ts_weight_out.num = 17;
|
|
#else
|
|
|
|
ts_weight_out.num = 15;
|
|
#endif
|
|
ts_weight_out.out6= tst_weight.out6;
|
|
L1_uartD_Array((u8 *)&ts_weight_out,ts_weight_out.num);
|
|
|
|
|
|
}
|
|
|
|
#if 0
|
|
|
|
void L3_adc_zero(void)
|
|
{
|
|
L3_out_zero(0);
|
|
L3_out_zero(1);
|
|
L3_out_zero(2);
|
|
L3_out_zero(3);
|
|
|
|
// printf("\r\niapData.zeroout= %d = 0x%4x\r\n", iapData.zeroout, iapData.zeroout);
|
|
// printf("\r\nR.sd.zeroout= %d = 0x%4x offset %d = 0x%4x\r\n", R.sd.zeroout, R.sd.zeroout,ts_adc_samples[0].offset,ts_adc_samples[0].offset);
|
|
/*
|
|
S.sd.offset[0] = ts_adc_samples[0].offset;
|
|
S.sd.offset[1] = ts_adc_samples[1].offset;
|
|
S.sd.offset[2] = ts_adc_samples[2].offset;
|
|
S.sd.offset[3] = ts_adc_samples[3].offset;
|
|
|
|
ts_weight_SPara.offset[0] = S.sd.offset[0];
|
|
ts_weight_SPara.offset[1] = S.sd.offset[1];
|
|
ts_weight_SPara.offset[2] = S.sd.offset[2];
|
|
ts_weight_SPara.offset[3] = S.sd.offset[3];
|
|
L0_waitFree_uartN(0);
|
|
printf("\r\nR.sd.offset 0x%4x,0x%4x,0x%4x,0x%4x,\r\n",S.sd.offset[0],S.sd.offset[1],S.sd.offset[2],S.sd.offset[3]);
|
|
|
|
*/
|
|
|
|
/// L4_reg_2_iap();///写入iap
|
|
/// L4_iap_2_reg();///读取出来验证
|
|
}
|
|
|
|
void L3_task_weight_set(Ts_uart_rev_ *ph4)
|
|
{
|
|
TS_P_debug *td;
|
|
if(ph4->debugok)
|
|
{ ph4->debugok = 0;
|
|
td = (TS_P_debug *)ph4->buf;
|
|
|
|
/// TS_PH4_modbus *ts_modbus = (TS_PH4_modbus *)ph4->buf;
|
|
|
|
L0_uartN_uchexArray(0,ph4->buf, 8);
|
|
if(0xfd == td->filter)
|
|
{
|
|
if(0x04 == td->R1)///设置四个传感器的清零
|
|
{ //// fd 04 33 44 55
|
|
L0_uart0_sendstr("\r\n 4sensor zero \r\n");
|
|
L3_adc_zero();
|
|
}else if(0x01 == td->R1)///设置重量的清零
|
|
{ //// fd 04 33 44 55
|
|
L0_uart0_sendstr("\r\n--weight zero-- \r\na b= ");
|
|
|
|
}else if(0x02 == td->R1)///读取
|
|
{
|
|
if(0x00 == td->R2)
|
|
{//// fd 02 00 44 55
|
|
L0_uart0_sendstr("\r\n--read iapData-- \r\n");
|
|
L4_print_iap(&iapData);
|
|
}else
|
|
{//// fd 02 33 44 55
|
|
L0_uart0_sendstr("\r\n--read R.sd-- \r\n");
|
|
L4_print_iap(&R.sd);
|
|
}
|
|
}
|
|
|
|
else
|
|
{
|
|
L0_uart0_sendstr("\r\n command error \r\n");
|
|
|
|
}
|
|
}
|
|
else if(0xf5 == td->filter)
|
|
{///设置重量
|
|
if(td->R1 < 3)///
|
|
{
|
|
//// R1 R2 R3
|
|
//// f5 00 33 44 55 把当前的adc的值作为第R1个校准点的值
|
|
R.sd.zerows[td->R1].adc = (vU16)tst_weight.out6;
|
|
|
|
Lc_buf_copy_uc((u8 *)&R.sd.factory_ws,(u8 *)&R.sd.zerows,12);
|
|
L4_reg_2_iap();///写入iap
|
|
L4_iap_2_reg();///读取出来验证
|
|
}else
|
|
{
|
|
|
|
}
|
|
L0_waitFree_uartN(0);
|
|
printf("\r\n set[ %d].adc = 0x%04x\r\n",(int)td->R1, (vU16)tst_weight.out6);
|
|
}
|
|
|
|
|
|
else if(0xf6 == td->filter)
|
|
{///设置砝码
|
|
if(td->R1 < 3)///
|
|
{
|
|
//// R1 R2 R3
|
|
//// f5 00 33 44 55 把当前第R1个校准曲线的点的kg的值 0x3344
|
|
R.sd.zerows[td->R1].kg = D_2uc_u16(R2,R3);
|
|
|
|
Lc_buf_copy_uc((u8 *)&R.sd.factory_ws,(u8 *)&R.sd.zerows,12);
|
|
L4_reg_2_iap();///写入iap
|
|
L4_iap_2_reg();///读取出来验证
|
|
}else
|
|
{
|
|
|
|
}
|
|
L0_waitFree_uartN(0);
|
|
printf("\r\nset [ %d],Kg = 0x%04x\r\n",(int)td->R1, R.sd.zerows[td->R1].kg );
|
|
}
|
|
|
|
|
|
else
|
|
{
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/////////cc 2023/04/06--7:3:24 协议解析
|
|
void L3_weight_setPara(u8 filter)
|
|
{
|
|
if(filter == Ts_debug.td->filter)
|
|
{
|
|
L1_uartD_uc('D');
|
|
L0_uart0_0d0a();
|
|
|
|
|
|
if(0x01 == Ts_debug.td->ocr)
|
|
{
|
|
if(0x04 == Ts_debug.td->R1)///设置四个传感器的清零
|
|
{ //// fd 04 33 44 01
|
|
L0_uart0_sendstr("\r\n 4sensor zero \r\n");
|
|
L3_adc_zero();
|
|
}else if(0x01 == Ts_debug.td->R1)///设置重量的清零
|
|
{ //// fd 01 33 44 01
|
|
L0_uart0_sendstr("\r\n--weight zero-- \r\na b= ");
|
|
|
|
}else if(0x02 == Ts_debug.td->R1)///读取
|
|
{
|
|
if(0x00 == Ts_debug.td->R2)
|
|
{//// fd 02 00 44 01
|
|
L0_uart0_sendstr("\r\n--read ts_weight_save-- \r\n");
|
|
L4_print_iap(&ts_weight_save);
|
|
}else
|
|
{//// fd 02 33 44 01
|
|
L0_uart0_sendstr("\r\n--read R.sd-- \r\n");
|
|
L4_print_iap(&R.sd);
|
|
}
|
|
}
|
|
|
|
else
|
|
{
|
|
L0_uart0_sendstr("\r\n command error \r\n");
|
|
|
|
}
|
|
}
|
|
else if(0x02 == Ts_debug.td->ocr)
|
|
{///设置重量
|
|
if(Ts_debug.td->R1 < 3)///
|
|
{
|
|
//// R1 R2 R3
|
|
//// fd 00 33 44 02 把当前的adc的值作为第R1个校准点的值
|
|
R.sd.zerows[Ts_debug.td->R1].adc = (vU16)tst_weight.out6;
|
|
|
|
Lc_buf_copy_uc((u8 *)&R.sd.factory_ws,(u8 *)&R.sd.zerows,12);
|
|
L4_reg_2_iap();///写入iap
|
|
L4_iap_2_reg();///读取出来验证
|
|
}else
|
|
{
|
|
|
|
}
|
|
L0_waitFree_uartN(0);
|
|
printf("\r\n set[ %d].adc = 0x%04x\r\n",(int)Ts_debug.td->R1, (vU16)tst_weight.out6);
|
|
}
|
|
|
|
|
|
else if(0x03 == Ts_debug.td->ocr)
|
|
{///设置砝码
|
|
if(Ts_debug.td->R1 < 3)///
|
|
{ //200
|
|
//// R1 R2 R3
|
|
//// fd 00 33 44 03 把当前第R1个校准曲线的点的kg的值 0x3344
|
|
R.sd.zerows[Ts_debug.td->R1].kg = D_2uc_u16(Ts_debug.td->R2,Ts_debug.td->R3);
|
|
Lc_buf_copy_uc((u8 *)&R.sd.factory_ws,(u8 *)&R.sd.zerows,12);
|
|
L4_reg_2_iap();///写入iap
|
|
L4_iap_2_reg();///读取出来验证 20 14
|
|
}else
|
|
{
|
|
|
|
}
|
|
L0_waitFree_uartN(0);
|
|
printf("\r\nset [ %d],Kg = 0x%04x\r\n",(int)Ts_debug.td->R1, R.sd.zerows[Ts_debug.td->R1].kg );
|
|
}
|
|
|
|
|
|
else
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
#endif
|
|
|
|
|
|
|