feat(uart): 分离ETH与Cat1通讯,支持UART1/Cat1/Debug互斥切换

Breaking Changes:
- USART1(PA11/PA12)改为Cat1(115200)/Debug(500000)共享,SGM3157控制
- USART4(PB09/PC13)独家给ETH(115200),不再共享
- 新增EthTask独立状态机,与CatOneTask解耦运行
- 上电默认Comm=CATONE_COMM,dch=RS485_CH1

Details:
- feat: 新增EthTask.c/h,ETH状态机(8态)独立运行
- refactor: CatOneTask移除ETH代码,AT发送/接收走USART1
- feat: comm cat1/eth命令增加USART1占用互斥检查
- feat: dch dbg命令增加USART1占用互斥检查
- feat: rt_kprintf根据dch通道自动路由(USART1/RS485)
- feat: 新增eth on/off调试打印开关命令
- fix: 两个状态机按Comm模式判断休眠,避免误发AT
- fix: bsp.c修复IRQ回调函数名不匹配(BusFault隐患)
- fix: PB08(PortB Pin08)PORT_Init触发复位,改用外部上拉+POUTE单bit使能
- fix: DebugCmd命令表DEBUG_CMD_CNT与实际条目数不符(crash风险)
- chore: 删除InfTest死函数、重复include、无用宏声明、EthRev_Sem等冗余代码
- chore: 更正中文标点(!→! ,→,)
This commit is contained in:
2026-07-22 12:36:01 +08:00
parent d08ca726df
commit f40c422684
14 changed files with 857 additions and 763 deletions
+19 -40
View File
@@ -2,8 +2,8 @@
#include <math.h>
#include "main.h"
#include "CatOneTask.h"
#include "EthTask.h"
#include "LoraTask.h"
#include "CatOneTask.h"
#include "RS485Task.h"
#include "DebugCmd.h"
#include "spiflash.h"
@@ -34,7 +34,8 @@ static const uint8_t GateWayMac_BL10[6] = {0x81, 0x00, 0x00, 0x06, 0x00, 0x0A};
bool MainDispEn = true;
static rt_thread_t Lora_Thread = RT_NULL;
static rt_thread_t Cat1Eth_Thread = RT_NULL;
static rt_thread_t Cat1_Thread = RT_NULL;
static rt_thread_t Eth_Thread = RT_NULL;
static rt_thread_t RS485Ch1_Thread = RT_NULL;
static rt_thread_t RS485Ch2_Thread = RT_NULL;
static rt_thread_t Debug_Thread = RT_NULL;
@@ -92,35 +93,6 @@ void SDCardTest(void)
}
#endif
void InfTest(void)
{
uint8_t sData[10] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A};
RS485_CH1_RX();
RS485_CH1_POW_ON();
rt_thread_delay(100);
RS485_CH1_POW_OFF();
RS485_CH2_POW_ON();
rt_thread_delay(100);
RS485_CH2_POW_OFF();
POWER_LED_OFF();
POWER_LED_ON();
LORA_RX_LED_SET();
LORA_RX_LED_CLR();
RS485_CH1_TX();
RS485_CH2_RX();
RS485Ch1_Config(500000);
RS485Ch2_Config(500000);
RS485Ch1UartSend(sData, 10);
rt_thread_delay(100);
RS485_CH2_TX();
RS485_CH1_RX();
RS485Ch2UartSend(sData, 10);
rt_thread_delay(100);
// SDCardTest();
}
void GateWayInit(void)
{
@@ -186,8 +158,7 @@ void GateWayInit(void)
#if MAC_ADDR_TYPE == 0
memcpy(GateWay.ConfigPara.GwMac, GateWayMac_Test, 6);
// GateWay.ConfigPara.DebugChannel = DEBUG_CH_RS485_1;
GateWay.ConfigPara.DebugChannel = DEBUG_CH_DBG;
GateWay.ConfigPara.DebugChannel = DEBUG_CH_RS485_1;
#elif MAC_ADDR_TYPE == 1
memcpy(GateWay.ConfigPara.GwMac, GateWayMac_BL1, 6);
GateWay.ConfigPara.DebugChannel = DEBUG_CH_RS485_1;
@@ -318,12 +289,14 @@ void GateWayInit(void)
else
rt_kprintf("History Num: 0\r\n");
if(GateWay.ConfigPara.Comm == CATONE_COMM) {
DbgOrCat1Uart_Config(115200);
CAT1_ON();
}
else {
DBG_ON();
ETH_ON();
rt_thread_delay(1000);
ETHReset();
rt_thread_delay(1000);
ETHReset();
}
}
@@ -418,9 +391,15 @@ int main(void)
else
return -1;
Cat1Eth_Thread = rt_thread_create("Cat1Eth", CatOne_Eth_Thread_Entry, &GateWay, 4096, 3, 20);
if (Cat1Eth_Thread != RT_NULL)
rt_thread_startup(Cat1Eth_Thread);
Cat1_Thread = rt_thread_create("Cat1", CatOne_Thread_Entry, &GateWay, 4096, 3, 20);
if (Cat1_Thread != RT_NULL)
rt_thread_startup(Cat1_Thread);
else
return -1;
Eth_Thread = rt_thread_create("Eth", Eth_Thread_Entry, &GateWay, 4096, 3, 20);
if (Eth_Thread != RT_NULL)
rt_thread_startup(Eth_Thread);
else
return -1;
@@ -437,9 +416,9 @@ int main(void)
POWER_LED_OFF();
}
}
EthRxOverhandler();
EthOverHandler();
RS485RxOverhandler();
DebugRxOverhandler();
DebugOrCat1RxOverhandler();
if(OneSecondDlyCnt % 200 == 0) {
FeedDog();
LORA_RX_TOGGLE();