Procházet zdrojové kódy

Uart任务调度初步测试成功

CHENJIE-PC\QiXiang_CHENJIE před 4 roky
rodič
revize
832997c2b3
7 změnil soubory, kde provedl 47 přidání a 33 odebrání
  1. 2 1
      ARMCC/Makefile
  2. 4 1
      inc/MainTask.h
  3. 0 10
      inc/UartTask.h
  4. 12 14
      inc/app.h
  5. 9 5
      src/MainTask.c
  6. 19 1
      src/UartTask.c
  7. 1 1
      src/app.c

+ 2 - 1
ARMCC/Makefile

@@ -18,6 +18,7 @@ obj-y             += PLAT/project/$(TARGET)/apps/qx_app/src/app.o \
                      PLAT/project/$(TARGET)/apps/qx_app/src/cisAsynEntry.o \
 		     		PLAT/project/$(TARGET)/apps/qx_app/src/bsp_custom.o \
 					PLAT/project/$(TARGET)/apps/qx_app/src/hal_module_adapter.o \
-					PLAT/project/$(TARGET)/apps/qx_app/src/MainTask.o
+					PLAT/project/$(TARGET)/apps/qx_app/src/MainTask.o \
+					PLAT/project/$(TARGET)/apps/qx_app/src/UartTask.o
 
 include $(TOP)/PLAT/tools/scripts/Makefile.rules

+ 4 - 1
inc/MainTask.h

@@ -6,7 +6,10 @@
  * History:      2021-03-05
  *
  ****************************************************************************/
