Skip to content

Commit 5de9c12

Browse files
committed
2025.3.18新增传感器
1 parent 3c44fe1 commit 5de9c12

File tree

8 files changed

+323
-26
lines changed

8 files changed

+323
-26
lines changed

Core/Inc/main.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,16 @@ void Error_Handler(void);
6161
#define RE_GPIO_Port GPIOC
6262
#define DE_Pin GPIO_PIN_1
6363
#define DE_GPIO_Port GPIOC
64+
#define PNPSensor2_Pin GPIO_PIN_2
65+
#define PNPSensor2_GPIO_Port GPIOC
6466
#define CYLIN_Pin GPIO_PIN_3
6567
#define CYLIN_GPIO_Port GPIOC
6668
#define LED1_Pin GPIO_PIN_1
6769
#define LED1_GPIO_Port GPIOG
6870
#define BOUNCE_Pin GPIO_PIN_4
6971
#define BOUNCE_GPIO_Port GPIOC
70-
#define PNPSensor_Pin GPIO_PIN_5
71-
#define PNPSensor_GPIO_Port GPIOC
72+
#define PNPSensor1_Pin GPIO_PIN_5
73+
#define PNPSensor1_GPIO_Port GPIOC
7274
#define LED_GREEN_Pin GPIO_PIN_14
7375
#define LED_GREEN_GPIO_Port GPIOF
7476

Core/Src/gpio.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,12 @@ void MX_GPIO_Init(void)
7777
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
7878
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
7979

80+
/*Configure GPIO pins : PNPSensor2_Pin PNPSensor1_Pin */
81+
GPIO_InitStruct.Pin = PNPSensor2_Pin|PNPSensor1_Pin;
82+
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
83+
GPIO_InitStruct.Pull = GPIO_PULLDOWN;
84+
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
85+
8086
/*Configure GPIO pin : CYLIN_Pin */
8187
GPIO_InitStruct.Pin = CYLIN_Pin;
8288
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
@@ -98,12 +104,6 @@ void MX_GPIO_Init(void)
98104
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
99105
HAL_GPIO_Init(BOUNCE_GPIO_Port, &GPIO_InitStruct);
100106

101-
/*Configure GPIO pin : PNPSensor_Pin */
102-
GPIO_InitStruct.Pin = PNPSensor_Pin;
103-
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
104-
GPIO_InitStruct.Pull = GPIO_PULLDOWN;
105-
HAL_GPIO_Init(PNPSensor_GPIO_Port, &GPIO_InitStruct);
106-
107107
/*Configure GPIO pin : LED_GREEN_Pin */
108108
GPIO_InitStruct.Pin = LED_GREEN_Pin;
109109
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
##########################################################################################################################
2-
# File automatically-generated by tool: [projectgenerator] version: [4.5.0-RC5] date: [Wed Mar 05 00:25:54 CST 2025]
2+
# File automatically-generated by tool: [projectgenerator] version: [4.6.0-B36] date: [Mon Mar 17 18:55:15 CST 2025]
33
##########################################################################################################################
44

55
# ------------------------------------------------
@@ -163,7 +163,7 @@ CFLAGS += -MMD -MP -MF"$(@:%.o=%.d)"
163163
# LDFLAGS
164164
#######################################
165165
# link script
166-
LDSCRIPT = stm32f427iihx_flash.ld
166+
LDSCRIPT = STM32F427XX_FLASH.ld
167167

168168
# libraries
169169
LIBS = -lc -lm -lnosys

README.md

