移植完成mdkv5工程

This commit is contained in:
iorebuild 2025-06-30 23:25:38 +08:00
commit 2b2747fef7
28 changed files with 11692 additions and 0 deletions

7
.gitignore vendored Normal file
View File

@ -0,0 +1,7 @@
Eide/build/*
MdkV5/Listings/*
MdkV5/Objects/*
MdkV5/*.uvoptx
MdkV5/EventRecorderStub.scvd
MdkV5/*\.uvguix*
Ses/Output/*

128
App/Inc/Board.h Normal file
View File

@ -0,0 +1,128 @@
#ifndef __BOARD_H__
#define __BOARD_H__
#include <stm32f10x.h>
#define VERSION "v1.0.0"
/* **********NVIC中断向量控制器组别********** */
#define NVIC_GROUP_LEVEL NVIC_PriorityGroup_2
/* **********END********** */
/* **********SystemClock相关********** */
// GPIO
#define GPIO_ENABLE
#define USE_GPIOA
#define USE_GPIOB
#define USE_GPIOC
#define USE_GPIOD
#define USE_GPIOE
#define USE_GPIOF
#define USE_GPIOG
// USART
#define USART_ENABLE
#define USE_USART1
#undef USE_USART2
#undef USE_USART3
#undef USE_USART4
#undef USE_USART5
#undef USE_USART6
/* **********END********** */
/* **********GPIO DO DI相关********** */
// 数字输出
#undef USE_DIGITAL_OUTPUT
#ifdef USE_DIGITAL_OUTPUT
#define DO_NUM 2
#define DO1 0
#define DO2 1
#endif
// 数字输入
#undef USE_DIGITAL_INPUT
#ifdef USE_DIGITAL_INPUT
#define DI_NUM 2
#define DI1 0
#define DI2 1
#endif
// LED灯
#define USE_LED
#ifdef USE_LED
#define LED_NUM 3
#define LED0 0
#define LED1 1
#define LED2 2
#endif
/* **********END********** */
/* **********串口相关********** */
#ifdef USE_USART1
#define COM0 USART1_BASE
#define COM0_IRQN USART1_IRQn
#define COM0_TX_PORT GPIOA
#define COM0_RX_PORT GPIOA
#define COM0_TX_PIN GPIO_Pin_9
#define COM0_RX_PIN GPIO_Pin_10
#endif
#ifdef USE_USART2
#define COM1 USART2_BASE
#define COM1_IRQN USART2_IRQn
#define COM1_TX_PORT GPIOA
#define COM1_RX_PORT GPIOA
#define COM1_TX_PIN GPIO_Pin_2
#define COM1_RX_PIN GPIO_Pin_3
#endif
#ifdef USE_USART3
#define COM2 USART3_BASE
#define COM2_IRQN USART3_IRQn
#define COM2_TX_PORT GPIOB
#define COM2_RX_PORT GPIOB
#define COM2_TX_PIN GPIO_Pin_10
#define COM2_RX_PIN GPIO_Pin_11
#endif
#ifdef USE_USART4
#define COM3 UART4_BASE
#define COM3_IRQN UART4_IRQn
#define COM3_TX_PORT GPIOC
#define COM3_RX_PORT GPIOC
#define COM3_TX_PIN GPIO_Pin_10
#define COM3_RX_PIN GPIO_Pin_11
#endif
#ifdef USE_USART5
#define COM4 UART5_BASE
#define COM4_IRQN UART5_IRQn
#define COM4_TX_PORT GPIOB
#define COM4_RX_PORT GPIOD
#define COM4_TX_PIN GPIO_Pin_12
#define COM4_RX_PIN GPIO_Pin_2
#endif
/* LetterShell */
#define USE_SHELL
#ifdef USE_SHELL
#define TTY_COM COM0
#define TTY_COM_IRQN COM0_IRQN
#endif
/* **********END********** */
#define USE_ANALOG_INPUT
#define USE_ANALOG_OUTPUT
/* 自定义Flash布局相关 */
#define BOOT_SIZE_16 /* 16Kb的Bootloader大小 不带网络*/
//#define BOOT_SIZE_32 /* 32Kb的Bootloader大小 带网络*/
#define FLASH_BASE_ADDR 0x08000000 //Flash基地址
#define BOOT_ADDR 0x08000000 //引导程序地址
//BOOT程序大小
#ifdef BOOT_SIZE_16
#define BOOT_ROM 0x4000
#endif
#ifdef BOOT_SIZE_32
#define BOOT_ROM 0x8000
#endif
#define USER_PARAM_ADDR (FLASH_BASE_ADDR + BOOT_ROM) //用户参数分区
#define APPLICATION_ADDR 0x08010000 //从128K的位置开始是应用程序
/* **********END********** */
#endif

8
App/Inc/LedTest.h Normal file
View File

@ -0,0 +1,8 @@
#ifndef __LEDTEST_H__
#define __LEDTEST_H__
#include "bsp.h"
void LedCtlTaskInit(uint8_t Level,uint8_t Preemption);
#endif

8
App/Inc/LetterShell.h Normal file
View File

@ -0,0 +1,8 @@
#ifndef __LETTER_SHELL_H__
#define __LETTER_SHELL_H__
#include "Bsp.h"
void LetterShellInit(uint32_t ComId, uint32_t baud);
#endif

49
App/Src/LedTest.c Normal file
View File

@ -0,0 +1,49 @@
#include "LedTest.h"
/* OS相关 */
#define TASK_STACK_SIZE 128 //任务栈大小
/* OS相关 */
TX_THREAD LedCtlTaskTCB; //LED控制任务句柄
static uint8_t TaskStack[TASK_STACK_SIZE]; //任务栈空间
void LedCtlTask(ULONG thread_input);
/**
* @brief LED控制任务初始化
* @param Level任务优先级 Preemption抢占阈值
* @retval void
* @note void
* @example void
*/
void LedCtlTaskInit(uint8_t Level,uint8_t Preemption)
{
tx_thread_create(&LedCtlTaskTCB, /* 任务句柄 */
"LedCtlTask", /* 任务名称 */
LedCtlTask, /* 任务入口函数 */
0, /* 任务参数 */
&TaskStack[0], /* 任务栈起始地址 */
TASK_STACK_SIZE, /* 任务堆栈大小 */
Level, /* 优先级 */
Preemption, /* 抢占阈值 */
TX_NO_TIME_SLICE, /* 不使用时间片轮转 */
TX_AUTO_START); /* 自动启动线程 */
}
/**
* @brief LED控制任务
* @param ThreadXInput
* @retval void
* @note void
* @example void
*/
void LedCtlTask(ULONG ThreadXInput)
{
(void)ThreadXInput;
while (true)
{
IoCtlLedToggle(LED2);
tx_thread_sleep(100);
}
}

103
App/Src/LetterShell.c Normal file
View File

@ -0,0 +1,103 @@
#include "LetterShell.h"
#include "shell.h"
#define WR_BUFFER_SIZE 512
/* 1. 创建shell对象开辟shell缓冲区 */
Shell Host; //Shell实例化
char HostBuffer[WR_BUFFER_SIZE]; //读写缓冲区
uint32_t HostId; //串口号
/**
* @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);
//设置串口回调函数
IntCbReg(TTY_COM_IRQN, LetterShellIrqFunc);
//设置中断等级
IntSetLevel(TTY_COM_IRQN,1,1);
//注册写函数
Host.write = ShellWrite;
shellInit(&Host, HostBuffer, WR_BUFFER_SIZE);
}
/**
* @brief
* @param void
* @retval void
* @note void
* @example void
*/
int version(void)
{
printf("%s\r\n",VERSION);
return 0;
}
/**
* @brief DO控制
* @param chnl val状态值
* @retval void
* @note void
* @example void
*/
void doSet(uint8_t chnl, uint8_t val)
{
IoCtl(IO_TYPE_DO, chnl, val);
}
/**
* @brief DO控制反转
* @param chnl
* @retval void
* @note void
* @example void
*/
void doToggle(uint8_t chnl)
{
IoCtlToggleDo(chnl);
}
//打印版本号
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC), version, version, version);
//控制DO
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC), doSet, doSet, doSet);
//反转DO
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC), doToggle, doToggle, doToggle);

47
App/Src/Main.c Normal file
View File

@ -0,0 +1,47 @@
/* MCU INCLUDE */
#include "stm32f10x.h"
/* BSP INCLUDE */
#include "Bsp.h"
/* OPEN_SOURCE_LIB INCLUDE */
#include "LetterShell.h"
/* APP INLCUDE */
#include "LedTest.h"
/**
* @brief ThreadX操作系统入口函数
* @param FirstUnusedMemory OS相关
* @retval void
* @note OS相关的初始化放到这里
* @example void
*/
void tx_application_define(void* FirstUnusedMemory)
{
/* 优先级31抢占10 */
LedCtlTaskInit(31,10);
}
/**
* @brief C程序主函数
* @param void
* @retval void
* @note void
* @example void
*/
int main(void)
{
//bsp初始化
BspConfigInit();
//LetterShell初始化
LetterShellInit(TTY_COM,115200);
/* Start ThreadX */
tx_kernel_enter();
while (true)
{
//程序运行到这里说明OS调度运行失败
printf("OS Start Error !\n");
DelayMs(1000);
}
}

38
Eide/.clang-format Normal file
View File

@ -0,0 +1,38 @@
---
BasedOnStyle: Microsoft
Language: Cpp
###################################
# indent conf
###################################
UseTab: Never
IndentWidth: 4
TabWidth: 4
ColumnLimit: 0
AccessModifierOffset: -4
NamespaceIndentation: All
FixNamespaceComments: false
BreakBeforeBraces: Linux
###################################
# other styles
###################################
#
# for more conf, you can ref: https://clang.llvm.org/docs/ClangFormatStyleOptions.html
#
AllowShortIfStatementsOnASingleLine: true
AllowShortLoopsOnASingleLine: true
AllowShortBlocksOnASingleLine: true
IndentCaseLabels: true
SortIncludes: false
AlignConsecutiveMacros: AcrossEmptyLines
AlignConsecutiveAssignments: Consecutive

18
Eide/.clangd Normal file
View File

