1、startup.s汇编文件的的中断重定向改为ifdef,通过切换app_debug和app_boot判断是否编译

2、Sx1276Type_t 结构体给定固定值
3、lora通道选择取消,通过修改频率来修改通道
4、增加了修改lora参数的函数
5、将USE_BOOTLOADER的宏定义更改到工程预编译define
6、将BootPara_t结构体定义到bsp.h文件下
7、在bsp.h文件下增加了LoraPara_r,RS485Para_t结构体并声明
8、串口带波特率参数初始化
9、增加了MAIN_DBG_LOG和DATA_DBG_LOG调试打印
10、Update.h的boot参数定义在bsp.h获取
11、当工程是app_boot时调试口为Lpuart0,当工程是app_debug时调试口为uart0
12、设备Mac从bootloader中固定地址0x00002800获取,设备类型、通讯方式、设备标志和设备序号从获取到的mac地址解析
13、debug文件增加了调试指令
This commit is contained in:
2026-05-20 13:41:07 +08:00
parent cd594e3d69
commit 2efab2862f
16 changed files with 1239 additions and 223 deletions
+44 -10
View File
@@ -6,6 +6,7 @@
#include <time.h>
#include "gpio.h"
#include "spi.h"
#include "Update.h"
/*模块启用与关闭*/
#define USE_DEBUG 1 //调试串口选择,0、关闭,1、启用
@@ -23,8 +24,7 @@
#define USE_SPI0 1 //SPI1开关,0、关闭,1、启用
#define USE_SPI1 0 //SPI1开关,0、关闭,1、启用
#define USE_BOOTLOADER 1 //BOOTLOADER开关,0、关闭,1、启用
#define USE_LORA_CH 0 //0为测试通道
//#define USE_BOOTLOADER 1 //BOOTLOADER开关,0、关闭,1、启用
//<<---------------------------- MCU -------------------------------->>
//< UART0
@@ -209,12 +209,22 @@
extern float VBAT_8V4;
extern uint8_t VBAT_Percentage;
typedef struct {
uint32_t AppFlag;
uint32_t UpdateFlag;
uint32_t PackageCnt;
uint32_t AppSize;
uint32_t Crc32Check;
uint32_t FirstRunFlag;//第一次运行
uint8_t DevMac[6];//设备MAC
uint32_t LoraFreq;//Lora频率
}BootPara_t, *BootPara;
typedef struct {
uint16_t CollectTime; //数据采集时间间隔,设置范围30*N秒,1<=N<=240(默认5分钟,N=10)
uint16_t ReportInterval; //上报时间间隔,设置范围,30*N秒,10<=N<=1440(默认20分钟,N=40
uint8_t ERInterval; //紧急上报时间间隔,设置范围,30*N秒,2<=N<=10(默认2分钟,N=4
uint8_t ERTime; //紧急上报时长,设置范围,30*N秒,20<=N<=240(默认20分钟,N=40
uint16_t CollectTime; //数据采集时间间隔,设置范围30*N秒,1<=N<=240(默认300秒,N=10)
uint16_t ReportInterval; //上报时间间隔,设置范围,30*N秒,10<=N<=1440(默认1200秒,N=40
uint8_t ERInterval; //紧急上报时间间隔,设置范围,30*N秒,2<=N<=10(默认120秒,N=4
uint8_t ERTime; //紧急上报时长,设置范围,30*N秒,20<=N<=240(默认1200秒,N=40
uint32_t TimeStamp; //网关返回RTC时间戳
}__attribute__((packed))LayoutPara_t,*LayoutPara;//上位机下发的配置参数
@@ -225,16 +235,39 @@ typedef struct {
}__attribute__ ((packed))CalibratePara_t, *CalibratePara;
typedef struct {
bool OnOff;
uint8_t ucChannel;
int8_t ucPower;
uint8_t SignalBw;
uint8_t SpreadFactor;
uint8_t ErrorCoding;
uint8_t RegPreamble;
uint32_t FreqCent;
}__attribute__ ((packed))LoraPara_t, *pLoraPara;
typedef struct {
bool Enable; //串口使能
bool UpgradeEnable;//升级功能使能
uint32_t Addr; //本机485地址
uint32_t BaudRate;
}__attribute__((packed))RS485Para_t, *RS485Para;
typedef struct {
BootPara_t BLPara;
LayoutPara_t Layout;
CalibratePara_t CaliPara;
uint32_t RS485Addr; //本机485地址
RS485Para_t Rs485Ch1;
RS485Para_t Rs485Ch2;
uint32_t FactoryFlag;//出厂标志位
LoraPara_t Lora;
}AppPara_T, *pAppPara;
#define APP_PARA_ADDRESS (0x0001FE00)
#define SAVE_APP_PARA(addr) FlashWrite(APP_PARA_ADDRESS, addr, sizeof(App.Para) / 4)
#define READ_APP_PARA(addr) FlashRead(APP_PARA_ADDRESS, addr, sizeof(App.Para) / 4)
//#define APP_PARA_ADDRESS (0x0001FC00)
#define SAVE_APP_PARA(addr) FlashWrite(BOOT_PARA_ADDRESS, addr, sizeof(App.Para) / 4)
#define READ_APP_PARA(addr) FlashRead(BOOT_PARA_ADDRESS, addr, sizeof(App.Para) / 4)
void BspInit(void);
void LpUart0Init(uint32_t Baud);
void Uart0Init(uint32_t Baud);
void EnterDeepSleep(void);
void DBGUartSendByte(uint8_t sData);
void DBGUartSend(uint8_t *sData, int sLen);
@@ -269,3 +302,4 @@ void LORAIntDisable(void);
void ACCandMMCIntEnable(void);
void ACCandMMCIntDisable(void);
#endif