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:
+3
-3
@@ -758,7 +758,7 @@ static void MasRevHandler(void)
|
||||
return;
|
||||
}
|
||||
|
||||
if(SFHeader->Addr != App.Para.RS485Addr)
|
||||
if(SFHeader->Addr != App.Para.Rs485Ch1.Addr)
|
||||
{
|
||||
if(SFHeader->Addr != 0x00)
|
||||
{
|
||||
@@ -1120,7 +1120,7 @@ static void InRevHandler(void)
|
||||
}
|
||||
else
|
||||
{
|
||||
App.Para.RS485Addr = temp;
|
||||
App.Para.Rs485Ch1.Addr = temp;
|
||||
SAVE_APP_PARA((uint32_t *)&App.Para);
|
||||
if(SGCP.InStatus == IN_STATUS_IDLE)
|
||||
{
|
||||
@@ -2195,7 +2195,7 @@ void InRevLoopHandler(void)
|
||||
case IN_STATUS_ALTER_485ADDR:{
|
||||
PrintfMess();
|
||||
Alter485AddrRes(LocalMAC, true);
|
||||
DBG_LOG("Alter RS485Addr:%X\r\n", App.Para.RS485Addr);
|
||||
DBG_LOG("Alter RS485Addr:%X\r\n", App.Para.Rs485Ch1.Addr);
|
||||
SGCP.InStatus = IN_STATUS_IDLE;
|
||||
break;}
|
||||
|
||||
|
||||
+15
-15
@@ -1,7 +1,7 @@
|
||||
#include "Update.h"
|
||||
#include "UartDebug.h"
|
||||
|
||||
BootPara_t BLPara;
|
||||
#include "main.h"
|
||||
#include "bsp.h"
|
||||
|
||||
/*****************************************************************************************
|
||||
* 函数名称: Update
|
||||
@@ -14,19 +14,19 @@ void Update(uint8_t *PayLoad)
|
||||
UpDataRequset_t Req;
|
||||
|
||||
memcpy(&Req, PayLoad, sizeof(UpDataRequset_t));
|
||||
BLPara.AppSize = Req.AppSize;
|
||||
BLPara.Crc32Check = Req.AppCrc32;
|
||||
BLPara.PackageCnt = Req.PackageNum;
|
||||
BLPara.AppFlag = 0;
|
||||
BLPara.UpdateFlag = APP_UPDATE_FLAG;
|
||||
App.Para.BLPara.AppSize = Req.AppSize;
|
||||
App.Para.BLPara.Crc32Check = Req.AppCrc32;
|
||||
App.Para.BLPara.PackageCnt = Req.PackageNum;
|
||||
App.Para.BLPara.AppFlag = 0;
|
||||
App.Para.BLPara.UpdateFlag = APP_UPDATE_FLAG;
|
||||
|
||||
U_DBG_LOG("Receive upgrade command:\r\n");
|
||||
U_DBG_LOG("PackageNum: %d\r\n", BLPara.PackageCnt);
|
||||
U_DBG_LOG("AppSize: %d\r\n", BLPara.AppSize);
|
||||
U_DBG_LOG("AppCrc32: 0x%08x\r\n", BLPara.Crc32Check);
|
||||
U_DBG_LOG("PackageNum: %d\r\n", App.Para.BLPara.PackageCnt);
|
||||
U_DBG_LOG("AppSize: %d\r\n", App.Para.BLPara.AppSize);
|
||||
U_DBG_LOG("AppCrc32: 0x%08x\r\n", App.Para.BLPara.Crc32Check);
|
||||
U_DBG_LOG("System Reset!\r\n");
|
||||
|
||||
SAVE_BOOT_PARA((uint32_t *)&BLPara);
|
||||
SAVE_BOOT_PARA((uint32_t *)&App.Para);
|
||||
U_DELAY_MS(200);
|
||||
U_SYSTEM_TESET();
|
||||
}
|
||||
@@ -39,10 +39,10 @@ void Update(uint8_t *PayLoad)
|
||||
*****************************************************************************************/
|
||||
void UpdateInit(void)
|
||||
{
|
||||
READ_BOOT_PARA((uint32_t *)&BLPara);
|
||||
if(BLPara.AppFlag != APP_START_FLAG) {
|
||||
BLPara.AppFlag = APP_START_FLAG;
|
||||
SAVE_BOOT_PARA((uint32_t *)&BLPara);
|
||||
READ_BOOT_PARA((uint32_t *)&App.Para);
|
||||
if(App.Para.BLPara.AppFlag != APP_START_FLAG) {
|
||||
App.Para.BLPara.AppFlag = APP_START_FLAG;
|
||||
SAVE_BOOT_PARA((uint32_t *)&App.Para);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+23
-9
@@ -89,7 +89,7 @@ static void SystemRCLInit(void)
|
||||
Sysctrl_ClkSourceEnable(SysctrlClkRCL, TRUE); ///< 使能RCL时钟
|
||||
}
|
||||
|
||||
static void Uart0Init(void)
|
||||
void Uart0Init(uint32_t Baud)
|
||||
{
|
||||
stc_gpio_cfg_t stcGpioCfg;
|
||||
stc_uart_cfg_t stcCfg;
|
||||
@@ -116,7 +116,7 @@ static void Uart0Init(void)
|
||||
stcCfg.enMmdorCk = UartMskEven; ///<偶校验
|
||||
stcCfg.stcBaud.u32Pclk = Sysctrl_GetPClkFreq(); ///<PCLK获取
|
||||
stcCfg.stcBaud.enClkDiv = UartMsk8Or16Div; ///<采样分频
|
||||
stcCfg.stcBaud.u32Baud = 500000; ///<波特率
|
||||
stcCfg.stcBaud.u32Baud = Baud; ///<波特率
|
||||
stcCfg.enRunMode = UartMskMode1; ///<工作模式
|
||||
Uart_Init(M0P_UART0, &stcCfg);
|
||||
|
||||
@@ -166,7 +166,7 @@ static void Uart1Init(void)
|
||||
Uart_EnableIrq(M0P_UART1, UartRxIrq); ///<使能接收中断
|
||||
EnableNvic(UART1_3_IRQn, IrqLevel3, TRUE); ///<系统中断使能
|
||||
}
|
||||
static void LpUart0Init(void)
|
||||
void LpUart0Init(uint32_t Baud)
|
||||
{
|
||||
stc_gpio_cfg_t stcGpioCfg;
|
||||
stc_lpuart_cfg_t stcCfg;
|
||||
@@ -193,7 +193,7 @@ static void LpUart0Init(void)
|
||||
stcCfg.stcBaud.enSclkSel = LPUartMskRcl; ///<传输时钟源
|
||||
stcCfg.stcBaud.u32Sclk = 38400; ///<PCLK获取
|
||||
stcCfg.stcBaud.enSclkDiv = LPUartMsk4Or8Div; ///<采样分频
|
||||
stcCfg.stcBaud.u32Baud = 9600; ///<波特率
|
||||
stcCfg.stcBaud.u32Baud = Baud; ///<波特率
|
||||
stcCfg.enRunMode = LPUartMskMode1; ///<工作模式
|
||||
LPUart_Init(M0P_LPUART0, &stcCfg);
|
||||
|
||||
@@ -703,9 +703,22 @@ void PrintfMess(void)
|
||||
}
|
||||
void DBGUartSendByte(uint8_t sData)
|
||||
{
|
||||
#if USE_BOOTLOADER
|
||||
LPUart_SendData(M0P_LPUART0, sData);
|
||||
#else
|
||||
Uart_SendDataPoll(M0P_UART0, sData);
|
||||
#endif
|
||||
}
|
||||
void DBGUartSend(uint8_t *sData, int sLen)
|
||||
{
|
||||
#if USE_BOOTLOADER
|
||||
LPUart0SendArray(sData, sLen);
|
||||
#else
|
||||
for(int i = 0; i < sLen; i++) {
|
||||
Uart_SendDataPoll(M0P_UART0, sData[i]);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void LPUart0SendArray(uint8_t *sData, uint8_t sLen)
|
||||
{
|
||||
RS485_CTRL_TX();
|
||||
@@ -783,6 +796,7 @@ void LpUart0_IRQHandler(void)
|
||||
LPUart_ClrStatus(M0P_LPUART0, LPUartRC); ///<清接收中断请求
|
||||
uint8_t u8RxData = LPUart_ReceiveData(M0P_LPUART0); ///读取数据
|
||||
LPUartRx_CallBack(u8RxData);
|
||||
DebugUartIRQ(u8RxData);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -791,7 +805,7 @@ void Uart0_IRQHandler(void)
|
||||
if(Uart_GetStatus(M0P_UART0, UartRC)) { ///接收数据
|
||||
Uart_ClrStatus(M0P_UART0, UartRC); ///<清接收中断请求
|
||||
uint8_t u8RxData = Uart_ReceiveData(M0P_UART0); ///读取数据
|
||||
DebugUartIRQ(u8RxData);
|
||||
//DebugUartIRQ(u8RxData);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -876,7 +890,7 @@ void WakeUpInit(void)
|
||||
AdcInit();
|
||||
#endif
|
||||
#if (USE_UART0 == 1)
|
||||
Uart0Init();
|
||||
Uart0Init(500000);
|
||||
#endif
|
||||
#if (USE_SPI0 == 1)
|
||||
SPI0Init();
|
||||
@@ -908,7 +922,7 @@ void BspInit(void)
|
||||
AdcInit();
|
||||
#endif
|
||||
#if (USE_UART0 == 1)//< DEBUG
|
||||
Uart0Init();
|
||||
Uart0Init(500000);
|
||||
#endif
|
||||
#if (USE_RTC == 1)//< RTC
|
||||
RTCInit(30);
|
||||
@@ -923,7 +937,7 @@ void BspInit(void)
|
||||
SPI1Init();
|
||||
#endif
|
||||
#if (USE_LPUART0 == 1)//< LPUART0
|
||||
LpUart0Init();
|
||||
LpUart0Init(9600);
|
||||
#endif
|
||||
#if(USE_I2C0 == 1)
|
||||
I2C0Init();
|
||||
|
||||
+126
-110
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user