@ -0,0 +1,18 @@
CompileFlags:
Add:
- -IC:\Program Files (x86)\Arm GNU Toolchain arm-none-eabi\14.2 rel1\arm-none-eabi\include\newlib-nano
- -IC:\Program Files (x86)\Arm GNU Toolchain arm-none-eabi\14.2 rel1\arm-none-eabi\include\c++\14.2.1
- -IC:\Program Files (x86)\Arm GNU Toolchain arm-none-eabi\14.2 rel1\arm-none-eabi\include\c++\14.2.1\arm-none-eabi\thumb\v7-m\nofp
- -IC:\Program Files (x86)\Arm GNU Toolchain arm-none-eabi\14.2 rel1\arm-none-eabi\include\c++\14.2.1\backward
- -IC:\Program Files (x86)\Arm GNU Toolchain arm-none-eabi\14.2 rel1\lib\gcc\arm-none-eabi\14.2.1\include
- -IC:\Program Files (x86)\Arm GNU Toolchain arm-none-eabi\14.2 rel1\lib\gcc\arm-none-eabi\14.2.1\include-fixed
- -IC:\Program Files (x86)\Arm GNU Toolchain arm-none-eabi\14.2 rel1\arm-none-eabi\include
- -Ic:\program files (x86)\gnu arm embedded toolchain\10 2021.10\arm-none-eabi\include\newlib-nano
- -Ic:\program files (x86)\gnu arm embedded toolchain\10 2021.10\arm-none-eabi\include\c++\10.3.1
- -Ic:\program files (x86)\gnu arm embedded toolchain\10 2021.10\arm-none-eabi\include\c++\10.3.1\arm-none-eabi\thumb\v7-m\nofp
- -Ic:\program files (x86)\gnu arm embedded toolchain\10 2021.10\arm-none-eabi\include\c++\10.3.1\backward
- -Ic:\program files (x86)\gnu arm embedded toolchain\10 2021.10\lib\gcc\arm-none-eabi\10.3.1\include
- -Ic:\program files (x86)\gnu arm embedded toolchain\10 2021.10\lib\gcc\arm-none-eabi\10.3.1\include-fixed
- -Ic:\program files (x86)\gnu arm embedded toolchain\10 2021.10\arm-none-eabi\include
CompilationDatabase: ./build/Debug
Compiler: c:\Program Files (x86)\GNU Arm Embedded Toolchain\10 2021.10\bin\arm-none-eabi-g++.exe

View File

@ -0,0 +1,110 @@
##############################################
#
# STM32 Option Bytes
#
# Usage: Uncomment to enable options
#
##############################################
# RDP = <Level>
# BOR_LEV = <Level>
# WWDG_SW = <Value>
# IWDG_SW = <Value>
# IWDG_STOP = <Value>
# IWDG_STDBY = <Value>
# IWDG_ULP = <Value>
# FZ_IWDG_STOP = <Value>
# FZ_IWDG_STDBY = <Value>
# nRST_STOP = <Value>
# nRST_STDBY = <Value>
# nBOOT_SEL = <Value>
# nRST_SHDW = <Value>
# PCROP_RDP = <Value>
# nBFB2 = <Value>
# BFB2 = <Value>
# nBoot1 = <Value>
# Boot1 = <Value>
# nBoot0 = <Value>
# nBoot0_SW_Cfg = <Value>
# VDDA = <Value>
# SDADC12_VDD = <Value>
# DB1M = <Value>
# DUALBANK = <Value>
# nDBANK = <Value>
# BOOT0_nSW_Config = <Value>
# Data0 = <Value>
# Data1 = <Value>
# nSRAM_Parity = <Value>
# SRAM2_RST = <Value>
# SRAM2_PE = <Value>
# DDS = <Value>
# FSD = <Value>
# SFSA = <Value>
# C2OPT = <Value>
# NBRSD = <Value>
# SNBRSA = <Value>
# SBRSA = <Value>
# BRSD = <Value>
# SBRV = <Value>
# DMEPB = <Value>
# DMESB = <Value>
# Security = <Value>
# CM7_BOOT_ADD0 = <Value>
# CM7_BOOT_ADD1 = <Value>
# IWDG1 = <Value>
# IWDG2 = <Value>
# nRST_STDBY_D2 = <Value>
# BOOT_CM4 = <Value>
# nRST_STDBY_D1 = <Value>
# BOOT_CM7 = <Value>
# CM7_BOOT_ADD0 = <Value>
# CM7_BOOT_ADD1 = <Value>
# DMEPA = <Value>
# DMESA = <Value>
# SECA_strt = <Value>
# SECA_end = <Value>
# SECB_strt = <Value>
# SECB_end = <Value>
# DTCM_RAM = <Value>
# SPRMOD = <Value>
# WPRMOD = <Value>
# PCROPA_STRT = <Value>
# PCROPA_END = <Value>
# PCROPB_STRT = <Value>
# PCROPB_END = <Value>
# WRP = <Value>
# WRP2 = <Value>
# WRP3 = <Value>
# WRP4 = <Value>
# WRP1A_STRT = <Value>
# WRP1A_END = <Value>
# WRP1B_STRT = <Value>
# WRP1B_END = <Value>
# WRP2A_STRT = <Value>
# WRP2A_END = <Value>
# WRP2B_STRT = <Value>
# WRP2B_END = <Value>
# IPCCDBA = <Value>

156
Eide/.eide/eide.json Normal file
View File

@ -0,0 +1,156 @@
{
"name": "Application",
"type": "ARM",
"dependenceList": [],
"srcDirs": [
"../../../Bsp/Src",
"../../../StdLib/Src",
"../../../System/CMSIS",
"../../../ThirdLib/LetterShell/Src",
"../App/Src"
],
"virtualFolder": {
"name": "<virtual_root>",
"files": [
{
"path": "../../../System/Startup/TrueStudio/startup_stm32f10x_hd.s"
},
{
"path": "../../../System/stm32f10x_it.c"
},
{
"path": "../../../System/system_stm32f10x.c"
}
],
"folders": []
},
"outDir": "build",
"deviceName": "STM32F103ZE",
"packDir": ".pack/Keil/STM32F1xx_DFP.2.3.0",
"miscInfo": {
"uid": "ecbbdd2006397faa870eccaf00bbaa03"
},
"targets": {
"Debug": {
"excludeList": [
"../../../../System/LinkScripts",
"../../../../System/Startup"
],
"toolchain": "GCC",
"compileConfig": {
"cpuType": "Cortex-M3",
"floatingPointHardware": "none",
"scatterFilePath": "../../../System/LinkScripts/TrueStudio/stm32_flash_ze.ld",
"useCustomScatterFile": true,
"storageLayout": {
"RAM": [],
"ROM": []
},
"options": "null"
},
"uploader": "OpenOCD",
"uploadConfig": {
"bin": "",
"target": "stm32f1x",
"interface": "stlink-v2-1",
"baseAddr": "0x08000000"
},
"uploadConfigMap": {
"JLink": {
"bin": "",
"baseAddr": "",
"cpuInfo": {
"vendor": "null",
"cpuName": "null"
},
"proType": 1,
"speed": 8000,
"otherCmds": ""
},
"STLink": {
"bin": "",
"proType": "SWD",
"resetMode": "default",
"runAfterProgram": true,
"speed": 4000,
"address": "0x08000000",
"elFile": "None",
"optionBytes": ".eide/debug.st.option.bytes.ini",
"otherCmds": ""
},
"OpenOCD": {
"bin": "",
"target": "stm32f1x",
"interface": "stlink",
"baseAddr": "0x08000000"
}
},
"custom_dep": {
"name": "default",
"incList": [
".",
"../App/Inc",
"../../../Bsp/Inc",
"../../../System",
"../../../StdLib/Inc",
"../../../ThirdLib/LetterShell/Inc",
"../../../System/CMSIS"
],
"libList": [],
"defineList": [
"DEBUG",
"USE_STDPERIPH_DRIVER",
"STM32F10X_HD"
]
},
"builderOptions": {
"GCC": {
"version": 5,
"beforeBuildTasks": [],
"afterBuildTasks": [],
"global": {
"$float-abi-type": "softfp",
"output-debug-info": "enable",
"misc-control": "--specs=nosys.specs --specs=nano.specs"
},
"c/cpp-compiler": {
"language-c": "c99",
"language-cpp": "c++11",
"optimization": "level-debug",
"warnings": "all-warnings",
"one-elf-section-per-function": true,
"one-elf-section-per-data": true
},
"asm-compiler": {},
"linker": {
"output-format": "elf",
"remove-unused-input-sections": true,
"LIB_FLAGS": "-lm",
"$toolName": "auto"
}
},
"AC5": {
"version": 4,
"beforeBuildTasks": [],
"afterBuildTasks": [],
"global": {
"use-microLIB": false,
"output-debug-info": "enable"
},
"c/cpp-compiler": {
"optimization": "level-0",
"one-elf-section-per-function": true,
"c99-mode": true,
"C_FLAGS": "--diag_suppress=1 --diag_suppress=1295",
"CXX_FLAGS": "--diag_suppress=1 --diag_suppress=1295"
},
"asm-compiler": {},
"linker": {
"output-format": "elf"
}
}
}
}
},
"version": "3.5"
}

19
Eide/.eide/env.ini Normal file
View File

@ -0,0 +1,19 @@
###########################################################
# project environment variables
###########################################################
# append command prefix for toolchain
#COMPILER_CMD_PREFIX=
# mcu ram size (used to print memory usage)
#MCU_RAM_SIZE=0x00
# mcu rom size (used to print memory usage)
#MCU_ROM_SIZE=0x00
# put your global variables ...
#GLOBAL_VAR=
[debug]
# put your variables for 'debug' target ...
#VAR=

View File

@ -0,0 +1,20 @@
##########################################################################################
# Append Compiler Options For Source Files
##########################################################################################
# syntax:
# <your pattern>: <compiler options>
# 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.0"
options:
Debug:
files: {}
virtualPathFiles: {}

15
Eide/.gitignore vendored Normal file
View File

@ -0,0 +1,15 @@
# dot files
/.vscode/launch.json
/.settings
/.eide/log
/.eide.usr.ctx.json
# project out
/build
/bin
/obj
/out
# eide template
*.ept
*.eide-template

1
Eide/.vscode/settings.json vendored Normal file
View File

@ -0,0 +1 @@
{}

40
Eide/.vscode/tasks.json vendored Normal file
View File

