#include "base/define.h"
#include "stdlib.h"
#include "hardware/gpio_cfg.h"
#include "base/delay.h"
#include "hardware/adc_cfg.h"
#include "hardware/power.h"
#include "base/utility.h"
//#include "usartapp.h"
//#include "database.h"
#include "interface/BaseChecker.h"
#include "hardware/jw3425iic.h"
#include "driver/EWDriver.h"
#include "elec_io.h"

static void MCCheckerTest(int argc, char**argv)
{
	uint16_t us_array[20];
	uint8_t* puc_buf;
	uint16_t us_temp;
	rt_memset(&checker_runcfg.params,0,sizeof(checker_runcfg.params));
	rt_memset(&checker_runcfg.Task_Result,0,sizeof(checker_runcfg.Task_Result));
	checker_runcfg.excue_rtv = 0;
	checker_runcfg.param_count = 0;
	checker_runcfg.rtv_count = 0;
	checker_runcfg.rtv_index = 0;
	checker_runcfg.task_info.runindex = 0;
	if(argc > 2)
	{
		checker_runcfg.param_count = argc-2;
		us_temp = 0;
		while(us_temp < checker_runcfg.param_count)
		{
			checker_runcfg.params[us_temp] = atoi(argv[us_temp+2]);
			us_temp++;
		}
	}
	if (argc < 2)
	{
		 goto MC_help_label_;
	}else if(!rt_strcmp(argv[1], "SDAOut")){
		SDA_OUT();
		if(checker_runcfg.params[0] == 0)
		{
			IIC_SDA(0);
		}else{
			IIC_SDA(1);
		}
	}else if(!rt_strcmp(argv[1], "SDAIn")){
		SDA_IN();
		rt_kprintf("SDAIn %1\n",READ_SDA);
	}else if(!rt_strcmp(argv[1], "SCLOut")){
		if(checker_runcfg.params[0] == 0)
		{
			IIC_SCL(0);
		}else{
			IIC_SCL(1);
		}
	}else if(!rt_strcmp(argv[1], "CodeCrc")){
		printf("CodeCrc   %X\n",boardinfo_un.boardinfo.mc_ICodeCrc32);
	}
	else if(!rt_strcmp(argv[1], "VrefTrim")){
		MC_VrefTrim();
		printf("VrefTrim Excute  %d\n",checker_runcfg.Task_Result[0]);
	}else if(!rt_strcmp(argv[1], "IrefTrim")){
		MC_IrefTrim();
		printf("IrefTrim Excute  %d\n",checker_runcfg.Task_Result[0]);
	}else if(!rt_strcmp(argv[1], "RC4MTrim")){
		MC_RC4MTrim();
		printf("RC4MTrim Excute  %d\n",checker_runcfg.Task_Result[0]);
	}else if(!rt_strcmp(argv[1], "RC128KTrim")){
		MC_RC128KTrim();
		printf("RC128KTrim Excute  %d\n",checker_runcfg.Task_Result[0]);
	}else if(!rt_strcmp(argv[1], "SetMTPVol")){
		MC_SetMTPVol();
		printf("SetMTPVol Excute  %d\n",checker_runcfg.Task_Result[0]);
	}else if(!rt_strcmp(argv[1], "EraseMTP")){
		MC_EraseMTP();
		printf("EraseMTP Excute  %d\n",checker_runcfg.Task_Result[0]);
	}else if(!rt_strcmp(argv[1], "IICWriteMTP")){
		MC_IICWriteMTP();
		printf("IICWriteMTP Excute  %d\n",checker_runcfg.Task_Result[0]);
	}else if(!rt_strcmp(argv[1], "IICEnMTP")){
		MC_IICEnMTP();
		printf("IICEnMTP Excute  %d\n",checker_runcfg.Task_Result[0]);
	}else if(!rt_strcmp(argv[1], "IICReadMTP")){
		checker_runcfg.rtv_count = (checker_runcfg.params[1]+1)/2;
		MC_IICReadMTP();
		printf("IICMTPState Excute  %d\n",checker_runcfg.Task_Result[0]);
		us_temp = 0;
		while(us_temp < checker_runcfg.rtv_count)
		{
			if((us_temp+1) % 4 == 0)
			{
				printf("\n");
			}
			printf("%02X %02X ",(checker_runcfg.Test_Rtv[us_temp] & 0xFF) ,((checker_runcfg.Test_Rtv[us_temp] >> 8) & 0xFF));
			us_temp++;
			
		}
		printf("\n");		
	}else if(!rt_strcmp(argv[1], "IICMTPState")){
		checker_runcfg.rtv_count = 1;
		MC_IICCheckMTPState();
		printf("IICMTPState Excute  %d   state %x \n",checker_runcfg.Task_Result[0],checker_runcfg.Test_Rtv[0] & 0x0FF);
	}else if(!rt_strcmp(argv[1], "IICUpdateMTP")){
		checker_runcfg.rtv_count = 1;
		POWER_ON
		delay_ms(50);
		MC_IICUpdateMTP();
		POWER_OFF;
		printf("IICMTPState Excute  %d   Error Code %d \n",checker_runcfg.Task_Result[0],checker_runcfg.Test_Rtv[0] & 0x0FF);
	}
	
	else{
		MC_help_label_:
		rt_kprintf("SDAOut [0/1] gpio out\n");
		rt_kprintf("SDAIn 	read gpio pin\n");
		rt_kprintf("SCLOut [0/1] gpio out\n");
		rt_kprintf("VrefTrim [En_update] [trim_value]\n");
		rt_kprintf("IrefTrim [Iref1En_update] [Iref2En_update] [Iref1_value] [Iref2_value]\n");
		rt_kprintf("RC4MTrim [En_update] [trim_value] \n");
		rt_kprintf("RC128KTrim [En_update] [trim_value] \n");
		rt_kprintf("SetMTPVol [L_V_Class] [H_V_Class] \n");
		rt_kprintf("EraseMTP 	[Addr] [Erase_Type] \n");
		rt_kprintf("IICWriteMTP 	[N datas len < 11] \n");
		rt_kprintf("IICReadMTP 	[read len] \n");
		rt_kprintf("IICMTPState 	read MTP status \n");
	}
}

