Browse Source

平峰硬件错误测试

LAPTOP-KB7QFH2U\ChenJie-PC 2 years ago
parent
commit
a0231bd571
8 changed files with 73 additions and 37 deletions
  1. 2 2
      .cproject
  2. 1 2
      Project_Settings/Startup_Code/exceptions.c
  3. 1 1
      src/AppGlobalVar.h
  4. 43 12
      src/AppTaskCan.c
  5. 11 0
      src/AppTaskMain.c
  6. 11 11
      src/AppTaskUart0.c
  7. 0 5
      src/AppTaskUart1.c
  8. 4 4
      src/hal_adapter.c

+ 2 - 2
.cproject

@@ -30,7 +30,7 @@
 							<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="cdt.managedbuild.targetPlatform.gnu.cross.64147430" isAbstract="false" osList="all" superClass="cdt.managedbuild.targetPlatform.gnu.cross"/>
 							<builder buildPath="${workspace_loc:/S32K146_4G}/Debug_FLASH" id="com.freescale.s32ds.cross.gnu.builder.466747471" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="FSL Make Builder" superClass="com.freescale.s32ds.cross.gnu.builder"/>
 							<tool id="com.nxp.s32ds.cle.arm.mbs.arm32.bare.gnu.9.2.tool.c.compiler.1980082058" name="Standard S32DS C Compiler" superClass="com.nxp.s32ds.cle.arm.mbs.arm32.bare.gnu.9.2.tool.c.compiler">
-								<option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.option.optimization.level.1168627068" name="Optimization Level" superClass="gnu.c.compiler.option.optimization.level" useByScannerDiscovery="false" value="gnu.c.optimization.level.none" valueType="enumerated"/>
+								<option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.option.optimization.level.1168627068" name="Optimization Level" superClass="gnu.c.compiler.option.optimization.level" useByScannerDiscovery="false" value="gnu.c.optimization.level.size" valueType="enumerated"/>
 								<option defaultValue="gnu.c.debugging.level.max" id="gnu.c.compiler.option.debugging.level.1120041103" name="Debug Level" superClass="gnu.c.compiler.option.debugging.level" useByScannerDiscovery="false" value="gnu.c.debugging.level.max" valueType="enumerated"/>
 								<option id="com.freescale.s32ds.cross.gnu.tool.c.compiler.option.optimization.functionsections.1916093778" name="Function sections (-ffunction-sections)" superClass="com.freescale.s32ds.cross.gnu.tool.c.compiler.option.optimization.functionsections" useByScannerDiscovery="true" value="false" valueType="boolean"/>
 								<option id="com.freescale.s32ds.cross.gnu.tool.c.compiler.option.optimization.datasections.499071697" name="Data sections (-fdata-sections)" superClass="com.freescale.s32ds.cross.gnu.tool.c.compiler.option.optimization.datasections" useByScannerDiscovery="true" value="false" valueType="boolean"/>
@@ -777,7 +777,7 @@
 		</scannerConfigBuildInfo>
 	</storageModule>
 	<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
-	<storageModule moduleId="org.eclipse.embsys" parent_project="true" register_architecture="" register_board="---  none ---" register_chip="" register_core="" register_vendor=""/>
+	<storageModule moduleId="org.eclipse.embsys" parent_project="true" register_architecture="" register_board="---  none ---" register_chip="S32K146" register_core="CortexM4F" register_vendor=""/>
 	<storageModule moduleId="refreshScope" versionNumber="2">
 		<configuration configurationName="Release_FLASH">
 			<resource resourceType="PROJECT" workspacePath="/S32K146_4G"/>

+ 1 - 2
Project_Settings/Startup_Code/exceptions.c

@@ -81,14 +81,13 @@ void SVC_Handler(void)
 }
 #endif
 #endif
-
-
 void NMI_Handler(void)
 {
     while(TRUE){};
 }
 void HardFault_Handler(void)
 {
+	ASM_KEYWORD("bx lr");
     while(TRUE){};
 }
 void MemManage_Handler(void)

