diff --git a/App/LetterShell.c b/App/LetterShell.c new file mode 100755 index 0000000..4065eb6 --- /dev/null +++ b/App/LetterShell.c @@ -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); diff --git a/App/LetterShell.h b/App/LetterShell.h new file mode 100755 index 0000000..3319cc9 --- /dev/null +++ b/App/LetterShell.h @@ -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 diff --git a/App/main.c b/App/main.c new file mode 100755 index 0000000..81491c2 --- /dev/null +++ b/App/main.c @@ -0,0 +1,21 @@ +// +// Created by anonymous on 2026/5/24. +// +/* C标准库头文件 */ +#include +#include +/* BSP文件 */ +#include "main.h" +#include "Bsp.h" + +int main(void) { + + BspInit(); + + while (1) { + LedToggle(LED0); + DelayMs(100); + } + + return 0; +} \ No newline at end of file diff --git a/App/main.h b/App/main.h new file mode 100755 index 0000000..83626a2 --- /dev/null +++ b/App/main.h @@ -0,0 +1,8 @@ +// +// Created by anonymous on 2026/5/24. +// + +#ifndef MAIN_H +#define MAIN_H + +#endif //MAIN_H diff --git a/Board/Board.h b/Board/Board.h new file mode 100755 index 0000000..ddf41d2 --- /dev/null +++ b/Board/Board.h @@ -0,0 +1,39 @@ +// +// Created by anonymous on 2026/5/28. +// + +#ifndef _BOARD_H +#define _BOARD_H + +/* Voilet Bsp */ +#include "VoiletPort.h" + +/* Chip Library Enable */ + +/* Extra Library Enable */ +#define TTY_COM COM1 +#define TTY_BAUD 115200 + +#define LED_NUM 2 //LED灯数量 +enum { + LED0 = 0, + LED1 +}; + +#define DI_NUM 0 //数字信号输入通道数量 +// enum { +// +// }; + +#define DO_NUM 0 //数字信号输出通道数量 +// enum { +// +// }; + +#define RS485_1 COM1 +// #define RS485_2 +// #define RS485_3 +// #define RS485_4 +// #define RS485_5 + +#endif //_BOARD_H diff --git a/VoiletBspStm32F10x b/VoiletBspStm32F10x index 2494094..b3bfcb4 160000 --- a/VoiletBspStm32F10x +++ b/VoiletBspStm32F10x @@ -1 +1 @@ -Subproject commit 249409457fcd556b5fbcecffa6330ab7a495d32b +Subproject commit b3bfcb42f5e605a4f102e009d2ba8bbfe9110d95