f40c422684
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: 更正中文标点(!→! ,→,)
102 lines
2.1 KiB
C
102 lines
2.1 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"
|
|
|
|
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 (32*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();
|
|
if(GateWay.ConfigPara.DebugChannel == DEBUG_CH_RS485_1) {
|
|
RS485Ch1UartSend((uint8_t *)str, strlen(str));
|
|
}
|
|
else if(GateWay.ConfigPara.DebugChannel == DEBUG_CH_RS485_2) {
|
|
RS485Ch2UartSend((uint8_t *)str, strlen(str));
|
|
}
|
|
else {
|
|
DebugOrCat1UartSend((uint8_t *)str, strlen(str));
|
|
}
|
|
rt_exit_critical();
|
|
}
|
|
|
|
#endif
|
|
|