Преглед на файлове

1、优化了UART接收,将超时LPUART_UART_IP_TIMEOUT_VALUE_US 由500ms改成500us(500000->500),仅适用于Uart_Abort函数
2、修改Free RTOS配置文件,优先级个数改为15个,堆栈提高至8192*4,提高时钟优先级至最高(14)
3、修改main函数各个任务的优先级(注:任务优先级与数值正相关,中断优先级与数值负相关)

CHENJIE-PC\QiXiang_CHENJIE преди 3 години
родител
ревизия
5d3180f97f

+ 4 - 4
.settings/language.settings.xml

@@ -5,7 +5,7 @@
 			<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
 			<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
 			<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
-			<provider class="com.freescale.s32ds.cross.gnu.CrossGCCBuiltinSpecsDetector" console="false" env-hash="1805121227979261312" id="com.freescale.s32ds.cross.gnu.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT S32DS Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
+			<provider class="com.freescale.s32ds.cross.gnu.CrossGCCBuiltinSpecsDetector" console="false" env-hash="512964616103659477" id="com.freescale.s32ds.cross.gnu.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT S32DS Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
 				<language-scope id="org.eclipse.cdt.core.gcc"/>
 				<language-scope id="org.eclipse.cdt.core.g++"/>
 			</provider>
@@ -16,7 +16,7 @@
 			<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
 			<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
 			<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
-			<provider class="com.freescale.s32ds.cross.gnu.CrossGCCBuiltinSpecsDetector" console="false" env-hash="1805121227979261312" id="com.freescale.s32ds.cross.gnu.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT S32DS Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
+			<provider class="com.freescale.s32ds.cross.gnu.CrossGCCBuiltinSpecsDetector" console="false" env-hash="512964616103659477" id="com.freescale.s32ds.cross.gnu.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT S32DS Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
 				<language-scope id="org.eclipse.cdt.core.gcc"/>
 				<language-scope id="org.eclipse.cdt.core.g++"/>
 			</provider>
@@ -27,7 +27,7 @@
 			<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
 			<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
 			<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
-			<provider class="com.freescale.s32ds.cross.gnu.CrossGCCBuiltinSpecsDetector" console="false" env-hash="1805121227979261312" id="com.freescale.s32ds.cross.gnu.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT S32DS Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
+			<provider class="com.freescale.s32ds.cross.gnu.CrossGCCBuiltinSpecsDetector" console="false" env-hash="512964616103659477" id="com.freescale.s32ds.cross.gnu.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT S32DS Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
 				<language-scope id="org.eclipse.cdt.core.gcc"/>
 				<language-scope id="org.eclipse.cdt.core.g++"/>
 			</provider>
@@ -38,7 +38,7 @@
 			<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
 			<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
 			<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
-			<provider class="com.freescale.s32ds.cross.gnu.CrossGCCBuiltinSpecsDetector" console="false" env-hash="1805121227979261312" id="com.freescale.s32ds.cross.gnu.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT S32DS Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
+			<provider class="com.freescale.s32ds.cross.gnu.CrossGCCBuiltinSpecsDetector" console="false" env-hash="512964616103659477" id="com.freescale.s32ds.cross.gnu.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT S32DS Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
 				<language-scope id="org.eclipse.cdt.core.gcc"/>
 				<language-scope id="org.eclipse.cdt.core.g++"/>
 			</provider>

+ 7 - 5
FreeRTOS/Source/include/FreeRTOSConfig.h

@@ -44,7 +44,7 @@
 
 #define configCPU_CLOCK_HZ                          ( 48000000UL )
 #define configTICK_RATE_HZ                          ((TickType_t) 1000 )
-#define configMAX_PRIORITIES                        5
+#define configMAX_PRIORITIES                        15
 #define configMINIMAL_STACK_SIZE                    ((unsigned short) 90 )
 #define configMAX_TASK_NAME_LEN                     10
 #define configUSE_16_BIT_TICKS                      0