@ -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": []
}
]
}

View File

@ -0,0 +1,45 @@
{
"folders": [
{
"path": "."
}
],
"settings": {
"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",
"alefragnani.project-manager",
"dan-c-underwood.arm",
"marus25.cortex-debug"
]
}
}

146
Eide/SysCall.c Normal file
View File

@ -0,0 +1,146 @@
/**
******************************************************************************
* @file syscalls.c
* @author Suroy Wrote with Auto-generated by STM32CubeIDE
* @url https://suroy.cn
* @brief STM32CubeIDE Minimal System calls file
*
* For more information about which c-functions
* need which of these lowlevel functions
* please consult the Newlib libc-manual
******************************************************************************
* @attention
*
* Copyright (c) 2020-2022 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* Includes */
#include <sys/stat.h>
#include <errno.h>
#include <signal.h>
#include <time.h>
#include <sys/time.h>
#include <sys/times.h>
#include "Bsp.h"
/* Variables */
extern int __io_putchar(int ch) __attribute__((weak));
extern int __io_getchar(void) __attribute__((weak));
/* Functions */
__attribute__((weak)) int _read(int file, char *ptr, int len)
{
(void)file;
int DataIdx;
for (DataIdx = 0; DataIdx < len; DataIdx++)
{
*ptr++ = __io_getchar();
}
return len;
}
__attribute__((weak)) int _write(int file, char *ptr, int len)
{
(void)file;
int DataIdx;
for (DataIdx = 0; DataIdx < len; DataIdx++)
{
__io_putchar(*ptr++);
}
return len;
}
// 条件编译
#ifdef __GNUC__
#define PUTCHAR_PROTOTYPE int __io_putchar(int ch)
#define GETCHAR_PROTOTYPE int __io_getchar(void)
#else
#define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f)
#define GETCHAR_PROTOTYPE int fgetc(FILE *f)
#endif /* __GNUC__ */
/**
* : c库函数 printf到 DEBUG_USARTx
* :
* :
*
*/
PUTCHAR_PROTOTYPE
{
UsartSendChar(TTY_COM, ch); //阻塞式无限等待
return ch;
}
/**
* : c库函数 getchar,scanf到 DEBUG_USARTx
* :
* :
*
*/
GETCHAR_PROTOTYPE
{
uint8_t ch = 0;
ch = UsartReceiveChar(TTY_COM);
return ch;
}
/* 非GCC模式才允许编译使用即 Keil、IAR 等 */
#ifndef __GNUC__
/**
* @brief C printf huart1
* KeilIAR IDE GCC
* @author Suroy
* @param ch
* @param f
* @return int
*
* @usage printf("USART1_Target:\r\n");
*/
int fputc(int ch, FILE *f)
{
//采用轮询方式发送1字节数据超时时间为无限等待
HAL_UART_Transmit(&huart1,(uint8_t *)&ch,1,HAL_MAX_DELAY); //huart1是串口的句柄
return ch;
}
/**
* @brief fgets
* C scanf huart1
*
* @param f
* @return int
*
* @usage scanf("%c", &RecData);
*/
int fgetc(FILE *f)
{
uint8_t ch;
HAL_UART_Receive(&huart1, (uint8_t *)&ch, 1, HAL_MAX_DELAY); //huart1是串口的句柄
return ch;
}
#endif /* __GNUC__ */

3180
MdkV5/Application.uvprojx Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,36 @@
// File: STM32F101_102_103_105_107.dbgconf
// Version: 1.0.0
// Note: refer to STM32F101xx STM32F102xx STM32F103xx STM32F105xx STM32F107xx Reference manual (RM0008)
// STM32F101xx STM32F102xx STM32F103xx STM32F105xx STM32F107xx datasheets
// <<< Use Configuration Wizard in Context Menu >>>
// <h> Debug MCU configuration register (DBGMCU_CR)
// <i> Reserved bits must be kept at reset value
// <o.30> DBG_TIM11_STOP <i> TIM11 counter stopped when core is halted
// <o.29> DBG_TIM10_STOP <i> TIM10 counter stopped when core is halted
// <o.28> DBG_TIM9_STOP <i> TIM9 counter stopped when core is halted
// <o.27> DBG_TIM14_STOP <i> TIM14 counter stopped when core is halted
// <o.26> DBG_TIM13_STOP <i> TIM13 counter stopped when core is halted
// <o.25> DBG_TIM12_STOP <i> TIM12 counter stopped when core is halted
// <o.21> DBG_CAN2_STOP <i> Debug CAN2 stopped when core is halted
// <o.20> DBG_TIM7_STOP <i> TIM7 counter stopped when core is halted
// <o.19> DBG_TIM6_STOP <i> TIM6 counter stopped when core is halted
// <o.18> DBG_TIM5_STOP <i> TIM5 counter stopped when core is halted
// <o.17> DBG_TIM8_STOP <i> TIM8 counter stopped when core is halted
// <o.16> DBG_I2C2_SMBUS_TIMEOUT <i> SMBUS timeout mode stopped when core is halted
// <o.15> DBG_I2C1_SMBUS_TIMEOUT <i> SMBUS timeout mode stopped when core is halted
// <o.14> DBG_CAN1_STOP <i> Debug CAN1 stopped when Core is halted
// <o.13> DBG_TIM4_STOP <i> TIM4 counter stopped when core is halted
// <o.12> DBG_TIM3_STOP <i> TIM3 counter stopped when core is halted
// <o.11> DBG_TIM2_STOP <i> TIM2 counter stopped when core is halted
// <o.10> DBG_TIM1_STOP <i> TIM1 counter stopped when core is halted
// <o.9> DBG_WWDG_STOP <i> Debug window watchdog stopped when core is halted
// <o.8> DBG_IWDG_STOP <i> Debug independent watchdog stopped when core is halted
// <o.2> DBG_STANDBY <i> Debug standby mode
// <o.1> DBG_STOP <i> Debug stop mode
// <o.0> DBG_SLEEP <i> Debug sleep mode
// </h>
DbgMCU_CR = 0x00000007;
// <<< end of configuration section >>>

View File

@ -0,0 +1,36 @@
// File: STM32F101_102_103_105_107.dbgconf
// Version: 1.0.0
// Note: refer to STM32F101xx STM32F102xx STM32F103xx STM32F105xx STM32F107xx Reference manual (RM0008)
// STM32F101xx STM32F102xx STM32F103xx STM32F105xx STM32F107xx datasheets
// <<< Use Configuration Wizard in Context Menu >>>
// <h> Debug MCU configuration register (DBGMCU_CR)
// <i> Reserved bits must be kept at reset value
// <o.30> DBG_TIM11_STOP <i> TIM11 counter stopped when core is halted
// <o.29> DBG_TIM10_STOP <i> TIM10 counter stopped when core is halted
// <o.28> DBG_TIM9_STOP <i> TIM9 counter stopped when core is halted
// <o.27> DBG_TIM14_STOP <i> TIM14 counter stopped when core is halted
// <o.26> DBG_TIM13_STOP <i> TIM13 counter stopped when core is halted
// <o.25> DBG_TIM12_STOP <i> TIM12 counter stopped when core is halted
// <o.21> DBG_CAN2_STOP <i> Debug CAN2 stopped when core is halted
// <o.20> DBG_TIM7_STOP <i> TIM7 counter stopped when core is halted
// <o.19> DBG_TIM6_STOP <i> TIM6 counter stopped when core is halted
// <o.18> DBG_TIM5_STOP <i> TIM5 counter stopped when core is halted
// <o.17> DBG_TIM8_STOP <i> TIM8 counter stopped when core is halted
// <o.16> DBG_I2C2_SMBUS_TIMEOUT <i> SMBUS timeout mode stopped when core is halted
// <o.15> DBG_I2C1_SMBUS_TIMEOUT <i> SMBUS timeout mode stopped when core is halted
// <o.14> DBG_CAN1_STOP <i> Debug CAN1 stopped when Core is halted
// <o.13> DBG_TIM4_STOP <i> TIM4 counter stopped when core is halted
// <o.12> DBG_TIM3_STOP <i> TIM3 counter stopped when core is halted
// <o.11> DBG_TIM2_STOP <i> TIM2 counter stopped when core is halted
// <o.10> DBG_TIM1_STOP <i> TIM1 counter stopped when core is halted
// <o.9> DBG_WWDG_STOP <i> Debug window watchdog stopped when core is halted
// <o.8> DBG_IWDG_STOP <i> Debug independent watchdog stopped when core is halted
// <o.2> DBG_STANDBY <i> Debug standby mode
// <o.1> DBG_STOP <i> Debug stop mode
// <o.0> DBG_SLEEP <i> Debug sleep mode
// </h>
DbgMCU_CR = 0x00000007;
// <<< end of configuration section >>>

160
Ses/Application.emProject Normal file
View File

