diff --git a/Module/LaserTracing_Debug/UartDebug.c b/Module/LaserTracing_Debug/UartDebug.c index 6df5696..6334776 100644 --- a/Module/LaserTracing_Debug/UartDebug.c +++ b/Module/LaserTracing_Debug/UartDebug.c @@ -12,7 +12,7 @@ #if (USE_DEBUG != 0) -#define DEBUG_CMD_CNT 16 +#define DEBUG_CMD_CNT 17 const DBGFunType DebugFun[DEBUG_CMD_CNT]; volatile DebugChannel_e gDebugChannel = DBG_CH_RS485_1;//上电默认调试口 diff --git a/source/inc/main.h b/source/inc/main.h index f77541e..eb1301d 100644 --- a/source/inc/main.h +++ b/source/inc/main.h @@ -1,4 +1,4 @@ -#ifndef __MAIN_H +#ifndef __MAIN_H #define __MAIN_H #include "bsp.h" #include "UartDebug.h" @@ -17,7 +17,7 @@ #define Z 2 #define XYZ 3 -#define SYSTEM_TIMING_LOGIN (86400 / 30) //系统定时注册时间(一天86400秒) +#define SYSTEM_TIMING_RESET (86400 / 30) //系统定时重启时间(一天86400秒) #define ERR_TIMING_LOGIN (1800 / 30) //注册错误重新注册时间(半个小时1800秒) #define TEST_TIME (60*60*1000) @@ -77,7 +77,6 @@ typedef struct { AHRSData_T AHRSData; ConvertedData_T ConvertedData; - uint32_t RepeLoginCount; //24h重复注册计数 uint8_t Login30MinCount; //注册30分定时计数 uint8_t Login2Min30SCount; //注册100ms~2分+30s定时计数 bool Login_RTC; //注册30分定时器启动标志位 diff --git a/source/src/Algorithm.c b/source/src/Algorithm.c index d3c239f..d0656a8 100644 --- a/source/src/Algorithm.c +++ b/source/src/Algorithm.c @@ -1,4 +1,4 @@ -#include "bsp.h" +#include "bsp.h" #include "Algorithm.h" #include "UartDebug.h" diff --git a/source/src/SGCP.c b/source/src/SGCP.c index 0763caf..6d0c8c4 100644 --- a/source/src/SGCP.c +++ b/source/src/SGCP.c @@ -1,4 +1,4 @@ -#include "SGCP.h" +#include "SGCP.h" #include "main.h" #include "UartDebug.h" #include "Update.h" @@ -916,7 +916,7 @@ static void GWRevHandler(void) return; } - if(memcmp(GFHeader->MDAddr, LocalMAC, sizeof(GFHeader->MDAddr)) != false) + if(memcmp(GFHeader->MDAddr, LocalMAC, sizeof(GFHeader->MDAddr)) != 0) { if(is_all_byte(GFHeader->MDAddr, sizeof(GFHeader->MDAddr), 0x00) != true) { @@ -1138,7 +1138,7 @@ static void InRevHandler(void) return; } - if(memcmp(IFHeader->MAC, LocalMAC, sizeof(IFHeader->MAC)) != false) + if(memcmp(IFHeader->MAC, LocalMAC, sizeof(IFHeader->MAC)) != 0) { DBG_LOG("Inside MAC Err...\r\n"); return; diff --git a/source/src/bsp.c b/source/src/bsp.c index d916d5b..7b31ae5 100644 --- a/source/src/bsp.c +++ b/source/src/bsp.c @@ -236,7 +236,7 @@ static void AdcInit(void) Adc_Init(&stcAdcCfg); Adc_CfgSglChannel(VBAT_ADC_PORTx); // 配置单次采样通道 - Adc_SGL_Always_Start(); // 启动单次一直采样 + Adc_SGL_Start(); // 启动单次采样 } /***************************************************************************************** * 函数名称: Battery_Level_Percent_Table @@ -278,6 +278,7 @@ void ADCLoopHandler(void) VBAT_Percentage = Percentage(VBAT_12V);//获取百分比 //DBG_LOG("VBAT_Percentage:%d\n",VBAT_Percentage); Adc_ClrIrqStatus(AdcMskIrqSgl);//清除ADC中断状态 + Adc_SGL_Start(); // 启动单次采样 } } void RTCInit(uint8_t sec) @@ -390,7 +391,7 @@ static void GPIOInit(void) Gpio_Init(LASER1_ON_OFF_PORTx,LASER1_ON_OFF_PINx,&GpioInitStruct); Gpio_Init(LASER2_ON_OFF_PORTx,LASER2_ON_OFF_PINx,&GpioInitStruct); Gpio_Init(LASER3_ON_OFF_PORTx,LASER3_ON_OFF_PINx,&GpioInitStruct); - //< ADC??????? + //< ADC控制引脚 Gpio_Init(AD_ON_OFF_PORTx,AD_ON_OFF_PINx,&GpioInitStruct); GpioInitStruct.bOutputVal = true; ///< 端口默认输出配置->高电平 @@ -398,7 +399,7 @@ static void GPIOInit(void) Gpio_Init(LORA_RST_PORTx,LORA_RST_PINx,&GpioInitStruct); //< LED_State Gpio_Init(LED_STATE_PORTx,LED_STATE_PINx,&GpioInitStruct); - + /********************************** GPIO输入 ****************************************/ GpioInitStruct.enDir = GpioDirIn; ///< 端口方向配置->输入 GpioInitStruct.enPu = GpioPuDisable; ///< 端口上下拉配置->无 diff --git a/source/src/main.c b/source/src/main.c index 1c46210..f4ca1a9 100644 --- a/source/src/main.c +++ b/source/src/main.c @@ -192,9 +192,9 @@ static void AppInit(void) SGCP.DeviceReadDataOk = false; SGCP.TimingAcquisition = false; + App.SysResetTimeCnt = 0; App.Login2Min30SCount = 0; App.Login30MinCount = 0; - App.RepeLoginCount = 0; App.LoginFlag = false; App.Login_RTC = false; App.Login_LPTimer0 = true; @@ -457,6 +457,7 @@ static void AppLoopHandler(void) } else if(SGCP.UploadOk == true) { + SGCP.UploadOk = false; App.Upload45S10SCount = 0; } SGCP.UploadMess = false; @@ -489,7 +490,7 @@ void FeedDogHandler(void) void SystemResetHandler(void) { //系统定时重启 - if(App.SysResetTimeCnt > SYSTEM_TIMING_LOGIN) { + if(App.SysResetTimeCnt > SYSTEM_TIMING_RESET) { delay_ms(5); SystemReset(); while(1); @@ -574,22 +575,19 @@ void SysTick_CallBack(void) void RtcIRQHander(void) { //SGCP.TimingAcquisition = true; //30S更新一次数据 + + + //系统定时重启 + App.SysResetTimeCnt++; + if(App.SysResetTimeCnt >= SYSTEM_TIMING_RESET) { + App.SysResetTimeCnt = 0; + delay_ms(5); + SystemReset(); + while(1); + } + if(SGCP.LoginOk == true) { - App.RepeLoginCount++; - if(App.RepeLoginCount >= SYSTEM_TIMING_LOGIN){ - MAIN_DBG_LOG("24h Repetition Login\r\n"); - App.RepeLoginCount = 0; - SGCP.LoginOk = false;//24h重复注册 - App.Login2Min30SCount = 0; - App.Login30MinCount = 0; - App.Login_RTC = false;//关闭30分注册定时器 - - App.Login_LPTimer0 = true; - LPTimer0_ON((App.Nonce % 1200) + 300);//定时30s+随机2分钟,最小间隙100ms - MAIN_DBG_LOG("Login LPTimer0 Open\r\n"); - } - App.Coll_N++; if(App.Coll_N >= App.Para.Layout.CollectTime) {