1
This commit is contained in:
12
Demo1/GPIO.md
Normal file
12
Demo1/GPIO.md
Normal file
@@ -0,0 +1,12 @@
|
||||
引脚带FT的可以容忍5V,不带的只能接入3.3V
|
||||
|
||||
输入模式:
|
||||
GPIO_Mode_AIN 模拟输入
|
||||
GPIO_Mode_IN_FLOATING 浮空输入
|
||||
GPIO_Mode_IPD 下拉输入
|
||||
GPIO_Mode_IPU 上拉输入
|
||||
输出模式:
|
||||
GPIO_Mode_Out_OD 开漏输出
|
||||
GPIO_Mode_Out_PP 推挽输出
|
||||
GPIO_Mode_AF_OD 复用开漏
|
||||
GPIO_Mode_AF_PP 复用推挽
|
||||
37
Demo1/demo.md
Normal file
37
Demo1/demo.md
Normal file
@@ -0,0 +1,37 @@
|
||||
C语言中,.h文件(头文件)主要用于声明接口(如函数原型、宏、类型定义等),而.c文件(源文件)用于实现这些接口的具体功能并包含程序的入口函数main()。
|
||||
.h文件(头文件)的作用
|
||||
- 声明接口内容:包含函数原型、宏定义、类型定义(如结构体)、全局变量声明(使用`extern`)等,为其他文件提供调用依据。例如:
|
||||
```c
|
||||
// math_utils.h
|
||||
#ifndef MATH_UTILS_H
|
||||
#define MATH_UTILS_H
|
||||
int add(int a, int b); // 函数声明
|
||||
#define MAX 100 // 宏定义
|
||||
extern int global_var; // 全局变量声明
|
||||
#endif
|
||||
```
|
||||
- 防止重复包含:通过条件编译指令(如`#ifndef`/`#define`/`#endif`)或`#pragma once`避免编译错误。
|
||||
- 模块化设计:提供清晰的接口规范,隐藏实现细节,便于多人协作和库文件分发。
|
||||
.c文件(源文件)的作用
|
||||
- 实现功能代码:包含函数的具体逻辑、全局变量的定义(分配内存)和程序入口`main()`。例如:
|
||||
```c
|
||||
// math_utils.c
|
||||
#include "math_utils.h" // 包含对应头文件
|
||||
int add(int a, int b) { // 函数实现
|
||||
return a + b;
|
||||
}
|
||||
int global_var = 10; // 全局变量定义
|
||||
```
|
||||
- 独立编译单元:每个.c文件被编译成目标文件(.o),再由链接器合并为可执行文件。
|
||||
- 管理内部细节:可定义静态变量或函数(使用`static`),限制作用域为当前文件,避免命名冲突。
|
||||
核心关系与工作流程
|
||||
- 分离编译优势:头文件定义接口,源文件实现功能,提升代码可读性、可维护性和编译效率。
|
||||
- 预处理过程:编译时,`#include`指令将头文件内容插入源文件,形成完整代码再编译。
|
||||
- 链接机制:链接器将多个目标文件(.o)的符号引用(如函数调用)解析并绑定到具体定义,生成最终程序。
|
||||
> 示例流程:
|
||||
> 1. 头文件`math_utils.h`声明`int add(int a, int b);`。
|
||||
> 2. 源文件`math_utils.c`实现该函数并包含头文件。
|
||||
> 3. 主程序`main.c`通过`#include "math_utils.h"`调用`add()`,编译后链接所有目标文件执行。
|
||||
|
||||
|
||||
中断函数结束后要清除中断函数标志位
|
||||
84
git/git操作.md
Normal file
84
git/git操作.md
Normal file
@@ -0,0 +1,84 @@
|
||||
1. 初始化仓库
|
||||
git init # 当前目录初始化为Git仓库
|
||||
git clone <repo_url> # 克隆远程仓库到本地
|
||||
|
||||
2. 查看状态与日志
|
||||
git status # 查看工作区/暂存区状态
|
||||
git log # 查看提交历史
|
||||
git log --oneline # 简洁版提交历史
|
||||
git log -p # 显示历史提交的代码差异
|
||||
|
||||
3. 添加与提交
|
||||
git add <file> # 添加文件到暂存区
|
||||
git add . # 添加所有修改到暂存区
|
||||
git commit -m "message" # 提交暂存区内容
|
||||
git commit -am "message" # 添加所有修改并直接提交(跳过`git add`)
|
||||
|
||||
二、分支管理
|
||||
1. 分支操作
|
||||
git branch # 查看本地分支
|
||||
git branch <name> # 创建新分支
|
||||
git checkout <branch> # 切换到分支
|
||||
git switch <branch> # (Git 2.23+) 更安全的切换命令
|
||||
git merge <branch> # 合并指定分支到当前分支
|
||||
git branch -d <branch> # 删除分支(已合并)
|
||||
git branch -D <branch> # 强制删除分支(未合并)
|
||||
|
||||
2. 远程分支
|
||||
git fetch # 拉取远程最新元数据(不自动合并)
|
||||
git pull # 拉取远程代码并合并(= fetch + merge)
|
||||
git pull --rebase # 拉取远程代码并用变基合并
|
||||
git push # 推送本地提交到远程
|
||||
git push -u origin <branch> # 首次推送并设置上游跟踪分支
|
||||
|
||||
三、撤销与回退
|
||||
1. 撤销工作区修改
|
||||
git restore <file> # 撤销工作区的修改(未add)
|
||||
git checkout -- <file> # 同上(旧版写法)
|
||||
|
||||
2. 撤销暂存区修改
|
||||
git restore --staged <file> # 将文件移出暂存区(保留工作区修改)
|
||||
git reset HEAD <file> # 同上(旧版写法)
|
||||
|
||||
3. 回退提交
|
||||
git reset --soft HEAD^ # 回退到上一提交(保留修改到暂存区)
|
||||
git reset --hard HEAD^ # 彻底回退到上一提交(丢弃所有修改)
|
||||
git revert <commit_id> # 创建新提交来撤销指定提交(安全!)
|
||||
注意:reset --hard 会永久丢弃修改,慎用!
|
||||
|
||||
四、远程仓库管理
|
||||
git remote -v # 查看远程仓库地址
|
||||
git remote add <name> <url> # 添加远程仓库
|
||||
git remote remove <name> # 删除远程仓库
|
||||
git push origin --delete <branch> # 删除远程分支
|
||||
|
||||
五、高级操作
|
||||
1. 储藏临时修改
|
||||
git stash # 储藏当前工作区修改
|
||||
git stash pop # 恢复最近储藏的修改
|
||||
git stash list # 查看所有储藏记录
|
||||
|
||||
2. 标签管理
|
||||
git tag # 查看所有标签
|
||||
git tag v1.0.0 # 创建轻量标签
|
||||
git tag -a v1.0.0 -m "msg" # 创建附注标签
|
||||
git push origin --tags # 推送所有标签到远程
|
||||
|
||||
3. 变基(Rebase)
|
||||
git rebase <branch> # 将当前分支变基到目标分支
|
||||
git rebase --abort # 终止变基
|
||||
git rebase --continue # 解决冲突后继续变基
|
||||
|
||||
六、配置相关
|
||||
git config --global user.name "Your Name" # 设置全局用户名
|
||||
git config --global user.email "email@example.com" # 设置邮箱
|
||||
git config --list # 查看所有配置
|
||||
|
||||
七、文件忽略规则
|
||||
创建 .gitignore 文件,添加需忽略的文件/目录:
|
||||
# 示例:
|
||||
*.log
|
||||
/node_modules
|
||||
.DS_Store
|
||||
|
||||
|
||||
33
git/git流程..md
Normal file
33
git/git流程..md
Normal file
@@ -0,0 +1,33 @@
|
||||
配置用户信息
|
||||
# 全局配置(所有项目生效)
|
||||
git config --global user.name "Your Name"
|
||||
git config --global user.email "your.email@example.com"
|
||||
|
||||
# 仅当前项目配置(优先级更高)
|
||||
git config user.name "Project Name"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
1. 初始化git
|
||||
1. git init
|
||||
|
||||
2. 绑定远程仓库链接
|
||||
1. git remote add origin <url>
|
||||
|
||||
3. 创建新分支并且切换到新分支
|
||||
1. git ckeckout -b <name>
|
||||
|
||||
4. 添加所有文件
|
||||
1. git add .
|
||||
|
||||
5. 添加提交说明
|
||||
1. git commit -m "Commit message"
|
||||
|
||||
6. 提交到仓库
|
||||
1. git push origin <name>
|
||||
2. git push origin main # 推送本地 main 分支到远程 origin
|
||||
3. git push -u origin feature/login # 第一次推送时设置上游分支(后续可用 git push 直接推送)
|
||||
|
||||
git操作指令看清楚了在操作,数据不易乱操作导致数据丢失
|
||||
Reference in New Issue
Block a user