完善bsp

This commit is contained in:
RB 2025-04-28 23:02:34 +08:00
parent d400dc5ea3
commit 0886f91b01
32 changed files with 101 additions and 33404 deletions

View File

@ -1,7 +0,0 @@
{
"files.associations": {
"uart.h": "c",
"device.h": "c",
"pc_uart.h": "c"
}
}

View File

@ -272,40 +272,41 @@ class MRobotApp:
file_path = os.path.join(task_dir, file_name)
try:
with open(file_path, "r", encoding="utf-8") as f:
for line in f:
match = re.search(r"#define\s+TASK_FREQ_\w+\s+\((\d+)\)", line)
if match:
frequency = int(match.group(1))
break
content = f.read()
# 调试信息:打印文件内容
print(f"读取任务文件 {file_name} 内容:\n{content}")
match = re.search(r"#define\s+TASK_FREQ_\w+\s*\((\d+)\)", content)
if match:
frequency = int(match.group(1))
print(f"从文件 {file_name} 中读取到频率: {frequency}")
except Exception as e:
print(f"读取任务文件 {file_name} 时出错: {e}")
# 自动添加已存在的任务名和频率
new_task_var = tk.StringVar(value=file_base)
self.task_vars.append((new_task_var, tk.IntVar(value=frequency)))
# 清空任务框架中的所有子组件
for widget in self.task_frame.winfo_children():
widget.destroy()
# 设置任务管理框的固定宽度
self.task_frame.config(width=400) # 将宽度固定为 400 像素
# 显示任务列表
for i, (task_var, freq_var) in enumerate(self.task_vars):
task_row = tk.Frame(self.task_frame, width=400) # 设置任务行的宽度
task_row.pack(fill="x", pady=5)
# 调整输入框和按钮的宽度
tk.Entry(task_row, textvariable=task_var, width=20).pack(side="left", padx=5) # 输入框宽度
tk.Label(task_row, text="频率:").pack(side="left", padx=5)
tk.Spinbox(task_row, from_=1, to=1000, textvariable=freq_var, width=5).pack(side="left", padx=5) # 数字选择框
tk.Button(task_row, text="删除", command=lambda idx=i: self.remove_task(idx), bg="red", fg="white").pack(side="left", padx=5)
# 添加新任务按钮
add_task_button = tk.Button(self.task_frame, text="添加任务", command=self.add_task, bg="blue", fg="white")
add_task_button.pack(pady=10)
# 修改 add_task 方法
def add_task(self):

@ -1 +0,0 @@
Subproject commit d56490f92f599809449d21b9381baefaa193fce9

View File

@ -1,14 +0,0 @@
/* Includes ----------------------------------------------------------------- */
#include "bsp\adc.h"
#include <adc.h>
/* Private define ----------------------------------------------------------- */
/* Private macro ------------------------------------------------------------ */
/* Private typedef ---------------------------------------------------------- */
/* Private variables -------------------------------------------------------- */
/* Private function -------------------------------------------------------- */
/* Exported functions ------------------------------------------------------- */
// float BSP_GetAdc(){
// }

View File

@ -1,20 +0,0 @@
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ----------------------------------------------------------------- */
#include <stdint.h>
#include "bsp/bsp.h"
/* Exported constants ------------------------------------------------------- */
/* Exported macro ----------------------------------------------------------- */
/* Exported types ----------------------------------------------------------- */
/* Exported functions prototypes -------------------------------------------- */
// float BSP_GetAdc();
#ifdef __cplusplus
}
#endif

View File

@ -10,8 +10,6 @@ extern "C" {
#define BSP_ERR_INITED (-3)
#define BSP_ERR_NO_DEV (-4)
#define SIGNAL_BSP_USB_BUF_RECV (1u << 0)
#ifdef __cplusplus
}
#endif

View File

