From 2fe944b7b3cb50c59cc48f079d4b0f90237681b3 Mon Sep 17 00:00:00 2001
From: chen <15335560115@163.com>
Date: 星期二, 22 十月 2024 15:15:02 +0800
Subject: [PATCH] 修改了ADC休眠后不采集bug

---
 keil/include/main/main.c |   41 ++++++++++++++++++++++++-----------------
 1 files changed, 24 insertions(+), 17 deletions(-)

diff --git a/keil/include/main/main.c b/keil/include/main/main.c
index 48d33de..b8edffb 100644
--- a/keil/include/main/main.c
+++ b/keil/include/main/main.c
@@ -62,7 +62,7 @@
 #include "HIDO_Timer.h"
 #include "TCPClient.h"
 
-#define DEBUG_MODE
+//#define DEBUG_MODE
 extern int simple_main(void);
 extern int temp_main(void);
 #define TEST_UART_POLL_MODE 0
@@ -107,7 +107,7 @@
 
 
 Commend_SendDate send_struct;
-static struct ADC_CFG_T usr_adc_cfg = {
+struct ADC_CFG_T usr_adc_cfg = {
     .mode = ADC_MODE_CONTINUE,    /* Selected single conversion mode  */
     .clk_sel = ADC_CLK_HIGH,      /* Selected 62.4M high speed clock */
     .vref_sel = ADC_SEL_VREF_INT, /* Using internal reference voltage (1.2V)*/
@@ -271,8 +271,8 @@
     }
     //UWB更新列表
     TagListUpdate();
-    //GPS_Poll();
-		gps_power_state=1;//测试gps长开
+    GPS_Poll();
+		//gps_power_state=1;//测试gps长开
     //UWB状态检测
 
     if(IfTCPConnected())
@@ -297,10 +297,10 @@
 }
 uint8_t tt=1;
 uint8_t flag_sleeptimer,flag_secondtask,secondtask_count,log_4g_enable_flag;
-
+uint8_t uwb_enable_flag=0;
 static void sleep_timer_callback(void *dev, uint32_t time)
 {
-    IO_control_init();
+   // IO_control_init();
 	if(tt)
     UWBPoll();
 	//车载poll
@@ -322,10 +322,10 @@
     {
         if(motor_open_air_flag||moter_open_uwb_flag)
         {
-           if (motor_count++%2==0)
+           if (motor_count++%3!=0)
            {
             motor_power_state = 1;
-           }else{
+           }else {//修改
             motor_power_state = 0;
            }
         } else {
@@ -334,6 +334,7 @@
     }else{
         motor_power_state=1;
     }
+		
  if(delaysleep_count>0)
         delaysleep_count--;
     //GPS工作逻辑
@@ -348,9 +349,9 @@
     nomove_count=0;
 }
 uint8_t flag_4G_recdata;
-static void _4gUsart_handler(enum IO_PIN_T pin)
+void _4gUsart_handler(enum IO_PIN_T pin)
 {
-     LOG_INFO(TRACE_MODULE_APP, "4G RX 唤醒\r\n");
+     //LOG_INFO(TRACE_MODULE_APP, "4G RX 唤醒\r\n");
         flag_4G_recdata = 1;
         delaysleep_count = 3;
 }
@@ -463,6 +464,8 @@
 uint8_t flag_4guart_needinit=0;
 uint8_t index1,index2,index3;
 int tt2;
+int test1,test3;
+uint32_t test4;
 int main(void)
 {
     board_clock_run();
@@ -506,13 +509,14 @@
     //board_led_init();
 
     adc_open(&usr_adc_cfg);
+		
     IIC2_Init();
     Accelerometer_Init();
     IO_control_init();
     io_pin_mux_set(SCL_PIN, IO_FUNC0);//测试测距波形
     gpio_pin_set_dir(SCL_PIN , GPIO_DIR_OUT, 0);
     io_pull_set(SCL_PIN , IO_PULL_DOWN, IO_PULL_UP_LEVEL4);
-    gps_air780_power_change(1,1);//开启gps,4G 
+    gps_air780_power_change(0,1);//开启gps,4G 
 //加速度计初始化必须在IO_control_init之前因为复用SDA引脚
     adc_get(&sample[0], NUM_SAMPLES, adc_callback);//adc采样
 		   Program_Init();
@@ -530,9 +534,8 @@
     sleep_timer_start(__MS_TO_32K_CNT(SLEEP_TIMER_NUM));//测试
  //   board_5V_input_init(voltage_input_handler);
     board_acceleration_detection_init(move_handler);
-		 board_4GUsart_detection_init(_4gUsart_handler);
 //		 LOG_INFO(TRACE_MODULE_APP, "测试进入app");
-  
+		board_4GUsart_detection_init(_4gUsart_handler);
     while (1)
     { 
 			tt2 = gpio_pin_get_val(_4G_USART_RX_Pin);
@@ -549,7 +552,7 @@
             {
                 flag_4G_recdata = 2;
                
-                LOG_INFO(TRACE_MODULE_APP, "运行Socket_RecvAll\r\n");
+                //LOG_INFO(TRACE_MODULE_APP, "运行Socket_RecvAll tt2 %d\r\n",tt2);
                 Socket_RecvAll();
             }
 						air780_led_on();
@@ -591,21 +594,25 @@
 index1=IfTCPConnected();
 index2=AIR780E_IsIPIdle();
 index3=Socket_IsSendQueueEmpty(0);
-        if(!gps_power_state&&(IfTCPConnected()&&AIR780E_IsIPIdle()&&Socket_IsSendQueueEmpty(0)))
+				if(delaysleep_count==0)
+        if(!gps_power_state&&!gpio_pin_get_val(INPUT_5V_Pin)&&(IfTCPConnected()&&AIR780E_IsIPIdle()&&Socket_IsSendQueueEmpty(0)))
         {
+//					test1=gpio_pin_get_val(_4G_USART_RX_Pin);
             uint32_t lock;
-            flag_4guart_needinit = 1;
+            //flag_4guart_needinit = 1;
             Internet_Poll();
             HIDO_ATLitePoll();
             HIDO_TimerPoll();
             TCPClient_Poll();
          //   power_wakeup_enable((enum POWER_WAKEUP_SOURCE_T)_4G_USART_RX_Pin, POWER_WAKEUP_LEVEL_LOW);
-            LOG_INFO(TRACE_MODULE_APP, "进入休眠\r\n");
+            
            // delay_us(300000);
             trace_flush();
             lock = int_lock();            
             power_enter_power_down_mode(0);
 						uart_receive(UART_ID1,m_EUART_DMA_RXBuf,EUART_RX_BUF_SIZE,uart_receive_callback);
+//					test3=gpio_pin_get_val(_4G_USART_RX_Pin);
+					//LOG_INFO(TRACE_MODULE_APP, "进入休眠\r\n");
             int_unlock(lock);
         }
 

--
Gitblit v1.9.3