@ -0,0 +1,160 @@
<!DOCTYPE CrossStudio_Project_File>
<solution Name="Solution 'Application'" target="8" version="2">
<configuration
LIBRARY_IO_TYPE="None"
Name="Debug"
arm_assembler_variant="gcc"
arm_compiler_variant="gcc"
arm_linker_variant="GNU"
arm_stm32cubeprogrammer_directory="C:/Program Files/STMicroelectronics/STM32Cube/STM32CubeProgrammer"
arm_target_connect_with_reset_stlink="Yes"
c_preprocessor_definitions="DEBUG;USE_STDPERIPH_DRIVER;STM32F10X_HD"
c_preprocessor_definitions_c_only=""
c_user_include_directories="$(ProjectDir)/../../../StdLib/Inc;$(ProjectDir)/../../../ThirdLib/LetterShell/Inc;$(ProjectDir)/../../../System;$(ProjectDir)/../../../System/CMSIS;$(ProjectDir)/../../../Bsp/Inc;$(ProjectDir)/../App/Inc;$(ProjectDir)/"
compile_post_build_command=""
compile_pre_build_command=""
debug_target_connection="ST-Link"
gcc_c_language_standard="gnu99"
gcc_debugging_level="Level 3"
gcc_entry_point="Reset_Handler"
gcc_has_Oz_optimization_level="Yes"
gcc_omit_frame_pointer="Yes"
gcc_optimization_level="Level 0"
gdb_server_allow_memory_access_during_execution="Yes"
gdb_server_autostart_server="No"
gdb_server_command_line=""
gdb_server_ignore_checksum_errors="Yes"
gdb_server_port="61234"
gdb_server_register_access="General and Individual"
gdb_server_reset_command="reset"
gdb_server_type="ST-LINK"
link_include_standard_libraries="Yes"
link_linker_script_file="../../../../System/LinkScripts/TrueStudio/stm32f10x_flash_extsram.ld"
linker_patch_build_command=""
linker_post_build_command=""
linker_pre_build_command=""
linker_printf_fmt_level="long long"
linker_printf_fp_enabled="Double"
linker_printf_wchar_enabled="Yes"
linker_printf_width_precision_supported="Yes"
linker_scanf_character_group_matching_enabled="Yes"
linker_scanf_fmt_level="long long"
linker_scanf_fp_enabled="Yes"
post_build_command=""
target_script_file="$(ProjectDir)/STM32F1xx_Target.js" />
<configuration
Name="Release"
c_preprocessor_definitions="NDEBUG"
gcc_debugging_level="Level 2"
gcc_omit_frame_pointer="Yes"
gcc_optimization_level="Level 2 balanced" />
<project Name="Application">
<configuration
LIBRARY_IO_TYPE="RTT"
Name="Common"
Target="STM32F103ZE"
arm_architecture="v7M"
arm_compiler_variant="gcc"
arm_core_type="Cortex-M3"
arm_endian="Little"
arm_fp_abi="Soft"
arm_fpu_type="None"
arm_linker_heap_size="1024"
arm_linker_process_stack_size="0"
arm_linker_stack_size="2048"
arm_linker_variant="SEGGER"
arm_simulator_memory_simulation_parameter="ROM;0x08000000;0x00080000;RAM;0x20000000;0x00010000"
arm_target_device_name="STM32F103ZE"
arm_target_interface_type="SWD"
c_preprocessor_definitions="ARM_MATH_CM3;STM32F10X_HD;__STM32F103_SUBFAMILY;__STM32F1XX_FAMILY;__NO_FPU_ENABLE"
c_user_include_directories="$(ProjectDir)/STM32F1xx/Device/Include"
debug_register_definition_file="$(ProjectDir)/STM32F103xx_Registers.xml"
debug_stack_pointer_start="__stack_end__"
debug_start_from_entry_point_symbol="Yes"
debug_target_connection="J-Link"
file_codec="UTF-8"
gcc_entry_point="Reset_Handler"
link_linker_script_file="$(ProjectDir)/STM32F1xx_Flash.icf"
linker_memory_map_file="$(ProjectDir)/STM32F103ZE_MemoryMap.xml"
macros="DeviceHeaderFile=$(PackagesDir)/STM32F1xx/Device/Include/stm32f10x.h;DeviceSystemFile=$(PackagesDir)/STM32F1xx/Device/Source/system_stm32f10x.c;DeviceVectorsFile=$(PackagesDir)/STM32F1xx/Source/stm32f10x_hd_Vectors.s;DeviceFamily=STM32F1xx;DeviceSubFamily=STM32F103;Target=STM32F103ZE"
project_directory=""
project_type="Executable"
target_reset_script="Reset();" />
<configuration
LIBRARY_IO_TYPE="None"
Name="Debug"
arm_compiler_variant="gcc"
arm_library_optimization="Balanced"
arm_linker_variant="GNU"
c_additional_options=""
c_only_additional_options=""
debug_stack_pointer_start="_estack"
debug_target_connection="ST-Link"
gcc_c_language_standard="gnu11"
gcc_entry_point="Reset_Handler"
link_include_standard_libraries="Yes"
link_linker_script_file="../../../System/LinkScripts/TrueStudio/stm32_flash_ze.ld"
link_use_linker_script_file="Yes"
linker_additional_options=""
linker_printf_fmt_level="long long"
linker_printf_fp_enabled="Double"
post_build_command=""
pre_build_command=""
target_reset_script="Reset()"
target_script_file="$(ProjectDir)/STM32F1xx_Target.js" />
<folder Name="App">
<file file_name="../App/Src/LetterShell.c">
<configuration Name="Debug" build_exclude_from_build="No" />
</file>
<file file_name="../App/Src/Main.c" />
</folder>
<folder Name="Bsp">
<configuration Name="Debug" build_exclude_from_build="No" />
<file file_name="../../../Bsp/Src/Bsp.c" />
<file file_name="../../../Bsp/Src/Delay.c" />
<file file_name="../../../Bsp/Src/Gpio.c" />
<file file_name="../../../Bsp/Src/Interrupt.c" />
<file file_name="../../../Bsp/Src/Usart.c" />
</folder>
<folder Name="LetterShell">
<configuration Name="Debug" build_exclude_from_build="No" />
<file file_name="../../../ThirdLib/LetterShell/Src/shell.c" />
<file file_name="../../../ThirdLib/LetterShell/Src/shell_cmd_list.c" />
<file file_name="../../../ThirdLib/LetterShell/Src/shell_companion.c" />
<file file_name="../../../ThirdLib/LetterShell/Src/shell_ext.c" />
</folder>
<folder Name="StdLib">
<configuration Name="Debug" build_exclude_from_build="No" />
<file file_name="../../../StdLib/Src/misc.c" />
<file file_name="../../../StdLib/Src/stm32f10x_adc.c" />
<file file_name="../../../StdLib/Src/stm32f10x_bkp.c" />
<file file_name="../../../StdLib/Src/stm32f10x_can.c" />
<file file_name="../../../StdLib/Src/stm32f10x_cec.c" />
<file file_name="../../../StdLib/Src/stm32f10x_crc.c" />
<file file_name="../../../StdLib/Src/stm32f10x_dac.c" />
<file file_name="../../../StdLib/Src/stm32f10x_dbgmcu.c" />
<file file_name="../../../StdLib/Src/stm32f10x_dma.c" />
<file file_name="../../../StdLib/Src/stm32f10x_exti.c" />
<file file_name="../../../StdLib/Src/stm32f10x_flash.c" />
<file file_name="../../../StdLib/Src/stm32f10x_fsmc.c" />
<file file_name="../../../StdLib/Src/stm32f10x_gpio.c" />
<file file_name="../../../StdLib/Src/stm32f10x_i2c.c" />
<file file_name="../../../StdLib/Src/stm32f10x_iwdg.c" />
<file file_name="../../../StdLib/Src/stm32f10x_pwr.c" />
<file file_name="../../../StdLib/Src/stm32f10x_rcc.c" />
<file file_name="../../../StdLib/Src/stm32f10x_rtc.c" />
<file file_name="../../../StdLib/Src/stm32f10x_sdio.c" />
<file file_name="../../../StdLib/Src/stm32f10x_spi.c" />
<file file_name="../../../StdLib/Src/stm32f10x_tim.c" />
<file file_name="../../../StdLib/Src/stm32f10x_usart.c" />
<file file_name="../../../StdLib/Src/stm32f10x_wwdg.c" />
</folder>
<folder Name="SystemFiles">
<file file_name="../../../System/CMSIS/core_cm3.c" />
<file file_name="../../../System/Startup/TrueStudio/startup_stm32f10x_hd.s" />
<file file_name="../../../System/LinkScripts/TrueStudio/stm32_flash_ze.ld" />
<file file_name="../../../System/stm32f10x_it.c" />
<file file_name="../../../System/system_stm32f10x.c" />
</folder>
</project>
</solution>

101
Ses/Application.emSession Normal file
View File

