CHENJIE-PC\QiXiang_CHENJIE 3 роки тому
батько
коміт
5ace8e6b16

+ 4 - 4
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*2 )
 #define configAPPLICATION_ALLOCATED_HEAP            0
 
 /* Hook function related definitions. */
@@ -91,7 +91,7 @@ PRIORITY THAN THIS! (higher priorities are lower numeric values. */
 
 /* Co-routine related definitions. */
 #define configUSE_CO_ROUTINES                       0
-#define configMAX_CO_ROUTINE_PRIORITIES             2
+#define configMAX_CO_ROUTINE_PRIORITIES             14
 
 /* SEMAPHORES and MUTEXS */
 #define configUSE_MUTEXES                           1
@@ -102,7 +102,7 @@ PRIORITY THAN THIS! (higher priorities are lower numeric values. */
 #define configUSE_TIMERS                            1
 #define configTIMER_TASK_PRIORITY                   2
 #define configTIMER_QUEUE_LENGTH                    10
-#define configTIMER_TASK_STACK_DEPTH                180
+#define configTIMER_TASK_STACK_DEPTH                256
 
 /* Tickless Idle Mode */
 #define configUSE_TICKLESS_IDLE                     0

+ 1 - 5
generate/include/Mcu_Cfg.h

@@ -167,10 +167,6 @@ extern "C"{
 ==================================================================================================*/
 
 
-#define MCU_CONFIG_EXT \
-    MCU_CONFIG_VS_0_PB \
-
-
 
 /**
 * @brief      Specifies the InstanceId of this module instance.
@@ -425,7 +421,7 @@ extern "C"{
 /**
 * @brief            Pre-compile Support.
 */
-#define MCU_PRECOMPILE_SUPPORT   (STD_OFF)
+#define MCU_PRECOMPILE_SUPPORT   (STD_ON)
 
 #ifdef MCU_GET_MIDR_API
   #if (MCU_GET_MIDR_API == STD_ON)

+ 1 - 2
generate/include/Mcu_VS_0_PBcfg.h

@@ -92,8 +92,7 @@ extern "C"
                                        GLOBAL VARIABLES
 ==================================================================================================*/
 
-#define MCU_CONFIG_VS_0_PB \
- extern const Mcu_ConfigType Mcu_Config_VS_0;
+
 
 /*==================================================================================================
                                    LOCAL FUNCTION PROTOTYPES

+ 2 - 2
generate/src/Clock_Ip_VS_0_PBcfg.c

@@ -219,7 +219,7 @@ const Clock_Ip_ClockConfigType Mcu_aClockConfigPB_VS_0[1U] = {
                 16000000U,                    /* External oscillator frequency. */
                 1U,                           /* Enable xosc. */
                 0U,                         /* Startup stabilization time. */
-                0U,                   /* XOSC bypass option */ 
+                0U,                           /* XOSC bypass option */
                 0U,                           /* Comparator enable */
                 0U,                          /* Crystal overdrive protection */
                 0U,                    /* High gain value */
@@ -243,7 +243,7 @@ const Clock_Ip_ClockConfigType Mcu_aClockConfigPB_VS_0[1U] = {
                 0U,                           /*!<     modulation;              */
                 0U,                           /*!<     modulationType;          */
                 0U,                           /*!<     modulationPeriod;        */
-                1U,                     /* incrementStep */
+                0U,                           /*!<     incrementStep;           */
                 0U,                           /*!<     sigmaDelta;              */
                 0U,                           /*!<     ditherControl;           */
                 0U,                           /*!<     ditherControlValue;      */

+ 1 - 1
generate/src/Mcu_VS_0_PBcfg.c

@@ -137,7 +137,7 @@ extern "C"
 *
 */
 
-const Mcu_ConfigType Mcu_Config_VS_0 =
+const Mcu_ConfigType Mcu_PreCompileConfig =
 {
 #if (MCU_INIT_CLOCK == STD_ON)
     /* Globally enable/disable SCM, loss of clock and loss of lock notification. */

+ 6 - 0
src/AppTaskBle.c

@@ -78,6 +78,12 @@ void BleTask(void *pvParameters)
 					BleDisconnectFlg = 0;
 					xSemaphoreGive(ConnSemaphore);
 				}
+				if(BleCurrentRole == 0)//如果从机在串口0上收到数据,则证明已连接
+				{
+					bleWorkState = 1;
+					BleConnectFlg = 1;
+					BleDisconnectFlg = 0;
+				}
 			}
 			break;
 		}

+ 34 - 17
src/AppTaskCan.c

@@ -7,6 +7,17 @@
 #include "AppTaskCan.h"
 static void CanDataAsk(QueueDataTrans_Type AskData);
 uint8 DataPackCounter[21] = {1,1,7,5,16,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};
+
+static void vCanRxCallback(TimerHandle_t pxTimer)
+{
+	uint32 ulTimerID;
+	ulTimerID = (uint32)pvTimerGetTimerID(pxTimer);
+	if(ulTimerID==0)
+	{
+		Can_MainFunction_Read();
+	}
+}
+
 void CanTask()
 {
 	CanRecvQueueHandle = xQueueCreate(16, sizeof(Can_Msg_Type_Data)); // CAN获取消息队列创建
@@ -16,31 +27,37 @@ void CanTask()
 	CanIf_bRxFlag = false;
 	Can_Msg_Type_Data CanRxMsg;
 	QueueDataTrans_Type CanAskData={0,NULL};
+
+	TimerHandle_t monitorTimer1ms;
+	monitorTimer1ms = xTimerCreate("monitor1ms",1,pdTRUE,(void *)0,vCanRxCallback);
+	xTimerStart(monitorTimer1ms,0);
+
 	while (TRUE)
 	{
 		switch (CanState)
 		{
-		case 0:
-		{
-			CanState = 1;
-			break;
-		}
-		case 1:
-		{
-			memset(&CanRxMsg, 0, sizeof(CanRxMsg));
-			Can_MainFunction_Read();
-			BaseType_t ret = xQueueReceive(CanRecvQueueHandle, &CanRxMsg, 0);
-			if (ret == pdPASS)
+			case 0:
 			{
-				BleCanTransmit(CanRxMsg.id, CanRxMsg.data);
+				CanState = 1;
+				break;
 			}
-			BaseType_t ret2 = xQueueReceive(Uart2ToCanDataHandle,&CanAskData,10);//带有校验码
-			if (ret2 == pdPASS)
+			case 1:
 			{
-				CanDataAsk(CanAskData);
+				memset(&CanRxMsg, 0, sizeof(CanRxMsg));
+	//			Can_MainFunction_Read();
+				BaseType_t ret = xQueueReceive(CanRecvQueueHandle, &CanRxMsg, 0);
+				if (ret == pdPASS)
+				{
+					BleCanTransmit(CanRxMsg.id, CanRxMsg.data);
+				}
+				BaseType_t ret2 = xQueueReceive(Uart2ToCanDataHandle,&CanAskData,10);//带有校验码
+				if (ret2 == pdPASS)
+				{
+					CanDataAsk(CanAskData);
+				}
+//				vTaskDelay(pdMS_TO_TICKS(10));
+				break;
 			}
-			break;
-		}
 		}
 	}
 }

+ 5 - 0
src/hal_adapter.c

@@ -107,6 +107,7 @@ UINT8 UartTramsit(UINT8 *pSend, UINT32 sendLen, UINT8 *pRead, UINT32 readLen, UI
  {
      Uart_TransmitStatus = Uart_GetStatus(transChannel, &T_bytesRemaining, UART_SEND);
      Uart_ReceiveStatus = Uart_GetStatus(recvChannel, &R_bytesRemaining, UART_RECEIVE);
+     vTaskDelay(pdMS_TO_TICKS(1));
  } while (((UART_STATUS_NO_ERROR != Uart_TransmitStatus || UART_STATUS_NO_ERROR != Uart_ReceiveStatus) && 0 < --timeout));
 
  if ((UART_STATUS_NO_ERROR != Uart_TransmitStatus))
@@ -161,6 +162,7 @@ UINT8 UartTramsit(UINT8 *pSend, UINT32 sendLen, UINT8 *pRead, UINT32 readLen, UI
      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))
@@ -367,6 +369,8 @@ UINT8 UartTramsit(UINT8 *pSend, UINT32 sendLen, UINT8 *pRead, UINT32 readLen, UI
      CanIf_bTxFlag = TRUE;
      (void)CanTxPduId;
  }
+
+ uint32 canrxcounter = 0;
  void CanIf_RxIndication(const Can_HwType *Mailbox, const PduInfoType *PduInfoPtr)
  {
 	 static portBASE_TYPE xHigherPriorityTaskWoken;
@@ -381,6 +385,7 @@ UINT8 UartTramsit(UINT8 *pSend, UINT32 sendLen, UINT8 *pRead, UINT32 readLen, UI
      Can_Msg_Data.length = canRxMsg_Buff.length;
      memcpy(Can_Msg_Data.data,canRxMsg_Buff.sdu,Can_Msg_Data.length);
      xQueueSend(CanRecvQueueHandle,&Can_Msg_Data,0);
+	 canrxcounter++;
  }
 
  void CanIf_CurrentIcomConfiguration(uint8 ControllerId, IcomConfigIdType ConfigurationId, IcomSwitch_ErrorType Error)

+ 1 - 1
src/hal_adapter.h

@@ -74,7 +74,7 @@ UINT8 UartTramsit(UINT8 *pSend, UINT32 sendLen, UINT8 *pRead, UINT32 readLen, UI
  #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)

+ 4 - 1
src/main.c

@@ -120,6 +120,7 @@ int main(void)
 {
 	volatile int exit_code = 0;
     /* Write your code here */
+    /* Initialize all pins*/
 
     /* Initialize the Mcu driver */
 #if (MCU_PRECOMPILE_SUPPORT == STD_ON)
@@ -130,6 +131,8 @@ int main(void)
 
     Mcu_InitClock(McuClockSettingConfig_0);
 
+
+
     /* Wait until PLL is locked */
      while ( MCU_PLL_LOCKED != Mcu_GetPllStatus() )
     {
@@ -173,7 +176,7 @@ int main(void)
     Dio_WriteChannel(DioConf_DioChannel_PTE7_GPIO_OUT_MCU_BT_MOD,STD_ON);
 
     xTaskCreate( BleTask, ( const char * const ) "BleTask", 256 + 64, (void*)0, main_TASK_PRIORITY , NULL );
-    xTaskCreate( CanTask, ( const char * const ) "CanTask" , 256, (void*)0, main_TASK_PRIORITY + 2, NULL );
+    xTaskCreate( CanTask, ( const char * const ) "CanTask" , 512, (void*)0, main_TASK_PRIORITY + 2, NULL );
     xTaskCreate( UartTask, ( const char * const ) "UartTask" , 256, (void*)0, main_TASK_PRIORITY + 1, NULL );
     vTaskStartScheduler();
     for( ;; )