MSH_CMD_EXPORT_ALIAS(MCCheckerTest ,MCI,  EW IIC CMD );

static void EWDriverTest(int argc, char**argv)
{
	uint16_t us_array[20];
	uint8_t* puc_buf;
	uint16_t us_temp;
	uint32_t ul_temp,ul_temp2;
	RunCfg_un runcfg;
	rt_memset(&checker_runcfg.params,0,sizeof(checker_runcfg.params));
	rt_memset(&checker_runcfg.Task_Result,0,sizeof(checker_runcfg.Task_Result));
	checker_runcfg.excue_rtv = 0;
	checker_runcfg.param_count = 0;
	checker_runcfg.rtv_count = 0;
	checker_runcfg.rtv_index = 0;
	checker_runcfg.task_info.runindex = 0;
	if(argc > 2)
	{
		checker_runcfg.param_count = argc-2;
		us_temp = 0;
		while(us_temp < checker_runcfg.param_count)
		{
			checker_runcfg.params[us_temp] = atoi(argv[us_temp+2]);
			us_temp++;
		}
	}
	if (argc < 2)
	{
		 goto EW_help_label_;
	}else if(!rt_strcmp(argv[1], "BUS_H")){
		EW_DIFF_MOD_H
	}else if(!rt_strcmp(argv[1], "BUS_L")){
		
		EW_DIFF_MOD_L
		
	}else if(!rt_strcmp(argv[1], "BUS_M")){
		EW_DIFF_MOD_M
		
	}else if(!rt_strcmp(argv[1], "BUS_OFF")){
		HMOS_SWITCH_OFF
		
	}else if(!rt_strcmp(argv[1], "BUS_ON")){
		HMOS_SWITCH_ON
		
	}
	else if(!rt_strcmp(argv[1], "BUS_CUR")){
		printf("BUS_CUR %d \r\n",Power_GetCurrent());
	}
	else if(!rt_strcmp(argv[1], "SetV")){
		us_temp = PowerCalibration_set(checker_runcfg.params[0],checker_runcfg.params[1]);
		printf("SetV Excute  %d\n",us_temp);
	}else if(!rt_strcmp(argv[1], "DModSend")){
		HexStrings2Byte(argv+4,argc-4,(uint8_t*)us_array,20);
		DMod_SendBytes((uint8_t*)us_array,checker_runcfg.params[0],checker_runcfg.params[1],1);
	}	
	else if(!rt_strcmp(argv[1], "CommTest")){
		memcpy(us_array,"1234567890ABC",4);
		if(checker_runcfg.params[0] < 200)
		{
			checker_runcfg.params[0] = 200;
		}
		puc_buf = (uint8_t*)us_array;
		us_temp = EW_CommTest(puc_buf,4,checker_runcfg.params[0]);
		puc_buf[5+1] = '\0';
		printf("CommTest Excute  %d  %s\n",us_temp,puc_buf+2);
	}else if(!rt_strcmp(argv[1], "EnWriteMTP")){
		us_temp = EW_EnWriteMTP(checker_runcfg.params[0],checker_runcfg.params[1]);
		printf("EnWriteMTP Excute  %d\n",us_temp);
	}else if(!rt_strcmp(argv[1], "WriteMTP")){
		HexStrings2Byte(argv+5,argc-5,(uint8_t*)us_array,sizeof(us_array));
		us_temp = EW_WriteMTP(checker_runcfg.params[0],checker_runcfg.params[1],(uint8_t*)us_array,checker_runcfg.params[2]);
		printf("WriteMTP Excute  %d\n",us_temp);
	}else if(!rt_strcmp(argv[1], "ReadMTP")){
		puc_buf = (uint8_t*)us_array;
		us_temp = EW_ReadMTP(checker_runcfg.params[0],checker_runcfg.params[1],puc_buf,checker_runcfg.params[2]);
		printf("ReadMTP Excute  %d \n",us_temp);
		for(us_temp = 0; us_temp < checker_runcfg.params[2]; us_temp++)
		{
			printf("%02X ",puc_buf[us_temp]);
			if((us_temp + 1) %8 == 0)
			{
				printf("\n");
			}
		}
		if((us_temp + 1) %8 != 0)
		{
			printf("\n");
		}
	}else if(!rt_strcmp(argv[1], "Boot")){
		us_temp = EW_RunBootLoader(checker_runcfg.params[0],checker_runcfg.params[1]);
		printf("Boot Excute  %d\n",us_temp);
	}else if(!rt_strcmp(argv[1], "WriteRunCfg")){
		runcfg.runcfg_st.fire_mos_sw = checker_runcfg.params[1];
		runcfg.runcfg_st.vbus_rx_sg = 3;
		runcfg.runcfg_st.vbus_mode = 1;
		runcfg.runcfg_st.reset_run_step = checker_runcfg.params[2];
		runcfg.runcfg_st.uid_len = checker_runcfg.params[3];
		runcfg.runcfg_st.pwd_len = checker_runcfg.params[4];
		runcfg.runcfg_st.version = checker_runcfg.params[5];
		us_temp = EW_WriteRunCfg(checker_runcfg.params[0],&runcfg);
		printf("WriteRunCfg Excute  %d\n",us_temp);
	}else if(!rt_strcmp(argv[1], "SetAddr")){
		puc_buf = (uint8_t*)us_array;
		memcpy(argv[3],puc_buf,strlen(argv[3]));
		us_temp = EW_SetAddrByUID(checker_runcfg.params[0],puc_buf,strlen(argv[3])-1);
		printf("SetAddr Excute  %d delay %d state %04X\n",us_temp,checker_runcfg.Test_Rtv[0],checker_runcfg.Test_Rtv[1]);
	}else if(!rt_strcmp(argv[1], "FastSet")){
		puc_buf = (uint8_t*)us_array;
		memcpy(argv[5],puc_buf,strlen(argv[5]));
		us_temp = EW_FastSetByUID(checker_runcfg.params[0],checker_runcfg.params[1],puc_buf,strlen(argv[5])-1,(uint8_t*)checker_runcfg.Test_Rtv);
		printf("FastSet Excute  %d delay %d\n",us_temp,checker_runcfg.Test_Rtv[0]);
	}else if(!rt_strcmp(argv[1], "SetDelay")){
		us_temp = EW_SetDelay(checker_runcfg.params[0],checker_runcfg.params[1]);
		printf("SetDelay Excute  %d \n",us_temp);
	}else if(!rt_strcmp(argv[1], "VerfyPWD")){
		puc_buf = (uint8_t*)us_array;
		memcpy(argv[3],puc_buf,strlen(argv[3]));
		us_temp = EW_VerfyPWD(checker_runcfg.params[0],puc_buf,strlen(argv[3])-1);
		printf("VerfyPWD Excute  %d \n",us_temp);
	}else if(!rt_strcmp(argv[1], "Boom")){
		us_temp = EW_Boom(checker_runcfg.params[0],checker_runcfg.params[1]);
		printf("Boom Excute %d \n",us_temp);
	}else if(!rt_strcmp(argv[1], "Charge")){
		us_temp = EW_Charge(checker_runcfg.params[0],checker_runcfg.params[1],checker_runcfg.params[2]);
		printf("Charge Excute %d \n",us_temp);
	}else if(!rt_strcmp(argv[1], "DisCharge")){
		us_temp = EW_DisCharge(checker_runcfg.params[0]);
		printf("DisCharge Excute %d \n",us_temp);
	}else if(!rt_strcmp(argv[1], "ReadState")){
		ul_temp = 0;
		us_temp = EW_ReadState(checker_runcfg.params[0],(uint8_t*)&ul_temp);
		printf("ReadState Excute %d state %08X\n",us_temp,ul_temp);
	}else if(!rt_strcmp(argv[1], "ClkAmend")){
		us_temp = EW_ClkAmend(checker_runcfg.params[0],checker_runcfg.params[1],checker_runcfg.params[2]);
		printf("ClkAmend Excute %d\n",us_temp);
	}else if(!rt_strcmp(argv[1], "Inspect")){
		puc_buf = (uint8_t*)us_array;
		us_temp = EW_Inspect(checker_runcfg.params[0],checker_runcfg.params[1],checker_runcfg.params[2],puc_buf);
		printf("Inspect Excute %d\n",us_temp);
		us_temp = (checker_runcfg.params[1] - checker_runcfg.params[0] + 7)/8;
		for(ul_temp = 0; ul_temp< us_temp;ul_temp++)
		{
			printf("%02X ",puc_buf[us_temp]);
			if((us_temp + 1) %8 == 0)
			{
				printf("\n");
			}
		}
		if((us_temp + 1) %8 != 0)
		{
			printf("\n");
		}
	}
	else if(!rt_strcmp(argv[1], "ClkAmend")){
		us_temp = EW_ClkAmend(checker_runcfg.params[0],checker_runcfg.params[1],checker_runcfg.params[2]);
		printf("ClkAmend Excute %d\n",us_temp);
	}	else if(!rt_strcmp(argv[1], "CheckRunCfg")){
		ul_temp = HexStrings2UInt(argv[3]);
		ul_temp2 = HexStrings2UInt(argv[4]);
		us_temp = EW_CheckRunCfg(checker_runcfg.params[0],ul_temp,ul_temp2,(uint8_t*)us_array);
		printf("CheckRunCfg Excute %d Checke_Flag %d\n",us_temp,us_array[0]);
	}else if(!rt_strcmp(argv[1], "ChecSelf")){
		us_array[0] = 0;
		us_temp = EW_ChecSelf(checker_runcfg.params[0],checker_runcfg.params[1],(uint8_t*)us_array);
		printf("ChecSelf Excute %d  SelfCheck Result %d \n",us_temp,us_array[0]);
	}	else if(!rt_strcmp(argv[1], "SaveFireInfo")){
		us_temp = EW_SaveFireInfo(checker_runcfg.params[0]);
		printf("SaveFireInfo Excute %d \n",us_temp);
	}	else if(!rt_strcmp(argv[1], "ReadDelayState")){
		us_array[0] = 0;
		us_temp = EW_ReadDelay(checker_runcfg.params[0],us_array);
		printf("SaveFireInfo Excute %d delay %d \n",us_temp,us_array[0]);
	}else if(!rt_strcmp(argv[1], "SetReportCfg")){
		us_temp = EW_SetReportCfg(checker_runcfg.params[0],checker_runcfg.params[1]);
		printf("SetReportCfg Excute %d \n",us_temp);
	}	else if(!rt_strcmp(argv[1], "UpdateCommAddr")){
		us_temp = EW_UpdateCommAddr(checker_runcfg.params[0],checker_runcfg.params[1]);
		printf("UpdateCommAddr Excute %d \n",us_temp);
	}else if(!rt_strcmp(argv[1], "ReadClkAmend")){
		us_temp = EW_ReadClkAmend(checker_runcfg.params[0],&ul_temp);
		printf("ReadClkAmend Excute %d amendValue %d\n",us_temp,ul_temp);
	}else if(!rt_strcmp(argv[1], "ReadCfgVer")){
		ul_temp2 = 0;
		ul_temp = 0;
		us_temp = EW_ReadRunCfgVersion(checker_runcfg.params[0],(uint8_t*)&ul_temp,(uint16_t*)&ul_temp2);
		printf("ReadCfgVer Excute %d RunCfg %08X Version %04X\n",us_temp,ul_temp,ul_temp2);
	}else if(!rt_strcmp(argv[1], "AutoSetAddr")){
		us_temp = EW_AutoSetAddr(checker_runcfg.params[0],checker_runcfg.params[1]);
		printf("AutoSetAddr Excute %d \n",us_temp);
	}else if(!rt_strcmp(argv[1], "EW_ReadUID")){
		puc_buf = (uint8_t*)us_array;
		us_temp = EW_ReadUID(checker_runcfg.params[0],puc_buf,checker_runcfg.params[1]);
		printf("EW_ReadUID Excute %d ",us_temp);
		us_temp = checker_runcfg.params[1];
		for(ul_temp = 0; ul_temp< us_temp;ul_temp++)
		{
			printf("%02X ",puc_buf[ul_temp]);
			if((ul_temp + 1) %8 == 0)
			{
				printf("\n");
			}
		}
		if((ul_temp + 1) %8 != 0)
		{
			printf("\n");
		}
		
	}						
	
	
	
	else{
		EW_help_label_:
		rt_kprintf("BUS_H   Out High Voltage");
		rt_kprintf("BUS_M 	Out Midle Voltage\n");
		rt_kprintf("BUS_L   Out High Voltage other side\n");
		rt_kprintf("BUS_OFF  Close Bus\n");
		rt_kprintf("BUS_ON   Open Bus\n");
		rt_kprintf("BUS_CUR  Get Bus Current\n");
		rt_kprintf("SetV 		 [Hight_V] [Midle_V]\n");
		rt_kprintf("CommTest [Cycle]VBusD Transport Test \n");
		rt_kprintf("EnWriteMTP [addr][en_flag] Enable or Disable MTP Written \n");
		rt_kprintf("WriteMTP   [addr][mtp_addr][dataSize][HexData] Write data to MTP \n");
		rt_kprintf("ReadMTP    [addr][mtp_addr][read_len] Read data from MTP \n");
		rt_kprintf("Boot    		Jump to BootLoader \n");
		rt_kprintf("WriteRunCfg [addr][mos_sw][reset_run_flg][uid_len][pwd_len][version]  \n");
		rt_kprintf("SetDelay  [addr][delay]\n");
		rt_kprintf("SetAddr  [commaddr][UID] Update CommAddr by UID\n");
		rt_kprintf("FastSet  [commaddr][delay][pwd_flag][UID] Fast Set Delay and CommAddr By UID\n");
		rt_kprintf("VerfyPWD  [addr][pwd] Verfy PWD\n");
		rt_kprintf("Boom      [addr][delay] \n");
		rt_kprintf("Charge    [addr][voltage_class][group]  voltage_class 0 bypass 1 16V 2 20V 3 3.5V  addr > group*4 \n");
		rt_kprintf("DisCharge [addr]\n");
		rt_kprintf("ReadState [addr] read delay and state\n");
		rt_kprintf("Inspect   [bgaddr] [endaddr] [state_mask]\n");
		rt_kprintf("ClkAmend  [addr] [Cycle] [PlusCount]\n");
		rt_kprintf("CheckRunCfg  [addr] [Cfg_mask_hex] [Cfg_state_hex]\n");
		rt_kprintf("ChecSelf  [addr] [Checke_Mode] [Result]\n");
		rt_kprintf("SaveFireInfo [addr]\n");
		rt_kprintf("ReadDelayState [addr]\n");
		rt_kprintf("SetReportCfg [speed][cur]\n");
		rt_kprintf("UpdateCommAddr [addr][new_addr]\n");
		rt_kprintf("ReadClkAmend [addr]\n");
		rt_kprintf("ReadCfgVer [addr]\n");
		rt_kprintf("AutoSetAddr [addr][addr_fac]\n");
		rt_kprintf("EW_ReadUID  [addr][uid_len]\n");
		
	}
}
MSH_CMD_EXPORT_ALIAS(EWDriverTest ,EW, EWPro Driver );