@ -0,0 +1,101 @@
<!DOCTYPE CrossStudio_Session_File>
<session>
<Bookmarks/>
<Breakpoints groups="Breakpoints" active_group="Breakpoints">
<Exceptions set="MemManage;UsageFault_Coprocessor;UsageFault_CheckingError;UsageFault_StateError;BusFault;ExceptionEntryReturnFault;HardFault"/>
</Breakpoints>
<ExecutionProfileWindow/>
<FrameBuffer>
<FrameBufferWindow width="0" keepAspectRatio="0" zoomToFitWindow="0" showGrid="0" addressSpace="" format="0" height="0" autoEvaluate="0" scaleFactor="1" refreshPeriod="0" name="Stm32F1xxProject_Debug" addressText="" accessByDisplayWidth="0"/>
<FrameBufferWindow width="0" keepAspectRatio="0" zoomToFitWindow="0" showGrid="0" addressSpace="" format="0" height="0" autoEvaluate="0" scaleFactor="1" refreshPeriod="0" name="Stm32F1xxTempProject_Debug" addressText="" accessByDisplayWidth="0"/>
<FrameBufferWindow width="0" keepAspectRatio="0" zoomToFitWindow="0" showGrid="0" addressSpace="" format="0" height="0" autoEvaluate="0" scaleFactor="1" refreshPeriod="0" name="Stm32F10xTempProject_Debug" addressText="" accessByDisplayWidth="0"/>
<FrameBufferWindow width="0" keepAspectRatio="0" zoomToFitWindow="0" showGrid="0" addressSpace="" format="0" height="0" autoEvaluate="0" scaleFactor="1" refreshPeriod="0" name="Application_Debug" addressText="" accessByDisplayWidth="0"/>
</FrameBuffer>
<Memory1>
<MemoryWindow addressSpace="" dataSize="1" autoEvaluate="0" viewMode="0" viewType="4" addressOrder="0" columnsText="" refreshPeriod="0" name="Stm32F1xxProject_Debug" sizeText="sizeof({)" addressText="&amp;{"/>
<MemoryWindow addressSpace="" dataSize="1" autoEvaluate="0" viewMode="0" viewType="4" addressOrder="0" columnsText="" refreshPeriod="0" name="Stm32F1xxTempProject_Debug" sizeText="sizeof({)" addressText="&amp;{"/>
<MemoryWindow addressSpace="" dataSize="1" autoEvaluate="0" viewMode="0" viewType="4" addressOrder="0" columnsText="" refreshPeriod="0" name="Stm32F10xTempProject_Debug" sizeText="sizeof({)" addressText="&amp;{"/>
<MemoryWindow addressSpace="" dataSize="1" autoEvaluate="0" viewMode="0" viewType="4" addressOrder="0" columnsText="" refreshPeriod="0" name="Application_Debug" sizeText="sizeof({)" addressText="&amp;{"/>
</Memory1>
<Memory2>
<MemoryWindow addressSpace="" dataSize="1" autoEvaluate="0" viewMode="0" viewType="4" addressOrder="0" columnsText="" refreshPeriod="0" name="Stm32F1xxProject_Debug" sizeText="" addressText=""/>
<MemoryWindow addressSpace="" dataSize="1" autoEvaluate="0" viewMode="0" viewType="4" addressOrder="0" columnsText="" refreshPeriod="0" name="Stm32F1xxTempProject_Debug" sizeText="" addressText=""/>
<MemoryWindow addressSpace="" dataSize="1" autoEvaluate="0" viewMode="0" viewType="4" addressOrder="0" columnsText="" refreshPeriod="0" name="Stm32F10xTempProject_Debug" sizeText="" addressText=""/>
<MemoryWindow addressSpace="" dataSize="1" autoEvaluate="0" viewMode="0" viewType="4" addressOrder="0" columnsText="" refreshPeriod="0" name="Application_Debug" sizeText="" addressText=""/>
</Memory2>
<Memory3>
<MemoryWindow addressSpace="" dataSize="1" autoEvaluate="0" viewMode="0" viewType="4" addressOrder="0" columnsText="" refreshPeriod="0" name="Stm32F1xxProject_Debug" sizeText="" addressText=""/>
<MemoryWindow addressSpace="" dataSize="1" autoEvaluate="0" viewMode="0" viewType="4" addressOrder="0" columnsText="" refreshPeriod="0" name="Stm32F1xxTempProject_Debug" sizeText="" addressText=""/>
<MemoryWindow addressSpace="" dataSize="1" autoEvaluate="0" viewMode="0" viewType="4" addressOrder="0" columnsText="" refreshPeriod="0" name="Stm32F10xTempProject_Debug" sizeText="" addressText=""/>
<MemoryWindow addressSpace="" dataSize="1" autoEvaluate="0" viewMode="0" viewType="4" addressOrder="0" columnsText="" refreshPeriod="0" name="Application_Debug" sizeText="" addressText=""/>
</Memory3>
<Memory4>
<MemoryWindow addressSpace="" dataSize="1" autoEvaluate="0" viewMode="0" viewType="4" addressOrder="0" columnsText="" refreshPeriod="0" name="Stm32F1xxProject_Debug" sizeText="" addressText=""/>
<MemoryWindow addressSpace="" dataSize="1" autoEvaluate="0" viewMode="0" viewType="4" addressOrder="0" columnsText="" refreshPeriod="0" name="Stm32F1xxTempProject_Debug" sizeText="" addressText=""/>
<MemoryWindow addressSpace="" dataSize="1" autoEvaluate="0" viewMode="0" viewType="4" addressOrder="0" columnsText="" refreshPeriod="0" name="Stm32F10xTempProject_Debug" sizeText="" addressText=""/>
<MemoryWindow addressSpace="" dataSize="1" autoEvaluate="0" viewMode="0" viewType="4" addressOrder="0" columnsText="" refreshPeriod="0" name="Application_Debug" sizeText="" addressText=""/>
</Memory4>
<Project>
<ProjectSessionItem path="Solution 'Application'"/>
<ProjectSessionItem path="Solution 'Application';Application"/>
<ProjectSessionItem path="Solution 'Application';Application;App"/>
<ProjectSessionItem path="Solution 'Application';Application;Bsp"/>
<ProjectSessionItem path="Solution 'Application';Application;LetterShell"/>
<ProjectSessionItem path="Solution 'Application';Application;StdLib"/>
<ProjectSessionItem path="Solution 'Application';Application;SystemFiles"/>
</Project>
<Register1>
<RegisterWindow invisibleNodes="" visibleNodes="USART1/SR;USART1/DR;USART1/BRR;USART1/CR1;USART1/CR2;USART1/CR3;USART1/GTPR;CPU/r0;CPU/r1;CPU/r2;CPU/r3;CPU/r4;CPU/r5;CPU/r6;CPU/r7;CPU/r8;CPU/r9;CPU/r10;CPU/r11;CPU/r12;CPU/sp(r13);CPU/lr(r14);CPU/pc(r15);CPU/xpsr;CPU/MSP;CPU/PSP;CPU/PRIMASK;CPU/BASEPRI;CPU/FAULTMASK;CPU/CONTROL;CPU/internal;CPU - Current Context/r0;CPU - Current Context/r1;CPU - Current Context/r2;CPU - Current Context/r3;CPU - Current Context/r4;CPU - Current Context/r5;CPU - Current Context/r6;CPU - Current Context/r7;CPU - Current Context/r8;CPU - Current Context/r9;CPU - Current Context/r10;CPU - Current Context/r11;CPU - Current Context/r12;CPU - Current Context/sp(r13);CPU - Current Context/lr(r14);CPU - Current Context/pc(r15);CPU - Current Context/apsr" binaryNodes="" asciiNodes="" openNodes="USART1;CPU;CPU - Current Context" name="Stm32F1xxProject_Debug" decimalNodes="" octalNodes="" unsignedNodes=""/>
<RegisterWindow invisibleNodes="" visibleNodes="CPU - Current Context/r0;CPU - Current Context/r1;CPU - Current Context/r2;CPU - Current Context/r3;CPU - Current Context/r4;CPU - Current Context/r5;CPU - Current Context/r6;CPU - Current Context/r7;CPU - Current Context/r8;CPU - Current Context/r9;CPU - Current Context/r10;CPU - Current Context/r11;CPU - Current Context/r12;CPU - Current Context/sp(r13);CPU - Current Context/lr(r14);CPU - Current Context/pc(r15);CPU - Current Context/apsr;CPU/r0;CPU/r1;CPU/r2;CPU/r3;CPU/r4;CPU/r5;CPU/r6;CPU/r7;CPU/r8;CPU/r9;CPU/r10;CPU/r11;CPU/r12;CPU/sp(r13);CPU/lr(r14);CPU/pc(r15);CPU/xpsr;CPU/MSP;CPU/PSP;CPU/PRIMASK;CPU/BASEPRI;CPU/FAULTMASK;CPU/CONTROL;CPU/internal" binaryNodes="" asciiNodes="" openNodes="CPU - Current Context" name="Stm32F1xxTempProject_Debug" decimalNodes="" octalNodes="" unsignedNodes=""/>
<RegisterWindow invisibleNodes="" visibleNodes="CPU - Current Context/r0;CPU - Current Context/r1;CPU - Current Context/r2;CPU - Current Context/r3;CPU - Current Context/r4;CPU - Current Context/r5;CPU - Current Context/r6;CPU - Current Context/r7;CPU - Current Context/r8;CPU - Current Context/r9;CPU - Current Context/r10;CPU - Current Context/r11;CPU - Current Context/r12;CPU - Current Context/sp(r13);CPU - Current Context/lr(r14);CPU - Current Context/pc(r15);CPU - Current Context/apsr;CPU/r0;CPU/r1;CPU/r2;CPU/r3;CPU/r4;CPU/r5;CPU/r6;CPU/r7;CPU/r8;CPU/r9;CPU/r10;CPU/r11;CPU/r12;CPU/sp(r13);CPU/lr(r14);CPU/pc(r15);CPU/xpsr;CPU/MSP;CPU/PSP;CPU/PRIMASK;CPU/BASEPRI;CPU/FAULTMASK;CPU/CONTROL;CPU/internal" binaryNodes="" asciiNodes="" openNodes="CPU - Current Context;CPU;CPU/CONTROL;CPU/internal" name="Stm32F10xTempProject_Debug" decimalNodes="" octalNodes="" unsignedNodes=""/>
<RegisterWindow invisibleNodes="" visibleNodes="CPU - Current Context/r0;CPU - Current Context/r1;CPU - Current Context/r2;CPU - Current Context/r3;CPU - Current Context/r4;CPU - Current Context/r5;CPU - Current Context/r6;CPU - Current Context/r7;CPU - Current Context/r8;CPU - Current Context/r9;CPU - Current Context/r10;CPU - Current Context/r11;CPU - Current Context/r12;CPU - Current Context/sp(r13);CPU - Current Context/lr(r14);CPU - Current Context/pc(r15);CPU - Current Context/apsr;CPU/r0;CPU/r1;CPU/r2;CPU/r3;CPU/r4;CPU/r5;CPU/r6;CPU/r7;CPU/r8;CPU/r9;CPU/r10;CPU/r11;CPU/r12;CPU/sp(r13);CPU/lr(r14);CPU/pc(r15);CPU/xpsr;CPU/MSP;CPU/PSP;CPU/PRIMASK;CPU/BASEPRI;CPU/FAULTMASK;CPU/CONTROL;CPU/internal" binaryNodes="" asciiNodes="" openNodes="CPU - Current Context" name="Application_Debug" decimalNodes="" octalNodes="" unsignedNodes=""/>
</Register1>
<Register2>
<RegisterWindow invisibleNodes="" visibleNodes="CPU - Current Context/r0;CPU - Current Context/r1;CPU - Current Context/r2;CPU - Current Context/r3;CPU - Current Context/r4;CPU - Current Context/r5;CPU - Current Context/r6;CPU - Current Context/r7;CPU - Current Context/r8;CPU - Current Context/r9;CPU - Current Context/r10;CPU - Current Context/r11;CPU - Current Context/r12;CPU - Current Context/sp(r13);CPU - Current Context/lr(r14);CPU - Current Context/pc(r15);CPU - Current Context/apsr;CPU/r0;CPU/r1;CPU/r2;CPU/r3;CPU/r4;CPU/r5;CPU/r6;CPU/r7;CPU/r8;CPU/r9;CPU/r10;CPU/r11;CPU/r12;CPU/sp(r13);CPU/lr(r14);CPU/pc(r15);CPU/xpsr;CPU/MSP;CPU/PSP;CPU/PRIMASK;CPU/BASEPRI;CPU/FAULTMASK;CPU/CONTROL;CPU/internal" binaryNodes="" asciiNodes="" openNodes="CPU - Current Context" name="Stm32F1xxProject_Debug" decimalNodes="" octalNodes="" unsignedNodes=""/>
<RegisterWindow invisibleNodes="" visibleNodes="CPU - Current Context/r0;CPU - Current Context/r1;CPU - Current Context/r2;CPU - Current Context/r3;CPU - Current Context/r4;CPU - Current Context/r5;CPU - Current Context/r6;CPU - Current Context/r7;CPU - Current Context/r8;CPU - Current Context/r9;CPU - Current Context/r10;CPU - Current Context/r11;CPU - Current Context/r12;CPU - Current Context/sp(r13);CPU - Current Context/lr(r14);CPU - Current Context/pc(r15);CPU - Current Context/apsr;CPU/r0;CPU/r1;CPU/r2;CPU/r3;CPU/r4;CPU/r5;CPU/r6;CPU/r7;CPU/r8;CPU/r9;CPU/r10;CPU/r11;CPU/r12;CPU/sp(r13);CPU/lr(r14);CPU/pc(r15);CPU/xpsr;CPU/MSP;CPU/PSP;CPU/PRIMASK;CPU/BASEPRI;CPU/FAULTMASK;CPU/CONTROL;CPU/internal" binaryNodes="" asciiNodes="" openNodes="CPU - Current Context" name="Stm32F1xxTempProject_Debug" decimalNodes="" octalNodes="" unsignedNodes=""/>
<RegisterWindow invisibleNodes="" visibleNodes="CPU - Current Context/r0;CPU - Current Context/r1;CPU - Current Context/r2;CPU - Current Context/r3;CPU - Current Context/r4;CPU - Current Context/r5;CPU - Current Context/r6;CPU - Current Context/r7;CPU - Current Context/r8;CPU - Current Context/r9;CPU - Current Context/r10;CPU - Current Context/r11;CPU - Current Context/r12;CPU - Current Context/sp(r13);CPU - Current Context/lr(r14);CPU - Current Context/pc(r15);CPU - Current Context/apsr;CPU/r0;CPU/r1;CPU/r2;CPU/r3;CPU/r4;CPU/r5;CPU/r6;CPU/r7;CPU/r8;CPU/r9;CPU/r10;CPU/r11;CPU/r12;CPU/sp(r13);CPU/lr(r14);CPU/pc(r15);CPU/xpsr;CPU/MSP;CPU/PSP;CPU/PRIMASK;CPU/BASEPRI;CPU/FAULTMASK;CPU/CONTROL;CPU/internal" binaryNodes="" asciiNodes="" openNodes="CPU - Current Context" name="Stm32F10xTempProject_Debug" decimalNodes="" octalNodes="" unsignedNodes=""/>
<RegisterWindow invisibleNodes="" visibleNodes="CPU - Current Context/r0;CPU - Current Context/r1;CPU - Current Context/r2;CPU - Current Context/r3;CPU - Current Context/r4;CPU - Current Context/r5;CPU - Current Context/r6;CPU - Current Context/r7;CPU - Current Context/r8;CPU - Current Context/r9;CPU - Current Context/r10;CPU - Current Context/r11;CPU - Current Context/r12;CPU - Current Context/sp(r13);CPU - Current Context/lr(r14);CPU - Current Context/pc(r15);CPU - Current Context/apsr;CPU/r0;CPU/r1;CPU/r2;CPU/r3;CPU/r4;CPU/r5;CPU/r6;CPU/r7;CPU/r8;CPU/r9;CPU/r10;CPU/r11;CPU/r12;CPU/sp(r13);CPU/lr(r14);CPU/pc(r15);CPU/xpsr;CPU/MSP;CPU/PSP;CPU/PRIMASK;CPU/BASEPRI;CPU/FAULTMASK;CPU/CONTROL;CPU/internal" binaryNodes="" asciiNodes="" openNodes="CPU - Current Context" name="Application_Debug" decimalNodes="" octalNodes="" unsignedNodes=""/>
</Register2>
<Register3>
<RegisterWindow invisibleNodes="" visibleNodes="CPU - Current Context/r0;CPU - Current Context/r1;CPU - Current Context/r2;CPU - Current Context/r3;CPU - Current Context/r4;CPU - Current Context/r5;CPU - Current Context/r6;CPU - Current Context/r7;CPU - Current Context/r8;CPU - Current Context/r9;CPU - Current Context/r10;CPU - Current Context/r11;CPU - Current Context/r12;CPU - Current Context/sp(r13);CPU - Current Context/lr(r14);CPU - Current Context/pc(r15);CPU - Current Context/apsr;CPU/r0;CPU/r1;CPU/r2;CPU/r3;CPU/r4;CPU/r5;CPU/r6;CPU/r7;CPU/r8;CPU/r9;CPU/r10;CPU/r11;CPU/r12;CPU/sp(r13);CPU/lr(r14);CPU/pc(r15);CPU/xpsr;CPU/MSP;CPU/PSP;CPU/PRIMASK;CPU/BASEPRI;CPU/FAULTMASK;CPU/CONTROL;CPU/internal" binaryNodes="" asciiNodes="" openNodes="CPU - Current Context" name="Stm32F1xxProject_Debug" decimalNodes="" octalNodes="" unsignedNodes=""/>
<RegisterWindow invisibleNodes="" visibleNodes="CPU - Current Context/r0;CPU - Current Context/r1;CPU - Current Context/r2;CPU - Current Context/r3;CPU - Current Context/r4;CPU - Current Context/r5;CPU - Current Context/r6;CPU - Current Context/r7;CPU - Current Context/r8;CPU - Current Context/r9;CPU - Current Context/r10;CPU - Current Context/r11;CPU - Current Context/r12;CPU - Current Context/sp(r13);CPU - Current Context/lr(r14);CPU - Current Context/pc(r15);CPU - Current Context/apsr;CPU/r0;CPU/r1;CPU/r2;CPU/r3;CPU/r4;CPU/r5;CPU/r6;CPU/r7;CPU/r8;CPU/r9;CPU/r10;CPU/r11;CPU/r12;CPU/sp(r13);CPU/lr(r14);CPU/pc(r15);CPU/xpsr;CPU/MSP;CPU/PSP;CPU/PRIMASK;CPU/BASEPRI;CPU/FAULTMASK;CPU/CONTROL;CPU/internal" binaryNodes="" asciiNodes="" openNodes="CPU - Current Context" name="Stm32F1xxTempProject_Debug" decimalNodes="" octalNodes="" unsignedNodes=""/>
<RegisterWindow invisibleNodes="" visibleNodes="CPU - Current Context/r0;CPU - Current Context/r1;CPU - Current Context/r2;CPU - Current Context/r3;CPU - Current Context/r4;CPU - Current Context/r5;CPU - Current Context/r6;CPU - Current Context/r7;CPU - Current Context/r8;CPU - Current Context/r9;CPU - Current Context/r10;CPU - Current Context/r11;CPU - Current Context/r12;CPU - Current Context/sp(r13);CPU - Current Context/lr(r14);CPU - Current Context/pc(r15);CPU - Current Context/apsr;CPU/r0;CPU/r1;CPU/r2;CPU/r3;CPU/r4;CPU/r5;CPU/r6;CPU/r7;CPU/r8;CPU/r9;CPU/r10;CPU/r11;CPU/r12;CPU/sp(r13);CPU/lr(r14);CPU/pc(r15);CPU/xpsr;CPU/MSP;CPU/PSP;CPU/PRIMASK;CPU/BASEPRI;CPU/FAULTMASK;CPU/CONTROL;CPU/internal" binaryNodes="" asciiNodes="" openNodes="CPU - Current Context" name="Stm32F10xTempProject_Debug" decimalNodes="" octalNodes="" unsignedNodes=""/>
<RegisterWindow invisibleNodes="" visibleNodes="CPU - Current Context/r0;CPU - Current Context/r1;CPU - Current Context/r2;CPU - Current Context/r3;CPU - Current Context/r4;CPU - Current Context/r5;CPU - Current Context/r6;CPU - Current Context/r7;CPU - Current Context/r8;CPU - Current Context/r9;CPU - Current Context/r10;CPU - Current Context/r11;CPU - Current Context/r12;CPU - Current Context/sp(r13);CPU - Current Context/lr(r14);CPU - Current Context/pc(r15);CPU - Current Context/apsr;CPU/r0;CPU/r1;CPU/r2;CPU/r3;CPU/r4;CPU/r5;CPU/r6;CPU/r7;CPU/r8;CPU/r9;CPU/r10;CPU/r11;CPU/r12;CPU/sp(r13);CPU/lr(r14);CPU/pc(r15);CPU/xpsr;CPU/MSP;CPU/PSP;CPU/PRIMASK;CPU/BASEPRI;CPU/FAULTMASK;CPU/CONTROL;CPU/internal" binaryNodes="" asciiNodes="" openNodes="CPU - Current Context" name="Application_Debug" decimalNodes="" octalNodes="" unsignedNodes=""/>
</Register3>
<Register4>
<RegisterWindow invisibleNodes="" visibleNodes="CPU - Current Context/r0;CPU - Current Context/r1;CPU - Current Context/r2;CPU - Current Context/r3;CPU - Current Context/r4;CPU - Current Context/r5;CPU - Current Context/r6;CPU - Current Context/r7;CPU - Current Context/r8;CPU - Current Context/r9;CPU - Current Context/r10;CPU - Current Context/r11;CPU - Current Context/r12;CPU - Current Context/sp(r13);CPU - Current Context/lr(r14);CPU - Current Context/pc(r15);CPU - Current Context/apsr;CPU/r0;CPU/r1;CPU/r2;CPU/r3;CPU/r4;CPU/r5;CPU/r6;CPU/r7;CPU/r8;CPU/r9;CPU/r10;CPU/r11;CPU/r12;CPU/sp(r13);CPU/lr(r14);CPU/pc(r15);CPU/xpsr;CPU/MSP;CPU/PSP;CPU/PRIMASK;CPU/BASEPRI;CPU/FAULTMASK;CPU/CONTROL;CPU/internal" binaryNodes="" asciiNodes="" openNodes="CPU - Current Context" name="Stm32F1xxProject_Debug" decimalNodes="" octalNodes="" unsignedNodes=""/>
<RegisterWindow invisibleNodes="" visibleNodes="CPU - Current Context/r0;CPU - Current Context/r1;CPU - Current Context/r2;CPU - Current Context/r3;CPU - Current Context/r4;CPU - Current Context/r5;CPU - Current Context/r6;CPU - Current Context/r7;CPU - Current Context/r8;CPU - Current Context/r9;CPU - Current Context/r10;CPU - Current Context/r11;CPU - Current Context/r12;CPU - Current Context/sp(r13);CPU - Current Context/lr(r14);CPU - Current Context/pc(r15);CPU - Current Context/apsr;CPU/r0;CPU/r1;CPU/r2;CPU/r3;CPU/r4;CPU/r5;CPU/r6;CPU/r7;CPU/r8;CPU/r9;CPU/r10;CPU/r11;CPU/r12;CPU/sp(r13);CPU/lr(r14);CPU/pc(r15);CPU/xpsr;CPU/MSP;CPU/PSP;CPU/PRIMASK;CPU/BASEPRI;CPU/FAULTMASK;CPU/CONTROL;CPU/internal" binaryNodes="" asciiNodes="" openNodes="CPU - Current Context" name="Stm32F1xxTempProject_Debug" decimalNodes="" octalNodes="" unsignedNodes=""/>
<RegisterWindow invisibleNodes="" visibleNodes="CPU - Current Context/r0;CPU - Current Context/r1;CPU - Current Context/r2;CPU - Current Context/r3;CPU - Current Context/r4;CPU - Current Context/r5;CPU - Current Context/r6;CPU - Current Context/r7;CPU - Current Context/r8;CPU - Current Context/r9;CPU - Current Context/r10;CPU - Current Context/r11;CPU - Current Context/r12;CPU - Current Context/sp(r13);CPU - Current Context/lr(r14);CPU - Current Context/pc(r15);CPU - Current Context/apsr;CPU/r0;CPU/r1;CPU/r2;CPU/r3;CPU/r4;CPU/r5;CPU/r6;CPU/r7;CPU/r8;CPU/r9;CPU/r10;CPU/r11;CPU/r12;CPU/sp(r13);CPU/lr(r14);CPU/pc(r15);CPU/xpsr;CPU/MSP;CPU/PSP;CPU/PRIMASK;CPU/BASEPRI;CPU/FAULTMASK;CPU/CONTROL;CPU/internal" binaryNodes="" asciiNodes="" openNodes="CPU - Current Context" name="Stm32F10xTempProject_Debug" decimalNodes="" octalNodes="" unsignedNodes=""/>
<RegisterWindow invisibleNodes="" visibleNodes="CPU - Current Context/r0;CPU - Current Context/r1;CPU - Current Context/r2;CPU - Current Context/r3;CPU - Current Context/r4;CPU - Current Context/r5;CPU - Current Context/r6;CPU - Current Context/r7;CPU - Current Context/r8;CPU - Current Context/r9;CPU - Current Context/r10;CPU - Current Context/r11;CPU - Current Context/r12;CPU - Current Context/sp(r13);CPU - Current Context/lr(r14);CPU - Current Context/pc(r15);CPU - Current Context/apsr;CPU/r0;CPU/r1;CPU/r2;CPU/r3;CPU/r4;CPU/r5;CPU/r6;CPU/r7;CPU/r8;CPU/r9;CPU/r10;CPU/r11;CPU/r12;CPU/sp(r13);CPU/lr(r14);CPU/pc(r15);CPU/xpsr;CPU/MSP;CPU/PSP;CPU/PRIMASK;CPU/BASEPRI;CPU/FAULTMASK;CPU/CONTROL;CPU/internal" binaryNodes="" asciiNodes="" openNodes="CPU - Current Context" name="Application_Debug" decimalNodes="" octalNodes="" unsignedNodes=""/>
</Register4>
<Threads>
<ThreadsWindow showLists=""/>
</Threads>
<TraceWindow>
<Trace enabled="Yes"/>
</TraceWindow>
<Watch1>
<Watches active="1" update="Twice a Second">
<Watchpoint expression="UsartInitSt" name="UsartInitSt" radix="-1" linenumber="68" filename="Bsp/Src/Usart.c"/>
<Watchpoint expression="SystemIntReg" name="SystemIntReg" radix="-1" linenumber="4" filename="Bsp/Src/Interrupt.c"/>
<Watchpoint expression="string" name="string" radix="-1" linenumber="296" filename="../../../ThirdLib/LetterShell/Src/shell.c"/>
<Watchpoint expression="shellText[SHELL_TEXT_INFO]" name="shellText[SHELL_TEXT_INFO]" radix="-1" linenumber="1268" filename="../../../ThirdLib/LetterShell/Src/shell.c"/>
<Watchpoint expression="Len" name="Len" radix="8" linenumber="18" filename="../App/Src/LetterShell.c"/>
<Watchpoint expression="GpioInitSt" name="GpioInitSt" radix="-1" linenumber="86" filename="Bsp/Src/Gpio.c"/>
<Watchpoint expression="fuck" name="fuck" radix="-1" linenumber="4" filename="App/Src/main.c"/>
</Watches>
</Watch1>
<Watch2>
<Watches active="0" update="Never"/>
</Watch2>
<Watch3>
<Watches active="0" update="Never"/>
</Watch3>
<Watch4>
<Watches active="0" update="Never"/>
</Watch4>
<Files>
<SessionOpenFile windowGroup="DockEditLeft" x="0" y="21" useTextEdit="1" path="../App/Src/main.c" left="0" selected="1" top="0" codecName="UTF-8"/>
</Files>
<EMStudioWindow activeProject="Application" fileDialogDefaultFilter="*.*" autoConnectTarget="ST-Link" buildConfiguration="Debug" sessionSettings="" debugSearchFileMap="" fileDialogInitialDirectory="C:/Users/anonymous/Desktop/Embedded/STM32/Projects/Stm32F10xProject/Projects/Stm32F10xTempProject/Ses" debugSearchPath="" autoConnectCapabilities="3455"/>
</session>