+ 1 - 1
src/AppGlobalVar.h

@@ -26,7 +26,7 @@
 #define HWVERSION 0x0001
 #define BLSWVERSION 0x00000002
 #define DRVSWVERSION 0x00000002
-#define APPSWVERSION 0x00000005
+#define APPSWVERSION 0x00000006
 #define BMS_MANUFACTURE 0xFF
 #define BMS_INFO 0xFF
 #define DATA_MODULE_TYPE 0x02

+ 43 - 12
src/AppTaskCan.c

@@ -110,6 +110,37 @@ static void UDSAnsFunc(uint8 *rawData)
 		}
 		break;
 	}
+	case 0x11://¿ØÖÆ
+	{
+		if(UdsStates==0x02)
+		{
+			switch(UdsSubService)
+			{
+				case 0x01://ÖØÆô
+				{
+					AnsData[0] = APPSWVERSION>>24;
+					AnsData[1] = APPSWVERSION>>16;
+					AnsData[2] = APPSWVERSION>>8;
+					AnsData[3] = APPSWVERSION>>0;
+					UdsAns(true,UdsService,UdsSubService,0x00,AnsData,4);
+					AppConfigInfo.appSaveFlg = true;
+					vTaskDelay(pdMS_TO_TICKS(1000));
+					SystemSoftwareReset();
+					break;
+				}
+				default:
+				{
+					UdsAns(false,UdsService,UdsSubService,0x00,NULL,0);
+					break;
+				}
+			}
+		}
+		else
+		{
+			UdsAns(false,UdsService,UdsSubService,0x00,NULL,0);
+		}
+		break;
+	}
 	case 0x22://²éѯ
 	{
 		if(UdsStates==0x02)
@@ -227,18 +258,6 @@ static void UDSAnsFunc(uint8 *rawData)
 		}
 		break;
 	}
-	case 0x27://¿ØÖÆ
-	{
-		if(UdsStates==0x02)
-		{
-
-		}
-		else
-		{
-			UdsAns(false,UdsService,UdsSubService,0x00,NULL,0);
-		}
-		break;
-	}
 	case 0x2E://дÈë
 	{
 		if(UdsStates==0x02)
@@ -273,6 +292,18 @@ static void UDSAnsFunc(uint8 *rawData)
 		}
 		break;
 	}
+	case 0x31://¿ØÖÆ
+	{
+		if(UdsStates==0x02)
+		{
+
+		}
+		else
+		{
+			UdsAns(false,UdsService,UdsSubService,0x00,NULL,0);
+		}
+		break;
+	}
 	default:
 		break;
 	}

+ 11 - 0
src/AppTaskMain.c

@@ -35,6 +35,17 @@ void MainTask(void *pvParameters)
 				WATCHDOG_HAL_Feed();
 			}
 		}