Lines changed: 60 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,60 @@
1-
# WTR2025R2
2-
南宫问天2025Robocon扣篮机器人
1+
## 版本历史
2+
3+
### [3.0.0] - 2025-3-17
4+
- 增加整车状态机,增加宇树电机大疆电机执行线程,增加各线程头文件,增加状态机修改线程,增加准备状态线程
5+
- 修改整车状态为准备、拍球、抛球三状态,修改抛射线程,修改弹射线程,修改宇树电机执行方式,修改线程优先级
6+
- 抛球线程已测试正常工作
7+
- 拍球状态未测试
8+
9+
### [2.2.1] - 2025-3-14
10+
- 通过上位机(电脑的串口助手)更改L1测距传感器,更改为上电后的激光关闭
11+
- 试图使用环形缓冲区进行数据接收以提高响应速率,但不好使,无法正常数据解析,故使用会原来的单缓冲区实时接收数据
12+
- 将上电后激光关闭的代码注释掉,发现反应速率提高,然而相同代码一段时间过后,无法正确解析数据,推测该传感器不好使!
13+
14+
### [2.2.0] - 2025-3-12
15+
- 拍球任务逻辑进行修改,使其能流程正常运作
16+
- 优化了L1测距传感器的数据读取与处理解析
17+
- L1传感器应上电后关闭激光,当拍球气缸向上时,打开激光并且快速连续测量
18+
- 目前20Hz的传感器不能够满足拍球需求,后续需更换传感器或直接优化掉传感器
19+
20+
21+
### [2.1.0] - 2025-3-9
22+
- 创建了双宇树持续发送控制的任务,以及更改宇树数据的函数代码
23+
- 能够实现双宇树的运动
24+
- 能够用ASCII通信协议接收L1测距传感器的数据
25+
- 更新了融合L1测距传感器的拍球部分代码
26+
- 为监测数据的实时数变化,现使用Jlink进行调试,不使用串口助手
27+
28+
### [2.0.0] - 2025-3-5
29+
- 框架重修,更细致拆分任务
30+
- 双宇树理论代码
31+
- 遥控器carmode模式还未放到合适位置,rmctltask.c在for循环之前就有死循环了,不能放在那个任务中
32+
33+
### [1.4.1] - 2025-2-26
34+
- 实现自旋与调整姿态的功能
35+
- 单个宇树电机带不动,无法实现罚球线前抛球
36+
- 光电开关存在延时误差,后续会更改为测距传感器
37+
38+
### [1.4.0] - 2025-02-16
39+
- 新安装的夹爪张开电流值为正,闭合为负
40+
41+
### [1.3.0] - 2025-01-15
42+
- 完成了遥控器控制整车上层机构(除拦截)的代码,能一整套进行控制运行
43+
- 修改了抛球代码的参数
44+
- 基于光电开关的位置,使用延时来控制拍球的夹球时机
45+
46+
### [1.2.0] - 2025-01-11
47+
- 修改了抛球代码
48+
- 实现遥控器控制抛球
49+
- 上位机调整了角编码器的回传速率,实现能较稳定地以60°抛出
50+
51+
### [1.1.0] - 2025-01-08
52+
- 修改了拍球代码&抛球代码
53+
- 实现遥控器控制电爪子,实现拍球功能
54+
- 拍球不稳定,后续需换传感器
55+
- 抛球代码为上电全自动,不需要遥控器控制,还待测试
56+
57+
### [1.0.0] - 2025-01-05
58+
- 初始化仓库版本
59+
- 实现遥控器控制气缸拍球功能
60+
- 含有气缸夹爪抛射+角编码器+自旋电机控制代码(为了单独测试拍球,都注释掉了)

STM32F427XX_FLASH.ld