@ -1,29 +1,32 @@
/* Includes ----------------------------------------------------------------- */
#include "bsp/buzzer_gpio.h"
#include "bsp/bsp.h"
#include <gpio.h>
/* Includes ----------------------------------------------------------------- */
#include <gpio.h>
#include "bsp/bsp.h"
#include "bsp/buzzer_gpio.h"
/* Private define ----------------------------------------------------------- */
#define BSP_BUZZER_GPIO GPIOA
#define BSP_BUZZER_PIN GPIO_PIN_1
/* Private macro ------------------------------------------------------------ */
/* Private typedef ---------------------------------------------------------- */
/* Private variables -------------------------------------------------------- */
/* Private function --------------------------------------------------------- */
/* Exported functions ------------------------------------------------------- */
int8_t BSP_Buzzer_Set(BSP_Buzzer_Status_t s) {
switch (s) {
case BSP_BUZZER_ON:
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_1, GPIO_PIN_SET); // 打开蜂鸣器
break;
case BSP_BUZZER_OFF:
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_1, GPIO_PIN_RESET); // 关闭蜂鸣器
break;
case BSP_BUZZER_TAGGLE:
HAL_GPIO_TogglePin(GPIOA, GPIO_PIN_1); // 切换蜂鸣器状态
break;
default:
return -1; // 无效的状态
int8_t BSP_Buzzer_Set(BSP_Buzzer_Status_t s)
{
switch (s)
{
case BSP_BUZZER_ON:
HAL_GPIO_WritePin(BSP_BUZZER_GPIO, BSP_BUZZER_PIN, GPIO_PIN_SET); // 打开蜂鸣器
break;
case BSP_BUZZER_OFF:
HAL_GPIO_WritePin(BSP_BUZZER_GPIO, BSP_BUZZER_PIN, GPIO_PIN_RESET); // 关闭蜂鸣器
break;
case BSP_BUZZER_TAGGLE:
HAL_GPIO_TogglePin(BSP_BUZZER_GPIO, BSP_BUZZER_PIN); // 切换蜂鸣器状态
break;
default:
return BSP_ERR;
}
return 0; // 成功
return BSP_OK;
}

View File

