31f6f4af9a
通道系统: - 新增Channel_m枚举(CH_NULL/DBG/CH1/CH2/ETH/LORA/CAT1) - Much/Auch/Duch/CuchMask替代旧Comm/DebugChannel - ChannelIsActive宏四重身份检查, ChannelMQ每通道独立队列 - much/auch/duch/cuch命令(互斥检查+USART1 pair冲突) - 各通道任务按ChannelIsActive休眠/活跃 双回调分离: - SvrRegFlag->MuchRegFlag+AuchRegFlag - _NetRevCallBack+pRegFlag实现Much/Auch回调复用 MQ重构: - ChMQ[6]每通道独立队列替代NetSendData_MQ - UploadSend无条件下发Much+Auch双队列 - Cat1/ETH/RS485/Lora各自消费ChMQ 注册流程: - 注册帧绕MQ直接发送(解决FIFO顺序冲突) - NetCommOrgData输入输出buffer分离(解决重叠bug) - Much首次连上必注册, Auch跳过注册直接发送 - ETH_REG_SVR SendRetryCnt首次清零(解决无限重试) - 状态机不再清零注册标志 调试通道: - Debug_Printf->rt_kprintf->rt_hw_console_output全ch路由 - rt_hw_console_output 6通道switch - EthTxMutex保护USART4多线程安全 - ETH接收线程非0x7A帧头->DebugAnalyze(网络debug指令) - EthOverHandler阈值>5->>0(短指令接收) 冗余清理: - 删Cat1UpdateCallback/Cat1SendRegister/ETHSendRegister - 删InfTest/FSInit/SDCardTest死代码 - 删unused includes/macros/variables - 删vcom_Print/buff/ir中间层 - DEBUG_CMD_CNT实际对齐 - 中文标点修正 - 默认: Much=ETH Auch=null Duch=ETH Cuch=LORA
103 lines
2.2 KiB
C
103 lines
2.2 KiB
C
/*
|
|
* Copyright (c) 2006-2019, RT-Thread Development Team
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*
|
|
* Change Logs:
|
|
* Date Author Notes
|
|
* 2021-05-24 the first version
|
|
*/
|
|
|
|
#include <rthw.h>
|
|
#include <rtthread.h>
|
|
#include "bsp.h"
|
|
#include "main.h"
|
|
#include "sx127x.h"
|
|
|
|
extern GateWayPara_t GateWay;
|
|
|
|
#if defined(RT_USING_USER_MAIN) && defined(RT_USING_HEAP)
|
|
/*
|
|
* Please modify RT_HEAP_SIZE if you enable RT_USING_HEAP
|
|
* the RT_HEAP_SIZE max value = (sram size - ZI size), 1024 means 1024 bytes
|
|
*/
|
|
#define RT_HEAP_SIZE (48*1024)
|
|
static rt_uint8_t rt_heap[RT_HEAP_SIZE];
|
|
|
|
RT_WEAK void *rt_heap_begin_get(void)
|
|
{
|
|
return rt_heap;
|
|
}
|
|
|
|
RT_WEAK void *rt_heap_end_get(void)
|
|
{
|
|
return rt_heap + RT_HEAP_SIZE;
|
|
}
|
|
#endif
|
|
|
|
void rt_os_tick_callback(void)
|
|
{
|
|
rt_interrupt_enter();
|
|
|
|
rt_tick_increase();
|
|
|
|
rt_interrupt_leave();
|
|
}
|
|
|
|
void SysTick_IrqHandler(void)
|
|
{
|
|
rt_os_tick_callback();
|
|
}
|
|
|
|
/**
|
|
* This function will initial your board.
|
|
*/
|
|
void rt_hw_board_init(void)
|
|
{
|
|
//#error "TODO 1: OS Tick Configuration."
|
|
BSP_Init();
|
|
/*
|
|
* TODO 1: OS Tick Configuration
|
|
* Enable the hardware timer and call the rt_os_tick_callback function
|
|
* periodically with the frequency RT_TICK_PER_SECOND.
|
|
*/
|
|
|
|
/* Call components board initial (use INIT_BOARD_EXPORT()) */
|
|
#ifdef RT_USING_COMPONENTS_INIT
|
|
rt_components_board_init();
|
|
#endif
|
|
|
|
#if defined(RT_USING_USER_MAIN) && defined(RT_USING_HEAP)
|
|
rt_system_heap_init(rt_heap_begin_get(), rt_heap_end_get());
|
|
#endif
|
|
}
|
|
|
|
#ifdef RT_USING_CONSOLE
|
|
|
|
static int uart_init(void)
|
|
{
|
|
//#error "TODO 2: Enable the hardware uart and config baudrate."
|
|
DbgOrCat1Uart_Config(500000);
|
|
// RS485Ch1_Config(500000);
|
|
return 0;
|
|
}
|
|
INIT_BOARD_EXPORT(uart_init);
|
|
|
|
void rt_hw_console_output(const char *str)
|
|
{
|
|
rt_enter_critical();
|
|
switch(GateWay.ConfigPara.Duch) {
|
|
case CH_RS485_1: RS485Ch1UartSend((uint8_t *)str, strlen(str)); break;
|
|
case CH_RS485_2: RS485Ch2UartSend((uint8_t *)str, strlen(str)); break;
|
|
case CH_ETH: EthUartSend((uint8_t *)str, strlen(str)); break;
|
|
case CH_LORA: Sx1276LoRaSendBuffer((uint8_t *)str, strlen(str)); break;
|
|
case CH_DBG:
|
|
case CH_CAT1:
|
|
default: DebugOrCat1UartSend((uint8_t *)str, strlen(str)); break;
|
|
}
|
|
rt_exit_critical();
|
|
}
|
|
|
|
#endif
|
|
|