+		if(TimerCounter%200==0)
+		{
+			if(AppConfigInfo.eolFlg==true)
+			{
+				Dio_FlipChannel(DioConf_DioChannel_PTE9_GPIO_OUT_MCU_LED5);
+			}
+			else
+			{
+				Dio_WriteChannel(DioConf_DioChannel_PTE9_GPIO_OUT_MCU_LED5, STD_ON);
+			}
+		}
 		if(AppConfigInfo.appSaveFlg)
 		{
 			AppConfigInfo.appSaveFlg = false;

+ 11 - 11
src/AppTaskUart0.c

@@ -76,6 +76,11 @@ void Uart0Task(void *pvParameters)
 				{
 					ReadDelayCounter++;
 				}
+				if(UartDataRecv!=NULL)
+				{
+					free(UartDataRecv);
+				}
+				UartDataRecv=NULL;
 				if(ReadLen1>=ReadLenTar)
 				{
 					ReadDelayCounter = 0;
@@ -90,11 +95,6 @@ void Uart0Task(void *pvParameters)
 					ReadLen1 = 0;
 					break;
 				}
-				if(UartDataRecv!=NULL)
-				{
-					free(UartDataRecv);
-				}
-				UartDataRecv=NULL;
 			}
 			if (pReadLen > 0)
 			{
@@ -145,6 +145,11 @@ void Uart0Task(void *pvParameters)
 				{
 					ReadDelayCounter++;
 				}
+				if(UartDataRecv!=NULL)
+				{
+					free(UartDataRecv);
+				}
+				UartDataRecv=NULL;
 				if(ReadLen1>=ReadLenTar)
 				{
 					ReadDelayCounter = 0;
@@ -159,11 +164,6 @@ void Uart0Task(void *pvParameters)
 					ReadLen1 = 0;
 					break;
 				}
-				if(UartDataRecv!=NULL)
-				{
-					free(UartDataRecv);
-				}
-				UartDataRecv=NULL;
 			}
 			if (pReadLen > 0)
 			{
@@ -478,7 +478,7 @@ void battDataCalFunc(void)
 	static float battEnrgTemp = 0;
 	timediff = TimerCounter - timercounterCal;
 	timercounterCal = TimerCounter;
-	if(timediff==0 ||timediff>10000)
+	if(timediff==0 ||timediff>60*1000)
 	{
 		return;
 	}

+ 0 - 5
src/AppTaskUart1.c

@@ -918,10 +918,6 @@ void TcpDataEncode(uint32 *PtrSendAddr, uint16 *SendLen)
 		*SendLen = ProtocolFixedLen + ProtocolFluctedLen;
 		SendBuffer = malloc(*SendLen);
 		GetCSQValue(&CSQValue);
-		if (SendBuffer == NULL)
-		{
-			return;
-		}
 		*(SendBuffer + 0) = TCP_START_SYM1;									 //ÆðʼÂë-1
 		*(SendBuffer + 1) = TCP_START_SYM2;									 //ÆðʼÂë-2
 		*(SendBuffer + 2) = TCP_CMD_SYM;									 //ÃüÁî±êʶ-3
@@ -1161,7 +1157,6 @@ void GetUtc8Time(UTC8TimeType *UTC8TimeTcp)
 			UTC8TimeTcp->minute = CharToHex(*(retptr + 20)) * 10 + CharToHex(*(retptr + 21));
 			UTC8TimeTcp->second = CharToHex(*(retptr + 23)) * 10 + CharToHex(*(retptr + 24));
 		}
-
 		if(UartRecvPtr != NULL)
 		{
 			free(UartRecvPtr);

+ 4 - 4
src/hal_adapter.c

@@ -281,13 +281,13 @@ Std_ReturnType UART_Send_Data(uint8 transChannel, const uint8 *txBuffer, uint32
 		  {
 			  if(UartHalMsgRecv.event==LPUART_UART_IP_EVENT_RECV_IDLE)
 			  {
+					if(UartHalMsgRecv.value>0)
+					{
 					UartMsg.DataLen = UartHalMsgRecv.value;
-					UartMsg.dataPrt = malloc(UartMsg.DataLen);
+					UartMsg.dataPrt = calloc(UartMsg.DataLen,sizeof(UINT8));
 					memset(UartMsg.dataPrt,0,UartMsg.DataLen);
 					memcpy(UartMsg.dataPrt,RX_Buffer[UartHalMsgRecv.Channel],UartMsg.DataLen);
-					if(UartMsg.DataLen>0)
-					{
-						xQueueSend(UartRecvQueue[UartHalMsgRecv.Channel],&UartMsg,10);
+					xQueueSend(UartRecvQueue[UartHalMsgRecv.Channel],&UartMsg,10);
 					}
 					T_timeout[UartHalMsgRecv.Channel] = 0;
 					UartState[UartHalMsgRecv.Channel] = UartRecvComplete;