172 Commits
v0.1 ... master

Author SHA1 Message Date
TuxMonkey
bd7f8f2962 silentmode(ERROR!) 2026-07-20 14:10:32 +08:00
TuxMonkey
4f7817f9de start song 2026-07-16 13:45:09 +08:00
TuxMonkey
59de1fafa4 start song 2026-07-16 13:38:48 +08:00
TuxMonkey
47f5e4ddab add DMA remote control 2026-07-14 21:58:07 +08:00
TuxMonkey
f4c0424c45 add DMA remote control 2026-07-14 21:56:46 +08:00
TuxMonkey
591707d9fc changed FDCAN!PowerModule OK! 2026-03-16 21:56:27 +08:00
TuxMonkey
aa6eefda50 changed FDCAN!PowerModule OK! 2026-03-16 18:15:05 +08:00
TuxMonkey
e84c3e11f3 狗好了,但是PowerMeterDecode还是g的,*rxbuff是好的,但是解析出来都是0.idxOK 头疼 2026-03-12 22:11:13 +08:00
TuxMonkey
f06df047db 狗好了,但是PowerMeterDecode还是g的,*rxbuff是好的,但是解析出来都是0.idxOK 头疼 2026-03-11 22:00:57 +08:00
TuxMonkey
4c2bff6257 狗好了,但是PowerMeterDecode还是g的,*rxbuff是好的,但是解析出来都是0.idxOK 头疼 2026-03-09 22:02:32 +08:00
TuxMonkey
0ccdd0a0d5 修复了吗?没有,很难的啦111 2026-03-09 21:43:44 +08:00
TuxMonkey
e3f5951881 修复了吗?没有,很难的啦 2026-03-09 18:28:45 +08:00
TuxMonkey
a96e9e939c 修复了吗?没有,很难的啦 2026-03-09 17:47:13 +08:00
79afbaf68d daemon init success 2026-03-09 02:49:56 +08:00
28006c3bd0 daemon init success 2026-03-09 02:46:48 +08:00
cf1bc7b2ae daemon init failed 2026-03-09 02:35:08 +08:00
9c58a09eab xidipower test 2026-03-09 01:57:43 +08:00
TuxMonkey
5145d60794 not powermeter data 2026-03-08 22:08:36 +08:00
TuxMonkey
b5863332b6 not powermeter data 2026-03-08 22:08:13 +08:00
TuxMonkey
2f0ca6d906 add devcmdtask but couldnt recv data 2026-03-07 21:59:47 +08:00
50edf7dedb xidipower test 2026-03-07 01:49:39 +08:00
cf161df939 add DM motor drv dwt delay times 2026-03-05 12:23:34 +08:00
483d5f0ac4 add DM motor drv 2026-03-05 02:06:41 +08:00
db95e9e44d Merge remote-tracking branch 'origin/master' 2026-03-05 00:58:01 +08:00
1e75c1a5e1 add lk motor drv 2026-03-05 00:56:03 +08:00
c3fc805aca changed bspfdcan 2026-03-05 00:44:44 +08:00
TuxMonkey
596d3d4c65 halfsteering 2026-03-03 21:44:39 +08:00
6d7d23ebba add some files 2026-03-03 01:30:09 +08:00
ed4e6ff0d1 add some files 2026-03-02 17:34:48 +08:00
f8b8616966 add some files 2026-03-02 11:14:12 +08:00
d8563db2be Remote To DMA 2026-03-01 17:40:22 +08:00
ede790e849 CAN CAN NEED 2026-02-24 23:47:15 +08:00
216c96c2c6 CAN CAN NEED 2026-02-24 16:46:57 +08:00
522d6a4545 CAN CAN NEED 2026-02-24 16:43:57 +08:00
c0c7658b39 Regenerated HAL Drivers to Support Power 5V EN/24V EN,Also fixed FDCAN3 Tx Fifo Queue Elmts Nbr/Baudrate. 2026-02-24 16:21:12 +08:00
17ce43a7ef Regenerated HAL Drivers to Support Power 5V EN/24V EN,Also fixed FDCAN3 Tx Fifo Queue Elmts Nbr/Baudrate. 2026-02-24 16:05:17 +08:00
ebe9ad087e Regenerated HAL Drivers to Support Power 5V EN/24V EN,Also fixed FDCAN3 Tx Fifo Queue Elmts Nbr/Baudrate. 2026-02-24 15:35:38 +08:00
e515c97955 great changes 2026-02-24 14:42:54 +08:00
a941a3719a great changes 2026-02-23 23:49:47 +08:00
58299949c5 dji motor but not tested 2026-02-23 13:32:10 +08:00
834f9e573c 双板通信inited 2026-02-22 00:16:04 +08:00
75f7c3defd add ffc controller 2026-02-12 01:12:05 +08:00
8458a4ffe7 add ffc controller 2026-02-12 01:03:41 +08:00
8f22f67c5a add ffc controller 2026-02-12 01:02:48 +08:00
b00cfac6f6 add ffc controller 2026-02-12 01:01:24 +08:00
d27b8e8473 add ffc controller 2026-02-12 00:59:13 +08:00
a025289597 add ffc controller 2026-02-12 00:41:34 +08:00
f94b76b982 change CMakeLists.txt 2026-02-11 23:35:13 +08:00
3704e1c689 change includes 2026-02-11 23:15:18 +08:00
9628c1eae0 user ozone config 2026-02-11 22:55:09 +08:00
de9b19b72d cmakelist 2026-02-11 15:59:17 +08:00
d2b7acd3d4 cmakelist 2026-02-11 15:56:03 +08:00
19278fa68f add docs 2026-02-11 15:47:17 +08:00
55d36d3812 add imu deadbands to prevent 0piao 2026-02-11 00:27:51 +08:00
4ec7340bc4 update cmakelists 2026-02-10 23:08:25 +08:00
86650fd2bd update cmakelists 2026-02-10 21:56:01 +08:00
f27dad8242 update cmakelists 2026-02-10 16:55:51 +08:00
1059a007a2 add readme.md 2026-02-10 16:36:25 +08:00
85e5c7d6a0 add readme.md 2026-02-10 16:29:30 +08:00
TuxMonkey
bda8bf1b43 spring 2026-01-17 17:51:35 +08:00
TuxMonkey
c6a0c3f0cc spring 2026-01-17 17:48:42 +08:00
93abe2381f changed bspfdcan 2026-01-09 03:05:55 +08:00
TuxMonkey
59e545e3f2 servo init 2025-12-25 21:31:04 +08:00
TuxMonkey
2ea642d04a servo init 2025-12-24 14:11:50 +08:00
TuxMonkey
f92289346d remote control init 2025-12-18 19:05:50 +08:00
TuxMonkey
8c66f57642 remote control init 2025-12-18 19:05:05 +08:00
TuxMonkey
987c402751 remote control init 2025-12-15 21:59:29 +08:00
TuxMonkey
a78fe6ea11 remote control init 2025-12-15 21:31:36 +08:00
TuxMonkey
2d905efeb7 videotransmiter 2025-12-05 22:03:47 +08:00
8ce7e064e8 Revert "message hub"
This reverts commit 7522bc9974.
2025-12-05 14:02:31 +00:00
TuxMonkey
ec509f0bf1 videotransmiter 2025-12-05 21:57:41 +08:00
TuxMonkey
c021b4794c videotransmiter 2025-12-05 21:47:00 +08:00
TuxMonkey
7522bc9974 message hub 2025-12-04 21:32:17 +08:00
TuxMonkey
80dd342a18 message hub 2025-12-02 22:05:51 +08:00
TuxMonkey
74a2ded88a bsp docs 2025-12-01 20:28:11 +08:00
TuxMonkey
0da5af5742 bsp docs 2025-11-25 14:56:22 +08:00
TuxMonkey
2c7c458769 bsp_flash 2025-11-25 14:55:34 +08:00
TuxMonkey
c1ebb09358 代码规范 usbvpc文档 2025-11-25 14:40:40 +08:00
TuxMonkey
72e8500a27 代码规范 usart文档 2025-11-25 14:28:03 +08:00
TuxMonkey
2a40c85a2b 代码规范 prts文档 2025-11-25 14:24:06 +08:00
TuxMonkey
a57f882fc3 代码规范 prts文档 2025-11-25 13:01:39 +08:00
TuxMonkey
e664bca77b 代码规范 prts文档 2025-11-24 15:27:46 +08:00
TuxMonkey
4bfdd87bab 代码规范 SuperCap文档 2025-11-24 14:58:44 +08:00
TuxMonkey
d23a73e4bf 代码规范 SuperCap文档 2025-11-24 14:54:15 +08:00
TuxMonkey
eb9ecf9c12 代码规范 SuperCap文档 2025-11-24 14:53:41 +08:00
TuxMonkey
262cff7d16 代码规范 SuperCap文档 2025-11-24 14:39:28 +08:00
TuxMonkey
41648fe75f 代码规范 2025-11-24 14:30:24 +08:00
TuxMonkey
d97528291a 代码规范 2025-11-20 19:49:12 +08:00
TuxMonkey
1ff64dea82 代码规范 2025-11-20 19:26:42 +08:00
TuxMonkey
d49c023f3c powermeter 2025-11-20 19:19:10 +08:00
TuxMonkey
8d88556f5f powermeter 2025-11-20 19:11:56 +08:00
TuxMonkey
bc248a88f7 adc 2025-11-20 17:37:07 +08:00
TuxMonkey
a5428702d7 adc 2025-11-20 17:19:43 +08:00
TuxMonkey
a46ac6e1d8 ld file 2025-11-20 15:33:09 +08:00
TuxMonkey
922370eeec ld file 2025-11-20 15:18:50 +08:00
TuxMonkey
69f6a4f799 add damiao imu module 2025-11-20 15:12:20 +08:00
TuxMonkey
d5185b491a add damiao imu module 2025-11-18 13:06:23 +08:00
TuxMonkey
3d73aeea5d add damiao imu module 2025-11-18 13:03:52 +08:00
TuxMonkey
bed78b6505 add some new md 2025-11-17 16:43:02 +08:00
TuxMonkey
56639afc18 add some new modules 2025-11-17 16:27:19 +08:00
TuxMonkey
d1e7f30373 add new drv but not benefit stm32h723vg 2025-11-16 22:08:58 +08:00
TuxMonkey
e08ffe766f add new drv but not benefit stm32h723vg 2025-11-16 21:37:51 +08:00
TuxMonkey
977f266a42 release bmi088 to dwt delay 2025-11-16 21:05:23 +08:00
TuxMonkey
38264c53e1 release bmi088 to dwt delay 2025-11-16 21:05:10 +08:00
TuxMonkey
66da7a1935 math lib ok(?) but not linked to lib 2025-11-16 20:55:29 +08:00
TuxMonkey
053563e951 math lib failure 2025-11-16 17:42:34 +08:00
TuxMonkey
ab01747052 imu test 2025-11-16 17:19:14 +08:00
TuxMonkey
de8a0d5117 imu test failed 2025-11-15 22:18:00 +08:00
TuxMonkey
14a3cbb955 为什么要演奏春日影 2025-11-15 20:52:09 +08:00
TuxMonkey
1a0484b332 format 2025-11-15 16:27:25 +08:00
TuxMonkey
b98674ac3f format 2025-11-15 16:13:35 +08:00
TuxMonkey
7c0273c80c format 2025-11-15 15:57:21 +08:00
TuxMonkey
71e9329709 linux armnoneeabigcc 2025-11-15 15:55:05 +08:00
TuxMonkey
0f85356b7d linux armnoneeabigcc 2025-11-15 15:22:57 +08:00
TuxMonkey
0ee14e9b47 buzzer ok (because rtos not start cant read ticks) 2025-11-15 15:21:02 +08:00
TuxMonkey
39c4551d1f buzzer ok (because rtos not start cant read ticks) 2025-11-15 15:16:47 +08:00
TuxMonkey
287cec0e84 buzzer ok (because rtos not start cant read ticks) 2025-11-14 21:42:22 +08:00
TuxMonkey
190921dc76 buzzer ok (because rtos not start cant read ticks) 2025-11-12 21:12:28 +08:00
TuxMonkey
9f205d6252 buzzer problem not ok 2025-11-11 21:46:38 +08:00
TuxMonkey
82f21f7d35 buzzer problem not ok 2025-11-11 21:46:23 +08:00
miss
9aac6aca4d changed default toolchain to arm-none-eabi 2025-11-11 20:58:22 +08:00
miss
6bd8f0c5c3 changed default toolchain to arm-none-eabi 2025-11-11 20:56:04 +08:00
miss
f06946af8c changed to have breakpoints 2025-11-11 20:51:46 +08:00
TuxMonkey
b266f8d4dd interwork problem 2025-11-11 20:31:11 +08:00
f8f3c229d8 add LICENSE.
Signed-off-by: TuxMonkey <nqx_2004@qq.com>
2025-11-11 07:59:12 +00:00
tux
cdf7d35259 format 2025-11-11 15:48:30 +08:00
tux
ee44ce8979 add first commit to modules/periph/buzzer 2025-11-11 15:32:53 +08:00
tux
a3eed14110 add commit to ld files 2025-11-11 15:22:07 +08:00
tux
0f5a3b51c4 add commit to cmake files 2025-11-11 15:18:39 +08:00
tux
d252e8b178 add commit to cmake files 2025-11-11 15:16:06 +08:00
tux
99568ff0bb add commit to Compile Options 2025-11-11 15:10:46 +08:00
tux
43678bf009 auto detect toolchain 2025-11-11 15:08:14 +08:00
tux
3143b12248 auto detect toolchain 2025-11-11 15:04:05 +08:00
tux
1554fcf449 auto detect toolchain 2025-11-11 14:26:15 +08:00
tux
44f890a6cb auto detect toolchain 2025-11-11 14:13:18 +08:00
TuxMonkey
4f13aff020 changed cmakelist and pending rpl lib to fix 2025-11-10 21:43:32 +08:00
eb122d0898 changed readme.md 2025-11-10 20:17:58 +08:00
d27518d189 !2 添加starm-clang和arm-none-eabi工具链检测逻辑,移除CMakePresets.json
Merge pull request !2 from 120MF/master
2025-11-10 11:40:48 +00:00
WeaveFeather
c49665cedc 添加starm-clang和arm-none-eabi工具链检测逻辑,移除CMakePresets.json 2025-11-10 19:36:02 +08:00
f4f131803f add linux db2 2025-11-10 18:28:52 +08:00
c736e3060c !1 添加 CMake 支持以自动查找和链接 rpl 库,并创建 CMake 构建说明文档
Merge pull request !1 from 120MF/master
2025-11-10 10:07:34 +00:00
MoonFeather
ed07d3659f 添加 CMake 支持以自动查找和链接 rpl 库,并创建 CMake 构建说明文档
Signed-off-by: MoonFeather <moonbite233@gmail.com>
2025-11-10 16:30:07 +08:00
MoonFeather
0e1c9cbbc1 自动添加User_Code下的源文件/包含目录
Signed-off-by: MoonFeather <moonbite233@gmail.com>
2025-11-10 15:59:47 +08:00
MoonFeather
e82cca9692 模块化主CMakeLists内容到cmake子目录
Signed-off-by: MoonFeather <moonbite233@gmail.com>
2025-11-10 15:54:11 +08:00
MoonFeather
deaefab9c3 停止追踪.idea,去除CMakeLists中多余内容 2025-11-10 15:46:49 +08:00
TuxMonkey
e8a55af06a add module-buzzer 2025-11-09 21:56:44 +08:00
fbedc008ef closed fucking IWDG and SPI WS2812 is running 2025-11-07 16:18:31 +08:00
bf787d97b4 closed fucking IWDG and SPI WS2812 is running 2025-11-07 16:17:18 +08:00
9dddb18932 add linux debug 2025-11-07 15:37:04 +08:00
TuxMonkey
99ad2328a3 push dedebfiles 2025-11-06 22:20:02 +08:00
tux
ac14e19828 updated ioc but not ok 2025-11-05 23:06:07 +08:00
TuxMonkey
2dbfa43588 must need stm32cubeclt to have breakpoint? 2025-11-05 21:16:46 +08:00
TuxMonkey
9dff60f9ae changed starm-clang.cmake
gcc-arm-none-eabi.cmake to have -O0-g
2025-11-05 20:44:10 +08:00
tux
dcc4e38451 updated powercontrol 2025-11-05 17:52:11 +08:00
tux
4a00b40821 updated readme.md 2025-11-05 15:10:43 +08:00
tux
9d0b8c49f7 fix ws2812Task void *argument issue 2025-11-05 15:04:29 +08:00
tux
3b3e6c764f add spi6 2025-11-05 15:01:47 +08:00
TuxMonkey
f51fe3cc4e error 2025-11-04 22:13:49 +08:00
TuxMonkey
d744034f45 changed add ws2812Task 2025-11-04 22:07:56 +08:00
TuxMonkey
cdc462789f add bsp_spi 2025-11-04 22:02:49 +08:00
TuxMonkey
183cc81446 add ws2812task 2025-11-03 22:14:44 +08:00
TuxMonkey
7a113a32dd add bsp_spi 2025-11-03 22:08:14 +08:00
38ecee9603 changed file and directory 2025-10-28 14:57:41 +08:00
95e8f8b623 changed file and directory 2025-10-28 14:52:24 +08:00
9658cd656e added fdcan.c/fdcan.h document markdown 2025-10-26 15:37:14 +08:00
9bffbabeac changed bsp_fdcan.c/bsp_fdcan.h 2025-10-26 13:39:49 +08:00
2cd749a652 changed fdcan.c 2025-10-26 13:26:30 +08:00
2f5e60e86c add bsp_fdcan.c/.h 2025-10-24 15:44:40 +08:00
faca03ab2a add bsp_fdcan.c/.h 2025-10-24 15:30:40 +08:00
bd6bd124fa changed CMakeLists.txt
add some refs
2025-10-24 15:09:49 +08:00
dfd5692c86 changed CMakeLists.txt
add some refs
2025-10-24 15:09:03 +08:00
239c7eca91 changed CMakeLists.txt
add some refs
2025-10-21 17:09:46 +08:00
316 changed files with 49062 additions and 2134 deletions

55
.clang-format Normal file
View File

@@ -0,0 +1,55 @@
---
Language: Cpp
BasedOnStyle: Microsoft
AccessModifierOffset: -4
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignOperands: true
AlignTrailingComments: false
AllowShortBlocksOnASingleLine: false
AlwaysBreakTemplateDeclarations: Yes
BraceWrapping:
AfterCaseLabel: true
AfterClass: true
AfterControlStatement: true
AfterEnum: true
AfterFunction: true
AfterNamespace: true
AfterStruct: true
AfterUnion: true
AfterExternBlock: true
BeforeCatch: true
BeforeElse: true
BeforeLambdaBody: true
BeforeWhile: true
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakConstructorInitializers: AfterColon
BreakConstructorInitializersBeforeComma: false
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ContinuationIndentWidth: 8
IncludeCategories:
- Regex: '^<.*'
Priority: 1
- Regex: '^".*'
Priority: 2
- Regex: '.*'
Priority: 3
IncludeIsMainRegex: '([-_](test|unittest))?$'
IndentCaseLabels: true
InsertNewlineAtEOF: true
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 2
NamespaceIndentation: All
SpaceAfterCStyleCast: true
SpaceAfterTemplateKeyword: false
SpaceBeforeRangeBasedForLoopColon: false
SpaceInEmptyParentheses: false
SpacesInAngles: false
SpacesInConditionalStatement: false
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
...

4
.gitignore vendored
View File

@@ -13,3 +13,7 @@ cmake-build-debug-stm32cube
/STM32H723VGTx_FLASH.ld /STM32H723VGTx_FLASH.ld
/compile_commands.json /compile_commands.json
.idea
cmake-build*

8
.idea/.gitignore generated vendored
View File

@@ -1,8 +0,0 @@
# 默认忽略的文件
/shelf/
/workspace.xml
# 基于编辑器的 HTTP 客户端请求
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

View File

@@ -1,2 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module classpath="CMake" type="CPP_MODULE" version="4" />

View File

@@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AgentMigrationStateService">
<option name="migrationStatus" value="COMPLETED" />
</component>
</project>

View File

@@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AskMigrationStateService">
<option name="migrationStatus" value="COMPLETED" />
</component>
</project>

View File

@@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Ask2AgentMigrationStateService">
<option name="migrationStatus" value="COMPLETED" />
</component>
</project>

View File

@@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="EditMigrationStateService">
<option name="migrationStatus" value="COMPLETED" />
</component>
</project>

252
.idea/editor.xml generated
View File

@@ -1,252 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="BackendCodeEditorSettings">
<option name="/Default/CodeInspection/GeneratedCode/GeneratedCodeRegions/=Component_0020Designer_0020generated_0020code/@EntryIndexedValue" value="Component Designer generated code" type="string" />
<option name="/Default/CodeInspection/GeneratedCode/GeneratedCodeRegions/=Designer_0020generated_0020code/@EntryIndexedValue" value="Designer generated code" type="string" />
<option name="/Default/CodeInspection/GeneratedCode/GeneratedCodeRegions/=Web_0020Form_0020Designer_0020generated_0020code/@EntryIndexedValue" value="Web Form Designer generated code" type="string" />
<option name="/Default/CodeInspection/GeneratedCode/GeneratedCodeRegions/=Windows_0020Form_0020Designer_0020generated_0020code/@EntryIndexedValue" value="Windows Form Designer generated code" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CDeclarationWithImplicitIntType/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CommentTypo/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=ConstevalIfIsAlwaysConstant/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppAbstractClassWithoutSpecifier/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppAbstractFinalClass/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppAbstractVirtualFunctionCallInCtor/@EntryIndexedValue" value="ERROR" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppAccessSpecifierWithNoDeclarations/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppAwaiterTypeIsNotClass/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppBooleanIncrementExpression/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppBoostFormatBadCode/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppBoostFormatLegacyCode/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppBoostFormatMixedArgs/@EntryIndexedValue" value="ERROR" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppBoostFormatTooFewArgs/@EntryIndexedValue" value="ERROR" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppBoostFormatTooManyArgs/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppCStyleCast/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppCVQualifierCanNotBeAppliedToReference/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppClassCanBeFinal/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppClassIsIncomplete/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppClassNeedsConstructorBecauseOfUninitializedMember/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppClassNeverUsed/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppCompileTimeConstantCanBeReplacedWithBooleanConstant/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppConceptNeverUsed/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppConditionalExpressionCanBeSimplified/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppConstParameterInDeclaration/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppConstValueFunctionReturnType/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppCoroutineCallResolveError/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFAArrayIndexOutOfBounds/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFAConstantConditions/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFAConstantFunctionResult/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFAConstantParameter/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFADeletedPointer/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFAEndlessLoop/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFAInfiniteRecursion/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFAInvalidatedMemory/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFALocalValueEscapesFunction/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFALocalValueEscapesScope/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFALoopConditionNotUpdated/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFAMemoryLeak/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFANotInitializedField/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFANullDereference/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFATimeOver/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFAUnreachableCode/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFAUnreachableFunctionCall/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFAUnreadVariable/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFAUnusedValue/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDeclarationHidesLocal/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDeclarationHidesUncapturedLocal/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDeclarationSpecifierWithoutDeclarators/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDeclaratorDisambiguatedAsFunction/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDeclaratorNeverUsed/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDeclaratorUsedBeforeInitialization/@EntryIndexedValue" value="ERROR" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDefaultCaseNotHandledInSwitchStatement/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDefaultInitializationWithNoUserConstructor/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDefaultIsUsedAsIdentifier/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDefaultedSpecialMemberFunctionIsImplicitlyDeleted/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDeletingVoidPointer/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDependentTemplateWithoutTemplateKeyword/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDependentTypeWithoutTypenameKeyword/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDeprecatedEntity/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDeprecatedOverridenMethod/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDeprecatedRegisterStorageClassSpecifier/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDereferenceOperatorLimitExceeded/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDiscardedPostfixOperatorResult/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDoxygenSyntaxError/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDoxygenUndocumentedParameter/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDoxygenUnresolvedReference/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEmptyDeclaration/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEnforceCVQualifiersOrder/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEnforceCVQualifiersPlacement/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEnforceDoStatementBraces/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEnforceForStatementBraces/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEnforceFunctionDeclarationStyle/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEnforceIfStatementBraces/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEnforceNestedNamespacesStyle/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEnforceOverridingDestructorStyle/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEnforceOverridingFunctionStyle/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEnforceTypeAliasCodeStyle/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEnforceWhileStatementBraces/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEntityAssignedButNoRead/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEntityUsedOnlyInUnevaluatedContext/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEnumeratorNeverUsed/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEqualOperandsInBinaryExpression/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEvaluationFailure/@EntryIndexedValue" value="ERROR" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppExplicitSpecializationInNonNamespaceScope/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppExpressionWithoutSideEffects/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppFinalFunctionInFinalClass/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppFinalNonOverridingVirtualFunction/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppForLoopCanBeReplacedWithWhile/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppForwardEnumDeclarationWithoutUnderlyingType/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppFunctionDoesntReturnValue/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppFunctionIsNotImplemented/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppFunctionResultShouldBeUsed/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppFunctionalStyleCast/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppHeaderHasBeenAlreadyIncluded/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppHiddenFunction/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppHidingFunction/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppIdenticalOperandsInBinaryExpression/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppIfCanBeReplacedByConstexprIf/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppImplicitDefaultConstructorNotAvailable/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppIncompatiblePointerConversion/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppIncompleteSwitchStatement/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppInconsistentNaming/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppIntegralToPointerConversion/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppInvalidLineContinuation/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppJoinDeclarationAndAssignment/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppLambdaCaptureNeverUsed/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppLocalVariableMayBeConst/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppLocalVariableMightNotBeInitialized/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppLocalVariableWithNonTrivialDtorIsNeverUsed/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppLongFloat/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMemberFunctionMayBeConst/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMemberFunctionMayBeStatic/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMemberInitializersOrder/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMismatchedClassTags/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMissingIncludeGuard/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMissingKeywordThrow/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppModulePartitionWithSeveralPartitionUnits/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMsExtAddressOfClassRValue/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMsExtBindingRValueToLvalueReference/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMsExtCopyElisionInCopyInitDeclarator/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMsExtDoubleUserConversionInCopyInit/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMsExtNotInitializedStaticConstLocalVar/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMsExtReinterpretCastFromNullptr/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMultiCharacterLiteral/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMultiCharacterWideLiteral/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMustBePublicVirtualToImplementInterface/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMutableSpecifierOnReferenceMember/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppNoDiscardExpression/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppNodiscardFunctionWithoutReturnValue/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppNonExceptionSafeResourceAcquisition/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppNonExplicitConversionOperator/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppNonExplicitConvertingConstructor/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppNonInlineFunctionDefinitionInHeaderFile/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppNonInlineVariableDefinitionInHeaderFile/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppNotAllPathsReturnValue/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppObjectMemberMightNotBeInitialized/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppOutParameterMustBeWritten/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppParameterMayBeConst/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppParameterMayBeConstPtrOrRef/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppParameterNamesMismatch/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppParameterNeverUsed/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPassValueParameterByConstReference/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPointerConversionDropsQualifiers/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPointerToIntegralConversion/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPolymorphicClassWithNonVirtualPublicDestructor/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPossiblyErroneousEmptyStatements/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPossiblyUninitializedMember/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPossiblyUnintendedObjectSlicing/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPrecompiledHeaderIsNotIncluded/@EntryIndexedValue" value="ERROR" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPrecompiledHeaderNotFound/@EntryIndexedValue" value="ERROR" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPrintfBadFormat/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPrintfExtraArg/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPrintfMissedArg/@EntryIndexedValue" value="ERROR" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPrintfRiskyFormat/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPrivateSpecialMemberFunctionIsNotImplemented/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRangeBasedForIncompatibleReference/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedefinitionOfDefaultArgumentInOverrideFunction/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantAccessSpecifier/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantBaseClassAccessSpecifier/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantBaseClassInitializer/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantBooleanExpressionArgument/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantCastExpression/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantComplexityInComparison/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantConditionalExpression/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantConstSpecifier/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantControlFlowJump/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantDereferencingAndTakingAddress/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantElaboratedTypeSpecifier/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantElseKeyword/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantElseKeywordInsideCompoundStatement/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantEmptyDeclaration/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantEmptyStatement/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantExportKeyword/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantFwdClassOrEnumSpecifier/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantInlineSpecifier/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantLambdaParameterList/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantMemberInitializer/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantNamespaceDefinition/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantParentheses/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantQualifier/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantQualifierADL/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantStaticSpecifierOnMemberAllocationFunction/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantStaticSpecifierOnThreadLocalLocalVariable/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantTemplateArguments/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantTemplateKeyword/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantTypenameKeyword/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantVoidArgumentList/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantZeroInitializerInAggregateInitialization/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppReinterpretCastFromVoidPtr/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRemoveRedundantBraces/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppReplaceMemsetWithZeroInitialization/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppReplaceTieWithStructuredBinding/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppReturnNoValueInNonVoidFunction/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppSmartPointerVsMakeFunction/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppSomeObjectMembersMightNotBeInitialized/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppSpecialFunctionWithoutNoexceptSpecification/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppStaticAssertFailure/@EntryIndexedValue" value="ERROR" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppStaticDataMemberInUnnamedStruct/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppStaticSpecifierOnAnonymousNamespaceMember/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppStringLiteralToCharPointerConversion/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppTabsAreDisallowed/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppTemplateArgumentsCanBeDeduced/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppTemplateParameterNeverUsed/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppTemplateParameterShadowing/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppThrowExpressionCanBeReplacedWithRethrow/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppTooWideScope/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppTooWideScopeInitStatement/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppTypeAliasNeverUsed/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUninitializedDependentBaseClass/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUninitializedNonStaticDataMember/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUnionMemberOfReferenceType/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUnmatchedPragmaEndRegionDirective/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUnmatchedPragmaRegionDirective/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUnnamedNamespaceInHeaderFile/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUnnecessaryWhitespace/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUnsignedZeroComparison/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUnusedIncludeDirective/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUseAlgorithmWithCount/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUseAssociativeContains/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUseAuto/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUseAutoForNumeric/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUseElementsView/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUseEraseAlgorithm/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUseFamiliarTemplateSyntaxForGenericLambdas/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUseRangeAlgorithm/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUseStdSize/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUseStructuredBinding/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUseTypeTraitAlias/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUserDefinedLiteralSuffixDoesNotStartWithUnderscore/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUsingResultOfAssignmentAsCondition/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppVariableCanBeMadeConstexpr/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppVirtualFunctionCallInsideCtor/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppVirtualFunctionInFinalClass/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppVolatileParameterInDeclaration/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppWarningDirective/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppWrongIncludesOrder/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppWrongSlashesInIncludeDirective/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppZeroConstantCanBeReplacedWithNullptr/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppZeroValuedExpressionUsedAsNullPointer/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=IdentifierTypo/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=IfStdIsConstantEvaluatedCanBeReplaced/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=StdIsConstantEvaluatedWillAlwaysEvaluateToConstant/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=StringLiteralTypo/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
</component>
</project>

14
.idea/misc.xml generated
View File

@@ -1,14 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CMakePythonSetting">
<option name="pythonIntegrationState" value="YES" />
</component>
<component name="CMakeWorkspace" PROJECT_DIR="$PROJECT_DIR$" />
<component name="MaterialThemeProjectNewConfig">
<option name="metadata">
<MTProjectMetadataState>
<option name="userId" value="-4755b0c8:1993c71e271:-7fed" />
</MTProjectMetadataState>
</option>
</component>
</project>

File diff suppressed because one or more lines are too long

View File

@@ -1,68 +1,297 @@
# ==============================================================================
# 大连民族大学创一工作室 达妙开发板脚手架-CMake构建系统
# ==============================================================================
cmake_minimum_required(VERSION 3.22) cmake_minimum_required(VERSION 3.22)
# #欢迎提示
# This file is generated only once, message(NOTICE ">> 欢迎使用创一工作室达妙开发板脚手架的CMake构建系统")
# and is not re-generated if converter is called multiple times. message(NOTICE ">> 如报错信息为未安装环境或找不到可用编译器请先安装STM32CubeCLT可以在ST官网找到下载链接 https://www.st.com/en/development-tools/stm32cubeclt.html")
# message(NOTICE ">> 安装完STM32CubeCLT后记得重启刷新编译器环境变量或自己添加到环境变量PATH中")
# User is free to modify the file as much as necessary message(NOTICE ">> 如使用Makefile需要自己添加Make构建工具的环境变量网上搜一搜教程都有的")
# message(NOTICE ">> 本项目默认使用arm-none-eabi-gcc如需使用starm-clang请注意编译优化设置截止发布前暂无法使用starm-clang构建的elf进行debug无法打断点")
# Setup compiler settings # ------------------------------------------------------------------------------
# 1. 机器人兵种选择开关 (Robot Configuration)
# 请将当前需要编译的机器人设置为 ON其余保持 OFF
# ------------------------------------------------------------------------------
option(INFANTRY_MEC "1. 麦轮步兵 (Mecanum Infantry)" OFF)
option(INFANTRY_HALF_STEER "2. 半舵步兵 (Half-Steer Infantry)" OFF)
option(HERO_MEC "3. 麦轮英雄 (Mecanum Hero)" OFF)
option(SENTRY_STEER "4. 舵轮哨兵 (Steer Sentry)" OFF)
option(INFANTRY_TRANSFORM "5. 变形步兵 (Transformable Infantry)" OFF)
option(BALANCE_SERIAL "6. 串联腿平衡步兵 (Serial-Leg Balance)" OFF)
option(BALANCE_PARALLEL "7. 并联腿平衡步兵 (Parallel-Leg Balance)" OFF)
option(DART "8. 飞镖架 (Dart System)" OFF)
option(DEV_DEBUG "9. 调试模式 (Debug Mode)" ON)
# ------------------------------------------------------------------------------
# 2. 安全互斥检查 (Safety Check)
# ------------------------------------------------------------------------------
set(ROBOT_ENABLE_COUNT 0)
if(INFANTRY_MEC)
math(EXPR ROBOT_ENABLE_COUNT "${ROBOT_ENABLE_COUNT}+1")
endif()
if(INFANTRY_HALF_STEER)
math(EXPR ROBOT_ENABLE_COUNT "${ROBOT_ENABLE_COUNT}+1")
endif()
if(HERO_MEC)
math(EXPR ROBOT_ENABLE_COUNT "${ROBOT_ENABLE_COUNT}+1")
endif()
if(SENTRY_STEER)
math(EXPR ROBOT_ENABLE_COUNT "${ROBOT_ENABLE_COUNT}+1")
endif()
if(INFANTRY_TRANSFORM)
math(EXPR ROBOT_ENABLE_COUNT "${ROBOT_ENABLE_COUNT}+1")
endif()
if(BALANCE_SERIAL)
math(EXPR ROBOT_ENABLE_COUNT "${ROBOT_ENABLE_COUNT}+1")
endif()
if(BALANCE_PARALLEL)
math(EXPR ROBOT_ENABLE_COUNT "${ROBOT_ENABLE_COUNT}+1")
endif()
if(DART)
math(EXPR ROBOT_ENABLE_COUNT "${ROBOT_ENABLE_COUNT}+1")
endif()
if(DEV_DEBUG)
math(EXPR ROBOT_ENABLE_COUNT "${ROBOT_ENABLE_COUNT}+1")
endif()
if(ROBOT_ENABLE_COUNT GREATER 1)
message(FATAL_ERROR "【错误】检测到同时开启了 ${ROBOT_ENABLE_COUNT} 个兵种!请检查 option 设置,确保只有一个为 ON。")
elseif(ROBOT_ENABLE_COUNT EQUAL 0)
message(WARNING "【警告】未选择任何兵种!将仅编译通用库,无法生成有效固件。")
endif()
# ------------------------------------------------------------------------------
# 3. 基础项目配置 (Project Setup)
# ------------------------------------------------------------------------------
include(cmake/DetectToolchain.cmake)
project(TronOneH7_Scaffold)
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
set(CMAKE_EXPORT_COMPILE_COMMANDS TRUE)
enable_language(C CXX ASM)
# 标准设置 (C23 / C++23)
set(CMAKE_C_STANDARD 23) set(CMAKE_C_STANDARD 23)
set(CMAKE_C_STANDARD_REQUIRED ON) set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_EXTENSIONS ON) set(CMAKE_C_EXTENSIONS ON)
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS ON)
# Define the build type #标准提示
if(NOT CMAKE_BUILD_TYPE) message(NOTICE ">> 本项目使用 C ${CMAKE_C_STANDARD} 及 C++ ${CMAKE_CXX_STANDARD} 标准")
# 根据构建类型设置不同的编译选项
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
set(CMAKE_C_FLAGS_DEBUG "-O0 -g") # 调试模式:无优化,包含调试信息
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
elseif (CMAKE_BUILD_TYPE STREQUAL "Release")
set(CMAKE_C_FLAGS_RELEASE "-O3") # 发布模式:最高级别优化
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
elseif (CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g") # 带调试信息的发布模式:中等优化,包含调试信息
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g")
elseif (CMAKE_BUILD_TYPE STREQUAL "MinSizeRel")
set(CMAKE_C_FLAGS_MINSIZEREL "-Os") # 最小体积模式:优化代码大小
set(CMAKE_CXX_FLAGS_MINSIZEREL "-Os")
endif ()
# 输出编译器路径
message(NOTICE ">> [Assembler] 找到的 C 编译器路径: ${CMAKE_C_COMPILER}")
message(NOTICE ">> [Assembler] 找到的 C++ 编译器路径: ${CMAKE_CXX_COMPILER}")
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Debug") set(CMAKE_BUILD_TYPE "Debug")
endif() endif ()
# Set the project name # 编译器标志
set(CMAKE_PROJECT_NAME TronOneH7_Scaffold) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -frtti -Wno-volatile")
# Enable compile command to ease indexing with e.g. clangd message(NOTICE ">> [Build Type] 当前构建类型: ${CMAKE_BUILD_TYPE}")
set(CMAKE_EXPORT_COMPILE_COMMANDS TRUE)
# Core project settings # ------------------------------------------------------------------------------
project(${CMAKE_PROJECT_NAME}) # 4. 目标与库链接 (Target & Libraries)
message("Build type: " ${CMAKE_BUILD_TYPE}) # ------------------------------------------------------------------------------
# Enable CMake support for ASM and C languages
enable_language(C ASM)
# Create an executable object type
add_executable(${CMAKE_PROJECT_NAME}) add_executable(${CMAKE_PROJECT_NAME})
# Add STM32CubeMX generated sources include(CompileOptions)
# FindModules
# 只有运行了这个CMake 才会去执行 git clone 云端modules 并配置它的路径
include(FindModules)
# 添加 STM32CubeMX 底层库
add_subdirectory(cmake/stm32cubemx) add_subdirectory(cmake/stm32cubemx)
# Link directories setup # 链接库
target_link_directories(${CMAKE_PROJECT_NAME} PRIVATE
# Add user defined library search paths
)
# Add sources to executable
target_sources(${CMAKE_PROJECT_NAME} PRIVATE
# Add user sources here
)
# Add include paths
target_include_directories(${CMAKE_PROJECT_NAME} PRIVATE
# Add user defined include paths
)
# Add project symbols (macros)
target_compile_definitions(${CMAKE_PROJECT_NAME} PRIVATE
# Add user defined symbols
)
# Remove wrong libob.a library dependency when using cpp files
list(REMOVE_ITEM CMAKE_C_IMPLICIT_LINK_LIBRARIES ob)
# Add linked libraries
target_link_libraries(${CMAKE_PROJECT_NAME} target_link_libraries(${CMAKE_PROJECT_NAME}
stm32cubemx stm32cubemx
# 因为 ems 是通过 FindModules 下载的外部库,不在 User_Code 里。
# Add user defined libraries # 链接这个库会自动把 ems 的头文件路径加入到工程里。
ems
${CMAKE_SOURCE_DIR}/Drivers/CMSIS/DSP/Lib/GCC/libarm_cortexM7lfdp_math.a
)
link_libraries("Drivers/CMSIS/DSP/Lib/GCC/libarm_cortexM7lfdp_math.a")
include_directories(
./Drivers/CMSIS/Include
./Drivers/CMSIS/DSP/Include/
)
link_directories(
./Drivers/CMSIS/DSP/Lib/GCC
)
# ==============================================================================
# 5. 源码与头文件管理 (Source & Header Management)
# ==============================================================================
# ------------------------------------------------------------------------------
# A. 头文件管理:全自动模式,扫描 User_Code 下的所有头文件。
# ------------------------------------------------------------------------------
message(NOTICE ">> [Searching All Header] 正在全自动递归扫描 User_Code 下所有头文件路径...")
file(GLOB_RECURSE USER_HEADERS "${CMAKE_SOURCE_DIR}/User_Code/*.h" "${CMAKE_SOURCE_DIR}/User_Code/*.hpp")
foreach (header ${USER_HEADERS})
get_filename_component(dir ${header} DIRECTORY) # 获取头文件所在目录
target_include_directories(${CMAKE_PROJECT_NAME} PRIVATE ${dir}) # 添加为私有包含目录
endforeach ()
# ------------------------------------------------------------------------------
# B. 源文件管理:半自动模式 (防止兵种冲突)
# 通用部分全自动扫描,特定兵种部分根据开关选择性扫描。
# ------------------------------------------------------------------------------
message(NOTICE ">> [INFO] 正在全自动递归扫描 User_Code/bsp下所有源文件路径...")
message(NOTICE ">> [INFO] 正在全自动递归扫描 User_Code/module下所有源文件路径...")
message(NOTICE ">> [INFO] 正在全自动递归扫描 User_Code/application下所有通用APP模块的源文件路径...")
# 1. 添加通用代码 (BSP & Module & Application 通用框架)
# 包含 bsp, module 以及 application 下的通用组件
file(GLOB_RECURSE COMMON_SOURCES
"${PROJECT_SOURCE_DIR}/User_Code/bsp/*.c"
"${PROJECT_SOURCE_DIR}/User_Code/bsp/*.cpp"
"${PROJECT_SOURCE_DIR}/User_Code/module/*.c"
"${PROJECT_SOURCE_DIR}/User_Code/module/*.cpp"
# 包含 application 根目录下的 robot.c 等文件 (不递归) todo 需重写
"${PROJECT_SOURCE_DIR}/User_Code/application/*.c"
"${PROJECT_SOURCE_DIR}/User_Code/application/*.cpp"
# 包含 application 下的通用模块 (根据目录结构递归) todo 需重写
"${PROJECT_SOURCE_DIR}/User_Code/application/chassis_app/*.c" "${PROJECT_SOURCE_DIR}/User_Code/application/chassis_app/*.cpp"
"${PROJECT_SOURCE_DIR}/User_Code/application/gimbal_app/*.c" "${PROJECT_SOURCE_DIR}/User_Code/application/gimbal_app/*.cpp" "${PROJECT_SOURCE_DIR}/User_Code/application/shoot_app/*.c" "${PROJECT_SOURCE_DIR}/User_Code/application/shoot_app/*.cpp"
"${PROJECT_SOURCE_DIR}/User_Code/application/indicator_app/*.c" "${PROJECT_SOURCE_DIR}/User_Code/application/indicator_app/*.cpp"
"${PROJECT_SOURCE_DIR}/User_Code/application/vision_app/*.c" "${PROJECT_SOURCE_DIR}/User_Code/application/vision_app/*.cpp"
)
target_sources(${CMAKE_PROJECT_NAME} PRIVATE ${COMMON_SOURCES})
list(LENGTH COMMON_SOURCES COMMON_SOURCES_COUNT)
# 输出统计结果
message(NOTICE ">> [INFO] 通用库源文件扫描结束,在通用库中共扫描到 ${COMMON_SOURCES_COUNT} 个源文件")
# 2. 根据开关添加特定兵种代码 (Specific Code)
# 定义一个变量来存储当前激活的 App 路径
set(ACTIVE_APP_DIR "")
# 1. 麦轮步兵
if(INFANTRY_MEC)
message(WARNING ">> 当前构建兵种: 麦轮步兵 (INFANTRY_MEC)")
set(ACTIVE_APP_DIR "${PROJECT_SOURCE_DIR}/User_Code/user_task/infantry_mec")
target_compile_definitions(${CMAKE_PROJECT_NAME} PRIVATE INFANTRY_MEC)
message(NOTICE ">> [Specific Source] 开始扫描各兵种对应代码,当前选中的兵种为: 麦轮步兵 (INFANTRY_MEC)")
# 2. 半舵步兵
elseif(INFANTRY_HALF_STEER)
message(NOTICE ">> 当前构建兵种: 半舵步兵 (INFANTRY_HALF_STEER)")
set(ACTIVE_APP_DIR "${PROJECT_SOURCE_DIR}/User_Code/user_task/infantry_half_steer")
target_compile_definitions(${CMAKE_PROJECT_NAME} PRIVATE INFANTRY_HALF_STEER)
message(NOTICE ">> [Specific Source] 开始扫描各兵种对应代码,当前选中的兵种为: 半舵步兵 (INFANTRY_HALF_STEER)")
# 3. 麦轮英雄
elseif(HERO_MEC)
message(NOTICE ">> 当前构建兵种: 麦轮英雄 (HERO_MEC)")
set(ACTIVE_APP_DIR "${PROJECT_SOURCE_DIR}/User_Code/user_task/hero_mec")
target_compile_definitions(${CMAKE_PROJECT_NAME} PRIVATE HERO_MEC)
message(NOTICE ">> [Specific Source] 开始扫描各兵种对应代码,当前选中的兵种为: 麦轮英雄 (HERO_MEC)")
# 4. 舵轮哨兵
elseif(SENTRY_STEER)
message(NOTICE ">> 当前构建兵种: 舵轮哨兵 (SENTRY_STEER)")
set(ACTIVE_APP_DIR "${PROJECT_SOURCE_DIR}/User_Code/user_task/sentry_steer")
target_compile_definitions(${CMAKE_PROJECT_NAME} PRIVATE SENTRY_STEER SENTRY)
message(NOTICE ">> [Specific Source] 开始扫描各兵种对应代码,当前选中的兵种为: 舵轮哨兵 (SENTRY_STEER)")
# 5. 变形步兵
elseif(INFANTRY_TRANSFORM)
message(NOTICE ">> 当前构建兵种: 变形步兵 (INFANTRY_TRANSFORM)")
set(ACTIVE_APP_DIR "${PROJECT_SOURCE_DIR}/User_Code/user_task/infantry_transform")
target_compile_definitions(${CMAKE_PROJECT_NAME} PRIVATE INFANTRY_TRANSFORM)
message(NOTICE ">> [Specific Source] 开始扫描各兵种对应代码,当前选中的兵种为: 变形步兵 (INFANTRY_TRANSFORM)")
# 6. 串联腿平衡步兵
elseif(BALANCE_SERIAL)
message(NOTICE ">> 当前构建兵种: 串联腿平衡步兵 (BALANCE_SERIAL)")
set(ACTIVE_APP_DIR "${PROJECT_SOURCE_DIR}/User_Code/user_task/balance_serial")
target_compile_definitions(${CMAKE_PROJECT_NAME} PRIVATE BALANCE_SERIAL BALANCE)
message(NOTICE ">> [Specific Source] 开始扫描各兵种对应代码,当前选中的兵种为: 串联腿平衡步兵 (BALANCE_SERIAL)")
# 7. 并联腿平衡步兵
elseif(BALANCE_PARALLEL)
message(NOTICE ">> 当前构建兵种: 并联腿平衡步兵 (BALANCE_PARALLEL)")
set(ACTIVE_APP_DIR "${PROJECT_SOURCE_DIR}/User_Code/user_task/balance_parallel")
target_compile_definitions(${CMAKE_PROJECT_NAME} PRIVATE BALANCE_PARALLEL BALANCE)
message(NOTICE ">> [Specific Source] 开始扫描各兵种对应代码,当前选中的兵种为: 并联腿平衡步兵 (BALANCE_PARALLEL)")
# 8. 飞镖架
elseif(DART)
message(NOTICE ">> 当前构建兵种: 飞镖架 (DART)")
set(ACTIVE_APP_DIR "${PROJECT_SOURCE_DIR}/User_Code/user_task/dart")
target_compile_definitions(${CMAKE_PROJECT_NAME} PRIVATE DART)
message(NOTICE ">> [Specific Source] 开始扫描各兵种对应代码,当前选中的兵种为: 飞镖架 (DART)")
# 9. 调试模式
elseif(DEV_DEBUG)
message(NOTICE ">> 当前构建兵种: 调试模式 (DEV_DEBUG)")
set(ACTIVE_APP_DIR "${PROJECT_SOURCE_DIR}/User_Code/user_task/dev_tasks")
target_compile_definitions(${CMAKE_PROJECT_NAME} PRIVATE DEV_DEBUG)
message(NOTICE ">> [Specific Source] 开始扫描各兵种对应代码,当前选中的兵种为: 调试模式 (DEV_DEBUG)")
endif()
# 执行特定代码的添加
if(ACTIVE_APP_DIR)
if(EXISTS "${ACTIVE_APP_DIR}")
# 添加该兵种目录下的所有源码
file(GLOB_RECURSE APP_SOURCES "${ACTIVE_APP_DIR}/*.c" "${ACTIVE_APP_DIR}/*.cpp")
# --- 新增:统计文件数量 ---
list(LENGTH APP_SOURCES APP_SOURCES_COUNT)
message(NOTICE ">> [INFO] 兵种对应的源文件目录: ${ACTIVE_APP_DIR}")
message(NOTICE ">> [INFO] 已添加源文件数量: ${APP_SOURCES_COUNT}")
target_sources(${CMAKE_PROJECT_NAME} PRIVATE ${APP_SOURCES})
else()
message(FATAL_ERROR ">> [ERROR] 选中的兵种目录不存在: ${ACTIVE_APP_DIR}")
endif()
endif()
# ------------------------------------------------------------------------------
# 6. 其他设置
# ------------------------------------------------------------------------------
# 其他自定义头文件路径(如果还有不在 User_Code 里的)
target_include_directories(${CMAKE_PROJECT_NAME} PRIVATE
# 可以在此处添加其他包含目录
)
target_compile_definitions(${CMAKE_PROJECT_NAME} PRIVATE
# RM_REFEREE
) )

View File

@@ -1,38 +0,0 @@
{
"version": 3,
"configurePresets": [
{
"name": "default",
"hidden": true,
"generator": "Ninja",
"binaryDir": "${sourceDir}/build/${presetName}",
"toolchainFile": "${sourceDir}/cmake/starm-clang.cmake",
"cacheVariables": {
}
},
{
"name": "Debug",
"inherits": "default",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "Release",
"inherits": "default",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
}
],
"buildPresets": [
{
"name": "Debug",
"configurePreset": "Debug"
},
{
"name": "Release",
"configurePreset": "Release"
}
]
}

View File

@@ -67,8 +67,8 @@
#define configCPU_CLOCK_HZ ( SystemCoreClock ) #define configCPU_CLOCK_HZ ( SystemCoreClock )
#define configTICK_RATE_HZ ((TickType_t)1000) #define configTICK_RATE_HZ ((TickType_t)1000)
#define configMAX_PRIORITIES ( 56 ) #define configMAX_PRIORITIES ( 56 )
#define configMINIMAL_STACK_SIZE ((uint16_t)128) #define configMINIMAL_STACK_SIZE ((uint16_t)256)
#define configTOTAL_HEAP_SIZE ((size_t)15360) #define configTOTAL_HEAP_SIZE ((size_t)30720)
#define configMAX_TASK_NAME_LEN ( 16 ) #define configMAX_TASK_NAME_LEN ( 16 )
#define configUSE_TRACE_FACILITY 1 #define configUSE_TRACE_FACILITY 1
#define configUSE_16_BIT_TICKS 0 #define configUSE_16_BIT_TICKS 0
@@ -93,7 +93,7 @@
#define configUSE_TIMERS 1 #define configUSE_TIMERS 1
#define configTIMER_TASK_PRIORITY ( 2 ) #define configTIMER_TASK_PRIORITY ( 2 )
#define configTIMER_QUEUE_LENGTH 10 #define configTIMER_QUEUE_LENGTH 10
#define configTIMER_TASK_STACK_DEPTH 256 #define configTIMER_TASK_STACK_DEPTH 512
/* CMSIS-RTOS V2 flags */ /* CMSIS-RTOS V2 flags */
#define configUSE_OS2_THREAD_SUSPEND_RESUME 1 #define configUSE_OS2_THREAD_SUSPEND_RESUME 1

View File

@@ -32,12 +32,15 @@ extern "C" {
/* USER CODE END Includes */ /* USER CODE END Includes */
extern ADC_HandleTypeDef hadc1;
extern ADC_HandleTypeDef hadc3; extern ADC_HandleTypeDef hadc3;
/* USER CODE BEGIN Private defines */ /* USER CODE BEGIN Private defines */
/* USER CODE END Private defines */ /* USER CODE END Private defines */
void MX_ADC1_Init(void);
void MX_ADC3_Init(void); void MX_ADC3_Init(void);
/* USER CODE BEGIN Prototypes */ /* USER CODE BEGIN Prototypes */

View File

@@ -1,52 +0,0 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file iwdg.h
* @brief This file contains all the function prototypes for
* the iwdg.c file
******************************************************************************
* @attention
*
* Copyright (c) 2025 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.
*
******************************************************************************
*/
/* USER CODE END Header */
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __IWDG_H__
#define __IWDG_H__
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "main.h"
/* USER CODE BEGIN Includes */
/* USER CODE END Includes */
extern IWDG_HandleTypeDef hiwdg1;
/* USER CODE BEGIN Private defines */
/* USER CODE END Private defines */
void MX_IWDG1_Init(void);
/* USER CODE BEGIN Prototypes */
/* USER CODE END Prototypes */
#ifdef __cplusplus
}
#endif
#endif /* __IWDG_H__ */

View File

@@ -57,14 +57,20 @@ void Error_Handler(void);
/* USER CODE END EFP */ /* USER CODE END EFP */
/* Private defines -----------------------------------------------------------*/ /* Private defines -----------------------------------------------------------*/
#define Power2_Pin GPIO_PIN_13
#define Power2_GPIO_Port GPIOC
#define Power1_Pin GPIO_PIN_14
#define Power1_GPIO_Port GPIOC
#define Power_5V_EN_Pin GPIO_PIN_15
#define Power_5V_EN_GPIO_Port GPIOC
#define ACC_CS_Pin GPIO_PIN_0 #define ACC_CS_Pin GPIO_PIN_0
#define ACC_CS_GPIO_Port GPIOC #define ACC_CS_GPIO_Port GPIOC
#define GYRO_CS_Pin GPIO_PIN_3 #define GYRO_CS_Pin GPIO_PIN_3
#define GYRO_CS_GPIO_Port GPIOC #define GYRO_CS_GPIO_Port GPIOC
#define pump1_Pin GPIO_PIN_0 #define power2_Pin GPIO_PIN_0
#define pump1_GPIO_Port GPIOA #define power2_GPIO_Port GPIOA
#define pump2_Pin GPIO_PIN_2 #define power1_Pin GPIO_PIN_2
#define pump2_GPIO_Port GPIOA #define power1_GPIO_Port GPIOA
#define pump3_Pin GPIO_PIN_9 #define pump3_Pin GPIO_PIN_9
#define pump3_GPIO_Port GPIOE #define pump3_GPIO_Port GPIOE
#define ACC_INT_Pin GPIO_PIN_10 #define ACC_INT_Pin GPIO_PIN_10

View File

@@ -36,12 +36,15 @@ extern SPI_HandleTypeDef hspi1;
extern SPI_HandleTypeDef hspi2; extern SPI_HandleTypeDef hspi2;
extern SPI_HandleTypeDef hspi6;
/* USER CODE BEGIN Private defines */ /* USER CODE BEGIN Private defines */
/* USER CODE END Private defines */ /* USER CODE END Private defines */
void MX_SPI1_Init(void); void MX_SPI1_Init(void);
void MX_SPI2_Init(void); void MX_SPI2_Init(void);
void MX_SPI6_Init(void);
/* USER CODE BEGIN Prototypes */ /* USER CODE BEGIN Prototypes */

View File

@@ -61,7 +61,7 @@
/* #define HAL_OSPI_MODULE_ENABLED */ /* #define HAL_OSPI_MODULE_ENABLED */
/* #define HAL_I2S_MODULE_ENABLED */ /* #define HAL_I2S_MODULE_ENABLED */
/* #define HAL_SMBUS_MODULE_ENABLED */ /* #define HAL_SMBUS_MODULE_ENABLED */
#define HAL_IWDG_MODULE_ENABLED /* #define HAL_IWDG_MODULE_ENABLED */
/* #define HAL_LPTIM_MODULE_ENABLED */ /* #define HAL_LPTIM_MODULE_ENABLED */
/* #define HAL_LTDC_MODULE_ENABLED */ /* #define HAL_LTDC_MODULE_ENABLED */
/* #define HAL_QSPI_MODULE_ENABLED */ /* #define HAL_QSPI_MODULE_ENABLED */

View File

@@ -52,14 +52,18 @@ void MemManage_Handler(void);
void BusFault_Handler(void); void BusFault_Handler(void);
void UsageFault_Handler(void); void UsageFault_Handler(void);
void DebugMon_Handler(void); void DebugMon_Handler(void);
void DMA1_Stream0_IRQHandler(void);
void DMA1_Stream1_IRQHandler(void); void DMA1_Stream1_IRQHandler(void);
void DMA1_Stream2_IRQHandler(void); void DMA1_Stream2_IRQHandler(void);
void DMA1_Stream3_IRQHandler(void); void DMA1_Stream3_IRQHandler(void);
void DMA1_Stream4_IRQHandler(void); void DMA1_Stream4_IRQHandler(void);
void DMA1_Stream5_IRQHandler(void); void DMA1_Stream5_IRQHandler(void);
void DMA1_Stream6_IRQHandler(void); void DMA1_Stream6_IRQHandler(void);
void ADC_IRQHandler(void);
void FDCAN1_IT0_IRQHandler(void); void FDCAN1_IT0_IRQHandler(void);
void FDCAN2_IT0_IRQHandler(void); void FDCAN2_IT0_IRQHandler(void);
void FDCAN1_IT1_IRQHandler(void);
void FDCAN2_IT1_IRQHandler(void);
void SPI1_IRQHandler(void); void SPI1_IRQHandler(void);
void SPI2_IRQHandler(void); void SPI2_IRQHandler(void);
void USART1_IRQHandler(void); void USART1_IRQHandler(void);
@@ -78,6 +82,7 @@ void OTG_HS_IRQHandler(void);
void UART7_IRQHandler(void); void UART7_IRQHandler(void);
void USART10_IRQHandler(void); void USART10_IRQHandler(void);
void FDCAN3_IT0_IRQHandler(void); void FDCAN3_IT0_IRQHandler(void);
void FDCAN3_IT1_IRQHandler(void);
void TIM23_IRQHandler(void); void TIM23_IRQHandler(void);
/* USER CODE BEGIN EFP */ /* USER CODE BEGIN EFP */

View File

@@ -24,8 +24,82 @@
/* USER CODE END 0 */ /* USER CODE END 0 */
ADC_HandleTypeDef hadc1;
ADC_HandleTypeDef hadc3; ADC_HandleTypeDef hadc3;
DMA_HandleTypeDef hdma_adc1;
/* ADC1 init function */
void MX_ADC1_Init(void)
{
/* USER CODE BEGIN ADC1_Init 0 */
/* USER CODE END ADC1_Init 0 */
ADC_MultiModeTypeDef multimode = {0};
ADC_ChannelConfTypeDef sConfig = {0};
/* USER CODE BEGIN ADC1_Init 1 */
/* USER CODE END ADC1_Init 1 */
/** Common config
*/
hadc1.Instance = ADC1;
hadc1.Init.ClockPrescaler = ADC_CLOCK_ASYNC_DIV64;
hadc1.Init.Resolution = ADC_RESOLUTION_16B;
hadc1.Init.ScanConvMode = ADC_SCAN_ENABLE;
hadc1.Init.EOCSelection = ADC_EOC_SINGLE_CONV;
hadc1.Init.LowPowerAutoWait = DISABLE;
hadc1.Init.ContinuousConvMode = ENABLE;
hadc1.Init.NbrOfConversion = 2;
hadc1.Init.DiscontinuousConvMode = DISABLE;
hadc1.Init.ExternalTrigConv = ADC_SOFTWARE_START;
hadc1.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE;
hadc1.Init.ConversionDataManagement = ADC_CONVERSIONDATA_DMA_CIRCULAR;
hadc1.Init.Overrun = ADC_OVR_DATA_PRESERVED;
hadc1.Init.LeftBitShift = ADC_LEFTBITSHIFT_NONE;
hadc1.Init.OversamplingMode = DISABLE;
hadc1.Init.Oversampling.Ratio = 1;
if (HAL_ADC_Init(&hadc1) != HAL_OK)
{
Error_Handler();
}
/** Configure the ADC multi-mode
*/
multimode.Mode = ADC_MODE_INDEPENDENT;
if (HAL_ADCEx_MultiModeConfigChannel(&hadc1, &multimode) != HAL_OK)
{
Error_Handler();
}
/** Configure Regular Channel
*/
sConfig.Channel = ADC_CHANNEL_4;
sConfig.Rank = ADC_REGULAR_RANK_1;
sConfig.SamplingTime = ADC_SAMPLETIME_1CYCLE_5;
sConfig.SingleDiff = ADC_SINGLE_ENDED;
sConfig.OffsetNumber = ADC_OFFSET_NONE;
sConfig.Offset = 0;
sConfig.OffsetSignedSaturation = DISABLE;
if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
{
Error_Handler();
}
/** Configure Regular Channel
*/
sConfig.Rank = ADC_REGULAR_RANK_2;
if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN ADC1_Init 2 */
/* USER CODE END ADC1_Init 2 */
}
/* ADC3 init function */ /* ADC3 init function */
void MX_ADC3_Init(void) void MX_ADC3_Init(void)
{ {
@@ -88,30 +162,55 @@ void MX_ADC3_Init(void)
void HAL_ADC_MspInit(ADC_HandleTypeDef* adcHandle) void HAL_ADC_MspInit(ADC_HandleTypeDef* adcHandle)
{ {
RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; GPIO_InitTypeDef GPIO_InitStruct = {0};
if(adcHandle->Instance==ADC3) if(adcHandle->Instance==ADC1)
{ {
/* USER CODE BEGIN ADC3_MspInit 0 */ /* USER CODE BEGIN ADC1_MspInit 0 */
/* USER CODE END ADC3_MspInit 0 */ /* USER CODE END ADC1_MspInit 0 */
/* ADC1 clock enable */
__HAL_RCC_ADC12_CLK_ENABLE();
/** Initializes the peripherals clock __HAL_RCC_GPIOC_CLK_ENABLE();
*/ /**ADC1 GPIO Configuration
PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_ADC; PC4 ------> ADC1_INP4
PeriphClkInitStruct.PLL2.PLL2M = 2; */
PeriphClkInitStruct.PLL2.PLL2N = 16; GPIO_InitStruct.Pin = GPIO_PIN_4;
PeriphClkInitStruct.PLL2.PLL2P = 2; GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
PeriphClkInitStruct.PLL2.PLL2Q = 2; GPIO_InitStruct.Pull = GPIO_NOPULL;
PeriphClkInitStruct.PLL2.PLL2R = 2; HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
PeriphClkInitStruct.PLL2.PLL2RGE = RCC_PLL2VCIRANGE_3;
PeriphClkInitStruct.PLL2.PLL2VCOSEL = RCC_PLL2VCOWIDE; /* ADC1 DMA Init */
PeriphClkInitStruct.PLL2.PLL2FRACN = 0; /* ADC1 Init */
PeriphClkInitStruct.AdcClockSelection = RCC_ADCCLKSOURCE_PLL2; hdma_adc1.Instance = DMA1_Stream2;
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) hdma_adc1.Init.Request = DMA_REQUEST_ADC1;
hdma_adc1.Init.Direction = DMA_PERIPH_TO_MEMORY;
hdma_adc1.Init.PeriphInc = DMA_PINC_DISABLE;
hdma_adc1.Init.MemInc = DMA_MINC_ENABLE;
hdma_adc1.Init.PeriphDataAlignment = DMA_PDATAALIGN_HALFWORD;
hdma_adc1.Init.MemDataAlignment = DMA_MDATAALIGN_HALFWORD;
hdma_adc1.Init.Mode = DMA_CIRCULAR;
hdma_adc1.Init.Priority = DMA_PRIORITY_LOW;
hdma_adc1.Init.FIFOMode = DMA_FIFOMODE_DISABLE;
if (HAL_DMA_Init(&hdma_adc1) != HAL_OK)
{ {
Error_Handler(); Error_Handler();
} }
__HAL_LINKDMA(adcHandle,DMA_Handle,hdma_adc1);
/* ADC1 interrupt Init */
HAL_NVIC_SetPriority(ADC_IRQn, 5, 0);
HAL_NVIC_EnableIRQ(ADC_IRQn);
/* USER CODE BEGIN ADC1_MspInit 1 */
/* USER CODE END ADC1_MspInit 1 */
}
else if(adcHandle->Instance==ADC3)
{
/* USER CODE BEGIN ADC3_MspInit 0 */
/* USER CODE END ADC3_MspInit 0 */
/* ADC3 clock enable */ /* ADC3 clock enable */
__HAL_RCC_ADC3_CLK_ENABLE(); __HAL_RCC_ADC3_CLK_ENABLE();
/* USER CODE BEGIN ADC3_MspInit 1 */ /* USER CODE BEGIN ADC3_MspInit 1 */
@@ -123,7 +222,29 @@ void HAL_ADC_MspInit(ADC_HandleTypeDef* adcHandle)
void HAL_ADC_MspDeInit(ADC_HandleTypeDef* adcHandle) void HAL_ADC_MspDeInit(ADC_HandleTypeDef* adcHandle)
{ {
if(adcHandle->Instance==ADC3) if(adcHandle->Instance==ADC1)
{
/* USER CODE BEGIN ADC1_MspDeInit 0 */
/* USER CODE END ADC1_MspDeInit 0 */
/* Peripheral clock disable */
__HAL_RCC_ADC12_CLK_DISABLE();
/**ADC1 GPIO Configuration
PC4 ------> ADC1_INP4
*/
HAL_GPIO_DeInit(GPIOC, GPIO_PIN_4);
/* ADC1 DMA DeInit */
HAL_DMA_DeInit(adcHandle->DMA_Handle);
/* ADC1 interrupt Deinit */
HAL_NVIC_DisableIRQ(ADC_IRQn);
/* USER CODE BEGIN ADC1_MspDeInit 1 */
/* USER CODE END ADC1_MspDeInit 1 */
}
else if(adcHandle->Instance==ADC3)
{ {
/* USER CODE BEGIN ADC3_MspDeInit 0 */ /* USER CODE BEGIN ADC3_MspDeInit 0 */

View File

@@ -44,6 +44,9 @@ void MX_DMA_Init(void)
__HAL_RCC_DMA1_CLK_ENABLE(); __HAL_RCC_DMA1_CLK_ENABLE();
/* DMA interrupt init */ /* DMA interrupt init */
/* DMA1_Stream0_IRQn interrupt configuration */
HAL_NVIC_SetPriority(DMA1_Stream0_IRQn, 5, 0);
HAL_NVIC_EnableIRQ(DMA1_Stream0_IRQn);
/* DMA1_Stream1_IRQn interrupt configuration */ /* DMA1_Stream1_IRQn interrupt configuration */
HAL_NVIC_SetPriority(DMA1_Stream1_IRQn, 5, 0); HAL_NVIC_SetPriority(DMA1_Stream1_IRQn, 5, 0);
HAL_NVIC_EnableIRQ(DMA1_Stream1_IRQn); HAL_NVIC_EnableIRQ(DMA1_Stream1_IRQn);

View File

@@ -42,9 +42,9 @@ void MX_FDCAN1_Init(void)
hfdcan1.Instance = FDCAN1; hfdcan1.Instance = FDCAN1;
hfdcan1.Init.FrameFormat = FDCAN_FRAME_CLASSIC; hfdcan1.Init.FrameFormat = FDCAN_FRAME_CLASSIC;
hfdcan1.Init.Mode = FDCAN_MODE_NORMAL; hfdcan1.Init.Mode = FDCAN_MODE_NORMAL;
hfdcan1.Init.AutoRetransmission = ENABLE; hfdcan1.Init.AutoRetransmission = DISABLE;
hfdcan1.Init.TransmitPause = DISABLE; hfdcan1.Init.TransmitPause = DISABLE;
hfdcan1.Init.ProtocolException = ENABLE; hfdcan1.Init.ProtocolException = DISABLE;
hfdcan1.Init.NominalPrescaler = 3; hfdcan1.Init.NominalPrescaler = 3;
hfdcan1.Init.NominalSyncJumpWidth = 10; hfdcan1.Init.NominalSyncJumpWidth = 10;
hfdcan1.Init.NominalTimeSeg1 = 29; hfdcan1.Init.NominalTimeSeg1 = 29;
@@ -54,11 +54,11 @@ void MX_FDCAN1_Init(void)
hfdcan1.Init.DataTimeSeg1 = 29; hfdcan1.Init.DataTimeSeg1 = 29;
hfdcan1.Init.DataTimeSeg2 = 10; hfdcan1.Init.DataTimeSeg2 = 10;
hfdcan1.Init.MessageRAMOffset = 0; hfdcan1.Init.MessageRAMOffset = 0;
hfdcan1.Init.StdFiltersNbr = 1; hfdcan1.Init.StdFiltersNbr = 14;
hfdcan1.Init.ExtFiltersNbr = 0; hfdcan1.Init.ExtFiltersNbr = 0;
hfdcan1.Init.RxFifo0ElmtsNbr = 32; hfdcan1.Init.RxFifo0ElmtsNbr = 4;
hfdcan1.Init.RxFifo0ElmtSize = FDCAN_DATA_BYTES_8; hfdcan1.Init.RxFifo0ElmtSize = FDCAN_DATA_BYTES_8;
hfdcan1.Init.RxFifo1ElmtsNbr = 0; hfdcan1.Init.RxFifo1ElmtsNbr = 4;
hfdcan1.Init.RxFifo1ElmtSize = FDCAN_DATA_BYTES_8; hfdcan1.Init.RxFifo1ElmtSize = FDCAN_DATA_BYTES_8;
hfdcan1.Init.RxBuffersNbr = 0; hfdcan1.Init.RxBuffersNbr = 0;
hfdcan1.Init.RxBufferSize = FDCAN_DATA_BYTES_8; hfdcan1.Init.RxBufferSize = FDCAN_DATA_BYTES_8;
@@ -90,9 +90,9 @@ void MX_FDCAN2_Init(void)
hfdcan2.Instance = FDCAN2; hfdcan2.Instance = FDCAN2;
hfdcan2.Init.FrameFormat = FDCAN_FRAME_CLASSIC; hfdcan2.Init.FrameFormat = FDCAN_FRAME_CLASSIC;
hfdcan2.Init.Mode = FDCAN_MODE_NORMAL; hfdcan2.Init.Mode = FDCAN_MODE_NORMAL;
hfdcan2.Init.AutoRetransmission = ENABLE; hfdcan2.Init.AutoRetransmission = DISABLE;
hfdcan2.Init.TransmitPause = DISABLE; hfdcan2.Init.TransmitPause = DISABLE;
hfdcan2.Init.ProtocolException = ENABLE; hfdcan2.Init.ProtocolException = DISABLE;
hfdcan2.Init.NominalPrescaler = 3; hfdcan2.Init.NominalPrescaler = 3;
hfdcan2.Init.NominalSyncJumpWidth = 10; hfdcan2.Init.NominalSyncJumpWidth = 10;
hfdcan2.Init.NominalTimeSeg1 = 29; hfdcan2.Init.NominalTimeSeg1 = 29;
@@ -102,11 +102,11 @@ void MX_FDCAN2_Init(void)
hfdcan2.Init.DataTimeSeg1 = 29; hfdcan2.Init.DataTimeSeg1 = 29;
hfdcan2.Init.DataTimeSeg2 = 10; hfdcan2.Init.DataTimeSeg2 = 10;
hfdcan2.Init.MessageRAMOffset = 853; hfdcan2.Init.MessageRAMOffset = 853;
hfdcan2.Init.StdFiltersNbr = 1; hfdcan2.Init.StdFiltersNbr = 14;
hfdcan2.Init.ExtFiltersNbr = 0; hfdcan2.Init.ExtFiltersNbr = 0;
hfdcan2.Init.RxFifo0ElmtsNbr = 0; hfdcan2.Init.RxFifo0ElmtsNbr = 4;
hfdcan2.Init.RxFifo0ElmtSize = FDCAN_DATA_BYTES_8; hfdcan2.Init.RxFifo0ElmtSize = FDCAN_DATA_BYTES_8;
hfdcan2.Init.RxFifo1ElmtsNbr = 32; hfdcan2.Init.RxFifo1ElmtsNbr = 4;
hfdcan2.Init.RxFifo1ElmtSize = FDCAN_DATA_BYTES_8; hfdcan2.Init.RxFifo1ElmtSize = FDCAN_DATA_BYTES_8;
hfdcan2.Init.RxBuffersNbr = 0; hfdcan2.Init.RxBuffersNbr = 0;
hfdcan2.Init.RxBufferSize = FDCAN_DATA_BYTES_8; hfdcan2.Init.RxBufferSize = FDCAN_DATA_BYTES_8;
@@ -138,29 +138,29 @@ void MX_FDCAN3_Init(void)
hfdcan3.Instance = FDCAN3; hfdcan3.Instance = FDCAN3;
hfdcan3.Init.FrameFormat = FDCAN_FRAME_CLASSIC; hfdcan3.Init.FrameFormat = FDCAN_FRAME_CLASSIC;
hfdcan3.Init.Mode = FDCAN_MODE_NORMAL; hfdcan3.Init.Mode = FDCAN_MODE_NORMAL;
hfdcan3.Init.AutoRetransmission = ENABLE; hfdcan3.Init.AutoRetransmission = DISABLE;
hfdcan3.Init.TransmitPause = DISABLE; hfdcan3.Init.TransmitPause = DISABLE;
hfdcan3.Init.ProtocolException = ENABLE; hfdcan3.Init.ProtocolException = DISABLE;
hfdcan3.Init.NominalPrescaler = 24; hfdcan3.Init.NominalPrescaler = 3;
hfdcan3.Init.NominalSyncJumpWidth = 10; hfdcan3.Init.NominalSyncJumpWidth = 10;
hfdcan3.Init.NominalTimeSeg1 = 2; hfdcan3.Init.NominalTimeSeg1 = 29;
hfdcan3.Init.NominalTimeSeg2 = 2; hfdcan3.Init.NominalTimeSeg2 = 10;
hfdcan3.Init.DataPrescaler = 3; hfdcan3.Init.DataPrescaler = 3;
hfdcan3.Init.DataSyncJumpWidth = 10; hfdcan3.Init.DataSyncJumpWidth = 10;
hfdcan3.Init.DataTimeSeg1 = 29; hfdcan3.Init.DataTimeSeg1 = 29;
hfdcan3.Init.DataTimeSeg2 = 10; hfdcan3.Init.DataTimeSeg2 = 10;
hfdcan3.Init.MessageRAMOffset = 1706; hfdcan3.Init.MessageRAMOffset = 1706;
hfdcan3.Init.StdFiltersNbr = 1; hfdcan3.Init.StdFiltersNbr = 14;
hfdcan3.Init.ExtFiltersNbr = 0; hfdcan3.Init.ExtFiltersNbr = 0;
hfdcan3.Init.RxFifo0ElmtsNbr = 0; hfdcan3.Init.RxFifo0ElmtsNbr = 4;
hfdcan3.Init.RxFifo0ElmtSize = FDCAN_DATA_BYTES_8; hfdcan3.Init.RxFifo0ElmtSize = FDCAN_DATA_BYTES_8;
hfdcan3.Init.RxFifo1ElmtsNbr = 32; hfdcan3.Init.RxFifo1ElmtsNbr = 4;
hfdcan3.Init.RxFifo1ElmtSize = FDCAN_DATA_BYTES_8; hfdcan3.Init.RxFifo1ElmtSize = FDCAN_DATA_BYTES_8;
hfdcan3.Init.RxBuffersNbr = 0; hfdcan3.Init.RxBuffersNbr = 0;
hfdcan3.Init.RxBufferSize = FDCAN_DATA_BYTES_8; hfdcan3.Init.RxBufferSize = FDCAN_DATA_BYTES_8;
hfdcan3.Init.TxEventsNbr = 0; hfdcan3.Init.TxEventsNbr = 0;
hfdcan3.Init.TxBuffersNbr = 0; hfdcan3.Init.TxBuffersNbr = 0;
hfdcan3.Init.TxFifoQueueElmtsNbr = 6; hfdcan3.Init.TxFifoQueueElmtsNbr = 32;
hfdcan3.Init.TxFifoQueueMode = FDCAN_TX_FIFO_OPERATION; hfdcan3.Init.TxFifoQueueMode = FDCAN_TX_FIFO_OPERATION;
hfdcan3.Init.TxElmtSize = FDCAN_DATA_BYTES_8; hfdcan3.Init.TxElmtSize = FDCAN_DATA_BYTES_8;
if (HAL_FDCAN_Init(&hfdcan3) != HAL_OK) if (HAL_FDCAN_Init(&hfdcan3) != HAL_OK)
@@ -216,6 +216,8 @@ void HAL_FDCAN_MspInit(FDCAN_HandleTypeDef* fdcanHandle)
/* FDCAN1 interrupt Init */ /* FDCAN1 interrupt Init */
HAL_NVIC_SetPriority(FDCAN1_IT0_IRQn, 5, 0); HAL_NVIC_SetPriority(FDCAN1_IT0_IRQn, 5, 0);
HAL_NVIC_EnableIRQ(FDCAN1_IT0_IRQn); HAL_NVIC_EnableIRQ(FDCAN1_IT0_IRQn);
HAL_NVIC_SetPriority(FDCAN1_IT1_IRQn, 5, 0);
HAL_NVIC_EnableIRQ(FDCAN1_IT1_IRQn);
/* USER CODE BEGIN FDCAN1_MspInit 1 */ /* USER CODE BEGIN FDCAN1_MspInit 1 */
/* USER CODE END FDCAN1_MspInit 1 */ /* USER CODE END FDCAN1_MspInit 1 */
@@ -256,6 +258,8 @@ void HAL_FDCAN_MspInit(FDCAN_HandleTypeDef* fdcanHandle)
/* FDCAN2 interrupt Init */ /* FDCAN2 interrupt Init */
HAL_NVIC_SetPriority(FDCAN2_IT0_IRQn, 5, 0); HAL_NVIC_SetPriority(FDCAN2_IT0_IRQn, 5, 0);
HAL_NVIC_EnableIRQ(FDCAN2_IT0_IRQn); HAL_NVIC_EnableIRQ(FDCAN2_IT0_IRQn);
HAL_NVIC_SetPriority(FDCAN2_IT1_IRQn, 5, 0);
HAL_NVIC_EnableIRQ(FDCAN2_IT1_IRQn);
/* USER CODE BEGIN FDCAN2_MspInit 1 */ /* USER CODE BEGIN FDCAN2_MspInit 1 */
/* USER CODE END FDCAN2_MspInit 1 */ /* USER CODE END FDCAN2_MspInit 1 */
@@ -296,6 +300,8 @@ void HAL_FDCAN_MspInit(FDCAN_HandleTypeDef* fdcanHandle)
/* FDCAN3 interrupt Init */ /* FDCAN3 interrupt Init */
HAL_NVIC_SetPriority(FDCAN3_IT0_IRQn, 5, 0); HAL_NVIC_SetPriority(FDCAN3_IT0_IRQn, 5, 0);
HAL_NVIC_EnableIRQ(FDCAN3_IT0_IRQn); HAL_NVIC_EnableIRQ(FDCAN3_IT0_IRQn);
HAL_NVIC_SetPriority(FDCAN3_IT1_IRQn, 5, 0);
HAL_NVIC_EnableIRQ(FDCAN3_IT1_IRQn);
/* USER CODE BEGIN FDCAN3_MspInit 1 */ /* USER CODE BEGIN FDCAN3_MspInit 1 */
/* USER CODE END FDCAN3_MspInit 1 */ /* USER CODE END FDCAN3_MspInit 1 */
@@ -324,6 +330,7 @@ void HAL_FDCAN_MspDeInit(FDCAN_HandleTypeDef* fdcanHandle)
/* FDCAN1 interrupt Deinit */ /* FDCAN1 interrupt Deinit */
HAL_NVIC_DisableIRQ(FDCAN1_IT0_IRQn); HAL_NVIC_DisableIRQ(FDCAN1_IT0_IRQn);
HAL_NVIC_DisableIRQ(FDCAN1_IT1_IRQn);
/* USER CODE BEGIN FDCAN1_MspDeInit 1 */ /* USER CODE BEGIN FDCAN1_MspDeInit 1 */
/* USER CODE END FDCAN1_MspDeInit 1 */ /* USER CODE END FDCAN1_MspDeInit 1 */
@@ -347,6 +354,7 @@ void HAL_FDCAN_MspDeInit(FDCAN_HandleTypeDef* fdcanHandle)
/* FDCAN2 interrupt Deinit */ /* FDCAN2 interrupt Deinit */
HAL_NVIC_DisableIRQ(FDCAN2_IT0_IRQn); HAL_NVIC_DisableIRQ(FDCAN2_IT0_IRQn);
HAL_NVIC_DisableIRQ(FDCAN2_IT1_IRQn);
/* USER CODE BEGIN FDCAN2_MspDeInit 1 */ /* USER CODE BEGIN FDCAN2_MspDeInit 1 */
/* USER CODE END FDCAN2_MspDeInit 1 */ /* USER CODE END FDCAN2_MspDeInit 1 */
@@ -370,6 +378,7 @@ void HAL_FDCAN_MspDeInit(FDCAN_HandleTypeDef* fdcanHandle)
/* FDCAN3 interrupt Deinit */ /* FDCAN3 interrupt Deinit */
HAL_NVIC_DisableIRQ(FDCAN3_IT0_IRQn); HAL_NVIC_DisableIRQ(FDCAN3_IT0_IRQn);
HAL_NVIC_DisableIRQ(FDCAN3_IT1_IRQn);
/* USER CODE BEGIN FDCAN3_MspDeInit 1 */ /* USER CODE BEGIN FDCAN3_MspDeInit 1 */
/* USER CODE END FDCAN3_MspDeInit 1 */ /* USER CODE END FDCAN3_MspDeInit 1 */

View File

@@ -25,7 +25,17 @@
/* Private includes ----------------------------------------------------------*/ /* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */ /* USER CODE BEGIN Includes */
#include "ws2812status.h"
#include "ins_task.h"
#include "buzzer.h"
// #include "remoteTask.h"
//
// #include "bsp_dwt.h"
// // #include "ins_task.h"
// #include "bsp_log.h"
#include "dev_cmd.h"
#include "daemon.h"
#include "bsp_usart.h"
/* USER CODE END Includes */ /* USER CODE END Includes */
/* Private typedef -----------------------------------------------------------*/ /* Private typedef -----------------------------------------------------------*/
@@ -103,9 +113,49 @@ const osThreadAttr_t reference_attributes = {
.stack_size = 512 * 4, .stack_size = 512 * 4,
.priority = (osPriority_t) osPriorityNormal, .priority = (osPriority_t) osPriorityNormal,
}; };
/* Definitions for WS2812Task */
osThreadId_t WS2812TaskHandle;
const osThreadAttr_t WS2812Task_attributes = {
.name = "WS2812Task",
.stack_size = 256 * 4,
.priority = (osPriority_t) osPriorityBelowNormal,
};
/* Private function prototypes -----------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/
/* USER CODE BEGIN FunctionPrototypes */ /* USER CODE BEGIN FunctionPrototypes */
//@Todo:测试instask
const osThreadAttr_t instask_attributes = {
.name = "instask",
.priority = osPriorityAboveNormal, // 较高优先级
.stack_size = 1024 * 4 // 栈大小单位是字节通常是字数的4倍
};
//@Todo:测试使用
osThreadId insTaskHandle;
void StartINSTASK(void *argument);
//@Todo:测试daemon(但是没有daemon注册)
const osThreadAttr_t daemon_attributes = {
.name = "daemon",
.priority = osPriorityAboveNormal, // 较高优先级
.stack_size = 1024 * 4 // 栈大小单位是字节通常是字数的4倍
};
//@Todo:测试使用
osThreadId daemonHandle;
void StartDaemonTask(void *argument); // <--- 新的,带参数的标准 RTOS 线程声明
const osThreadAttr_t buzzer_attributes = {
.name = "buzzer",
.priority = osPriorityNormal,
.stack_size = 512 * 4
};
osThreadId buzzerHandle;
extern void buzzerTask(void const *argument);
/* USER CODE END FunctionPrototypes */ /* USER CODE END FunctionPrototypes */
@@ -117,6 +167,7 @@ void StartInitTask(void *argument);
void VisionTask(void *argument); void VisionTask(void *argument);
void CmdTask(void *argument); void CmdTask(void *argument);
void RefereeTask(void *argument); void RefereeTask(void *argument);
extern void ws2812Task(void *argument);
extern void MX_USB_DEVICE_Init(void); extern void MX_USB_DEVICE_Init(void);
void MX_FREERTOS_Init(void); /* (MISRA C 2004 rule 8.1) */ void MX_FREERTOS_Init(void); /* (MISRA C 2004 rule 8.1) */
@@ -128,26 +179,28 @@ void vApplicationMallocFailedHook(void);
/* USER CODE BEGIN 4 */ /* USER CODE BEGIN 4 */
void vApplicationStackOverflowHook(xTaskHandle xTask, signed char *pcTaskName) void vApplicationStackOverflowHook(xTaskHandle xTask, signed char *pcTaskName)
{ {
/* Run time stack overflow checking is performed if /* Run time stack overflow checking is performed if
configCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2. This hook function is configCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2. This hook function is
called if a stack overflow is detected. */ called if a stack overflow is detected. */
} }
/* USER CODE END 4 */ /* USER CODE END 4 */
/* USER CODE BEGIN 5 */ /* USER CODE BEGIN 5 */
void vApplicationMallocFailedHook(void) void vApplicationMallocFailedHook(void)
{ {
/* vApplicationMallocFailedHook() will only be called if /* vApplicationMallocFailedHook() will only be called if
configUSE_MALLOC_FAILED_HOOK is set to 1 in FreeRTOSConfig.h. It is a hook configUSE_MALLOC_FAILED_HOOK is set to 1 in FreeRTOSConfig.h. It is a hook
function that will get called if a call to pvPortMalloc() fails. function that will get called if a call to pvPortMalloc() fails.
pvPortMalloc() is called internally by the kernel whenever a task, queue, pvPortMalloc() is called internally by the kernel whenever a task, queue,
timer or semaphore is created. It is also called by various parts of the timer or semaphore is created. It is also called by various parts of the
demo application. If heap_1.c or heap_2.c are used, then the size of the demo application. If heap_1.c or heap_2.c are used, then the size of the
heap available to pvPortMalloc() is defined by configTOTAL_HEAP_SIZE in heap available to pvPortMalloc() is defined by configTOTAL_HEAP_SIZE in
FreeRTOSConfig.h, and the xPortGetFreeHeapSize() API function can be used FreeRTOSConfig.h, and the xPortGetFreeHeapSize() API function can be used
to query the size of free heap space that remains (although it does not to query the size of free heap space that remains (although it does not
provide information on how the remaining heap might be fragmented). */ provide information on how the remaining heap might be fragmented). */
} }
/* USER CODE END 5 */ /* USER CODE END 5 */
/** /**
@@ -201,8 +254,19 @@ void MX_FREERTOS_Init(void) {
/* creation of reference */ /* creation of reference */
referenceHandle = osThreadNew(RefereeTask, NULL, &reference_attributes); referenceHandle = osThreadNew(RefereeTask, NULL, &reference_attributes);
/* creation of WS2812Task */
WS2812TaskHandle = osThreadNew(ws2812Task, NULL, &WS2812Task_attributes);
/* USER CODE BEGIN RTOS_THREADS */ /* USER CODE BEGIN RTOS_THREADS */
/* add threads, ... */ /* add threads, ... */
//@Todo:INS_Task是测试版本
// 创建线程
insTaskHandle = osThreadNew(StartINSTASK, NULL, &instask_attributes);
//@Todo:daemon是测试版本
// 创建线程
daemonHandle = osThreadNew(StartDaemonTask, NULL, &daemon_attributes); // <--- 换成新的函数名
buzzerHandle = osThreadNew(buzzerTask, NULL, &buzzer_attributes);
/* USER CODE END RTOS_THREADS */ /* USER CODE END RTOS_THREADS */
/* USER CODE BEGIN RTOS_EVENTS */ /* USER CODE BEGIN RTOS_EVENTS */
@@ -224,7 +288,7 @@ __weak void StartDefaultTask(void *argument)
MX_USB_DEVICE_Init(); MX_USB_DEVICE_Init();
/* USER CODE BEGIN StartDefaultTask */ /* USER CODE BEGIN StartDefaultTask */
/* Infinite loop */ /* Infinite loop */
for(;;) for (;;)
{ {
osDelay(1); osDelay(1);
} }
@@ -242,7 +306,7 @@ __weak void ShootTask(void *argument)
{ {
/* USER CODE BEGIN ShootTask */ /* USER CODE BEGIN ShootTask */
/* Infinite loop */ /* Infinite loop */
for(;;) for (;;)
{ {
osDelay(1); osDelay(1);
} }
@@ -260,7 +324,7 @@ __weak void GimbalTask(void *argument)
{ {
/* USER CODE BEGIN GimbalTask */ /* USER CODE BEGIN GimbalTask */
/* Infinite loop */ /* Infinite loop */
for(;;) for (;;)
{ {
osDelay(1); osDelay(1);
} }
@@ -278,7 +342,7 @@ __weak void ChassisTask(void *argument)
{ {
/* USER CODE BEGIN ChassisTask */ /* USER CODE BEGIN ChassisTask */
/* Infinite loop */ /* Infinite loop */
for(;;) for (;;)
{ {
osDelay(1); osDelay(1);
} }
@@ -296,7 +360,7 @@ __weak void StartInitTask(void *argument)
{ {
/* USER CODE BEGIN StartInitTask */ /* USER CODE BEGIN StartInitTask */
/* Infinite loop */ /* Infinite loop */
for(;;) for (;;)
{ {
osDelay(1); osDelay(1);
} }
@@ -314,7 +378,7 @@ __weak void VisionTask(void *argument)
{ {
/* USER CODE BEGIN VisionTask */ /* USER CODE BEGIN VisionTask */
/* Infinite loop */ /* Infinite loop */
for(;;) for (;;)
{ {
osDelay(1); osDelay(1);
} }
@@ -332,7 +396,7 @@ __weak void CmdTask(void *argument)
{ {
/* USER CODE BEGIN CmdTask */ /* USER CODE BEGIN CmdTask */
/* Infinite loop */ /* Infinite loop */
for(;;) for (;;)
{ {
osDelay(1); osDelay(1);
} }
@@ -350,7 +414,7 @@ __weak void RefereeTask(void *argument)
{ {
/* USER CODE BEGIN RefereeTask */ /* USER CODE BEGIN RefereeTask */
/* Infinite loop */ /* Infinite loop */
for(;;) for (;;)
{ {
osDelay(1); osDelay(1);
} }
@@ -360,5 +424,53 @@ __weak void RefereeTask(void *argument)
/* Private application code --------------------------------------------------*/ /* Private application code --------------------------------------------------*/
/* USER CODE BEGIN Application */ /* USER CODE BEGIN Application */
//@Todo:INS_Task是测试阶段使用。
__attribute__((noreturn)) void StartINSTASK(void *argument)
{
static float ins_start;
static float ins_dt;
INS_Init(); // 确保BMI088被正确初始化.
// LOGINFO("[freeRTOS] INS Task Start");
for (;;)
{
// 1kHz
// ins_start = DWT_GetTimeline_ms();
INS_Task();
// ins_dt = DWT_GetTimeline_ms() - ins_start;
// if (ins_dt > 1)
// @Todo: LOGERROR("[freeRTOS] INS Task is being DELAY! dt = [%f]", &ins_dt);
// // VisionSend(); // 解算完成后发送视觉数据,但是当前的实现不太优雅,后续若添加硬件触发需要重新考虑结构的组织
osDelay(1); // 1ms, 1kHz
}
}
/**
* @brief Function implementing the reference thread.
* @param argument: Not used
* @retval None
* @Todo:Deamon task 后期加入cmd和def
*/
/* USER CODE END Header_RefereeTask */
__attribute__((noreturn)) void StartDaemonTask(void *argument)
{
/* USER CODE BEGIN StartDaemonTask */
// LOGINFO("[freeRTOS] Daemon Task Start");
/* Infinite loop */
for (;;)
{
USARTServiceTask();
// 1. 执行核心的数据刷新逻辑
Daemon_Update();
// 2. 线程休眠 10ms (100Hz 运行频率)
osDelay(10);
}
/* USER CODE END StartDaemonTask */
}
// 注意:把你原来写在 freertos.c 里的那个 __weak void DaemonTask() 整个删掉,防止干扰!
/* USER CODE END Application */ /* USER CODE END Application */

View File

@@ -38,8 +38,6 @@
* Output * Output
* EVENT_OUT * EVENT_OUT
* EXTI * EXTI
PA6 ------> SPI6_MISO
PA7 ------> SPI6_MOSI
PA8 ------> RCC_MCO_1 PA8 ------> RCC_MCO_1
PC10 ------> SPI3_SCK PC10 ------> SPI3_SCK
PC11 ------> SPI3_MISO PC11 ------> SPI3_MISO
@@ -58,13 +56,13 @@ void MX_GPIO_Init(void)
__HAL_RCC_GPIOD_CLK_ENABLE(); __HAL_RCC_GPIOD_CLK_ENABLE();
/*Configure GPIO pin Output Level */ /*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(GPIOC, GPIO_PIN_14|ACC_CS_Pin, GPIO_PIN_RESET); HAL_GPIO_WritePin(GPIOC, Power2_Pin|Power1_Pin|Power_5V_EN_Pin|GYRO_CS_Pin, GPIO_PIN_SET);
/*Configure GPIO pin Output Level */ /*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(GPIOC, GPIO_PIN_15|GYRO_CS_Pin, GPIO_PIN_SET); HAL_GPIO_WritePin(ACC_CS_GPIO_Port, ACC_CS_Pin, GPIO_PIN_RESET);
/*Configure GPIO pin Output Level */ /*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(GPIOA, pump1_Pin|pump2_Pin, GPIO_PIN_SET); HAL_GPIO_WritePin(GPIOA, power2_Pin|power1_Pin, GPIO_PIN_SET);
/*Configure GPIO pin Output Level */ /*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(GPIOE, pump3_Pin|pump4_Pin, GPIO_PIN_RESET); HAL_GPIO_WritePin(GPIOE, pump3_Pin|pump4_Pin, GPIO_PIN_RESET);
@@ -78,8 +76,8 @@ void MX_GPIO_Init(void)
/*Configure GPIO pin Output Level */ /*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(cs3_GPIO_Port, cs3_Pin, GPIO_PIN_SET); HAL_GPIO_WritePin(cs3_GPIO_Port, cs3_Pin, GPIO_PIN_SET);
/*Configure GPIO pins : PC14 PC15 */ /*Configure GPIO pins : Power2_Pin Power1_Pin Power_5V_EN_Pin */
GPIO_InitStruct.Pin = GPIO_PIN_14|GPIO_PIN_15; GPIO_InitStruct.Pin = Power2_Pin|Power1_Pin|Power_5V_EN_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
@@ -92,21 +90,13 @@ void MX_GPIO_Init(void)
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
/*Configure GPIO pins : pump1_Pin pump2_Pin */ /*Configure GPIO pins : power2_Pin power1_Pin */
GPIO_InitStruct.Pin = pump1_Pin|pump2_Pin; GPIO_InitStruct.Pin = power2_Pin|power1_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_PULLDOWN; GPIO_InitStruct.Pull = GPIO_PULLDOWN;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
/*Configure GPIO pins : PA6 PA7 */
GPIO_InitStruct.Pin = GPIO_PIN_6|GPIO_PIN_7;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
GPIO_InitStruct.Alternate = GPIO_AF8_SPI6;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
/*Configure GPIO pins : pump3_Pin pump4_Pin */ /*Configure GPIO pins : pump3_Pin pump4_Pin */
GPIO_InitStruct.Pin = pump3_Pin|pump4_Pin; GPIO_InitStruct.Pin = pump3_Pin|pump4_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;

View File

@@ -1,56 +0,0 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file iwdg.c
* @brief This file provides code for the configuration
* of the IWDG instances.
******************************************************************************
* @attention
*
* Copyright (c) 2025 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.
*
******************************************************************************
*/
/* USER CODE END Header */
/* Includes ------------------------------------------------------------------*/
#include "iwdg.h"
/* USER CODE BEGIN 0 */
/* USER CODE END 0 */
IWDG_HandleTypeDef hiwdg1;
/* IWDG1 init function */
void MX_IWDG1_Init(void)
{
/* USER CODE BEGIN IWDG1_Init 0 */
/* USER CODE END IWDG1_Init 0 */
/* USER CODE BEGIN IWDG1_Init 1 */
/* USER CODE END IWDG1_Init 1 */
hiwdg1.Instance = IWDG1;
hiwdg1.Init.Prescaler = IWDG_PRESCALER_4;
hiwdg1.Init.Window = 4095;
hiwdg1.Init.Reload = 4095;
if (HAL_IWDG_Init(&hiwdg1) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN IWDG1_Init 2 */
/* USER CODE END IWDG1_Init 2 */
}
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */

View File

@@ -23,7 +23,6 @@
#include "crc.h" #include "crc.h"
#include "dma.h" #include "dma.h"
#include "fdcan.h" #include "fdcan.h"
#include "iwdg.h"
#include "spi.h" #include "spi.h"
#include "tim.h" #include "tim.h"
#include "usart.h" #include "usart.h"
@@ -33,6 +32,10 @@
/* Private includes ----------------------------------------------------------*/ /* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */ /* USER CODE BEGIN Includes */
#include "buzzer.h"
#include "ws2812status.h"
#include "robot.h"
/* USER CODE END Includes */ /* USER CODE END Includes */
/* Private typedef -----------------------------------------------------------*/ /* Private typedef -----------------------------------------------------------*/
@@ -58,6 +61,7 @@
/* Private function prototypes -----------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void); void SystemClock_Config(void);
void PeriphCommonClock_Config(void);
static void MPU_Config(void); static void MPU_Config(void);
void MX_FREERTOS_Init(void); void MX_FREERTOS_Init(void);
/* USER CODE BEGIN PFP */ /* USER CODE BEGIN PFP */
@@ -103,6 +107,9 @@ int main(void)
/* Configure the system clock */ /* Configure the system clock */
SystemClock_Config(); SystemClock_Config();
/* Configure the peripherals common clocks */
PeriphCommonClock_Config();
/* USER CODE BEGIN SysInit */ /* USER CODE BEGIN SysInit */
/* USER CODE END SysInit */ /* USER CODE END SysInit */
@@ -126,9 +133,15 @@ int main(void)
MX_SPI1_Init(); MX_SPI1_Init();
MX_UART5_Init(); MX_UART5_Init();
MX_TIM3_Init(); MX_TIM3_Init();
MX_IWDG1_Init(); MX_SPI6_Init();
MX_ADC1_Init();
/* USER CODE BEGIN 2 */ /* USER CODE BEGIN 2 */
robotSelfCheck(); //自检LED
RobotInit();
systemstart_song(); //开机音乐
/*还没有启动调度器!不允许任何涉及到 Freertos ticks的内容在这里运行*/
/* USER CODE END 2 */ /* USER CODE END 2 */
/* Init scheduler */ /* Init scheduler */
@@ -142,12 +155,12 @@ int main(void)
/* Infinite loop */ /* Infinite loop */
/* USER CODE BEGIN WHILE */ /* USER CODE BEGIN WHILE */
while (1) while (1)
{ {
/* USER CODE END WHILE */ /* USER CODE END WHILE */
/* USER CODE BEGIN 3 */ /* USER CODE BEGIN 3 */
} }
/* USER CODE END 3 */ /* USER CODE END 3 */
} }
@@ -174,11 +187,10 @@ void SystemClock_Config(void)
* in the RCC_OscInitTypeDef structure. * in the RCC_OscInitTypeDef structure.
*/ */
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI48|RCC_OSCILLATORTYPE_HSI RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI48|RCC_OSCILLATORTYPE_HSI
|RCC_OSCILLATORTYPE_LSI|RCC_OSCILLATORTYPE_HSE; |RCC_OSCILLATORTYPE_HSE;
RCC_OscInitStruct.HSEState = RCC_HSE_ON; RCC_OscInitStruct.HSEState = RCC_HSE_ON;
RCC_OscInitStruct.HSIState = RCC_HSI_DIV1; RCC_OscInitStruct.HSIState = RCC_HSI_DIV1;
RCC_OscInitStruct.HSICalibrationValue = 64; RCC_OscInitStruct.HSICalibrationValue = 64;
RCC_OscInitStruct.LSIState = RCC_LSI_ON;
RCC_OscInitStruct.HSI48State = RCC_HSI48_ON; RCC_OscInitStruct.HSI48State = RCC_HSI48_ON;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
@@ -215,6 +227,32 @@ void SystemClock_Config(void)
HAL_RCC_MCOConfig(RCC_MCO1, RCC_MCO1SOURCE_HSI, RCC_MCODIV_1); HAL_RCC_MCOConfig(RCC_MCO1, RCC_MCO1SOURCE_HSI, RCC_MCODIV_1);
} }
/**
* @brief Peripherals Common Clock Configuration
* @retval None
*/
void PeriphCommonClock_Config(void)
{
RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0};
/** Initializes the peripherals clock
*/
PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_ADC;
PeriphClkInitStruct.PLL2.PLL2M = 2;
PeriphClkInitStruct.PLL2.PLL2N = 16;
PeriphClkInitStruct.PLL2.PLL2P = 2;
PeriphClkInitStruct.PLL2.PLL2Q = 2;
PeriphClkInitStruct.PLL2.PLL2R = 2;
PeriphClkInitStruct.PLL2.PLL2RGE = RCC_PLL2VCIRANGE_3;
PeriphClkInitStruct.PLL2.PLL2VCOSEL = RCC_PLL2VCOWIDE;
PeriphClkInitStruct.PLL2.PLL2FRACN = 0;
PeriphClkInitStruct.AdcClockSelection = RCC_ADCCLKSOURCE_PLL2;
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK)
{
Error_Handler();
}
}
/* USER CODE BEGIN 4 */ /* USER CODE BEGIN 4 */
/* USER CODE END 4 */ /* USER CODE END 4 */
@@ -277,11 +315,11 @@ void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
void Error_Handler(void) void Error_Handler(void)
{ {
/* USER CODE BEGIN Error_Handler_Debug */ /* USER CODE BEGIN Error_Handler_Debug */
/* User can add his own implementation to report the HAL error return state */ /* User can add his own implementation to report the HAL error return state */
__disable_irq(); __disable_irq();
while (1) while (1)
{ {
} }
/* USER CODE END Error_Handler_Debug */ /* USER CODE END Error_Handler_Debug */
} }
#ifdef USE_FULL_ASSERT #ifdef USE_FULL_ASSERT
@@ -295,8 +333,8 @@ void Error_Handler(void)
void assert_failed(uint8_t *file, uint32_t line) void assert_failed(uint8_t *file, uint32_t line)
{ {
/* USER CODE BEGIN 6 */ /* USER CODE BEGIN 6 */
/* User can add his own implementation to report the file name and line number, /* User can add his own implementation to report the file name and line number,
ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
/* USER CODE END 6 */ /* USER CODE END 6 */
} }
#endif /* USE_FULL_ASSERT */ #endif /* USE_FULL_ASSERT */

View File

@@ -26,6 +26,7 @@
SPI_HandleTypeDef hspi1; SPI_HandleTypeDef hspi1;
SPI_HandleTypeDef hspi2; SPI_HandleTypeDef hspi2;
SPI_HandleTypeDef hspi6;
DMA_HandleTypeDef hdma_spi1_rx; DMA_HandleTypeDef hdma_spi1_rx;
DMA_HandleTypeDef hdma_spi1_tx; DMA_HandleTypeDef hdma_spi1_tx;
DMA_HandleTypeDef hdma_spi2_rx; DMA_HandleTypeDef hdma_spi2_rx;
@@ -114,6 +115,48 @@ void MX_SPI2_Init(void)
/* USER CODE END SPI2_Init 2 */ /* USER CODE END SPI2_Init 2 */
}
/* SPI6 init function */
void MX_SPI6_Init(void)
{
/* USER CODE BEGIN SPI6_Init 0 */
/* USER CODE END SPI6_Init 0 */
/* USER CODE BEGIN SPI6_Init 1 */
/* USER CODE END SPI6_Init 1 */
hspi6.Instance = SPI6;
hspi6.Init.Mode = SPI_MODE_MASTER;
hspi6.Init.Direction = SPI_DIRECTION_2LINES_TXONLY;
hspi6.Init.DataSize = SPI_DATASIZE_8BIT;
hspi6.Init.CLKPolarity = SPI_POLARITY_LOW;
hspi6.Init.CLKPhase = SPI_PHASE_2EDGE;
hspi6.Init.NSS = SPI_NSS_SOFT;
hspi6.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_4;
hspi6.Init.FirstBit = SPI_FIRSTBIT_MSB;
hspi6.Init.TIMode = SPI_TIMODE_DISABLE;
hspi6.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
hspi6.Init.CRCPolynomial = 0x0;
hspi6.Init.NSSPMode = SPI_NSS_PULSE_ENABLE;
hspi6.Init.NSSPolarity = SPI_NSS_POLARITY_LOW;
hspi6.Init.FifoThreshold = SPI_FIFO_THRESHOLD_01DATA;
hspi6.Init.TxCRCInitializationPattern = SPI_CRC_INITIALIZATION_ALL_ZERO_PATTERN;
hspi6.Init.RxCRCInitializationPattern = SPI_CRC_INITIALIZATION_ALL_ZERO_PATTERN;
hspi6.Init.MasterSSIdleness = SPI_MASTER_SS_IDLENESS_00CYCLE;
hspi6.Init.MasterInterDataIdleness = SPI_MASTER_INTERDATA_IDLENESS_00CYCLE;
hspi6.Init.MasterReceiverAutoSusp = SPI_MASTER_RX_AUTOSUSP_DISABLE;
hspi6.Init.MasterKeepIOState = SPI_MASTER_KEEP_IO_STATE_DISABLE;
hspi6.Init.IOSwap = SPI_IO_SWAP_DISABLE;
if (HAL_SPI_Init(&hspi6) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN SPI6_Init 2 */
/* USER CODE END SPI6_Init 2 */
} }
void HAL_SPI_MspInit(SPI_HandleTypeDef* spiHandle) void HAL_SPI_MspInit(SPI_HandleTypeDef* spiHandle)
@@ -180,7 +223,7 @@ void HAL_SPI_MspInit(SPI_HandleTypeDef* spiHandle)
__HAL_LINKDMA(spiHandle,hdmarx,hdma_spi1_rx); __HAL_LINKDMA(spiHandle,hdmarx,hdma_spi1_rx);
/* SPI1_TX Init */ /* SPI1_TX Init */
hdma_spi1_tx.Instance = DMA1_Stream2; hdma_spi1_tx.Instance = DMA1_Stream3;
hdma_spi1_tx.Init.Request = DMA_REQUEST_SPI1_TX; hdma_spi1_tx.Init.Request = DMA_REQUEST_SPI1_TX;
hdma_spi1_tx.Init.Direction = DMA_MEMORY_TO_PERIPH; hdma_spi1_tx.Init.Direction = DMA_MEMORY_TO_PERIPH;
hdma_spi1_tx.Init.PeriphInc = DMA_PINC_DISABLE; hdma_spi1_tx.Init.PeriphInc = DMA_PINC_DISABLE;
@@ -245,7 +288,7 @@ void HAL_SPI_MspInit(SPI_HandleTypeDef* spiHandle)
/* SPI2 DMA Init */ /* SPI2 DMA Init */
/* SPI2_RX Init */ /* SPI2_RX Init */
hdma_spi2_rx.Instance = DMA1_Stream3; hdma_spi2_rx.Instance = DMA1_Stream0;
hdma_spi2_rx.Init.Request = DMA_REQUEST_SPI2_RX; hdma_spi2_rx.Init.Request = DMA_REQUEST_SPI2_RX;
hdma_spi2_rx.Init.Direction = DMA_PERIPH_TO_MEMORY; hdma_spi2_rx.Init.Direction = DMA_PERIPH_TO_MEMORY;
hdma_spi2_rx.Init.PeriphInc = DMA_PINC_DISABLE; hdma_spi2_rx.Init.PeriphInc = DMA_PINC_DISABLE;
@@ -287,6 +330,41 @@ void HAL_SPI_MspInit(SPI_HandleTypeDef* spiHandle)
/* USER CODE END SPI2_MspInit 1 */ /* USER CODE END SPI2_MspInit 1 */
} }
else if(spiHandle->Instance==SPI6)
{
/* USER CODE BEGIN SPI6_MspInit 0 */
/* USER CODE END SPI6_MspInit 0 */
/** Initializes the peripherals clock
*/
PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_SPI6;
PeriphClkInitStruct.Spi6ClockSelection = RCC_SPI6CLKSOURCE_HSE;
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK)
{
Error_Handler();
}
/* SPI6 clock enable */
__HAL_RCC_SPI6_CLK_ENABLE();
__HAL_RCC_GPIOA_CLK_ENABLE();
/**SPI6 GPIO Configuration
PA5 ------> SPI6_SCK
PA6 ------> SPI6_MISO
PA7 ------> SPI6_MOSI
*/
GPIO_InitStruct.Pin = GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
GPIO_InitStruct.Alternate = GPIO_AF8_SPI6;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
/* USER CODE BEGIN SPI6_MspInit 1 */
/* USER CODE END SPI6_MspInit 1 */
}
} }
void HAL_SPI_MspDeInit(SPI_HandleTypeDef* spiHandle) void HAL_SPI_MspDeInit(SPI_HandleTypeDef* spiHandle)
@@ -346,6 +424,25 @@ void HAL_SPI_MspDeInit(SPI_HandleTypeDef* spiHandle)
/* USER CODE END SPI2_MspDeInit 1 */ /* USER CODE END SPI2_MspDeInit 1 */
} }
else if(spiHandle->Instance==SPI6)
{
/* USER CODE BEGIN SPI6_MspDeInit 0 */
/* USER CODE END SPI6_MspDeInit 0 */
/* Peripheral clock disable */
__HAL_RCC_SPI6_CLK_DISABLE();
/**SPI6 GPIO Configuration
PA5 ------> SPI6_SCK
PA6 ------> SPI6_MISO
PA7 ------> SPI6_MOSI
*/
HAL_GPIO_DeInit(GPIOA, GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7);
/* USER CODE BEGIN SPI6_MspDeInit 1 */
/* USER CODE END SPI6_MspDeInit 1 */
}
} }
/* USER CODE BEGIN 1 */ /* USER CODE BEGIN 1 */

View File

@@ -56,6 +56,8 @@
/* External variables --------------------------------------------------------*/ /* External variables --------------------------------------------------------*/
extern PCD_HandleTypeDef hpcd_USB_OTG_HS; extern PCD_HandleTypeDef hpcd_USB_OTG_HS;
extern DMA_HandleTypeDef hdma_adc1;
extern ADC_HandleTypeDef hadc1;
extern FDCAN_HandleTypeDef hfdcan1; extern FDCAN_HandleTypeDef hfdcan1;
extern FDCAN_HandleTypeDef hfdcan2; extern FDCAN_HandleTypeDef hfdcan2;
extern FDCAN_HandleTypeDef hfdcan3; extern FDCAN_HandleTypeDef hfdcan3;
@@ -185,6 +187,20 @@ void DebugMon_Handler(void)
/* please refer to the startup file (startup_stm32h7xx.s). */ /* please refer to the startup file (startup_stm32h7xx.s). */
/******************************************************************************/ /******************************************************************************/
/**
* @brief This function handles DMA1 stream0 global interrupt.
*/
void DMA1_Stream0_IRQHandler(void)
{
/* USER CODE BEGIN DMA1_Stream0_IRQn 0 */
/* USER CODE END DMA1_Stream0_IRQn 0 */
HAL_DMA_IRQHandler(&hdma_spi2_rx);
/* USER CODE BEGIN DMA1_Stream0_IRQn 1 */
/* USER CODE END DMA1_Stream0_IRQn 1 */
}
/** /**
* @brief This function handles DMA1 stream1 global interrupt. * @brief This function handles DMA1 stream1 global interrupt.
*/ */
@@ -207,7 +223,7 @@ void DMA1_Stream2_IRQHandler(void)
/* USER CODE BEGIN DMA1_Stream2_IRQn 0 */ /* USER CODE BEGIN DMA1_Stream2_IRQn 0 */
/* USER CODE END DMA1_Stream2_IRQn 0 */ /* USER CODE END DMA1_Stream2_IRQn 0 */
HAL_DMA_IRQHandler(&hdma_spi1_tx); HAL_DMA_IRQHandler(&hdma_adc1);
/* USER CODE BEGIN DMA1_Stream2_IRQn 1 */ /* USER CODE BEGIN DMA1_Stream2_IRQn 1 */
/* USER CODE END DMA1_Stream2_IRQn 1 */ /* USER CODE END DMA1_Stream2_IRQn 1 */
@@ -221,7 +237,7 @@ void DMA1_Stream3_IRQHandler(void)
/* USER CODE BEGIN DMA1_Stream3_IRQn 0 */ /* USER CODE BEGIN DMA1_Stream3_IRQn 0 */
/* USER CODE END DMA1_Stream3_IRQn 0 */ /* USER CODE END DMA1_Stream3_IRQn 0 */
HAL_DMA_IRQHandler(&hdma_spi2_rx); HAL_DMA_IRQHandler(&hdma_spi1_tx);
/* USER CODE BEGIN DMA1_Stream3_IRQn 1 */ /* USER CODE BEGIN DMA1_Stream3_IRQn 1 */
/* USER CODE END DMA1_Stream3_IRQn 1 */ /* USER CODE END DMA1_Stream3_IRQn 1 */
@@ -269,6 +285,20 @@ void DMA1_Stream6_IRQHandler(void)
/* USER CODE END DMA1_Stream6_IRQn 1 */ /* USER CODE END DMA1_Stream6_IRQn 1 */
} }
/**
* @brief This function handles ADC1 and ADC2 global interrupts.
*/
void ADC_IRQHandler(void)
{
/* USER CODE BEGIN ADC_IRQn 0 */
/* USER CODE END ADC_IRQn 0 */
HAL_ADC_IRQHandler(&hadc1);
/* USER CODE BEGIN ADC_IRQn 1 */
/* USER CODE END ADC_IRQn 1 */
}
/** /**
* @brief This function handles FDCAN1 interrupt 0. * @brief This function handles FDCAN1 interrupt 0.
*/ */
@@ -297,6 +327,34 @@ void FDCAN2_IT0_IRQHandler(void)
/* USER CODE END FDCAN2_IT0_IRQn 1 */ /* USER CODE END FDCAN2_IT0_IRQn 1 */
} }
/**
* @brief This function handles FDCAN1 interrupt 1.
*/
void FDCAN1_IT1_IRQHandler(void)
{
/* USER CODE BEGIN FDCAN1_IT1_IRQn 0 */
/* USER CODE END FDCAN1_IT1_IRQn 0 */
HAL_FDCAN_IRQHandler(&hfdcan1);
/* USER CODE BEGIN FDCAN1_IT1_IRQn 1 */
/* USER CODE END FDCAN1_IT1_IRQn 1 */
}
/**
* @brief This function handles FDCAN2 interrupt 1.
*/
void FDCAN2_IT1_IRQHandler(void)
{
/* USER CODE BEGIN FDCAN2_IT1_IRQn 0 */
/* USER CODE END FDCAN2_IT1_IRQn 0 */
HAL_FDCAN_IRQHandler(&hfdcan2);
/* USER CODE BEGIN FDCAN2_IT1_IRQn 1 */
/* USER CODE END FDCAN2_IT1_IRQn 1 */
}
/** /**
* @brief This function handles SPI1 global interrupt. * @brief This function handles SPI1 global interrupt.
*/ */
@@ -549,6 +607,20 @@ void FDCAN3_IT0_IRQHandler(void)
/* USER CODE END FDCAN3_IT0_IRQn 1 */ /* USER CODE END FDCAN3_IT0_IRQn 1 */
} }
/**
* @brief This function handles FDCAN3 interrupt 1.
*/
void FDCAN3_IT1_IRQHandler(void)
{
/* USER CODE BEGIN FDCAN3_IT1_IRQn 0 */
/* USER CODE END FDCAN3_IT1_IRQn 0 */
HAL_FDCAN_IRQHandler(&hfdcan3);
/* USER CODE BEGIN FDCAN3_IT1_IRQn 1 */
/* USER CODE END FDCAN3_IT1_IRQn 1 */
}
/** /**
* @brief This function handles TIM23 global interrupt. * @brief This function handles TIM23 global interrupt.
*/ */

View File

@@ -57,11 +57,11 @@
#endif /* HSE_VALUE */ #endif /* HSE_VALUE */
#if !defined (CSI_VALUE) #if !defined (CSI_VALUE)
#define CSI_VALUE ((uint32_t)4000000) /*!< Value of the Internal oscillator in Hz*/ #define CSI_VALUE ((uint32_t)4000000) /*!< Value of the Internal oscillator in Hz*/
#endif /* CSI_VALUE */ #endif /* CSI_VALUE */
#if !defined (HSI_VALUE) #if !defined (HSI_VALUE)
#define HSI_VALUE ((uint32_t)64000000) /*!< Value of the Internal oscillator in Hz*/ #define HSI_VALUE ((uint32_t)64000000) /*!< Value of the Internal oscillator in Hz*/
#endif /* HSI_VALUE */ #endif /* HSI_VALUE */
@@ -142,17 +142,17 @@
/** @addtogroup STM32H7xx_System_Private_Variables /** @addtogroup STM32H7xx_System_Private_Variables
* @{ * @{
*/ */
/* This variable is updated in three ways: /* This variable is updated in three ways:
1) by calling CMSIS function SystemCoreClockUpdate() 1) by calling CMSIS function SystemCoreClockUpdate()
2) by calling HAL API function HAL_RCC_GetHCLKFreq() 2) by calling HAL API function HAL_RCC_GetHCLKFreq()
3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency 3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency
Note: If you use this function to configure the system clock; then there Note: If you use this function to configure the system clock; then there
is no need to call the 2 first functions listed above, since SystemCoreClock is no need to call the 2 first functions listed above, since SystemCoreClock
variable is updated automatically. variable is updated automatically.
*/ */
uint32_t SystemCoreClock = 64000000; uint32_t SystemCoreClock = 64000000;
uint32_t SystemD2Clock = 64000000; uint32_t SystemD2Clock = 64000000;
const uint8_t D1CorePrescTable[16] = {0, 0, 0, 0, 1, 2, 3, 4, 1, 2, 3, 4, 6, 7, 8, 9}; const uint8_t D1CorePrescTable[16] = {0, 0, 0, 0, 1, 2, 3, 4, 1, 2, 3, 4, 6, 7, 8, 9};
/** /**
* @} * @}
@@ -177,140 +177,149 @@
* @param None * @param None
* @retval None * @retval None
*/ */
void SystemInit (void) void SystemInit(void)
{ {
#if defined (DATA_IN_D2_SRAM) #if defined (DATA_IN_D2_SRAM)
__IO uint32_t tmpreg; __IO uint32_t tmpreg;
#endif /* DATA_IN_D2_SRAM */ #endif /* DATA_IN_D2_SRAM */
/* FPU settings ------------------------------------------------------------*/ /* FPU settings ------------------------------------------------------------*/
#if (__FPU_PRESENT == 1) && (__FPU_USED == 1) #if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
SCB->CPACR |= ((3UL << (10*2))|(3UL << (11*2))); /* set CP10 and CP11 Full Access */ SCB->CPACR |= ((3UL << (10 * 2)) | (3UL << (11 * 2))); /* set CP10 and CP11 Full Access */
#endif #endif
/* Reset the RCC clock configuration to the default reset state ------------*/ /* Reset the RCC clock configuration to the default reset state ------------*/
/* Increasing the CPU frequency */ /* Increasing the CPU frequency */
if(FLASH_LATENCY_DEFAULT > (READ_BIT((FLASH->ACR), FLASH_ACR_LATENCY))) if (FLASH_LATENCY_DEFAULT > (READ_BIT((FLASH->ACR), FLASH_ACR_LATENCY)))
{ {
/* Program the new number of wait states to the LATENCY bits in the FLASH_ACR register */ /* Program the new number of wait states to the LATENCY bits in the FLASH_ACR register */
MODIFY_REG(FLASH->ACR, FLASH_ACR_LATENCY, (uint32_t)(FLASH_LATENCY_DEFAULT)); MODIFY_REG(FLASH->ACR, FLASH_ACR_LATENCY, (uint32_t)(FLASH_LATENCY_DEFAULT));
} }
/* Set HSION bit */ /* Set HSION bit */
RCC->CR |= RCC_CR_HSION; RCC->CR |= RCC_CR_HSION;
/* Reset CFGR register */ /* Reset CFGR register */
RCC->CFGR = 0x00000000; RCC->CFGR = 0x00000000;
/* Reset HSEON, HSECSSON, CSION, HSI48ON, CSIKERON, PLL1ON, PLL2ON and PLL3ON bits */ /* Reset HSEON, HSECSSON, CSION, HSI48ON, CSIKERON, PLL1ON, PLL2ON and PLL3ON bits */
RCC->CR &= 0xEAF6ED7FU; RCC->CR &= 0xEAF6ED7FU;
/* Decreasing the number of wait states because of lower CPU frequency */ /* Decreasing the number of wait states because of lower CPU frequency */
if(FLASH_LATENCY_DEFAULT < (READ_BIT((FLASH->ACR), FLASH_ACR_LATENCY))) if (FLASH_LATENCY_DEFAULT < (READ_BIT((FLASH->ACR), FLASH_ACR_LATENCY)))
{ {
/* Program the new number of wait states to the LATENCY bits in the FLASH_ACR register */ /* Program the new number of wait states to the LATENCY bits in the FLASH_ACR register */
MODIFY_REG(FLASH->ACR, FLASH_ACR_LATENCY, (uint32_t)(FLASH_LATENCY_DEFAULT)); MODIFY_REG(FLASH->ACR, FLASH_ACR_LATENCY, (uint32_t)(FLASH_LATENCY_DEFAULT));
} }
#if defined(D3_SRAM_BASE) #if defined(D3_SRAM_BASE)
/* Reset D1CFGR register */ /* Reset D1CFGR register */
RCC->D1CFGR = 0x00000000; RCC->D1CFGR = 0x00000000;
/* Reset D2CFGR register */ /* Reset D2CFGR register */
RCC->D2CFGR = 0x00000000; RCC->D2CFGR = 0x00000000;
/* Reset D3CFGR register */ /* Reset D3CFGR register */
RCC->D3CFGR = 0x00000000; RCC->D3CFGR = 0x00000000;
#else #else
/* Reset CDCFGR1 register */ /* Reset CDCFGR1 register */
RCC->CDCFGR1 = 0x00000000; RCC->CDCFGR1 = 0x00000000;
/* Reset CDCFGR2 register */ /* Reset CDCFGR2 register */
RCC->CDCFGR2 = 0x00000000; RCC->CDCFGR2 = 0x00000000;
/* Reset SRDCFGR register */ /* Reset SRDCFGR register */
RCC->SRDCFGR = 0x00000000; RCC->SRDCFGR = 0x00000000;
#endif #endif
/* Reset PLLCKSELR register */ /* Reset PLLCKSELR register */
RCC->PLLCKSELR = 0x02020200; RCC->PLLCKSELR = 0x02020200;
/* Reset PLLCFGR register */ /* Reset PLLCFGR register */
RCC->PLLCFGR = 0x01FF0000; RCC->PLLCFGR = 0x01FF0000;
/* Reset PLL1DIVR register */ /* Reset PLL1DIVR register */
RCC->PLL1DIVR = 0x01010280; RCC->PLL1DIVR = 0x01010280;
/* Reset PLL1FRACR register */ /* Reset PLL1FRACR register */
RCC->PLL1FRACR = 0x00000000; RCC->PLL1FRACR = 0x00000000;
/* Reset PLL2DIVR register */ /* Reset PLL2DIVR register */
RCC->PLL2DIVR = 0x01010280; RCC->PLL2DIVR = 0x01010280;
/* Reset PLL2FRACR register */ /* Reset PLL2FRACR register */
RCC->PLL2FRACR = 0x00000000; RCC->PLL2FRACR = 0x00000000;
/* Reset PLL3DIVR register */ /* Reset PLL3DIVR register */
RCC->PLL3DIVR = 0x01010280; RCC->PLL3DIVR = 0x01010280;
/* Reset PLL3FRACR register */ /* Reset PLL3FRACR register */
RCC->PLL3FRACR = 0x00000000; RCC->PLL3FRACR = 0x00000000;
/* Reset HSEBYP bit */ /* Reset HSEBYP bit */
RCC->CR &= 0xFFFBFFFFU; RCC->CR &= 0xFFFBFFFFU;
/* Disable all interrupts */ /* Disable all interrupts */
RCC->CIER = 0x00000000; RCC->CIER = 0x00000000;
#if (STM32H7_DEV_ID == 0x450UL) #if (STM32H7_DEV_ID == 0x450UL)
/* dual core CM7 or single core line */ /* dual core CM7 or single core line */
if((DBGMCU->IDCODE & 0xFFFF0000U) < 0x20000000U) if ((DBGMCU->IDCODE & 0xFFFF0000U) < 0x20000000U)
{ {
/* if stm32h7 revY*/ /* if stm32h7 revY*/
/* Change the switch matrix read issuing capability to 1 for the AXI SRAM target (Target 7) */ /* Change the switch matrix read issuing capability to 1 for the AXI SRAM target (Target 7) */
*((__IO uint32_t*)0x51008108) = 0x000000001U; *((__IO
} uint32_t *
)
0x51008108
)
=
0x000000001U;
}
#endif /* STM32H7_DEV_ID */ #endif /* STM32H7_DEV_ID */
#if defined(DATA_IN_D2_SRAM) #if defined(DATA_IN_D2_SRAM)
/* in case of initialized data in D2 SRAM (AHB SRAM), enable the D2 SRAM clock (AHB SRAM clock) */ /* in case of initialized data in D2 SRAM (AHB SRAM), enable the D2 SRAM clock (AHB SRAM clock) */
#if defined(RCC_AHB2ENR_D2SRAM3EN) #if defined(RCC_AHB2ENR_D2SRAM3EN)
RCC->AHB2ENR |= (RCC_AHB2ENR_D2SRAM1EN | RCC_AHB2ENR_D2SRAM2EN | RCC_AHB2ENR_D2SRAM3EN); RCC->AHB2ENR |= (RCC_AHB2ENR_D2SRAM1EN | RCC_AHB2ENR_D2SRAM2EN | RCC_AHB2ENR_D2SRAM3EN);
#elif defined(RCC_AHB2ENR_D2SRAM2EN) #elif defined(RCC_AHB2ENR_D2SRAM2EN)
RCC->AHB2ENR |= (RCC_AHB2ENR_D2SRAM1EN | RCC_AHB2ENR_D2SRAM2EN); RCC->AHB2ENR |= (RCC_AHB2ENR_D2SRAM1EN | RCC_AHB2ENR_D2SRAM2EN);
#else #else
RCC->AHB2ENR |= (RCC_AHB2ENR_AHBSRAM1EN | RCC_AHB2ENR_AHBSRAM2EN); RCC->AHB2ENR |= (RCC_AHB2ENR_AHBSRAM1EN | RCC_AHB2ENR_AHBSRAM2EN);
#endif /* RCC_AHB2ENR_D2SRAM3EN */ #endif /* RCC_AHB2ENR_D2SRAM3EN */
tmpreg = RCC->AHB2ENR; tmpreg = RCC->AHB2ENR;
(void) tmpreg; (void) tmpreg;
#endif /* DATA_IN_D2_SRAM */ #endif /* DATA_IN_D2_SRAM */
#if defined(DUAL_CORE) && defined(CORE_CM4) #if defined(DUAL_CORE) && defined(CORE_CM4)
/* Configure the Vector Table location add offset address for cortex-M4 ------------------*/ /* Configure the Vector Table location add offset address for cortex-M4 ------------------*/
#if defined(USER_VECT_TAB_ADDRESS) #if defined(USER_VECT_TAB_ADDRESS)
SCB->VTOR = VECT_TAB_BASE_ADDRESS | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal D2 AXI-RAM or in Internal FLASH */ SCB->VTOR = VECT_TAB_BASE_ADDRESS | VECT_TAB_OFFSET;
/* Vector Table Relocation in Internal D2 AXI-RAM or in Internal FLASH */
#endif /* USER_VECT_TAB_ADDRESS */ #endif /* USER_VECT_TAB_ADDRESS */
#else #else
if(READ_BIT(RCC->AHB3ENR, RCC_AHB3ENR_FMCEN) == 0U) if (READ_BIT(RCC->AHB3ENR, RCC_AHB3ENR_FMCEN) == 0U)
{ {
/* Enable the FMC interface clock */ /* Enable the FMC interface clock */
SET_BIT(RCC->AHB3ENR, RCC_AHB3ENR_FMCEN); SET_BIT(RCC->AHB3ENR, RCC_AHB3ENR_FMCEN);
/* /*
* Disable the FMC bank1 (enabled after reset). * Disable the FMC bank1 (enabled after reset).
* This, prevents CPU speculation access on this bank which blocks the use of FMC during * This, prevents CPU speculation access on this bank which blocks the use of FMC during
* 24us. During this time the others FMC master (such as LTDC) cannot use it! * 24us. During this time the others FMC master (such as LTDC) cannot use it!
*/ */
FMC_Bank1_R->BTCR[0] = 0x000030D2; FMC_Bank1_R->BTCR[0] = 0x000030D2;
/* Disable the FMC interface clock */ /* Disable the FMC interface clock */
CLEAR_BIT(RCC->AHB3ENR, RCC_AHB3ENR_FMCEN); CLEAR_BIT(RCC->AHB3ENR, RCC_AHB3ENR_FMCEN);
} }
/* Configure the Vector Table location -------------------------------------*/ /* Configure the Vector Table location -------------------------------------*/
#if defined(USER_VECT_TAB_ADDRESS) #if defined(USER_VECT_TAB_ADDRESS)
SCB->VTOR = VECT_TAB_BASE_ADDRESS | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal D1 AXI-RAM or in Internal FLASH */ SCB->VTOR = VECT_TAB_BASE_ADDRESS | VECT_TAB_OFFSET;
/* Vector Table Relocation in Internal D1 AXI-RAM or in Internal FLASH */
#endif /* USER_VECT_TAB_ADDRESS */ #endif /* USER_VECT_TAB_ADDRESS */
__HAL_RCC_D2SRAM1_CLK_ENABLE(); //添加如下代码使能D2域的RAM之用的ram_1,顺便把ram_d2也使能了
__HAL_RCC_D2SRAM2_CLK_ENABLE(); //ps.不使能的话会导致变量显式初始化无法赋值
#endif /*DUAL_CORE && CORE_CM4*/ #endif /*DUAL_CORE && CORE_CM4*/
} }
@@ -351,102 +360,112 @@ void SystemInit (void)
* @param None * @param None
* @retval None * @retval None
*/ */
void SystemCoreClockUpdate (void) void SystemCoreClockUpdate(void)
{ {
uint32_t pllp, pllsource, pllm, pllfracen, hsivalue, tmp; uint32_t pllp, pllsource, pllm, pllfracen, hsivalue, tmp;
uint32_t common_system_clock; uint32_t common_system_clock;
float_t fracn1, pllvco; float_t fracn1, pllvco;
/* Get SYSCLK source -------------------------------------------------------*/ /* Get SYSCLK source -------------------------------------------------------*/
switch (RCC->CFGR & RCC_CFGR_SWS) switch (RCC->CFGR & RCC_CFGR_SWS)
{
case RCC_CFGR_SWS_HSI: /* HSI used as system clock source */
common_system_clock = (uint32_t) (HSI_VALUE >> ((RCC->CR & RCC_CR_HSIDIV)>> 3));
break;
case RCC_CFGR_SWS_CSI: /* CSI used as system clock source */
common_system_clock = CSI_VALUE;
break;
case RCC_CFGR_SWS_HSE: /* HSE used as system clock source */
common_system_clock = HSE_VALUE;
break;
case RCC_CFGR_SWS_PLL1: /* PLL1 used as system clock source */
/* PLL_VCO = (HSE_VALUE or HSI_VALUE or CSI_VALUE/ PLLM) * PLLN
SYSCLK = PLL_VCO / PLLR
*/
pllsource = (RCC->PLLCKSELR & RCC_PLLCKSELR_PLLSRC);
pllm = ((RCC->PLLCKSELR & RCC_PLLCKSELR_DIVM1)>> 4) ;
pllfracen = ((RCC->PLLCFGR & RCC_PLLCFGR_PLL1FRACEN)>>RCC_PLLCFGR_PLL1FRACEN_Pos);
fracn1 = (float_t)(uint32_t)(pllfracen* ((RCC->PLL1FRACR & RCC_PLL1FRACR_FRACN1)>> 3));
if (pllm != 0U)
{ {
switch (pllsource) case RCC_CFGR_SWS_HSI: /* HSI used as system clock source */
{ common_system_clock = (uint32_t) (HSI_VALUE >> ((RCC->CR & RCC_CR_HSIDIV) >> 3));
case RCC_PLLCKSELR_PLLSRC_HSI: /* HSI used as PLL clock source */ break;
hsivalue = (HSI_VALUE >> ((RCC->CR & RCC_CR_HSIDIV)>> 3)) ; case RCC_CFGR_SWS_CSI: /* CSI used as system clock source */
pllvco = ( (float_t)hsivalue / (float_t)pllm) * ((float_t)(uint32_t)(RCC->PLL1DIVR & RCC_PLL1DIVR_N1) + (fracn1/(float_t)0x2000) +(float_t)1 ); common_system_clock = CSI_VALUE;
break;
break; case RCC_CFGR_SWS_HSE: /* HSE used as system clock source */
common_system_clock = HSE_VALUE;
break;
case RCC_PLLCKSELR_PLLSRC_CSI: /* CSI used as PLL clock source */ case RCC_CFGR_SWS_PLL1: /* PLL1 used as system clock source */
pllvco = ((float_t)CSI_VALUE / (float_t)pllm) * ((float_t)(uint32_t)(RCC->PLL1DIVR & RCC_PLL1DIVR_N1) + (fracn1/(float_t)0x2000) +(float_t)1 );
break;
case RCC_PLLCKSELR_PLLSRC_HSE: /* HSE used as PLL clock source */ /* PLL_VCO = (HSE_VALUE or HSI_VALUE or CSI_VALUE/ PLLM) * PLLN
pllvco = ((float_t)HSE_VALUE / (float_t)pllm) * ((float_t)(uint32_t)(RCC->PLL1DIVR & RCC_PLL1DIVR_N1) + (fracn1/(float_t)0x2000) +(float_t)1 ); SYSCLK = PLL_VCO / PLLR
break; */
pllsource = (RCC->PLLCKSELR & RCC_PLLCKSELR_PLLSRC);
pllm = ((RCC->PLLCKSELR & RCC_PLLCKSELR_DIVM1) >> 4);
pllfracen = ((RCC->PLLCFGR & RCC_PLLCFGR_PLL1FRACEN) >> RCC_PLLCFGR_PLL1FRACEN_Pos);
fracn1 = (float_t) (uint32_t) (pllfracen * ((RCC->PLL1FRACR & RCC_PLL1FRACR_FRACN1) >> 3));
default: if (pllm != 0U)
hsivalue = (HSI_VALUE >> ((RCC->CR & RCC_CR_HSIDIV)>> 3)) ; {
pllvco = ((float_t)hsivalue / (float_t)pllm) * ((float_t)(uint32_t)(RCC->PLL1DIVR & RCC_PLL1DIVR_N1) + (fracn1/(float_t)0x2000) +(float_t)1 ); switch (pllsource)
break; {
} case RCC_PLLCKSELR_PLLSRC_HSI: /* HSI used as PLL clock source */
pllp = (((RCC->PLL1DIVR & RCC_PLL1DIVR_P1) >>9) + 1U ) ;
common_system_clock = (uint32_t)(float_t)(pllvco/(float_t)pllp); hsivalue = (HSI_VALUE >> ((RCC->CR & RCC_CR_HSIDIV) >> 3));
pllvco = ((float_t) hsivalue / (float_t) pllm) * (
(float_t) (uint32_t) (RCC->PLL1DIVR & RCC_PLL1DIVR_N1) + (
fracn1 / (float_t) 0x2000) + (float_t) 1);
break;
case RCC_PLLCKSELR_PLLSRC_CSI: /* CSI used as PLL clock source */
pllvco = ((float_t) CSI_VALUE / (float_t) pllm) * (
(float_t) (uint32_t) (RCC->PLL1DIVR & RCC_PLL1DIVR_N1) + (
fracn1 / (float_t) 0x2000) + (float_t) 1);
break;
case RCC_PLLCKSELR_PLLSRC_HSE: /* HSE used as PLL clock source */
pllvco = ((float_t) HSE_VALUE / (float_t) pllm) * (
(float_t) (uint32_t) (RCC->PLL1DIVR & RCC_PLL1DIVR_N1) + (
fracn1 / (float_t) 0x2000) + (float_t) 1);
break;
default:
hsivalue = (HSI_VALUE >> ((RCC->CR & RCC_CR_HSIDIV) >> 3));
pllvco = ((float_t) hsivalue / (float_t) pllm) * (
(float_t) (uint32_t) (RCC->PLL1DIVR & RCC_PLL1DIVR_N1) + (
fracn1 / (float_t) 0x2000) + (float_t) 1);
break;
}
pllp = (((RCC->PLL1DIVR & RCC_PLL1DIVR_P1) >> 9) + 1U);
common_system_clock = (uint32_t) (float_t) (pllvco / (float_t) pllp);
}
else
{
common_system_clock = 0U;
}
break;
default:
common_system_clock = (uint32_t) (HSI_VALUE >> ((RCC->CR & RCC_CR_HSIDIV) >> 3));
break;
} }
else
{
common_system_clock = 0U;
}
break;
default: /* Compute SystemClock frequency --------------------------------------------------*/
common_system_clock = (uint32_t) (HSI_VALUE >> ((RCC->CR & RCC_CR_HSIDIV)>> 3));
break;
}
/* Compute SystemClock frequency --------------------------------------------------*/
#if defined (RCC_D1CFGR_D1CPRE) #if defined (RCC_D1CFGR_D1CPRE)
tmp = D1CorePrescTable[(RCC->D1CFGR & RCC_D1CFGR_D1CPRE)>> RCC_D1CFGR_D1CPRE_Pos]; tmp = D1CorePrescTable[(RCC->D1CFGR & RCC_D1CFGR_D1CPRE) >> RCC_D1CFGR_D1CPRE_Pos];
/* common_system_clock frequency : CM7 CPU frequency */ /* common_system_clock frequency : CM7 CPU frequency */
common_system_clock >>= tmp; common_system_clock >>= tmp;
/* SystemD2Clock frequency : CM4 CPU, AXI and AHBs Clock frequency */ /* SystemD2Clock frequency : CM4 CPU, AXI and AHBs Clock frequency */
SystemD2Clock = (common_system_clock >> ((D1CorePrescTable[(RCC->D1CFGR & RCC_D1CFGR_HPRE)>> RCC_D1CFGR_HPRE_Pos]) & 0x1FU)); SystemD2Clock = (common_system_clock >> ((D1CorePrescTable[(RCC->D1CFGR & RCC_D1CFGR_HPRE) >> RCC_D1CFGR_HPRE_Pos])
& 0x1FU));
#else #else
tmp = D1CorePrescTable[(RCC->CDCFGR1 & RCC_CDCFGR1_CDCPRE)>> RCC_CDCFGR1_CDCPRE_Pos]; tmp = D1CorePrescTable[(RCC->CDCFGR1 & RCC_CDCFGR1_CDCPRE) >> RCC_CDCFGR1_CDCPRE_Pos];
/* common_system_clock frequency : CM7 CPU frequency */ /* common_system_clock frequency : CM7 CPU frequency */
common_system_clock >>= tmp; common_system_clock >>= tmp;
/* SystemD2Clock frequency : AXI and AHBs Clock frequency */ /* SystemD2Clock frequency : AXI and AHBs Clock frequency */
SystemD2Clock = (common_system_clock >> ((D1CorePrescTable[(RCC->CDCFGR1 & RCC_CDCFGR1_HPRE)>> RCC_CDCFGR1_HPRE_Pos]) & 0x1FU)); SystemD2Clock = (common_system_clock >> ((D1CorePrescTable[
(RCC->CDCFGR1 & RCC_CDCFGR1_HPRE) >> RCC_CDCFGR1_HPRE_Pos]) & 0x1FU));
#endif #endif
#if defined(DUAL_CORE) && defined(CORE_CM4) #if defined(DUAL_CORE) && defined(CORE_CM4)
SystemCoreClock = SystemD2Clock; SystemCoreClock = SystemD2Clock;
#else #else
SystemCoreClock = common_system_clock; SystemCoreClock = common_system_clock;
#endif /* DUAL_CORE && CORE_CM4 */ #endif /* DUAL_CORE && CORE_CM4 */
} }
@@ -476,70 +495,81 @@ void SystemCoreClockUpdate (void)
void ExitRun0Mode(void) void ExitRun0Mode(void)
{ {
#if defined(USE_PWR_LDO_SUPPLY) #if defined(USE_PWR_LDO_SUPPLY)
#if defined(SMPS) #if defined(SMPS)
/* Exit Run* mode by disabling SMPS and enabling LDO */ /* Exit Run* mode by disabling SMPS and enabling LDO */
PWR->CR3 = (PWR->CR3 & ~PWR_CR3_SMPSEN) | PWR_CR3_LDOEN; PWR->CR3 = (PWR->CR3 & ~PWR_CR3_SMPSEN) | PWR_CR3_LDOEN;
#else #else
/* Enable LDO mode */ /* Enable LDO mode */
PWR->CR3 |= PWR_CR3_LDOEN; PWR->CR3 |= PWR_CR3_LDOEN;
#endif /* SMPS */ #endif /* SMPS */
/* Wait till voltage level flag is set */ /* Wait till voltage level flag is set */
while ((PWR->CSR1 & PWR_CSR1_ACTVOSRDY) == 0U) while ((PWR->CSR1 & PWR_CSR1_ACTVOSRDY) == 0U)
{} {
}
#elif defined(USE_PWR_EXTERNAL_SOURCE_SUPPLY) #elif defined(USE_PWR_EXTERNAL_SOURCE_SUPPLY)
#if defined(SMPS) #if defined(SMPS)
/* Exit Run* mode */ /* Exit Run* mode */
PWR->CR3 = (PWR->CR3 & ~(PWR_CR3_SMPSEN | PWR_CR3_LDOEN)) | PWR_CR3_BYPASS; PWR->CR3 = (PWR->CR3 & ~(PWR_CR3_SMPSEN | PWR_CR3_LDOEN)) | PWR_CR3_BYPASS;
#else
PWR->CR3 = (PWR->CR3 & ~(PWR_CR3_LDOEN)) | PWR_CR3_BYPASS;
#endif /* SMPS */
/* Wait till voltage level flag is set */
while ((PWR->CSR1 & PWR_CSR1_ACTVOSRDY) == 0U)
{}
#elif defined(USE_PWR_DIRECT_SMPS_SUPPLY) && defined(SMPS)
/* Exit Run* mode */
PWR->CR3 &= ~(PWR_CR3_LDOEN);
/* Wait till voltage level flag is set */
while ((PWR->CSR1 & PWR_CSR1_ACTVOSRDY) == 0U)
{}
#elif defined(USE_PWR_SMPS_1V8_SUPPLIES_LDO) && defined(SMPS)
/* Exit Run* mode */
PWR->CR3 |= PWR_CR3_SMPSLEVEL_0 | PWR_CR3_SMPSEN | PWR_CR3_LDOEN;
/* Wait till voltage level flag is set */
while ((PWR->CSR1 & PWR_CSR1_ACTVOSRDY) == 0U)
{}
#elif defined(USE_PWR_SMPS_2V5_SUPPLIES_LDO) && defined(SMPS)
/* Exit Run* mode */
PWR->CR3 |= PWR_CR3_SMPSLEVEL_1 | PWR_CR3_SMPSEN | PWR_CR3_LDOEN;
/* Wait till voltage level flag is set */
while ((PWR->CSR1 & PWR_CSR1_ACTVOSRDY) == 0U)
{}
#elif defined(USE_PWR_SMPS_1V8_SUPPLIES_EXT_AND_LDO) && defined(SMPS)
/* Exit Run* mode */
PWR->CR3 |= PWR_CR3_SMPSLEVEL_0 | PWR_CR3_SMPSEXTHP | PWR_CR3_SMPSEN | PWR_CR3_LDOEN;
/* Wait till voltage level flag is set */
while ((PWR->CSR1 & PWR_CSR1_ACTVOSRDY) == 0U)
{}
#elif defined(USE_PWR_SMPS_2V5_SUPPLIES_EXT_AND_LDO) && defined(SMPS)
/* Exit Run* mode */
PWR->CR3 |= PWR_CR3_SMPSLEVEL_1 | PWR_CR3_SMPSEXTHP | PWR_CR3_SMPSEN | PWR_CR3_LDOEN;
/* Wait till voltage level flag is set */
while ((PWR->CSR1 & PWR_CSR1_ACTVOSRDY) == 0U)
{}
#elif defined(USE_PWR_SMPS_1V8_SUPPLIES_EXT) && defined(SMPS)
/* Exit Run* mode */
PWR->CR3 = (PWR->CR3 & ~(PWR_CR3_LDOEN)) | PWR_CR3_SMPSLEVEL_0 | PWR_CR3_SMPSEXTHP | PWR_CR3_SMPSEN | PWR_CR3_BYPASS;
/* Wait till voltage level flag is set */
while ((PWR->CSR1 & PWR_CSR1_ACTVOSRDY) == 0U)
{}
#elif defined(USE_PWR_SMPS_2V5_SUPPLIES_EXT) && defined(SMPS)
/* Exit Run* mode */
PWR->CR3 = (PWR->CR3 & ~(PWR_CR3_LDOEN)) | PWR_CR3_SMPSLEVEL_1 | PWR_CR3_SMPSEXTHP | PWR_CR3_SMPSEN | PWR_CR3_BYPASS;
/* Wait till voltage level flag is set */
while ((PWR->CSR1 & PWR_CSR1_ACTVOSRDY) == 0U)
{}
#else #else
/* No system power supply configuration is selected at exit Run* mode */ PWR->CR3 = (PWR->CR3 & ~(PWR_CR3_LDOEN)) | PWR_CR3_BYPASS;
#endif /* SMPS */
/* Wait till voltage level flag is set */
while ((PWR->CSR1 & PWR_CSR1_ACTVOSRDY) == 0U)
{
}
#elif defined(USE_PWR_DIRECT_SMPS_SUPPLY) && defined(SMPS)
/* Exit Run* mode */
PWR->CR3 &= ~(PWR_CR3_LDOEN);
/* Wait till voltage level flag is set */
while ((PWR->CSR1 & PWR_CSR1_ACTVOSRDY) == 0U)
{
}
#elif defined(USE_PWR_SMPS_1V8_SUPPLIES_LDO) && defined(SMPS)
/* Exit Run* mode */
PWR->CR3 |= PWR_CR3_SMPSLEVEL_0 | PWR_CR3_SMPSEN | PWR_CR3_LDOEN;
/* Wait till voltage level flag is set */
while ((PWR->CSR1 & PWR_CSR1_ACTVOSRDY) == 0U)
{
}
#elif defined(USE_PWR_SMPS_2V5_SUPPLIES_LDO) && defined(SMPS)
/* Exit Run* mode */
PWR->CR3 |= PWR_CR3_SMPSLEVEL_1 | PWR_CR3_SMPSEN | PWR_CR3_LDOEN;
/* Wait till voltage level flag is set */
while ((PWR->CSR1 & PWR_CSR1_ACTVOSRDY) == 0U)
{
}
#elif defined(USE_PWR_SMPS_1V8_SUPPLIES_EXT_AND_LDO) && defined(SMPS)
/* Exit Run* mode */
PWR->CR3 |= PWR_CR3_SMPSLEVEL_0 | PWR_CR3_SMPSEXTHP | PWR_CR3_SMPSEN | PWR_CR3_LDOEN;
/* Wait till voltage level flag is set */
while ((PWR->CSR1 & PWR_CSR1_ACTVOSRDY) == 0U)
{
}
#elif defined(USE_PWR_SMPS_2V5_SUPPLIES_EXT_AND_LDO) && defined(SMPS)
/* Exit Run* mode */
PWR->CR3 |= PWR_CR3_SMPSLEVEL_1 | PWR_CR3_SMPSEXTHP | PWR_CR3_SMPSEN | PWR_CR3_LDOEN;
/* Wait till voltage level flag is set */
while ((PWR->CSR1 & PWR_CSR1_ACTVOSRDY) == 0U)
{
}
#elif defined(USE_PWR_SMPS_1V8_SUPPLIES_EXT) && defined(SMPS)
/* Exit Run* mode */
PWR->CR3 = (PWR->CR3 & ~(PWR_CR3_LDOEN)) | PWR_CR3_SMPSLEVEL_0 | PWR_CR3_SMPSEXTHP | PWR_CR3_SMPSEN |
PWR_CR3_BYPASS;
/* Wait till voltage level flag is set */
while ((PWR->CSR1 & PWR_CSR1_ACTVOSRDY) == 0U)
{
}
#elif defined(USE_PWR_SMPS_2V5_SUPPLIES_EXT) && defined(SMPS)
/* Exit Run* mode */
PWR->CR3 = (PWR->CR3 & ~(PWR_CR3_LDOEN)) | PWR_CR3_SMPSLEVEL_1 | PWR_CR3_SMPSEXTHP | PWR_CR3_SMPSEN |
PWR_CR3_BYPASS;
/* Wait till voltage level flag is set */
while ((PWR->CSR1 & PWR_CSR1_ACTVOSRDY) == 0U)
{
}
#else
/* No system power supply configuration is selected at exit Run* mode */
#endif /* USE_PWR_LDO_SUPPLY */ #endif /* USE_PWR_LDO_SUPPLY */
} }

View File

@@ -55,7 +55,7 @@ void MX_UART5_Init(void)
huart5.Instance = UART5; huart5.Instance = UART5;
huart5.Init.BaudRate = 100000; huart5.Init.BaudRate = 100000;
huart5.Init.WordLength = UART_WORDLENGTH_9B; huart5.Init.WordLength = UART_WORDLENGTH_9B;
huart5.Init.StopBits = UART_STOPBITS_1; huart5.Init.StopBits = UART_STOPBITS_2;
huart5.Init.Parity = UART_PARITY_EVEN; huart5.Init.Parity = UART_PARITY_EVEN;
huart5.Init.Mode = UART_MODE_RX; huart5.Init.Mode = UART_MODE_RX;
huart5.Init.HwFlowCtl = UART_HWCONTROL_NONE; huart5.Init.HwFlowCtl = UART_HWCONTROL_NONE;
@@ -241,7 +241,7 @@ void MX_USART3_UART_Init(void)
huart3.Init.ClockPrescaler = UART_PRESCALER_DIV1; huart3.Init.ClockPrescaler = UART_PRESCALER_DIV1;
huart3.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_RXOVERRUNDISABLE_INIT; huart3.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_RXOVERRUNDISABLE_INIT;
huart3.AdvancedInit.OverrunDisable = UART_ADVFEATURE_OVERRUN_DISABLE; huart3.AdvancedInit.OverrunDisable = UART_ADVFEATURE_OVERRUN_DISABLE;
if (HAL_RS485Ex_Init(&huart3, UART_DE_POLARITY_HIGH, 0, 0) != HAL_OK) if (HAL_UART_Init(&huart3) != HAL_OK)
{ {
Error_Handler(); Error_Handler();
} }
@@ -361,8 +361,8 @@ void HAL_UART_MspInit(UART_HandleTypeDef* uartHandle)
hdma_uart5_rx.Init.MemInc = DMA_MINC_ENABLE; hdma_uart5_rx.Init.MemInc = DMA_MINC_ENABLE;
hdma_uart5_rx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE; hdma_uart5_rx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
hdma_uart5_rx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE; hdma_uart5_rx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
hdma_uart5_rx.Init.Mode = DMA_CIRCULAR; hdma_uart5_rx.Init.Mode = DMA_NORMAL;
hdma_uart5_rx.Init.Priority = DMA_PRIORITY_LOW; hdma_uart5_rx.Init.Priority = DMA_PRIORITY_VERY_HIGH;
hdma_uart5_rx.Init.FIFOMode = DMA_FIFOMODE_DISABLE; hdma_uart5_rx.Init.FIFOMode = DMA_FIFOMODE_DISABLE;
if (HAL_DMA_Init(&hdma_uart5_rx) != HAL_OK) if (HAL_DMA_Init(&hdma_uart5_rx) != HAL_OK)
{ {
@@ -601,20 +601,11 @@ void HAL_UART_MspInit(UART_HandleTypeDef* uartHandle)
/* USART3 clock enable */ /* USART3 clock enable */
__HAL_RCC_USART3_CLK_ENABLE(); __HAL_RCC_USART3_CLK_ENABLE();
__HAL_RCC_GPIOB_CLK_ENABLE();
__HAL_RCC_GPIOD_CLK_ENABLE(); __HAL_RCC_GPIOD_CLK_ENABLE();
/**USART3 GPIO Configuration /**USART3 GPIO Configuration
PB14 ------> USART3_DE
PD8 ------> USART3_TX PD8 ------> USART3_TX
PD9 ------> USART3_RX PD9 ------> USART3_RX
*/ */
GPIO_InitStruct.Pin = GPIO_PIN_14;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
GPIO_InitStruct.Alternate = GPIO_AF7_USART3;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
GPIO_InitStruct.Pin = GPIO_PIN_8|GPIO_PIN_9; GPIO_InitStruct.Pin = GPIO_PIN_8|GPIO_PIN_9;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Pull = GPIO_NOPULL;
@@ -858,12 +849,9 @@ void HAL_UART_MspDeInit(UART_HandleTypeDef* uartHandle)
__HAL_RCC_USART3_CLK_DISABLE(); __HAL_RCC_USART3_CLK_DISABLE();
/**USART3 GPIO Configuration /**USART3 GPIO Configuration
PB14 ------> USART3_DE
PD8 ------> USART3_TX PD8 ------> USART3_TX
PD9 ------> USART3_RX PD9 ------> USART3_RX
*/ */
HAL_GPIO_DeInit(GPIOB, GPIO_PIN_14);
HAL_GPIO_DeInit(GPIOD, GPIO_PIN_8|GPIO_PIN_9); HAL_GPIO_DeInit(GPIOD, GPIO_PIN_8|GPIO_PIN_9);
/* USART3 DMA DeInit */ /* USART3 DMA DeInit */

View File

@@ -0,0 +1,378 @@
/* ----------------------------------------------------------------------
* Project: CMSIS DSP Library
* Title: arm_common_tables.h
* Description: Extern declaration for common tables
*
* $Date: 27. January 2017
* $Revision: V.1.5.1
*
* Target Processor: Cortex-M cores
* -------------------------------------------------------------------- */
/*
* Copyright (C) 2010-2017 ARM Limited or its affiliates. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the License); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _ARM_COMMON_TABLES_H
#define _ARM_COMMON_TABLES_H
#include "arm_math.h"
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_FFT_ALLOW_TABLES)
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_BITREV_1024)
extern const uint16_t armBitRevTable[1024];
#endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_F32_16)
extern const float32_t twiddleCoef_16[32];
#endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_F32_32)
extern const float32_t twiddleCoef_32[64];
#endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_F32_64)
extern const float32_t twiddleCoef_64[128];
#endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_F32_128)
extern const float32_t twiddleCoef_128[256];
#endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_F32_256)
extern const float32_t twiddleCoef_256[512];
#endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_F32_512)
extern const float32_t twiddleCoef_512[1024];
#endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_F32_1024)
extern const float32_t twiddleCoef_1024[2048];
#endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_F32_2048)
extern const float32_t twiddleCoef_2048[4096];
#endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_F32_4096)
extern const float32_t twiddleCoef_4096[8192];
#define twiddleCoef twiddleCoef_4096
#endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_Q31_16)
extern const q31_t twiddleCoef_16_q31[24];
#endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_Q31_32)
extern const q31_t twiddleCoef_32_q31[48];
#endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_Q31_64)
extern const q31_t twiddleCoef_64_q31[96];
#endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_Q31_128)
extern const q31_t twiddleCoef_128_q31[192];
#endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_Q31_256)
extern const q31_t twiddleCoef_256_q31[384];
#endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_Q31_512)
extern const q31_t twiddleCoef_512_q31[768];
#endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_Q31_1024)
extern const q31_t twiddleCoef_1024_q31[1536];
#endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_Q31_2048)
extern const q31_t twiddleCoef_2048_q31[3072];
#endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_Q31_4096)
extern const q31_t twiddleCoef_4096_q31[6144];
#endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_Q15_16)
extern const q15_t twiddleCoef_16_q15[24];
#endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_Q15_32)
extern const q15_t twiddleCoef_32_q15[48];
#endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_Q15_64)
extern const q15_t twiddleCoef_64_q15[96];
#endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_Q15_128)
extern const q15_t twiddleCoef_128_q15[192];
#endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_Q15_256)
extern const q15_t twiddleCoef_256_q15[384];
#endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_Q15_512)
extern const q15_t twiddleCoef_512_q15[768];
#endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_Q15_1024)
extern const q15_t twiddleCoef_1024_q15[1536];
#endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_Q15_2048)
extern const q15_t twiddleCoef_2048_q15[3072];
#endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_Q15_4096)
extern const q15_t twiddleCoef_4096_q15[6144];
#endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_RFFT_F32_32)
extern const float32_t twiddleCoef_rfft_32[32];
#endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_RFFT_F32_64)
extern const float32_t twiddleCoef_rfft_64[64];
#endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_RFFT_F32_128)
extern const float32_t twiddleCoef_rfft_128[128];
#endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_RFFT_F32_256)
extern const float32_t twiddleCoef_rfft_256[256];
#endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_RFFT_F32_512)
extern const float32_t twiddleCoef_rfft_512[512];
#endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_RFFT_F32_1024)
extern const float32_t twiddleCoef_rfft_1024[1024];
#endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_RFFT_F32_2048)
extern const float32_t twiddleCoef_rfft_2048[2048];
#endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_RFFT_F32_4096)
extern const float32_t twiddleCoef_rfft_4096[4096];
#endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */
/* floating-point bit reversal tables */
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_BITREVIDX_FLT_16)
#define ARMBITREVINDEXTABLE_16_TABLE_LENGTH ((uint16_t)20)
extern const uint16_t armBitRevIndexTable16[ARMBITREVINDEXTABLE_16_TABLE_LENGTH];
#endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_BITREVIDX_FLT_32)
#define ARMBITREVINDEXTABLE_32_TABLE_LENGTH ((uint16_t)48)
extern const uint16_t armBitRevIndexTable32[ARMBITREVINDEXTABLE_32_TABLE_LENGTH];
#endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_BITREVIDX_FLT_64)
#define ARMBITREVINDEXTABLE_64_TABLE_LENGTH ((uint16_t)56)
extern const uint16_t armBitRevIndexTable64[ARMBITREVINDEXTABLE_64_TABLE_LENGTH];
#endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_BITREVIDX_FLT_128)
#define ARMBITREVINDEXTABLE_128_TABLE_LENGTH ((uint16_t)208)
extern const uint16_t armBitRevIndexTable128[ARMBITREVINDEXTABLE_128_TABLE_LENGTH];
#endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_BITREVIDX_FLT_256)
#define ARMBITREVINDEXTABLE_256_TABLE_LENGTH ((uint16_t)440)
extern const uint16_t armBitRevIndexTable256[ARMBITREVINDEXTABLE_256_TABLE_LENGTH];
#endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_BITREVIDX_FLT_512)
#define ARMBITREVINDEXTABLE_512_TABLE_LENGTH ((uint16_t)448)
extern const uint16_t armBitRevIndexTable512[ARMBITREVINDEXTABLE_512_TABLE_LENGTH];
#endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_BITREVIDX_FLT_1024)
#define ARMBITREVINDEXTABLE_1024_TABLE_LENGTH ((uint16_t)1800)
extern const uint16_t armBitRevIndexTable1024[ARMBITREVINDEXTABLE_1024_TABLE_LENGTH];
#endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_BITREVIDX_FLT_2048)
#define ARMBITREVINDEXTABLE_2048_TABLE_LENGTH ((uint16_t)3808)
extern const uint16_t armBitRevIndexTable2048[ARMBITREVINDEXTABLE_2048_TABLE_LENGTH];
#endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_BITREVIDX_FLT_4096)
#define ARMBITREVINDEXTABLE_4096_TABLE_LENGTH ((uint16_t)4032)
extern const uint16_t armBitRevIndexTable4096[ARMBITREVINDEXTABLE_4096_TABLE_LENGTH];
#endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */
/* fixed-point bit reversal tables */
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_BITREVIDX_FXT_16)
#define ARMBITREVINDEXTABLE_FIXED_16_TABLE_LENGTH ((uint16_t)12)
extern const uint16_t armBitRevIndexTable_fixed_16[ARMBITREVINDEXTABLE_FIXED_16_TABLE_LENGTH];
#endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_BITREVIDX_FXT_32)
#define ARMBITREVINDEXTABLE_FIXED_32_TABLE_LENGTH ((uint16_t)24)
extern const uint16_t armBitRevIndexTable_fixed_32[ARMBITREVINDEXTABLE_FIXED_32_TABLE_LENGTH];
#endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_BITREVIDX_FXT_64)
#define ARMBITREVINDEXTABLE_FIXED_64_TABLE_LENGTH ((uint16_t)56)
extern const uint16_t armBitRevIndexTable_fixed_64[ARMBITREVINDEXTABLE_FIXED_64_TABLE_LENGTH];
#endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_BITREVIDX_FXT_128)
#define ARMBITREVINDEXTABLE_FIXED_128_TABLE_LENGTH ((uint16_t)112)
extern const uint16_t armBitRevIndexTable_fixed_128[ARMBITREVINDEXTABLE_FIXED_128_TABLE_LENGTH];
#endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_BITREVIDX_FXT_256)
#define ARMBITREVINDEXTABLE_FIXED_256_TABLE_LENGTH ((uint16_t)240)
extern const uint16_t armBitRevIndexTable_fixed_256[ARMBITREVINDEXTABLE_FIXED_256_TABLE_LENGTH];
#endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_BITREVIDX_FXT_512)
#define ARMBITREVINDEXTABLE_FIXED_512_TABLE_LENGTH ((uint16_t)480)
extern const uint16_t armBitRevIndexTable_fixed_512[ARMBITREVINDEXTABLE_FIXED_512_TABLE_LENGTH];
#endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_BITREVIDX_FXT_1024)
#define ARMBITREVINDEXTABLE_FIXED_1024_TABLE_LENGTH ((uint16_t)992)
extern const uint16_t armBitRevIndexTable_fixed_1024[ARMBITREVINDEXTABLE_FIXED_1024_TABLE_LENGTH];
#endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_BITREVIDX_FXT_2048)
#define ARMBITREVINDEXTABLE_FIXED_2048_TABLE_LENGTH ((uint16_t)1984)
extern const uint16_t armBitRevIndexTable_fixed_2048[ARMBITREVINDEXTABLE_FIXED_2048_TABLE_LENGTH];
#endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_BITREVIDX_FXT_4096)
#define ARMBITREVINDEXTABLE_FIXED_4096_TABLE_LENGTH ((uint16_t)4032)
extern const uint16_t armBitRevIndexTable_fixed_4096[ARMBITREVINDEXTABLE_FIXED_4096_TABLE_LENGTH];
#endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_REALCOEF_F32)
extern const float32_t realCoefA[8192];
extern const float32_t realCoefB[8192];
#endif
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_REALCOEF_Q31)
extern const q31_t realCoefAQ31[8192];
extern const q31_t realCoefBQ31[8192];
#endif
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_REALCOEF_Q15)
extern const q15_t realCoefAQ15[8192];
extern const q15_t realCoefBQ15[8192];
#endif
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_DCT4_F32_128)
extern const float32_t Weights_128[256];
extern const float32_t cos_factors_128[128];
#endif
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_DCT4_F32_512)
extern const float32_t Weights_512[1024];
extern const float32_t cos_factors_512[512];
#endif
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_DCT4_F32_2048)
extern const float32_t Weights_2048[4096];
extern const float32_t cos_factors_2048[2048];
#endif
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_DCT4_F32_8192)
extern const float32_t Weights_8192[16384];
extern const float32_t cos_factors_8192[8192];
#endif
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_DCT4_Q15_128)
extern const q15_t WeightsQ15_128[256];
extern const q15_t cos_factorsQ15_128[128];
#endif
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_DCT4_Q15_512)
extern const q15_t WeightsQ15_512[1024];
extern const q15_t cos_factorsQ15_512[512];
#endif
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_DCT4_Q15_2048)
extern const q15_t WeightsQ15_2048[4096];
extern const q15_t cos_factorsQ15_2048[2048];
#endif
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_DCT4_Q15_8192)
extern const q15_t WeightsQ15_8192[16384];
extern const q15_t cos_factorsQ15_8192[8192];
#endif
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_DCT4_Q31_128)
extern const q31_t WeightsQ31_128[256];
extern const q31_t cos_factorsQ31_128[128];
#endif
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_DCT4_Q31_512)
extern const q31_t WeightsQ31_512[1024];
extern const q31_t cos_factorsQ31_512[512];
#endif
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_DCT4_Q31_2048)
extern const q31_t WeightsQ31_2048[4096];
extern const q31_t cos_factorsQ31_2048[2048];
#endif
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_DCT4_Q31_8192)
extern const q31_t WeightsQ31_8192[16384];
extern const q31_t cos_factorsQ31_8192[8192];
#endif
#endif /* if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_FFT_TABLES) */
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_FAST_ALLOW_TABLES)
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FAST_TABLES) || defined(ARM_TABLE_RECIP_Q15)
extern const q15_t armRecipTableQ15[64];
#endif /* !defined(ARM_DSP_CONFIG_TABLES) defined(ARM_ALL_FAST_TABLES) */
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FAST_TABLES) || defined(ARM_TABLE_RECIP_Q31)
extern const q31_t armRecipTableQ31[64];
#endif /* !defined(ARM_DSP_CONFIG_TABLES) defined(ARM_ALL_FAST_TABLES) */
/* Tables for Fast Math Sine and Cosine */
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FAST_TABLES) || defined(ARM_TABLE_SIN_F32)
extern const float32_t sinTable_f32[FAST_MATH_TABLE_SIZE + 1];
#endif /* !defined(ARM_DSP_CONFIG_TABLES) defined(ARM_ALL_FAST_TABLES) */
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FAST_TABLES) || defined(ARM_TABLE_SIN_Q31)
extern const q31_t sinTable_q31[FAST_MATH_TABLE_SIZE + 1];
#endif /* !defined(ARM_DSP_CONFIG_TABLES) defined(ARM_ALL_FAST_TABLES) */
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FAST_TABLES) || defined(ARM_TABLE_SIN_Q15)
extern const q15_t sinTable_q15[FAST_MATH_TABLE_SIZE + 1];
#endif /* !defined(ARM_DSP_CONFIG_TABLES) defined(ARM_ALL_FAST_TABLES) */
#endif /* if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_FAST_TABLES) */
#endif /* ARM_COMMON_TABLES_H */

View File

@@ -0,0 +1,66 @@
/* ----------------------------------------------------------------------
* Project: CMSIS DSP Library
* Title: arm_const_structs.h
* Description: Constant structs that are initialized for user convenience.
* For example, some can be given as arguments to the arm_cfft_f32() function.
*
* $Date: 27. January 2017
* $Revision: V.1.5.1
*
* Target Processor: Cortex-M cores
* -------------------------------------------------------------------- */
/*
* Copyright (C) 2010-2017 ARM Limited or its affiliates. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the License); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _ARM_CONST_STRUCTS_H
#define _ARM_CONST_STRUCTS_H
#include "arm_math.h"
#include "arm_common_tables.h"
extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len16;
extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len32;
extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len64;
extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len128;
extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len256;
extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len512;
extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len1024;
extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len2048;
extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len4096;
extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len16;
extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len32;
extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len64;
extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len128;
extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len256;
extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len512;
extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len1024;
extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len2048;
extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len4096;
extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len16;
extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len32;
extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len64;
extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len128;
extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len256;
extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len512;
extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len1024;
extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len2048;
extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len4096;
#endif

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -1,237 +0,0 @@
/**
******************************************************************************
* @file stm32h7xx_hal_iwdg.h
* @author MCD Application Team
* @brief Header file of IWDG HAL module.
******************************************************************************
* @attention
*
* Copyright (c) 2017 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.
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef STM32H7xx_HAL_IWDG_H
#define STM32H7xx_HAL_IWDG_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "stm32h7xx_hal_def.h"
/** @addtogroup STM32H7xx_HAL_Driver
* @{
*/
/** @defgroup IWDG IWDG
* @{
*/
/* Exported types ------------------------------------------------------------*/
/** @defgroup IWDG_Exported_Types IWDG Exported Types
* @{
*/
/**
* @brief IWDG Init structure definition
*/
typedef struct
{
uint32_t Prescaler; /*!< Select the prescaler of the IWDG.
This parameter can be a value of @ref IWDG_Prescaler */
uint32_t Reload; /*!< Specifies the IWDG down-counter reload value.
This parameter must be a number between Min_Data = 0 and Max_Data = 0x0FFF */
uint32_t Window; /*!< Specifies the window value to be compared to the down-counter.
This parameter must be a number between Min_Data = 0 and Max_Data = 0x0FFF */
} IWDG_InitTypeDef;
/**
* @brief IWDG Handle Structure definition
*/
typedef struct
{
IWDG_TypeDef *Instance; /*!< Register base address */
IWDG_InitTypeDef Init; /*!< IWDG required parameters */
} IWDG_HandleTypeDef;
/**
* @}
*/
/* Exported constants --------------------------------------------------------*/
/** @defgroup IWDG_Exported_Constants IWDG Exported Constants
* @{
*/
/** @defgroup IWDG_Prescaler IWDG Prescaler
* @{
*/
#define IWDG_PRESCALER_4 0x00000000u /*!< IWDG prescaler set to 4 */
#define IWDG_PRESCALER_8 IWDG_PR_PR_0 /*!< IWDG prescaler set to 8 */
#define IWDG_PRESCALER_16 IWDG_PR_PR_1 /*!< IWDG prescaler set to 16 */
#define IWDG_PRESCALER_32 (IWDG_PR_PR_1 | IWDG_PR_PR_0) /*!< IWDG prescaler set to 32 */
#define IWDG_PRESCALER_64 IWDG_PR_PR_2 /*!< IWDG prescaler set to 64 */
#define IWDG_PRESCALER_128 (IWDG_PR_PR_2 | IWDG_PR_PR_0) /*!< IWDG prescaler set to 128 */
#define IWDG_PRESCALER_256 (IWDG_PR_PR_2 | IWDG_PR_PR_1) /*!< IWDG prescaler set to 256 */
/**
* @}
*/
/** @defgroup IWDG_Window_option IWDG Window option
* @{
*/
#define IWDG_WINDOW_DISABLE IWDG_WINR_WIN
/**
* @}
*/
/**
* @}
*/
/* Exported macros -----------------------------------------------------------*/
/** @defgroup IWDG_Exported_Macros IWDG Exported Macros
* @{
*/
/**
* @brief Enable the IWDG peripheral.
* @param __HANDLE__ IWDG handle
* @retval None
*/
#define __HAL_IWDG_START(__HANDLE__) WRITE_REG((__HANDLE__)->Instance->KR, IWDG_KEY_ENABLE)
/**
* @brief Reload IWDG counter with value defined in the reload register
* (write access to IWDG_PR, IWDG_RLR and IWDG_WINR registers disabled).
* @param __HANDLE__ IWDG handle
* @retval None
*/
#define __HAL_IWDG_RELOAD_COUNTER(__HANDLE__) WRITE_REG((__HANDLE__)->Instance->KR, IWDG_KEY_RELOAD)
/**
* @}
*/
/* Exported functions --------------------------------------------------------*/
/** @defgroup IWDG_Exported_Functions IWDG Exported Functions
* @{
*/
/** @defgroup IWDG_Exported_Functions_Group1 Initialization and Start functions
* @{
*/
/* Initialization/Start functions ********************************************/
HAL_StatusTypeDef HAL_IWDG_Init(IWDG_HandleTypeDef *hiwdg);
/**
* @}
*/
/** @defgroup IWDG_Exported_Functions_Group2 IO operation functions
* @{
*/
/* I/O operation functions ****************************************************/
HAL_StatusTypeDef HAL_IWDG_Refresh(IWDG_HandleTypeDef *hiwdg);
/**
* @}
*/
/**
* @}
*/
/* Private constants ---------------------------------------------------------*/
/** @defgroup IWDG_Private_Constants IWDG Private Constants
* @{
*/
/**
* @brief IWDG Key Register BitMask
*/
#define IWDG_KEY_RELOAD 0x0000AAAAu /*!< IWDG Reload Counter Enable */
#define IWDG_KEY_ENABLE 0x0000CCCCu /*!< IWDG Peripheral Enable */
#define IWDG_KEY_WRITE_ACCESS_ENABLE 0x00005555u /*!< IWDG KR Write Access Enable */
#define IWDG_KEY_WRITE_ACCESS_DISABLE 0x00000000u /*!< IWDG KR Write Access Disable */
/**
* @}
*/
/* Private macros ------------------------------------------------------------*/
/** @defgroup IWDG_Private_Macros IWDG Private Macros
* @{
*/
/**
* @brief Enable write access to IWDG_PR, IWDG_RLR and IWDG_WINR registers.
* @param __HANDLE__ IWDG handle
* @retval None
*/
#define IWDG_ENABLE_WRITE_ACCESS(__HANDLE__) WRITE_REG((__HANDLE__)->Instance->KR, IWDG_KEY_WRITE_ACCESS_ENABLE)
/**
* @brief Disable write access to IWDG_PR, IWDG_RLR and IWDG_WINR registers.
* @param __HANDLE__ IWDG handle
* @retval None
*/
#define IWDG_DISABLE_WRITE_ACCESS(__HANDLE__) WRITE_REG((__HANDLE__)->Instance->KR, IWDG_KEY_WRITE_ACCESS_DISABLE)
/**
* @brief Check IWDG prescaler value.
* @param __PRESCALER__ IWDG prescaler value
* @retval None
*/
#define IS_IWDG_PRESCALER(__PRESCALER__) (((__PRESCALER__) == IWDG_PRESCALER_4) || \
((__PRESCALER__) == IWDG_PRESCALER_8) || \
((__PRESCALER__) == IWDG_PRESCALER_16) || \
((__PRESCALER__) == IWDG_PRESCALER_32) || \
((__PRESCALER__) == IWDG_PRESCALER_64) || \
((__PRESCALER__) == IWDG_PRESCALER_128)|| \
((__PRESCALER__) == IWDG_PRESCALER_256))
/**
* @brief Check IWDG reload value.
* @param __RELOAD__ IWDG reload value
* @retval None
*/
#define IS_IWDG_RELOAD(__RELOAD__) ((__RELOAD__) <= IWDG_RLR_RL)
/**
* @brief Check IWDG window value.
* @param __WINDOW__ IWDG window value
* @retval None
*/
#define IS_IWDG_WINDOW(__WINDOW__) ((__WINDOW__) <= IWDG_WINR_WIN)
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* STM32H7xx_HAL_IWDG_H */

View File

@@ -1,338 +0,0 @@
/**
******************************************************************************
* @file stm32h7xx_ll_iwdg.h
* @author MCD Application Team
* @brief Header file of IWDG LL module.
******************************************************************************
* @attention
*
* Copyright (c) 2017 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.
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef STM32H7xx_LL_IWDG_H
#define STM32H7xx_LL_IWDG_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "stm32h7xx.h"
/** @addtogroup STM32H7xx_LL_Driver
* @{
*/
#if defined(IWDG1) || defined(IWDG2)
/** @defgroup IWDG_LL IWDG
* @{
*/
/* Private types -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/* Private constants ---------------------------------------------------------*/
/** @defgroup IWDG_LL_Private_Constants IWDG Private Constants
* @{
*/
#define LL_IWDG_KEY_RELOAD 0x0000AAAAU /*!< IWDG Reload Counter Enable */
#define LL_IWDG_KEY_ENABLE 0x0000CCCCU /*!< IWDG Peripheral Enable */
#define LL_IWDG_KEY_WR_ACCESS_ENABLE 0x00005555U /*!< IWDG KR Write Access Enable */
#define LL_IWDG_KEY_WR_ACCESS_DISABLE 0x00000000U /*!< IWDG KR Write Access Disable */
/**
* @}
*/
/* Private macros ------------------------------------------------------------*/
/* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/
/** @defgroup IWDG_LL_Exported_Constants IWDG Exported Constants
* @{
*/
/** @defgroup IWDG_LL_EC_GET_FLAG Get Flags Defines
* @brief Flags defines which can be used with LL_IWDG_ReadReg function
* @{
*/
#define LL_IWDG_SR_PVU IWDG_SR_PVU /*!< Watchdog prescaler value update */
#define LL_IWDG_SR_RVU IWDG_SR_RVU /*!< Watchdog counter reload value update */
#define LL_IWDG_SR_WVU IWDG_SR_WVU /*!< Watchdog counter window value update */
/**
* @}
*/
/** @defgroup IWDG_LL_EC_PRESCALER Prescaler Divider
* @{
*/
#define LL_IWDG_PRESCALER_4 0x00000000U /*!< Divider by 4 */
#define LL_IWDG_PRESCALER_8 (IWDG_PR_PR_0) /*!< Divider by 8 */
#define LL_IWDG_PRESCALER_16 (IWDG_PR_PR_1) /*!< Divider by 16 */
#define LL_IWDG_PRESCALER_32 (IWDG_PR_PR_1 | IWDG_PR_PR_0) /*!< Divider by 32 */
#define LL_IWDG_PRESCALER_64 (IWDG_PR_PR_2) /*!< Divider by 64 */
#define LL_IWDG_PRESCALER_128 (IWDG_PR_PR_2 | IWDG_PR_PR_0) /*!< Divider by 128 */
#define LL_IWDG_PRESCALER_256 (IWDG_PR_PR_2 | IWDG_PR_PR_1) /*!< Divider by 256 */
/**
* @}
*/
/**
* @}
*/
/* Exported macro ------------------------------------------------------------*/
/** @defgroup IWDG_LL_Exported_Macros IWDG Exported Macros
* @{
*/
/** @defgroup IWDG_LL_EM_WRITE_READ Common Write and read registers Macros
* @{
*/
/**
* @brief Write a value in IWDG register
* @param __INSTANCE__ IWDG Instance
* @param __REG__ Register to be written
* @param __VALUE__ Value to be written in the register
* @retval None
*/
#define LL_IWDG_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
/**
* @brief Read a value in IWDG register
* @param __INSTANCE__ IWDG Instance
* @param __REG__ Register to be read
* @retval Register value
*/
#define LL_IWDG_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
/**
* @}
*/
/**
* @}
*/
/* Exported functions --------------------------------------------------------*/
/** @defgroup IWDG_LL_Exported_Functions IWDG Exported Functions
* @{
*/
/** @defgroup IWDG_LL_EF_Configuration Configuration
* @{
*/
/**
* @brief Start the Independent Watchdog
* @note Except if the hardware watchdog option is selected
* @rmtoll KR KEY LL_IWDG_Enable
* @param IWDGx IWDG Instance
* @retval None
*/
__STATIC_INLINE void LL_IWDG_Enable(IWDG_TypeDef *IWDGx)
{
WRITE_REG(IWDGx->KR, LL_IWDG_KEY_ENABLE);
}
/**
* @brief Reloads IWDG counter with value defined in the reload register
* @rmtoll KR KEY LL_IWDG_ReloadCounter
* @param IWDGx IWDG Instance
* @retval None
*/
__STATIC_INLINE void LL_IWDG_ReloadCounter(IWDG_TypeDef *IWDGx)
{
WRITE_REG(IWDGx->KR, LL_IWDG_KEY_RELOAD);
}
/**
* @brief Enable write access to IWDG_PR, IWDG_RLR and IWDG_WINR registers
* @rmtoll KR KEY LL_IWDG_EnableWriteAccess
* @param IWDGx IWDG Instance
* @retval None
*/
__STATIC_INLINE void LL_IWDG_EnableWriteAccess(IWDG_TypeDef *IWDGx)
{
WRITE_REG(IWDGx->KR, LL_IWDG_KEY_WR_ACCESS_ENABLE);
}
/**
* @brief Disable write access to IWDG_PR, IWDG_RLR and IWDG_WINR registers
* @rmtoll KR KEY LL_IWDG_DisableWriteAccess
* @param IWDGx IWDG Instance
* @retval None
*/
__STATIC_INLINE void LL_IWDG_DisableWriteAccess(IWDG_TypeDef *IWDGx)
{
WRITE_REG(IWDGx->KR, LL_IWDG_KEY_WR_ACCESS_DISABLE);
}
/**
* @brief Select the prescaler of the IWDG
* @rmtoll PR PR LL_IWDG_SetPrescaler
* @param IWDGx IWDG Instance
* @param Prescaler This parameter can be one of the following values:
* @arg @ref LL_IWDG_PRESCALER_4
* @arg @ref LL_IWDG_PRESCALER_8
* @arg @ref LL_IWDG_PRESCALER_16
* @arg @ref LL_IWDG_PRESCALER_32
* @arg @ref LL_IWDG_PRESCALER_64
* @arg @ref LL_IWDG_PRESCALER_128
* @arg @ref LL_IWDG_PRESCALER_256
* @retval None
*/
__STATIC_INLINE void LL_IWDG_SetPrescaler(IWDG_TypeDef *IWDGx, uint32_t Prescaler)
{
WRITE_REG(IWDGx->PR, IWDG_PR_PR & Prescaler);
}
/**
* @brief Get the selected prescaler of the IWDG
* @rmtoll PR PR LL_IWDG_GetPrescaler
* @param IWDGx IWDG Instance
* @retval Returned value can be one of the following values:
* @arg @ref LL_IWDG_PRESCALER_4
* @arg @ref LL_IWDG_PRESCALER_8
* @arg @ref LL_IWDG_PRESCALER_16
* @arg @ref LL_IWDG_PRESCALER_32
* @arg @ref LL_IWDG_PRESCALER_64
* @arg @ref LL_IWDG_PRESCALER_128
* @arg @ref LL_IWDG_PRESCALER_256
*/
__STATIC_INLINE uint32_t LL_IWDG_GetPrescaler(const IWDG_TypeDef *IWDGx)
{
return (READ_REG(IWDGx->PR));
}
/**
* @brief Specify the IWDG down-counter reload value
* @rmtoll RLR RL LL_IWDG_SetReloadCounter
* @param IWDGx IWDG Instance
* @param Counter Value between Min_Data=0 and Max_Data=0x0FFF
* @retval None
*/
__STATIC_INLINE void LL_IWDG_SetReloadCounter(IWDG_TypeDef *IWDGx, uint32_t Counter)
{
WRITE_REG(IWDGx->RLR, IWDG_RLR_RL & Counter);
}
/**
* @brief Get the specified IWDG down-counter reload value
* @rmtoll RLR RL LL_IWDG_GetReloadCounter
* @param IWDGx IWDG Instance
* @retval Value between Min_Data=0 and Max_Data=0x0FFF
*/
__STATIC_INLINE uint32_t LL_IWDG_GetReloadCounter(const IWDG_TypeDef *IWDGx)
{
return (READ_REG(IWDGx->RLR));
}
/**
* @brief Specify high limit of the window value to be compared to the down-counter.
* @rmtoll WINR WIN LL_IWDG_SetWindow
* @param IWDGx IWDG Instance
* @param Window Value between Min_Data=0 and Max_Data=0x0FFF
* @retval None
*/
__STATIC_INLINE void LL_IWDG_SetWindow(IWDG_TypeDef *IWDGx, uint32_t Window)
{
WRITE_REG(IWDGx->WINR, IWDG_WINR_WIN & Window);
}
/**
* @brief Get the high limit of the window value specified.
* @rmtoll WINR WIN LL_IWDG_GetWindow
* @param IWDGx IWDG Instance
* @retval Value between Min_Data=0 and Max_Data=0x0FFF
*/
__STATIC_INLINE uint32_t LL_IWDG_GetWindow(const IWDG_TypeDef *IWDGx)
{
return (READ_REG(IWDGx->WINR));
}
/**
* @}
*/
/** @defgroup IWDG_LL_EF_FLAG_Management FLAG_Management
* @{
*/
/**
* @brief Check if flag Prescaler Value Update is set or not
* @rmtoll SR PVU LL_IWDG_IsActiveFlag_PVU
* @param IWDGx IWDG Instance
* @retval State of bit (1 or 0).
*/
__STATIC_INLINE uint32_t LL_IWDG_IsActiveFlag_PVU(const IWDG_TypeDef *IWDGx)
{
return ((READ_BIT(IWDGx->SR, IWDG_SR_PVU) == (IWDG_SR_PVU)) ? 1UL : 0UL);
}
/**
* @brief Check if flag Reload Value Update is set or not
* @rmtoll SR RVU LL_IWDG_IsActiveFlag_RVU
* @param IWDGx IWDG Instance
* @retval State of bit (1 or 0).
*/
__STATIC_INLINE uint32_t LL_IWDG_IsActiveFlag_RVU(const IWDG_TypeDef *IWDGx)
{
return ((READ_BIT(IWDGx->SR, IWDG_SR_RVU) == (IWDG_SR_RVU)) ? 1UL : 0UL);
}
/**
* @brief Check if flag Window Value Update is set or not
* @rmtoll SR WVU LL_IWDG_IsActiveFlag_WVU
* @param IWDGx IWDG Instance
* @retval State of bit (1 or 0).
*/
__STATIC_INLINE uint32_t LL_IWDG_IsActiveFlag_WVU(const IWDG_TypeDef *IWDGx)
{
return ((READ_BIT(IWDGx->SR, IWDG_SR_WVU) == (IWDG_SR_WVU)) ? 1UL : 0UL);
}
/**
* @brief Check if all flags Prescaler, Reload & Window Value Update are reset or not
* @rmtoll SR PVU LL_IWDG_IsReady\n
* SR RVU LL_IWDG_IsReady\n
* SR WVU LL_IWDG_IsReady
* @param IWDGx IWDG Instance
* @retval State of bits (1 or 0).
*/
__STATIC_INLINE uint32_t LL_IWDG_IsReady(const IWDG_TypeDef *IWDGx)
{
return ((READ_BIT(IWDGx->SR, IWDG_SR_PVU | IWDG_SR_RVU | IWDG_SR_WVU) == 0U) ? 1UL : 0UL);
}
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#endif /* IWDG1 || IWDG2 */
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* STM32H7xx_LL_IWDG_H */

View File

@@ -1,284 +0,0 @@
/**
******************************************************************************
* @file stm32h7xx_hal_iwdg.c
* @author MCD Application Team
* @brief IWDG HAL module driver.
* This file provides firmware functions to manage the following
* functionalities of the Independent Watchdog (IWDG) peripheral:
* + Initialization and Start functions
* + IO operation functions
*
******************************************************************************
* @attention
*
* Copyright (c) 2017 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.
*
******************************************************************************
@verbatim
==============================================================================
##### IWDG Generic features #####
==============================================================================
[..]
(+) The IWDG can be started by either software or hardware (configurable
through option byte).
(+) The IWDG is clocked by the Low-Speed Internal clock (LSI) and thus stays
active even if the main clock fails.
(+) Once the IWDG is started, the LSI is forced ON and both cannot be
disabled. The counter starts counting down from the reset value (0xFFF).
When it reaches the end of count value (0x000) a reset signal is
generated (IWDG reset).
(+) Whenever the key value 0x0000 AAAA is written in the IWDG_KR register,
the IWDG_RLR value is reloaded into the counter and the watchdog reset
is prevented.
(+) The IWDG is implemented in the VDD voltage domain that is still functional
in STOP and STANDBY mode (IWDG reset can wake up the CPU from STANDBY).
IWDGRST flag in RCC_CSR register can be used to inform when an IWDG
reset occurs.
(+) Debug mode: When the microcontroller enters debug mode (core halted),
the IWDG counter either continues to work normally or stops, depending
on DBG_IWDG_STOP configuration bit in DBG module, accessible through
__HAL_DBGMCU_FREEZE_IWDG1() or __HAL_DBGMCU_FREEZE2_IWDG2() and
__HAL_DBGMCU_UnFreeze_IWDG1 or __HAL_DBGMCU_UnFreeze2_IWDG2() macros.
[..] Min-max timeout value @32KHz (LSI): ~125us / ~32.7s
The IWDG timeout may vary due to LSI clock frequency dispersion.
STM32H7xx devices provide the capability to measure the LSI clock
frequency (LSI clock is internally connected to TIM16 CH1 input capture).
The measured value can be used to have an IWDG timeout with an
acceptable accuracy.
[..] Default timeout value (necessary for IWDG_SR status register update):
Constant LSI_VALUE is defined based on the nominal LSI clock frequency.
This frequency being subject to variations as mentioned above, the
default timeout value (defined through constant HAL_IWDG_DEFAULT_TIMEOUT
below) may become too short or too long.
In such cases, this default timeout value can be tuned by redefining
the constant LSI_VALUE at user-application level (based, for instance,
on the measured LSI clock frequency as explained above).
##### How to use this driver #####
==============================================================================
[..]
(#) Use IWDG using HAL_IWDG_Init() function to :
(++) Enable instance by writing Start keyword in IWDG_KEY register. LSI
clock is forced ON and IWDG counter starts counting down.
(++) Enable write access to configuration registers:
IWDG_PR, IWDG_RLR and IWDG_WINR.
(++) Configure the IWDG prescaler and counter reload value. This reload
value will be loaded in the IWDG counter each time the watchdog is
reloaded, then the IWDG will start counting down from this value.
(++) Depending on window parameter:
(+++) If Window Init parameter is same as Window register value,
nothing more is done but reload counter value in order to exit
function with exact time base.
(+++) Else modify Window register. This will automatically reload
watchdog counter.
(++) Wait for status flags to be reset.
(#) Then the application program must refresh the IWDG counter at regular
intervals during normal operation to prevent an MCU reset, using
HAL_IWDG_Refresh() function.
*** IWDG HAL driver macros list ***
====================================
[..]
Below the list of most used macros in IWDG HAL driver:
(+) __HAL_IWDG_START: Enable the IWDG peripheral
(+) __HAL_IWDG_RELOAD_COUNTER: Reloads IWDG counter with value defined in
the reload register
@endverbatim
*/
/* Includes ------------------------------------------------------------------*/
#include "stm32h7xx_hal.h"
/** @addtogroup STM32H7xx_HAL_Driver
* @{
*/
#ifdef HAL_IWDG_MODULE_ENABLED
/** @addtogroup IWDG
* @brief IWDG HAL module driver.
* @{
*/
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/** @defgroup IWDG_Private_Defines IWDG Private Defines
* @{
*/
/* Status register needs up to 5 LSI clock periods divided by the clock
prescaler to be updated. The number of LSI clock periods is upper-rounded to
6 for the timeout value calculation.
The timeout value is calculated using the highest prescaler (256) and
the LSI_VALUE constant. The value of this constant can be changed by the user
to take into account possible LSI clock period variations.
The timeout value is multiplied by 1000 to be converted in milliseconds.
LSI startup time is also considered here by adding LSI_STARTUP_TIME
converted in milliseconds. */
#define HAL_IWDG_DEFAULT_TIMEOUT (((6UL * 256UL * 1000UL) / (LSI_VALUE / 128U)) + \
((LSI_STARTUP_TIME / 1000UL) + 1UL))
#define IWDG_KERNEL_UPDATE_FLAGS (IWDG_SR_WVU | IWDG_SR_RVU | IWDG_SR_PVU)
/**
* @}
*/
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/* Private function prototypes -----------------------------------------------*/
/* Exported functions --------------------------------------------------------*/
/** @addtogroup IWDG_Exported_Functions
* @{
*/
/** @addtogroup IWDG_Exported_Functions_Group1
* @brief Initialization and Start functions.
*
@verbatim
===============================================================================
##### Initialization and Start functions #####
===============================================================================
[..] This section provides functions allowing to:
(+) Initialize the IWDG according to the specified parameters in the
IWDG_InitTypeDef of associated handle.
(+) Manage Window option.
(+) Once initialization is performed in HAL_IWDG_Init function, Watchdog
is reloaded in order to exit function with correct time base.
@endverbatim
* @{
*/
/**
* @brief Initialize the IWDG according to the specified parameters in the
* IWDG_InitTypeDef and start watchdog. Before exiting function,
* watchdog is refreshed in order to have correct time base.
* @param hiwdg pointer to a IWDG_HandleTypeDef structure that contains
* the configuration information for the specified IWDG module.
* @retval HAL status
*/
HAL_StatusTypeDef HAL_IWDG_Init(IWDG_HandleTypeDef *hiwdg)
{
uint32_t tickstart;
/* Check the IWDG handle allocation */
if (hiwdg == NULL)
{
return HAL_ERROR;
}
/* Check the parameters */
assert_param(IS_IWDG_ALL_INSTANCE(hiwdg->Instance));
assert_param(IS_IWDG_PRESCALER(hiwdg->Init.Prescaler));
assert_param(IS_IWDG_RELOAD(hiwdg->Init.Reload));
assert_param(IS_IWDG_WINDOW(hiwdg->Init.Window));
/* Enable IWDG. LSI is turned on automatically */
__HAL_IWDG_START(hiwdg);
/* Enable write access to IWDG_PR, IWDG_RLR and IWDG_WINR registers by writing
0x5555 in KR */
IWDG_ENABLE_WRITE_ACCESS(hiwdg);
/* Write to IWDG registers the Prescaler & Reload values to work with */
hiwdg->Instance->PR = hiwdg->Init.Prescaler;
hiwdg->Instance->RLR = hiwdg->Init.Reload;
/* Check pending flag, if previous update not done, return timeout */
tickstart = HAL_GetTick();
/* Wait for register to be updated */
while ((hiwdg->Instance->SR & IWDG_KERNEL_UPDATE_FLAGS) != 0x00u)
{
if ((HAL_GetTick() - tickstart) > HAL_IWDG_DEFAULT_TIMEOUT)
{
if ((hiwdg->Instance->SR & IWDG_KERNEL_UPDATE_FLAGS) != 0x00u)
{
return HAL_TIMEOUT;
}
}
}
/* If window parameter is different than current value, modify window
register */
if (hiwdg->Instance->WINR != hiwdg->Init.Window)
{
/* Write to IWDG WINR the IWDG_Window value to compare with. In any case,
even if window feature is disabled, Watchdog will be reloaded by writing
windows register */
hiwdg->Instance->WINR = hiwdg->Init.Window;
}
else
{
/* Reload IWDG counter with value defined in the reload register */
__HAL_IWDG_RELOAD_COUNTER(hiwdg);
}
/* Return function status */
return HAL_OK;
}
/**
* @}
*/
/** @addtogroup IWDG_Exported_Functions_Group2
* @brief IO operation functions
*
@verbatim
===============================================================================
##### IO operation functions #####
===============================================================================
[..] This section provides functions allowing to:
(+) Refresh the IWDG.
@endverbatim
* @{
*/
/**
* @brief Refresh the IWDG.
* @param hiwdg pointer to a IWDG_HandleTypeDef structure that contains
* the configuration information for the specified IWDG module.
* @retval HAL status
*/
HAL_StatusTypeDef HAL_IWDG_Refresh(IWDG_HandleTypeDef *hiwdg)
{
/* Reload IWDG counter with value defined in the reload register */
__HAL_IWDG_RELOAD_COUNTER(hiwdg);
/* Return function status */
return HAL_OK;
}
/**
* @}
*/
/**
* @}
*/
#endif /* HAL_IWDG_MODULE_ENABLED */
/**
* @}
*/
/**
* @}
*/

201
LICENSE Normal file
View File

@@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

212
MY_FLASH.ld Normal file
View File

@@ -0,0 +1,212 @@
/*
******************************************************************************
**
** File : LinkerScript.ld
**
** Author : STM32CubeMX
**
** Abstract : Linker script for STM32H723VGTx series
** 1024Kbytes FLASH and 368Kbytes RAM
**
** Set heap size, stack size and stack location according
** to application requirements.
**
** Set memory bank area and size if external memory is used.
**
** Target : STMicroelectronics STM32
**
** Distribution: The file is distributed “as is,” without any warranty
** of any kind.
**
*****************************************************************************
** @attention
**
** <h2><center>&copy; COPYRIGHT(c) 2019 STMicroelectronics</center></h2>
**
** Redistribution and use in source and binary forms, with or without modification,
** are permitted provided that the following conditions are met:
** 1. Redistributions of source code must retain the above copyright notice,
** this list of conditions and the following disclaimer.
** 2. Redistributions in binary form must reproduce the above copyright notice,
** this list of conditions and the following disclaimer in the documentation
** and/or other materials provided with the distribution.
** 3. Neither the name of STMicroelectronics nor the names of its contributors
** may be used to endorse or promote products derived from this software
** without specific prior written permission.
**
** 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 THE COPYRIGHT HOLDER OR CONTRIBUTORS 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.
**
*****************************************************************************
*/
/* Entry Point */
ENTRY(Reset_Handler)
/* Highest address of the user mode stack */
_estack = ORIGIN(DTCMRAM) + LENGTH(DTCMRAM); /* end of RAM */
/* Generate a link error if heap and stack don't fit into RAM */
_Min_Heap_Size = 0x5000; /* required amount of heap */
_Min_Stack_Size = 0x5000; /* required amount of stack */
/* Specify the memory areas */
MEMORY
{
ITCMRAM (xrw) : ORIGIN = 0x00000008, LENGTH = 64K
DTCMRAM (xrw) : ORIGIN = 0x20000400, LENGTH = 128K
RAM (xrw) : ORIGIN = 0x24000000, LENGTH = 128K
RAM_D2 (xrw) : ORIGIN = 0x30000000, LENGTH = 32K
RAM_D3 (xrw) : ORIGIN = 0x38000000, LENGTH = 16K
FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 1024K
}
/* Define output sections */
SECTIONS
{
/* The startup code goes first into FLASH */
.isr_vector :
{
. = ALIGN(4);
KEEP(*(.isr_vector)) /* Startup code */
. = ALIGN(4);
} >FLASH
.ITCM :
{
. = ALIGN(4);
__itcm_start = .;
*(.ITCM)
. = ALIGN(4);
__itcm_end = .;
} > ITCMRAM AT>FLASH
__itcm_rom_start = LOADADDR(.ITCM);
__itcm_size = SIZEOF(.ITCM);
/* The program code and other data goes into FLASH */
.text :
{
_stext = .; /* create a global symbol at text start */
. = ALIGN(4);
*(.text) /* .text sections (code) */
*(.text*) /* .text* sections (code) */
*(.glue_7) /* glue arm to thumb code */
*(.glue_7t) /* glue thumb to arm code */
*(.eh_frame)
KEEP (*(.init))
KEEP (*(.fini))
. = ALIGN(4);
_etext = .; /* define a global symbols at end of code */
} >FLASH
/* Constant data goes into FLASH */
.rodata :
{
. = ALIGN(4);
*(.rodata) /* .rodata sections (constants, strings, etc.) */
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
. = ALIGN(4);
} >FLASH
.ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH
.ARM : {
__exidx_start = .;
*(.ARM.exidx*)
__exidx_end = .;
} >FLASH
.preinit_array :
{
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP (*(.preinit_array*))
PROVIDE_HIDDEN (__preinit_array_end = .);
} >FLASH
.init_array :
{
PROVIDE_HIDDEN (__init_array_start = .);
KEEP (*(SORT(.init_array.*)))
KEEP (*(.init_array*))
PROVIDE_HIDDEN (__init_array_end = .);
} >FLASH
.fini_array :
{
PROVIDE_HIDDEN (__fini_array_start = .);
KEEP (*(SORT(.fini_array.*)))
KEEP (*(.fini_array*))
PROVIDE_HIDDEN (__fini_array_end = .);
} >FLASH
/* used by the startup to initialize data */
_sidata = LOADADDR(.data);
/* Initialized data sections goes into RAM, load LMA copy after code */
.data :
{
. = ALIGN(4);
_sdata = .; /* create a global symbol at data start */
*(.data) /* .data sections */
*(.data*) /* .data* sections */
. = ALIGN(4);
_edata = .; /* define a global symbol at data end */
} >DTCMRAM AT> FLASH
/* Uninitialized data section */
. = ALIGN(4);
.bss :
{
/* This is used by the startup in order to initialize the .bss secion */
_sbss = .; /* define a global symbol at bss start */
__bss_start__ = _sbss;
*(.bss)
*(.bss*)
*(COMMON)
. = ALIGN(4);
_ebss = .; /* define a global symbol at bss end */
__bss_end__ = _ebss;
} >DTCMRAM
/* User_heap_stack section, used to check that there is enough RAM left */
._user_heap_stack :
{
. = ALIGN(8);
_sstack = .;
PROVIDE ( end = . );
PROVIDE ( _end = . );
. = . + _Min_Heap_Size;
. = . + _Min_Stack_Size;
. = ALIGN(8);
_estack = .;
} >DTCMRAM
/*在RAM_D1中开辟DMA缓存区域*/
._DMA_RAM :
{
. = ALIGN(4);
*(_DMA_RAM)
. = ALIGN(4);
} >RAM
/* Remove information from the standard libraries */
/DISCARD/ :
{
libc.a ( * )
libm.a ( * )
libgcc.a ( * )
}
.ARM.attributes 0 : { *(.ARM.attributes) }
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "{}"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright {yyyy} {name of copyright owner}
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View File

@@ -0,0 +1,144 @@
# SBUS 遥控接收修复说明
这份记录用来说明这次从“遥控器收不到数据 / `rc_ctrl` 不变化”一路排查到当前稳定版本的主要修改点。写得偏简略重点放在为什么改、DMA 怎么配、哪些文件动过,以及最后对当前 `git diff` 的复核结论。
## 1. 一开始的问题和定位思路
最开始的现象是:遥控器链路没有让 `rc_ctrl` 更新,后面又观察到 `rc_debug.rx_event_count` 也不增长,说明问题不只是协议解析,而是 UART/DMA 接收事件本身没有稳定进入。
排查时按链路分层看:
1. **初始化链路**:发现遥控器模块没有在 `RobotInit()` 里真正初始化,所以补了 `RemoteControlInit(&huart5)`
2. **UART 协议配置**:用户确认 SBUS 硬件已经做了反向,所以保持 UART5 为 `100000 / 8E2`,也就是 HAL 里的 `UART_WORDLENGTH_9B + UART_PARITY_EVEN + UART_STOPBITS_2`。当前没有启用软件 `RXINV`
3. **GPIO 电平配置**UART5 RX 是 PD2当前保持 `GPIO_NOPULL`,没有继续保留“内部上拉”的实验配置。
4. **DMA 内存可访问性**H7 上 DMA1/DMA2 不能访问 DTCM。原来接收对象如果落到 DTCM就可能导致 DMA 没法真正写入数据。现在把 USART 实例池和接收 buffer 放进 `.dma_buffer` 段,并链接到 RAM_D1。
5. **DMA 接收方式**:原来的 UART5 RX DMA 是 `DMA_CIRCULAR`,但这里使用的是 `HAL_UARTEx_ReceiveToIdle_DMA()`,为了按实际一帧 25 字节触发并重启,改成 `DMA_NORMAL + ReceiveToIdle`
6. **异常恢复**:如果 UART/DMA 出错或重启失败,不能只在中断里死等。现在加了 `USARTServiceTask()`,在 daemon 任务上下文里做 stream 级恢复。
7. **SBUS 解析**:只接受完整 25 字节帧,检查帧头 `0x0F`,尾字节允许 `0x00/0x04/0x14/0x24/0x34`,并处理 failsafe/offline。
后面临时试过的 `RXINV`、PD2 上拉、50 字节接收、滑动同步、`rc_debug` 等实验代码已经撤掉,当前版本回到“硬件反相 + 正常 SBUS 帧解析”的方案。
## 2. DMA 当前怎么配置
UART5 RX 的 DMA 配置在 `Core/Src/usart.c``TronOneH7_Scaffold.ioc` 中保持一致:
- UART`UART5`
- RX 引脚:`PD2`
- DMA stream`DMA1_Stream5`
- Request`DMA_REQUEST_UART5_RX`
- 方向:`DMA_PERIPH_TO_MEMORY`
- 外设地址不自增:`DMA_PINC_DISABLE`
- 内存地址自增:`DMA_MINC_ENABLE`
- 外设/内存数据宽度:`BYTE`
- 模式:`DMA_NORMAL`
- 优先级:`DMA_PRIORITY_VERY_HIGH`
- FIFO关闭
接收 buffer 的关键点:
- `USART_Instance usart_instance_pool[DEVICE_USART_CNT]` 放在 `User_Code/bsp/usart/bsp_usart.c`
- 这个池加了 `__attribute__((section(".dma_buffer"), aligned(32)))`
- `STM32H723XG_FLASH.ld` 新增 `.dma_buffer (NOLOAD)` 段,并放到 `RAM_D1`,避免 DMA 访问 DTCM 失败。
- `USART_Instance.recv_buff` 也做了 32 字节对齐。
启动和重启方式:
- `USARTServiceInit()` 调用 `HAL_UARTEx_ReceiveToIdle_DMA()` 启动接收。
- 启动成功后关闭 DMA 半传输中断 `DMA_IT_HT`,避免半包回调干扰。
- `HAL_UARTEx_RxEventCallback()` 中记录 `rx_event_count``last_rx_size`,把实际收到的 `Size` 传给遥控器解析回调,然后重新启动接收。
- `HAL_UART_ErrorCallback()` 中记录 `uart_error_count``last_uart_error`,并尝试重启接收。
- 如果中断里重启失败,会置位/累计错误,后续由 `USARTServiceTask()` 在任务上下文里恢复 UART/DMA。
## 3. 主要加了什么,在哪里
- `User_Code/application/robot.c`
- 定义全局 `volatile RobotMode_t RobotMode`
-`RobotInit()` 中调用 `RemoteControlInit(&huart5)`
- `Core/Src/usart.c`
- UART5 保持 `100000 / 8E2`
- UART5 `AdvancedInit` 保持 `UART_ADVFEATURE_NO_INIT`,没有软件 RXINV。
- PD2 保持 `GPIO_NOPULL`
- UART5 RX DMA 从 `DMA_CIRCULAR` 改为 `DMA_NORMAL`
- `TronOneH7_Scaffold.ioc`
- 同步把 `Dma.UART5_RX.13.Mode` 改为 `DMA_NORMAL`
- `STM32H723XG_FLASH.ld`
- 新增 `.dma_buffer` 段,放入 `RAM_D1`
- `User_Code/bsp/usart/bsp_usart.c/.h`
- USART 实例不再 `malloc`,改用静态实例池,并放入 `.dma_buffer`
- 模块回调改为携带 `(USART_Instance *instance, const uint8_t *recv_data, uint16_t recv_size)`
- 加入 `rx_event_count``last_rx_size``uart_error_count``last_uart_error``rx_restart_error_count` 等接收状态字段。
- 加入 `USARTServiceTask()` 做 UART/DMA 恢复。
- `USARTServiceInit()` 改为返回 `HAL_StatusTypeDef`
- `User_Code/module/periph/remote_control/rc.c/.h`
- `RemoteControlInit()` 注册 UART5并显式启动 USART 接收服务。
- SBUS 解析只接受完整 25 字节帧。
- 加入帧头、尾字节、failsafe 校验。
- 加入 `RemoteControlReadSnapshot()`,用于原子读取当前遥控器快照。
- 修复 `RemoteControlIsOnline()` 和失控清零的竞态。
- 修复 SWB/SWC 通道、开关边沿标志。
- `Core/Src/freertos.c`
- daemon task 中调用 `USARTServiceTask()`,让 UART/DMA 异常恢复发生在任务上下文。
- `User_Code/module/software/daemon/daemon.c/.h`
- 修正 `temp_count/init_count` 初始化逻辑。
- `DaemonReload()``DaemonIsOnline()``Daemon_Update()` 加了简单临界区保护。
- `temp_count` 改为 `volatile`
- `User_Code/application/indicator_app/ws2812status.c`
- 不再用局部 `RobotMode` 遮蔽全局状态。
- LED 显示时结合 `RemoteControlIsOnline()` 判断遥控器离线。
- `User_Code/module/paramdef/robot_def.h`
- `RobotMode` 声明改为 `extern volatile RobotMode_t RobotMode`
## 4. 当前建议上板观察项
上板后重点看这些量:
- `rx_event_count` 是否持续增长。
- `last_rx_size` 是否稳定为 `25`
- `rc_valid_frame_count` 是否持续增长。
- `uart_error_count``rx_restart_error_count` 是否不持续增长。
- 原始帧是否类似 `0F ... 00/04/14/24/34`
注意:当前稳定版本已经没有 `rc_debug` 这个临时调试结构。`rx_event_count``last_rx_size``USART_Instance` 里,`rc_valid_frame_count` 等在 `rc.c` 内部是 `static volatile`。如果后续想长期在调试器里直接 watch 一个固定结构,可以再专门加一个轻量 getter 或 debug struct当前为了回到干净版本没有保留那套临时代码。
## 5. Git 变更复核和可疑点
已读取当前 `git status --short``git diff --stat``git diff --check` 和关键文件 diff。当前工作区共有 16 个已修改文件,其中 SBUS 接收链路相关的是:
- `Core/Src/freertos.c`
- `Core/Src/usart.c`
- `STM32H723XG_FLASH.ld`
- `TronOneH7_Scaffold.ioc`
- `User_Code/application/indicator_app/ws2812status.c`
- `User_Code/application/robot.c`
- `User_Code/bsp/usart/bsp_usart.c`
- `User_Code/bsp/usart/bsp_usart.h`
- `User_Code/module/paramdef/robot_def.h`
- `User_Code/module/periph/remote_control/rc.c`
- `User_Code/module/periph/remote_control/rc.h`
- `User_Code/module/software/daemon/daemon.c`
- `User_Code/module/software/daemon/daemon.h`
复核结论:
- `git diff --check` 没有发现空白错误,只提示这些文件下次被 Git 处理时 LF 可能转 CRLF。
- 没有发现 `rc_debug``rc_ctrl_debug``RemoteControlDebugPoll``RXINV``RxPinLevelInvert`、50 字节 buffer、滑动同步等实验代码残留。
- UART5 当前确实是 `100000 / 8E2`,没有软件 RXINVPD2 也是 `GPIO_NOPULL`
- UART5 RX DMA 在 `.ioc` 和生成代码里都已经是 `DMA_NORMAL`,没有一边改一边没同步的问题。
- `RobotMode` 目前只有一个定义,在 `robot.c`;其它地方通过 `extern volatile` 使用,没看到重复定义。
需要特别注意的可疑/无关变更:
- `User_Code/module/periph/buzzer/buzzer.cpp` 只改了两行注释空格,和 SBUS 修复无关,建议不要混进本次提交。
- `ozonedeb/windebnewestux.jdebug``ozonedeb/windebnewestux.jdebug.user` 是 Ozone/J-Link 调试器本地状态变化,包括探针序列号、打开窗口、布局、打开文件等,和代码逻辑无关,建议不要混进本次提交。
- `rc_valid_frame_count` 等计数是 `static volatile`,调试符号里一般能看到,但 C 代码外部不能直接引用;这不是接收链路问题,只是“是否方便 watch”的问题。
总体看SBUS 主链路相关 diff 没看到明显可疑残留;最需要清理的是 `buzzer.cpp``ozonedeb/*.jdebug*` 这些无关 dirty 文件。

View File

@@ -1,7 +1,6 @@
/* /*
****************************************************************************** ******************************************************************************
** **
** File : LinkerScript.ld ** File : LinkerScript.ld
** **
** Author : STM32CubeMX ** Author : STM32CubeMX
@@ -16,7 +15,7 @@
** **
** Target : STMicroelectronics STM32 ** Target : STMicroelectronics STM32
** **
** Distribution: The file is distributed as is, without any warranty ** Distribution: The file is distributed "as is," without any warranty
** of any kind. ** of any kind.
** **
***************************************************************************** *****************************************************************************
@@ -24,105 +23,95 @@
** **
** <h2><center>&copy; COPYRIGHT(c) 2025 STMicroelectronics</center></h2> ** <h2><center>&copy; COPYRIGHT(c) 2025 STMicroelectronics</center></h2>
** **
** Redistribution and use in source and binary forms, with or without modification, ** 版权声明和许可条款
** are permitted provided that the following conditions are met:
** 1. Redistributions of source code must retain the above copyright notice,
** this list of conditions and the following disclaimer.
** 2. Redistributions in binary form must reproduce the above copyright notice,
** this list of conditions and the following disclaimer in the documentation
** and/or other materials provided with the distribution.
** 3. Neither the name of STMicroelectronics nor the names of its contributors
** may be used to endorse or promote products derived from this software
** without specific prior written permission.
**
** 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 THE COPYRIGHT HOLDER OR CONTRIBUTORS 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.
** **
***************************************************************************** *****************************************************************************
*/ */
/* Entry Point */ /* 程序入口点 - 指定复位处理程序为程序的起始执行点 */
ENTRY(Reset_Handler) ENTRY(Reset_Handler)
/* Specify the memory areas */ /* 定义内存区域 */
MEMORY MEMORY
{ {
/* 数据紧耦合内存 (Data TCM) - 128KB零等待周期用于高性能数据访问 */
DTCMRAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K DTCMRAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K
RAM_D1 (xrw) : ORIGIN = 0x24000000, LENGTH = 320K /* D1域RAM (AXI SRAM) - 320KB主系统内存 */
RAM_D1 (xrw) : ORIGIN = 0x24000000, LENGTH = 128K
/* D2域RAM (AHB SRAM) - 32KB用于外设数据缓冲 */
RAM_D2 (xrw) : ORIGIN = 0x30000000, LENGTH = 32K RAM_D2 (xrw) : ORIGIN = 0x30000000, LENGTH = 32K
/* D3域RAM (备份域RAM) - 16KB在低功耗模式下保持数据 */
RAM_D3 (xrw) : ORIGIN = 0x38000000, LENGTH = 16K RAM_D3 (xrw) : ORIGIN = 0x38000000, LENGTH = 16K
/* 指令紧耦合内存 (Instruction TCM) - 64KB零等待周期用于高性能代码执行 */
ITCMRAM (xrw) : ORIGIN = 0x00000000, LENGTH = 64K ITCMRAM (xrw) : ORIGIN = 0x00000000, LENGTH = 64K
/* 主闪存 - 1024KB存储程序代码和常量数据 */
FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 1024K FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 1024K
} }
/* Highest address of the user mode stack */ /* 定义用户模式栈的最高地址(栈向低地址增长) */
_estack = ORIGIN(DTCMRAM) + LENGTH(DTCMRAM); /* end of RAM */ _estack = ORIGIN(DTCMRAM) + LENGTH(DTCMRAM); /* RAM的末尾作为栈起始位置 */
/* Generate a link error if heap and stack don't fit into RAM */
/* 如果堆和栈不能放入RAM则生成链接错误 */
_Min_Heap_Size = 0x4000; /* required amount of heap */ _Min_Heap_Size = 0x4000; /* required amount of heap */
_Min_Stack_Size = 0x4000; /* required amount of stack */ _Min_Stack_Size = 0x4000; /* required amount of stack */
/* Define output sections */ /* 定义输出段 */
SECTIONS SECTIONS
{ {
/* The startup code goes first into FLASH */ /* 启动代码首先放入FLASH */
.isr_vector : .isr_vector :
{ {
. = ALIGN(4); . = ALIGN(4); /* 4字节对齐 */
KEEP(*(.isr_vector)) /* Startup code */ KEEP(*(.isr_vector)) /* 保留中断向量表(启动代码) */
. = ALIGN(4); . = ALIGN(4);
} >FLASH } >FLASH
/* The program code and other data goes into FLASH */ /* 程序代码和其他数据放入FLASH */
.text : .text :
{ {
. = ALIGN(4); . = ALIGN(4);
*(.text) /* .text sections (code) */ *(.text) /* 所有.text段(代码) */
*(.text*) /* .text* sections (code) */ *(.text*) /* 所有.text*段(代码) */
*(.glue_7) /* glue arm to thumb code */ *(.glue_7) /* ARM和Thumb代码粘合段 */
*(.glue_7t) /* glue thumb to arm code */ *(.glue_7t) /* Thumb和ARM代码粘合段 */
*(.eh_frame) *(.eh_frame) /* 异常处理帧信息 */
KEEP (*(.init)) KEEP (*(.init)) /* 保留初始化代码 */
KEEP (*(.fini)) KEEP (*(.fini)) /* 保留终止化代码 */
. = ALIGN(4); . = ALIGN(4);
_etext = .; /* define a global symbols at end of code */ _etext = .; /* 定义代码结束的全局符号 */
} >FLASH } >FLASH
/* Constant data goes into FLASH */ /* 常量数据放入FLASH */
.rodata : .rodata :
{ {
. = ALIGN(4); . = ALIGN(4);
*(.rodata) /* .rodata sections (constants, strings, etc.) */ *(.rodata) /* .rodata段(常量、字符串等) */
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */ *(.rodata*) /* .rodata*段(常量、字符串等) */
. = ALIGN(4); . = ALIGN(4);
} >FLASH } >FLASH
.ARM.extab (READONLY) : /* The "READONLY" keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */ /* ARM异常处理表段 */
.ARM.extab (READONLY) : /* "READONLY"关键字仅在GCC11及以后版本支持如果使用GCC10或更早版本请移除 */
{ {
. = ALIGN(4); . = ALIGN(4);
*(.ARM.extab* .gnu.linkonce.armextab.*) *(.ARM.extab* .gnu.linkonce.armextab.*)
. = ALIGN(4); . = ALIGN(4);
} >FLASH } >FLASH
.ARM (READONLY) : /* The "READONLY" keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */ /* ARM异常索引表段 */
.ARM (READONLY) : /* "READONLY"关键字仅在GCC11及以后版本支持如果使用GCC10或更早版本请移除 */
{ {
. = ALIGN(4); . = ALIGN(4);
__exidx_start = .; __exidx_start = .; /* 异常索引表开始 */
*(.ARM.exidx*) *(.ARM.exidx*)
__exidx_end = .; __exidx_end = .; /* 异常索引表结束 */
. = ALIGN(4); . = ALIGN(4);
} >FLASH } >FLASH
.preinit_array (READONLY) : /* The "READONLY" keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */ /* 预初始化数组段 */
.preinit_array (READONLY) : /* "READONLY"关键字仅在GCC11及以后版本支持如果使用GCC10或更早版本请移除 */
{ {
. = ALIGN(4); . = ALIGN(4);
PROVIDE_HIDDEN (__preinit_array_start = .); PROVIDE_HIDDEN (__preinit_array_start = .);
@@ -131,56 +120,59 @@ SECTIONS
. = ALIGN(4); . = ALIGN(4);
} >FLASH } >FLASH
.init_array (READONLY) : /* The "READONLY" keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */ /* 初始化数组段 */
.init_array (READONLY) : /* "READONLY"关键字仅在GCC11及以后版本支持如果使用GCC10或更早版本请移除 */
{ {
. = ALIGN(4); . = ALIGN(4);
PROVIDE_HIDDEN (__init_array_start = .); PROVIDE_HIDDEN (__init_array_start = .);
KEEP (*(SORT(.init_array.*))) KEEP (*(SORT(.init_array.*))) /* 排序的初始化数组 */
KEEP (*(.init_array*)) KEEP (*(.init_array*))
PROVIDE_HIDDEN (__init_array_end = .); PROVIDE_HIDDEN (__init_array_end = .);
. = ALIGN(4); . = ALIGN(4);
} >FLASH } >FLASH
.fini_array (READONLY) : /* The "READONLY" keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */ /* 终止化数组段 */
.fini_array (READONLY) : /* "READONLY"关键字仅在GCC11及以后版本支持如果使用GCC10或更早版本请移除 */
{ {
. = ALIGN(4); . = ALIGN(4);
PROVIDE_HIDDEN (__fini_array_start = .); PROVIDE_HIDDEN (__fini_array_start = .);
KEEP (*(SORT(.fini_array.*))) KEEP (*(SORT(.fini_array.*))) /* 排序的终止化数组 */
KEEP (*(.fini_array*)) KEEP (*(.fini_array*))
PROVIDE_HIDDEN (__fini_array_end = .); PROVIDE_HIDDEN (__fini_array_end = .);
. = ALIGN(4); . = ALIGN(4);
} >FLASH } >FLASH
/* used by the startup to initialize data */ /* 用于启动时初始化数据的加载地址 */
_sidata = LOADADDR(.data); _sidata = LOADADDR(.data);
/* Initialized data sections goes into RAM, load LMA copy after code */ /* 已初始化数据段放入RAM但在FLASH中保留加载镜像 */
.data : .data :
{ {
. = ALIGN(4); . = ALIGN(4);
_sdata = .; /* create a global symbol at data start */ _sdata = .; /* 在数据开始处创建全局符号 */
*(.data) /* .data sections */ *(.data) /* .data */
*(.data*) /* .data* sections */ *(.data*) /* .data* */
*(.RamFunc) /* .RamFunc sections */ *(.RamFunc) /* 在RAM中执行的函数段 */
*(.RamFunc*) /* .RamFunc* sections */ *(.RamFunc*) /* 在RAM中执行的函数段 */
. = ALIGN(4); . = ALIGN(4);
} >DTCMRAM AT> FLASH _edata = .; /* 在数据结束处定义全局符号 */
} >DTCMRAM AT> FLASH /* VMA在DTCMRAMLMA在FLASH */
/* Initialized TLS data section */ /* 已初始化TLS线程局部存储数据段 */
.tdata : ALIGN(4) .tdata : ALIGN(4)
{ {
*(.tdata .tdata.* .gnu.linkonce.td.*) *(.tdata .tdata.* .gnu.linkonce.td.*)
. = ALIGN(4); . = ALIGN(4);
_edata = .; /* define a global symbol at data end */
PROVIDE(__data_end = .);
PROVIDE(__tdata_end = .); PROVIDE(__tdata_end = .);
} >DTCMRAM AT> FLASH } >DTCMRAM AT> FLASH
/* 提供TLS相关符号供启动代码和运行时使用 */
PROVIDE( __tdata_start = ADDR(.tdata) ); PROVIDE( __tdata_start = ADDR(.tdata) );
PROVIDE( __tdata_size = __tdata_end - __tdata_start ); PROVIDE( __tdata_size = __tdata_end - __tdata_start );
PROVIDE( __data_start = ADDR(.data) ); PROVIDE( __data_start = ADDR(.data) );
PROVIDE( __data_end = _edata );
PROVIDE( __data_size = __data_end - __data_start ); PROVIDE( __data_size = __data_end - __data_start );
PROVIDE( __tdata_source = LOADADDR(.tdata) ); PROVIDE( __tdata_source = LOADADDR(.tdata) );
@@ -188,23 +180,26 @@ SECTIONS
PROVIDE( __tdata_source_size = __tdata_source_end - __tdata_source ); PROVIDE( __tdata_source_size = __tdata_source_end - __tdata_source );
PROVIDE( __data_source = LOADADDR(.data) ); PROVIDE( __data_source = LOADADDR(.data) );
PROVIDE( __data_source_end = __tdata_source_end ); PROVIDE( __data_source_end = LOADADDR(.data) + SIZEOF(.data) );
PROVIDE( __data_source_size = __data_source_end - __data_source ); PROVIDE( __data_source_size = __data_source_end - __data_source );
/* Uninitialized data section */
/* 未初始化的TLS BSS段 */
.tbss (NOLOAD) : ALIGN(4) .tbss (NOLOAD) : ALIGN(4)
{ {
/* This is used by the startup in order to initialize the .bss secion */ /* 启动代码使用此符号来初始化.bss段 */
_sbss = .; /* define a global symbol at bss start */ _sbss = .; /* 在bss开始处定义全局符号 */
__bss_start__ = _sbss; __bss_start__ = _sbss;
*(.tbss .tbss.*) *(.tbss .tbss.*)
. = ALIGN(4); . = ALIGN(4);
PROVIDE( __tbss_end = . ); PROVIDE( __tbss_end = . );
} >DTCMRAM } >DTCMRAM
/* 提供TLS BSS相关符号 */
PROVIDE( __tbss_start = ADDR(.tbss) ); PROVIDE( __tbss_start = ADDR(.tbss) );
PROVIDE( __tbss_size = __tbss_end - __tbss_start ); PROVIDE( __tbss_size = __tbss_end - __tbss_start );
PROVIDE( __tbss_offset = ADDR(.tbss) - ADDR(.tdata) ); PROVIDE( __tbss_offset = ADDR(.tbss) - ADDR(.tdata) );
/* 提供TLS基础信息 */
PROVIDE( __tls_base = __tdata_start ); PROVIDE( __tls_base = __tdata_start );
PROVIDE( __tls_end = __tbss_end ); PROVIDE( __tls_end = __tbss_end );
PROVIDE( __tls_size = __tls_end - __tls_base ); PROVIDE( __tls_size = __tls_end - __tls_base );
@@ -213,41 +208,52 @@ SECTIONS
PROVIDE( __arm32_tls_tcb_offset = MAX(8, __tls_align) ); PROVIDE( __arm32_tls_tcb_offset = MAX(8, __tls_align) );
PROVIDE( __arm64_tls_tcb_offset = MAX(16, __tls_align) ); PROVIDE( __arm64_tls_tcb_offset = MAX(16, __tls_align) );
/* 常规BSS段未初始化数据 */
.bss (NOLOAD) : ALIGN(4) .bss (NOLOAD) : ALIGN(4)
{ {
*(.bss) *(.bss)
*(.bss*) *(.bss*)
*(COMMON) *(COMMON) /* 未初始化的全局变量 */
. = ALIGN(4); . = ALIGN(4);
_ebss = .; /* define a global symbol at bss end */ _ebss = .; /* 在bss结束处定义全局符号 */
__bss_end__ = _ebss; __bss_end__ = _ebss;
PROVIDE( __bss_end = .); PROVIDE( __bss_end = .);
} >DTCMRAM } >DTCMRAM
PROVIDE( __non_tls_bss_start = ADDR(.bss) ); PROVIDE( __non_tls_bss_start = ADDR(.bss) );
PROVIDE( __bss_start = __tbss_start ); /* 提供完整的BSS信息包含TLS和非TLS */
PROVIDE( __bss_start = _sbss );
PROVIDE( __bss_size = __bss_end - __bss_start ); PROVIDE( __bss_size = __bss_end - __bss_start );
/* User_heap_stack section, used to check that there is enough RAM left */ /* DMA1/DMA2 cannot access DTCM. The MPU config makes RAM_D1 non-cacheable. */
.dma_buffer (NOLOAD) :
{
. = ALIGN(32);
__dma_buffer_start__ = .;
KEEP(*(.dma_buffer))
KEEP(*(.dma_buffer.*))
. = ALIGN(32);
__dma_buffer_end__ = .;
} >RAM_D1
/* 用户堆栈段用于检查剩余RAM是否足够 */
._user_heap_stack (NOLOAD) : ._user_heap_stack (NOLOAD) :
{ {
. = ALIGN(8); . = ALIGN(8);
PROVIDE ( end = . ); PROVIDE ( end = . ); /* 堆起始位置 */
PROVIDE ( _end = . ); PROVIDE ( _end = . );
. = . + _Min_Heap_Size; . = . + _Min_Heap_Size; /* 分配堆空间 */
. = . + _Min_Stack_Size; . = . + _Min_Stack_Size; /* 分配栈空间 */
. = ALIGN(8); . = ALIGN(8);
} >DTCMRAM } >DTCMRAM
/* 从标准库中移除调试信息 */
/* Remove information from the standard libraries */
/DISCARD/ : /DISCARD/ :
{ {
libc.a:* ( * ) libc.a:* ( * ) /* 丢弃C库的调试信息 */
libm.a:* ( * ) libm.a:* ( * ) /* 丢弃数学库的调试信息 */
libgcc.a:* ( * ) libgcc.a:* ( * ) /* 丢弃GCC库的调试信息 */
} }
} }

View File

@@ -1,6 +1,24 @@
#MicroXplorer Configuration settings - do not modify #MicroXplorer Configuration settings - do not modify
ADC1.Channel-0\#ChannelRegularConversion=ADC_CHANNEL_4
ADC1.Channel-1\#ChannelRegularConversion=ADC_CHANNEL_4
ADC1.ClockPrescaler=ADC_CLOCK_ASYNC_DIV64
ADC1.ContinuousConvMode=ENABLE
ADC1.ConversionDataManagement=ADC_CONVERSIONDATA_DMA_CIRCULAR
ADC1.IPParameters=Rank-0\#ChannelRegularConversion,master,Channel-0\#ChannelRegularConversion,SamplingTime-0\#ChannelRegularConversion,OffsetNumber-0\#ChannelRegularConversion,OffsetSignedSaturation-0\#ChannelRegularConversion,NbrOfConversionFlag,ClockPrescaler,ConversionDataManagement,ContinuousConvMode,Rank-1\#ChannelRegularConversion,Channel-1\#ChannelRegularConversion,SamplingTime-1\#ChannelRegularConversion,OffsetNumber-1\#ChannelRegularConversion,OffsetSignedSaturation-1\#ChannelRegularConversion,NbrOfConversion
ADC1.NbrOfConversion=2
ADC1.NbrOfConversionFlag=1
ADC1.OffsetNumber-0\#ChannelRegularConversion=ADC_OFFSET_NONE
ADC1.OffsetNumber-1\#ChannelRegularConversion=ADC_OFFSET_NONE
ADC1.OffsetSignedSaturation-0\#ChannelRegularConversion=DISABLE
ADC1.OffsetSignedSaturation-1\#ChannelRegularConversion=DISABLE
ADC1.Rank-0\#ChannelRegularConversion=1
ADC1.Rank-1\#ChannelRegularConversion=2
ADC1.SamplingTime-0\#ChannelRegularConversion=ADC_SAMPLETIME_1CYCLE_5
ADC1.SamplingTime-1\#ChannelRegularConversion=ADC_SAMPLETIME_1CYCLE_5
ADC1.master=1
ADC3.Channel-0\#ChannelRegularConversion=ADC_CHANNEL_TEMPSENSOR ADC3.Channel-0\#ChannelRegularConversion=ADC_CHANNEL_TEMPSENSOR
ADC3.IPParameters=Rank-0\#ChannelRegularConversion,Channel-0\#ChannelRegularConversion,SamplingTime-0\#ChannelRegularConversion,OffsetNumber-0\#ChannelRegularConversion,OffsetSign-0\#ChannelRegularConversion,NbrOfConversionFlag ADC3.ClockPrescaler=ADC_CLOCK_ASYNC_DIV64
ADC3.IPParameters=Rank-0\#ChannelRegularConversion,Channel-0\#ChannelRegularConversion,SamplingTime-0\#ChannelRegularConversion,OffsetNumber-0\#ChannelRegularConversion,OffsetSign-0\#ChannelRegularConversion,NbrOfConversionFlag,ClockPrescaler
ADC3.NbrOfConversionFlag=1 ADC3.NbrOfConversionFlag=1
ADC3.OffsetNumber-0\#ChannelRegularConversion=ADC_OFFSET_NONE ADC3.OffsetNumber-0\#ChannelRegularConversion=ADC_OFFSET_NONE
ADC3.OffsetSign-0\#ChannelRegularConversion=ADC3_OFFSET_SIGN_NEGATIVE ADC3.OffsetSign-0\#ChannelRegularConversion=ADC3_OFFSET_SIGN_NEGATIVE
@@ -26,12 +44,31 @@ CRC.DefaultInitValueUse=DEFAULT_INIT_VALUE_DISABLE
CRC.DefaultPolynomialUse=DEFAULT_POLYNOMIAL_DISABLE CRC.DefaultPolynomialUse=DEFAULT_POLYNOMIAL_DISABLE
CRC.IPParameters=InputDataInversionMode,DefaultInitValueUse,DefaultPolynomialUse,CRCLength CRC.IPParameters=InputDataInversionMode,DefaultInitValueUse,DefaultPolynomialUse,CRCLength
CRC.InputDataInversionMode=CRC_INPUTDATA_INVERSION_BYTE CRC.InputDataInversionMode=CRC_INPUTDATA_INVERSION_BYTE
Dma.ADC1.14.Direction=DMA_PERIPH_TO_MEMORY
Dma.ADC1.14.EventEnable=DISABLE
Dma.ADC1.14.FIFOMode=DMA_FIFOMODE_DISABLE
Dma.ADC1.14.Instance=DMA1_Stream2
Dma.ADC1.14.MemDataAlignment=DMA_MDATAALIGN_HALFWORD
Dma.ADC1.14.MemInc=DMA_MINC_ENABLE
Dma.ADC1.14.Mode=DMA_CIRCULAR
Dma.ADC1.14.PeriphDataAlignment=DMA_PDATAALIGN_HALFWORD
Dma.ADC1.14.PeriphInc=DMA_PINC_DISABLE
Dma.ADC1.14.Polarity=HAL_DMAMUX_REQ_GEN_RISING
Dma.ADC1.14.Priority=DMA_PRIORITY_LOW
Dma.ADC1.14.RequestNumber=1
Dma.ADC1.14.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber
Dma.ADC1.14.SignalID=NONE
Dma.ADC1.14.SyncEnable=DISABLE
Dma.ADC1.14.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT
Dma.ADC1.14.SyncRequestNumber=1
Dma.ADC1.14.SyncSignalID=NONE
Dma.Request0=USART10_RX Dma.Request0=USART10_RX
Dma.Request1=USART10_TX Dma.Request1=USART10_TX
Dma.Request10=USART3_TX Dma.Request10=USART3_TX
Dma.Request11=SPI1_RX Dma.Request11=SPI1_RX
Dma.Request12=SPI1_TX Dma.Request12=SPI1_TX
Dma.Request13=UART5_RX Dma.Request13=UART5_RX
Dma.Request14=ADC1
Dma.Request2=SPI2_RX Dma.Request2=SPI2_RX
Dma.Request3=SPI2_TX Dma.Request3=SPI2_TX
Dma.Request4=UART7_RX Dma.Request4=UART7_RX
@@ -40,7 +77,7 @@ Dma.Request6=USART1_TX
Dma.Request7=USART2_RX Dma.Request7=USART2_RX
Dma.Request8=USART2_TX Dma.Request8=USART2_TX
Dma.Request9=USART3_RX Dma.Request9=USART3_RX
Dma.RequestsNb=14 Dma.RequestsNb=15
Dma.SPI1_RX.11.Direction=DMA_PERIPH_TO_MEMORY Dma.SPI1_RX.11.Direction=DMA_PERIPH_TO_MEMORY
Dma.SPI1_RX.11.EventEnable=DISABLE Dma.SPI1_RX.11.EventEnable=DISABLE
Dma.SPI1_RX.11.FIFOMode=DMA_FIFOMODE_DISABLE Dma.SPI1_RX.11.FIFOMode=DMA_FIFOMODE_DISABLE
@@ -62,7 +99,7 @@ Dma.SPI1_RX.11.SyncSignalID=NONE
Dma.SPI1_TX.12.Direction=DMA_MEMORY_TO_PERIPH Dma.SPI1_TX.12.Direction=DMA_MEMORY_TO_PERIPH
Dma.SPI1_TX.12.EventEnable=DISABLE Dma.SPI1_TX.12.EventEnable=DISABLE
Dma.SPI1_TX.12.FIFOMode=DMA_FIFOMODE_DISABLE Dma.SPI1_TX.12.FIFOMode=DMA_FIFOMODE_DISABLE
Dma.SPI1_TX.12.Instance=DMA1_Stream2 Dma.SPI1_TX.12.Instance=DMA1_Stream3
Dma.SPI1_TX.12.MemDataAlignment=DMA_MDATAALIGN_HALFWORD Dma.SPI1_TX.12.MemDataAlignment=DMA_MDATAALIGN_HALFWORD
Dma.SPI1_TX.12.MemInc=DMA_MINC_ENABLE Dma.SPI1_TX.12.MemInc=DMA_MINC_ENABLE
Dma.SPI1_TX.12.Mode=DMA_NORMAL Dma.SPI1_TX.12.Mode=DMA_NORMAL
@@ -80,7 +117,7 @@ Dma.SPI1_TX.12.SyncSignalID=NONE
Dma.SPI2_RX.2.Direction=DMA_PERIPH_TO_MEMORY Dma.SPI2_RX.2.Direction=DMA_PERIPH_TO_MEMORY
Dma.SPI2_RX.2.EventEnable=DISABLE Dma.SPI2_RX.2.EventEnable=DISABLE
Dma.SPI2_RX.2.FIFOMode=DMA_FIFOMODE_DISABLE Dma.SPI2_RX.2.FIFOMode=DMA_FIFOMODE_DISABLE
Dma.SPI2_RX.2.Instance=DMA1_Stream3 Dma.SPI2_RX.2.Instance=DMA1_Stream0
Dma.SPI2_RX.2.MemDataAlignment=DMA_MDATAALIGN_BYTE Dma.SPI2_RX.2.MemDataAlignment=DMA_MDATAALIGN_BYTE
Dma.SPI2_RX.2.MemInc=DMA_MINC_ENABLE Dma.SPI2_RX.2.MemInc=DMA_MINC_ENABLE
Dma.SPI2_RX.2.Mode=DMA_NORMAL Dma.SPI2_RX.2.Mode=DMA_NORMAL
@@ -119,11 +156,11 @@ Dma.UART5_RX.13.FIFOMode=DMA_FIFOMODE_DISABLE
Dma.UART5_RX.13.Instance=DMA1_Stream5 Dma.UART5_RX.13.Instance=DMA1_Stream5
Dma.UART5_RX.13.MemDataAlignment=DMA_MDATAALIGN_BYTE Dma.UART5_RX.13.MemDataAlignment=DMA_MDATAALIGN_BYTE
Dma.UART5_RX.13.MemInc=DMA_MINC_ENABLE Dma.UART5_RX.13.MemInc=DMA_MINC_ENABLE
Dma.UART5_RX.13.Mode=DMA_CIRCULAR Dma.UART5_RX.13.Mode=DMA_NORMAL
Dma.UART5_RX.13.PeriphDataAlignment=DMA_PDATAALIGN_BYTE Dma.UART5_RX.13.PeriphDataAlignment=DMA_PDATAALIGN_BYTE
Dma.UART5_RX.13.PeriphInc=DMA_PINC_DISABLE Dma.UART5_RX.13.PeriphInc=DMA_PINC_DISABLE
Dma.UART5_RX.13.Polarity=HAL_DMAMUX_REQ_GEN_RISING Dma.UART5_RX.13.Polarity=HAL_DMAMUX_REQ_GEN_RISING
Dma.UART5_RX.13.Priority=DMA_PRIORITY_LOW Dma.UART5_RX.13.Priority=DMA_PRIORITY_VERY_HIGH
Dma.UART5_RX.13.RequestNumber=1 Dma.UART5_RX.13.RequestNumber=1
Dma.UART5_RX.13.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber Dma.UART5_RX.13.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber
Dma.UART5_RX.13.SignalID=NONE Dma.UART5_RX.13.SignalID=NONE
@@ -293,7 +330,7 @@ Dma.USART3_TX.10.SyncEnable=DISABLE
Dma.USART3_TX.10.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT Dma.USART3_TX.10.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT
Dma.USART3_TX.10.SyncRequestNumber=1 Dma.USART3_TX.10.SyncRequestNumber=1
Dma.USART3_TX.10.SyncSignalID=NONE Dma.USART3_TX.10.SyncSignalID=NONE
FDCAN1.AutoRetransmission=ENABLE FDCAN1.AutoRetransmission=DISABLE
FDCAN1.CalculateBaudRateNominal=1000000 FDCAN1.CalculateBaudRateNominal=1000000
FDCAN1.CalculateTimeBitNominal=1000 FDCAN1.CalculateTimeBitNominal=1000
FDCAN1.CalculateTimeQuantumNominal=25.0 FDCAN1.CalculateTimeQuantumNominal=25.0
@@ -301,17 +338,18 @@ FDCAN1.DataPrescaler=3
FDCAN1.DataSyncJumpWidth=10 FDCAN1.DataSyncJumpWidth=10
FDCAN1.DataTimeSeg1=29 FDCAN1.DataTimeSeg1=29
FDCAN1.DataTimeSeg2=10 FDCAN1.DataTimeSeg2=10
FDCAN1.IPParameters=CalculateTimeQuantumNominal,CalculateTimeBitNominal,CalculateBaudRateNominal,NominalPrescaler,NominalTimeSeg1,NominalTimeSeg2,DataPrescaler,DataTimeSeg1,DataTimeSeg2,TxFifoQueueMode,RxFifo0ElmtsNbr,TxFifoQueueElmtsNbr,StdFiltersNbr,AutoRetransmission,ProtocolException,NominalSyncJumpWidth,DataSyncJumpWidth FDCAN1.IPParameters=CalculateTimeQuantumNominal,CalculateTimeBitNominal,CalculateBaudRateNominal,NominalPrescaler,NominalTimeSeg1,NominalTimeSeg2,DataPrescaler,DataTimeSeg1,DataTimeSeg2,TxFifoQueueMode,RxFifo0ElmtsNbr,TxFifoQueueElmtsNbr,StdFiltersNbr,AutoRetransmission,ProtocolException,NominalSyncJumpWidth,DataSyncJumpWidth,RxFifo1ElmtsNbr
FDCAN1.NominalPrescaler=3 FDCAN1.NominalPrescaler=3
FDCAN1.NominalSyncJumpWidth=10 FDCAN1.NominalSyncJumpWidth=10
FDCAN1.NominalTimeSeg1=29 FDCAN1.NominalTimeSeg1=29
FDCAN1.NominalTimeSeg2=10 FDCAN1.NominalTimeSeg2=10
FDCAN1.ProtocolException=ENABLE FDCAN1.ProtocolException=DISABLE
FDCAN1.RxFifo0ElmtsNbr=32 FDCAN1.RxFifo0ElmtsNbr=4
FDCAN1.StdFiltersNbr=1 FDCAN1.RxFifo1ElmtsNbr=4
FDCAN1.StdFiltersNbr=14
FDCAN1.TxFifoQueueElmtsNbr=32 FDCAN1.TxFifoQueueElmtsNbr=32
FDCAN1.TxFifoQueueMode=FDCAN_TX_FIFO_OPERATION FDCAN1.TxFifoQueueMode=FDCAN_TX_FIFO_OPERATION
FDCAN2.AutoRetransmission=ENABLE FDCAN2.AutoRetransmission=DISABLE
FDCAN2.CalculateBaudRateNominal=1000000 FDCAN2.CalculateBaudRateNominal=1000000
FDCAN2.CalculateTimeBitNominal=1000 FDCAN2.CalculateTimeBitNominal=1000
FDCAN2.CalculateTimeQuantumNominal=25.0 FDCAN2.CalculateTimeQuantumNominal=25.0
@@ -319,40 +357,44 @@ FDCAN2.DataPrescaler=3
FDCAN2.DataSyncJumpWidth=10 FDCAN2.DataSyncJumpWidth=10
FDCAN2.DataTimeSeg1=29 FDCAN2.DataTimeSeg1=29
FDCAN2.DataTimeSeg2=10 FDCAN2.DataTimeSeg2=10
FDCAN2.IPParameters=CalculateTimeQuantumNominal,CalculateTimeBitNominal,CalculateBaudRateNominal,DataPrescaler,DataTimeSeg1,DataTimeSeg2,NominalPrescaler,NominalTimeSeg1,NominalTimeSeg2,RxFifo1ElmtsNbr,TxFifoQueueElmtsNbr,MessageRAMOffset,StdFiltersNbr,AutoRetransmission,ProtocolException,NominalSyncJumpWidth,DataSyncJumpWidth FDCAN2.IPParameters=CalculateTimeQuantumNominal,CalculateTimeBitNominal,CalculateBaudRateNominal,DataPrescaler,DataTimeSeg1,DataTimeSeg2,NominalPrescaler,NominalTimeSeg1,NominalTimeSeg2,RxFifo1ElmtsNbr,TxFifoQueueElmtsNbr,MessageRAMOffset,StdFiltersNbr,AutoRetransmission,ProtocolException,NominalSyncJumpWidth,DataSyncJumpWidth,RxFifo0ElmtsNbr
FDCAN2.MessageRAMOffset=853 FDCAN2.MessageRAMOffset=853
FDCAN2.NominalPrescaler=3 FDCAN2.NominalPrescaler=3
FDCAN2.NominalSyncJumpWidth=10 FDCAN2.NominalSyncJumpWidth=10
FDCAN2.NominalTimeSeg1=29 FDCAN2.NominalTimeSeg1=29
FDCAN2.NominalTimeSeg2=10 FDCAN2.NominalTimeSeg2=10
FDCAN2.ProtocolException=ENABLE FDCAN2.ProtocolException=DISABLE
FDCAN2.RxFifo1ElmtsNbr=32 FDCAN2.RxFifo0ElmtsNbr=4
FDCAN2.StdFiltersNbr=1 FDCAN2.RxFifo1ElmtsNbr=4
FDCAN2.StdFiltersNbr=14
FDCAN2.TxFifoQueueElmtsNbr=32 FDCAN2.TxFifoQueueElmtsNbr=32
FDCAN3.AutoRetransmission=ENABLE FDCAN3.AutoRetransmission=DISABLE
FDCAN3.CalculateBaudRateNominal=1000000 FDCAN3.CalculateBaudRateNominal=1000000
FDCAN3.CalculateTimeBitNominal=1000 FDCAN3.CalculateTimeBitNominal=1000
FDCAN3.CalculateTimeQuantumNominal=200.0 FDCAN3.CalculateTimeQuantumNominal=25.0
FDCAN3.ClockCalibrationCCU=DISABLE FDCAN3.ClockCalibrationCCU=DISABLE
FDCAN3.DataPrescaler=3 FDCAN3.DataPrescaler=3
FDCAN3.DataSyncJumpWidth=10 FDCAN3.DataSyncJumpWidth=10
FDCAN3.DataTimeSeg1=29 FDCAN3.DataTimeSeg1=29
FDCAN3.DataTimeSeg2=10 FDCAN3.DataTimeSeg2=10
FDCAN3.IPParameters=CalculateTimeQuantumNominal,CalculateTimeBitNominal,CalculateBaudRateNominal,DataPrescaler,DataTimeSeg1,DataTimeSeg2,NominalPrescaler,NominalTimeSeg1,NominalTimeSeg2,RxFifo1ElmtsNbr,TxFifoQueueElmtsNbr,MessageRAMOffset,StdFiltersNbr,AutoRetransmission,ProtocolException,NominalSyncJumpWidth,DataSyncJumpWidth,ClockCalibrationCCU FDCAN3.IPParameters=CalculateTimeQuantumNominal,CalculateTimeBitNominal,CalculateBaudRateNominal,DataPrescaler,DataTimeSeg1,DataTimeSeg2,NominalPrescaler,NominalTimeSeg1,NominalTimeSeg2,RxFifo1ElmtsNbr,TxFifoQueueElmtsNbr,MessageRAMOffset,StdFiltersNbr,AutoRetransmission,ProtocolException,NominalSyncJumpWidth,DataSyncJumpWidth,ClockCalibrationCCU,RxFifo0ElmtsNbr
FDCAN3.MessageRAMOffset=1706 FDCAN3.MessageRAMOffset=1706
FDCAN3.NominalPrescaler=24 FDCAN3.NominalPrescaler=3
FDCAN3.NominalSyncJumpWidth=10 FDCAN3.NominalSyncJumpWidth=10
FDCAN3.NominalTimeSeg1=2 FDCAN3.NominalTimeSeg1=29
FDCAN3.NominalTimeSeg2=2 FDCAN3.NominalTimeSeg2=10
FDCAN3.ProtocolException=ENABLE FDCAN3.ProtocolException=DISABLE
FDCAN3.RxFifo1ElmtsNbr=32 FDCAN3.RxFifo0ElmtsNbr=4
FDCAN3.StdFiltersNbr=1 FDCAN3.RxFifo1ElmtsNbr=4
FDCAN3.TxFifoQueueElmtsNbr=6 FDCAN3.StdFiltersNbr=14
FDCAN3.TxFifoQueueElmtsNbr=32
FREERTOS.FootprintOK=true FREERTOS.FootprintOK=true
FREERTOS.IPParameters=Tasks01,configENABLE_FPU,FootprintOK,configUSE_NEWLIB_REENTRANT,configCHECK_FOR_STACK_OVERFLOW,configUSE_MALLOC_FAILED_HOOK FREERTOS.IPParameters=Tasks01,configENABLE_FPU,FootprintOK,configUSE_NEWLIB_REENTRANT,configCHECK_FOR_STACK_OVERFLOW,configUSE_MALLOC_FAILED_HOOK,configTOTAL_HEAP_SIZE,configMINIMAL_STACK_SIZE
FREERTOS.Tasks01=BeginTask,24,256,StartDefaultTask,As weak,NULL,Dynamic,NULL,NULL;shoot,24,512,ShootTask,As weak,NULL,Dynamic,NULL,NULL;gimbal,24,512,GimbalTask,As weak,NULL,Dynamic,NULL,NULL;chassis,24,512,ChassisTask,As weak,NULL,Dynamic,NULL,NULL;init,40,256,StartInitTask,As weak,NULL,Dynamic,NULL,NULL;vision,24,512,VisionTask,As weak,NULL,Dynamic,NULL,NULL;cmd,24,512,CmdTask,As weak,NULL,Dynamic,NULL,NULL;reference,24,512,RefereeTask,As weak,NULL,Dynamic,NULL,NULL FREERTOS.Tasks01=BeginTask,24,256,StartDefaultTask,As weak,NULL,Dynamic,NULL,NULL;shoot,24,512,ShootTask,As weak,NULL,Dynamic,NULL,NULL;gimbal,24,512,GimbalTask,As weak,NULL,Dynamic,NULL,NULL;chassis,24,512,ChassisTask,As weak,NULL,Dynamic,NULL,NULL;init,40,256,StartInitTask,As weak,NULL,Dynamic,NULL,NULL;vision,24,512,VisionTask,As weak,NULL,Dynamic,NULL,NULL;cmd,24,512,CmdTask,As weak,NULL,Dynamic,NULL,NULL;reference,24,512,RefereeTask,As weak,NULL,Dynamic,NULL,NULL;WS2812Task,16,256,ws2812Task,As external,NULL,Dynamic,NULL,NULL
FREERTOS.configCHECK_FOR_STACK_OVERFLOW=2 FREERTOS.configCHECK_FOR_STACK_OVERFLOW=2
FREERTOS.configENABLE_FPU=1 FREERTOS.configENABLE_FPU=1
FREERTOS.configMINIMAL_STACK_SIZE=256
FREERTOS.configTOTAL_HEAP_SIZE=30720
FREERTOS.configUSE_MALLOC_FAILED_HOOK=1 FREERTOS.configUSE_MALLOC_FAILED_HOOK=1
FREERTOS.configUSE_NEWLIB_REENTRANT=0 FREERTOS.configUSE_NEWLIB_REENTRANT=0
File.Version=6 File.Version=6
@@ -410,104 +452,111 @@ MMTAppReg6.MEMORYMAP.Size=1048576
MMTAppReg6.MEMORYMAP.StartAddress=0x08000000 MMTAppReg6.MEMORYMAP.StartAddress=0x08000000
MMTAppRegionsCount=6 MMTAppRegionsCount=6
MMTConfigApplied=false MMTConfigApplied=false
MMTSectionSuffix=
Mcu.CPN=STM32H723VGT6 Mcu.CPN=STM32H723VGT6
Mcu.Family=STM32H7 Mcu.Family=STM32H7
Mcu.IP0=ADC3 Mcu.IP0=ADC1
Mcu.IP1=CORTEX_M7 Mcu.IP1=ADC3
Mcu.IP10=NVIC Mcu.IP10=NVIC
Mcu.IP11=RCC Mcu.IP11=RCC
Mcu.IP12=SPI1 Mcu.IP12=SPI1
Mcu.IP13=SPI2 Mcu.IP13=SPI2
Mcu.IP14=SYS Mcu.IP14=SPI6
Mcu.IP15=TIM1 Mcu.IP15=SYS
Mcu.IP16=TIM3 Mcu.IP16=TIM1
Mcu.IP17=TIM12 Mcu.IP17=TIM3
Mcu.IP18=UART5 Mcu.IP18=TIM12
Mcu.IP19=UART7 Mcu.IP19=UART5
Mcu.IP2=CRC Mcu.IP2=CORTEX_M7
Mcu.IP20=USART1 Mcu.IP20=UART7
Mcu.IP21=USART2 Mcu.IP21=USART1
Mcu.IP22=USART3 Mcu.IP22=USART2
Mcu.IP23=USART10 Mcu.IP23=USART3
Mcu.IP24=USB_DEVICE Mcu.IP24=USART10
Mcu.IP25=USB_OTG_HS Mcu.IP25=USB_DEVICE
Mcu.IP3=DMA Mcu.IP26=USB_OTG_HS
Mcu.IP4=FDCAN1 Mcu.IP3=CRC
Mcu.IP5=FDCAN2 Mcu.IP4=DMA
Mcu.IP6=FDCAN3 Mcu.IP5=FDCAN1
Mcu.IP7=FREERTOS Mcu.IP6=FDCAN2
Mcu.IP8=IWDG1 Mcu.IP7=FDCAN3
Mcu.IP8=FREERTOS
Mcu.IP9=MEMORYMAP Mcu.IP9=MEMORYMAP
Mcu.IPNb=26 Mcu.IPNb=27
Mcu.Name=STM32H723VGTx Mcu.Name=STM32H723VGTx
Mcu.Package=LQFP100 Mcu.Package=LQFP100
Mcu.Pin0=PE2 Mcu.Pin0=PE2
Mcu.Pin1=PE3 Mcu.Pin1=PE3
Mcu.Pin10=PA0 Mcu.Pin10=PC3_C
Mcu.Pin11=PA2 Mcu.Pin11=PA0
Mcu.Pin12=PA6 Mcu.Pin12=PA2
Mcu.Pin13=PA7 Mcu.Pin13=PA5
Mcu.Pin14=PB1 Mcu.Pin14=PA6
Mcu.Pin15=PE7 Mcu.Pin15=PA7
Mcu.Pin16=PE8 Mcu.Pin16=PC4
Mcu.Pin17=PE9 Mcu.Pin17=PB1
Mcu.Pin18=PE10 Mcu.Pin18=PE7
Mcu.Pin19=PE12 Mcu.Pin19=PE8
Mcu.Pin2=PC14-OSC32_IN Mcu.Pin2=PC13
Mcu.Pin20=PE13 Mcu.Pin20=PE9
Mcu.Pin21=PE15 Mcu.Pin21=PE10
Mcu.Pin22=PB10 Mcu.Pin22=PE12
Mcu.Pin23=PB11 Mcu.Pin23=PE13
Mcu.Pin24=PB13 Mcu.Pin24=PE15
Mcu.Pin25=PB14 Mcu.Pin25=PB10
Mcu.Pin26=PB15 Mcu.Pin26=PB11
Mcu.Pin27=PD8 Mcu.Pin27=PB13
Mcu.Pin28=PD9 Mcu.Pin28=PB15
Mcu.Pin29=PD10 Mcu.Pin29=PD8
Mcu.Pin3=PC15-OSC32_OUT Mcu.Pin3=PC14-OSC32_IN
Mcu.Pin30=PD12 Mcu.Pin30=PD9
Mcu.Pin31=PD13 Mcu.Pin31=PD10
Mcu.Pin32=PA8 Mcu.Pin32=PD12
Mcu.Pin33=PA9 Mcu.Pin33=PD13
Mcu.Pin34=PA10 Mcu.Pin34=PA8
Mcu.Pin35=PA11 Mcu.Pin35=PA9
Mcu.Pin36=PA12 Mcu.Pin36=PA10
Mcu.Pin37=PC10 Mcu.Pin37=PA11
Mcu.Pin38=PC11 Mcu.Pin38=PA12
Mcu.Pin39=PC12 Mcu.Pin39=PC10
Mcu.Pin4=PH0-OSC_IN Mcu.Pin4=PC15-OSC32_OUT
Mcu.Pin40=PD0 Mcu.Pin40=PC11
Mcu.Pin41=PD1 Mcu.Pin41=PC12
Mcu.Pin42=PD2 Mcu.Pin42=PD0
Mcu.Pin43=PD4 Mcu.Pin43=PD1
Mcu.Pin44=PD5 Mcu.Pin44=PD2
Mcu.Pin45=PD6 Mcu.Pin45=PD4
Mcu.Pin46=PD7 Mcu.Pin46=PD5
Mcu.Pin47=PB3(JTDO/TRACESWO) Mcu.Pin47=PD6
Mcu.Pin48=PB4(NJTRST) Mcu.Pin48=PD7
Mcu.Pin49=PB5 Mcu.Pin49=PB3(JTDO/TRACESWO)
Mcu.Pin5=PH1-OSC_OUT Mcu.Pin5=PH0-OSC_IN
Mcu.Pin50=PB6 Mcu.Pin50=PB4(NJTRST)
Mcu.Pin51=VP_ADC3_TempSens_Input Mcu.Pin51=PB5
Mcu.Pin52=VP_CRC_VS_CRC Mcu.Pin52=PB6
Mcu.Pin53=VP_FREERTOS_VS_CMSIS_V2 Mcu.Pin53=VP_ADC3_TempSens_Input
Mcu.Pin54=VP_IWDG1_VS_IWDG Mcu.Pin54=VP_CRC_VS_CRC
Mcu.Pin55=VP_SYS_VS_tim23 Mcu.Pin55=VP_FREERTOS_VS_CMSIS_V2
Mcu.Pin56=VP_TIM1_VS_ClockSourceINT Mcu.Pin56=VP_SYS_VS_tim23
Mcu.Pin57=VP_TIM1_VS_no_output3 Mcu.Pin57=VP_TIM1_VS_ClockSourceINT
Mcu.Pin58=VP_USB_DEVICE_VS_USB_DEVICE_CDC_HS Mcu.Pin58=VP_TIM1_VS_no_output3
Mcu.Pin59=VP_MEMORYMAP_VS_MEMORYMAP Mcu.Pin59=VP_USB_DEVICE_VS_USB_DEVICE_CDC_HS
Mcu.Pin6=PC0 Mcu.Pin6=PH1-OSC_OUT
Mcu.Pin7=PC1 Mcu.Pin60=VP_MEMORYMAP_VS_MEMORYMAP
Mcu.Pin8=PC2_C Mcu.Pin61=VP_STMicroelectronics.X-CUBE-ALGOBUILD_VS_DSPOoLibraryJjLibrary_1.4.0_1.4.0
Mcu.Pin9=PC3_C Mcu.Pin7=PC0
Mcu.PinsNb=60 Mcu.Pin8=PC1
Mcu.ThirdPartyNb=0 Mcu.Pin9=PC2_C
Mcu.PinsNb=62
Mcu.ThirdParty0=STMicroelectronics.X-CUBE-ALGOBUILD.1.4.0
Mcu.ThirdPartyNb=1
Mcu.UserConstants= Mcu.UserConstants=
Mcu.UserName=STM32H723VGTx Mcu.UserName=STM32H723VGTx
MxCube.Version=6.15.0 MxCube.Version=6.16.0
MxDb.Version=DB.6.0.150 MxDb.Version=DB.6.0.160
NVIC.ADC_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true\:true
NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false\:false NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false\:false
NVIC.DMA1_Stream0_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true\:true
NVIC.DMA1_Stream1_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true\:true NVIC.DMA1_Stream1_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true\:true
NVIC.DMA1_Stream2_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true\:true NVIC.DMA1_Stream2_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true\:true
NVIC.DMA1_Stream3_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true\:true NVIC.DMA1_Stream3_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true\:true
@@ -524,8 +573,11 @@ NVIC.DMA2_Stream6_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true\:true
NVIC.DMA2_Stream7_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true\:true NVIC.DMA2_Stream7_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true\:true
NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false\:false NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false\:false
NVIC.FDCAN1_IT0_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true\:true NVIC.FDCAN1_IT0_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true\:true
NVIC.FDCAN1_IT1_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true\:true
NVIC.FDCAN2_IT0_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true\:true NVIC.FDCAN2_IT0_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true\:true
NVIC.FDCAN2_IT1_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true\:true
NVIC.FDCAN3_IT0_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true\:true NVIC.FDCAN3_IT0_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true\:true
NVIC.FDCAN3_IT1_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true\:true
NVIC.ForceEnableDMAVector=true NVIC.ForceEnableDMAVector=true
NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false\:false NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false\:false
NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false\:false NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false\:false
@@ -551,7 +603,7 @@ NVIC.USART2_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true\:true
NVIC.USART3_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true\:true NVIC.USART3_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true\:true
NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false\:false NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false\:false
PA0.GPIOParameters=GPIO_Speed,PinState,GPIO_PuPd,GPIO_Label PA0.GPIOParameters=GPIO_Speed,PinState,GPIO_PuPd,GPIO_Label
PA0.GPIO_Label=pump1 PA0.GPIO_Label=power2
PA0.GPIO_PuPd=GPIO_PULLDOWN PA0.GPIO_PuPd=GPIO_PULLDOWN
PA0.GPIO_Speed=GPIO_SPEED_FREQ_HIGH PA0.GPIO_Speed=GPIO_SPEED_FREQ_HIGH
PA0.Locked=true PA0.Locked=true
@@ -566,15 +618,17 @@ PA12.Locked=true
PA12.Mode=Device_Only_FS PA12.Mode=Device_Only_FS
PA12.Signal=USB_OTG_HS_DP PA12.Signal=USB_OTG_HS_DP
PA2.GPIOParameters=GPIO_Speed,PinState,GPIO_PuPd,GPIO_Label PA2.GPIOParameters=GPIO_Speed,PinState,GPIO_PuPd,GPIO_Label
PA2.GPIO_Label=pump2 PA2.GPIO_Label=power1
PA2.GPIO_PuPd=GPIO_PULLDOWN PA2.GPIO_PuPd=GPIO_PULLDOWN
PA2.GPIO_Speed=GPIO_SPEED_FREQ_HIGH PA2.GPIO_Speed=GPIO_SPEED_FREQ_HIGH
PA2.Locked=true PA2.Locked=true
PA2.PinState=GPIO_PIN_SET PA2.PinState=GPIO_PIN_SET
PA2.Signal=GPIO_Output PA2.Signal=GPIO_Output
PA5.Mode=TX_Only_Simplex_Unidirect_Master
PA5.Signal=SPI6_SCK
PA6.Mode=Full_Duplex_Master PA6.Mode=Full_Duplex_Master
PA6.Signal=SPI6_MISO PA6.Signal=SPI6_MISO
PA7.Mode=Full_Duplex_Master PA7.Mode=TX_Only_Simplex_Unidirect_Master
PA7.Signal=SPI6_MOSI PA7.Signal=SPI6_MOSI
PA8.Mode=Clock-out-1 PA8.Mode=Clock-out-1
PA8.Signal=RCC_MCO_1 PA8.Signal=RCC_MCO_1
@@ -601,8 +655,6 @@ PB13.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH
PB13.Locked=true PB13.Locked=true
PB13.Mode=Full_Duplex_Master PB13.Mode=Full_Duplex_Master
PB13.Signal=SPI2_SCK PB13.Signal=SPI2_SCK
PB14.Mode=Hardware Flow Control (RS485)
PB14.Signal=USART3_DE
PB15.Signal=S_TIM12_CH2 PB15.Signal=S_TIM12_CH2
PB3(JTDO/TRACESWO).Locked=true PB3(JTDO/TRACESWO).Locked=true
PB3(JTDO/TRACESWO).Mode=Full_Duplex_Master PB3(JTDO/TRACESWO).Mode=Full_Duplex_Master
@@ -632,9 +684,18 @@ PC11.Signal=SPI3_MISO
PC12.Locked=true PC12.Locked=true
PC12.Signal=SharedStack_PC12 PC12.Signal=SharedStack_PC12
PC12.Stacked=true PC12.Stacked=true
PC13.GPIOParameters=PinState,GPIO_Label
PC13.GPIO_Label=Power2
PC13.Locked=true
PC13.PinState=GPIO_PIN_SET
PC13.Signal=GPIO_Output
PC14-OSC32_IN.GPIOParameters=PinState,GPIO_Label
PC14-OSC32_IN.GPIO_Label=Power1
PC14-OSC32_IN.Locked=true PC14-OSC32_IN.Locked=true
PC14-OSC32_IN.PinState=GPIO_PIN_SET
PC14-OSC32_IN.Signal=GPIO_Output PC14-OSC32_IN.Signal=GPIO_Output
PC15-OSC32_OUT.GPIOParameters=PinState PC15-OSC32_OUT.GPIOParameters=PinState,GPIO_Label
PC15-OSC32_OUT.GPIO_Label=Power_5V_EN
PC15-OSC32_OUT.Locked=true PC15-OSC32_OUT.Locked=true
PC15-OSC32_OUT.PinState=GPIO_PIN_SET PC15-OSC32_OUT.PinState=GPIO_PIN_SET
PC15-OSC32_OUT.Signal=GPIO_Output PC15-OSC32_OUT.Signal=GPIO_Output
@@ -648,6 +709,8 @@ PC3_C.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH
PC3_C.Locked=true PC3_C.Locked=true
PC3_C.PinState=GPIO_PIN_SET PC3_C.PinState=GPIO_PIN_SET
PC3_C.Signal=GPIO_Output PC3_C.Signal=GPIO_Output
PC4.Locked=true
PC4.Signal=ADCx_INP4
PD0.Mode=FDCAN_Activate PD0.Mode=FDCAN_Activate
PD0.Signal=FDCAN1_RX PD0.Signal=FDCAN1_RX
PD1.Mode=FDCAN_Activate PD1.Mode=FDCAN_Activate
@@ -724,7 +787,7 @@ PH1-OSC_OUT.Signal=RCC_OSC_OUT
PinOutPanel.RotationAngle=0 PinOutPanel.RotationAngle=0
ProjectManager.AskForMigrate=true ProjectManager.AskForMigrate=true
ProjectManager.BackupPrevious=false ProjectManager.BackupPrevious=false
ProjectManager.CompilerLinker=Starm-Clang ProjectManager.CompilerLinker=GCC
ProjectManager.CompilerOptimize=6 ProjectManager.CompilerOptimize=6
ProjectManager.ComputerToolchain=false ProjectManager.ComputerToolchain=false
ProjectManager.CoupleFile=true ProjectManager.CoupleFile=true
@@ -734,6 +797,7 @@ ProjectManager.DeletePrevious=true
ProjectManager.DeviceId=STM32H723VGTx ProjectManager.DeviceId=STM32H723VGTx
ProjectManager.FirmwarePackage=STM32Cube FW_H7 V1.12.1 ProjectManager.FirmwarePackage=STM32Cube FW_H7 V1.12.1
ProjectManager.FreePins=false ProjectManager.FreePins=false
ProjectManager.FreePinsContext=
ProjectManager.HalAssertFull=false ProjectManager.HalAssertFull=false
ProjectManager.HeapSize=0x4000 ProjectManager.HeapSize=0x4000
ProjectManager.KeepUserCode=true ProjectManager.KeepUserCode=true
@@ -753,7 +817,7 @@ ProjectManager.ToolChainLocation=
ProjectManager.UAScriptAfterPath= ProjectManager.UAScriptAfterPath=
ProjectManager.UAScriptBeforePath= ProjectManager.UAScriptBeforePath=
ProjectManager.UnderRoot=false ProjectManager.UnderRoot=false
ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false,2-MX_GPIO_Init-GPIO-false-HAL-true,3-MX_DMA_Init-DMA-false-HAL-true,4-MX_FDCAN2_Init-FDCAN2-false-HAL-true,5-MX_FDCAN3_Init-FDCAN3-false-HAL-true,6-MX_CRC_Init-CRC-false-HAL-true,7-MX_USB_DEVICE_Init-USB_DEVICE-false-HAL-false,8-MX_FDCAN1_Init-FDCAN1-false-HAL-true,9-MX_USART10_UART_Init-USART10-false-HAL-true,10-MX_SPI2_Init-SPI2-false-HAL-true,11-MX_TIM12_Init-TIM12-false-HAL-true,12-MX_UART7_Init-UART7-false-HAL-true,13-MX_TIM1_Init-TIM1-false-HAL-true,14-MX_USART1_UART_Init-USART1-false-HAL-true,15-MX_ADC3_Init-ADC3-false-HAL-true,16-MX_USART2_UART_Init-USART2-false-HAL-true,17-MX_USART3_UART_Init-USART3-false-HAL-true,18-MX_SPI1_Init-SPI1-false-HAL-true,19-MX_UART5_Init-UART5-false-HAL-true,20-MX_TIM3_Init-TIM3-false-HAL-true,21-MX_IWDG1_Init-IWDG1-false-HAL-true,0-MX_CORTEX_M7_Init-CORTEX_M7-false-HAL-true ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false,2-MX_GPIO_Init-GPIO-false-HAL-true,3-MX_DMA_Init-DMA-false-HAL-true,4-MX_FDCAN2_Init-FDCAN2-false-HAL-true,5-MX_FDCAN3_Init-FDCAN3-false-HAL-true,6-MX_CRC_Init-CRC-false-HAL-true,7-MX_USB_DEVICE_Init-USB_DEVICE-false-HAL-false,8-MX_FDCAN1_Init-FDCAN1-false-HAL-true,9-MX_USART10_UART_Init-USART10-false-HAL-true,10-MX_SPI2_Init-SPI2-false-HAL-true,11-MX_TIM12_Init-TIM12-false-HAL-true,12-MX_UART7_Init-UART7-false-HAL-true,13-MX_TIM1_Init-TIM1-false-HAL-true,14-MX_USART1_UART_Init-USART1-false-HAL-true,15-MX_ADC3_Init-ADC3-false-HAL-true,16-MX_USART2_UART_Init-USART2-false-HAL-true,17-MX_USART3_UART_Init-USART3-false-HAL-true,18-MX_SPI1_Init-SPI1-false-HAL-true,19-MX_UART5_Init-UART5-false-HAL-true,20-MX_TIM3_Init-TIM3-false-HAL-true,21-MX_SPI6_Init-SPI6-false-HAL-true,22-MX_ADC1_Init-ADC1-false-HAL-true,0-MX_CORTEX_M7_Init-CORTEX_M7-false-HAL-true
RCC.ADCFreq_Value=96000000 RCC.ADCFreq_Value=96000000
RCC.AHB12Freq_Value=240000000 RCC.AHB12Freq_Value=240000000
RCC.AHB4Freq_Value=240000000 RCC.AHB4Freq_Value=240000000
@@ -837,6 +901,8 @@ RCC.VCO3OutputFreq_Value=96750000
RCC.VCOInput1Freq_Value=12000000 RCC.VCOInput1Freq_Value=12000000
RCC.VCOInput2Freq_Value=12000000 RCC.VCOInput2Freq_Value=12000000
RCC.VCOInput3Freq_Value=750000 RCC.VCOInput3Freq_Value=750000
SH.ADCx_INP4.0=ADC1_INP4,IN4-Single-Ended
SH.ADCx_INP4.ConfNb=1
SH.GPXTI10.0=GPIO_EXTI10 SH.GPXTI10.0=GPIO_EXTI10
SH.GPXTI10.ConfNb=1 SH.GPXTI10.ConfNb=1
SH.GPXTI12.0=GPIO_EXTI12 SH.GPXTI12.0=GPIO_EXTI12
@@ -865,6 +931,18 @@ SPI2.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate,DataSize,BaudRate
SPI2.Mode=SPI_MODE_MASTER SPI2.Mode=SPI_MODE_MASTER
SPI2.NSSPMode=SPI_NSS_PULSE_ENABLE SPI2.NSSPMode=SPI_NSS_PULSE_ENABLE
SPI2.VirtualType=VM_MASTER SPI2.VirtualType=VM_MASTER
SPI6.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_4
SPI6.CLKPhase=SPI_PHASE_2EDGE
SPI6.CalculateBaudRate=6.0 MBits/s
SPI6.DataSize=SPI_DATASIZE_8BIT
SPI6.Direction=SPI_DIRECTION_2LINES_TXONLY
SPI6.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate,DataSize,BaudRatePrescaler,CLKPhase
SPI6.Mode=SPI_MODE_MASTER
SPI6.VirtualType=VM_MASTER
STMicroelectronics.X-CUBE-ALGOBUILD.1.4.0.DSPOoLibraryJjLibrary_Checked=true
STMicroelectronics.X-CUBE-ALGOBUILD.1.4.0.IPParameters=LibraryCcDSPOoLibraryJjDSPOoLibrary
STMicroelectronics.X-CUBE-ALGOBUILD.1.4.0.LibraryCcDSPOoLibraryJjDSPOoLibrary=true
STMicroelectronics.X-CUBE-ALGOBUILD.1.4.0_SwParameter=LibraryCcDSPOoLibraryJjDSPOoLibrary\:true;
TIM1.Channel-PWM\ Generation3\ No\ Output=TIM_CHANNEL_3 TIM1.Channel-PWM\ Generation3\ No\ Output=TIM_CHANNEL_3
TIM1.IPParameters=Channel-PWM Generation3 No Output,Prescaler,Period TIM1.IPParameters=Channel-PWM Generation3 No Output,Prescaler,Period
TIM1.Period=1999 TIM1.Period=1999
@@ -880,9 +958,10 @@ TIM3.IPParameters=Channel-PWM Generation4 CH4,Prescaler,Period,AutoReloadPreload
TIM3.Period=10000-1 TIM3.Period=10000-1
TIM3.Prescaler=24-1 TIM3.Prescaler=24-1
UART5.BaudRate=100000 UART5.BaudRate=100000
UART5.IPParameters=Mode,BaudRate,WordLength,Parity UART5.IPParameters=Mode,BaudRate,WordLength,Parity,StopBits
UART5.Mode=MODE_RX UART5.Mode=MODE_RX
UART5.Parity=PARITY_EVEN UART5.Parity=PARITY_EVEN
UART5.StopBits=UART_STOPBITS_2
UART5.WordLength=WORDLENGTH_9B UART5.WordLength=WORDLENGTH_9B
UART7.BaudRate=921600 UART7.BaudRate=921600
UART7.DMADisableonRxErrorParam=UART_ADVFEATURE_DMA_ENABLEONRXERROR UART7.DMADisableonRxErrorParam=UART_ADVFEATURE_DMA_ENABLEONRXERROR
@@ -903,10 +982,9 @@ USART2.OverrunDisableParam=ADVFEATURE_OVERRUN_DISABLE
USART2.VirtualMode-Asynchronous=VM_ASYNC USART2.VirtualMode-Asynchronous=VM_ASYNC
USART2.VirtualMode-Hardware\ Flow\ Control\ (RS485)=VM_ASYNC USART2.VirtualMode-Hardware\ Flow\ Control\ (RS485)=VM_ASYNC
USART3.BaudRate=4800000 USART3.BaudRate=4800000
USART3.IPParameters=VirtualMode-Asynchronous,VirtualMode-Hardware Flow Control (RS485),BaudRate,OverrunDisableParam USART3.IPParameters=VirtualMode-Asynchronous,BaudRate,OverrunDisableParam
USART3.OverrunDisableParam=ADVFEATURE_OVERRUN_DISABLE USART3.OverrunDisableParam=ADVFEATURE_OVERRUN_DISABLE
USART3.VirtualMode-Asynchronous=VM_ASYNC USART3.VirtualMode-Asynchronous=VM_ASYNC
USART3.VirtualMode-Hardware\ Flow\ Control\ (RS485)=VM_ASYNC
USB_DEVICE.CLASS_NAME_HS=CDC USB_DEVICE.CLASS_NAME_HS=CDC
USB_DEVICE.IPParameters=VirtualMode,VirtualModeHS,CLASS_NAME_HS USB_DEVICE.IPParameters=VirtualMode,VirtualModeHS,CLASS_NAME_HS
USB_DEVICE.VirtualMode=Cdc USB_DEVICE.VirtualMode=Cdc
@@ -919,10 +997,10 @@ VP_CRC_VS_CRC.Mode=CRC_Activate
VP_CRC_VS_CRC.Signal=CRC_VS_CRC VP_CRC_VS_CRC.Signal=CRC_VS_CRC
VP_FREERTOS_VS_CMSIS_V2.Mode=CMSIS_V2 VP_FREERTOS_VS_CMSIS_V2.Mode=CMSIS_V2
VP_FREERTOS_VS_CMSIS_V2.Signal=FREERTOS_VS_CMSIS_V2 VP_FREERTOS_VS_CMSIS_V2.Signal=FREERTOS_VS_CMSIS_V2
VP_IWDG1_VS_IWDG.Mode=IWDG_Activate
VP_IWDG1_VS_IWDG.Signal=IWDG1_VS_IWDG
VP_MEMORYMAP_VS_MEMORYMAP.Mode=CurAppReg VP_MEMORYMAP_VS_MEMORYMAP.Mode=CurAppReg
VP_MEMORYMAP_VS_MEMORYMAP.Signal=MEMORYMAP_VS_MEMORYMAP VP_MEMORYMAP_VS_MEMORYMAP.Signal=MEMORYMAP_VS_MEMORYMAP
VP_STMicroelectronics.X-CUBE-ALGOBUILD_VS_DSPOoLibraryJjLibrary_1.4.0_1.4.0.Mode=DSPOoLibraryJjLibrary
VP_STMicroelectronics.X-CUBE-ALGOBUILD_VS_DSPOoLibraryJjLibrary_1.4.0_1.4.0.Signal=STMicroelectronics.X-CUBE-ALGOBUILD_VS_DSPOoLibraryJjLibrary_1.4.0_1.4.0
VP_SYS_VS_tim23.Mode=TIM23 VP_SYS_VS_tim23.Mode=TIM23
VP_SYS_VS_tim23.Signal=SYS_VS_tim23 VP_SYS_VS_tim23.Signal=SYS_VS_tim23
VP_TIM1_VS_ClockSourceINT.Mode=Internal VP_TIM1_VS_ClockSourceINT.Mode=Internal

View File

@@ -31,7 +31,8 @@
/* USER CODE BEGIN PV */ /* USER CODE BEGIN PV */
/* Private variables ---------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/
static USBCallback tx_cbk = NULL;
static USBCallback rx_cbk = NULL;
/* USER CODE END PV */ /* USER CODE END PV */
/** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY /** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY
@@ -154,10 +155,10 @@ USBD_CDC_ItfTypeDef USBD_Interface_fops_HS =
static int8_t CDC_Init_HS(void) static int8_t CDC_Init_HS(void)
{ {
/* USER CODE BEGIN 8 */ /* USER CODE BEGIN 8 */
/* Set Application Buffers */ /* Set Application Buffers */
USBD_CDC_SetTxBuffer(&hUsbDeviceHS, UserTxBufferHS, 0); USBD_CDC_SetTxBuffer(&hUsbDeviceHS, UserTxBufferHS, 0);
USBD_CDC_SetRxBuffer(&hUsbDeviceHS, UserRxBufferHS); USBD_CDC_SetRxBuffer(&hUsbDeviceHS, UserRxBufferHS);
return (USBD_OK); return (USBD_OK);
/* USER CODE END 8 */ /* USER CODE END 8 */
} }
@@ -169,7 +170,7 @@ static int8_t CDC_Init_HS(void)
static int8_t CDC_DeInit_HS(void) static int8_t CDC_DeInit_HS(void)
{ {
/* USER CODE BEGIN 9 */ /* USER CODE BEGIN 9 */
return (USBD_OK); return (USBD_OK);
/* USER CODE END 9 */ /* USER CODE END 9 */
} }
@@ -183,66 +184,66 @@ static int8_t CDC_DeInit_HS(void)
static int8_t CDC_Control_HS(uint8_t cmd, uint8_t* pbuf, uint16_t length) static int8_t CDC_Control_HS(uint8_t cmd, uint8_t* pbuf, uint16_t length)
{ {
/* USER CODE BEGIN 10 */ /* USER CODE BEGIN 10 */
switch(cmd) switch (cmd)
{ {
case CDC_SEND_ENCAPSULATED_COMMAND: case CDC_SEND_ENCAPSULATED_COMMAND:
break; break;
case CDC_GET_ENCAPSULATED_RESPONSE: case CDC_GET_ENCAPSULATED_RESPONSE:
break; break;
case CDC_SET_COMM_FEATURE: case CDC_SET_COMM_FEATURE:
break; break;
case CDC_GET_COMM_FEATURE: case CDC_GET_COMM_FEATURE:
break; break;
case CDC_CLEAR_COMM_FEATURE: case CDC_CLEAR_COMM_FEATURE:
break; break;
/*******************************************************************************/ /*******************************************************************************/
/* Line Coding Structure */ /* Line Coding Structure */
/*-----------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------*/
/* Offset | Field | Size | Value | Description */ /* Offset | Field | Size | Value | Description */
/* 0 | dwDTERate | 4 | Number |Data terminal rate, in bits per second*/ /* 0 | dwDTERate | 4 | Number |Data terminal rate, in bits per second*/
/* 4 | bCharFormat | 1 | Number | Stop bits */ /* 4 | bCharFormat | 1 | Number | Stop bits */
/* 0 - 1 Stop bit */ /* 0 - 1 Stop bit */
/* 1 - 1.5 Stop bits */ /* 1 - 1.5 Stop bits */
/* 2 - 2 Stop bits */ /* 2 - 2 Stop bits */
/* 5 | bParityType | 1 | Number | Parity */ /* 5 | bParityType | 1 | Number | Parity */
/* 0 - None */ /* 0 - None */
/* 1 - Odd */ /* 1 - Odd */
/* 2 - Even */ /* 2 - Even */
/* 3 - Mark */ /* 3 - Mark */
/* 4 - Space */ /* 4 - Space */
/* 6 | bDataBits | 1 | Number Data bits (5, 6, 7, 8 or 16). */ /* 6 | bDataBits | 1 | Number Data bits (5, 6, 7, 8 or 16). */
/*******************************************************************************/ /*******************************************************************************/
case CDC_SET_LINE_CODING: case CDC_SET_LINE_CODING:
break; break;
case CDC_GET_LINE_CODING: case CDC_GET_LINE_CODING:
break; break;
case CDC_SET_CONTROL_LINE_STATE: case CDC_SET_CONTROL_LINE_STATE:
break; break;
case CDC_SEND_BREAK: case CDC_SEND_BREAK:
break; break;
default: default:
break; break;
} }
return (USBD_OK); return (USBD_OK);
/* USER CODE END 10 */ /* USER CODE END 10 */
} }
@@ -264,9 +265,9 @@ static int8_t CDC_Control_HS(uint8_t cmd, uint8_t* pbuf, uint16_t length)
static int8_t CDC_Receive_HS(uint8_t* Buf, uint32_t *Len) static int8_t CDC_Receive_HS(uint8_t* Buf, uint32_t *Len)
{ {
/* USER CODE BEGIN 11 */ /* USER CODE BEGIN 11 */
USBD_CDC_SetRxBuffer(&hUsbDeviceHS, &Buf[0]); USBD_CDC_SetRxBuffer(&hUsbDeviceHS, &Buf[0]);
USBD_CDC_ReceivePacket(&hUsbDeviceHS); USBD_CDC_ReceivePacket(&hUsbDeviceHS);
return (USBD_OK); return (USBD_OK);
/* USER CODE END 11 */ /* USER CODE END 11 */
} }
@@ -281,12 +282,13 @@ uint8_t CDC_Transmit_HS(uint8_t* Buf, uint16_t Len)
{ {
uint8_t result = USBD_OK; uint8_t result = USBD_OK;
/* USER CODE BEGIN 12 */ /* USER CODE BEGIN 12 */
USBD_CDC_HandleTypeDef *hcdc = (USBD_CDC_HandleTypeDef*)hUsbDeviceHS.pClassData; USBD_CDC_HandleTypeDef *hcdc = (USBD_CDC_HandleTypeDef *) hUsbDeviceHS.pClassData;
if (hcdc->TxState != 0){ if (hcdc->TxState != 0)
return USBD_BUSY; {
} return USBD_BUSY;
USBD_CDC_SetTxBuffer(&hUsbDeviceHS, Buf, Len); }
result = USBD_CDC_TransmitPacket(&hUsbDeviceHS); USBD_CDC_SetTxBuffer(&hUsbDeviceHS, Buf, Len);
result = USBD_CDC_TransmitPacket(&hUsbDeviceHS);
/* USER CODE END 12 */ /* USER CODE END 12 */
return result; return result;
} }
@@ -307,14 +309,22 @@ static int8_t CDC_TransmitCplt_HS(uint8_t *Buf, uint32_t *Len, uint8_t epnum)
{ {
uint8_t result = USBD_OK; uint8_t result = USBD_OK;
/* USER CODE BEGIN 14 */ /* USER CODE BEGIN 14 */
UNUSED(Buf); UNUSED(Buf);
UNUSED(Len); UNUSED(Len);
UNUSED(epnum); UNUSED(epnum);
if (tx_cbk)
tx_cbk(*Len);
/* USER CODE END 14 */ /* USER CODE END 14 */
return result; return result;
} }
/* USER CODE BEGIN PRIVATE_FUNCTIONS_IMPLEMENTATION */ /* USER CODE BEGIN PRIVATE_FUNCTIONS_IMPLEMENTATION */
uint8_t *CDCInitRxbufferNcallback(USBCallback transmit_cbk, USBCallback recv_cbk)
{
tx_cbk = transmit_cbk;
rx_cbk = recv_cbk;
return UserRxBufferHS;
}
/* USER CODE END PRIVATE_FUNCTIONS_IMPLEMENTATION */ /* USER CODE END PRIVATE_FUNCTIONS_IMPLEMENTATION */

View File

@@ -65,6 +65,7 @@
*/ */
/* USER CODE BEGIN EXPORTED_TYPES */ /* USER CODE BEGIN EXPORTED_TYPES */
typedef void (*USBCallback)(uint16_t);
/* USER CODE END EXPORTED_TYPES */ /* USER CODE END EXPORTED_TYPES */
@@ -109,6 +110,7 @@ extern USBD_CDC_ItfTypeDef USBD_Interface_fops_HS;
uint8_t CDC_Transmit_HS(uint8_t* Buf, uint16_t Len); uint8_t CDC_Transmit_HS(uint8_t* Buf, uint16_t Len);
/* USER CODE BEGIN EXPORTED_FUNCTIONS */ /* USER CODE BEGIN EXPORTED_FUNCTIONS */
uint8_t *CDCInitRxbufferNcallback(USBCallback transmit_cbk, USBCallback recv_cbk);
/* USER CODE END EXPORTED_FUNCTIONS */ /* USER CODE END EXPORTED_FUNCTIONS */

View File

@@ -0,0 +1,5 @@
//
// Created by esqwt on 2026/3/2.
//
#include "chassis_balance_parallel.h"

View File

@@ -0,0 +1,8 @@
//
// Created by esqwt on 2026/3/2.
//
#ifndef TRONONEH7_SCAFFOLD_CHASSIS_BALANCE_PARALLEL_H
#define TRONONEH7_SCAFFOLD_CHASSIS_BALANCE_PARALLEL_H
#endif // TRONONEH7_SCAFFOLD_CHASSIS_BALANCE_PARALLEL_H

View File

@@ -0,0 +1,5 @@
//
// Created by esqwt on 2026/3/2.
//
#include "chassis_balance_serial.h"

View File

@@ -0,0 +1,8 @@
//
// Created by esqwt on 2026/3/2.
//
#ifndef TRONONEH7_SCAFFOLD_CHASSIS_BALANCE_SERIAL_H
#define TRONONEH7_SCAFFOLD_CHASSIS_BALANCE_SERIAL_H
#endif // TRONONEH7_SCAFFOLD_CHASSIS_BALANCE_SERIAL_H

View File

@@ -0,0 +1,5 @@
//
// Created by esqwt on 2026/3/2.
//
#include "chassis_ctrl.h"

View File

@@ -0,0 +1,8 @@
//
// Created by esqwt on 2026/3/2.
//
#ifndef TRONONEH7_SCAFFOLD_CHASSIS_CTRL_H
#define TRONONEH7_SCAFFOLD_CHASSIS_CTRL_H
#endif // TRONONEH7_SCAFFOLD_CHASSIS_CTRL_H

View File

@@ -0,0 +1,219 @@
#include "chassis_half_steer.h"
#include "user_lib.h" // 包含 arm_math.h, PI, user_malloc 等
#include <math.h>
// 宏定义 (根据实际机械结构调整)
#ifndef WHEEL_BASE
#define WHEEL_BASE 0.35f // 轴距 (示例值)
#endif
#ifndef TRACK_WIDTH
#define TRACK_WIDTH 0.35f // 轮距 (示例值)
#endif
#define CHASSIS_WHEEL_OFFSET 30.0f // 舵轮偏置参数
#define SQRT2 1.41421356f // 根号2
#define RAD_2_DEGREE 57.2957795f
#define DEGREE_2_RAD 0.01745329f
// 舵轮对齐角度 (根据实际安装调整)
#define STEERING_CHASSIS_ALIGN_ANGLE_RF 0.0f
#define STEERING_CHASSIS_ALIGN_ANGLE_LB 0.0f
// 静态函数声明
static void MinmizeRotation(float *angle, const float *last_angle, float *speed);
static void SteeringWheelCalculate(Chassis_HalfSteer_t *chassis);
// 默认跟随PID配置
static PID_Init_Config_s follow_pid_config = {
.Kp = 6.0f,
.Ki = 0.0f,
.Kd = 0.495f,
.MaxOut = 45.0f,
};
void Chassis_HalfSteer_Init(Chassis_HalfSteer_t *chassis,
LKMotorInstance *drive_rf, LKMotorInstance *drive_lb,
DJIMotorInstance *steer_rf, DJIMotorInstance *steer_lb)
{
if (chassis == NULL) return;
// 绑定电机实例
chassis->motor_drive_rf = drive_rf;
chassis->motor_drive_lb = drive_lb;
chassis->motor_steer_rf = steer_rf;
chassis->motor_steer_lb = steer_lb;
// 初始化PID
PIDInit(&chassis->pid_follow, &follow_pid_config);
// 初始化状态变量
chassis->last_angle_rf = 0.0f;
chassis->last_angle_lb = 0.0f;
chassis->target_speed_rf = 0.0f;
chassis->target_speed_lb = 0.0f;
chassis->target_angle_rf = 0.0f;
chassis->target_angle_lb = 0.0f;
// 如果有电机需要特定的初始化配置(如 dji_motor 的参数),请在此处补充或在外部完成
}
void Chassis_HalfSteer_Update(Chassis_HalfSteer_t *chassis, const Chassis_Ctrl_Cmd_s *cmd)
{
if (chassis == NULL || cmd == NULL) return;
// 1. 更新内部命令副本
chassis->cmd = *cmd;
// 2. 检查底盘模式与安全状态
if (chassis->cmd.chassis_mode == CHASSIS_ZERO_FORCE)
{
LKMotorStop(chassis->motor_drive_rf);
LKMotorStop(chassis->motor_drive_lb);
DJIMotorStop(chassis->motor_steer_rf);
DJIMotorStop(chassis->motor_steer_lb);
return; // 直接返回,不再计算
}
else
{
LKMotorEnable(chassis->motor_drive_rf);
LKMotorEnable(chassis->motor_drive_lb);
DJIMotorEnable(chassis->motor_steer_rf);
DJIMotorEnable(chassis->motor_steer_lb);
}
// 3. 预处理旋转量 (wz)
switch (chassis->cmd.chassis_mode)
{
case CHASSIS_NO_FOLLOW:
chassis->cmd.wz = 0;
break;
case CHASSIS_FOLLOW_GIMBAL_YAW:
{
float angle_err = chassis->cmd.offset_angle;
// 归一化到 [-180, 180]
if(angle_err > 180.0f) angle_err -= 360.0f;
else if(angle_err < -180.0f) angle_err += 360.0f;
// 计算跟随PID输出
chassis->cmd.wz = PIDCalculate(&chassis->pid_follow, angle_err, 0.0f) / 100.0f; // 根据原代码保留/100
}
break;
case CHASSIS_ROTATE:
chassis->cmd.wz = 0.5f; // 固定自旋速度,可改为变量
break;
default:
break;
}
// 4. 坐标系转换 (云台系 -> 底盘系)
// 假设 cmd.vx/vy 是云台坐标系下的指令
float sin_theta = arm_sin_f32(chassis->cmd.offset_angle * DEGREE_2_RAD);
float cos_theta = arm_cos_f32(chassis->cmd.offset_angle * DEGREE_2_RAD);
// 覆盖原始 vx/vy 为底盘系速度 (使用中间变量避免污染原始cmd数据这里直接覆盖cmd结构体中的值用于后续计算)
float chassis_vx = chassis->cmd.vx * cos_theta - chassis->cmd.vy * sin_theta;
float chassis_vy = chassis->cmd.vx * sin_theta + chassis->cmd.vy * cos_theta;
// 将转换后的速度存回用于计算,或者传递给计算函数
// 为了保持清晰,我们修改 SteeringWheelCalculate 的输入方式,这里暂时存入 cmd 结构体或传递局部变量
// 这里选择传递局部变量,需要修改 SteeringWheelCalculate 内部逻辑
// 为了复用原逻辑,我将在函数内部使用 chassis_vx/vy
// 5. 运动学解算
// 传入 chassis_vx, chassis_vy 和 chassis->cmd.wz
// 注意:原代码使用全局变量,这里我们需要适配
float w = chassis->cmd.wz * CHASSIS_WHEEL_OFFSET * SQRT2;
if (fabsf(chassis_vx) == 0 && fabsf(chassis_vy) == 0 && chassis->cmd.wz == 0) {
chassis->target_speed_lb = 0;
chassis->target_speed_rf = 0;
// 角度保持不变,或回中?原代码保持不变
} else {
// LB (Left Back) 计算: y+, x-
// 注意:原代码注释里的方向似乎与变量名有差异,这里基于原代码逻辑复刻
// 原代码: arm_sqrt_f32(temp_x * temp_x + temp_y * temp_y, &vt_lb); // lb: y+ , x-
// temp_x = chassis_vx - w; temp_y = chassis_vy + w;
float temp_x_lb = chassis_vx - w;
float temp_y_lb = chassis_vy + w;
arm_sqrt_f32(temp_x_lb * temp_x_lb + temp_y_lb * temp_y_lb, &chassis->target_speed_lb);
float offset_lb = -atan2f(temp_y_lb, temp_x_lb) * RAD_2_DEGREE;
chassis->target_angle_lb = STEERING_CHASSIS_ALIGN_ANGLE_LB + offset_lb;
// RF (Right Front) 计算: y-, x+
// 原代码: arm_sqrt_f32(temp_x * temp_x + temp_y * temp_y, &vt_rf); // rf: y- , x+
// temp_x = chassis_vx + w; temp_y = chassis_vy - w;
float temp_x_rf = chassis_vx + w;
float temp_y_rf = chassis_vy - w;
arm_sqrt_f32(temp_x_rf * temp_x_rf + temp_y_rf * temp_y_rf, &chassis->target_speed_rf);
float offset_rf = -atan2f(temp_y_rf, temp_x_rf) * RAD_2_DEGREE;
chassis->target_angle_rf = STEERING_CHASSIS_ALIGN_ANGLE_RF + offset_rf;
// 6. 角度优化 (MinmizeRotation)
// 更新 last_angle
chassis->last_angle_lb = chassis->motor_steer_lb->measure.total_angle;
chassis->last_angle_rf = chassis->motor_steer_rf->measure.total_angle;
// 限制到 [-180, 180] 绝对值逻辑? 原代码使用了 ANGLE_LIMIT_360_TO_180_ABS 宏
// 这里手动实现或调用 user_lib
// 假设 user_lib.h 中有相关宏,这里简单处理
// (省略部分宏展开,直接使用 MinmizeRotation)
MinmizeRotation(&chassis->target_angle_lb, &chassis->last_angle_lb, &chassis->target_speed_lb);
MinmizeRotation(&chassis->target_angle_rf, &chassis->last_angle_rf, &chassis->target_speed_rf);
}
// 7. 发送控制指令
// 转向电机 (DJI GM6020)
DJIMotorSetRef(chassis->motor_steer_lb, chassis->target_angle_lb);
DJIMotorSetRef(chassis->motor_steer_rf, chassis->target_angle_rf);
// 驱动电机 (LK 9015)
LKMotorSetRef(chassis->motor_drive_lb, chassis->target_speed_lb);
LKMotorSetRef(chassis->motor_drive_rf, chassis->target_speed_rf);
}
/**
* @brief 使舵电机角度最小旋转,取优弧
*/
static void MinmizeRotation(float *angle, const float *last_angle, float *speed)
{
float target_angle = *angle;
float actual_angle = *last_angle;
float rotation = target_angle - actual_angle;
float norm_rotation = rotation;
// 规范化旋转角度到 [-180, 180]
while (norm_rotation > 180.0f) {
norm_rotation -= 360.0f;
}
while (norm_rotation < -180.0f) {
norm_rotation += 360.0f;
}
float threshold = 110.0f; // 阈值,超过此角度则反转轮子方向
// 简单的优弧判断
if (norm_rotation > threshold) {
int32_t round_diff = (int32_t)((target_angle - actual_angle) / 360.0f);
*angle = actual_angle + norm_rotation - 180.0f + round_diff * 360.0f;
*speed = -(*speed);
} else if (norm_rotation < -threshold) {
int32_t round_diff = (int32_t)((target_angle - actual_angle) / 360.0f);
*angle = actual_angle + norm_rotation + 180.0f + round_diff * 360.0f;
*speed = -(*speed);
}
// 如果没有触发反转,目标角度通常需要加上圈数,
// 但原代码逻辑似乎是直接修改传入的 angle 指针。
// 如果 norm_rotation 在阈值内,我们需要确保 angle 是基于 actual_angle 的最近点
// 原逻辑中 MinmizeRotation 似乎只处理了反转的情况,
// 对于常规旋转,可能需要确保 *angle 包含了正确的圈数信息。
// 补充逻辑:
if (norm_rotation <= threshold && norm_rotation >= -threshold) {
// 计算最近的目标角度(包含圈数)
*angle = actual_angle + norm_rotation;
}
}

View File

@@ -0,0 +1,89 @@
#ifndef CHASSIS_HALF_STEER_H
#define CHASSIS_HALF_STEER_H
#include "stdint.h"
#include "dji_motor.h"
#include "lk_motor.h" // 假设存在对应的C接口头文件
#include "pid.h"
#include "chassis_ctrl.h" // 包含底盘控制相关的通用定义
// 定义底盘控制命令结构体 (如果 chassis_ctrl.h 中未定义,请在此定义或确保通用)
#ifndef CHASSIS_CTRL_CMD_DEFINED
#define CHASSIS_CTRL_CMD_DEFINED
typedef enum
{
CHASSIS_ZERO_FORCE = 0, // 无力/急停
CHASSIS_NO_FOLLOW, // 不跟随/自由移动
CHASSIS_FOLLOW_GIMBAL_YAW, // 跟随云台Yaw
CHASSIS_ROTATE, // 小陀螺/自旋
} Chassis_Mode_e;
typedef struct
{
float vx; // 前后速度 (m/s)
float vy; // 左右速度 (m/s)
float wz; // 旋转角速度 (rad/s 或 对应单位)
float offset_angle; // 底盘与云台的夹角 (度)
Chassis_Mode_e chassis_mode;
} Chassis_Ctrl_Cmd_s;
#endif
// 定义底盘反馈数据结构体
typedef struct
{
float vx;
float vy;
float wz;
// float real_angle; // 预留
} Chassis_Upload_Data_s;
// 半舵轮底盘对象结构体
typedef struct
{
// 轮毂电机实例 (驱动) - LK9015
LKMotorInstance *motor_drive_rf; // 右前
LKMotorInstance *motor_drive_lb; // 左后
// 舵向电机实例 (转向) - GM6020
DJIMotorInstance *motor_steer_rf; // 右前舵
DJIMotorInstance *motor_steer_lb; // 左后舵
// PID实例
PIDInstance pid_follow; // 跟随PID
// 控制命令与状态
Chassis_Ctrl_Cmd_s cmd;
Chassis_Upload_Data_s feedback;
// 内部计算中间变量
float target_speed_rf; // 右前轮目标速度
float target_speed_lb; // 左后轮目标速度
float target_angle_rf; // 右前舵目标角度
float target_angle_lb; // 左后舵目标角度
// 上一次的角度记录 (用于就近转动逻辑)
float last_angle_rf;
float last_angle_lb;
} Chassis_HalfSteer_t;
/**
* @brief 初始化半舵轮底盘对象
* @param chassis 底盘对象指针
* @param drive_rf 右前驱动电机指针
* @param drive_lb 左后驱动电机指针
* @param steer_rf 右前转向电机指针
* @param steer_lb 左后转向电机指针
*/
void Chassis_HalfSteer_Init(Chassis_HalfSteer_t *chassis,
LKMotorInstance *drive_rf, LKMotorInstance *drive_lb,
DJIMotorInstance *steer_rf, DJIMotorInstance *steer_lb);
/**
* @brief 底盘控制更新函数建议在RTOS任务中周期调用
* @param chassis 底盘对象指针
* @param cmd 控制命令指针
*/
void Chassis_HalfSteer_Update(Chassis_HalfSteer_t *chassis, const Chassis_Ctrl_Cmd_s *cmd);
#endif // CHASSIS_HALF_STEER_H

View File

@@ -0,0 +1,5 @@
//
// Created by esqwt on 2026/3/2.
//
#include "chassis_lift_onmi.h"

View File

@@ -0,0 +1,8 @@
//
// Created by esqwt on 2026/3/2.
//
#ifndef TRONONEH7_SCAFFOLD_LIFT_ONMI_H
#define TRONONEH7_SCAFFOLD_LIFT_ONMI_H
#endif // TRONONEH7_SCAFFOLD_LIFT_ONMI_H

View File

@@ -0,0 +1,5 @@
//
// Created by esqwt on 2026/3/2.
//
#include "chassis_mecanum.h"

View File

@@ -0,0 +1,8 @@
//
// Created by esqwt on 2026/3/2.
//
#ifndef TRONONEH7_SCAFFOLD_CHASSIS_MECANUM_H
#define TRONONEH7_SCAFFOLD_CHASSIS_MECANUM_H
#endif // TRONONEH7_SCAFFOLD_CHASSIS_MECANUM_H

View File

@@ -0,0 +1,273 @@
#include "chassis_omni.h"
#include <math.h>
#include <stdlib.h>
#include <string.h>
#ifndef M_PI
#define M_PI 3.14159265358979323846f
#endif
// 辅助函数:绝对值限幅
static float abs_clip(float val, float limit)
{
if (val > limit) return limit;
if (val < -limit) return -limit;
return val;
}
// PID配置
static PID_Init_Config_s chassis_speed_pid_config = {
.MaxOut = 16000.0f,
.IntegralLimit = 2000.0f, // 对应 C++ IntegralLimit (Integral_Min/Max 在 C PID 中未直接对应,取其中值或限制值)
.Kp = 15.0f,
.Ki = 0.0f,
.Kd = 0.001f,
.Output_LPF_RC = 0.002f, // 对应 C++ Output_LPF
.Derivative_LPF_RC = 0.002f, // 对应 C++ D_LPF
.Improve = PID_Integral_Limit, // 对应 0x01
};
// 跟随环内环 (对应 index 0)
static PID_Init_Config_s follow_pid_inner_config = {
.MaxOut = 4000.0f,
.IntegralLimit = 200.0f,
.Kp = 20.0f,
.Ki = 4.0f,
.Kd = 0.0001f,
.Output_LPF_RC = 0.002f,
.Derivative_LPF_RC = 0.002f,
// 对应 0x37 = Integral_Limit | Differential_Forward | Trapezoid_Intergral | OutputFilter | ChangingIntegrationRate
// C definitions:
// PID_Integral_Limit (1)
// PID_Derivative_On_Measurement (2)
// PID_Trapezoid_Intergral (4)
// PID_OutputFilter (16)
// PID_ChangingIntegrationRate (32)
.Improve = PID_Integral_Limit | PID_Derivative_On_Measurement | PID_Trapezoid_Intergral | PID_OutputFilter | PID_ChangingIntegrationRate,
};
// 跟随环外环 (对应 index 1)
static PID_Init_Config_s follow_pid_outer_config = {
.MaxOut = 4000.0f,
.IntegralLimit = 4000.0f,
.Kp = 15.0f,
.Ki = 0.0f,
.Kd = 1.8f,
.Output_LPF_RC = 0.002f,
.Derivative_LPF_RC = 0.002f,
.Improve = PID_Integral_Limit | PID_Derivative_On_Measurement | PID_Trapezoid_Intergral | PID_OutputFilter | PID_ChangingIntegrationRate,
};
void Chassis_Omni_Init(Chassis_Omni_t *chassis, DJIMotorInstance *lf, DJIMotorInstance *rf, DJIMotorInstance *lb, DJIMotorInstance *rb)
{
if (chassis == NULL) return;
chassis->moto_chassis[0] = lf;
chassis->moto_chassis[1] = rf;
chassis->moto_chassis[2] = lb;
chassis->moto_chassis[3] = rb;
// 初始化速度PID
for (int i = 0; i < 4; i++) {
PIDInit(&chassis->pid_speed[i], &chassis_speed_pid_config);
}
// 初始化跟随PID (串级)
PIDInit(&chassis->pid_follow_angle_inner, &follow_pid_inner_config);
PIDInit(&chassis->pid_follow_angle_outer, &follow_pid_outer_config);
// 初始化功率控制参数
chassis->power_config.super_power_health = 90.0f;
chassis->power_config.super_power_week = 20.0f;
chassis->power_config.chassis_normal_speed_limit = 80; // 这里的单位可能需要根据实际调整
}
// 功率分配 (防止超功率)
static void Chassis_Power_Allocation(Chassis_Omni_t *chassis)
{
float scaling[4];
float total_err = 0.0f;
// 计算总误差 (使用 Err 字段)
for (int i = 0; i < 4; i++) {
total_err += fabsf(chassis->pid_speed[i].Err);
}
if (total_err > 1e-6f) { // 避免除零
for (int i = 0; i < 4; i++) {
scaling[i] = chassis->pid_speed[i].Err / total_err;
}
// 限制输出
for (int i = 0; i < 4; i++) {
// 原代码: pidinstance[0].pos_out = abs_clip(..., abs(Scaling[i] * 50000))
// 注意: 这里直接修改了 PID 的 Output可能会影响下一次计算但在C++原版中就是这样写的
float limit = fabsf(scaling[i] * 50000.0f);
chassis->pid_speed[i].Output = abs_clip(chassis->pid_speed[i].Output, limit);
}
}
}
void Chassis_Omni_Update(Chassis_Omni_t *chassis)
{
if (chassis == NULL) return;
// 1. 获取电机速度并进行正运动学解算 (估计底盘当前速度)
float motor_speeds[4];
float real_speed[4]; // [0]=vx, [1]=vy, [2]=w
for (int i = 0; i < 4; i++) {
// 使用 speed_aps (度/秒)
motor_speeds[i] = chassis->moto_chassis[i]->measure.speed_aps;
}
// 逆结算部分 (原代码注释,实际是正解算:轮速 -> 体速)
// 假设是X型全向轮/麦克纳姆轮布局
real_speed[0] = (-motor_speeds[0] - motor_speeds[1] + motor_speeds[2] + motor_speeds[3]) / 4.0f;
real_speed[1] = (-motor_speeds[0] + motor_speeds[1] - motor_speeds[2] + motor_speeds[3]) / 4.0f;
real_speed[2] = (-motor_speeds[0] - motor_speeds[1] - motor_speeds[2] - motor_speeds[3]) / 4.0f;
// 将底盘体坐标系速度转换到之前的参考系 (可能是云台系或世界系,取决于 real_angle 的定义)
float cos_a = cosf(chassis->cmd.real_angle);
float sin_a = sinf(chassis->cmd.real_angle);
float speedx = real_speed[0] * cos_a - real_speed[1] * sin_a;
float speedy = real_speed[0] * sin_a + real_speed[1] * cos_a;
float target_speed[3] = {0};
if (chassis->cmd.if_enable != 0)
{
// 2. 跟随PID计算
chassis->offset_angle = -chassis->cmd.follow_angle;
chassis->offset_speed = chassis->cmd.yaw_speed;
if (!chassis->cmd.if_free) {
// 串级PID: 外环(角度) -> 内环(速度)
// 外环目标: 0 (使 offset_angle 归零)
float outer_out = PIDCalculate(&chassis->pid_follow_angle_outer, chassis->offset_angle, 0.0f);
// 内环目标: 外环输出
// 内环反馈: offset_speed (yaw_speed)
chassis->follow_increment = PIDCalculate(&chassis->pid_follow_angle_inner, chassis->offset_speed, outer_out);
} else {
chassis->follow_increment = 0.0f;
// 清空PID积分等状态
chassis->pid_follow_angle_outer.Output = 0;
chassis->pid_follow_angle_inner.Output = 0;
}
// 3. 底盘速度闭环控制 (P控制)
// 这里的 5.5 是速度环增益,计算出的是"加速度"或"力"的需求
target_speed[0] = (chassis->cmd.speed[0] - speedx) * 5.5f;
target_speed[1] = (chassis->cmd.speed[1] - speedy) * 5.5f;
// 旋转轴控制
// 如果没有指令输入,则使用 real_speed 差值进行阻尼控制?
// 原代码逻辑: speed[2] = (cmd - real) * 5.5
target_speed[2] = (chassis->cmd.speed[2] - real_speed[2]) * 5.5f;
if (chassis->cmd.speed[2] == 0.0f) // 如果没有旋转指令
{
// 叠加跟随PID输出并减去当前旋转速度 (阻尼)
target_speed[2] = (chassis->follow_increment - real_speed[2] - real_speed[2]) * 5.5f;
}
else
{
// 如果有手动旋转指令清除跟随PID积分
chassis->pid_follow_angle_outer.Output = 0;
chassis->pid_follow_angle_inner.Output = 0;
}
// 4. 逆运动学解算 (体速 -> 轮速)
// 引入了旋转补偿: real_angle - 0.002 * real_speed[2]
float corrected_angle = chassis->cmd.real_angle - 0.002f * real_speed[2];
float sin_ca = sinf(corrected_angle);
float cos_ca = cosf(corrected_angle);
// 转换回电机解算所需的 x, y 分量
float y = -(target_speed[0] * sinf(chassis->cmd.real_angle) - target_speed[1] * cos_ca);
float x = (target_speed[0] * cosf(chassis->cmd.real_angle) + target_speed[1] * sin_ca);
// 5. 电机PID控制与输出
float wheel_targets[4];
wheel_targets[0] = (-x - y) - target_speed[2];
wheel_targets[1] = (-x + y) - target_speed[2];
wheel_targets[2] = (x - y) - target_speed[2];
wheel_targets[3] = (x + y) - target_speed[2];
for (int i = 0; i < 4; i++) {
// PIDCalculate(pid, measure, target) -> 这里的measure似乎被当作0处理
// 原C++代码: pid_chassis[i]->PID_handle(wheel_targets[i]);
// PID_handle(target) 内部通常是 calculate(measure, target).
// 但原代码中 PID 构造时传入了 &moto_chassis[i]->speed 地址。
// 因此 C++ PID 类会自动读取 measure。
// 在 C 中,我们需要手动传入 measure。
float output = PIDCalculate(&chassis->pid_speed[i], chassis->moto_chassis[i]->measure.speed_aps, wheel_targets[i]);
// 设置电机输出 (注意DJIMotorSetRef 设置的是目标值还是直接电流?)
// 根据 dji_motor.h 注释: "可以将电机视为传递函数为1的设备...不需要关心底层的闭环"
// 如果 DJIMotorSetRef 是设定速度闭环的目标,那么上面的 PID 是多余的吗?
// 不,原代码 clearly 使用了 pid_chassis[i] 计算 send_data。
// 这意味着 dji_motor 应该工作在 OPEN_LOOP 或 CURRENT_LOOP 模式,或者我们需要直接操作 current。
// 假设我们这里计算的是电流值,因为 MaxOut 是 16000 (M3508电流范围)。
// DJIMotorSetRef 通常用于设定内置闭环的目标。
// 如果要发送电流,通常没有直接的 SetCurrent API除非 Motor_Control_Setting_s 允许。
// 为了保持移植性,我们假设 DJIMotorSetRef 能够处理这个输出,或者我们需要修改 dji_motor 模块。
// 这里我们假设 DJIMotorSetRef 在电流模式下工作。
DJIMotorSetRef(chassis->moto_chassis[i], output);
}
// 6. 功率限制
Chassis_Power_Allocation(chassis);
// 如果 Chassis_Power_Allocation 修改了 PID Output我们需要重新 SetRef 吗?
// 原代码直接修改了 pos_out这在下一次计算时生效或者如果 PID 类直接返回 pos_out 给 send_data。
// C++代码: moto_chassis[i]->send_data = PID_handle(...); Chassis_Power_Allocation();
// Power_Allocation 修改了 pid instance 的 pos_out。
// 这意味着当前的 send_data 并没有被 Power_Allocation 修正!
// 修正逻辑应该是先计算 PID再分配再发送。
// 但为了忠实还原原代码逻辑,我们保持顺序。
// (注:原代码逻辑可能存在缺陷,分配后的功率限制在下一帧才通过积分项或直接赋值生效?
// 或者 moto_chassis->send_data 是个指针引用?不,它是值。
// 如果原代码 Allocation 在赋值给 send_data 之后调用,那么它只影响了 PID 内部状态,不影响当前帧输出。)
}
else
{
for (int i = 0; i < 4; i++) {
DJIMotorStop(chassis->moto_chassis[i]);
}
}
}
void Chassis_Omni_PowerControl(Chassis_Omni_t *chassis, Chassis_Power_Info_s *power_info, Chassis_Ctrl_Cmd_s *raw_cmd)
{
if (chassis == NULL || power_info == NULL || raw_cmd == NULL) return;
// 复制原始指令到内部 cmd (默认)
chassis->cmd = *raw_cmd;
// 简单的功率策略实现 (参考 Chassis_OmniWheel_Crtl::powerControl)
float speed_scaling = 1.0f;
if (power_info->remain_energy >= chassis->power_config.super_power_health)
{
speed_scaling = 1.0f; // 正常模式
}
else if (power_info->remain_energy >= chassis->power_config.super_power_week)
{
// 线性降额: energy + 10 ? 原代码: tired = energy + 10
float tired = power_info->remain_energy + 10.0f;
speed_scaling = tired * 0.01f; // 归一化
}
else
{
speed_scaling = 0.3f; // 低电量模式
}
// 应用缩放系数 (原代码还有 200 * 1.5/1.8 的系数,这里假设 raw_cmd 已经是归一化值,只做缩放)
// 原代码: data_to_chassis.speed[...] = data_from_FSM.speed[...] * 200 * ...
// 这里我们只做相对缩放,保留原始比例
chassis->cmd.speed[0] *= speed_scaling;
chassis->cmd.speed[1] *= speed_scaling;
chassis->cmd.speed[2] *= speed_scaling;
}

View File

@@ -0,0 +1,81 @@
#ifndef CHASSIS_OMNI_H
#define CHASSIS_OMNI_H
#include "stdint.h"
#include "dji_motor.h"
#include "pid.h"
// 定义底盘控制命令结构体 (由于chassis_ctrl.h为空在此定义以适配逻辑)
typedef struct
{
float speed[3]; // x, y, z (旋转) 速度设定值
float follow_angle; // 跟随角度 (底盘与云台夹角)
float yaw_speed; // 当前Yaw轴角速度 (作为前馈或反馈)
float real_angle; // 底盘当前实际角度 (用于坐标系转换)
uint8_t if_enable; // 底盘使能标志
uint8_t if_free; // 底盘自由模式标志 (不跟随)
} Chassis_Ctrl_Cmd_s;
// 定义功率控制所需的外部数据结构
typedef struct
{
uint16_t chassis_power_limit; // 来自裁判系统的功率限制
float remain_energy; // 来自超级电容的剩余能量
uint16_t chassis_power_buffer; // 缓冲能量 (可选)
} Chassis_Power_Info_s;
// 全向轮底盘对象结构体
typedef struct
{
// 电机实例指针 (LF, RF, LB, RB)
DJIMotorInstance *moto_chassis[4];
// 速度环PID实例 (每个轮子一个)
PIDInstance pid_speed[4];
// 跟随环串级PID实例
PIDInstance pid_follow_angle_outer; // 外环 (角度)
PIDInstance pid_follow_angle_inner; // 内环 (角速度)
// 控制数据
Chassis_Ctrl_Cmd_s cmd;
// 内部计算状态变量
float offset_angle;
float offset_speed;
float follow_increment;
// 功率控制参数
struct {
float super_power_health;
float super_power_week;
uint16_t chassis_normal_speed_limit;
} power_config;
} Chassis_Omni_t;
/**
* @brief 初始化全向轮底盘对象
* @param chassis 底盘对象指针
* @param lf 左前电机指针
* @param rf 右前电机指针
* @param lb 左后电机指针
* @param rb 右后电机指针
*/
void Chassis_Omni_Init(Chassis_Omni_t *chassis, DJIMotorInstance *lf, DJIMotorInstance *rf, DJIMotorInstance *lb, DJIMotorInstance *rb);
/**
* @brief 底盘控制任务函数建议在RTOS任务中周期调用
* @param chassis 底盘对象指针
*/
void Chassis_Omni_Update(Chassis_Omni_t *chassis);
/**
* @brief 功率控制逻辑,根据裁判系统和超电状态限制目标速度
* @param chassis 底盘对象指针
* @param power_info 功率状态信息
* @param raw_cmd 原始控制命令 (通常来自上层FSM)
*/
void Chassis_Omni_PowerControl(Chassis_Omni_t *chassis, Chassis_Power_Info_s *power_info, Chassis_Ctrl_Cmd_s *raw_cmd);
#endif // CHASSIS_OMNI_H

View File

@@ -0,0 +1,5 @@
//
// Created by esqwt on 2026/3/2.
//
#include "chassis_steer.h"

View File

@@ -0,0 +1,8 @@
//
// Created by esqwt on 2026/3/2.
//
#ifndef TRONONEH7_SCAFFOLD_CHASSIS_STEER_H
#define TRONONEH7_SCAFFOLD_CHASSIS_STEER_H
#endif // TRONONEH7_SCAFFOLD_CHASSIS_STEER_H

View File

@@ -0,0 +1,5 @@
//
// Created by esqwt on 2026/3/2.
//
#include "gimbal.h"

View File

@@ -0,0 +1,8 @@
//
// Created by esqwt on 2026/3/2.
//
#ifndef TRONONEH7_SCAFFOLD_GIMBAL_H
#define TRONONEH7_SCAFFOLD_GIMBAL_H
#endif // TRONONEH7_SCAFFOLD_GIMBAL_H

View File

@@ -0,0 +1,5 @@
//
// Created by esqwt on 2026/3/2.
//
#include "gimbal_control.h"

View File

@@ -0,0 +1,8 @@
//
// Created by esqwt on 2026/3/2.
//
#ifndef TRONONEH7_SCAFFOLD_GIMBAL_CTRL_H
#define TRONONEH7_SCAFFOLD_GIMBAL_CTRL_H
#endif // TRONONEH7_SCAFFOLD_GIMBAL_CTRL_H

View File

@@ -0,0 +1,201 @@
/**
* @file ws2812Task.c
* @brief WS2812 LED control task
* @author TuxMonkey (nqx2004@gmail.com)
* @version 1.0
* @date 2025-07-08
*
* @copyright Copyright (c) 2025 DLMU-C.ONE
*
* @par 修改日志:
* <table>
* <tr><th>Date <th>Version <th>Author <th>Description
* <tr><td>2025-07-08 <td>1.0 <td>TuxMonkey <td>内容
* </table>
*/
//真的有点抽象了不太清楚什么问题24V的时候用16的分频器可以 5V时候就只能用32的分频器了 spi6的 这个之后注意一下吧 如果要开发还是用32的分频器。
/*---------------------INCLUDES----------------------*/
#include "ws2812status.h"
#include "ws2812.h"
#include "cmsis_os.h"
#include "tim.h"
#include "delayticks.h"
#include "robot_def.h"
#include "rc.h"
/*---------------------VARIABLES---------------------*/
uint8_t r = 0;
uint8_t g = 0;
uint8_t b = 0;
/*---------------------FUNCTIONS---------------------*/
void robotSelfCheck(void)
{
WS2812_Ctrl(255, 0, 0);
HAL_Delay(300);
WS2812_Ctrl(0, 0, 255);
HAL_Delay(300);
WS2812_Ctrl(0, 255, 0);
HAL_Delay(300);
WS2812_Ctrl(0, 255, 0);
}
/**
* @brief WS2812 LED control task
* @param argument
*/
void ws2812Task(void *argument)
{
(void) argument;
RC_ctrl_t rc_data;
while (1)
{
RobotMode_t display_mode = RobotMode;
if (display_mode != SYS_ERROR_OCCURRED && !RemoteControlIsOnline())
display_mode = REMOTE_NOT_CONNECTED;
if (RemoteControlReadSnapshot(&rc_data) && switch_is_down(rc_data.sw_d))
display_mode = NORMAL_MODE;
switch (display_mode)
{
case NORMAL_MODE:
BlinkBlue();
break;
case SYS_ERROR_OCCURRED:
BlinkRed();
break;
case REMOTE_NOT_CONNECTED:
BlinkRed();
break;
case REMOTE_CONNECTED:
BlinkYellow();
break;
case AUTO_SHOOTING_MODE:
BlinkCyan();
break;
case IMU_CALIBERATION_MODE:
BlinkPurple();
break;
default:
BlinkYellow();
}
osDelay(10); // 每个任务最后都要写在while里要不然会导致任务切换失败
}
}
void BlinkYellow(void)
{
r = 255; // 红色分量
g = 255; // 绿色分量
b = 0; // 蓝色分量
WS2812_Ctrl(r, g, b); // 设置为黄色
delay_ticks(500); // 延时500毫秒
WS2812_Ctrl(0, 0, 0); // 关闭LED灯
delay_ticks(500); // 延时500毫秒
}
void BlinkRed(void)
{
r = 255; // 红色分量
g = 0; // 绿色分量
b = 0; // 蓝色分量
WS2812_Ctrl(r, g, b); // 设置为红色
delay_ticks(500); // 延时500毫秒
WS2812_Ctrl(0, 0, 0); // 关闭LED灯
delay_ticks(500); // 延时500毫秒
}
void BlinkGreen(void)
{
r = 0; // 红色分量
g = 255; // 绿色分量
b = 0; // 蓝色分量
WS2812_Ctrl(r, g, b); // 设置为绿色
delay_ticks(500); // 延时500毫秒
WS2812_Ctrl(0, 0, 0); // 关闭LED灯
delay_ticks(500); // 延时500毫秒
}
void BlinkBlue(void)
{
r = 0; // 红色分量
g = 0; // 绿色分量
b = 255; // 蓝色分量
WS2812_Ctrl(r, g, b); // 设置为蓝色
delay_ticks(500); // 延时500毫秒
WS2812_Ctrl(0, 0, 0); // 关闭LED灯
delay_ticks(500); // 延时500毫秒
}
void BlinkWhite(void)
{
r = 255; // 红色分量
g = 255; // 绿色分量
b = 255; // 蓝色分量
WS2812_Ctrl(r, g, b); // 设置为白色
delay_ticks(500); // 延时500毫秒
WS2812_Ctrl(0, 0, 0); // 关闭LED灯
delay_ticks(500); // 延时500毫秒
}
void BlinkCyan(void)
{
r = 0; // 红色分量
g = 255; // 绿色分量
b = 255; // 蓝色分量
WS2812_Ctrl(r, g, b); // 设置为青色
delay_ticks(500); // 延时500毫秒
WS2812_Ctrl(0, 0, 0); // 关闭LED灯
delay_ticks(500); // 延时500毫秒
}
void BlinkPurple(void)
{
r = 255; // 红色分量
g = 0; // 绿色分量
b = 255; // 蓝色分量
WS2812_Ctrl(r, g, b); // 设置为紫色
delay_ticks(500); // 延时500毫秒
WS2812_Ctrl(0, 0, 0); // 关闭LED灯
delay_ticks(500); // 延时500毫秒
}
void PWMControlLed(void)
{
//
// WS2812_Ctrl(r, g, b);
// r++;
// g += 5;
// b += 10;
// r=0;g=255;b=0;//绿色
// WS2812_Ctrl(r, g, b);
// delay_ticks(500); // 使用延时函数代替osDelay避免任务切换失败
// r=0;g=0;b=255;//蓝色
// WS2812_Ctrl(r, g, b);
// delay_ticks(500);
// r=0;g=255;b=255;//青色
// WS2812_Ctrl(r, g, b);
// delay_ticks(500);
// r=255;g=0;b=255;//紫色
// WS2812_Ctrl(r, g, b);
// delay_ticks(500);
// r=255;g=255;b=255;
// WS2812_Ctrl(r, g, b);
// delay_ticks(1000);
// osDelay(1);
// osDelay(100);
}

View File

@@ -0,0 +1,29 @@
#ifndef ws2812status_H
#define ws2812status_H
/*---------------------INCLUDES----------------------*/
#include "main.h"
#include "cmsis_os.h"
#include "tim.h"
#include "ws2812.h"
/*---------------------FUNCTIONS---------------------*/
void ws2812Task(void *argument);
void robotSelfCheck(void);
void BlinkYellow(void);
void BlinkRed(void);
void BlinkBlue(void);
void BlinkGreen(void);
void BlinkWhite(void);
void BlinkCyan(void);
void BlinkPurple(void);
#endif

View File

@@ -0,0 +1,97 @@
/**
* @file robot.c
* @brief
* @author TuxMonkey (nqx2004@gmail.com)
* @version 1.0
* @date 2025-07-08
*
* @copyright Copyright (c) 2025 DLMU-C.ONE
*
* @par 修改日志:
* <table>
* <tr><th>Date <th>Version <th>Author <th>Description
* <tr><td>2025-07-08 <td>1.0 <td>TuxMonkey <td>内容
* </table>
*/
#include "bsp_init.h"
#include "robot.h"
#include "rc.h"
#include "robot_def.h"
#include "cmsis_gcc.h"
// #include "robot_def.h"
// #include "robot_task.h"
// // 编译warning,提醒开发者修改机器人参数
// #ifndef ROBOT_DEF_PARAM_WARNING
// #define ROBOT_DEF_PARAM_WARNING
// #pragma message "check if you have configured the parameters in robot_def.h, IF NOT, please refer to the comments AND DO IT, otherwise the robot will have FATAL ERRORS!!!"
// #endif // !ROBOT_DEF_PARAM_WARNING
volatile RobotMode_t RobotMode = REMOTE_NOT_CONNECTED;
// #if defined(ONE_BOARD) || defined(CHASSIS_BOARD)
// #include "chassis.h"
// #endif
// #if defined(ONE_BOARD) || defined(GIMBAL_BOARD)
// #include "gimbal.h"
// #include "shoot.h"
// #include "robot_cmd.h"
// #endif
/**
* @brief 机器人初始化函数
*
* @note 该函数在系统启动时调用,用于初始化机器人各个模块
*
* @attention 请不要在初始化过程中使用中断和延时函数!
* 若必须,则只允许使用DWT_Delay()
*/
void RobotInit()
{
// 关闭中断,防止在初始化过程中发生中断
// 请不要在初始化过程中使用中断和延时函数!
// 若必须,则只允许使用DWT_Delay()
__disable_irq();
// HAL_GPIO_WritePin(Power1_GPIO_Port, Power1_Pin, GPIO_PIN_SET);//使能24V电源
// HAL_GPIO_WritePin(Power2_GPIO_Port, Power2_Pin, GPIO_PIN_SET);//使能24V电源
// HAL_GPIO_WritePin(Power_5V_EN_GPIO_Port, Power_5V_EN_Pin, GPIO_PIN_SET);//使能5V电源
BSPInit();
if (RemoteControlInit(&huart5) == NULL)
RobotMode = SYS_ERROR_OCCURRED;
#if defined(ONE_BOARD) || defined(GIMBAL_BOARD)
RobotCMDInit();
// GimbalInit();
// ShootInit();
#endif
#if defined(ONE_BOARD) || defined(CHASSIS_BOARD)
ChassisInit();
#endif
// OSTaskInit(); // 创建基础任务
// 初始化完成,开启中断
__enable_irq();
}
// void RobotTask()
// {
// #if defined(ONE_BOARD) || defined(GIMBAL_BOARD)
// RobotCMDTask();
// // GimbalTask();
// // ShootTask();
// #endif
// #if defined(ONE_BOARD) || defined(CHASSIS_BOARD)
// ChassisTask();
// #endif
// }

View File

@@ -0,0 +1,18 @@
#ifndef ROBOT_H
#define ROBOT_H
/* Robot利用robot_def.h中的宏对不同的机器人进行了大量的兼容,同时兼容了两个开发板(云台板和底盘板)的配置 */
/**
* @brief 机器人初始化,请在开启rtos之前调用.这也是唯一需要放入main函数的函数
*
*/
void RobotInit();
/**
* @brief 机器人任务,放入实时系统以一定频率运行,内部会调用各个应用的任务
*
*/
void RobotTask();
#endif

View File

@@ -0,0 +1,5 @@
//
// Created by esqwt on 2026/3/2.
//
#include "shoot.h"

View File

@@ -0,0 +1,8 @@
//
// Created by esqwt on 2026/3/2.
//
#ifndef TRONONEH7_SCAFFOLD_SHOOT_H
#define TRONONEH7_SCAFFOLD_SHOOT_H
#endif // TRONONEH7_SCAFFOLD_SHOOT_H

View File

@@ -0,0 +1,5 @@
//
// Created by esqwt on 2026/3/2.
//
#include "shoot_control.h"

View File

@@ -0,0 +1,8 @@
//
// Created by esqwt on 2026/3/2.
//
#ifndef TRONONEH7_SCAFFOLD_SHOOT_CONTROL_H
#define TRONONEH7_SCAFFOLD_SHOOT_CONTROL_H
#endif // TRONONEH7_SCAFFOLD_SHOOT_CONTROL_H

View File

@@ -0,0 +1,5 @@
//
// Created by esqwt on 2026/3/2.
//
#include "visionapp.h"

View File

@@ -0,0 +1,8 @@
//
// Created by esqwt on 2026/3/2.
//
#ifndef TRONONEH7_SCAFFOLD_VISIONAPP_H
#define TRONONEH7_SCAFFOLD_VISIONAPP_H
#endif // TRONONEH7_SCAFFOLD_VISIONAPP_H

View File

@@ -0,0 +1,48 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file : bsp_adc.c
* @brief : bsp adc functions
* @author : TuxMonkey
* @date : 2025/11/22
* @version : v1.0
******************************************************************************
* @attention : Pay attention to enable the adc
******************************************************************************
*/
/* USER CODE END Header */
/* Includes ------------------------------------------------------------------*/
#include "bsp_adc.h"
#include "adc.h"
/**
* @brief ADC sampling voltage array
*/
__attribute__((section (".AXI_SRAM"))) uint16_t ADC_Voltage_Val[2];
/**
* @brief Configures the ADC.
* @param None
* @retval None
*/
void BSP_ADC_Init(void)
{
HAL_ADCEx_Calibration_Start(&hadc1, ADC_CALIB_OFFSET, ADC_SINGLE_ENDED);
HAL_ADC_Start_DMA(&hadc1, (uint32_t *) ADC_Voltage_Val, 2);
}
//------------------------------------------------------------------------------
/**
* @brief USER get current voltage.
* @param None
* @retval Voltage
*/
float USER_ADC_Voltage_Update(void)
{
auto Voltage = (ADC_Voltage_Val[0] * 3.3f / 65535) * 11.0f;
return Voltage;
}
//------------------------------------------------------------------------------

View File

@@ -0,0 +1,34 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file : bsp_adc.h
* @brief : The header file of bsp_adc.h
* @author : TuxMonkey
* @date : 2025/11/22
* @version : v1.0
******************************************************************************
* @attention : Pay attention to config the clock source of the advanced TIM
******************************************************************************
*/
/* USER CODE END Header */
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef BSP_ADC_H
#define BSP_ADC_H
#ifdef __cplusplus
extern "C"
{
#endif
/* Includes ------------------------------------------------------------------*/
#include "adc.h"
/* Externs ---------------------------------------------*/
void BSP_ADC_Init(void);
float USER_ADC_Voltage_Update(void);
#endif //BSP_ADC_H

22
User_Code/bsp/bsp_init.h Normal file
View File

@@ -0,0 +1,22 @@
#ifndef BSP_INIT_h
#define BSP_INIT_h
#include "bsp_init.h"
// #include "bsp_log.h"
#include "bsp_dwt.h"
// #include "bsp_usb.h"
/**
* @brief bsp层初始化统一入口,这里仅初始化必须的bsp组件,其他组件的初始化在各自的模块中进行
* 需在实时系统启动前调用,目前由RobotoInit()调用
*
* @note 其他实例型的外设如CAN和串口会在注册实例的时候自动初始化,不注册不初始化
*/
void BSPInit()
{
DWT_Init(480); //Todo:修改这里以适配喵板cpufreq
// BSPLogInit();
}
#endif // !BSP_INIT_h

View File

@@ -0,0 +1,39 @@
#include "delayticks.h"
/*延时函数,不会将任务挂起*/
void delay_ticks(uint32_t delay)
{
/*开始计数器值*/
uint32_t tickstart = xTaskGetTickCount();
/*指定延时时间*/
uint32_t wait = delay;
/*计算当前计数器值和开始计数器值的差*/
uint32_t ticks_diff = xTaskGetTickCount() - tickstart;
if ( ticks_diff < wait )
{
/*计算剩余等待的时间*/
uint32_t remaining_ticks = wait - ticks_diff;
/*循环等待,直到剩余时间结束*/
while ( ( xTaskGetTickCount() - tickstart) < wait )
{
/*如果发生溢出,则重新计算时间差*/
if ( xTaskGetTickCount() < tickstart )
{
/*重新计算时间差*/
ticks_diff = UINT32_MAX - tickstart + xTaskGetTickCount();
if ( ticks_diff < wait )
{
remaining_ticks = wait - ticks_diff;
}
else
{
/*如果时间差已经大于等于等待时间,则退出*/
break;
}
}
}
}
}

View File

@@ -0,0 +1,10 @@
#ifndef DELAYTICKS_H
#define DELAYTICKS_H
#include "main.h"
#include "cmsis_os.h"
#include "tim.h"
extern void delay_ticks(uint32_t delay);
#endif

View File

@@ -0,0 +1,5 @@
//
// Created by tuxmonkey on 2025/10/28.
//
#include "bsp_dmaMalloc.h"

View File

@@ -0,0 +1,8 @@
//
// Created by tuxmonkey on 2025/10/28.
//
#ifndef TRONONEH7_SCAFFOLD_BSP_DMAMALLOC_H
#define TRONONEH7_SCAFFOLD_BSP_DMAMALLOC_H
#endif //TRONONEH7_SCAFFOLD_BSP_DMAMALLOC_H

139
User_Code/bsp/dwt/bsp_dwt.c Normal file
View File

@@ -0,0 +1,139 @@
/**
* @file bsp_dwt.c
* @brief DWT延时 软件延时库
* @author TuxMonkey (nqx2004@gmail.com)
* @version 1.0
* @date 2025-07-08
*
* @copyright Copyright (c) 2025 DLMU-C.ONE
*
* @par 修改日志:
* <table>
* <tr><th>Date <th>Version <th>Author <th>Description
* <tr><td>2025-07-08 <td>1.0 <td>TuxMonkey <td>内容
* </table>
*/
#include "bsp_dwt.h"
#include "cmsis_os.h"
static DWT_Time_t SysTime;
static uint32_t CPU_FREQ_Hz, CPU_FREQ_Hz_ms, CPU_FREQ_Hz_us;
static uint32_t CYCCNT_RountCount;
static uint32_t CYCCNT_LAST;
static uint64_t CYCCNT64;
/**
* @brief 私有函数,用于检查DWT CYCCNT寄存器是否溢出,并更新CYCCNT_RountCount
* @attention 此函数假设两次调用之间的时间间隔不超过一次溢出
*
* @todo 更好的方案是为dwt的时间更新单独设置一个任务?
* 不过,使用dwt的初衷是定时不被中断/任务等因素影响,因此该实现仍然有其存在的意义
*
*/
static void DWT_CNT_Update(void)
{
static volatile uint8_t bit_locker = 0;
if (!bit_locker)
{
bit_locker = 1;
volatile uint32_t cnt_now = DWT->CYCCNT;
if (cnt_now < CYCCNT_LAST)
CYCCNT_RountCount++;
CYCCNT_LAST = DWT->CYCCNT;
bit_locker = 0;
}
}
void DWT_Init(uint32_t CPU_Freq_mHz)
{
/* 使能DWT外设 */
CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk;
/* DWT CYCCNT寄存器计数清0 */
DWT->CYCCNT = (uint32_t) 0u;
/* 使能Cortex-M DWT CYCCNT寄存器 */
DWT->CTRL |= DWT_CTRL_CYCCNTENA_Msk;
CPU_FREQ_Hz = CPU_Freq_mHz * 1000000;
CPU_FREQ_Hz_ms = CPU_FREQ_Hz / 1000;
CPU_FREQ_Hz_us = CPU_FREQ_Hz / 1000000;
CYCCNT_RountCount = 0;
DWT_CNT_Update();
}
float DWT_GetDeltaT(uint32_t *cnt_last)
{
volatile uint32_t cnt_now = DWT->CYCCNT;
float dt = ((uint32_t) (cnt_now - *cnt_last)) / ((float) (CPU_FREQ_Hz));
*cnt_last = cnt_now;
DWT_CNT_Update();
return dt;
}
double DWT_GetDeltaT64(uint32_t *cnt_last)
{
volatile uint32_t cnt_now = DWT->CYCCNT;
double dt = ((uint32_t) (cnt_now - *cnt_last)) / ((double) (CPU_FREQ_Hz));
*cnt_last = cnt_now;
DWT_CNT_Update();
return dt;
}
void DWT_SysTimeUpdate(void)
{
volatile uint32_t cnt_now = DWT->CYCCNT;
static uint64_t CNT_TEMP1, CNT_TEMP2, CNT_TEMP3;
DWT_CNT_Update();
CYCCNT64 = (uint64_t) CYCCNT_RountCount * (uint64_t) UINT32_MAX + (uint64_t) cnt_now;
CNT_TEMP1 = CYCCNT64 / CPU_FREQ_Hz;
CNT_TEMP2 = CYCCNT64 - CNT_TEMP1 * CPU_FREQ_Hz;
SysTime.s = CNT_TEMP1;
SysTime.ms = CNT_TEMP2 / CPU_FREQ_Hz_ms;
CNT_TEMP3 = CNT_TEMP2 - SysTime.ms * CPU_FREQ_Hz_ms;
SysTime.us = CNT_TEMP3 / CPU_FREQ_Hz_us;
}
float DWT_GetTimeline_s(void)
{
DWT_SysTimeUpdate();
float DWT_Timelinef32 = SysTime.s + SysTime.ms * 0.001f + SysTime.us * 0.000001f;
return DWT_Timelinef32;
}
float DWT_GetTimeline_ms(void)
{
DWT_SysTimeUpdate();
float DWT_Timelinef32 = SysTime.s * 1000 + SysTime.ms + SysTime.us * 0.001f;
return DWT_Timelinef32;
}
uint64_t DWT_GetTimeline_us(void)
{
DWT_SysTimeUpdate();
uint64_t DWT_Timelinef32 = SysTime.s * 1000000 + SysTime.ms * 1000 + SysTime.us;
return DWT_Timelinef32;
}
void DWT_Delay(float Delay)
{
uint32_t tickstart = DWT->CYCCNT;
float wait = Delay;
while ((DWT->CYCCNT - tickstart) < wait * (float) CPU_FREQ_Hz);
}

104
User_Code/bsp/dwt/bsp_dwt.h Normal file
View File

@@ -0,0 +1,104 @@
/**
* @file bsp_dwt.h
* @brief DWT延时 软件延时库头文件
* @author TuxMonkey (nqx2004@gmail.com)
* @version 1.0
* @date 2025-07-08
*
* @copyright Copyright (c) 2025 DLMU-C.ONE
*
* @par 修改日志:
* <table>
* <tr><th>Date <th>Version <th>Author <th>Description
* <tr><td>2025-07-08 <td>1.0 <td>TuxMonkey <td>内容
* </table>
*/
#ifndef _BSP_DWT_H
#define _BSP_DWT_H
#include "main.h"
#include "stdint.h"
#include "bsp_log.h"
typedef struct
{
uint32_t s;
uint16_t ms;
uint16_t us;
} DWT_Time_t;
/**
* @brief 该宏用于计算代码段执行时间,单位为秒/s,返回值为float类型
* 首先需要创建一个float类型的变量,用于存储时间间隔
* 计算得到的时间间隔同时还会通过RTT打印到日志终端,你也可以将你的dt变量添加到查看
*/
#define TIME_ELAPSE(dt, code) \
do \
{ \
float tstart = DWT_GetTimeline_s(); \
code; \
dt = DWT_GetTimeline_s() - tstart; \
LOGINFO("[DWT] " #dt " = %f s\r\n", dt); \
} while (0)
/**
* @brief 初始化DWT,传入参数为CPU频率,单位MHz
*
* @param CPU_Freq_mHz c板为168MHz,A板为180MHz
*/
void DWT_Init(uint32_t CPU_Freq_mHz);
/**
* @brief 获取两次调用之间的时间间隔,单位为秒/s
*
* @param cnt_last 上一次调用的时间戳
* @return float 时间间隔,单位为秒/s
*/
float DWT_GetDeltaT(uint32_t *cnt_last);
/**
* @brief 获取两次调用之间的时间间隔,单位为秒/s,高精度
*
* @param cnt_last 上一次调用的时间戳
* @return double 时间间隔,单位为秒/s
*/
double DWT_GetDeltaT64(uint32_t *cnt_last);
/**
* @brief 获取当前时间,单位为秒/s,即初始化后的时间
*
* @return float 时间轴
*/
float DWT_GetTimeline_s(void);
/**
* @brief 获取当前时间,单位为毫秒/ms,即初始化后的时间
*
* @return float
*/
float DWT_GetTimeline_ms(void);
/**
* @brief 获取当前时间,单位为微秒/us,即初始化后的时间
*
* @return uint64_t
*/
uint64_t DWT_GetTimeline_us(void);
/**
* @brief DWT延时函数,单位为秒/s
* @attention 该函数不受中断是否开启的影响,可以在临界区和关闭中断时使用
* @note 禁止在__disable_irq()和__enable_irq()之间使用HAL_Delay()函数,应使用本函数
*
* @param Delay 延时时间,单位为秒/s
*/
void DWT_Delay(float Delay);
/**
* @brief DWT更新时间轴函数,会被三个timeline函数调用
* @attention 如果长时间不调用timeline函数,则需要手动调用该函数更新时间轴,否则CYCCNT溢出后定时和时间轴不准确
*/
void DWT_SysTimeUpdate(void);
#endif /* BSP_DWT_H_ */

View File

@@ -0,0 +1,54 @@
# bsp_dwt
DWT是stm32内部的一个"隐藏资源",他的用途是给下载器提供准确的定时,从而为调试信息加上时间戳.并在固定的时间间隔将调试数据发送到你的xxlink上.
## 常用功能
### 计算两次进入同一个函数的时间间隔
```c
static uint32_t cnt;
float deltaT;
deltaT=DWT_GetDeltaT(&cnt);
```
### 计算执行某部分代码的耗时
```c
float start,end;
start=DWT_DetTimeline_ms();
// some proc to go...
for(uint8_t i=0;i<10;i++)
foo();
end = DWT_DetTimeline_ms()-start;
```
我们还提供了一个宏用于调试计时:
```c
#define TIME_ELAPSE(dt, code) \
do \
{ \
float tstart = DWT_GetTimeline_s(); \
code; \
dt = DWT_GetTimeline_s() - tstart; \
LOGINFO("[DWT] " #dt " = %f s\r\n", dt); \
} while (0)
```
传入一个float类型的变量,并将你要执行的代码写入第二个参数:
```c
static float my_func_dt;
TIME_ELAPSE(my_func_dt,
Function1(vara);
Function2(some, var);
Function3(your,param);
// something more
);
// my_func_dt can be used for other purpose then;
```

View File

@@ -0,0 +1,437 @@
#include "bsp_fdcan.h"
#include "main.h"
#include "memory.h"
#include "stdlib.h"
#include "bsp_dwt.h"
#include "bsp_log.h"
//说是fdcan实际上就是配置成了经典的CAN
/* can instance ptrs storage, used for recv callback */
// 在CAN产生接收中断会遍历数组,选出hcan和rxid与发生中断的实例相同的那个,调用其回调函数
// @todo: 后续为每个CAN总线单独添加一个can_instance指针数组,提高回调查找的性能
static FDCANInstance *fdcan_instance[CAN_MX_REGISTER_CNT] = {NULL};
static uint8_t idx; // 全局CAN实例索引,每次有新的模块注册会自增
/* ----------------two static function called by CANRegister()-------------------- */
/**
* @brief 添加过滤器以实现对特定id的报文的接收,会被CANRegister()调用
* 给CAN添加过滤器后,BxCAN会根据接收到的报文的id进行消息过滤,符合规则的id会被填入FIFO触发中断
* 对于FDCAN设置使用特定ID模式过滤。
*
* @note f407的bxCAN有28个过滤器,这里将其配置为前14个过滤器给CAN1使用,后14个被CAN2使用
* 初始化时,奇数id的模块会被分配到FIFO0,偶数id的模块会被分配到FIFO1
* 注册到CAN1的模块使用过滤器0-13,CAN2使用过滤器14-27
* FDCAN的消息RAM是所有FDCAN外设共用的。
* H723系列FDCAN过滤器数量完全在CubeMX中自定义因此先做一次检查再添加即可。
*
* @attention 你不需要完全理解这个函数的作用,因为它主要是用于初始化,在开发过程中不需要关心底层的实现
* 享受开发的乐趣吧!如果你真的想知道这个函数在干什么,请联系作者或自己查阅资料(请直接查阅官方的reference manual)
* FDCAN的教程较少但是添加FDCAN的人已经发了一篇CSDN讲解了可以参考一下
*
* @param _instance can instance owned by specific module
*/
static void CANAddFilter(FDCANInstance *_instance)
{
#ifdef FDCAN
static uint8_t can1_filter_idx = 0, can2_filter_idx = 0, can3_filter_idx = 0;
//检查是否超出过滤器设定数量上限
if (can1_filter_idx > hfdcan1.Init.StdFiltersNbr || can2_filter_idx > hfdcan2.Init.StdFiltersNbr || can3_filter_idx
> hfdcan3.Init.StdFiltersNbr)
{
while (1)
{
//报错
}
}
uint8_t *filter_idx_p;
if (_instance->can_handle == &hfdcan1)
{
filter_idx_p = &can1_filter_idx;
}
else if (_instance->can_handle == &hfdcan2)
{
filter_idx_p = &can2_filter_idx;
}
else if (_instance->can_handle == &hfdcan3)
{
filter_idx_p = &can3_filter_idx;
}
else
{
while (1)
{
//报错
}
}
FDCAN_FilterTypeDef fdcan_filter_conf;
fdcan_filter_conf.FilterIndex = (*filter_idx_p)++;
//使用单个ID模式
fdcan_filter_conf.FilterType = FDCAN_FILTER_DUAL;
fdcan_filter_conf.FilterConfig = (_instance->tx_id & 1) ? FDCAN_FILTER_TO_RXFIFO0 : FDCAN_FILTER_TO_RXFIFO1;
//奇数id的模块会被分配到FIFO0,偶数id的模块会被分配到FIFO1
fdcan_filter_conf.FilterID1 = _instance->rx_id;
fdcan_filter_conf.FilterID2 = _instance->rx_id;
fdcan_filter_conf.IdType = FDCAN_STANDARD_ID;
fdcan_filter_conf.IsCalibrationMsg = 0;
//fdcan_filter_conf.RxBufferIndex=0;
// // ================== 【核心修复区】 ==================@todo有问题 我要验牌
// // 1. 强制让 FDCAN 进入 INIT 模式,否则无法写入 Message RAM
// HAL_FDCAN_Stop(_instance->can_handle);
//
// // 2. 写入过滤器配置
// HAL_FDCAN_ConfigFilter(_instance->can_handle, &fdcan_filter_conf);
//
// // 3. 重新启动 FDCAN
// HAL_FDCAN_Start(_instance->can_handle);
//
// // 4. 【救命稻草】HAL_FDCAN_Stop 关闭了所有中断,必须在这里重新激活!
// uint32_t FDCAN_RXActiveITs = FDCAN_IT_RX_FIFO0_NEW_MESSAGE | FDCAN_IT_RX_FIFO0_FULL |
// FDCAN_IT_RX_FIFO0_WATERMARK | FDCAN_IT_RX_FIFO0_MESSAGE_LOST |
// FDCAN_IT_RX_FIFO1_NEW_MESSAGE | FDCAN_IT_RX_FIFO1_FULL |
// FDCAN_IT_RX_FIFO1_WATERMARK | FDCAN_IT_RX_FIFO1_MESSAGE_LOST;
// HAL_FDCAN_ActivateNotification(_instance->can_handle, FDCAN_RXActiveITs, 0);
// // ====================================================
HAL_FDCAN_ConfigFilter(_instance->can_handle, &fdcan_filter_conf);
#else
CAN_FilterTypeDef can_filter_conf;
static uint8_t can1_filter_idx = 0, can2_filter_idx = 14; // 0-13给can1用,14-27给can2用
can_filter_conf.FilterMode = CAN_FILTERMODE_IDLIST; // 使用id list模式,即只有将rxid添加到过滤器中才会接收到,其他报文会被过滤
can_filter_conf.FilterScale = CAN_FILTERSCALE_16BIT; // 使用16位id模式,即只有低16位有效
can_filter_conf.FilterFIFOAssignment = (_instance->tx_id & 1) ? CAN_RX_FIFO0 : CAN_RX_FIFO1;
// 奇数id的模块会被分配到FIFO0,偶数id的模块会被分配到FIFO1
can_filter_conf.SlaveStartFilterBank = 14; // 从第14个过滤器开始配置从机过滤器(在STM32的BxCAN控制器中CAN2是CAN1的从机)
can_filter_conf.FilterIdLow = _instance->rx_id << 5; // 过滤器寄存器的低16位,因为使用STDID,所以只有低11位有效,高5位要填0
can_filter_conf.FilterBank = _instance->can_handle == &hcan1 ? (can1_filter_idx++) : (can2_filter_idx++);
// 根据can_handle判断是CAN1还是CAN2,然后自增
can_filter_conf.FilterActivation = CAN_FILTER_ENABLE; // 启用过滤器
HAL_CAN_ConfigFilter(_instance->can_handle, &can_filter_conf);
#endif
}
/**
* @brief 在第一个CAN实例初始化的时候会自动调用此函数,启动CAN服务
*
* @note 此函数会启动CAN1并开启中断
* FDCAN的情况下我们采用FIFO接收方式而不是bufferFIFO和buffer还有queue接收方式请自行查阅H723手册
* FDCAN比bxCAN多了一个全局过滤器这里配置为全部拒绝只接受指定ID。
*
*/
void CANServiceInit()
{
#ifdef FDCAN
//可能不需要这么多中断
uint32_t FDCAN_RXActiveITs = FDCAN_IT_RX_FIFO0_NEW_MESSAGE | FDCAN_IT_RX_FIFO0_FULL\
| FDCAN_IT_RX_FIFO0_WATERMARK | FDCAN_IT_RX_FIFO0_MESSAGE_LOST
| FDCAN_IT_RX_FIFO1_NEW_MESSAGE | FDCAN_IT_RX_FIFO1_FULL\
| FDCAN_IT_RX_FIFO1_WATERMARK | FDCAN_IT_RX_FIFO1_MESSAGE_LOST;
//HAL_FDCAN_ConfigClockCalibration()
HAL_FDCAN_ConfigRxFifoOverwrite(&hfdcan1,FDCAN_RX_FIFO0,FDCAN_RX_FIFO_OVERWRITE);
HAL_FDCAN_ConfigRxFifoOverwrite(&hfdcan1,FDCAN_RX_FIFO1,FDCAN_RX_FIFO_OVERWRITE);
HAL_FDCAN_ConfigGlobalFilter(&hfdcan1, FDCAN_REJECT, FDCAN_REJECT, FDCAN_REJECT_REMOTE, FDCAN_REJECT_REMOTE);
//全局过滤器设置
HAL_FDCAN_Start(&hfdcan1);
HAL_FDCAN_ActivateNotification(&hfdcan1, FDCAN_RXActiveITs, 0);
HAL_FDCAN_ConfigRxFifoOverwrite(&hfdcan2,FDCAN_RX_FIFO0,FDCAN_RX_FIFO_OVERWRITE);
HAL_FDCAN_ConfigRxFifoOverwrite(&hfdcan2,FDCAN_RX_FIFO1,FDCAN_RX_FIFO_OVERWRITE);
HAL_FDCAN_ConfigGlobalFilter(&hfdcan2, FDCAN_REJECT, FDCAN_REJECT, FDCAN_REJECT_REMOTE, FDCAN_REJECT_REMOTE);
HAL_FDCAN_Start(&hfdcan2);
HAL_FDCAN_ActivateNotification(&hfdcan2, FDCAN_RXActiveITs, 0);
HAL_FDCAN_ConfigRxFifoOverwrite(&hfdcan3,FDCAN_RX_FIFO0,FDCAN_RX_FIFO_OVERWRITE);
HAL_FDCAN_ConfigRxFifoOverwrite(&hfdcan3,FDCAN_RX_FIFO1,FDCAN_RX_FIFO_OVERWRITE);
HAL_FDCAN_ConfigGlobalFilter(&hfdcan3, FDCAN_REJECT, FDCAN_REJECT, FDCAN_REJECT_REMOTE, FDCAN_REJECT_REMOTE);
HAL_FDCAN_Start(&hfdcan3);
HAL_FDCAN_ActivateNotification(&hfdcan3, FDCAN_RXActiveITs, 0);
#else
HAL_CAN_Start(&hcan1);
HAL_CAN_ActivateNotification(&hcan1, CAN_IT_RX_FIFO0_MSG_PENDING);
HAL_CAN_ActivateNotification(&hcan1, CAN_IT_RX_FIFO1_MSG_PENDING);
HAL_CAN_Start(&hcan2);
HAL_CAN_ActivateNotification(&hcan2, CAN_IT_RX_FIFO0_MSG_PENDING);
HAL_CAN_ActivateNotification(&hcan2, CAN_IT_RX_FIFO1_MSG_PENDING);
#endif
}
/* ----------------------- two extern callable function -----------------------*/
FDCANInstance *CANRegister(FDCAN_Init_Config_s *config)
{
if (!idx)
{
CANServiceInit(); // 第一次注册,先进行硬件初始化
LOGINFO("[bsp_can] CAN Service Init");
}
if (idx >= CAN_MX_REGISTER_CNT) // 超过最大实例数
{
while (1)
{
LOGERROR("[bsp_can] CAN instance exceeded MAX num, consider balance the load of CAN bus");
}
}
for (size_t i = 0; i < idx; i++)
{
// 重复注册 | id重复
if (fdcan_instance[i]->rx_id == config->rx_id && fdcan_instance[i]->can_handle == config->can_handle)
{
while (1)
{
LOGERROR("[}bsp_can] CAN id crash ,tx [%d] or rx [%d] already registered", &config->tx_id,
&config->rx_id);
}
}
}
FDCANInstance *instance = (FDCANInstance *) malloc(sizeof(FDCANInstance)); // 分配空间
memset(instance, 0, sizeof(FDCANInstance)); // 分配的空间未必是0,所以要先清空
// 进行发送报文的配置
#ifdef FDCAN
instance->txconf.Identifier = config->tx_id; // 发送id
instance->txconf.IdType = FDCAN_STANDARD_ID; // 使用标准id,扩展id则使用CAN_ID_EXT(目前没有需求)
instance->txconf.TxFrameType = FDCAN_DATA_FRAME, // 发送数据帧
instance->txconf.DataLength = FDCAN_DLC_BYTES_8, // 数据长度为8字节
instance->txconf.ErrorStateIndicator = FDCAN_ESI_ACTIVE, // 兼容CAN2.0,错误状态指示器设为主动
instance->txconf.BitRateSwitch = FDCAN_BRS_OFF, // 兼容CAN2.0禁用位速率切换
instance->txconf.FDFormat = FDCAN_CLASSIC_CAN, // 使用经典CAN格式
instance->txconf.TxEventFifoControl = FDCAN_NO_TX_EVENTS, // 不需要禁用事件FIFO
instance->txconf.MessageMarker = 0; // 不使用消息标记
#else
instance->txconf.StdId = config->tx_id; // 发送id
instance->txconf.IDE = CAN_ID_STD; // 使用标准id,扩展id则使用CAN_ID_EXT(目前没有需求)
instance->txconf.RTR = CAN_RTR_DATA; // 发送数据帧
instance->txconf.DLC = 0x08; // 默认发送长度为8
#endif
// 设置回调函数和接收发送id
instance->can_handle = config->can_handle;
instance->tx_id = config->tx_id; // 好像没用,可以删掉
instance->rx_id = config->rx_id;
instance->can_module_callback = config->can_module_callback;
instance->id = config->id;
CANAddFilter(instance); // 添加CAN过滤器规则
fdcan_instance[idx++] = instance; // 将实例保存到can_instance中
return instance; // 返回can实例指针
}
/* @todo 目前似乎封装过度,应该添加一个指向tx_buff的指针,tx_buff不应该由CAN instance保存 */
/* 如果让CANinstance保存txbuff,会增加一次复制的开销 */
uint8_t CANTransmit(FDCANInstance *_instance, float timeout)
{
static uint32_t busy_count;
static volatile float wait_time __attribute__((unused)); // for cancel warning
float dwt_start = DWT_GetTimeline_ms();
#ifdef FDCAN
while (HAL_FDCAN_GetTxFifoFreeLevel(_instance->can_handle) == 0)
#else
while (HAL_CAN_GetTxMailboxesFreeLevel(_instance->can_handle) == 0) // 等待邮箱空闲
#endif
{
if (DWT_GetTimeline_ms() - dwt_start > timeout) // 超时
{
LOGWARNING("[bsp_can] CAN MAILbox full! failed to add msg to mailbox. Cnt [%d]", busy_count);
busy_count++;
return 0;
}
}
wait_time = DWT_GetTimeline_ms() - dwt_start;
#ifdef FDCAN
if (HAL_FDCAN_AddMessageToTxFifoQ(_instance->can_handle, &_instance->txconf, _instance->tx_buff))
#else
// tx_mailbox会保存实际填入了这一帧消息的邮箱,但是知道是哪个邮箱发的似乎也没啥用
if (HAL_CAN_AddTxMessage(_instance->can_handle, &_instance->txconf, _instance->tx_buff, &_instance->tx_mailbox))
#endif
{
LOGWARNING("[bsp_can] CAN bus BUSY! cnt:%d", busy_count);
busy_count++;
return 0;
}
return 1; // 发送成功
}
void CANSetDLC(FDCANInstance *_instance, uint8_t length)
{
// 发送长度错误!检查调用参数是否出错,或出现野指针/越界访问
if (length > 8 || length == 0) // 安全检查
while (1)
{
LOGERROR("[bsp_can] CAN DLC error! check your code or wild pointer");
}
_instance->txconf.DataLength = DLC_LookUp_Table[length];
}
/* -----------------------belows are callback definitions--------------------------*/
//对于FDCAN回调函数和处理方式完全不同因此直接用两套逻辑处理
#ifdef FDCAN
/**
* @brief 此函数会被下面两个函数调用,用于处理FIFO0和FIFO1溢出中断(说明收到了新的数据)
* 所有的实例都会被遍历,找到can_handle和rx_id相等的实例时,调用该实例的回调函数
*
* @param _hfdcan
* @param fifox passed to HAL_CAN_GetRxMessage() to get mesg from a specific fifo
*/
static void FDCANFIFOxCallback(FDCAN_HandleTypeDef *_hfdcan, uint32_t fifox)
{
static FDCAN_RxHeaderTypeDef rxconf;
static uint16_t DataLength = 0;
static uint8_t fdcan_rx_buff[8];
while (HAL_FDCAN_GetRxFifoFillLevel(_hfdcan, fifox))
{
HAL_FDCAN_GetRxMessage(_hfdcan, fifox, &rxconf, fdcan_rx_buff);
//@todo:DataLength解析
switch (rxconf.DataLength)
{
case FDCAN_DLC_BYTES_0: DataLength = 0;
break;
case FDCAN_DLC_BYTES_1: DataLength = 1;
break;
case FDCAN_DLC_BYTES_2: DataLength = 2;
break;
case FDCAN_DLC_BYTES_3: DataLength = 3;
break;
case FDCAN_DLC_BYTES_4: DataLength = 4;
break;
case FDCAN_DLC_BYTES_5: DataLength = 5;
break;
case FDCAN_DLC_BYTES_6: DataLength = 6;
break;
case FDCAN_DLC_BYTES_7: DataLength = 7;
break;
case FDCAN_DLC_BYTES_8: DataLength = 8;
break;
// 如果后续用到了 FDCAN 真正的长帧(12~64字节),可以在这里继续加 case
default: DataLength = 8;
break; // 兜底保护
}
if (rxconf.RxFrameType == FDCAN_DATA_FRAME && rxconf.IdType == FDCAN_STANDARD_ID)
{
for (size_t i = 0; i < idx; ++i)
{
if (_hfdcan == fdcan_instance[i]->can_handle && rxconf.Identifier == fdcan_instance[i]->rx_id)
{
if (fdcan_instance[i]->can_module_callback != NULL)
{
fdcan_instance[i]->rx_len = DataLength;
memcpy(fdcan_instance[i]->rx_buff, fdcan_rx_buff, fdcan_instance[i]->rx_len);
fdcan_instance[i]->can_module_callback(fdcan_instance[i]);
}
break;
}
}
}
}
}
void HAL_FDCAN_RxFifo0Callback(FDCAN_HandleTypeDef *hfdcan, uint32_t RxFifo0ITs)
{
/* 检查Rx FIFO 0中是否有消息丢失 */
if ((RxFifo0ITs & FDCAN_IT_RX_FIFO0_MESSAGE_LOST) != 0)
{
//报错
}
/* 检查是否有新消息写入Rx FIFO 0或到达一定阈值 */
if ((RxFifo0ITs & FDCAN_IT_RX_FIFO0_NEW_MESSAGE) || (RxFifo0ITs & FDCAN_IT_RX_FIFO0_FULL) || (
RxFifo0ITs & FDCAN_IT_RX_FIFO0_WATERMARK))
{
FDCANFIFOxCallback(hfdcan, FDCAN_RX_FIFO0); // 调用我们自己写的函数来处理消息
}
}
void HAL_FDCAN_RxFifo1Callback(FDCAN_HandleTypeDef *hfdcan, uint32_t RxFifo1ITs)
{
/* 检查Rx FIFO 1中是否有消息丢失 */
if ((RxFifo1ITs & FDCAN_IT_RX_FIFO1_MESSAGE_LOST) != 0)
{
//报错
}
/* 检查是否有新消息写入Rx FIFO 1或到达一定阈值 */
if ((RxFifo1ITs & FDCAN_IT_RX_FIFO1_NEW_MESSAGE) || (RxFifo1ITs & FDCAN_IT_RX_FIFO1_FULL) || (
RxFifo1ITs & FDCAN_IT_RX_FIFO1_WATERMARK))
{
FDCANFIFOxCallback(hfdcan, FDCAN_RX_FIFO1); // 调用我们自己写的函数来处理消息
}
}
#else
/**
* @brief 此函数会被下面两个函数调用,用于处理FIFO0和FIFO1溢出中断(说明收到了新的数据)
* 所有的实例都会被遍历,找到can_handle和rx_id相等的实例时,调用该实例的回调函数
*
* @param _hcan
* @param fifox passed to HAL_CAN_GetRxMessage() to get mesg from a specific fifo
*/
static void CANFIFOxCallback(CAN_HandleTypeDef *_hcan, uint32_t fifox)
{
static CAN_RxHeaderTypeDef rxconf; // 同上
uint8_t can_rx_buff[8];
while (HAL_CAN_GetRxFifoFillLevel(_hcan, fifox)) // FIFO不为空,有可能在其他中断时有多帧数据进入
{
HAL_CAN_GetRxMessage(_hcan, fifox, &rxconf, can_rx_buff); // 从FIFO中获取数据
for (size_t i = 0; i < idx; ++i)
{
// 两者相等说明这是要找的实例
if (_hcan == fdcan_instance[i]->can_handle && rxconf.StdId == fdcan_instance[i]->rx_id)
{
if (fdcan_instance[i]->can_module_callback != NULL) // 回调函数不为空就调用
{
fdcan_instance[i]->rx_len = rxconf.DLC; // 保存接收到的数据长度
memcpy(fdcan_instance[i]->rx_buff, can_rx_buff, rxconf.DLC); // 消息拷贝到对应实例
fdcan_instance[i]->can_module_callback(fdcan_instance[i]); // 触发回调进行数据解析和处理
}
return;
}
}
}
}
/**
* @brief 注意,STM32的两个CAN设备共享两个FIFO
* 下面两个函数是HAL库中的回调函数,他们被HAL声明为__weak,这里对他们进行重载(重写)
* 当FIFO0或FIFO1溢出时会调用这两个函数
*/
// 下面的函数会调用CANFIFOxCallback()来进一步处理来自特定CAN设备的消息
/**
* @brief rx fifo callback. Once FIFO_0 is full,this func would be called
*
* @param hcan CAN handle indicate which device the oddest mesg in FIFO_0 comes from
*/
void HAL_CAN_RxFifo0MsgPendingCallback(CAN_HandleTypeDef *hcan)
{
CANFIFOxCallback(hcan, CAN_RX_FIFO0); // 调用我们自己写的函数来处理消息
}
/**
* @brief rx fifo callback. Once FIFO_1 is full,this func would be called
*
* @param hcan CAN handle indicate which device the oddest mesg in FIFO_1 comes from
*/
void HAL_CAN_RxFifo1MsgPendingCallback(CAN_HandleTypeDef *hcan)
{
CANFIFOxCallback(hcan, CAN_RX_FIFO1); // 调用我们自己写的函数来处理消息
}
#endif

View File

@@ -0,0 +1,114 @@
#ifndef BSP_FDCAN_H
#define BSP_FDCAN_H
//在此选择CAN类型两者只能选择一个
#define FDCAN //G系列和H7系列使用FDCAN
//#define BXCAN //F系列使用BxCAN
//CAN类型宏定义检查有错误停止编译
#if !defined(FDCAN) && !defined(BXCAN)
#error "Neither FDCAN nor BXCAN is defined. Please define one of them."
#elif defined(FDCAN) && defined(BXCAN)
#error "Both FDCAN and BXCAN are defined. Please define only one."
#endif
#include <stdint.h>
#ifdef FDCAN
#include "fdcan.h"
#define hcan1 hfdcan1
#define hcan2 hfdcan2
#define hcan3 hfdcan3
#define CAN_MX_REGISTER_CNT 16 // 这个数量取决于CAN总线的负载
#define MX_CAN_FILTER_CNT (3 * 14) // 最多可以使用的CAN过滤器数量,目前远不会用到这么多
#define DEVICE_CAN_CNT 3 //H723VG有3个FDCAN
#endif
#ifdef BXCAN
#include "can.h"
// 最多能够支持的CAN设备数
#define CAN_MX_REGISTER_CNT 16 // 这个数量取决于CAN总线的负载
#define MX_CAN_FILTER_CNT (2 * 14) // 最多可以使用的CAN过滤器数量,目前远不会用到这么多
#define DEVICE_CAN_CNT 2 // 根据板子设定,F407IG有CAN1,CAN2,因此为2;F334只有一个,则设为1
// 如果只有1个CAN,还需要把bsp_can.c中所有的hcan2变量改为hcan1(别担心,主要是总线和FIFO的负载均衡,不影响功能)
#endif
// 定义查找表
static const uint32_t DLC_LookUp_Table[9] = {
FDCAN_DLC_BYTES_0,
FDCAN_DLC_BYTES_1,
FDCAN_DLC_BYTES_2,
FDCAN_DLC_BYTES_3,
FDCAN_DLC_BYTES_4,
FDCAN_DLC_BYTES_5,
FDCAN_DLC_BYTES_6,
FDCAN_DLC_BYTES_7,
FDCAN_DLC_BYTES_8
};
/* can instance typedef, every module registered to CAN should have this variable */
#pragma pack(1)
typedef struct _
{
#ifdef FDCAN
FDCAN_HandleTypeDef *can_handle; // can句柄
FDCAN_TxHeaderTypeDef txconf; // CAN报文发送配置
#else
CAN_HandleTypeDef *can_handle; // can句柄
CAN_TxHeaderTypeDef txconf; // CAN报文发送配置
#endif
uint32_t tx_id; // 发送id
uint32_t tx_mailbox; // CAN消息填入的邮箱号
uint8_t tx_buff[8]; // 发送缓存,发送消息长度可以通过CANSetDLC()设定,最大为8
uint8_t rx_buff[8]; // 接收缓存,最大消息长度为8
uint32_t rx_id; // 接收id
uint8_t rx_len; // 接收长度,可能为0-8
// 接收的回调函数,用于解析接收到的数据
void (*can_module_callback)(struct _ *); // callback needs an instance to tell among registered ones
void *id; // 使用can外设的模块指针(即id指向的模块拥有此can实例,是父子关系)
} FDCANInstance;
#pragma pack()
/* CAN实例初始化结构体,将此结构体指针传入注册函数 */
typedef struct
{
#ifdef FDCAN
FDCAN_HandleTypeDef *can_handle; // can句柄
#else
CAN_HandleTypeDef *can_handle; // can句柄
#endif
uint32_t tx_id; // 发送id
uint32_t rx_id; // 接收id
void (*can_module_callback)(FDCANInstance *); // 处理接收数据的回调函数
void *id; // 拥有can实例的模块地址,用于区分不同的模块(如果有需要的话),如果不需要可以不传入
} FDCAN_Init_Config_s;
/**
* @brief Register a module to CAN service,remember to call this before using a CAN device
* 注册(初始化)一个can实例,需要传入初始化配置的指针.
* @param config init config
* @return CANInstance* can instance owned by module
*/
FDCANInstance *CANRegister(FDCAN_Init_Config_s *config);
/**
* @brief 修改CAN发送报文的数据帧长度;注意最大长度为8,在没有进行修改的时候,默认长度为8
*
* @param _instance 要修改长度的can实例
* @param length 设定长度
*/
void CANSetDLC(FDCANInstance *_instance, uint8_t length);
/**
* @brief transmit mesg through CAN device,通过can实例发送消息
* 发送前需要向CAN实例的tx_buff写入发送数据
*
* @attention 超时时间不应该超过调用此函数的任务的周期,否则会导致任务阻塞
*
* @param timeout 超时时间,单位为ms;后续改为us,获得更精确的控制
* @param _instance* can instance owned by module
*/
uint8_t CANTransmit(FDCANInstance *_instance,float timeout);
#endif

View File

@@ -0,0 +1,168 @@
# bsp_fdcan.c/bsp_fdcan.h
> 请注意使用FDCAN设备的时候务必保证总线只接入了2个终端电阻开发板一般都有一个6020电机、c620/c610电调、LK电机也都有终端电阻注意把多于2个的全部断开通过拨码
## 使用说明
若你希望新增一个基于FDCAN的module首先在该模块下应该有一个包含`FDCANInstance`指针的module结构体或当功能简单的时候可以是单独存在的
`FDCANInstance`,但不推荐这样做)。
## 代码结构
.h文件内包括了外部接口和类型定义,以及模块对应的宏。c文件内为私有函数和外部接口的定义。
## 类型定义
```c
#define CAN_MX_REGISTER_CNT 16 // 最大FDCAN设备注册数量
#define MX_CAN_FILTER_CNT (3 * 14) // 最多可以使用的CAN过滤器数量支持3个CAN
#define DEVICE_CAN_CNT 3 // FDCAN1, FDCAN2, FDCAN3
#define CAN_CLASS 0 // 经典CAN模式
#define CAN_FD_BRS 1 // CAN FD模式
#define CAN_BR_125K 0 // 125Kbps
#define CAN_BR_200K 1 // 200Kbps
#define CAN_BR_250K 2 // 250Kbps
#define CAN_BR_500K 3 // 500Kbps
#define CAN_BR_1M 4 // 1Mbps
#define CAN_BR_2M 5 // 2Mbps
#define CAN_BR_2M5 6 // 2.5Mbps
#define CAN_BR_3M2 7 // 3.2Mbps
#define CAN_BR_4M 8 // 4Mbps
#define CAN_BR_5M 9 // 5Mbps
/* FDCAN实例结构体每个注册到FDCAN的模块都应该有这个变量 */
typedef struct _FDCANInstance
{
FDCAN_HandleTypeDef *can_handle; // FDCAN句柄
FDCAN_TxHeaderTypeDef txconf; // FDCAN报文发送配置
uint32_t tx_id; // 发送id
uint32_t tx_mailbox; // FDCAN消息填入的邮箱号
uint8_t tx_buff[64]; // 发送缓存FDCAN最大支持64字节
uint8_t rx_buff[64]; // 接收缓存FDCAN最大支持64字节
uint32_t rx_id; // 接收id
uint8_t rx_len; // 接收长度
// 接收的回调函数,用于解析接收到的数据
void (*can_module_callback)(struct _FDCANInstance *); // 回调函数需要实例来区分注册的设备
void *id; // 使用FDCAN外设的模块指针
} FDCANInstance;
/* FDCAN实例初始化结构体 */
typedef struct
{
FDCAN_HandleTypeDef *can_handle; // FDCAN句柄
uint32_t tx_id; // 发送id
uint32_t rx_id; // 接收id
void (*can_module_callback)(FDCANInstance *); // 处理接收数据的回调函数
void *id; // 拥有FDCAN实例的模块地址
} FDCAN_Init_Config_s;
typedef void (*fdcan_callback)(FDCANInstance *);
```
- `CAN_MX_REGISTER_CNT`是最大的FDCAN设备注册数量当每个设备的发送频率都较高时设备过多会产生总线拥塞从而出现丢包和数据错误的情况。
- `MX_CAN_FILTER_CNT`是最大的FDCAN接收过滤器数量三个FDCAN共享多个过滤器。当前为简单起见每个过滤器只设置一组规则用于控制一个id的过滤。
- `DEVICE_CAN_CNT`是MCU拥有的FDCAN硬件数量H7有3个
- `FDCANInstance`
是一个FDCAN实例。注意FDCAN作为一个总线设备一条总线上可以挂载多个设备因此多个设备可以共享同一个FDCAN硬件。其成员变量包括发送id发送邮箱发送buff以及接收buff还有接收id和接收协议解析回调函数。
**FDCAN支持最大64字节的数据帧**因此收发buff长度设置为64字节。
- `FDCAN_Init_Config_s`是用于初始化FDCAN实例的结构在调用FDCAN实例的初始化函数时传入。
- `can_module_callback()`是模块提供给FDCAN接收中断回调函数使用的协议解析函数指针。对于每个需要FDCAN的模块需要定义一个这样的函数用于解包数据。
- 每个使用FDCAN外设的module都需要在其内部定义一个`FDCANInstance*`
## 外部接口
```c
FDCANInstance *FDCANRegister(FDCAN_Init_Config_s *config);
void FDCANSetDLC(FDCANInstance *_instance, uint8_t length);
uint8_t FDCANTransmit(FDCANInstance *_instance, float timeout);
void bsp_fdcan_set_baud(FDCAN_HandleTypeDef *hfdcan, uint8_t mode, uint8_t baud);
```
`FDCANRegister`是用于初始化FDCAN实例的接口module层的模块对象也应当为一个结构体内要包含一个`FDCANInstance`
。调用时传入初始化配置的指针。`FDCANRegister`应当在module的初始化函数内被调用推荐config采用以下的方式定义更加直观明了
```c
FDCAN_Init_Config_s config = {
.can_handle = &hfdcan1,
.tx_id = 0x005,
.rx_id = 0x200,
.can_module_callback = MotorCallback,
.id = (void*)motor_ptr
};
```
`FDCANTransmit()`是通过模块通过其拥有的FDCAN实例发送数据的接口调用时传入对应的instance。在发送之前应当给instance内的
`tx_buff`赋值。
`bsp_fdcan_set_baud()`用于设置FDCAN的波特率和模式经典CAN或CAN FD
## 私有函数和变量
在.c文件内设为static的函数和变量
```c
static FDCANInstance *fdcan_instance[CAN_MX_REGISTER_CNT] = {NULL};
```
这是bsp层管理所有FDCAN实例的入口。
```c
static void FDCANServiceInit()
static void FDCANAddFilter(FDCANInstance *_instance)
static void FDCANFIFOxCallback(FDCAN_HandleTypeDef *_hcan, uint32_t fifox)
static uint8_t FDCANDlcToLen(uint32_t dlc)
static uint32_t FDCANLenToDlc(uint8_t len)
void HAL_FDCAN_RxFifo0Callback(FDCAN_HandleTypeDef *hfdcan, uint32_t RxFifo0ITs)
void HAL_FDCAN_RxFifo1Callback(FDCAN_HandleTypeDef *hfdcan, uint32_t RxFifo1ITs)
void HAL_FDCAN_ErrorStatusCallback(FDCAN_HandleTypeDef *hfdcan, uint32_t ErrorStatusITs)
```
- `FDCANServiceInit()`会被`FDCANRegister()`调用对FDCAN外设进行硬件初始化并开启接收中断和消息提醒。
- `FDCANAddFilter()`在每次使用`FDCANRegister()`的时候被调用,用于给当前注册的实例添加过滤器规则并设定处理对应`rx_id`
的接收FIFO。过滤器的作用是减小FDCAN收发器的压力只接收符合过滤器规则的报文否则不会产生接收中断
- `FDCANDlcToLen()``FDCANLenToDlc()`是FDCAN特有的数据长度码转换函数用于在数据长度码和实际字节数之间转换。
- `HAL_FDCAN_RxFifo0Callback()``HAL_FDCAN_RxFifo1Callback()`都是对HAL的FDCAN回调函数的重定义原本的callback是`__weak`
修饰的弱定义当发生FIFO0或FIFO1有新消息到达的时候对应的callback会被调用。`FDCANFIFOxCallback()`
随后被前两者调用并根据接收id和硬件中断来源哪一个FDCAN硬件调用对应的instance的回调函数进行协议解析。
- `HAL_FDCAN_ErrorStatusCallback()`处理FDCAN的错误状态包括总线关闭和错误被动状态的恢复。
- 当有一个模块注册了多个FDCAN实例时通过`FDCANInstance.id`,使用强制类型转换将其转换成对应模块的实例指针,就可以对不同的模块实例进行回调处理了。
## 弱定义回调函数
```c
__weak void fdcan1_rx_callback(void);
__weak void fdcan2_rx_callback(void);
__weak void fdcan3_rx_callback(void);
```
这些是弱定义的FDCAN接收回调函数用户可以根据需要重写这些函数来实现特定的功能。
## 注意事项
1. **终端电阻**使用FDCAN设备时务必保证总线只接入了2个终端电阻
2. **FDCAN特性**
- FDCAN支持经典CAN和CAN FD模式
- CAN FD模式下支持最高64字节的数据帧
- 支持更高的通信速率最高5Mbps
3. **发送超时**由于FDCAN总线自带发送检测如果总线上没有挂载目标设备那么发送FIFO会被占满而无法发送。在`FDCANTransmit()`
中会对发送FIFO是否已满进行检查。当超出`timeout`之后函数会返回零,说明发送失败。
4. **任务阻塞**:由于卡在`while(1)`处不断检查FIFO是否空闲调用`FDCANTransmit()`
的任务可能无法按时挂起导致任务定时不精确。建议在没有连接FDCAN进行调试时按需注释掉有关FDCAN发送的代码部分或设定一个较小的
`timeout`值,防止对其他需要精确定时的任务产生影响。
5. **模式选择**:使用`bsp_fdcan_set_baud()`函数可以在经典CAN模式和CAN FD模式之间切换注意不同模式支持的波特率范围不同。
6. **数据长度**FDCAN支持最大64字节的数据帧使用`FDCANSetDLC()`函数设置数据长度时要注意不要超过64字节。

View File

@@ -0,0 +1,268 @@
#include "bsp_flash.h"
#include "main.h"
#include "string.h"
static uint32_t ger_sector(uint32_t address);
/**
* @brief erase flash
* @param[in] address: flash address
* @param[in] len: page num
* @retval none
*/
/**
* @brief 擦除flash
* @param[in] address: flash 地址
* @param[in] len: 页数量
* @retval none
*/
void flash_erase_address(uint32_t address, uint16_t len)
{
FLASH_EraseInitTypeDef flash_erase;
uint32_t error;
flash_erase.Sector = ger_sector(address);
flash_erase.TypeErase = FLASH_TYPEERASE_SECTORS;
flash_erase.VoltageRange = FLASH_VOLTAGE_RANGE_3;
flash_erase.NbSectors = len;
HAL_FLASH_Unlock();
HAL_FLASHEx_Erase(&flash_erase, &error);
HAL_FLASH_Lock();
}
/**
* @brief write data to one page of flash
* @param[in] start_address: flash address
* @param[in] buf: data point
* @param[in] len: data num
* @retval success 0, fail -1
*/
/**
* @brief 往一页flash写数据
* @param[in] start_address: flash 地址
* @param[in] buf: 数据指针
* @param[in] len: 数据长度
* @retval success 0, fail -1
*/
int8_t flash_write_single_address(uint32_t start_address, uint32_t *buf, uint32_t len)
{
static uint32_t uw_address;
static uint32_t end_address;
static uint32_t *data_buf;
static uint32_t data_len;
HAL_FLASH_Unlock();
uw_address = start_address;
end_address = get_next_flash_address(start_address);
data_buf = buf;
data_len = 0;
while (uw_address <= end_address)
{
if (HAL_FLASH_Program(FLASH_TYPEPROGRAM_FLASHWORD, uw_address, *data_buf) == HAL_OK)
{
uw_address += 4;
data_buf++;
data_len++;
if (data_len == len)
{
break;
}
}
else
{
HAL_FLASH_Lock();
return -1;
}
}
HAL_FLASH_Lock();
return 0;
}
/**
* @brief write data to some pages of flash
* @param[in] start_address: flash start address
* @param[in] end_address: flash end address
* @param[in] buf: data point
* @param[in] len: data num
* @retval success 0, fail -1
*/
/**
* @brief 往几页flash写数据
* @param[in] start_address: flash 开始地址
* @param[in] end_address: flash 结束地址
* @param[in] buf: 数据指针
* @param[in] len: 数据长度
* @retval success 0, fail -1
*/
int8_t flash_write_muli_address(uint32_t start_address, uint32_t end_address, uint32_t *buf, uint32_t len)
{
uint32_t uw_address = 0;
uint32_t *data_buf;
uint32_t data_len;
HAL_FLASH_Unlock();
uw_address = start_address;
data_buf = buf;
data_len = 0;
while (uw_address <= end_address)
{
if (HAL_FLASH_Program(FLASH_TYPEPROGRAM_FLASHWORD, uw_address, *data_buf) == HAL_OK)
{
uw_address += 4;
data_buf++;
data_len++;
if (data_len == len)
{
break;
}
}
else
{
HAL_FLASH_Lock();
return -1;
}
}
HAL_FLASH_Lock();
return 0;
}
/**
* @brief read data for flash
* @param[in] address: flash address
* @param[out] buf: data point
* @param[in] len: data num
* @retval none
*/
/**
* @brief 从flash读数据
* @param[in] start_address: flash 地址
* @param[out] buf: 数据指针
* @param[in] len: 数据长度
* @retval none
*/
void flash_read(uint32_t address, uint32_t *buf, uint32_t len)
{
memcpy(buf, (void *) address, len * 4);
}
/**
* @brief get the sector number of flash
* @param[in] address: flash address
* @retval sector number
*/
/**
* @brief 获取flash的sector号
* @param[in] address: flash 地址
* @retval sector号
*/
static uint32_t ger_sector(uint32_t address)
{
uint32_t sector = 0;
if ((address < ADDR_FLASH_SECTOR_1) && (address >= ADDR_FLASH_SECTOR_0))
{
sector = FLASH_SECTOR_0;
}
else if ((address < ADDR_FLASH_SECTOR_2) && (address >= ADDR_FLASH_SECTOR_1))
{
sector = FLASH_SECTOR_1;
}
else if ((address < ADDR_FLASH_SECTOR_3) && (address >= ADDR_FLASH_SECTOR_2))
{
sector = FLASH_SECTOR_2;
}
else if ((address < ADDR_FLASH_SECTOR_4) && (address >= ADDR_FLASH_SECTOR_3))
{
sector = FLASH_SECTOR_3;
}
else if ((address < ADDR_FLASH_SECTOR_5) && (address >= ADDR_FLASH_SECTOR_4))
{
sector = FLASH_SECTOR_4;
}
else if ((address < ADDR_FLASH_SECTOR_6) && (address >= ADDR_FLASH_SECTOR_5))
{
sector = FLASH_SECTOR_5;
}
else if ((address < ADDR_FLASH_SECTOR_7) && (address >= ADDR_FLASH_SECTOR_6))
{
sector = FLASH_SECTOR_6;
}
else if ((address < ADDR_FLASH_SECTOR_8) && (address >= ADDR_FLASH_SECTOR_7))
{
sector = FLASH_SECTOR_7;
}
return sector;
}
/**
* @brief get the next page flash address
* @param[in] address: flash address
* @retval next page flash address
*/
/**
* @brief 获取下一页flash地址
* @param[in] address: flash 地址
* @retval 下一页flash地址
*/
uint32_t get_next_flash_address(uint32_t address)
{
uint32_t sector = 0;
if ((address < ADDR_FLASH_SECTOR_1) && (address >= ADDR_FLASH_SECTOR_0))
{
sector = ADDR_FLASH_SECTOR_1;
}
else if ((address < ADDR_FLASH_SECTOR_2) && (address >= ADDR_FLASH_SECTOR_1))
{
sector = ADDR_FLASH_SECTOR_2;
}
else if ((address < ADDR_FLASH_SECTOR_3) && (address >= ADDR_FLASH_SECTOR_2))
{
sector = ADDR_FLASH_SECTOR_3;
}
else if ((address < ADDR_FLASH_SECTOR_4) && (address >= ADDR_FLASH_SECTOR_3))
{
sector = ADDR_FLASH_SECTOR_4;
}
else if ((address < ADDR_FLASH_SECTOR_5) && (address >= ADDR_FLASH_SECTOR_4))
{
sector = ADDR_FLASH_SECTOR_5;
}
else if ((address < ADDR_FLASH_SECTOR_6) && (address >= ADDR_FLASH_SECTOR_5))
{
sector = ADDR_FLASH_SECTOR_6;
}
else if ((address < ADDR_FLASH_SECTOR_7) && (address >= ADDR_FLASH_SECTOR_6))
{
sector = ADDR_FLASH_SECTOR_7;
}
else if ((address < ADDR_FLASH_SECTOR_8) && (address >= ADDR_FLASH_SECTOR_7))
{
sector = ADDR_FLASH_SECTOR_8;
}
else if ((address < ADDR_FLASH_SECTOR_9) && (address >= ADDR_FLASH_SECTOR_8))
{
sector = ADDR_FLASH_SECTOR_9;
}
else if ((address < ADDR_FLASH_SECTOR_10) && (address >= ADDR_FLASH_SECTOR_9))
{
sector = ADDR_FLASH_SECTOR_10;
}
else if ((address < ADDR_FLASH_SECTOR_11) && (address >= ADDR_FLASH_SECTOR_10))
{
sector = ADDR_FLASH_SECTOR_11;
}
else /*(address < FLASH_END_ADDR) && (address >= ADDR_FLASH_SECTOR_23))*/
{
sector = FLASH_END_ADDR;
}
return sector;
}

View File

@@ -0,0 +1,79 @@
#ifndef _BSP_FLASH_H
#define _BSP_FLASH_H
#include "main.h"
/* Base address of the Flash sectors */
#define ADDR_FLASH_SECTOR_0 ((uint32_t)0x08000000) /* Base address of Sector 0, 16 Kbytes */
#define ADDR_FLASH_SECTOR_1 ((uint32_t)0x08004000) /* Base address of Sector 1, 16 Kbytes */
#define ADDR_FLASH_SECTOR_2 ((uint32_t)0x08008000) /* Base address of Sector 2, 16 Kbytes */
#define ADDR_FLASH_SECTOR_3 ((uint32_t)0x0800C000) /* Base address of Sector 3, 16 Kbytes */
#define ADDR_FLASH_SECTOR_4 ((uint32_t)0x08010000) /* Base address of Sector 4, 64 Kbytes */
#define ADDR_FLASH_SECTOR_5 ((uint32_t)0x08020000) /* Base address of Sector 5, 128 Kbytes */
#define ADDR_FLASH_SECTOR_6 ((uint32_t)0x08040000) /* Base address of Sector 6, 128 Kbytes */
#define ADDR_FLASH_SECTOR_7 ((uint32_t)0x08060000) /* Base address of Sector 7, 128 Kbytes */
#define ADDR_FLASH_SECTOR_8 ((uint32_t)0x08080000) /* Base address of Sector 8, 128 Kbytes */
#define ADDR_FLASH_SECTOR_9 ((uint32_t)0x080A0000) /* Base address of Sector 9, 128 Kbytes */
#define ADDR_FLASH_SECTOR_10 ((uint32_t)0x080C0000) /* Base address of Sector 10, 128 Kbytes */
#define ADDR_FLASH_SECTOR_11 ((uint32_t)0x080E0000) /* Base address of Sector 11, 128 Kbytes */
#define FLASH_END_ADDR ((uint32_t)0x08100000) /* Base address of Sector 23, 128 Kbytes */
#define ADDR_FLASH_SECTOR_12 ((uint32_t)0x08100000) /* Base address of Sector 12, 16 Kbytes */
#define ADDR_FLASH_SECTOR_13 ((uint32_t)0x08104000) /* Base address of Sector 13, 16 Kbytes */
#define ADDR_FLASH_SECTOR_14 ((uint32_t)0x08108000) /* Base address of Sector 14, 16 Kbytes */
#define ADDR_FLASH_SECTOR_15 ((uint32_t)0x0810C000) /* Base address of Sector 15, 16 Kbytes */
#define ADDR_FLASH_SECTOR_16 ((uint32_t)0x08110000) /* Base address of Sector 16, 64 Kbytes */
#define ADDR_FLASH_SECTOR_17 ((uint32_t)0x08120000) /* Base address of Sector 17, 128 Kbytes */
#define ADDR_FLASH_SECTOR_18 ((uint32_t)0x08140000) /* Base address of Sector 18, 128 Kbytes */
#define ADDR_FLASH_SECTOR_19 ((uint32_t)0x08160000) /* Base address of Sector 19, 128 Kbytes */
#define ADDR_FLASH_SECTOR_20 ((uint32_t)0x08180000) /* Base address of Sector 20, 128 Kbytes */
#define ADDR_FLASH_SECTOR_21 ((uint32_t)0x081A0000) /* Base address of Sector 21, 128 Kbytes */
#define ADDR_FLASH_SECTOR_22 ((uint32_t)0x081C0000) /* Base address of Sector 22, 128 Kbytes */
#define ADDR_FLASH_SECTOR_23 ((uint32_t)0x081E0000) /* Base address of Sector 23, 128 Kbytes */
/**
* @brief erase flash
* @param[in] address: flash address
* @param[in] len: page num
* @retval none
*/
void flash_erase_address(uint32_t address, uint16_t len);
/**
* @brief write data to one page of flash
* @param[in] start_address: flash address
* @param[in] buf: data point
* @param[in] len: data num
* @retval success 0, fail -1
*/
int8_t flash_write_single_address(uint32_t start_address, uint32_t *buf, uint32_t len);
/**
* @brief write data to some pages of flash
* @param[in] start_address: flash start address
* @param[in] end_address: flash end address
* @param[in] buf: data point
* @param[in] len: data num
* @retval success 0, fail -1
*/
int8_t flash_write_muli_address(uint32_t start_address, uint32_t end_address, uint32_t *buf, uint32_t len);
/**
* @brief read data for flash
* @param[in] address: flash address
* @param[out] buf: data point
* @param[in] len: data num
* @retval none
*/
void flash_read(uint32_t address, uint32_t *buf, uint32_t len);
/**
* @brief get the next page flash address
* @param[in] address: flash address
* @retval next page flash address
*/
uint32_t get_next_flash_address(uint32_t address);
#endif

Some files were not shown because too many files have changed in this diff Show More