288
Ses/SEGGER_THUMB_Startup.s Normal file
View File

@ -0,0 +1,288 @@
/*********************************************************************
* SEGGER Microcontroller GmbH *
* The Embedded Experts *
**********************************************************************
* *
* (c) 2014 - 2024 SEGGER Microcontroller GmbH *
* *
* www.segger.com Support: support@segger.com *
* *
**********************************************************************
* *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or *
* without modification, are permitted provided that the following *
* condition is met: *
* *
* - Redistributions of source code must retain the above copyright *
* notice, this condition and the following disclaimer. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND *
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, *
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF *
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE *
* DISCLAIMED. IN NO EVENT SHALL SEGGER Microcontroller BE LIABLE FOR *
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR *
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT *
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; *
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE *
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH *
* DAMAGE. *
* *
**********************************************************************
-------------------------- END-OF-HEADER -----------------------------
File : SEGGER_THUMB_Startup.s
Purpose : Generic runtime init startup code for ARM CPUs running
in THUMB mode.
Designed to work with the SEGGER linker to produce
smallest possible executables.
This file does not normally require any customization.
Additional information:
Preprocessor Definitions
FULL_LIBRARY
If defined then
- argc, argv are set up by calling SEGGER_SEMIHOST_GetArgs().
- the exit symbol is defined and executes on return from main.
- the exit symbol calls destructors, atexit functions and then
calls SEGGER_SEMIHOST_Exit().
If not defined then
- argc and argv are not valid (main is assumed to not take parameters)
- the exit symbol is defined, executes on return from main and
halts in a loop.
*/
.syntax unified
/*********************************************************************
*
* Defines, configurable
*
**********************************************************************
*/
#ifndef APP_ENTRY_POINT
#define APP_ENTRY_POINT main
#endif
#ifndef ARGSSPACE
#define ARGSSPACE 128
#endif
/*********************************************************************
*
* Macros
*
**********************************************************************
*/
//
// Declare a label as function symbol (without switching sections)
//
.macro MARK_FUNC Name
.global \Name
.thumb_func
.code 16
\Name:
.endm
//
// Declare a regular function.
// Functions from the startup are placed in the init section.
//
.macro START_FUNC Name
.section .init.\Name, "ax"
.global \Name
.balign 2
.thumb_func
.code 16
\Name:
.endm
//
// Declare a weak function
//
.macro WEAK_FUNC Name
.section .init.\Name, "ax", %progbits
.weak \Name
.balign 2
.thumb_func
.code 16
\Name:
.endm
//
// Mark the end of a function and calculate its size
//
.macro END_FUNC name
.size \name,.-\name
.endm
/*********************************************************************
*
* Externals
*
**********************************************************************
*/
.extern APP_ENTRY_POINT // typically main
/*********************************************************************
*
* Global functions
*
**********************************************************************
*/
/*********************************************************************
*
* _start
*
* Function description
* Entry point for the startup code.
* Usually called by the reset handler.
* Performs all initialisation, based on the entries in the
* linker-generated init table, then calls main().
* It is device independent, so there should not be any need for an
* end-user to modify it.
*
* Additional information
* At this point, the stack pointer should already have been
* initialized
* - by hardware (such as on Cortex-M),
* - by the device-specific reset handler,
* - or by the debugger (such as for RAM Code).
*/
#undef L
#define L(label) .L_start_##label
START_FUNC _start
//
// Call linker init functions which in turn performs the following:
// * Perform segment init
// * Perform heap init (if used)
// * Call constructors of global Objects (if any exist)
//
ldr R4, =__SEGGER_init_table__ // Set table pointer to start of initialization table
L(RunInit):
ldr R0, [R4] // Get next initialization function from table
adds R4, R4, #4 // Increment table pointer to point to function arguments
blx R0 // Call initialization function
b L(RunInit)
//
MARK_FUNC __SEGGER_init_done
MARK_FUNC __startup_complete
//
// Time to call main(), the application entry point.
//
#ifndef FULL_LIBRARY
//
// In a real embedded application ("Free-standing environment"),
// main() does not get any arguments,
// which means it is not necessary to init R0 and R1.
//
bl APP_ENTRY_POINT // Call to application entry point (usually main())
END_FUNC _start
//
// end of _start
// Fall-through to exit if main ever returns.
//
MARK_FUNC exit
//
// In a free-standing environment, if returned from application:
// Loop forever.
//
b .
.size exit,.-exit
#else
//
// In a hosted environment,
// we need to load R0 and R1 with argc and argv, in order to handle
// the command line arguments.
// This is required for some programs running under control of a
// debugger, such as automated tests.
//
movs R0, #ARGSSPACE
ldr R1, =__SEGGER_init_arg_data
bl SEGGER_SEMIHOST_GetArgs
ldr R1, =__SEGGER_init_arg_data
bl APP_ENTRY_POINT // Call to application entry point (usually main())
bl exit // Call exit function
b . // If we unexpectedly return from exit, hang.
END_FUNC _start
#endif
//
#ifdef FULL_LIBRARY
/*********************************************************************
*
* exit
*
* Function description
* Exit of the system.
* Called on return from application entry point or explicit call
* to exit.
*
* Additional information
* In a hosted environment exit gracefully, by
* saving the return value,
* calling destructurs of global objects,
* calling registered atexit functions,
* and notifying the host/debugger.
*/
#undef L
#define L(label) .L_exit_##label
WEAK_FUNC exit
mov R5, R0 // Save the exit parameter/return result
//
// Call destructors
//
ldr R0, =__dtors_start__ // Pointer to destructor list
ldr R1, =__dtors_end__
L(Loop):
cmp R0, R1
beq L(End) // Reached end of destructor list? => Done
ldr R2, [R0] // Load current destructor address into R2
adds R0, R0, #4 // Increment pointer
push {R0-R1} // Save R0 and R1
blx R2 // Call destructor
pop {R0-R1} // Restore R0 and R1
b L(Loop)
L(End):
//
// Call atexit functions
//
bl __SEGGER_RTL_execute_at_exit_fns
//
// Call debug_exit with return result/exit parameter
//
mov R0, R5
//
// Entry points for _exit and _Exit, which terminate immediately.
// Note: Destructors and registered atexit functions are not called. File descriptors are not closed.
//
MARK_FUNC _exit
MARK_FUNC _Exit
bl SEGGER_SEMIHOST_Exit
//
// If execution is not terminated, loop forever
//
L(ExitLoop):
b L(ExitLoop) // Loop forever.
END_FUNC exit
#endif
#ifdef FULL_LIBRARY
.bss
.balign 4
__SEGGER_init_arg_data:
.space ARGSSPACE
.size __SEGGER_init_arg_data, .-__SEGGER_init_arg_data
.type __SEGGER_init_arg_data, %object
#endif
/*************************** End of file ****************************/

