串口和中断写完

This commit is contained in:
2026-05-25 23:53:39 +08:00
parent 42ceefc5ad
commit 4f108bc26a
9 changed files with 33254 additions and 444 deletions
+49 -52
View File
@@ -2,65 +2,62 @@
#include "shell.h"
/* 板级BSP头文件 */
#include "Bsp.h"
#include "Voilet.h"
#define WR_BUFFER_SIZE 512
/* 1. 创建shell对象,开辟shell缓冲区 */
Shell Host; //Shell实例化
char HostBuffer[WR_BUFFER_SIZE]; //读写缓冲区
uint32_t HostId; //串口号
const COM_MAP_T *HostCom = TTY_COM;
/**
* @brief Shell写函数
* @param ComId 串口号,ch 数据
* @retval void
* @note void
* @example void
*/
signed short ShellWrite(char* ch, unsigned short Len)
{
ComSendStr(HostCom, (uint8_t* )ch,Len);
return Len;
}
/**
* @brief Shell读函数 - 中断回调实现
* @param Vector 中断向量号
* @retval void
* @note void
* @example void
*/
void LetterShellIrqFunc(void *Param)
{
uint8_t ch = 0x00;
ch = ComReceiveChar(Param);
shellHandler(&Host, ch);
}
/**
* @brief 初始化Shell
* @param ComId 串口号,baud 波特率
* @retval void
* @note void
* @example void
*/
void LetterShellInit(const COM_MAP_T *ComX, uint32_t Baud)
{
//初始化串口
ComStdConfig(ComX, Baud);
//设置串口回调函数
IrqRegister(ComX->Periph.Irqn, LetterShellIrqFunc);
//设置中断等级
IrqConfig(ComX->Periph.Irqn,1,1);
//注册写函数
Host.write = ShellWrite;
//初始化LetterShell
shellInit(&Host, HostBuffer, WR_BUFFER_SIZE);
}
// /**
// * @brief Shell写函数
// * @param ComId 串口号,ch 数据
// * @retval void
// * @note void
// * @example void
// */
// signed short ShellWrite(char* ch, unsigned short Len)
// {
// UsartSendStr(HostId, (uint8_t* )ch,Len);
// return Len;
// }
// /**
// * @brief Shell读函数 - 中断回调实现
// * @param Vector 中断向量号
// * @retval void
// * @note void
// * @example void
// */
// void LetterShellIrqFunc(uint32_t Vector)
// {
// uint8_t ch = 0x00;
// ch = UsartReceiveChar(Vector);
//
// shellHandler(&Host, ch);
// }
//
//
// /**
// * @brief 初始化Shell
// * @param ComId 串口号,baud 波特率
// * @retval void
// * @note void
// * @example void
// */
// void LetterShellInit(uint32_t ComId, uint32_t baud)
// {
// HostId = ComId;
//
// //初始化串口
// UsartStdConfig(ComId, baud);
// //设置串口回调函数
// InterruptRegister(TTY_COM_IRQN, LetterShellIrqFunc);
// //设置中断等级
// InterruptSetLevel(TTY_COM_IRQN,1,1);
// //注册写函数
// Host.write = ShellWrite;
//
// shellInit(&Host, HostBuffer, WR_BUFFER_SIZE);
// }
//
// /**
// * @brief 打印版本号
// * @param void