Lines changed: 227 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,227 @@
1+
/*
2+
******************************************************************************
3+
**
4+
5+
** File : LinkerScript.ld
6+
**
7+
** Author : STM32CubeMX
8+
**
9+
** Abstract : Linker script for STM32F427IIHx series
10+
** 2048Kbytes FLASH and 256Kbytes RAM
11+
**
12+
** Set heap size, stack size and stack location according
13+
** to application requirements.
14+
**
15+
** Set memory bank area and size if external memory is used.
16+
**
17+
** Target : STMicroelectronics STM32
18+
**
19+
** Distribution: The file is distributed “as is,” without any warranty
20+
** of any kind.
21+
**
22+
*****************************************************************************
23+
** @attention
24+
**
25+
** <h2><center>&copy; COPYRIGHT(c) 2025 STMicroelectronics</center></h2>
26+
**
27+
** Redistribution and use in source and binary forms, with or without modification,
28+
** are permitted provided that the following conditions are met:
29+
** 1. Redistributions of source code must retain the above copyright notice,
30+
** this list of conditions and the following disclaimer.
31+
** 2. Redistributions in binary form must reproduce the above copyright notice,
32+
** this list of conditions and the following disclaimer in the documentation
33+
** and/or other materials provided with the distribution.
34+
** 3. Neither the name of STMicroelectronics nor the names of its contributors
35+
** may be used to endorse or promote products derived from this software
36+
** without specific prior written permission.
37+
**
38+
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
39+
** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40+
** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
41+
** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
42+
** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
43+
** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
44+
** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
45+
** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
46+
** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
47+
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
48+
**
49+
*****************************************************************************
50+
*/
51+
52+
/* Entry Point */
53+
ENTRY(Reset_Handler)
54+
55+
/* Highest address of the user mode stack */
56+
_estack = ORIGIN(RAM) + LENGTH(RAM); /* end of RAM */
57+
/* Generate a link error if heap and stack don't fit into RAM */
58+
_Min_Heap_Size = 0x400; /* required amount of heap */
59+
_Min_Stack_Size = 0x800; /* required amount of stack */
60+
61+
/* Specify the memory areas */
62+
MEMORY
63+
{
64+
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 192K
65+
CCMRAM (xrw) : ORIGIN = 0x10000000, LENGTH = 64K
66+
FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 2048K
67+
}
68+
69+
/* Define output sections */
70+
SECTIONS
71+
{
72+
/* The startup code goes first into FLASH */
73+
.isr_vector :
74+
{
75+
. = ALIGN(4);
76+
KEEP(*(.isr_vector)) /* Startup code */
77+
. = ALIGN(4);
78+
} >FLASH
79+
80+
/* The program code and other data goes into FLASH */
81+
.text :
82+
{
83+
. = ALIGN(4);
84+
*(.text) /* .text sections (code) */
85+
*(.text*) /* .text* sections (code) */
86+
*(.glue_7) /* glue arm to thumb code */
87+
*(.glue_7t) /* glue thumb to arm code */
88+
*(.eh_frame)
89+
90+
KEEP (*(.init))
91+
KEEP (*(.fini))
92+
93+
. = ALIGN(4);
94+
_etext = .; /* define a global symbols at end of code */
95+
} >FLASH
96+
97+
/* Constant data goes into FLASH */
98+
.rodata :
99+
{
100+
. = ALIGN(4);
101+
*(.rodata) /* .rodata sections (constants, strings, etc.) */
102+
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
103+
. = ALIGN(4);
104+
} >FLASH
105+
106+
.ARM.extab (READONLY) : /* The "READONLY" keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */
107+
{
108+
. = ALIGN(4);
109+
*(.ARM.extab* .gnu.linkonce.armextab.*)
110+
. = ALIGN(4);
111+
} >FLASH
112+
113+
.ARM (READONLY) : /* The "READONLY" keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */
114+
{
115+
. = ALIGN(4);
116+
__exidx_start = .;
117+
*(.ARM.exidx*)
118+
__exidx_end = .;
119+
. = ALIGN(4);
120+
} >FLASH
121+
122+
.preinit_array (READONLY) : /* The "READONLY" keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */
123+
{
124+
. = ALIGN(4);
125+
PROVIDE_HIDDEN (__preinit_array_start = .);
126+
KEEP (*(.preinit_array*))
127+
PROVIDE_HIDDEN (__preinit_array_end = .);
128+
. = ALIGN(4);
129+
} >FLASH
130+
131+
.init_array (READONLY) : /* The "READONLY" keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */
132+
{
133+
. = ALIGN(4);
134+
PROVIDE_HIDDEN (__init_array_start = .);
135+
KEEP (*(SORT(.init_array.*)))
136+
KEEP (*(.init_array*))
137+
PROVIDE_HIDDEN (__init_array_end = .);
138+
. = ALIGN(4);
139+
} >FLASH
140+
141+
.fini_array (READONLY) : /* The "READONLY" keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */
142+
{
143+
. = ALIGN(4);
144+
PROVIDE_HIDDEN (__fini_array_start = .);
145+
KEEP (*(SORT(.fini_array.*)))
146+
KEEP (*(.fini_array*))
147+
PROVIDE_HIDDEN (__fini_array_end = .);
148+
. = ALIGN(4);
149+
} >FLASH
150+
151+
/* used by the startup to initialize data */
152+
_sidata = LOADADDR(.data);
153+
154+
/* Initialized data sections goes into RAM, load LMA copy after code */
155+
.data :
156+
{
157+
. = ALIGN(4);
158+
_sdata = .; /* create a global symbol at data start */
159+
*(.data) /* .data sections */
160+
*(.data*) /* .data* sections */
161+
*(.RamFunc) /* .RamFunc sections */
162+
*(.RamFunc*) /* .RamFunc* sections */
163+
164+
. = ALIGN(4);
165+
_edata = .; /* define a global symbol at data end */
166+
} >RAM AT> FLASH
167+
168+
_siccmram = LOADADDR(.ccmram);
169+
170+
/* CCM-RAM section
171+
*
172+
* IMPORTANT NOTE!
173+
* If initialized variables will be placed in this section,
174+
* the startup code needs to be modified to copy the init-values.
175+
*/
176+
.ccmram :
177+
{
178+
. = ALIGN(4);
179+
_sccmram = .; /* create a global symbol at ccmram start */
180+
*(.ccmram)
181+
*(.ccmram*)
182+
183+
. = ALIGN(4);
184+
_eccmram = .; /* create a global symbol at ccmram end */
185+
} >CCMRAM AT> FLASH
186+
187+
188+
/* Uninitialized data section */
189+
. = ALIGN(4);
190+
.bss :
191+
{
192+
/* This is used by the startup in order to initialize the .bss secion */
193+
_sbss = .; /* define a global symbol at bss start */
194+
__bss_start__ = _sbss;
195+
*(.bss)
196+
*(.bss*)
197+
*(COMMON)
198+
199+
. = ALIGN(4);
200+
_ebss = .; /* define a global symbol at bss end */
201+
__bss_end__ = _ebss;
202+
} >RAM
203+
204+
/* User_heap_stack section, used to check that there is enough RAM left */
205+
._user_heap_stack :
206+
{
207+
. = ALIGN(8);
208+
PROVIDE ( end = . );
209+
PROVIDE ( _end = . );
210+
. = . + _Min_Heap_Size;
211+
. = . + _Min_Stack_Size;
212+
. = ALIGN(8);
213+
} >RAM
214+
215+
216+
217+
/* Remove information from the standard libraries */
218+
/DISCARD/ :
219+
{
220+
libc.a ( * )
221+
libm.a ( * )
222+
libgcc.a ( * )
223+
}
224+
225+
}
226+
227+

0 commit comments

Comments
 (0)