View File

@ -0,0 +1,5 @@
<!DOCTYPE Board_Memory_Definition_File>
<root name="STM32F103ZE">
<MemorySegment name="FLASH1" start="0x08000000" size="0x00080000" access="ReadOnly" />
<MemorySegment name="RAM1" start="0x20000000" size="0x00010000" access="Read/Write" />
</root>

File diff suppressed because it is too large Load Diff

44
Ses/STM32F1xx_Target.js Normal file
View File

@ -0,0 +1,44 @@
/*********************************************************************
* SEGGER Microcontroller GmbH *
* The Embedded Experts *
**********************************************************************
* *
* (c) 2014 - 2024 SEGGER Microcontroller GmbH *
* *
* www.segger.com Support: support@segger.com *
* *
**********************************************************************
* *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or *
* without modification, are permitted provided that the following *
* condition is met: *
* *
* - Redistributions of source code must retain the above copyright *
* notice, this condition and the following disclaimer. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND *
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, *
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF *
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE *
* DISCLAIMED. IN NO EVENT SHALL SEGGER Microcontroller BE LIABLE FOR *
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR *
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT *
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; *
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE *
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH *
* DAMAGE. *
* *
*********************************************************************/
function Reset() {
TargetInterface.resetAndStop();
}
function EnableTrace(traceInterfaceType) {
// TODO: Enable trace
}

