使用make -f Makeboot 来使用gcc编译
添加 DMod_FireBusReadDatasV2_RC 函数
This commit is contained in:
@@ -235,3 +235,7 @@
|
||||
2023.10.31
|
||||
添加通用的异常判定算法,已验证
|
||||
更新EW模块驱动
|
||||
2023.11.1
|
||||
使用make -f Makeboot 来使用gcc编译
|
||||
添加 DMod_FireBusReadDatasV2_RC 函数
|
||||
|
||||
|
@@ -97,13 +97,13 @@ typedef struct{
|
||||
}reboot_type_str;
|
||||
|
||||
static const reboot_type_str g_reboot_str[]={
|
||||
REBOOT_APP_TO_APP,"app restart",
|
||||
REBOOT_APP_TO_BOOT,"app reboot to boot",
|
||||
REBOOT_BOOT_TO_APP,"boot guide to app",
|
||||
REBOOT_BOOT_TO_BOOT,"boot restart",
|
||||
REBOOT_PARAM_ERR,"param err then reboot",
|
||||
REBOOT_HARD_ERR,"hard err then reboot",
|
||||
REBOOT_INIT,"watch dog died then reboot",
|
||||
{REBOOT_APP_TO_APP,"app restart",},
|
||||
{REBOOT_APP_TO_BOOT,"app reboot to boot",},
|
||||
{REBOOT_BOOT_TO_APP,"boot guide to app",},
|
||||
{REBOOT_BOOT_TO_BOOT,"boot restart",},
|
||||
{REBOOT_PARAM_ERR,"param err then reboot",},
|
||||
{REBOOT_HARD_ERR,"hard err then reboot",},
|
||||
{REBOOT_INIT,"watch dog died then reboot",},
|
||||
};
|
||||
|
||||
|
||||
|
@@ -685,6 +685,185 @@ uint8_t DMod_FireBusReadDatasV2(uint8_t* buf, uint8_t len, uint32_t time_out)
|
||||
}
|
||||
|
||||
|
||||
static uint16_t us_plus_H,us_plus_H2;//高电平采用次数
|
||||
static uint16_t us_plus_T,us_plus_T2;//采样周期
|
||||
typedef struct{
|
||||
uint16_t cur_idle;
|
||||
uint16_t cur_idle_ad;
|
||||
uint16_t cur_high_value;
|
||||
uint16_t cur_idle_line;
|
||||
uint16_t cur_max;
|
||||
}firebus_def;
|
||||
uint8_t DMod_FireBusReadDatasV2_RC(uint8_t* buf, uint8_t len, uint32_t time_out)
|
||||
{
|
||||
uint32_t ul_ad_sample;
|
||||
uint32_t ul_check_falg; //奇校验
|
||||
uint32_t us_time_out = time_out;
|
||||
uint32_t ul_data = 0;
|
||||
uint32_t us_dataT_Or;//数据周期
|
||||
uint32_t us_temp1,us_temp2;
|
||||
uint16_t ad_max = 0,ad_min_temp=0,ad_max_temp = 0;
|
||||
firebus_def fire_dat={0};
|
||||
uint8_t ret=0;
|
||||
CurrentSample_Range_eu range = buscurrent_range;//档位保存
|
||||
Power_SetSampleCurrentRange(R10_2mA_30mA_MC);
|
||||
ADC_CurChnnelSet(AN_MAL_CH,ADC_SPEED_HFAST);
|
||||
delay_us(2000);
|
||||
//总线跳转到中电平
|
||||
EW_DIFF_MOD_M;
|
||||
//延时等待电流稳定
|
||||
delay_us(800);
|
||||
//COM_PH2_Out = 0;
|
||||
PBout(I2IC_SCL_Pin_Nu) = 0;
|
||||
delay_us(200);
|
||||
//获取中电平电流
|
||||
PBout(I2IC_SCL_Pin_Nu) = 1 ;
|
||||
DMod_GetIdle2V();
|
||||
fire_dat.cur_idle=SMod_Read_Idle_C;
|
||||
fire_dat.cur_idle_ad=ADC_GetCurADCFast();
|
||||
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)
|
||||
{
|
||||
if(ul_ad_sample-SMod_Read_Idle_C>50){
|
||||
us_plus_H++;
|
||||
fire_dat.cur_high_value=fire_dat.cur_high_value/2+ul_ad_sample/2;
|
||||
}else{
|
||||
SMod_Read_Idle_C=ul_ad_sample;
|
||||
}
|
||||
}else{
|
||||
us_plus_H = 0;
|
||||
fire_dat.cur_high_value=0;
|
||||
}
|
||||
delay_us(2);
|
||||
us_time_out--;
|
||||
}
|
||||
while((us_plus_H < 4) && (us_time_out > 0));
|
||||
fire_dat.cur_max=ad_max;
|
||||
if(us_time_out < 1)//等待起始信号超时
|
||||
{
|
||||
ret=1;
|
||||
goto end;
|
||||
}
|
||||
|
||||
// 空闲判线以最高电平为基准
|
||||
SMod_Read_Idle_C=(SMod_Read_Idle_C+fire_dat.cur_high_value)/2;
|
||||
fire_dat.cur_idle_line=SMod_Read_Idle_C;
|
||||
|
||||
while(len > 0)
|
||||
{
|
||||
//等待数据帧起始信号
|
||||
us_time_out = 10;
|
||||
us_plus_T2 = 0xFFFF;
|
||||
us_plus_H2 = 0;
|
||||
while(us_time_out > 0)
|
||||
{
|
||||
us_plus_H = 0;
|
||||
us_plus_T = 0;
|
||||
idle_line = SMod_Read_Idle_C;
|
||||
// idle_line = ad_max - SMod_Read_Idle_C;
|
||||
// idle_line = (idle_line>>1)+ (idle_line>>4)+ SMod_Read_Idle_C;
|
||||
if(SMod_FireBusReadPlus(&us_plus_H,&us_plus_T,time_out,idle_line,&ad_max_temp,&ad_min_temp ) > 0)
|
||||
{
|
||||
ret=2;
|
||||
goto end;
|
||||
}
|
||||
if(us_plus_H2 > (us_plus_T2- us_plus_H2))
|
||||
{
|
||||
us_temp1 = us_plus_T << 1; //2倍
|
||||
us_temp2 = us_plus_T + (us_plus_T >> 1);//1.5倍
|
||||
if((us_plus_T2 > us_temp2) && (us_plus_T2 < us_temp1))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
us_plus_T2 = us_plus_T;
|
||||
us_plus_H2 = us_plus_H;
|
||||
us_time_out--;
|
||||
}
|
||||
//采集8bit数据+1位校验
|
||||
ul_data = 0;
|
||||
ul_check_falg = 0;
|
||||
us_time_out = 0;
|
||||
us_plus_T2 = 0;
|
||||
us_dataT_Or = us_plus_T;//保存数据周期
|
||||
do{
|
||||
ul_data <<= 1;
|
||||
if(us_plus_H > (us_plus_T- us_plus_H)) //高电平时间大于低电平 1
|
||||
{
|
||||
ul_data |= 0x01;
|
||||
ul_check_falg ^= 0x01;
|
||||
}else{//检测是否是结束信号 0
|
||||
us_temp1 = us_plus_T2 << 1; //2倍
|
||||
us_temp2 = us_plus_T2 + (us_plus_T2 >> 1);//1.5倍
|
||||
if((us_plus_T > us_temp2) && (us_plus_T < us_temp1))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
//约束数据周期范围
|
||||
// if(((us_dataT_Or+4) < us_plus_T)
|
||||
// || ((us_dataT_Or - 4) > us_plus_T))
|
||||
// {
|
||||
// SetSampleCurrentRange(range);
|
||||
// EW_SINGLE_MOD_H;
|
||||
// return 3;
|
||||
// }
|
||||
us_plus_T2 = us_plus_T;
|
||||
us_plus_H2 = us_plus_H;
|
||||
us_plus_H = 0;
|
||||
us_plus_T = 0;
|
||||
//idle_line = ad_max - SMod_Read_Idle_C;
|
||||
//idle_line = (idle_line>>1)+ (idle_line>>4)+ SMod_Read_Idle_C;
|
||||
idle_line = SMod_Read_Idle_C;
|
||||
if(SMod_FireBusReadPlus(&us_plus_H,&us_plus_T,time_out,idle_line,&ad_max_temp,&ad_min_temp ) > 0)
|
||||
{
|
||||
ret=4;
|
||||
goto end;
|
||||
}
|
||||
ad_max = (uint16_t)(ad_max * 0.7f + ad_max_temp*0.3f);
|
||||
us_time_out++;
|
||||
}while(us_time_out < 13);
|
||||
if(ul_check_falg == 0)
|
||||
{
|
||||
ret=5;
|
||||
goto end;
|
||||
}
|
||||
if(us_time_out != 9)
|
||||
{
|
||||
ret=6;
|
||||
goto end;
|
||||
}
|
||||
ul_data >>= 2;
|
||||
*buf = (uint8_t)ul_data;
|
||||
buf++;
|
||||
len--;
|
||||
}
|
||||
//delay_us(time_out >> 1);
|
||||
|
||||
end:
|
||||
EW_DIFF_MOD_H;
|
||||
Power_SetSampleCurrentRange(range);
|
||||
if(ret){
|
||||
DBG_LOG("cur_idle=%d,high_value=%d,idle_line=%d.",fire_dat.cur_idle, fire_dat.cur_high_value,fire_dat.cur_idle_line);
|
||||
DBG_LOG("cur_max=%d,cur_idle_ad=%d",fire_dat.cur_max,fire_dat.cur_idle_ad);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
@brief 差分模式数据发送
|
||||
@param buf 发送数据缓存
|
||||
@@ -805,7 +984,7 @@ uint8_t DMod_ReadBytesXor(uint8_t* buf, uint8_t len,uint16_t retry_times)
|
||||
{
|
||||
uint8_t ret;
|
||||
// for(int i=0;i<retry_times;i++){
|
||||
ret=DMod_FireBusReadDatasV2(buf,len,500*1000/2);
|
||||
ret=DMod_FireBusReadDatasV2_RC(buf,len,500*1000/2);
|
||||
// if(ret==0) break;
|
||||
// delay_ms(10);
|
||||
// }
|
||||
|
@@ -309,6 +309,13 @@ void EW_Updata(void)
|
||||
DBG_LOG("ret=%d",ret);
|
||||
Checker_MaskResult(ret,checker_runcfg.task_info.runindex);
|
||||
}
|
||||
static int cmd_jwt_updata(list_def *argv)
|
||||
{
|
||||
int ret=0;
|
||||
EW_Updata();
|
||||
return ret;
|
||||
}
|
||||
commend_export(jwt_updata,cmd_jwt_updata,"jwt updata")
|
||||
|
||||
|
||||
|
||||
|
@@ -11,6 +11,7 @@
|
||||
#include "hardware/jw3425iic.h"
|
||||
#include "driver/EWDriver.h"
|
||||
#include "elec_io.h"
|
||||
|
||||
static void MCCheckerTest(int argc, char**argv)
|
||||
{
|
||||
uint16_t us_array[20];
|
||||
|
@@ -6,7 +6,7 @@
|
||||
|
||||
|
||||
|
||||
#define BUILD_DATE "2023-10-31 23:33:54"
|
||||
#define BUILD_DATE "2023-11-01 16:33:25"
|
||||
#define SOFT_VERSION "2.03"
|
||||
|
||||
|
||||
|
@@ -391,7 +391,7 @@ void param_init(rom_head *h)
|
||||
memcpy(pars.pack_time,h->pack_time,20);
|
||||
if(pars.local_id==0xffffffff){
|
||||
memcpy(pars.host_if,h->host_if,8);
|
||||
memcpy(pars.device_type,"slave",8);
|
||||
memcpy(pars.device_type,"slave",6);
|
||||
mac_init(pars.mac);
|
||||
pars.local_id=0;
|
||||
}
|
||||
@@ -401,7 +401,7 @@ void param_init(rom_head *h)
|
||||
// 填充默认配置
|
||||
if(pars.local_id==0xffffffff){
|
||||
memcpy(pars.pack_time,"initial app",12);
|
||||
memcpy(pars.host_if,"host",6);
|
||||
memcpy(pars.host_if,"host",5);
|
||||
memcpy(pars.device_type,"slave",6);
|
||||
mac_init(pars.mac);
|
||||
pars.local_id=0;
|
||||
|
@@ -220,11 +220,21 @@ void cpy4byte(uint32_t *dst,uint32_t *src,int num_4byte)
|
||||
|
||||
|
||||
|
||||
#ifdef __GNUC__
|
||||
|
||||
/* With GCC, small printf (option LD Linker->Libraries->Small printf
|
||||
set to 'Yes') calls __io_putchar() */
|
||||
#define PUTCHAR_PROTOTYPE int __io_putchar(int ch)
|
||||
|
||||
#else
|
||||
|
||||
#define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f)
|
||||
#pragma import(__use_no_semihosting)
|
||||
|
||||
#endif /* __GNUC__ */
|
||||
|
||||
|
||||
|
||||
#pragma import(__use_no_semihosting)
|
||||
|
||||
struct __FILE
|
||||
{
|
||||
int handle;
|
||||
@@ -237,7 +247,7 @@ void _sys_exit(int x)
|
||||
x = x;
|
||||
}
|
||||
|
||||
int fputc(int ch, FILE *f)
|
||||
PUTCHAR_PROTOTYPE
|
||||
{
|
||||
// SEGGER_RTT_PutChar(0,ch);
|
||||
return ch;
|
||||
|
Reference in New Issue
Block a user