新增:串口通讯避障功能

​ 1、Launcher中的串口只使用串口0(调试串口)、串口2(主动RS485端口);串口1与串口3不使用,且不初始化。将串口通讯缓冲区修改为1100Byte。

​  目的:CH564由于将Launcher代码搬运到RAM中运行,因此可使用的变量大小只有32Kbyte。不使用的串口将不初始化,同时使用的通讯缓冲区将节约出来,否则RAM空间不够使用。

​ 2、串口2 - 增加RS485使能,同时通讯增加避障功能。
This commit is contained in:
caocong
2026-01-19 16:39:22 +08:00
parent 094fd76a72
commit 5e9338cee4
37 changed files with 37088 additions and 289 deletions

View File

@@ -11,6 +11,7 @@
*******************************************************************************/
#include "ch564_spi.h"
#include "debug.h"
#include "watchdog.h"
uint32_t spi_comm_tick = 0;
#define SPICOMM_TIMEOUT 10
@@ -77,6 +78,8 @@ void SPI0_MasterSendByte(uint8_t data)
spi_comm_tick = SysTick_100us;
while (SPI0_GET_TOTAL_CNT() != 0)
{
WDT_Feed();
if(SysTick_100us - spi_comm_tick >= SPICOMM_TIMEOUT) break;
}
}
@@ -96,6 +99,8 @@ uint8_t SPI0_MasterRecvByte(void)
spi_comm_tick = SysTick_100us;
while (!SPI0_GET_FIFO_CNT())
{
WDT_Feed();
if(SysTick_100us - spi_comm_tick >= SPICOMM_TIMEOUT) break;
}
return (SPI0_GET_FIFO());
@@ -121,6 +126,8 @@ void SPI0_MasterTrans(uint8_t *pbuf, uint16_t len)
spi_comm_tick = SysTick_100us;
while (sendlen)
{
WDT_Feed();
if (SPI0_GET_FIFO_CNT() < SPI0_FIFO_SIZE)
{
SPI0_SET_FIFO(*pbuf);
@@ -133,6 +140,8 @@ void SPI0_MasterTrans(uint8_t *pbuf, uint16_t len)
spi_comm_tick = SysTick_100us;
while (SPI0_GET_TOTAL_CNT() != 0) // Wait for all the data in the FIFO to be sent
{
WDT_Feed();
if(SysTick_100us - spi_comm_tick >= SPICOMM_TIMEOUT) break;
}
}
@@ -160,6 +169,8 @@ void SPI0_MasterRecv(uint8_t *pbuf, uint16_t len)
spi_comm_tick = SysTick_100us;
while (readlen)
{
WDT_Feed();
if (SPI0_GET_FIFO_CNT())
{
*pbuf = SPI0_GET_FIFO();
@@ -193,6 +204,8 @@ void SPI0_MasterTransRecv(uint8_t *ptbuf, uint8_t *prbuf, uint16_t len)
spi_comm_tick = SysTick_100us;
while (sendlen)
{
WDT_Feed();
if (SPI0_GET_FIFO_CNT() == 0)
{
SPI0_SET_FIFO(*ptbuf);
@@ -227,6 +240,8 @@ void SPI0_DMATrans(uint8_t *pbuf, uint32_t len)
spi_comm_tick = SysTick_100us;
while (SPI0_GET_TOTAL_CNT())
{
WDT_Feed();
if(SysTick_100us - spi_comm_tick >= SPICOMM_TIMEOUT) break;
}
SPI0_SET_DMA_MODE(RB_SPI_DMA_ENABLE, DISABLE);
@@ -252,6 +267,8 @@ void SPI0_DMARecv(uint8_t *pbuf, uint32_t len)
spi_comm_tick = SysTick_100us;
while (SPI0_GET_TOTAL_CNT())
{
WDT_Feed();
if(SysTick_100us - spi_comm_tick >= 1000) break;
}
SPI0_SET_DMA_MODE(RB_SPI_DMA_ENABLE, DISABLE);