288
Ses/SysCall.c Normal file
View File

@ -0,0 +1,288 @@
/*********************************************************************
* (c) SEGGER Microcontroller GmbH *
* The Embedded Experts *
* www.segger.com *
**********************************************************************
-------------------------- END-OF-HEADER -----------------------------
Purpose : Implementation of low-level functions for I/O with the
SEGGER Runtime Library
using a UART (SEGGER's BSP UART module)
*/
/*********************************************************************
*
* #include section
*
**********************************************************************
*/
#include "__SEGGER_RTL_Int.h"
#include "stdio.h"
#include "Bsp.h"
/*********************************************************************
*
* Local types
*
**********************************************************************
*/
struct __SEGGER_RTL_FILE_impl { // NOTE: Provides implementation for FILE
int stub; // only needed so impl has size != 0.
};
/*********************************************************************
*
* Static data
*
**********************************************************************
*/
static FILE __SEGGER_RTL_stdin_file = { 0 }; // stdin reads from UART
static FILE __SEGGER_RTL_stdout_file = { 0 }; // stdout writes to UART
static FILE __SEGGER_RTL_stderr_file = { 0 }; // stderr writes to UART
static unsigned int _UART_Port = TTY_COM;
static int _stdin_ungot = EOF;
/*********************************************************************
*
* Public data
*
**********************************************************************
*/
FILE *stdin = &__SEGGER_RTL_stdin_file; // NOTE: Provide implementation of stdin for RTL.
FILE *stdout = &__SEGGER_RTL_stdout_file; // NOTE: Provide implementation of stdout for RTL.
FILE *stderr = &__SEGGER_RTL_stderr_file; // NOTE: Provide implementation of stderr for RTL.
void *__aeabi_read_tp(void) {
return 0; // 单线程环境下直接返回 0
}
/*********************************************************************
*
* Static code
*
**********************************************************************
*/
/*********************************************************************
*
* _stdin_getc()
*
* Function description
* Get character from standard input.
*
* Return value
* Character received.
*
* Additional information
* This function never fails to deliver a character.
*/
static char _stdin_getc(void) {
unsigned char c;
if (_stdin_ungot != EOF) {
c = _stdin_ungot;
_stdin_ungot = EOF;
} else {
c = UsartReceiveChar(_UART_Port);
}
return c;
}
/*********************************************************************
*
* Public code
*
**********************************************************************
*/
/*********************************************************************
*
* RTL_UART_Init()
*
* Function description
* Initialize RTL to use given UART for stdio.
*
* Parameters
* Unit : UART unit number (typically zero-based).
* Baudrate : Baud rate to configure [Hz].
* NumDataBits: Number of data bits to use.
* Parity : One of the following values:
* * BSP_UART_PARITY_NONE
* * BSP_UART_PARITY_ODD
* * BSP_UART_PARITY_EVEN
* NumStopBits: Number of stop bits to use.
*
* Additional description
* Parameters are same as for BSP_UART_Init().
* This also sets appropriate RX and TX interrupt handlers.
*/
void RTL_UART_Init(unsigned int Unit, unsigned long Baudrate, unsigned char NumDataBits, unsigned char Parity, unsigned char NumStopBits) {
_UART_Port = Unit;
UsartStdConfig(_UART_Port, Baudrate);
}
/*********************************************************************
*
* __SEGGER_RTL_X_file_stat()
*
* Function description
* Get file status.
*
* Parameters
* stream - Pointer to file.
*
* Additional information
* Low-overhead test to determine if stream is valid. If stream
* is a valid pointer and the stream is open, this function must
* succeed. If stream is a valid pointer and the stream is closed,
* this function must fail.
*
* The implementation may optionally determine whether stream is
* a valid pointer: this may not always be possible and is not
* required, but may assist debugging when clients provide wild
* pointers.
*
* Return value
* < 0 - Failure, stream is not a valid file.
* >= 0 - Success, stream is a valid file.
*/
int __SEGGER_RTL_X_file_stat(FILE *stream) {
if (stream == stdin || stream == stdout || stream == stderr) {
return 0; // NOTE: stdin, stdout, and stderr are assumed to be valid.
} else {
return EOF;
}
}
/*********************************************************************
*
* __SEGGER_RTL_X_file_bufsize()
*
* Function description
* Get stream buffer size.
*
* Parameters
* stream - Pointer to file.
*
* Additional information
* Returns the number of characters to use for buffered I/O on
* the file stream. The I/O buffer is allocated on the stack
* for the duration of the I/O call, therefore this value should
* not be set arbitrarily large.
*
* For unbuffered I/O, return 1.
*
* Return value
* Nonzero number of characters to use for buffered I/O; for
* unbuffered I/O, return 1.
*/
int __SEGGER_RTL_X_file_bufsize(FILE *stream) {
(void)stream;
return 1;
}
/*********************************************************************
*
* __SEGGER_RTL_X_file_read()
*
* Function description
* Read data from file.
*
* Parameters
* stream - Pointer to file to read from.
* s - Pointer to object that receives the input.
* len - Number of characters to read from file.
*
* Return value
* >= 0 - Success, amount of data read.
* < 0 - Failure.
*
* Additional information
* Reading from any stream other than stdin results in an error.
*/
int __SEGGER_RTL_X_file_read(FILE *stream, char *s, unsigned len) {
int c;
if (stream == stdin) {
c = 0;
while (len > 0) {
*s = _stdin_getc();
++s;
++c;
--len;
}
} else {
c = EOF;
}
return c;
}
/*********************************************************************
*
* __SEGGER_RTL_X_file_write()
*
* Function description
* Write data to file.
*
* Parameters
* stream - Pointer to file to write to.
* s - Pointer to object to write to file.
* len - Number of characters to write to the file.
*
* Return value
* >= 0 - Success.
* < 0 - Failure.
*
* Additional information
* this version is NOT reentrant!
* stdout and stderr are directed to UART;
* writing to any stream other than stdout or stderr results in an error
*/
int __SEGGER_RTL_X_file_write(FILE *stream, const char *s, unsigned len) {
if ((stream == stdout) || (stream == stderr)) {
UsartSendStr(_UART_Port, (uint8_t* ) s, len);
return len;
} else {
return EOF;
}
}
/*********************************************************************
*
* __SEGGER_RTL_X_file_unget()
*
* Function description
* Push character back to stream.
*
* Parameters
* stream - Pointer to file to push back to.
* c - Character to push back.
*
* Return value
* >= 0 - Success.
* < 0 - Failure.
*
* Additional information
* Push-back is only supported for standard input, and
* only a single-character pushback buffer is implemented.
*/
int __SEGGER_RTL_X_file_unget(FILE *stream, int c) {
if (stream == stdin) {
if (c != EOF && _stdin_ungot == EOF) {
_stdin_ungot = c;
} else {
c = EOF;
}
} else {
c = EOF;
}
return c;
}
/*************************** End of file ****************************/