commit 6c99b1201ee52d74e55a0740eca36fa8c1c3b992 Author: liyp Date: Tue Aug 25 22:08:26 2026 -0400 first commit diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..9a6a19f --- /dev/null +++ b/.clang-format @@ -0,0 +1,20 @@ +# For more options, open this url: https://clang.llvm.net.cn/docs/ClangFormatStyleOptions.html +--- +BasedOnStyle: Microsoft +IndentWidth: 4 +UseTab: Never +TabWidth: 4 +ColumnLimit: 0 +--- +Language: Cpp +AccessModifierOffset: -4 +NamespaceIndentation: All +FixNamespaceComments: false +BreakBeforeBraces: Linux +AllowShortIfStatementsOnASingleLine: true +AllowShortLoopsOnASingleLine: true +AllowShortBlocksOnASingleLine: true +IndentCaseLabels: true +SortIncludes: false +AlignConsecutiveMacros: AcrossEmptyLines +AlignConsecutiveAssignments: Consecutive diff --git a/.eide/eide.yml b/.eide/eide.yml new file mode 100644 index 0000000..7933ec1 --- /dev/null +++ b/.eide/eide.yml @@ -0,0 +1,208 @@ +version: "4.1" +name: Stm32F10xTmp +type: ARM +deviceName: null +packDir: null +srcDirs: [] +virtualFolder: + name: + files: [] + folders: + - name: System + files: + - path: VoiletBspStm32F10x/System/system_stm32f10x.c + - path: VoiletBspStm32F10x/System/LinkScripts/Gcc/stm32_flash_ze.ld + - path: VoiletBspStm32F10x/System/Cmsis/Src/core_cm3.c + folders: [] + - name: Startup + files: + - path: VoiletBspStm32F10x/System/Startup/Gcc/startup_stm32f10x_hd.s + folders: [] + - name: App + files: + - path: App/Src/LetterShell.c + - path: App/Src/main.c + folders: [] + - name: Shell + files: + - path: VoiletBspStm32F10x/ThirdParty/LetterShellV3/Src/shell.c + - path: VoiletBspStm32F10x/ThirdParty/LetterShellV3/Src/shell_cmd_list.c + - path: VoiletBspStm32F10x/ThirdParty/LetterShellV3/Src/shell_companion.c + - path: VoiletBspStm32F10x/ThirdParty/LetterShellV3/Src/shell_ext.c + folders: [] + - name: Bsp + files: + - path: VoiletBspStm32F10x/Bsp/Src/Bsp.c + - path: VoiletBspStm32F10x/Bsp/Src/Delay.c + - path: VoiletBspStm32F10x/Bsp/Src/Gpio.c + - path: VoiletBspStm32F10x/Bsp/Src/Interrupt.c + - path: VoiletBspStm32F10x/Bsp/Src/SeggerCall.c + - path: VoiletBspStm32F10x/Bsp/Src/SysCall.c + - path: VoiletBspStm32F10x/Bsp/Src/Uart.c + folders: [] + - name: StdLib + files: + - path: VoiletBspStm32F10x/StdLib/Src/misc.c + - path: VoiletBspStm32F10x/StdLib/Src/stm32f10x_adc.c + - path: VoiletBspStm32F10x/StdLib/Src/stm32f10x_bkp.c + - path: VoiletBspStm32F10x/StdLib/Src/stm32f10x_can.c + - path: VoiletBspStm32F10x/StdLib/Src/stm32f10x_cec.c + - path: VoiletBspStm32F10x/StdLib/Src/stm32f10x_crc.c + - path: VoiletBspStm32F10x/StdLib/Src/stm32f10x_dac.c + - path: VoiletBspStm32F10x/StdLib/Src/stm32f10x_dbgmcu.c + - path: VoiletBspStm32F10x/StdLib/Src/stm32f10x_dma.c + - path: VoiletBspStm32F10x/StdLib/Src/stm32f10x_exti.c + - path: VoiletBspStm32F10x/StdLib/Src/stm32f10x_flash.c + - path: VoiletBspStm32F10x/StdLib/Src/stm32f10x_fsmc.c + - path: VoiletBspStm32F10x/StdLib/Src/stm32f10x_gpio.c + - path: VoiletBspStm32F10x/StdLib/Src/stm32f10x_i2c.c + - path: VoiletBspStm32F10x/StdLib/Src/stm32f10x_iwdg.c + - path: VoiletBspStm32F10x/StdLib/Src/stm32f10x_pwr.c + - path: VoiletBspStm32F10x/StdLib/Src/stm32f10x_rcc.c + - path: VoiletBspStm32F10x/StdLib/Src/stm32f10x_rtc.c + - path: VoiletBspStm32F10x/StdLib/Src/stm32f10x_sdio.c + - path: VoiletBspStm32F10x/StdLib/Src/stm32f10x_spi.c + - path: VoiletBspStm32F10x/StdLib/Src/stm32f10x_tim.c + - path: VoiletBspStm32F10x/StdLib/Src/stm32f10x_usart.c + - path: VoiletBspStm32F10x/StdLib/Src/stm32f10x_wwdg.c + folders: [] +dependenceList: [] +outDir: Output +miscInfo: + uid: d92a06a9fb4c340402d39197c79d1252 +targets: + Debug: + cppPreprocessAttrs: + defineList: + - USE_STDPERIPH_DRIVER + - STM32F10X_HD + - DEBUG + incList: + - App/Inc + - Board + - VoiletBspStm32F10x/Bsp/Inc + - VoiletBspStm32F10x/StdLib/Inc + - VoiletBspStm32F10x/System/Cmsis/Inc + - VoiletBspStm32F10x/System + - VoiletBspStm32F10x/ThirdParty/LetterShellV3/Inc + libList: [] + excludeList: [] + settings: + debugger: cortex-debug + toolchain: GCC + toolchainConfigMap: + GCC: + archExtensions: "" + cpuType: Cortex-M3 + floatingPointHardware: none + options: + version: 5 + afterBuildTasks: [] + asm-compiler: + ASM_FLAGS: "" + beforeBuildTasks: [] + c/cpp-compiler: + CXX_FLAGS: "" + C_FLAGS: "" + language-c: c11 + language-cpp: c++11 + one-elf-section-per-data: true + one-elf-section-per-function: true + optimization: level-debug + warnings: all-warnings + global: + $float-abi-type: hard + misc-control: "" + not-use-syscalls: true + output-debug-info: enable + use-newlib-nano: true + linker: + $outputTaskExcludes: + - .bin + LD_FLAGS: "" + LIB_FLAGS: -lm + output-format: elf + remove-unused-input-sections: true + scatterFilePath: VoiletBspStm32F10x/System/LinkScripts/Gcc/stm32_flash_ze.ld + storageLayout: + RAM: [] + ROM: [] + useCustomScatterFile: true + uploadConfigMap: + JLink: + baseAddr: "" + bin: "" + cpuInfo: + cpuName: STM32F103ZE + vendor: ST + otherCmds: "" + proType: 1 + speed: 8000 + uploader: JLink + Release: + cppPreprocessAttrs: + defineList: + - USE_STDPERIPH_DRIVER + - STM32F10X_HD + incList: + - App/Inc + - Board + - VoiletBspStm32F10x/Bsp/Inc + - VoiletBspStm32F10x/StdLib/Inc + - VoiletBspStm32F10x/System/Cmsis/Inc + - VoiletBspStm32F10x/System + - VoiletBspStm32F10x/ThirdParty/LetterShellV3/Inc + libList: [] + excludeList: [] + settings: + debugger: cortex-debug + toolchain: GCC + toolchainConfigMap: + GCC: + archExtensions: "" + cpuType: Cortex-M3 + floatingPointHardware: none + options: + version: 5 + afterBuildTasks: [] + asm-compiler: + ASM_FLAGS: "" + beforeBuildTasks: [] + c/cpp-compiler: + CXX_FLAGS: "" + C_FLAGS: "" + language-c: c11 + language-cpp: c++11 + one-elf-section-per-data: true + one-elf-section-per-function: true + optimization: level-debug + warnings: all-warnings + global: + $float-abi-type: hard + misc-control: "" + not-use-syscalls: true + output-debug-info: enable + use-newlib-nano: true + linker: + $outputTaskExcludes: + - .bin + LD_FLAGS: "" + LIB_FLAGS: -lm + output-format: elf + remove-unused-input-sections: true + scatterFilePath: VoiletBspStm32F10x/System/LinkScripts/Gcc/stm32_flash_ze.ld + storageLayout: + RAM: [] + ROM: [] + useCustomScatterFile: true + uploadConfigMap: + JLink: + baseAddr: "" + bin: "" + cpuInfo: + cpuName: STM32F103ZE + vendor: ST + otherCmds: "" + proType: 1 + speed: 8000 + uploader: JLink diff --git a/.eide/files.options.yml b/.eide/files.options.yml new file mode 100644 index 0000000..52b7793 --- /dev/null +++ b/.eide/files.options.yml @@ -0,0 +1,23 @@ +########################################################################################## +# Append Compiler Options For Source Files +########################################################################################## + +# syntax: +# : +# For get pattern syntax, please refer to: https://www.npmjs.com/package/micromatch +# +# examples: +# 'main.cpp': --cpp11 -Og ... +# 'src/*.c': -gnu -O2 ... +# 'src/lib/**/*.cpp': --cpp11 -Os ... +# '!Application/*.c': -O0 +# '**/*.c': -O2 -gnu ... + +version: "2.1" +options: + Debug: + files: {} + virtualPathFiles: {} + Release: + files: {} + virtualPathFiles: {} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ced8fc7 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +# Ignore Output directory +Output/ diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..ae4a6a2 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "VoiletBspStm32F10x"] + path = VoiletBspStm32F10x + url = https://git.linuxacme.com/iorebuild/VoiletBspStm32F10x.git diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..3874a73 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,17 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "cwd": "${workspaceRoot}", + "type": "cortex-debug", + "request": "launch", + "name": "Debug: JLINK", + "servertype": "jlink", + "interface": "swd", + "executable": "Output/Debug/Stm32F10xTmp.elf", + "runToEntryPoint": "main", + "device": "STM32F103ZE", + "toolchainPrefix": "arm-none-eabi" + } + ] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..06fb314 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,9 @@ +{ + "editor.formatOnSave": true, + "[c]": { + "editor.defaultFormatter": "xaver.clang-format" + }, + "[cpp]": { + "editor.defaultFormatter": "xaver.clang-format" + } +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..3e192b9 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,40 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "type": "shell", + "command": "${command:eide.project.build}", + "group": "build", + "problemMatcher": [] + }, + { + "label": "flash", + "type": "shell", + "command": "${command:eide.project.uploadToDevice}", + "group": "build", + "problemMatcher": [] + }, + { + "label": "build and flash", + "type": "shell", + "command": "${command:eide.project.buildAndFlash}", + "group": "build", + "problemMatcher": [] + }, + { + "label": "rebuild", + "type": "shell", + "command": "${command:eide.project.rebuild}", + "group": "build", + "problemMatcher": [] + }, + { + "label": "clean", + "type": "shell", + "command": "${command:eide.project.clean}", + "group": "build", + "problemMatcher": [] + } + ] +} \ No newline at end of file diff --git a/App/Inc/LetterShell.h b/App/Inc/LetterShell.h new file mode 100755 index 0000000..3319cc9 --- /dev/null +++ b/App/Inc/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/Inc/main.h b/App/Inc/main.h new file mode 100755 index 0000000..83626a2 --- /dev/null +++ b/App/Inc/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/App/Src/LetterShell.c b/App/Src/LetterShell.c new file mode 100755 index 0000000..56bdf61 --- /dev/null +++ b/App/Src/LetterShell.c @@ -0,0 +1,100 @@ +#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/Src/main.c b/App/Src/main.c new file mode 100755 index 0000000..bc5c81d --- /dev/null +++ b/App/Src/main.c @@ -0,0 +1,30 @@ +// +// Created by anonymous on 2026/5/24. +// +/* C标准库头文件 */ +#include +#include +/* BSP文件 */ +#include "Bsp.h" +#include "main.h" + +int8_t DiTbl[DI_NUM]; + +int main(void) +{ + + BspInit(); + + while (1) + { + for (uint8_t i = 0; i < DI_NUM; i++) + { + DiTbl[i] = DiGet(i); + } + + LedToggle(LED0); + DelayMs(100); + } + + EXIT_APP +} \ No newline at end of file diff --git a/Board/Board.h b/Board/Board.h new file mode 100755 index 0000000..7a2d451 --- /dev/null +++ b/Board/Board.h @@ -0,0 +1,41 @@ +// +// 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 3 // 数字信号输入通道数量 +enum { + KEY_WK_UP = 0, + KEY_0, + KEY_1, +}; + +#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/Doc/普中STM32-F103-凤凰开发板原理图.pdf b/Doc/普中STM32-F103-凤凰开发板原理图.pdf new file mode 100755 index 0000000..65a81d5 Binary files /dev/null and b/Doc/普中STM32-F103-凤凰开发板原理图.pdf differ diff --git a/README.md b/README.md new file mode 100644 index 0000000..75360fa --- /dev/null +++ b/README.md @@ -0,0 +1,15 @@ +1、克隆仓库 + +``` +git clone --recurse https://git.linuxacme.com/iorebuild/Stm32F10xTmp.git +``` + +2、将子模块切换为main分支 + +``` +cd Stm32F10xTmp +``` + +``` +git submodule foreach "git checkout main" +``` diff --git a/Stm32F10xTmp.code-workspace b/Stm32F10xTmp.code-workspace new file mode 100644 index 0000000..c1f8cb2 --- /dev/null +++ b/Stm32F10xTmp.code-workspace @@ -0,0 +1,47 @@ +{ + "folders": [ + { + "path": "." + } + ], + "settings": { + "clangd.arguments": [ + "--header-insertion=never" + ], + "files.autoGuessEncoding": true, + "C_Cpp.default.configurationProvider": "cl.eide", + "C_Cpp.errorSquiggles": "disabled", + "files.associations": { + ".eideignore": "ignore", + "*.a51": "a51", + "*.h": "c", + "*.c": "c", + "*.hxx": "cpp", + "*.hpp": "cpp", + "*.c++": "cpp", + "*.cpp": "cpp", + "*.cxx": "cpp", + "*.cc": "cpp" + }, + "[yaml]": { + "editor.insertSpaces": true, + "editor.tabSize": 4, + "editor.autoIndent": "advanced" + } + }, + "extensions": { + "recommendations": [ + "cl.eide", + "keroc.hex-fmt", + "xiaoyongdong.srecord", + "hars.cppsnippets", + "zixuanwang.linkerscript", + "redhat.vscode-yaml", + "IBM.output-colorizer", + "cschlosser.doxdocgen", + "ms-vscode.vscode-serial-monitor", + "dan-c-underwood.arm", + "marus25.cortex-debug" + ] + } +} \ No newline at end of file