添加工程应用文件

This commit is contained in:
2026-07-05 13:20:02 +08:00
parent 47079ae36a
commit a9fc53c97b
6 changed files with 175 additions and 1 deletions
+98
View File
@@ -0,0 +1,98 @@
#include "LetterShell.h"
#include "shell.h"
/* 板级BSP头文件 */
#include "Bsp.h"
#define WR_BUFFER_SIZE 512
/* 1. 创建shell对象,开辟shell缓冲区 */
Shell Host; //Shell实例化
char HostBuffer[WR_BUFFER_SIZE]; //读写缓冲区
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
* @note void
* @param ComX 串口号,baud 波特率
* @retval void
*/
void LetterShellInit(const COM_MAP_T *ComX, uint32_t Baud) {
//初始化串口
ComStdConfig(ComX, Baud);
//设置串口回调函数
IrqRegister(ComX->Periph.Irqn, LetterShellIrqFunc);
//设置中断等级
IrqEnable(ComX->Periph.Irqn, 1, 1);
//注册写函数
Host.write = ShellWrite;
//初始化LetterShell
shellInit(&Host, HostBuffer, WR_BUFFER_SIZE);
}
// /**
// * @brief 打印版本号
// * @param void
// * @retval void
// * @note void
// * @example void
// */
// void version(void)
// {
// printf("%s,%s\r\n",HARDWARE_VERSION,SOFTWARE_VERSION);
// }
//
// /**
// * @brief 重启单片机
// * @param void
// * @retval void
// * @note void
// * @example void
// */
// void reboot(void)
// {
// SystemReboot();
// }
//
// /**
// * @brief 串口测试程序
// * @param void
// * @retval void
// * @note void
// * @example void
// */
//
// void comTest(uint8_t ComId)
// {
// }
//
// //打印版本号
// SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC), version, version, version);
// //软重启单片机
// SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC), reboot, reboot, reboot);
// //串口测试
// SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC), comTest, comTest, comTest);
+8
View File
@@ -0,0 +1,8 @@
#ifndef __LETTER_SHELL_H__
#define __LETTER_SHELL_H__
#include "Bsp.h"
void LetterShellInit(const COM_MAP_T *ComX, uint32_t Baud);
#endif
Executable
+21
View File
@@ -0,0 +1,21 @@
//
// Created by anonymous on 2026/5/24.
//
/* C标准库头文件 */
#include <stdio.h>
#include <stdint.h>
/* BSP文件 */
#include "main.h"
#include "Bsp.h"
int main(void) {
BspInit();
while (1) {
LedToggle(LED0);
DelayMs(100);
}
return 0;
}
Executable
+8
View File
@@ -0,0 +1,8 @@
//
// Created by anonymous on 2026/5/24.
//
#ifndef MAIN_H
#define MAIN_H
#endif //MAIN_H