/******************************************************************************* 功能:复位CAN控制器。 参数:无。 输出:无。 *********************************************************************************/ static bool_t Sh_CAN_Reset(char *param) { char *word_ChipNum,*word_trail,*next_param; uint8_t byCanNo; bool_t ret; //提取1个参数 extern char *Sh_GetWord(char *buf,char **next); word_ChipNum = Sh_GetWord(param,&next_param); word_trail = Sh_GetWord(next_param,&next_param); if((word_ChipNum == NULL)||(word_trail != NULL)) { printf("\r\n格式错误,正确格式是:\r\n>d CAN控制器编号. \r\n"); return false; } byCanNo = strtol(word_ChipNum, (char **)NULL, 0); if(byCanNo>=2) { printf("The Chip Num must be one of 0/1!\r\n"); return false; } ret=CAN_Hard_Init(byCanNo,gs_CANBaudRate[byCanNo],gs_pCanFilterPara); if(!ret) printf("CAN reset failed.\r\n"); else printf("CAN reset success.\r\n"); return true; }
bool_t debug_dm9000a_write_reg(char *param) { char *word, *next_param; u32 reg = 0; u32 value = 0; // 提取为SOCKET号 if (param) { next_param = param; word = Sh_GetWord(next_param, &next_param); reg = __sh_atol(word); word = Sh_GetWord(next_param, &next_param); value = __sh_atol(word); word = Sh_GetWord(next_param, &next_param); if(word != NULL) { printf("\r\n参数错误\r\n"); return false; } } if (Lock_SempPend(semp_dm9000, 10000*mS) == true) { Int_SaveAsynLine(cn_int_line_enet); // 关闭DM9000A的外部中断 printf("\r\n写入DM9000A的【%4x】寄存器:%4x", reg, value); iow(reg, value); printf("\r\n"); Int_RestoreAsynLine(cn_int_line_enet); // 打开DM9000A的外部中断 Lock_SempPost(semp_dm9000); } return true; }
//------pcie命令---------------------------------- //功能:shell命令,查看pcie设备信息 //参数:param: 字符串 //返回:true: 打印完成 //---------------------------------------------------------- bool_t sh_cmd_pcie(char *param) { ptu32_t busno; char *next_param; char *str_busno; int i; if(param == NULL) { for(i =0; i<=pci_last_busno(); i++) pciinfo(i); return true; } str_busno = Sh_GetWord(param,&next_param); if(str_busno == NULL) { for(i =0; i<=pci_last_busno(); i++) pciinfo(i); return true; } busno = strtol(str_busno, (char **)NULL, 0); if(busno>pci_last_busno()) { printf("输入的pcie设备 bus号超过了当前总线上的最大bus号\r\n"); return false; } else pciinfo(busno); return true; }
/******************************************************************************* 功能:获取CAN可读寄存器的值。 参数:无. 输出:无。 *******************************************************************************/ static void Sh_CAN_LoopBack(char *param) { char *word_ChipNum,*word_trail,*next_param; uint8_t byCanNo; //提取1个参数 extern char *Sh_GetWord(char *buf,char **next); word_ChipNum = Sh_GetWord(param,&next_param); word_trail = Sh_GetWord(next_param,&next_param); if((word_ChipNum == NULL)||(word_trail != NULL)) { printf("\r\n格式错误,正确格式是:\r\n>d CAN控制器编号. \r\n"); return ; } byCanNo = strtol(word_ChipNum, (char **)NULL, 0); if(byCanNo>=2) { printf("The Chip Num must be one of 0/1!\r\n"); return ; } gs_bLoopBackFlag=true; CAN_Hard_Init(byCanNo,gs_CANBaudRate[byCanNo],gs_pCanFilterPara); }
bool_t Sh_Reboot(char *param) { u32 flag; char *word_addr,*next_param; //提取参数 word_addr = Sh_GetWord(param,&next_param); if(word_addr == NULL) { printf("\r\n格式错误,正确格式是:\r\n异常条目\r\n"); return false; } flag = strtol(word_addr, (char **)NULL, 0); if(flag==monitor_reboot) __second_stage_reboot(flag); else if(flag==release_reboot) __second_stage_reboot(flag); else return false; return true; }
/******************************************************************************* 功能:CAN控制块内存申请初始化。 参数:空。 返回:true--初始化成功,false--初始化失败。 ******************************************************************************/ static void Sh_CAN_FilterConfig(char *param) { char *word_FilterIdHigh,*word_FilterIdLow,*word_FilterMaskIdHigh,*word_FilterMaskIdLow; char *word_FilterFIFOAssignment,*word_FilterNumber,*word_FilterMode; char *word_FilterScale,*word_FilterActivation,*word_BankNumber; char *word_trail,*next_param; CanFilterConfPara Para; uint8_t i; extern char *Sh_GetWord(char *buf,char **next); word_FilterIdHigh = Sh_GetWord(param,&next_param); word_FilterIdLow=Sh_GetWord(next_param,&next_param); word_FilterMaskIdHigh=Sh_GetWord(next_param,&next_param); word_FilterMaskIdLow=Sh_GetWord(next_param,&next_param); word_FilterFIFOAssignment=Sh_GetWord(next_param,&next_param); word_FilterNumber=Sh_GetWord(next_param,&next_param); word_FilterMode=Sh_GetWord(next_param,&next_param); word_FilterScale=Sh_GetWord(next_param,&next_param); word_FilterActivation=Sh_GetWord(next_param,&next_param); word_BankNumber=Sh_GetWord(next_param,&next_param); word_trail = Sh_GetWord(next_param,&next_param); if((word_FilterIdHigh == NULL)||(word_FilterIdLow==NULL)||(word_FilterMaskIdHigh==NULL)||\ (word_FilterMaskIdLow==NULL)||(word_FilterFIFOAssignment==NULL)||\ (word_FilterNumber==NULL)||(word_FilterMode==NULL)||(word_FilterScale==NULL)||\ (word_FilterActivation==NULL)||(word_BankNumber==NULL)||(word_trail != NULL)) { printf("\r\nCAN过滤器参数不对.\r\n"); return ; } Para.FilterIdHigh=strtol(word_FilterIdHigh, (char **)NULL, 0); Para.FilterIdLow=strtol(word_FilterIdLow, (char **)NULL, 0); Para.FilterMaskIdHigh=strtol(word_FilterMaskIdHigh, (char **)NULL, 0); Para.FilterMaskIdLow=strtol(word_FilterMaskIdLow, (char **)NULL, 0); Para.FilterFIFOAssignment=strtol(word_FilterFIFOAssignment, (char **)NULL, 0); Para.FilterNumber=strtol(word_FilterNumber, (char **)NULL, 0); Para.FilterMode=strtol(word_FilterMode, (char **)NULL, 0); Para.FilterScale=strtol(word_FilterScale, (char **)NULL, 0); Para.FilterActivation=strtol(word_FilterActivation, (char **)NULL, 0); Para.BankNumber=strtol(word_BankNumber, (char **)NULL, 0); memcpy(gs_pCanFilterPara,&Para,sizeof(CanFilterConfPara)); for(i=0;i<CN_CAN_NUM;i++) { CAN_Hard_Init(i,gs_CANBaudRate[i],gs_pCanFilterPara); } }
bool_t debug_dm9000a_read_reg(char *param) { char *word, *next_param; int i; u32 reg = 0xFFFF; // 提取为SOCKET号 if (param) { next_param = param; word = Sh_GetWord(next_param, &next_param); reg = __sh_atol(word); word = Sh_GetWord(next_param, &next_param); if(word != NULL) { printf("\r\n参数错误\r\n"); return false; } } if (Lock_SempPend(semp_dm9000, 10000*mS) == true) { Int_SaveAsynLine(cn_int_line_enet); // 关闭DM9000A的外部中断 if (reg != 0xFFFF) { printf("\r\n读取DM9000A的【%4x】寄存器:", reg); printf("\r\n %4x:%4x", reg, ior(reg)); } else { printf("\r\n读取DM9000A的【所有】寄存器:"); printf("\r\n"); for (i=0; i<=0x1f; i++) { printf("\r\n %4x:%4x", i, ior(i)); } printf("\r\n"); for (i=0x22; i<=0x25; i++) { printf("\r\n %4x:%4x", i, ior(i)); } printf("\r\n"); for (i=0x28; i<=0x34; i++) { printf("\r\n %4x:%4x", i, ior(i)); } printf("\r\n"); i = 0x38; printf("\r\n %4x:%4x", i, ior(i)); i = 0x39; printf("\r\n %4x:%4x", i, ior(i)); printf("\r\n"); i = 0x50; printf("\r\n %4x:%4x", i, ior(i)); i = 0x51; printf("\r\n %4x:%4x", i, ior(i)); printf("\r\n"); i = 0xF0; printf("\r\n %4x:%4x", i, ior(i)); i = 0xF1; printf("\r\n %4x:%4x", i, ior(i)); i = 0xF2; printf("\r\n %4x:%4x", i, ior(i)); i = 0xF4; printf("\r\n %4x:%4x", i, ior(i)); i = 0xF5; printf("\r\n %4x:%4x", i, ior(i)); i = 0xF6; printf("\r\n %4x:%4x", i, ior(i)); i = 0xF8; printf("\r\n %4x:%4x", i, ior(i)); printf("\r\n"); for (i=0xFA; i<=0xFF; i++) { printf("\r\n %4x:%4x", i, ior(i)); } } printf("\r\n"); Int_RestoreAsynLine(cn_int_line_enet); // 打开DM9000A的外部中断 Lock_SempPost(semp_dm9000); } return true; }