@@ -72,7 +72,7 @@ PRIORITY THAN THIS! (higher priorities are lower numeric values. */
 /* Memory allocation related definitions. */
 #define configSUPPORT_STATIC_ALLOCATION             0
 #define configSUPPORT_DYNAMIC_ALLOCATION            1
-#define configTOTAL_HEAP_SIZE                       (( size_t ) 8192 )
+#define configTOTAL_HEAP_SIZE                       (( size_t ) 8192*4 )
 #define configAPPLICATION_ALLOCATED_HEAP            0
 
 /* Hook function related definitions. */
@@ -100,9 +100,11 @@ PRIORITY THAN THIS! (higher priorities are lower numeric values. */
 
 /* Software timer related definitions. */
 #define configUSE_TIMERS                            1
-#define configTIMER_TASK_PRIORITY                   2
+#define configTIMER_TASK_PRIORITY                   14
 #define configTIMER_QUEUE_LENGTH                    10
-#define configTIMER_TASK_STACK_DEPTH                180
+#define configTIMER_TASK_STACK_DEPTH                256
+
+#define configIDLE_TASK_STACK_DEPTH					512
 
 /* Tickless Idle Mode */
 #define configUSE_TICKLESS_IDLE                     0
@@ -148,7 +150,7 @@ PRIORITY THAN THIS! (higher priorities are lower numeric values. */
 
 /* The lowest interrupt priority that can be used in a call to a "set priority"
 function. */
-#define configLIBRARY_LOWEST_INTERRUPT_PRIORITY  (0x0F)
+#define configLIBRARY_LOWEST_INTERRUPT_PRIORITY  (0x01)
 
 /* Interrupt priorities used by the kernel port layer itself.  These are generic
 to all Cortex-M ports, and do not rely on any particular library functions. */

+ 2 - 2
RTD/include/Lpuart_Uart_Ip_HwAccess.h

@@ -698,10 +698,10 @@ static inline void Lpuart_Uart_Ip_StartTimeout(uint32 *StartTimeOut, uint32 *Tim
 
 static inline boolean Lpuart_Uart_Ip_CheckTimeout(uint32 * StartTime, uint32 * ElapsedTicks, uint32 TimeoutTicks, OsIf_CounterType OsifCounter)
 {
-	Dio_WriteChannel(DioConf_DioChannel_PTE1_GPIO_OUT_MCU_LED2,STD_OFF);
+//	Dio_WriteChannel(DioConf_DioChannel_PTE1_GPIO_OUT_MCU_LED2,STD_OFF);
     uint32 CurrentElapsedTicks = OsIf_GetElapsed(StartTime, OsifCounter);
     *ElapsedTicks += CurrentElapsedTicks;
-    Dio_WriteChannel(DioConf_DioChannel_PTE1_GPIO_OUT_MCU_LED2,STD_ON);
+//    Dio_WriteChannel(DioConf_DioChannel_PTE1_GPIO_OUT_MCU_LED2,STD_ON);
     return ((*ElapsedTicks >= TimeoutTicks) ? TRUE : FALSE);
 
 }

+ 2 - 2
RTD/src/Lpuart_Uart_Ip.c

@@ -1230,9 +1230,9 @@ void Lpuart_Uart_Ip_IrqHandler(const uint8 Instance)
 		{
 			if (Lpuart_Uart_Ip_GetIntMode(Base, (uint32)LPUART_UART_IP_IDLE))
 			{
-				Dio_WriteChannel(DioConf_DioChannel_PTE0_GPIO_OUT_MCU_LED1,STD_OFF);
+//				Dio_WriteChannel(DioConf_DioChannel_PTE0_GPIO_OUT_MCU_LED1,STD_OFF);
 				Lpuart_Uart_Ip_RxIdleIrqHandler(Instance);
-				Dio_WriteChannel(DioConf_DioChannel_PTE0_GPIO_OUT_MCU_LED1,STD_ON);
+//				Dio_WriteChannel(DioConf_DioChannel_PTE0_GPIO_OUT_MCU_LED1,STD_ON);
 				//return;
 			}
 			else

+ 1 - 1
generate/include/Lpuart_Uart_Ip_Defines.h

@@ -86,7 +86,7 @@ extern "C"{
 #define LPUART_UART_IP_TIMEOUT_TYPE                 (OSIF_COUNTER_SYSTEM)
 
 /* @brief Number of loops before returning LPUART_STATUS_TIMEOUT.*/
-#define LPUART_UART_IP_TIMEOUT_VALUE_US             (500000U)
+#define LPUART_UART_IP_TIMEOUT_VALUE_US             (500U)  //zhengchao
 
 /* @brief LPUART DMA support */
 #define LPUART_UART_IP_HAS_DMA_ENABLED              (STD_ON)

+ 16 - 16
generate/src/IntCtrl_Ip_Cfg.c

@@ -61,14 +61,14 @@ extern "C" {
 
 /* List of configurations for interrupts */
 static const IntCtrl_Ip_IrqConfigType aIrqConfiguration[] = {
-    {DMA0_IRQn, (boolean)TRUE, 0U},
-    {DMA1_IRQn, (boolean)TRUE, 0U},
-    {DMA2_IRQn, (boolean)TRUE, 0U},
-    {DMA3_IRQn, (boolean)TRUE, 3U},
-    {DMA4_IRQn, (boolean)TRUE, 3U},
-    {DMA5_IRQn, (boolean)TRUE, 3U},
-    {DMA6_IRQn, (boolean)TRUE, 3U},
-    {DMA7_IRQn, (boolean)TRUE, 3U},
+    {DMA0_IRQn, (boolean)TRUE, 6U},
+    {DMA1_IRQn, (boolean)TRUE, 6U},
+    {DMA2_IRQn, (boolean)TRUE, 6U},
+    {DMA3_IRQn, (boolean)TRUE, 7U},
+    {DMA4_IRQn, (boolean)TRUE, 7U},
+    {DMA5_IRQn, (boolean)TRUE, 7U},
+    {DMA6_IRQn, (boolean)TRUE, 7U},
+    {DMA7_IRQn, (boolean)TRUE, 7U},
     {DMA8_IRQn, (boolean)FALSE, 0U},
     {DMA9_IRQn, (boolean)FALSE, 0U},
     {DMA10_IRQn, (boolean)FALSE, 0U},
@@ -89,10 +89,10 @@ static const IntCtrl_Ip_IrqConfigType aIrqConfiguration[] = {
     {LPI2C0_Slave_IRQn, (boolean)TRUE, 0U},
     {LPSPI0_IRQn, (boolean)FALSE, 0U},
     {LPSPI1_IRQn, (boolean)FALSE, 0U},
-    {LPSPI2_IRQn, (boolean)TRUE, 3U},
-    {LPUART0_RxTx_IRQn, (boolean)TRUE, 3U},
-    {LPUART1_RxTx_IRQn, (boolean)TRUE, 3U},
-    {LPUART2_RxTx_IRQn, (boolean)TRUE, 3U},
+    {LPSPI2_IRQn, (boolean)TRUE, 7U},
+    {LPUART0_RxTx_IRQn, (boolean)TRUE, 7U},
+    {LPUART1_RxTx_IRQn, (boolean)TRUE, 7U},
+    {LPUART2_RxTx_IRQn, (boolean)TRUE, 7U},
     {ADC0_IRQn, (boolean)FALSE, 0U},
     {ADC1_IRQn, (boolean)TRUE, 0U},
     {CMP0_IRQn, (boolean)FALSE, 0U},
@@ -120,10 +120,10 @@ static const IntCtrl_Ip_IrqConfigType aIrqConfiguration[] = {
     {CAN0_Wake_Up_IRQn, (boolean)TRUE, 0U},
     {CAN0_ORed_0_15_MB_IRQn, (boolean)TRUE, 0U},
     {CAN0_ORed_16_31_MB_IRQn, (boolean)TRUE, 0U},
-    {CAN1_ORed_IRQn, (boolean)TRUE, 0U},
-    {CAN1_Error_IRQn, (boolean)TRUE, 0U},
-    {CAN1_ORed_0_15_MB_IRQn, (boolean)TRUE, 0U},
-    {CAN1_ORed_16_31_MB_IRQn, (boolean)TRUE, 0U},
+    {CAN1_ORed_IRQn, (boolean)TRUE, 7U},
+    {CAN1_Error_IRQn, (boolean)TRUE, 7U},
+    {CAN1_ORed_0_15_MB_IRQn, (boolean)TRUE, 7U},
+    {CAN1_ORed_16_31_MB_IRQn, (boolean)TRUE, 7U},
     {CAN2_ORed_IRQn, (boolean)FALSE, 0U},
     {CAN2_Error_IRQn, (boolean)FALSE, 0U},
     {CAN2_ORed_0_15_MB_IRQn, (boolean)FALSE, 0U},

+ 2 - 2
src/AppGlobalVar.c

@@ -322,7 +322,7 @@ uint8 BMS23_Gun1DCPosTemp = 0x00;				   // A枪DC+
 uint8 BMS23_Gun1DCNegTemp = 0x00;				   // A枪DC-温度传感器温度 精度_1,偏移量_-40,单位_℃
 uint8 BMS23_Gun2DCPosTemp = 0x00;				   // B枪DC+温度传感器温度 精度_1,偏移量_-40,单位_℃
 uint8 BMS23_Gun2DCNegTemp = 0x00;				   // B枪DC-温度传感器温度 精度_1,偏移量_-40,单位_℃
-uint8 BMS_Cell_TempN[64] = {0x00};				   //电池温度编号
+uint8 BMS_Cell_TempN[BMS_TEMP_MAX_NUM] = {0x00};				   //电池温度编号
 uint8 BMS_SN_SysCode[24] = {0x00};				   //电池实际SN
 uint8 BMS21_BattType = 0x00;					   //电池类型,1 -铅酸电池 2 -镍氢电池 3 -磷酸铁锂电池  4 -锰酸锂电池 5 -钴酸锂电池 6 -三元材料电池  7 -聚合物锂离子电池 8 -钛酸锂电池  9-超级电容 15-其他车载储能装置,精度_1,偏移量_0,单位_
 uint8 BMS21_CoolType = 0x00;					   //电池冷却方式,0-其他冷却方式 1-自然冷却 2-风扇冷却 3-水冷却,精度_1,偏移量_0,单位_
@@ -357,7 +357,7 @@ uint8 TMS_Version = 0x00;						   // TMS
 uint8 TMS_ErrCode = 0x00;						   // TMS故障码,见附件,精度_1,偏移量_0,单位_
 uint8 TMS_FaultLevel = 0x00;					   // TMS故障码等级,0-无效 1-1级故障 2-2级故障 3-3级故障,精度_1,偏移量_0,单位_
 uint8 BCU_SnMsgFlag = 0x00;						   // SN码收全标志位
-uint16 BMS_Cell_Volt[384] = {0x00};				   //电芯电压
+uint16 BMS_Cell_Volt[BMS_CELL_MAX_NUM] = {0x00};				   //电芯电压
 uint16 BMS11_PackOutsideVolt = 0x00;			   //电池包外侧电压 精度_0.1,偏移量_0,单位_V
 uint16 BMS2_PackCurrent = 0x00;					   //电池包总电流,充电为负值,放电为正值 精度_0.1,偏移量_-1000,单位_A
 uint16 BMS2_PackInsideVolt = 0x00;				   //电池包内侧电压 精度_0.1,偏移量_0,单位_V

+ 3 - 0
src/AppGlobalVar.h

@@ -30,6 +30,9 @@
 #define BMS_MANUFACTURE 0xFF
 #define BMS_INFO 0xFF
 #define DATA_MODULE_TYPE 0x02
+
+#define BMS_CELL_MAX_NUM 384
+#define BMS_TEMP_MAX_NUM 64
 //*È«¾Ö±äÁ¿*//
 
 extern uint8 TcpbattSN[17];

+ 2 - 2
src/AppTaskUart0.c

@@ -47,10 +47,10 @@ void Uart0Task(void *pvParameters)
 			Uart0AskMsg.CRC_L = CRC_chk_buffer;
 			Uart0AskMsg.CRC_H = CRC_chk_buffer >> 8;
 			Dio_WriteChannel(DioConf_DioChannel_PTB4_GPIO_OUT_MCU_RS485_EN, STD_ON);
-			UART_Send_Data(UART_LPUART0, (uint8 *)&Uart0AskMsg, sizeof(Uart0AskMsg), 1000 * 10);
+			UART_Send_Data(UART_LPUART0, (uint8 *)&Uart0AskMsg, sizeof(Uart0AskMsg), 1000);
 			Dio_WriteChannel(DioConf_DioChannel_PTB4_GPIO_OUT_MCU_RS485_EN, STD_OFF);
 			memset(RX_Buffer[UART_LPUART0], 0x00, sizeof(RX_Buffer[UART_LPUART0]));
-			UART_Receive_Data(UART_LPUART0, RX_Buffer[UART_LPUART0], &pReadLen, 1000 * 10);
+			UART_Receive_Data(UART_LPUART0, RX_Buffer[UART_LPUART0], &pReadLen, 1000);
 			Dio_WriteChannel(DioConf_DioChannel_PTB4_GPIO_OUT_MCU_RS485_EN, STD_ON);
 			if (pReadLen > 0)
 			{

+ 8 - 6
src/AppTaskUart1.c

@@ -179,7 +179,7 @@ sint8 TcpDataSendFunc(sint8 ConnectId)
 	if (ATRet == 0)
 	{
 		memset(RX_Buffer[UART_LPUART1], 0x00, sizeof(RX_Buffer[UART_LPUART1]));
-		UART_Query_Data(UART_LPUART1, UART_LPUART1, (uint8 *)pSendDataAddr, DataSendLen, RX_Buffer[UART_LPUART1], &ReadLen, 1000 * 10);
+		UART_Query_Data(UART_LPUART1, UART_LPUART1, (uint8 *)pSendDataAddr, DataSendLen, RX_Buffer[UART_LPUART1], &ReadLen, 1000);
 		if ((uint8 *)strstr((char *)RX_Buffer[UART_LPUART1], (char *)("OK")))
 		{
 			outValue = 0;
@@ -207,7 +207,7 @@ sint8 TcpConnectFunc(sint8 *ConnectId)
 			uint8 ATCmdSendLen = mstrlen(ATCmdSend);
 			uint8 ReadLen = 0;
 			memset(RX_Buffer[UART_LPUART1], 0x00, sizeof(RX_Buffer[UART_LPUART1]));
-			UART_Query_Data(UART_LPUART1, UART_LPUART1, ATCmdSend, ATCmdSendLen, RX_Buffer[UART_LPUART1], &ReadLen, 1000 * 10);
+			UART_Query_Data(UART_LPUART1, UART_LPUART1, ATCmdSend, ATCmdSendLen, RX_Buffer[UART_LPUART1], &ReadLen, 1000);
 			uint8 *retptr = NULL;
 			if (ReadLen > 0)
 			{
@@ -390,7 +390,7 @@ void InitFunc(void)
 			ATCmdSend = (char *)("ATE0\r\n");
 			ATCmdSendLen = mstrlen(ATCmdSend);
 			memset(RX_Buffer[UART_LPUART1], 0x00, sizeof(RX_Buffer[UART_LPUART1]));
-			UART_Query_Data(UART_LPUART1, UART_LPUART1, ATCmdSend, ATCmdSendLen, RX_Buffer[UART_LPUART1], &ReadLen, 1000 * 10);
+			UART_Query_Data(UART_LPUART1, UART_LPUART1, ATCmdSend, ATCmdSendLen, RX_Buffer[UART_LPUART1], &ReadLen, 1000);
 			uint8 *retptr = NULL;
 			if (ReadLen > 0)
 			{
@@ -415,7 +415,7 @@ void InitFunc(void)
 			ATCmdSend = (char *)("AT+SIMEI?\r\n");
 			ATCmdSendLen = mstrlen(ATCmdSend);
 			memset(RX_Buffer[UART_LPUART1], 0x00, sizeof(RX_Buffer[UART_LPUART1]));
-			UART_Query_Data(UART_LPUART1, UART_LPUART1, ATCmdSend, ATCmdSendLen, RX_Buffer[UART_LPUART1], &ReadLen, 1000 * 10);
+			UART_Query_Data(UART_LPUART1, UART_LPUART1, ATCmdSend, ATCmdSendLen, RX_Buffer[UART_LPUART1], &ReadLen, 1000);
 			uint8 *retptr = NULL;
 			if (ReadLen > 0)
 			{
@@ -441,7 +441,7 @@ void InitFunc(void)
 			ATCmdSend = (char *)("AT+CTZU=1\r\n");
 			ATCmdSendLen = mstrlen(ATCmdSend);
 			memset(RX_Buffer[UART_LPUART1], 0x00, sizeof(RX_Buffer[UART_LPUART1]));
-			UART_Query_Data(UART_LPUART1, UART_LPUART1, ATCmdSend, ATCmdSendLen, RX_Buffer[UART_LPUART1], &ReadLen, 1000 * 10);
+			UART_Query_Data(UART_LPUART1, UART_LPUART1, ATCmdSend, ATCmdSendLen, RX_Buffer[UART_LPUART1], &ReadLen, 1000);
 			uint8 *retptr = NULL;
 			if (ReadLen > 0)
 			{
@@ -498,7 +498,9 @@ static void AtcmdTransmit(sint8 CmdIdx, uint8 *SetValuePtr, uint16 SetValueLen,
 		memcpy(PtrATCmdSend + ATCmdFixedLen, SetValuePtr, SetValueLen);
 	}
 	memset(RX_Buffer[UART_LPUART1], 0x00, sizeof(RX_Buffer[UART_LPUART1]));
-	UART_Query_Data(UART_LPUART1, UART_LPUART1, PtrATCmdSend, ATCmdTotalLen, RX_Buffer[UART_LPUART1], &ReadLen, 1000 * 100);
+
+	UART_Query_Data(UART_LPUART1, UART_LPUART1, PtrATCmdSend, ATCmdTotalLen, RX_Buffer[UART_LPUART1], &ReadLen, 1000);
+
 	*retFunc = Atcmdfunc[CmdIdx].cb(PtrATCmdSend, RX_Buffer[UART_LPUART1], CmdIdx, ReadLen);
 	if (PtrATCmdSend != NULL)
 	{

+ 90 - 71
src/hal_adapter.c

@@ -26,71 +26,89 @@
      /* Uart_AsyncReceive transmit data */
  //    IP_LPUART0->CTRL |= LPUART_CTRL_ILIE(0);
      bufferIdx[recvChannel]=0;
- 	switch(recvChannel)
- 	{
- 	case 0:
- 		IP_LPUART0->CTRL |= LPUART_CTRL_ILIE(1);
- 		break;
- 	case 1:
- 		IP_LPUART1->CTRL |= LPUART_CTRL_ILIE(1);
- 		break;
- 	case 2:
- 		IP_LPUART2->CTRL |= LPUART_CTRL_ILIE(1);
- 		break;
- 	default:
- 		break;
- 	}
- if (txBuffer == NULL || rxBuffer == NULL)
- {
-     return retVal;
- }
+	 switch(recvChannel)
+	 {
+		case 0:
+			IP_LPUART0->CTRL |= LPUART_CTRL_ILIE(1);
+			break;
+		case 1:
+			IP_LPUART1->CTRL |= LPUART_CTRL_ILIE(1);
+			break;
+		case 2:
+			IP_LPUART2->CTRL |= LPUART_CTRL_ILIE(1);
+			break;
+		default:
+			break;
+	 }
+	 if (txBuffer == NULL || rxBuffer == NULL)
+	 {
+		 return retVal;
+	 }
 
- Uart_SetBuffer(recvChannel, &RX_Buffer[recvChannel][0], DMA_SIZE, UART_RECEIVE);
- R_Uart_Status = Uart_AsyncReceive(recvChannel, rxBuffer, DMA_SIZE);
- if (E_OK != R_Uart_Status)
- {
-     Uart_Abort(recvChannel, UART_RECEIVE);
-     return E_NOT_OK;
- }
+	 Uart_SetBuffer(recvChannel, &RX_Buffer[recvChannel][0], DMA_SIZE, UART_RECEIVE);
+	 R_Uart_Status = Uart_AsyncReceive(recvChannel, rxBuffer, DMA_SIZE);
+	 if (E_OK != R_Uart_Status)
+	 {
+		 Uart_Abort(recvChannel, UART_RECEIVE);
+		 return E_NOT_OK;
+	 }
 
- /* Uart_AsyncSend transmit data */
- Uart_SetBuffer(transChannel, txBuffer, sendLength, UART_SEND);
- T_Uart_Status = Uart_AsyncSend(transChannel, txBuffer, sendLength);
- if (E_OK != T_Uart_Status)
- {
-     Uart_Abort(transChannel, UART_SEND);
-     return E_NOT_OK;
- }
 
- /* Check for no on-going transmission */
- do
- {
-     Uart_TransmitStatus = Uart_GetStatus(transChannel, &T_bytesRemaining, UART_SEND);
-     Uart_ReceiveStatus = Uart_GetStatus(recvChannel, &R_bytesRemaining, UART_RECEIVE);
- } while (((UART_STATUS_NO_ERROR != Uart_TransmitStatus || UART_STATUS_NO_ERROR != Uart_ReceiveStatus) && 0 < --timeout));
+	 /* Uart_AsyncSend transmit data */
+	 Uart_SetBuffer(transChannel, txBuffer, sendLength, UART_SEND);
+	 T_Uart_Status = Uart_AsyncSend(transChannel, txBuffer, sendLength);
+	 if (E_OK != T_Uart_Status)
+	 {
+		 Uart_Abort(transChannel, UART_SEND);
+		 return E_NOT_OK;
+	 }
 
- if ((UART_STATUS_NO_ERROR != Uart_TransmitStatus))
- {
-     Uart_Abort(transChannel, UART_SEND);
-     retVal = E_NOT_OK;
- }
- else
- {
-     retVal = E_OK;
- }
 
- if ((UART_STATUS_NO_ERROR != Uart_ReceiveStatus))
- {
-     Uart_Abort(recvChannel, UART_RECEIVE);
-     //    	IP_LPUART0->CTRL |= LPUART_CTRL_ILIE(1);
-     retVal = E_NOT_OK;
- }
- else
- {
-	 *rxlen = bufferIdx[recvChannel];
-     retVal = E_OK;
- }
- return retVal;
+
+
+	 /* Check for no on-going transmission */
+//	 Dio_WriteChannel(DioConf_DioChannel_PTE1_GPIO_OUT_MCU_LED2, STD_ON);
+	 do
+	 {
+//		 Dio_WriteChannel(DioConf_DioChannel_PTE1_GPIO_OUT_MCU_LED2, STD_ON);
+		 if(Uart_TransmitStatus != UART_STATUS_NO_ERROR)
+		 {
+			 Uart_TransmitStatus = Uart_GetStatus(transChannel, &T_bytesRemaining, UART_SEND);
+		 }
+		 if(Uart_ReceiveStatus != UART_STATUS_NO_ERROR)
+		 {
+			 Uart_ReceiveStatus = Uart_GetStatus(recvChannel, &R_bytesRemaining, UART_RECEIVE);
+		 }
+
+		 vTaskDelay(pdMS_TO_TICKS(1));
+//		 Dio_WriteChannel(DioConf_DioChannel_PTE1_GPIO_OUT_MCU_LED2, STD_OFF);
+
+	 } while (((UART_STATUS_NO_ERROR != Uart_TransmitStatus || UART_STATUS_NO_ERROR != Uart_ReceiveStatus) && 0 < --timeout));
+//	 Dio_WriteChannel(DioConf_DioChannel_PTE1_GPIO_OUT_MCU_LED2, STD_OFF);
+
+
+	 if ((UART_STATUS_NO_ERROR != Uart_TransmitStatus))
+	 {
+		 Uart_Abort(transChannel, UART_SEND);
+		 retVal = E_NOT_OK;
+	 }
+	 else
+	 {
+		 retVal = E_OK;
+	 }
+
+	 if ((UART_STATUS_NO_ERROR != Uart_ReceiveStatus))
+	 {
+		 Uart_Abort(recvChannel, UART_RECEIVE);
+		 //    	IP_LPUART0->CTRL |= LPUART_CTRL_ILIE(1);
+		 retVal = E_NOT_OK;
+	 }
+	 else
+	 {
+		 *rxlen = bufferIdx[recvChannel];
+		 retVal = E_OK;
+	 }
+	 return retVal;
  }
 
  Std_ReturnType UART_Send_Data(uint8 transChannel, const uint8 *txBuffer, uint32 sendLength, uint32 T_timeout)
@@ -121,6 +139,7 @@
      do
      {
          Uart_TransmitStatus = Uart_GetStatus(transChannel, &T_bytesRemaining, UART_SEND);
+         vTaskDelay(pdMS_TO_TICKS(1));
      } while ((UART_STATUS_NO_ERROR != Uart_TransmitStatus && 0 < --timeout));
 
      if ((UART_STATUS_NO_ERROR != Uart_TransmitStatus))
@@ -151,17 +170,17 @@
      /* Uart_AsyncReceive transmit data */
 	switch(recvChannel)
 	{
-	case 0:
-		IP_LPUART0->CTRL |= LPUART_CTRL_ILIE(1);
-		break;
-	case 1:
-		IP_LPUART1->CTRL |= LPUART_CTRL_ILIE(1);
-		break;
-	case 2:
-		IP_LPUART2->CTRL |= LPUART_CTRL_ILIE(1);
-		break;
-	default:
-		break;
+		case 0:
+			IP_LPUART0->CTRL |= LPUART_CTRL_ILIE(1);
+			break;
+		case 1:
+			IP_LPUART1->CTRL |= LPUART_CTRL_ILIE(1);
+			break;
+		case 2:
+			IP_LPUART2->CTRL |= LPUART_CTRL_ILIE(1);
+			break;
+		default:
+			break;
 	}
      Uart_SetBuffer(recvChannel, rxBuffer, DMA_SIZE, UART_RECEIVE);
      R_Uart_Status = Uart_AsyncReceive(recvChannel, rxBuffer, DMA_SIZE);

+ 1 - 1
src/hal_adapter.h

@@ -49,7 +49,7 @@
  #define UART_LPUART2 2
  #define FLEXIO_RX 3
  #define FLEXIO_TX 4
- #define main_TASK_PRIORITY                ( tskIDLE_PRIORITY + 2 )
+ #define main_TASK_PRIORITY                ( tskIDLE_PRIORITY + 7 )
 
  #define MSG_LEN 50U
  #define TJA1153_START_ID (uint32_t)(0x555u)

+ 21 - 32
src/main.c

@@ -68,33 +68,17 @@ int main(void)
 	Mcu_InitClock(McuClockSettingConfig_0);
 
 	/* Wait until PLL is locked */
-	 while ( MCU_PLL_LOCKED != Mcu_GetPllStatus() )
+	while (MCU_PLL_LOCKED != Mcu_GetPllStatus())
 	{
 		/* Busy wait until the System PLL is locked */
 	}
-	 Mcu_DistributePllClock();
+	Mcu_DistributePllClock();
 	/* Initialize Mcl module */
 	Mcl_Init(NULL_PTR);
 
 	Mcu_SetMode(McuModeSettingConf_Run);
 	OsIf_Init(NULL_PTR);
 	Platform_Init(NULL_PTR);
-	//    Platform_InstallIrqHandler(LPUART0_RxTx_IRQn, LPUART_UART_IP_0_IRQHandler, NULL_PTR);
-	//    Platform_InstallIrqHandler(LPUART1_RxTx_IRQn, LPUART_UART_IP_1_IRQHandler, NULL_PTR);
-	//    Platform_InstallIrqHandler(LPUART2_RxTx_IRQn, LPUART_UART_IP_2_IRQHandler, NULL_PTR);
-	//    Platform_InstallIrqHandler(FLEXIO_IRQn, MCL_FLEXIO_ISR, NULL_PTR);
-	//    Platform_InstallIrqHandler(DMA0_IRQn,Dma0_Ch0_IRQHandler,NULL_PTR);
-	//    Platform_InstallIrqHandler(DMA1_IRQn,Dma0_Ch1_IRQHandler,NULL_PTR);
-	//    Platform_InstallIrqHandler(DMA2_IRQn,Dma0_Ch2_IRQHandler,NULL_PTR);
-	//    Platform_InstallIrqHandler(DMA3_IRQn,Dma0_Ch3_IRQHandler,NULL_PTR);
-	//    Platform_InstallIrqHandler(DMA4_IRQn,Dma0_Ch4_IRQHandler,NULL_PTR);
-	//    Platform_InstallIrqHandler(DMA5_IRQn,Dma0_Ch5_IRQHandler,NULL_PTR);
-
-	//    Platform_InstallIrqHandler(CAN0_ORed_IRQn,IRQHandler,NULL_PTR);
-	//    Platform_InstallIrqHandler(CAN0_Error_IRQn,Dma0_Ch5_IRQHandler,NULL_PTR);
-	//    Platform_InstallIrqHandler(CAN0_Wake_Up_IRQn,Dma0_Ch5_IRQHandler,NULL_PTR);
-	//    Platform_InstallIrqHandler(CAN0_ORed_0_15_MB_IRQn,Dma0_Ch5_IRQHandler,NULL_PTR);
-	//    Platform_InstallIrqHandler(CAN0_ORed_16_31_MB_IRQn,Dma0_Ch5_IRQHandler,NULL_PTR);
 
 	/* Initialize all pins*/
 #if (PORT_PRECOMPILE_SUPPORT == STD_ON)
@@ -120,37 +104,42 @@ int main(void)
 	Can_SetControllerMode(CanController_1, CAN_CS_STARTED);
 #endif
 #if (ADC_PRECOMPILE_SUPPORT == STD_ON)
-    Adc_Init(NULL_PTR);
+	Adc_Init(NULL_PTR);
 #else
-    Adc_Init(&Adc_Config_VS_0);
+	Adc_Init(&Adc_Config_VS_0);
 #endif /* ADC_PRECOMPILE_SUPPORT == STD_ON */
 
-
-    //this function should be called in ADC Task at once
-    Adc_CalibrationStatusType CalibStatus;
-    Adc_Calibrate(AdcHwUnit_0, &CalibStatus);
-	if(CalibStatus.Adc_UnitSelfTestStatus == E_NOT_OK)
+	// this function should be called in ADC Task at once
+	Adc_CalibrationStatusType CalibStatus;
+	Adc_Calibrate(AdcHwUnit_0, &CalibStatus);
+	if (CalibStatus.Adc_UnitSelfTestStatus == E_NOT_OK)
 	{
-		//if so, the adc is failed to Calibrate;
+		// if so, the adc is failed to Calibrate;
 	}
 	TP_Value_Type value = 0;
-	for(ADC_TP_Channel_Type channel = 0; channel <ChannelCounter; channel++ )
+	for (ADC_TP_Channel_Type channel = 0; channel < ChannelCounter; channel++)
 	{
-		ADC_ReadValue(channel,&value);
+		ADC_ReadValue(channel, &value);
 	}
 
 	IP_LPUART0->CTRL |= LPUART_CTRL_ILT(1);
 	IP_LPUART1->CTRL |= LPUART_CTRL_ILT(1);
 	IP_LPUART2->CTRL |= LPUART_CTRL_ILT(1);
-	xTaskCreate(MainTask, (const char *const)"MainTask", 128, (void *)0, main_TASK_PRIORITY, NULL);
-	xTaskCreate(Uart_4G_Task, (const char *const)"Uart_4G_Task", 256 + 64, (void *)0, main_TASK_PRIORITY, NULL);
+
+	Dio_WriteChannel(DioConf_DioChannel_PTE0_GPIO_OUT_MCU_LED1, STD_OFF);
+	Dio_WriteChannel(DioConf_DioChannel_PTE1_GPIO_OUT_MCU_LED2, STD_OFF);
+	Dio_WriteChannel(DioConf_DioChannel_PTE7_GPIO_OUT_MCU_LED3, STD_OFF);
+	Dio_WriteChannel(DioConf_DioChannel_PTE8_GPIO_OUT_MCU_LED4, STD_OFF);
+
+	xTaskCreate(MainTask, (const char *const)"MainTask", 128, (void *)0, main_TASK_PRIORITY + 3, NULL);
+	xTaskCreate(Uart_4G_Task, (const char *const)"Uart_4G_Task", 2048, (void *)0, main_TASK_PRIORITY + 0, NULL);
 #ifdef APP_UART0_ENABLE
 	xTaskCreate(Uart0Task, (const char *const)"Uart0_Bms_Task", 256, (void *)0, main_TASK_PRIORITY + 1, NULL);
 #endif
 #ifdef APP_CAN_ENABLE
-	xTaskCreate(CanTask, (const char *const)"CanTask", 256, (void *)0, main_TASK_PRIORITY + 1, NULL);
+	xTaskCreate(CanTask, (const char *const)"CanTask", 512, (void *)0, main_TASK_PRIORITY + 2, NULL);
 #endif
-	xTaskCreate(GpsTask, (const char *const)"GpsTask", 256, (void *)0, main_TASK_PRIORITY + 2, NULL);
+	xTaskCreate(GpsTask, (const char *const)"GpsTask", 512, (void *)0, main_TASK_PRIORITY + 1, NULL);
 	vTaskStartScheduler();
 	for (;;)
 	{