mirror of
https://github.com/goldenfishs/MRobot.git
synced 2025-11-01 20:13:11 +08:00
修复bsp的bug
This commit is contained in:
parent
bbb521654c
commit
3e49722616
@ -64,7 +64,13 @@ class CodeGenerateInterface(QWidget):
|
||||
freertos_label.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred)
|
||||
top_layout.addWidget(freertos_label)
|
||||
|
||||
# 配置并生成FreeRTOS任务按钮,直接调用已有方法
|
||||
# 自动生成FreeRTOS任务按钮
|
||||
auto_task_btn = PushButton(FluentIcon.SEND, "自动生成FreeRTOS任务")
|
||||
auto_task_btn.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
|
||||
auto_task_btn.clicked.connect(self.on_freertos_task_btn_clicked)
|
||||
top_layout.addWidget(auto_task_btn, alignment=Qt.AlignRight)
|
||||
|
||||
# 配置并生成FreeRTOS任务按钮
|
||||
freertos_task_btn = PushButton(FluentIcon.SETTING, "配置并生成FreeRTOS任务")
|
||||
freertos_task_btn.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
|
||||
freertos_task_btn.clicked.connect(self.on_task_code_btn_clicked)
|
||||
@ -113,6 +119,41 @@ class CodeGenerateInterface(QWidget):
|
||||
duration=2000
|
||||
)
|
||||
|
||||
def on_freertos_task_btn_clicked(self):
|
||||
# 检查是否开启 FreeRTOS
|
||||
ioc_files = [f for f in os.listdir(self.project_path) if f.endswith('.ioc')]
|
||||
if ioc_files:
|
||||
ioc_path = os.path.join(self.project_path, ioc_files[0])
|
||||
if not analyzing_ioc.is_freertos_enabled_from_ioc(ioc_path):
|
||||
InfoBar.error(
|
||||
title="错误",
|
||||
content="请先在 .ioc 文件中开启 FreeRTOS,再自动生成任务!",
|
||||
parent=self,
|
||||
duration=3000
|
||||
)
|
||||
return
|
||||
else:
|
||||
InfoBar.error(
|
||||
title="错误",
|
||||
content="未找到 .ioc 文件,无法检测 FreeRTOS 状态!",
|
||||
parent=self,
|
||||
duration=3000
|
||||
)
|
||||
return
|
||||
|
||||
# 自动生成FreeRTOS任务代码
|
||||
from app.data_interface import DataInterface
|
||||
di = DataInterface()
|
||||
di.project_path = self.project_path
|
||||
di.generate_freertos_task()
|
||||
InfoBar.success(
|
||||
title="自动生成成功",
|
||||
content="FreeRTOS任务代码已自动生成!",
|
||||
parent=self,
|
||||
duration=2000
|
||||
)
|
||||
|
||||
|
||||
def generate_code(self):
|
||||
"""生成代码逻辑"""
|
||||
# 收集所有已加载的页面对象
|
||||
|
||||
@ -50,15 +50,15 @@ class MainWindow(FluentWindow):
|
||||
self.homeInterface = HomeInterface(self)
|
||||
self.serialTerminalInterface = SerialTerminalInterface(self)
|
||||
self.partLibraryInterface = PartLibraryInterface(self)
|
||||
self.dataInterface = DataInterface(self)
|
||||
# self.dataInterface = DataInterface(self)
|
||||
self.miniToolInterface = MiniToolInterface(self)
|
||||
self.codeConfigurationInterface = CodeConfigurationInterface(self)
|
||||
|
||||
|
||||
def initNavigation(self):
|
||||
self.addSubInterface(self.homeInterface, FIF.HOME, self.tr('主页'))
|
||||
self.addSubInterface(self.dataInterface, FIF.CODE, self.tr('代码生成'))
|
||||
self.addSubInterface(self.codeConfigurationInterface, FIF.SETTING, self.tr('代码配置'))
|
||||
# self.addSubInterface(self.dataInterface, FIF.CODE, self.tr('代码生成'))
|
||||
self.addSubInterface(self.codeConfigurationInterface, FIF.CODE, self.tr('代码生成'))
|
||||
self.addSubInterface(self.serialTerminalInterface, FIF.COMMAND_PROMPT,self.tr('串口助手'))
|
||||
self.addSubInterface(self.partLibraryInterface, FIF.DOWNLOAD, self.tr('零件库'))
|
||||
self.addSubInterface(self.miniToolInterface, FIF.LIBRARY, self.tr('迷你工具箱'))
|
||||
|
||||
@ -101,9 +101,9 @@ int8_t BSP_SPI_Transmit(BSP_SPI_t spi, uint8_t *data, uint16_t size, bool dma) {
|
||||
if (hspi == NULL) return BSP_ERR;
|
||||
|
||||
if (dma) {
|
||||
return HAL_SPI_Transmit_DMA(hspi, data, size);
|
||||
return HAL_SPI_Transmit_DMA(hspi, data, size)!= HAL_OK;;
|
||||
} else {
|
||||
return HAL_SPI_Transmit_IT(hspi, data, size);
|
||||
return HAL_SPI_Transmit_IT(hspi, data, size)!= HAL_OK;;
|
||||
}
|
||||
}
|
||||
|
||||
@ -113,9 +113,9 @@ int8_t BSP_SPI_Receive(BSP_SPI_t spi, uint8_t *data, uint16_t size, bool dma) {
|
||||
if (hspi == NULL) return BSP_ERR;
|
||||
|
||||
if (dma) {
|
||||
return HAL_SPI_Receive_DMA(hspi, data, size);
|
||||
return HAL_SPI_Receive_DMA(hspi, data, size)!= HAL_OK;;
|
||||
} else {
|
||||
return HAL_SPI_Receive_IT(hspi, data, size);
|
||||
return HAL_SPI_Receive_IT(hspi, data, size)!= HAL_OK;;
|
||||
}
|
||||
}
|
||||
|
||||
@ -126,9 +126,9 @@ int8_t BSP_SPI_TransmitReceive(BSP_SPI_t spi, uint8_t *txData, uint8_t *rxData,
|
||||
if (hspi == NULL) return BSP_ERR;
|
||||
|
||||
if (dma) {
|
||||
return HAL_SPI_TransmitReceive_DMA(hspi, txData, rxData, size);
|
||||
return HAL_SPI_TransmitReceive_DMA(hspi, txData, rxData, size)!= HAL_OK;;
|
||||
} else {
|
||||
return HAL_SPI_TransmitReceive_IT(hspi, txData, rxData, size);
|
||||
return HAL_SPI_TransmitReceive_IT(hspi, txData, rxData, size)!= HAL_OK;;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -7,6 +7,7 @@ extern "C" {
|
||||
/* Includes ----------------------------------------------------------------- */
|
||||
#include <spi.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "bsp/bsp.h"
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/* Includes ----------------------------------------------------------------- */
|
||||
#include "bsp/delay.h"
|
||||
#include "bsp/time.h"
|
||||
#include "bsp.h"
|
||||
|
||||
#include <cmsis_os2.h>
|
||||
|
||||
@ -7,6 +7,7 @@ extern "C" {
|
||||
/* Includes ----------------------------------------------------------------- */
|
||||
#include <usart.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "bsp/bsp.h"
|
||||
|
||||
@ -43,7 +44,7 @@ typedef enum {
|
||||
UART_HandleTypeDef *BSP_UART_GetHandle(BSP_UART_t uart);
|
||||
int8_t BSP_UART_RegisterCallback(BSP_UART_t uart, BSP_UART_Callback_t type,
|
||||
void (*callback)(void));
|
||||
|
||||
|
||||
int8_t BSP_UART_Transmit(BSP_UART_t uart, uint8_t *data, uint16_t size, bool dma);
|
||||
int8_t BSP_UART_Receive(BSP_UART_t uart, uint8_t *data, uint16_t size, bool dma);
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
bsp,can,delay,dwt,,gpio,i2c,mm,spi,uart,pwm,time
|
||||
bsp,can,dwt,gpio,i2c,mm,spi,uart,pwm,time
|
||||
component,pid,filter,ahrs
|
||||
device,dr16,ai,nuc
|
||||
module,chassis,gimbal,arm,shoot
|
||||
|
Loading…
Reference in New Issue
Block a user