实现大部分小板通信命令
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#include "board.h"
|
||||
#include "bytearray.h"
|
||||
#include "mystdlib.h"
|
||||
#include "debug.h"
|
||||
|
||||
#include "elec_det.h"
|
||||
#include "base/delay.h"
|
||||
@@ -23,15 +24,42 @@
|
||||
|
||||
|
||||
typedef struct{
|
||||
CheckerTask_Info_st* task_info_array[PLAN_MAX_TASK];//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ṹ<EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD>
|
||||
|
||||
CheckerTask_Info_st* task_info_array[PLAN_MAX_TASK];//方案参数结构体指针
|
||||
int scheme_inited;
|
||||
}self_def;
|
||||
|
||||
|
||||
static self_def g_self;
|
||||
|
||||
|
||||
// <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ
|
||||
|
||||
|
||||
// 初始化
|
||||
int elec_init(void)
|
||||
{
|
||||
self_def *s=&g_self;
|
||||
void Ye_BoardInit(void);
|
||||
void Ye_BoardCheck(void);
|
||||
int elec_check_scheme(void);
|
||||
void elec_load_scheme(void);
|
||||
Ye_BoardInit();
|
||||
Ye_BoardCheck();
|
||||
if(elec_check_scheme()!=0){
|
||||
// 方案校验失败
|
||||
DBG_WARN("scheme check failed.");
|
||||
s->scheme_inited=0;
|
||||
return 1;
|
||||
}
|
||||
s->scheme_inited=1;
|
||||
elec_load_scheme();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// 获取本机地址
|
||||
uint8_t elec_local_addr(void)
|
||||
{
|
||||
static uint8_t addr=0;
|
||||
@@ -41,13 +69,13 @@ uint8_t elec_local_addr(void)
|
||||
}
|
||||
|
||||
|
||||
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD>led1״̬
|
||||
// 设置led1状态
|
||||
void elec_led1_power(int power)
|
||||
{
|
||||
LED1_Out=power?1:0;
|
||||
}
|
||||
|
||||
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD>led2״̬
|
||||
// 设置led2状态
|
||||
void elec_led2_power(int power)
|
||||
{
|
||||
LED2_Out=power?1:0;
|
||||
@@ -55,40 +83,44 @@ void elec_led2_power(int power)
|
||||
|
||||
|
||||
|
||||
// <EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
// 获取检测结果
|
||||
array_def *elec_check_result(void)
|
||||
{
|
||||
array_def *r=arr_creat();
|
||||
|
||||
arr_append(r,3);
|
||||
return arr_temp(r);
|
||||
}
|
||||
|
||||
|
||||
// дӲ<EFBFBD><EFBFBD><EFBFBD>汾<EFBFBD><EFBFBD>
|
||||
int elec_write_hardversion(int version)
|
||||
// 写硬件版本号
|
||||
array_def *elec_write_hardversion(int version)
|
||||
{
|
||||
array_def *r=arr_creat();
|
||||
board_st.hard_v=version;
|
||||
return 0;
|
||||
arr_append(r,0);
|
||||
return arr_temp(r);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// д<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Уֵ
|
||||
int elec_write_resistor_cbv(int cbv)
|
||||
// 写电阻校准值
|
||||
array_def *elec_write_resistor_cbv(int cbv)
|
||||
{
|
||||
array_def *r=arr_creat();
|
||||
board_st.resistor_diff=cbv;
|
||||
arr_append(r,0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD><EFBFBD>ֵ
|
||||
// 测量桥丝阻值
|
||||
array_def *elec_check_resistor(void)
|
||||
{
|
||||
/*
|
||||
1 ͨ<EFBFBD><EFBFBD>1-4ͨ<34><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˿
|
||||
2 ͨ<EFBFBD><EFBFBD>2-3ͨ<33><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˿
|
||||
3 ͨ<EFBFBD><EFBFBD>1-3ͨ<33><CDA8><EFBFBD><EFBFBD><EFBFBD>迹
|
||||
4 ͨ<EFBFBD><EFBFBD>2-4ͨ<34><CDA8><EFBFBD><EFBFBD><EFBFBD>迹
|
||||
1 通道1-4通,过桥丝
|
||||
2 通道2-3通,过桥丝
|
||||
3 通道1-3通,测阻抗
|
||||
4 通道2-4通,测阻抗
|
||||
*/
|
||||
uint16_t aus_sample[5];
|
||||
uint16_t us_resistor;
|
||||
@@ -98,7 +130,7 @@ array_def *elec_check_resistor(void)
|
||||
{
|
||||
aus_sample[uc_index] -= board_st.resistor_diff;
|
||||
}
|
||||
// <EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>в<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ
|
||||
// 读取方案中测量电阻的模式
|
||||
switch(0)
|
||||
{
|
||||
case 0: us_resistor = aus_sample[0];break;
|
||||
@@ -117,7 +149,7 @@ array_def *elec_check_resistor(void)
|
||||
|
||||
|
||||
|
||||
// У<EFBFBD>鷽<EFBFBD><EFBFBD>,<2C><>0<EFBFBD>ɹ<EFBFBD>
|
||||
// 校验方案,返0成功
|
||||
static int elec_check_scheme(void)
|
||||
{
|
||||
uint32_t ul_crc32;
|
||||
@@ -135,7 +167,7 @@ static int elec_check_scheme(void)
|
||||
|
||||
|
||||
|
||||
// <EFBFBD><EFBFBD><EFBFBD>ط<EFBFBD><EFBFBD><EFBFBD>
|
||||
// 加载方案
|
||||
static void elec_load_scheme(void)
|
||||
{
|
||||
self_def *s=&g_self;
|
||||
@@ -159,7 +191,7 @@ static void elec_load_scheme(void)
|
||||
}
|
||||
|
||||
|
||||
// <EFBFBD><EFBFBD><EFBFBD>м<EFBFBD><EFBFBD><EFBFBD>
|
||||
// 进行检测
|
||||
array_def *elec_check_with_scheme(array_def *uid_psw)
|
||||
{
|
||||
self_def *s=&g_self;
|
||||
@@ -172,10 +204,14 @@ array_def *elec_check_with_scheme(array_def *uid_psw)
|
||||
uint8_t res=0;
|
||||
array_def *r=arr_creat();
|
||||
chip_type=(board_st.plan_id >> 12 ) & 0x0F;
|
||||
if(chip_type>=LENGTH(tasks_fun_table)){
|
||||
if(s->scheme_inited==0){
|
||||
arr_append(r,1);
|
||||
return arr_temp(r);
|
||||
}
|
||||
if(chip_type>=LENGTH(tasks_fun_table)){
|
||||
arr_append(r,2);
|
||||
return arr_temp(r);
|
||||
}
|
||||
memset(&checker_runcfg,0,sizeof(Checker_RunCfg_st));
|
||||
int task_index=0;
|
||||
int err_flag=0;
|
||||
@@ -184,8 +220,8 @@ array_def *elec_check_with_scheme(array_def *uid_psw)
|
||||
memset(&checker_runcfg.task_info,0,sizeof(CheckerTask_Info_st));
|
||||
taskid=ptaskindex[task_index];
|
||||
memset(checker_runcfg.params,0,20);
|
||||
checker_runcfg.param_count = 0;//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
checker_runcfg.rtv_count = 0;//<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
checker_runcfg.param_count = 0;//参数个数
|
||||
checker_runcfg.rtv_count = 0;//返回值个数
|
||||
checker_runcfg.excue_rtv = 0;
|
||||
checker_runcfg.task_info.retry_time = 0;
|
||||
if(taskid>=CHECKER_MAXID_COUNT){
|
||||
@@ -200,13 +236,13 @@ array_def *elec_check_with_scheme(array_def *uid_psw)
|
||||
break;
|
||||
}
|
||||
|
||||
// װ<EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>
|
||||
// 装载参数
|
||||
rt_memcpy(&checker_runcfg.task_info,task_par,sizeof(CheckerTask_Info_st));
|
||||
checker_runcfg.param_count = checker_runcfg.task_info.param_rtv_count & 0x0F;
|
||||
checker_runcfg.rtv_count = (checker_runcfg.task_info.param_rtv_count >> 4) & 0x0F;
|
||||
rt_memcpy(checker_runcfg.params,checker_runcfg.task_info.params,checker_runcfg.param_count*2);
|
||||
|
||||
// ִ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
// 执行任务
|
||||
for(int i=0;i<1+task_par->retry_time;i++)
|
||||
{
|
||||
checker_runcfg.excue_rtv=1;
|
||||
@@ -216,23 +252,23 @@ array_def *elec_check_with_scheme(array_def *uid_psw)
|
||||
break;
|
||||
}
|
||||
|
||||
// <EFBFBD><EFBFBD>Ѱ<EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
// 找寻下一个任务
|
||||
if((checker_runcfg.excue_rtv != 0)
|
||||
&& (checker_runcfg.task_info.error_jumpto != 0)
|
||||
&& (checker_runcfg.task_info.error_jumpto != 0xFF)
|
||||
)
|
||||
{
|
||||
uint8_t uc_index = task_index+1;//<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD><EFBFBD>˳<EFBFBD><EFBFBD>ִ<EFBFBD><EFBFBD>
|
||||
uint8_t uc_index = task_index+1;//如果时跳至下一个,直接顺序执行
|
||||
task_index = checker_runcfg.task_info.error_jumpto;
|
||||
while(uc_index < task_index)
|
||||
{
|
||||
Checker_MaskResult(1,uc_index);//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IJ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>δִ<EFBFBD><EFBFBD>
|
||||
//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD>±꣬<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IJ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ķ<EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD>洢<EFBFBD>ռ䱣<EFBFBD><EFBFBD>
|
||||
Checker_MaskResult(1,uc_index);//将跳过的步骤标记未执行
|
||||
//调整参数返回值下标,将跳过的步骤里面的返回值存储空间保留
|
||||
checker_runcfg.rtv_index += (s->task_info_array[uc_index]->param_rtv_count >> 4) & 0x0F;
|
||||
uc_index++;
|
||||
}
|
||||
}else{
|
||||
task_index++;//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD><EFBFBD>˳<EFBFBD><EFBFBD>ִ<EFBFBD><EFBFBD>
|
||||
task_index++;//正常情况直接顺序执行
|
||||
}
|
||||
}
|
||||
|
||||
@@ -246,3 +282,5 @@ array_def *elec_check_with_scheme(array_def *uid_psw)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user