mirror of
https://github.com/goldenfishs/MRobot.git
synced 2026-02-04 18:00:19 +08:00
更新
This commit is contained in:
parent
21052cf0a7
commit
5e8bab2014
@ -917,10 +917,48 @@ class bsp_spi(BspPeripheralBase):
|
||||
|
||||
|
||||
def patch_uart_interrupts(project_path, uart_instances):
|
||||
"""自动修改 stm32f4xx_it.c,插入 UART BSP 相关代码"""
|
||||
it_path = os.path.join(project_path, "Core/Src/stm32f4xx_it.c")
|
||||
"""自动修改中断文件,插入 UART BSP 相关代码(支持 F1/F4/H7 等系列)"""
|
||||
# 检测MCU型号,确定正确的中断文件
|
||||
ioc_files = [f for f in os.listdir(project_path) if f.endswith('.ioc')]
|
||||
if not ioc_files:
|
||||
return
|
||||
|
||||
ioc_path = os.path.join(project_path, ioc_files[0])
|
||||
mcu_name = analyzing_ioc.get_mcu_name_from_ioc(ioc_path)
|
||||
|
||||
if not mcu_name:
|
||||
return
|
||||
|
||||
# 根据MCU型号确定中断文件名
|
||||
mcu_upper = mcu_name.upper()
|
||||
if 'STM32F1' in mcu_upper:
|
||||
it_file = "stm32f1xx_it.c"
|
||||
elif 'STM32F4' in mcu_upper:
|
||||
it_file = "stm32f4xx_it.c"
|
||||
elif 'STM32H7' in mcu_upper:
|
||||
it_file = "stm32h7xx_it.c"
|
||||
elif 'STM32F7' in mcu_upper:
|
||||
it_file = "stm32f7xx_it.c"
|
||||
elif 'STM32G4' in mcu_upper:
|
||||
it_file = "stm32g4xx_it.c"
|
||||
elif 'STM32L4' in mcu_upper:
|
||||
it_file = "stm32l4xx_it.c"
|
||||
else:
|
||||
# 通用处理:尝试从MCU名称提取系列信息
|
||||
# 格式通常为 STM32X0XXX,提取 X0 部分
|
||||
import re as regex
|
||||
match = regex.match(r'STM32([A-Z]\d)', mcu_upper)
|
||||
if match:
|
||||
series = match.group(1).lower()
|
||||
it_file = f"stm32{series}xx_it.c"
|
||||
else:
|
||||
# 默认尝试 F4
|
||||
it_file = "stm32f4xx_it.c"
|
||||
|
||||
it_path = os.path.join(project_path, f"Core/Src/{it_file}")
|
||||
if not os.path.exists(it_path):
|
||||
return
|
||||
|
||||
with open(it_path, "r", encoding="utf-8") as f:
|
||||
code = f.read()
|
||||
|
||||
|
||||
@ -84,9 +84,12 @@ void Task_atti_esti(void *argument) {
|
||||
AHRS_GetEulr(&eulr_to_send, &gimbal_ahrs);
|
||||
osKernelUnlock();
|
||||
|
||||
/* 在此处用消息队列传递imu数据 */
|
||||
/* osMessageQueuePut( ... ); */
|
||||
|
||||
/* 控制IMU加热器 */
|
||||
BSP_PWM_SetComp(BSP_PWM_IMU_HEAT, PID_Calc(&imu_temp_ctrl_pid, 40.5f,
|
||||
bmi088.temp, 0.0f, 0.0f));
|
||||
|
||||
/* USER CODE END */
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user