@ -7,7 +7,7 @@
/* Exported macro ----------------------------------------------------------- */
/* Exported types ----------------------------------------------------------- */
/* Buzzer状态设置用 */
/* 设置BUZZER状态 */
typedef enum
{
BSP_BUZZER_ON,

View File

@ -9,10 +9,11 @@ static void (*I2C_Callback[BSP_I2C_NUM][BSP_I2C_CB_NUM])(void);
/* Private function -------------------------------------------------------- */
static BSP_I2C_t I2C_Get(I2C_HandleTypeDef *hi2c) {
if (hi2c->Instance == I2C1) return BSP_I2C_OLED;
if (hi2c->Instance == I2C1)
return BSP_I2C_EXAMPLE;
/*
else if (hi2c->Instance == I2CX)
return BSP_I2C_XXX;
return BSP_I2C_XXX;
*/
else
return BSP_I2C_ERR;
@ -93,7 +94,7 @@ void HAL_I2C_AbortCpltCallback(I2C_HandleTypeDef *hi2c) {
/* Exported functions ------------------------------------------------------- */
I2C_HandleTypeDef *BSP_I2C_GetHandle(BSP_I2C_t i2c) {
switch (i2c) {
case BSP_I2C_OLED:
case BSP_I2C_EXAMPLE:
return &hi2c1;
/*
case BSP_I2C_XXX:

View File

@ -17,13 +17,13 @@ extern "C" {
/* I2C实体枚举与设备对应 */
typedef enum {
BSP_I2C_OLED,
BSP_I2C_EXAMPLE,
/* BSP_I2C_XXX,*/
BSP_I2C_NUM,
BSP_I2C_ERR,
} BSP_I2C_t;
/* I2C支持的中断回调函数类型具体参考HAL中定义 */
/* I2C支持的中断回调函数类型*/
typedef enum {
HAL_I2C_MASTER_TX_CPLT_CB,
HAL_I2C_MASTER_RX_CPLT_CB,

View File

@ -7,33 +7,43 @@
/* Private macro ------------------------------------------------------------ */
/* Private typedef ---------------------------------------------------------- */
/* Private variables -------------------------------------------------------- */
static uint32_t led_stats; // 使用位掩码记录每个通道的状态
static uint32_t led_stats; // 使用位掩码记录每个通道的状态最多支持32LED
// 定义 LED 引脚映射表
static const uint16_t LED_PINS[] = {GPIO_PIN_2, GPIO_PIN_3, GPIO_PIN_4};
// 定义 LED 引脚和端口映射表:需要根据自己的修改,添加,或删减。
static const BSP_LED_Config_t LED_CONFIGS[] = {
{GPIOA, GPIO_PIN_2}, // BSP_LED_1
{GPIOA, GPIO_PIN_3}, // BSP_LED_2
{GPIOA, GPIO_PIN_4}, // BSP_LED_3
};
#define LED_CHANNEL_COUNT (sizeof(LED_CONFIGS) / sizeof(LED_CONFIGS[0])) // 通道数量
/* Private function --------------------------------------------------------- */
/* Exported functions ------------------------------------------------------- */
int8_t BSP_LED_Set(BSP_LED_Channel_t ch, BSP_LED_Status_t s) {
if (ch >= BSP_LED_1 && ch <= BSP_LED_3) {
uint16_t pin = LED_PINS[ch - BSP_LED_1]; // 获取对应的 GPIO 引脚
switch (s) {
case BSP_LED_ON:
led_stats |= (1 << ch); // 设置对应位为1
HAL_GPIO_WritePin(GPIOA, pin, GPIO_PIN_SET); // 点亮LED
break;
case BSP_LED_OFF:
led_stats &= ~(1 << ch); // 清除对应位为0
HAL_GPIO_WritePin(GPIOA, pin, GPIO_PIN_RESET); // 熄灭LED
break;
case BSP_LED_TAGGLE:
led_stats ^= (1 << ch); // 切换对应位
HAL_GPIO_TogglePin(GPIOA, pin); // 切换LED状态
break;
default:
return -1; // 无效的状态
int8_t BSP_LED_Set(BSP_LED_Channel_t ch, BSP_LED_Status_t s)
{
if (ch < LED_CHANNEL_COUNT)
{
GPIO_TypeDef *port = LED_CONFIGS[ch].port;
uint16_t pin = LED_CONFIGS[ch].pin;
switch (s)
{
case BSP_LED_ON:
led_stats |= (1 << ch);
HAL_GPIO_WritePin(port, pin, GPIO_PIN_SET); // 点亮LED
break;
case BSP_LED_OFF:
led_stats &= ~(1 << ch);
HAL_GPIO_WritePin(port, pin, GPIO_PIN_RESET); // 熄灭LED
break;
case BSP_LED_TAGGLE:
led_stats ^= (1 << ch);
HAL_GPIO_TogglePin(port, pin); // 切换LED状态
break;
default:
return BSP_ERR;
}
return 0; // 成功
return BSP_OK;
}
return -1; // 无效的通道
return BSP_ERR;
}

View File

@ -21,8 +21,16 @@ typedef enum
BSP_LED_1,
BSP_LED_2,
BSP_LED_3,
/*BSP_LED_XXX*/
} BSP_LED_Channel_t;
/* LED GPIO 配置 */
typedef struct
{
GPIO_TypeDef *port; // GPIO 端口 (如 GPIOA, GPIOB)
uint16_t pin; // GPIO 引脚
} BSP_LED_Config_t;
/* Exported functions prototypes -------------------------------------------- */
int8_t BSP_LED_Set(BSP_LED_Channel_t ch, BSP_LED_Status_t s);
int8_t BSP_LED_Set(BSP_LED_Channel_t ch, BSP_LED_Status_t s);

View File

@ -10,7 +10,7 @@ static void (*SPI_Callback[BSP_SPI_NUM][BSP_SPI_CB_NUM])(void);
/* Private function -------------------------------------------------------- */
static BSP_SPI_t SPI_Get(SPI_HandleTypeDef *hspi) {
if (hspi->Instance == SPI1)
return BSP_SPI_OLED;
return BSP_SPI_EXAMPLE;
/*
else if (hspi->Instance == SPIX)
return BSP_SPI_XXX;
@ -87,7 +87,7 @@ void HAL_SPI_AbortCpltCallback(SPI_HandleTypeDef *hspi) {
/* Exported functions ------------------------------------------------------- */
SPI_HandleTypeDef *BSP_SPI_GetHandle(BSP_SPI_t spi) {
switch (spi) {
case BSP_SPI_OLED:
case BSP_SPI_EXAMPLE:
return &hspi1;
/*
case BSP_SPI_XXX:

View File

@ -17,7 +17,7 @@ extern "C" {
/* SPI实体枚举与设备对应 */
typedef enum {
BSP_SPI_OLED,
BSP_SPI_EXAMPLE,
/* BSP_SPI_XXX,*/
BSP_SPI_NUM,
BSP_SPI_ERR,

View File

@ -10,7 +10,7 @@ static void (*UART_Callback[BSP_UART_NUM][BSP_UART_CB_NUM])(void);
/* Private function -------------------------------------------------------- */
static BSP_UART_t UART_Get(UART_HandleTypeDef *huart) {
if (huart->Instance == USART1)
return BSP_UART_PC;
return BSP_UART_EXAMPLE;
/*else */
@ -102,7 +102,7 @@ void BSP_UART_IRQHandler(UART_HandleTypeDef *huart) {
UART_HandleTypeDef *BSP_UART_GetHandle(BSP_UART_t uart) {
switch (uart) {
case BSP_UART_PC:
case BSP_UART_EXAMPLE:
return &huart1;
default:
return NULL;

View File

@ -17,7 +17,7 @@ extern "C" {
/* UART实体枚举与设备对应 */
typedef enum {
BSP_UART_PC,
BSP_UART_EXAMPLE,
/*BSP_UART_??*/
BSP_UART_NUM,
BSP_UART_ERR,

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

View File

@ -1,61 +0,0 @@
This file lists modules PyInstaller was not able to find. This does not
necessarily mean this module is required for running your program. Python and
Python 3rd-party packages include a lot of conditional or optional modules. For
example the module 'ntpath' only exists on Windows, whereas the module
'posixpath' only exists on Posix systems.
Types if import:
* top-level: imported at the top-level - look at these first
* conditional: imported within an if-statement
* delayed: imported within a function
* optional: imported within a try-except-statement
IMPORTANT: Do NOT post this list to the issue-tracker. Use it as a basis for
tracking down the missing module yourself. Thanks!
missing module named pyimod02_importers - imported by C:\Users\lvzucheng\AppData\Local\Programs\Python\Python313\Lib\site-packages\PyInstaller\hooks\rthooks\pyi_rth_pkgutil.py (delayed), C:\Users\lvzucheng\AppData\Local\Programs\Python\Python313\Lib\site-packages\PyInstaller\hooks\rthooks\pyi_rth_pkgres.py (delayed)
missing module named pwd - imported by posixpath (delayed, conditional, optional), shutil (delayed, optional), tarfile (optional), pathlib._local (optional), subprocess (delayed, conditional, optional), getpass (delayed, optional), setuptools._distutils.util (delayed, conditional, optional), netrc (delayed, conditional), setuptools._vendor.backports.tarfile (optional), setuptools._distutils.archive_util (optional), http.server (delayed, optional)
missing module named grp - imported by shutil (delayed, optional), tarfile (optional), pathlib._local (optional), subprocess (delayed, conditional, optional), setuptools._vendor.backports.tarfile (optional), setuptools._distutils.archive_util (optional)
missing module named _posixsubprocess - imported by subprocess (conditional), multiprocessing.util (delayed)
missing module named fcntl - imported by subprocess (optional), _pyrepl.unix_console (top-level)
missing module named _manylinux - imported by packaging._manylinux (delayed, optional), setuptools._vendor.packaging._manylinux (delayed, optional), setuptools._vendor.wheel.vendored.packaging._manylinux (delayed, optional)
missing module named posix - imported by posixpath (optional), shutil (conditional), importlib._bootstrap_external (conditional), os (conditional, optional), _pyrepl.unix_console (delayed, optional)
missing module named resource - imported by posix (top-level)
missing module named _frozen_importlib_external - imported by importlib._bootstrap (delayed), importlib (optional), importlib.abc (optional), zipimport (top-level)
missing module named typing_extensions.TypeAlias - imported by setuptools._vendor.typing_extensions (top-level), setuptools._distutils.compilers.C.base (conditional), setuptools._reqs (conditional), setuptools.warnings (conditional), setuptools._path (conditional), setuptools._distutils.dist (conditional), setuptools.config.setupcfg (conditional), setuptools.config._apply_pyprojecttoml (conditional), setuptools.dist (conditional), pkg_resources (conditional), setuptools.command.bdist_egg (conditional), setuptools.compat.py311 (conditional)
missing module named typing_extensions.Self - imported by setuptools._vendor.typing_extensions (top-level), setuptools.config.expand (conditional), setuptools.config.pyprojecttoml (conditional), setuptools.config._validate_pyproject.error_reporting (conditional), pkg_resources (conditional)
missing module named asyncio.DefaultEventLoopPolicy - imported by asyncio (delayed, conditional), asyncio.events (delayed, conditional)
missing module named _posixshmem - imported by multiprocessing.resource_tracker (conditional), multiprocessing.shared_memory (conditional)
missing module named multiprocessing.set_start_method - imported by multiprocessing (top-level), multiprocessing.spawn (top-level)
missing module named multiprocessing.get_start_method - imported by multiprocessing (top-level), multiprocessing.spawn (top-level)
missing module named multiprocessing.get_context - imported by multiprocessing (top-level), multiprocessing.pool (top-level), multiprocessing.managers (top-level), multiprocessing.sharedctypes (top-level)
missing module named multiprocessing.TimeoutError - imported by multiprocessing (top-level), multiprocessing.pool (top-level)
missing module named _scproxy - imported by urllib.request (conditional)
missing module named termios - imported by getpass (optional), tty (top-level), _pyrepl.pager (delayed, optional), _pyrepl.unix_console (top-level), _pyrepl.fancy_termios (top-level), _pyrepl.unix_eventqueue (top-level)
missing module named multiprocessing.BufferTooShort - imported by multiprocessing (top-level), multiprocessing.connection (top-level)
missing module named multiprocessing.AuthenticationError - imported by multiprocessing (top-level), multiprocessing.connection (top-level)
missing module named usercustomize - imported by site (delayed, optional)
missing module named sitecustomize - imported by site (delayed, optional)
missing module named _curses - imported by curses (top-level), curses.has_key (top-level), _pyrepl.curses (optional)
missing module named readline - imported by site (delayed, optional), rlcompleter (optional), code (delayed, conditional, optional)
missing module named trove_classifiers - imported by setuptools.config._validate_pyproject.formats (optional)
missing module named typing_extensions.Buffer - imported by setuptools._vendor.typing_extensions (top-level), setuptools._vendor.wheel.wheelfile (conditional)
missing module named typing_extensions.Literal - imported by setuptools._vendor.typing_extensions (top-level), setuptools.config._validate_pyproject.formats (conditional)
missing module named typing_extensions.deprecated - imported by setuptools._vendor.typing_extensions (top-level), setuptools._distutils.sysconfig (conditional), setuptools._distutils.command.bdist (conditional)
missing module named typing_extensions.Unpack - imported by setuptools._vendor.typing_extensions (top-level), setuptools._distutils.util (conditional), setuptools._distutils.compilers.C.base (conditional), setuptools._distutils.cmd (conditional)
missing module named typing_extensions.TypeVarTuple - imported by setuptools._vendor.typing_extensions (top-level), setuptools._distutils.util (conditional), setuptools._distutils.compilers.C.base (conditional), setuptools._distutils.cmd (conditional)
missing module named '_typeshed.importlib' - imported by pkg_resources (conditional)
missing module named _typeshed - imported by setuptools._distutils.dist (conditional), pkg_resources (conditional), setuptools.glob (conditional), setuptools.compat.py311 (conditional), git.objects.fun (conditional)
missing module named jnius - imported by setuptools._vendor.platformdirs.android (delayed, conditional, optional)
missing module named android - imported by setuptools._vendor.platformdirs.android (delayed, conditional, optional)
missing module named importlib_resources - imported by setuptools._vendor.jaraco.text (optional)
missing module named 'collections.abc' - imported by traceback (top-level), inspect (top-level), logging (top-level), typing (top-level), importlib.resources.readers (top-level), selectors (top-level), tracemalloc (top-level), setuptools (top-level), setuptools._distutils.filelist (top-level), setuptools._distutils.util (top-level), setuptools._vendor.jaraco.functools (top-level), setuptools._vendor.more_itertools.more (top-level), setuptools._vendor.more_itertools.recipes (top-level), setuptools._distutils._modified (top-level), setuptools._distutils.compat (top-level), setuptools._distutils.spawn (top-level), setuptools._distutils.compilers.C.base (top-level), setuptools._distutils.fancy_getopt (top-level), setuptools._reqs (top-level), http.client (top-level), setuptools.discovery (top-level), setuptools.dist (top-level), setuptools._distutils.command.bdist (top-level), setuptools._distutils.core (top-level), setuptools._distutils.cmd (top-level), setuptools._distutils.dist (top-level), configparser (top-level), setuptools._distutils.extension (top-level), setuptools.config.setupcfg (top-level), setuptools.config.expand (top-level), setuptools.config.pyprojecttoml (top-level), setuptools.config._apply_pyprojecttoml (top-level), tomllib._parser (top-level), setuptools._vendor.tomli._parser (top-level), pkg_resources (top-level), setuptools._vendor.platformdirs.windows (conditional), setuptools.command.egg_info (top-level), setuptools._distutils.command.build (top-level), setuptools._distutils.command.sdist (top-level), setuptools.glob (top-level), setuptools.command._requirestxt (top-level), setuptools.command.bdist_wheel (top-level), setuptools._vendor.wheel.cli.convert (top-level), setuptools._vendor.wheel.cli.tags (top-level), setuptools._vendor.typing_extensions (top-level), asyncio.base_events (top-level), asyncio.coroutines (top-level), setuptools._distutils.command.build_ext (top-level), _pyrepl.types (top-level), _pyrepl.readline (top-level), setuptools._distutils.compilers.C.msvc (top-level)
excluded module named _frozen_importlib - imported by importlib (optional), importlib.abc (optional), zipimport (top-level)
missing module named vms_lib - imported by platform (delayed, optional)
missing module named 'java.lang' - imported by platform (delayed, optional)
missing module named java - imported by platform (delayed)
missing module named _suggestions - imported by traceback (delayed, optional)
missing module named gitdb_speedups - imported by gitdb.fun (optional)
missing module named 'gitdb_speedups._perf' - imported by gitdb.stream (optional), gitdb.pack (optional)
missing module named sha - imported by gitdb.util (delayed, optional)

File diff suppressed because it is too large Load Diff

BIN
dist/MRobot.exe vendored

Binary file not shown.

10
开发要求.md Normal file
View File

@ -0,0 +1,10 @@
# BSP
按照规范开发
# component
按照规范开发
# develop
按照规范开发
# module
按照规范开发
# task
按照规范开发