-
+//全局变量
+extern uint32_t Timer_count;//每100ms加1
+extern volatile bool Sleep_flag;//睡眠标志位
+/*---------------------------------------------------------------------------*/
 #define PROC_MAIN_TASK_STACK_SIZE           (512)
 typedef enum
 {

+ 0 - 10
src/UartTask.h → inc/UartTask.h

@@ -7,16 +7,6 @@
  *
  ****************************************************************************/
 
-//全局变量声明区
-extern bool Sleep_flag;
-extern uint32_t Timer_count;
-
-//底层变量声明区
-extern ARM_DRIVER_USART Driver_USART1;
-static ARM_DRIVER_USART *USARTdrv = &Driver_USART1;
-volatile bool isRecvTimeout = false;
-volatile bool isRecvComplete = false;
-//
 #define PROC_UART_TASK_STACK_SIZE           (1024)
 #define UART_READ_CODE 0x03
 #define UART_WRITE_CODE 0x10

+ 12 - 14
inc/app.h

@@ -11,21 +11,21 @@
 #ifdef __cplusplus
 extern "C" {
 #endif
-
+//全局定义声明区
 #define BAT4830
 #ifdef  BAT4830
-    #define Batt_Cell_Num  (14)
-    #define Batt_Temp_Num  (5)
+    #define BATT_CELL_VOL_NUM  (14)
+    #define BATT_TEMP_NUM  (5)
 #else
-    #define Batt_Cell_Num  (17)
-    #define Batt_Temp_Num  (7)
+    #define BATT_CELL_VOL_NUM  (17)
+    #define BATT_TEMP_NUM  (7)
 #endif
-#define Batt_Cell_Num_2 (Batt_Cell_Num*2)
-
-#define	SwVersion		0xA21
-#define HwVersion		0xB22
-
+#define BATT_CELL_VOL_NUM_2 (BATT_CELL_VOL_NUM*2)
+#define BATT_SN_LEN           17
+#define	SWVERSION		0xA21
+#define HWVERSION		0xB22
 
+//--------------------------------------------------------------------------------
 #define QMSG_ID_BASE               (0x160) 
 #define QMSG_ID_NW_IP_READY        (QMSG_ID_BASE)
 #define QMSG_ID_NW_IP_SUSPEND      (QMSG_ID_BASE + 1)
@@ -39,9 +39,7 @@ extern "C" {
 #define APP_WAKEUP_WORK_TIME		1
 #define APP_SLEEP_TIME				5
 
-#define BATT_CELL_VOL_NUM      17
-#define BATT_TEMP_NUM         7
-#define BATT_SN_LEN           17
+
 
 #define TCP_START_SYM1			0x23
 #define TCP_START_SYM2			0x23
@@ -119,7 +117,7 @@ typedef struct BattInfoType
 	UINT8	battSOH;
 	UINT8	batCellBalenceState[4];	//uint32 should change to uint8[]: each bit stand for 1 cell, up to 1024
 	UINT8	battCellNum[2];			//uint8 should change to uint16 (0~65535)  //zhengchao
-	UINT8	battCellU[BATT_CELL_VOL_NUM*2];
+	UINT8	battCellU[BATT_CELL_VOL_NUM_2];
 	UINT8	battTempNum[2];			//uint8 should change to uint16 (0~65535)
 	UINT8	battCellTemp[BATT_TEMP_NUM];
 	UINT8	battWorkState;

+ 9 - 5
src/MainTask.c

@@ -4,7 +4,7 @@
  * File name:    MainTask.c
  * Description:  APP任务调取和异常处理
  * History:      2021-03-05
- *
+ * PS:主线程里面关闭了网络为了测试睡眠和唤醒
  ****************************************************************************/
 #include "bsp.h"
 #include "bsp_custom.h"
@@ -29,10 +29,13 @@
 #include "app.h"
 #include "MainTask.h"
 
+
+
 //全局变量
-static uint32_t Timer_count = 0;//每100ms加1
+uint32_t Timer_count;//每100ms加1
 volatile bool Sleep_flag = false;//睡眠标志位
 
+
 //主线程堆栈声明区
 static StaticTask_t           gProcess_Main_Task_t;
 static UINT8                  gProcess_Main_TaskStack[PROC_MAIN_TASK_STACK_SIZE];
@@ -66,7 +69,7 @@ static void MainTask(void* arg)
     int32_t inParam = 0xAABBCCDD;
     slpManSetPmuSleepMode(true,SLP_HIB_STATE,false);
     slpManApplyPlatVoteHandle("MainSlp",&MainSlpHandler);
-    slpManPlatVoteDisableSleep(MainSlpHandler, SLP_SLP2_STATE);
+    slpManPlatVoteDisableSleep(MainSlpHandler, SLP_SLP1_STATE);
     slpManRegisterUsrdefinedBackupCb(appBeforeHib,&inParam,SLPMAN_HIBERNATE_STATE);
     slpManRegisterUsrdefinedRestoreCb(appAfterHib,NULL,SLPMAN_HIBERNATE_STATE);
     slpManRegisterUsrdefinedBackupCb(appBeforeSlp1,NULL,SLPMAN_SLEEP1_STATE);
@@ -93,6 +96,7 @@ static void MainTask(void* arg)
         {
             case PROCESS_STATE_IDLE:
             {
+                Timer_count = 0;
                 xTimerStart(montior_timer, 0);
                 xTimerStart(work_timer, 0);
                 Sleep_flag = false;
@@ -121,7 +125,7 @@ static void MainTask(void* arg)
                         printf("[%d]We Can Check Vote Main State, state=%d, cnt=%d\r\n",__LINE__,State,cnt);
                     #endif						
                 }
-                slpManPlatVoteForceEnableSleep(MainSlpHandler, SLP_SLP2_STATE);
+                slpManPlatVoteForceEnableSleep(MainSlpHandler, SLP_SLP1_STATE);
                 if(slpManCheckVoteState(MainSlpHandler, &State, &cnt)==RET_TRUE)
                 {
                     #ifdef USING_PRINTF
@@ -187,7 +191,7 @@ void montior_timer_callback(TimerHandle_t xTimer)
     #ifdef USING_PRINTF
         if (Timer_count%50==0)
         {
-            printf("Hello 5s montior Timer,SwVersion:%x!\n",SwVersion);
+            printf("Main Task,Batt_Cell_Num:%d,%d!\n",BATT_CELL_VOL_NUM,Timer_count);
         }
     #endif
     Timer_count++;

+ 19 - 1
src/UartTask.c

@@ -26,7 +26,16 @@
 #include "ec_tcpip_api.h"
 #include "hal_module_adapter.h"
 #include "UartTask.h"
+#include "MainTask.h"
+#include "app.h"
 
+//
+extern ARM_DRIVER_USART Driver_USART1;
+static ARM_DRIVER_USART *USARTdrv = &Driver_USART1;
+volatile bool isRecvTimeout = false;
+volatile bool isRecvComplete = false;
+
+//线程声明区
 static StaticTask_t             gProcess_Uart_Task_t;
 static UINT8                  gProcess_Uart_TaskStack[PROC_UART_TASK_STACK_SIZE];
 static osThreadId_t           UartTaskId = NULL;
@@ -37,7 +46,16 @@ static process_Uart             gProcess_Uart_Task = PROCESS_UART_STATE_IDLE;
 //Uart线程任务区
 static void UartTask(void* arg)
 {
-
+    while (1)
+    {
+        osDelay(100);
+        #ifdef USING_PRINTF
+        if (Timer_count%50==0)
+        {
+            printf("Uart Task,Batt_Cell_Num:%d,%d!\n",BATT_CELL_VOL_NUM,Timer_count);
+        }
+        #endif
+    }
 }
 //Uart线程初始化
 void UartTaskInit(void *arg)

+ 1 - 1
src/app.c

@@ -25,7 +25,6 @@
 #include "hal_module_adapter.h"
 #include "timers.h"
 #include "app.h"
-
 #include "MainTask.h"
 #include "UartTask.h"
 
@@ -35,6 +34,7 @@ void appInit(void *arg)
     	printf("%s[%d]\r\n",__FUNCTION__, __LINE__);
     #endif
     MainTaskInit(arg);
+    UartTaskInit(arg);
 }
 //主函数入口
 void main_entry(void)