static void EWBDriverTest(int argc, char**argv)
{
	uint16_t us_array[20];
	uint8_t* puc_buf;
	uint16_t us_temp;
	uint32_t ul_temp;
	rt_memset(&checker_runcfg.params,0,sizeof(checker_runcfg.params));
	rt_memset(&checker_runcfg.Task_Result,0,sizeof(checker_runcfg.Task_Result));
	checker_runcfg.excue_rtv = 0;
	checker_runcfg.param_count = 0;
	checker_runcfg.rtv_count = 0;
	checker_runcfg.rtv_index = 0;
	checker_runcfg.task_info.runindex = 0;
	if(argc > 2)
	{
		checker_runcfg.param_count = argc-2;
		us_temp = 0;
		while(us_temp < checker_runcfg.param_count)
		{
			checker_runcfg.params[us_temp] = atoi(argv[us_temp+2]);
			us_temp++;
		}
	}
	if (argc < 2)
	{
		 goto EW_help_label_;
	}else if(!rt_strcmp(argv[1], "BUS_H")){
		EW_DIFF_MOD_H
	}else if(!rt_strcmp(argv[1], "BUS_L")){
		
		EW_DIFF_MOD_L
		
	}else if(!rt_strcmp(argv[1], "BUS_M")){
		EW_DIFF_MOD_M
		
	}else if(!rt_strcmp(argv[1], "BUS_OFF")){
		HMOS_SWITCH_OFF
		
	}else if(!rt_strcmp(argv[1], "BUS_ON")){
		HMOS_SWITCH_ON
		
	}
	else if(!rt_strcmp(argv[1], "BUS_CUR")){
		printf("BUS_CUR %d \r\n",Power_GetCurrent());
	}
	else if(!rt_strcmp(argv[1], "SetV")){
		us_temp = PowerCalibration_set(checker_runcfg.params[0],checker_runcfg.params[1]);
		printf("SetV Excute  %d\n",us_temp);
	}
	else if(!rt_strcmp(argv[1], "ChgCtrl")){
		us_temp = EWB_ChgCtrl(checker_runcfg.params[0]);
		printf("ChgCtrl Excute  %d \n",us_temp);
	}else if(!rt_strcmp(argv[1], "EraseMTP")){
		us_temp = EWB_EraseMTP(checker_runcfg.params[0],checker_runcfg.params[1]);
		printf("EraseMTP Excute  %d\n",us_temp);
	}else if(!rt_strcmp(argv[1], "EraseCode")){
		us_temp = EWB_EraseCode();
		printf("EraseCode Excute  %d\n",us_temp);
	}else if(!rt_strcmp(argv[1], "ReadMTP")){
		puc_buf = (uint8_t*)us_array;
		memset(us_array,0,checker_runcfg.params[1]+1);
		us_temp = EWB_ReadMTP(checker_runcfg.params[0],checker_runcfg.params[1],puc_buf);
		printf("ReadMTP Excute  %d \n",us_temp);
		for(us_temp = 0; us_temp < checker_runcfg.params[1]; us_temp++)
		{
			printf("%02X ",puc_buf[us_temp]);
			if((us_temp + 1) %8 == 0)
			{
				printf("\n");
			}
		}
		if((us_temp + 1) %8 != 0)
		{
			printf("\n");
		}
	}else if(!rt_strcmp(argv[1], "CacluCrc32")){
		us_temp = EWB_CacluCrc32(checker_runcfg.params[0],checker_runcfg.params[1],&ul_temp);
		printf("CacluCrc32 Excute  %d  %08X\n",us_temp,ul_temp);
	}else if(!rt_strcmp(argv[1], "RunApp")){
		us_temp = EWB_RunApp();
		printf("RunApp Excute  %d\n",us_temp);
	}else if(!rt_strcmp(argv[1], "WriteMTP")){
		HexStrings2Byte(argv+4,argc-4,(uint8_t*)us_array,sizeof(us_array));
		us_temp = EWB_WriteMTP(checker_runcfg.params[0],(const uint8_t*)us_array,checker_runcfg.params[1]);
		printf("WriteMTP Excute  %d\n",us_temp);
	}				
	else{
		EW_help_label_:
		rt_kprintf("BUS_H   Out High Voltage");
		rt_kprintf("BUS_M 	Out Midle Voltage\n");
		rt_kprintf("BUS_L   Out High Voltage other side\n");
		rt_kprintf("BUS_OFF  Close Bus\n");
		rt_kprintf("BUS_ON   Open Bus\n");
		rt_kprintf("BUS_CUR  Get Bus Current\n");
		rt_kprintf("SetV 		 [Hight_V] [Midle_V]\n");
		rt_kprintf("ChgCtrl  [Chg_SW] \n");
		rt_kprintf("EraseMTP [bgaddr][endaddr]\n");
		rt_kprintf("EraseCode    \n");
		rt_kprintf("ReadMTP   [bgaddr][read_len] \n");
		rt_kprintf("CacluCrc32 [bgaddr][endaddr]  \n");
		rt_kprintf("RunApp  \n");
		rt_kprintf("WriteMTP  [MTP Addr][w_len] [hex data]\n");
		
	}
}
MSH_CMD_EXPORT_ALIAS(EWBDriverTest ,EWB, EW BootLoader Driver );

