解决任务重试会导致返回数据长度增加的问题
修改jwt读取空闲判线算法以自适应返回电流挡位,未验证
This commit is contained in:
@@ -17,7 +17,7 @@ static volatile CurrentSample_Range_eu buscurrent_range = Current_Max;
|
||||
|
||||
#define SMod_Read_Idle_Filter 90
|
||||
// 根据反码电流改变
|
||||
#define DMod_Read_Idle_Filter 300
|
||||
#define DMod_Read_Idle_Filter 50
|
||||
|
||||
volatile uint16_t* EW_Read_AD_V = FireBus_ADC_Buf;
|
||||
static volatile uint16_t SMod_Read_Idle_C;
|
||||
@@ -483,6 +483,7 @@ uint8_t DMod_FireBusReadDatasV2(uint8_t* buf, uint8_t len, uint32_t time_out)
|
||||
uint32_t us_dataT_Or;//数据周期
|
||||
uint32_t us_temp1,us_temp2;
|
||||
uint16_t ad_max = 0,ad_max_temp = 0;
|
||||
uint16_t ad_high_value=0;
|
||||
CurrentSample_Range_eu range = buscurrent_range;//档位保存
|
||||
Power_SetSampleCurrentRange(R10_2mA_30mA_MC);
|
||||
ADC_CurChnnelSet(AN_MAL_CH,ADC_SPEED_HFAST);
|
||||
@@ -492,40 +493,45 @@ uint8_t DMod_FireBusReadDatasV2(uint8_t* buf, uint8_t len, uint32_t time_out)
|
||||
//延时等待电流稳定
|
||||
delay_us(800);
|
||||
//COM_PH2_Out = 0;
|
||||
PBout(I2IC_SCL_Pin_Nu) = 0;
|
||||
PBout(I2IC_SCL_Pin_Nu) = 0;
|
||||
delay_us(200);
|
||||
//获取中电平电流
|
||||
PBout(I2IC_SCL_Pin_Nu) = 1 ;
|
||||
PBout(I2IC_SCL_Pin_Nu) = 1 ;
|
||||
DMod_GetIdle2V();
|
||||
PBout(I2IC_SCL_Pin_Nu) = 0 ;
|
||||
PBout(I2IC_SCL_Pin_Nu) = 0 ;
|
||||
//读取指定长度数据
|
||||
//读取单字节数据
|
||||
ul_data = 0;
|
||||
//等待起始信号唤醒信号
|
||||
us_plus_H = 0;
|
||||
us_plus_T = 0;
|
||||
us_time_out = 2000 + time_out;
|
||||
do{
|
||||
|
||||
ul_ad_sample = ADC_GetCurADCFast();
|
||||
if(ad_max < ul_ad_sample)
|
||||
ad_max = ul_ad_sample;
|
||||
if(ul_ad_sample > SMod_Read_Idle_C)
|
||||
{
|
||||
us_plus_H++;
|
||||
}else{
|
||||
us_plus_H = 0;
|
||||
}
|
||||
delay_us(2);
|
||||
us_time_out--;
|
||||
}
|
||||
while((us_plus_H < 4) && (us_time_out > 0));
|
||||
if(us_time_out < 1)//等待起始信号超时
|
||||
{
|
||||
EW_DIFF_MOD_H;
|
||||
Power_SetSampleCurrentRange(range);
|
||||
return 1;
|
||||
}
|
||||
//读取单字节数据
|
||||
ul_data = 0;
|
||||
//等待起始信号唤醒信号
|
||||
us_plus_H = 0;
|
||||
us_plus_T = 0;
|
||||
us_time_out = 2000 + time_out;
|
||||
do{
|
||||
|
||||
ul_ad_sample = ADC_GetCurADCFast();
|
||||
if(ad_max < ul_ad_sample)
|
||||
ad_max = ul_ad_sample;
|
||||
if(ul_ad_sample > SMod_Read_Idle_C)
|
||||
{
|
||||
us_plus_H++;
|
||||
ad_high_value=ad_high_value/2+ul_ad_sample/2;
|
||||
}else{
|
||||
us_plus_H = 0;
|
||||
ad_high_value=0;
|
||||
}
|
||||
delay_us(2);
|
||||
us_time_out--;
|
||||
}
|
||||
while((us_plus_H < 4) && (us_time_out > 0));
|
||||
if(us_time_out < 1)//等待起始信号超时
|
||||
{
|
||||
EW_DIFF_MOD_H;
|
||||
Power_SetSampleCurrentRange(range);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// 空闲判线以最高电平为基准
|
||||
SMod_Read_Idle_C=ad_high_value-50;
|
||||
|
||||
while(len > 0)
|
||||
{
|
||||
@@ -916,7 +922,7 @@ uint8_t EW_WriteMTP(uint16_t addr,uint8_t mtpaddr,uint8_t* buf,uint8_t len)
|
||||
len = 10;
|
||||
}
|
||||
EW_CommBuf[3] = len;
|
||||
memcpy((void*)EW_CommBuf+4,buf,len);
|
||||
memcpy((void*)(EW_CommBuf+4),buf,len);
|
||||
DMod_SendBytes((uint8_t*)EW_CommBuf,len+4,EW_DMOD_Peroid,uc_readflag);
|
||||
if(uc_readflag == 0)
|
||||
{
|
||||
@@ -956,7 +962,7 @@ uint8_t EW_ReadMTP(uint16_t addr,uint8_t mtpaddr,uint8_t* buf,uint8_t len)
|
||||
len = 10;
|
||||
}
|
||||
EW_CommBuf[3] = len;
|
||||
memcpy((void*)EW_CommBuf+4,buf,len);
|
||||
memcpy((void*)(EW_CommBuf+4),buf,len);
|
||||
DMod_SendBytes((uint8_t*)EW_CommBuf,len+4,EW_DMOD_Peroid,uc_readflag);
|
||||
if(uc_readflag == 0)
|
||||
{
|
||||
@@ -987,7 +993,7 @@ uint8_t EW_RunBootLoader(uint16_t addr,uint8_t reboot)
|
||||
{
|
||||
ul_bootflag = 0x9966AA55;
|
||||
}
|
||||
memcpy((void*)EW_CommBuf+2,&ul_bootflag,4);
|
||||
memcpy((void*)(EW_CommBuf+2),&ul_bootflag,4);
|
||||
DMod_SendBytes((uint8_t*)EW_CommBuf,6,EW_DMOD_Peroid,0);
|
||||
return 0;
|
||||
}
|
||||
@@ -1009,7 +1015,7 @@ uint8_t EW_WriteRunCfg(uint16_t addr,RunCfg_un* runcfg)
|
||||
addr = (addr & 0xFFC0) | 20;
|
||||
EW_CommBuf[0] = addr&0xFF;
|
||||
EW_CommBuf[1] = (addr >> 8)&0xFF;
|
||||
memcpy((void*)EW_CommBuf+2,&runcfg,3);
|
||||
memcpy((void*)(EW_CommBuf+2),&runcfg,3);
|
||||
DMod_SendBytes((uint8_t*)EW_CommBuf,6,EW_DMOD_Peroid,uc_readflag);
|
||||
if(uc_readflag == 0)
|
||||
{
|
||||
@@ -1045,7 +1051,7 @@ uint8_t EW_SetAddrByUID(uint16_t addr,uint8_t* uid,uint8_t uid_len,uint8_t* ack_
|
||||
addr = (addr & 0xFFC0) | 21;
|
||||
EW_CommBuf[0] = addr&0xFF;
|
||||
EW_CommBuf[1] = (addr >> 8)&0xFF;
|
||||
memcpy((void*)EW_CommBuf+2,uid,uid_len);
|
||||
memcpy((void*)(EW_CommBuf+2),uid,uid_len);
|
||||
DMod_SendBytes((uint8_t*)EW_CommBuf,uid_len+2,EW_DMOD_Peroid,uc_readflag);
|
||||
if(uc_readflag == 0)
|
||||
{
|
||||
@@ -1084,7 +1090,7 @@ uint8_t EW_FastSetByUID(uint16_t addr,uint16_t delay, uint8_t pwd_flag,uint8_t*
|
||||
EW_CommBuf[0] = addr&0xFF;
|
||||
EW_CommBuf[1] = (addr >> 8)&0xFF;
|
||||
EW_CommBuf[2] = pwd_flag;
|
||||
memcpy(((void*)(EW_CommBuf)+3),&delay,2);
|
||||
memcpy((void*)(EW_CommBuf+3),&delay,2);
|
||||
memcpy((void*)(EW_CommBuf+5),uid,uid_len);
|
||||
uid_len +=5;
|
||||
DMod_SendBytes(((uint8_t*)(EW_CommBuf)),uid_len,EW_DMOD_Peroid,uc_readflag);
|
||||
@@ -1115,7 +1121,7 @@ uint8_t EW_SetDelay(uint16_t addr,uint16_t delay)
|
||||
addr = (addr & 0xFFC0) | 23;
|
||||
EW_CommBuf[0] = addr&0xFF;
|
||||
EW_CommBuf[1] = (addr >> 8)&0xFF;
|
||||
memcpy((void*)EW_CommBuf+2,&delay,2);
|
||||
memcpy((void*)(EW_CommBuf+2),&delay,2);
|
||||
DMod_SendBytes((uint8_t*)EW_CommBuf,4,EW_DMOD_Peroid,0);
|
||||
uc_ack = DMod_FireBusReadDatasV2((uint8_t*)EW_CommBuf+2,2,EW_DMOD_READ_Timeout);
|
||||
if(EW_CommBuf[0] != EW_CommBuf[2] || EW_CommBuf[1] != EW_CommBuf[3])
|
||||
@@ -1139,7 +1145,7 @@ uint8_t EW_VerfyPWD(uint16_t addr,uint8_t* pwd,uint8_t pwd_len)
|
||||
addr = (addr & 0xFFC0) | 24;
|
||||
EW_CommBuf[0] = addr&0xFF;
|
||||
EW_CommBuf[1] = (addr >> 8)&0xFF;
|
||||
memcpy((void*)EW_CommBuf+2,pwd,pwd_len);
|
||||
memcpy((void*)(EW_CommBuf+2),pwd,pwd_len);
|
||||
pwd_len += 2;
|
||||
DMod_SendBytes((uint8_t*)EW_CommBuf,pwd_len,EW_DMOD_Peroid,0);
|
||||
return 0;
|
||||
@@ -1417,7 +1423,7 @@ uint8_t EW_UpdateCommAddr(uint8_t addr,uint16_t new_addr)
|
||||
addr = (addr & 0xFFC0) | 36;
|
||||
EW_CommBuf[0] = addr&0xFF;
|
||||
EW_CommBuf[1] = (addr >> 8)&0xFF;
|
||||
memcpy((void*)EW_CommBuf+2,&new_addr,2);
|
||||
memcpy((void*)(EW_CommBuf+2),&new_addr,2);
|
||||
DMod_SendBytes((uint8_t*)EW_CommBuf,4,EW_DMOD_Peroid,uc_readflag);
|
||||
if(uc_readflag == 0)
|
||||
{
|
||||
|
Reference in New Issue
Block a user