准备驱动移植适配Rust

This commit is contained in:
冯佳
2026-01-29 15:08:30 +08:00
parent e879b18602
commit 1bdeca55ea
68 changed files with 4371 additions and 4392 deletions

View File

@ -2,7 +2,7 @@
/**
******************************************************************************
* @file : bsp_board_manager.c
* @brief : Board support package manager source file
* @brief : 板级支持包管理器源文件
******************************************************************************
*/
/* USER CODE END Header */
@ -14,7 +14,7 @@
extern const bsp_board_config_t stm32f407vet6_board_config;
/**
* @brief List of supported board configurations
* @brief 支持的板卡配置列表
*/
static const bsp_board_config_t* supported_boards[] = {
&stm32f407vet6_board_config,
@ -22,22 +22,22 @@ static const bsp_board_config_t* supported_boards[] = {
};
/**
* @brief Current board configuration index
* @brief 当前板卡配置索引
*/
static uint8_t current_board_index = 0;
/**
* @brief Get number of supported boards
* @retval Number of supported boards
* @brief 获取支持的板卡数量
* @retval 支持的板卡数量
*/
uint8_t bsp_board_get_count(void) {
return sizeof(supported_boards) / sizeof(supported_boards[0]);
}
/**
* @brief Get board configuration by index
* @param index: Board configuration index
* @retval Pointer to board configuration structure, NULL if invalid index
* @brief 通过索引获取板卡配置
* @param index: 板卡配置索引
* @retval 指向板卡配置结构体的指针,无效索引返回 NULL
*/
const bsp_board_config_t* bsp_board_get_by_index(uint8_t index) {
if (index < bsp_board_get_count()) {
@ -47,9 +47,9 @@ const bsp_board_config_t* bsp_board_get_by_index(uint8_t index) {
}
/**
* @brief Get board configuration by name
* @param name: Board name string
* @retval Pointer to board configuration structure, NULL if not found
* @brief 通过名称获取板卡配置
* @param name: 板卡名称字符串
* @retval 指向板卡配置结构体的指针,未找到返回 NULL
*/
const bsp_board_config_t* bsp_board_get_by_name(const char* name) {
for (uint8_t i = 0; i < bsp_board_get_count(); i++) {
@ -62,9 +62,9 @@ const bsp_board_config_t* bsp_board_get_by_name(const char* name) {
}
/**
* @brief Set current board configuration by index
* @param index: Board configuration index
* @retval HAL status code
* @brief 通过索引设置当前板卡配置
* @param index: 板卡配置索引
* @retval HAL 状态码
*/
hal_ret_t bsp_board_set_by_index(uint8_t index) {
if (index < bsp_board_get_count()) {
@ -75,9 +75,9 @@ hal_ret_t bsp_board_set_by_index(uint8_t index) {
}
/**
* @brief Set current board configuration by name
* @param name: Board name string
* @retval HAL status code
* @brief 通过名称设置当前板卡配置
* @param name: 板卡名称字符串
* @retval HAL 状态码
*/
hal_ret_t bsp_board_set_by_name(const char* name) {
if (name == NULL) {
@ -95,16 +95,16 @@ hal_ret_t bsp_board_set_by_name(const char* name) {
}
/**
* @brief Get current board configuration
* @retval Pointer to current board configuration structure
* @brief 获取当前板卡配置
* @retval 指向当前板卡配置结构体的指针
*/
const bsp_board_config_t* bsp_board_get_config(void) {
return supported_boards[current_board_index];
}
/**
* @brief Get current board index
* @retval Current board index
* @brief 获取当前板卡索引
* @retval 当前板卡索引
*/
uint8_t bsp_board_get_current_index(void) {
return current_board_index;