fix: 多项修复优化
1. 24h周期注册改为系统定时重启(SystemReset),移除RepeLoginCount 2. ADC连续采样改为单次采样,每次读完后重新触发Adc_SGL_Start 3. GWRevHandler/InRevHandler memcmp返回值修正 != false → != 0 4. APP_STATUS_WAIT_UPLOAD上传成功后UploadOk清零 5. UartDebug: DEBUG_CMD_CNT 16→17
This commit is contained in:
@@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#if (USE_DEBUG != 0)
|
#if (USE_DEBUG != 0)
|
||||||
#define DEBUG_CMD_CNT 16
|
#define DEBUG_CMD_CNT 17
|
||||||
const DBGFunType DebugFun[DEBUG_CMD_CNT];
|
const DBGFunType DebugFun[DEBUG_CMD_CNT];
|
||||||
|
|
||||||
volatile DebugChannel_e gDebugChannel = DBG_CH_RS485_1;//上电默认调试口
|
volatile DebugChannel_e gDebugChannel = DBG_CH_RS485_1;//上电默认调试口
|
||||||
|
|||||||
+2
-3
@@ -1,4 +1,4 @@
|
|||||||
#ifndef __MAIN_H
|
#ifndef __MAIN_H
|
||||||
#define __MAIN_H
|
#define __MAIN_H
|
||||||
#include "bsp.h"
|
#include "bsp.h"
|
||||||
#include "UartDebug.h"
|
#include "UartDebug.h"
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
#define Z 2
|
#define Z 2
|
||||||
#define XYZ 3
|
#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 ERR_TIMING_LOGIN (1800 / 30) //注册错误重新注册时间(半个小时1800秒)
|
||||||
|
|
||||||
#define TEST_TIME (60*60*1000)
|
#define TEST_TIME (60*60*1000)
|
||||||
@@ -77,7 +77,6 @@ typedef struct {
|
|||||||
AHRSData_T AHRSData;
|
AHRSData_T AHRSData;
|
||||||
ConvertedData_T ConvertedData;
|
ConvertedData_T ConvertedData;
|
||||||
|
|
||||||
uint32_t RepeLoginCount; //24h重复注册计数
|
|
||||||
uint8_t Login30MinCount; //注册30分定时计数
|
uint8_t Login30MinCount; //注册30分定时计数
|
||||||
uint8_t Login2Min30SCount; //注册100ms~2分+30s定时计数
|
uint8_t Login2Min30SCount; //注册100ms~2分+30s定时计数
|
||||||
bool Login_RTC; //注册30分定时器启动标志位
|
bool Login_RTC; //注册30分定时器启动标志位
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "bsp.h"
|
#include "bsp.h"
|
||||||
#include "Algorithm.h"
|
#include "Algorithm.h"
|
||||||
#include "UartDebug.h"
|
#include "UartDebug.h"
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -1,4 +1,4 @@
|
|||||||
#include "SGCP.h"
|
#include "SGCP.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "UartDebug.h"
|
#include "UartDebug.h"
|
||||||
#include "Update.h"
|
#include "Update.h"
|
||||||
@@ -916,7 +916,7 @@ static void GWRevHandler(void)
|
|||||||
return;
|
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)
|
if(is_all_byte(GFHeader->MDAddr, sizeof(GFHeader->MDAddr), 0x00) != true)
|
||||||
{
|
{
|
||||||
@@ -1138,7 +1138,7 @@ static void InRevHandler(void)
|
|||||||
return;
|
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");
|
DBG_LOG("Inside MAC Err...\r\n");
|
||||||
return;
|
return;
|
||||||
|
|||||||
+3
-2
@@ -236,7 +236,7 @@ static void AdcInit(void)
|
|||||||
Adc_Init(&stcAdcCfg);
|
Adc_Init(&stcAdcCfg);
|
||||||
|
|
||||||
Adc_CfgSglChannel(VBAT_ADC_PORTx); // 配置单次采样通道
|
Adc_CfgSglChannel(VBAT_ADC_PORTx); // 配置单次采样通道
|
||||||
Adc_SGL_Always_Start(); // 启动单次一直采样
|
Adc_SGL_Start(); // 启动单次采样
|
||||||
}
|
}
|
||||||
/*****************************************************************************************
|
/*****************************************************************************************
|
||||||
* 函数名称: Battery_Level_Percent_Table
|
* 函数名称: Battery_Level_Percent_Table
|
||||||
@@ -278,6 +278,7 @@ void ADCLoopHandler(void)
|
|||||||
VBAT_Percentage = Percentage(VBAT_12V);//获取百分比
|
VBAT_Percentage = Percentage(VBAT_12V);//获取百分比
|
||||||
//DBG_LOG("VBAT_Percentage:%d\n",VBAT_Percentage);
|
//DBG_LOG("VBAT_Percentage:%d\n",VBAT_Percentage);
|
||||||
Adc_ClrIrqStatus(AdcMskIrqSgl);//清除ADC中断状态
|
Adc_ClrIrqStatus(AdcMskIrqSgl);//清除ADC中断状态
|
||||||
|
Adc_SGL_Start(); // 启动单次采样
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void RTCInit(uint8_t sec)
|
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(LASER1_ON_OFF_PORTx,LASER1_ON_OFF_PINx,&GpioInitStruct);
|
||||||
Gpio_Init(LASER2_ON_OFF_PORTx,LASER2_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);
|
Gpio_Init(LASER3_ON_OFF_PORTx,LASER3_ON_OFF_PINx,&GpioInitStruct);
|
||||||
//< ADC???????
|
//< ADC控制引脚
|
||||||
Gpio_Init(AD_ON_OFF_PORTx,AD_ON_OFF_PINx,&GpioInitStruct);
|
Gpio_Init(AD_ON_OFF_PORTx,AD_ON_OFF_PINx,&GpioInitStruct);
|
||||||
|
|
||||||
GpioInitStruct.bOutputVal = true; ///< 端口默认输出配置->高电平
|
GpioInitStruct.bOutputVal = true; ///< 端口默认输出配置->高电平
|
||||||
|
|||||||
+13
-15
@@ -192,9 +192,9 @@ static void AppInit(void)
|
|||||||
SGCP.DeviceReadDataOk = false;
|
SGCP.DeviceReadDataOk = false;
|
||||||
SGCP.TimingAcquisition = false;
|
SGCP.TimingAcquisition = false;
|
||||||
|
|
||||||
|
App.SysResetTimeCnt = 0;
|
||||||
App.Login2Min30SCount = 0;
|
App.Login2Min30SCount = 0;
|
||||||
App.Login30MinCount = 0;
|
App.Login30MinCount = 0;
|
||||||
App.RepeLoginCount = 0;
|
|
||||||
App.LoginFlag = false;
|
App.LoginFlag = false;
|
||||||
App.Login_RTC = false;
|
App.Login_RTC = false;
|
||||||
App.Login_LPTimer0 = true;
|
App.Login_LPTimer0 = true;
|
||||||
@@ -457,6 +457,7 @@ static void AppLoopHandler(void)
|
|||||||
}
|
}
|
||||||
else if(SGCP.UploadOk == true)
|
else if(SGCP.UploadOk == true)
|
||||||
{
|
{
|
||||||
|
SGCP.UploadOk = false;
|
||||||
App.Upload45S10SCount = 0;
|
App.Upload45S10SCount = 0;
|
||||||
}
|
}
|
||||||
SGCP.UploadMess = false;
|
SGCP.UploadMess = false;
|
||||||
@@ -489,7 +490,7 @@ void FeedDogHandler(void)
|
|||||||
void SystemResetHandler(void)
|
void SystemResetHandler(void)
|
||||||
{
|
{
|
||||||
//系统定时重启
|
//系统定时重启
|
||||||
if(App.SysResetTimeCnt > SYSTEM_TIMING_LOGIN) {
|
if(App.SysResetTimeCnt > SYSTEM_TIMING_RESET) {
|
||||||
delay_ms(5);
|
delay_ms(5);
|
||||||
SystemReset();
|
SystemReset();
|
||||||
while(1);
|
while(1);
|
||||||
@@ -574,22 +575,19 @@ void SysTick_CallBack(void)
|
|||||||
void RtcIRQHander(void)
|
void RtcIRQHander(void)
|
||||||
{
|
{
|
||||||
//SGCP.TimingAcquisition = true; //30S更新一次数据
|
//SGCP.TimingAcquisition = true; //30S更新一次数据
|
||||||
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.SysResetTimeCnt++;
|
||||||
|
if(App.SysResetTimeCnt >= SYSTEM_TIMING_RESET) {
|
||||||
|
App.SysResetTimeCnt = 0;
|
||||||
|
delay_ms(5);
|
||||||
|
SystemReset();
|
||||||
|
while(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(SGCP.LoginOk == true)
|
||||||
|
{
|
||||||
App.Coll_N++;
|
App.Coll_N++;
|
||||||
if(App.Coll_N >= App.Para.Layout.CollectTime)
|
if(App.Coll_N >= App.Para.Layout.CollectTime)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user