准备驱动移植适配Rust
This commit is contained in:
@ -2,7 +2,7 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file : bsp_board.h
|
||||
* @brief : Board support package board abstraction header file
|
||||
* @brief : 板级支持包板级抽象头文件
|
||||
******************************************************************************
|
||||
*/
|
||||
/* USER CODE END Header */
|
||||
@ -18,9 +18,11 @@
|
||||
#include "hal_i2c.h"
|
||||
#include "hal_can.h"
|
||||
#include "hal_adc.h"
|
||||
#include "hal_eth.h"
|
||||
#include "bsp_eth.h"
|
||||
|
||||
/**
|
||||
* @brief BSP configuration version
|
||||
* @brief BSP 配置版本
|
||||
*/
|
||||
#define BSP_CONFIG_VERSION_MAJOR 1
|
||||
#define BSP_CONFIG_VERSION_MINOR 0
|
||||
@ -28,49 +30,49 @@
|
||||
#define BSP_CONFIG_VERSION (BSP_CONFIG_VERSION_MAJOR << 16 | BSP_CONFIG_VERSION_MINOR << 8 | BSP_CONFIG_VERSION_PATCH)
|
||||
|
||||
/**
|
||||
* @brief Board LED configuration structure
|
||||
* @brief 板级 LED 配置结构体
|
||||
*/
|
||||
typedef struct {
|
||||
uint8_t enable; /*!< LED enable flag */
|
||||
hal_gpio_port_t port; /*!< LED GPIO port */
|
||||
hal_gpio_pin_t pin; /*!< LED GPIO pin */
|
||||
hal_gpio_mode_t mode; /*!< LED GPIO mode */
|
||||
hal_gpio_speed_t speed; /*!< LED GPIO speed */
|
||||
hal_gpio_pull_t pull; /*!< LED GPIO pull configuration */
|
||||
uint8_t enable; /*!< LED 使能标志 */
|
||||
hal_gpio_port_t port; /*!< LED GPIO 端口 */
|
||||
hal_gpio_pin_t pin; /*!< LED GPIO 引脚 */
|
||||
hal_gpio_mode_t mode; /*!< LED GPIO 模式 */
|
||||
hal_gpio_speed_t speed; /*!< LED GPIO 速度 */
|
||||
hal_gpio_pull_t pull; /*!< LED GPIO 上拉配置 */
|
||||
} bsp_led_config_t;
|
||||
|
||||
/**
|
||||
* @brief Board LEDs configuration structure
|
||||
* @brief 板级 LEDs 配置结构体
|
||||
*/
|
||||
typedef struct {
|
||||
uint8_t enable; /*!< LEDs enable flag */
|
||||
uint8_t count; /*!< Number of LEDs */
|
||||
const bsp_led_config_t* leds; /*!< Pointer to LEDs configuration array */
|
||||
uint8_t enable; /*!< LEDs 使能标志 */
|
||||
uint8_t count; /*!< LED 数量 */
|
||||
const bsp_led_config_t* leds; /*!< 指向 LEDs 配置数组的指针 */
|
||||
} bsp_leds_config_t;
|
||||
|
||||
/**
|
||||
* @brief Board button configuration structure
|
||||
* @brief 板级按键配置结构体
|
||||
*/
|
||||
typedef struct {
|
||||
hal_gpio_port_t port; /*!< Button GPIO port */
|
||||
hal_gpio_pin_t pin; /*!< Button GPIO pin */
|
||||
hal_gpio_mode_t mode; /*!< Button GPIO mode */
|
||||
hal_gpio_speed_t speed; /*!< Button GPIO speed */
|
||||
hal_gpio_pull_t pull; /*!< Button GPIO pull configuration */
|
||||
uint8_t active_high; /*!< Button active high flag */
|
||||
hal_gpio_port_t port; /*!< 按键 GPIO 端口 */
|
||||
hal_gpio_pin_t pin; /*!< 按键 GPIO 引脚 */
|
||||
hal_gpio_mode_t mode; /*!< 按键 GPIO 模式 */
|
||||
hal_gpio_speed_t speed; /*!< 按键 GPIO 速度 */
|
||||
hal_gpio_pull_t pull; /*!< 按键 GPIO 上拉配置 */
|
||||
uint8_t active_high; /*!< 按键高电平有效标志 */
|
||||
} bsp_button_config_t;
|
||||
|
||||
/**
|
||||
* @brief Board buttons configuration structure
|
||||
* @brief 板级按键组配置结构体
|
||||
*/
|
||||
typedef struct {
|
||||
uint8_t enable; /*!< Buttons enable flag */
|
||||
uint8_t count; /*!< Number of buttons */
|
||||
const bsp_button_config_t* buttons; /*!< Pointer to buttons configuration array */
|
||||
uint8_t enable; /*!< 按键使能标志 */
|
||||
uint8_t count; /*!< 按键数量 */
|
||||
const bsp_button_config_t* buttons; /*!< 指向按键配置数组的指针 */
|
||||
} bsp_buttons_config_t;
|
||||
|
||||
/**
|
||||
* @brief UART instance identifier definitions
|
||||
* @brief UART 实例标识符定义
|
||||
*/
|
||||
typedef enum {
|
||||
BSP_UART_INSTANCE_1 = 0,
|
||||
@ -83,251 +85,258 @@ typedef enum {
|
||||
} bsp_uart_instance_t;
|
||||
|
||||
/**
|
||||
* @brief Board UART configuration structure
|
||||
* @brief 板级 UART 配置结构体
|
||||
*/
|
||||
typedef struct {
|
||||
uint8_t enable; /*!< UART enable flag */
|
||||
bsp_uart_instance_t instance; /*!< UART instance */
|
||||
uint32_t baudrate; /*!< UART baudrate */
|
||||
hal_uart_parity_t parity; /*!< UART parity */
|
||||
hal_uart_stopbits_t stopbits; /*!< UART stop bits */
|
||||
hal_uart_databits_t databits; /*!< UART data bits */
|
||||
hal_gpio_port_t tx_port; /*!< UART TX port */
|
||||
hal_gpio_pin_t tx_pin; /*!< UART TX pin */
|
||||
hal_gpio_port_t rx_port; /*!< UART RX port */
|
||||
hal_gpio_pin_t rx_pin; /*!< UART RX pin */
|
||||
uint8_t enable; /*!< UART 使能标志 */
|
||||
bsp_uart_instance_t instance; /*!< UART 实例 */
|
||||
uint32_t baudrate; /*!< UART 波特率 */
|
||||
hal_uart_parity_t parity; /*!< UART 校验位 */
|
||||
hal_uart_stopbits_t stopbits; /*!< UART 停止位 */
|
||||
hal_uart_databits_t databits; /*!< UART 数据位 */
|
||||
hal_gpio_port_t tx_port; /*!< UART TX 端口 */
|
||||
hal_gpio_pin_t tx_pin; /*!< UART TX 引脚 */
|
||||
hal_gpio_port_t rx_port; /*!< UART RX 端口 */
|
||||
hal_gpio_pin_t rx_pin; /*!< UART RX 引脚 */
|
||||
} bsp_uart_config_t;
|
||||
|
||||
/**
|
||||
* @brief Board SPI configuration structure
|
||||
* @brief 板级 SPI 配置结构体
|
||||
*/
|
||||
typedef struct {
|
||||
uint8_t enable; /*!< SPI enable flag */
|
||||
hal_spi_instance_t instance; /*!< SPI instance */
|
||||
hal_spi_mode_t mode; /*!< SPI mode */
|
||||
uint32_t baudrate; /*!< SPI baudrate */
|
||||
hal_spi_polarity_t polarity; /*!< SPI clock polarity */
|
||||
hal_spi_phase_t phase; /*!< SPI clock phase */
|
||||
hal_spi_databits_t databits; /*!< SPI data bits */
|
||||
hal_gpio_port_t sck_port; /*!< SPI SCK port */
|
||||
hal_gpio_pin_t sck_pin; /*!< SPI SCK pin */
|
||||
hal_gpio_port_t miso_port; /*!< SPI MISO port */
|
||||
hal_gpio_pin_t miso_pin; /*!< SPI MISO pin */
|
||||
hal_gpio_port_t mosi_port; /*!< SPI MOSI port */
|
||||
hal_gpio_pin_t mosi_pin; /*!< SPI MOSI pin */
|
||||
uint8_t enable; /*!< SPI 使能标志 */
|
||||
hal_spi_instance_t instance; /*!< SPI 实例 */
|
||||
hal_spi_mode_t mode; /*!< SPI 模式 */
|
||||
uint32_t baudrate; /*!< SPI 波特率 */
|
||||
hal_spi_polarity_t polarity; /*!< SPI 时钟极性 */
|
||||
hal_spi_phase_t phase; /*!< SPI 时钟相位 */
|
||||
hal_spi_databits_t databits; /*!< SPI 数据位 */
|
||||
hal_gpio_port_t sck_port; /*!< SPI SCK 端口 */
|
||||
hal_gpio_pin_t sck_pin; /*!< SPI SCK 引脚 */
|
||||
hal_gpio_port_t miso_port; /*!< SPI MISO 端口 */
|
||||
hal_gpio_pin_t miso_pin; /*!< SPI MISO 引脚 */
|
||||
hal_gpio_port_t mosi_port; /*!< SPI MOSI 端口 */
|
||||
hal_gpio_pin_t mosi_pin; /*!< SPI MOSI 引脚 */
|
||||
} bsp_spi_config_t;
|
||||
|
||||
/**
|
||||
* @brief Board I2C configuration structure
|
||||
* @brief 板级 I2C 配置结构体
|
||||
*/
|
||||
typedef struct {
|
||||
uint8_t enable; /*!< I2C enable flag */
|
||||
hal_i2c_instance_t instance; /*!< I2C instance */
|
||||
hal_i2c_speed_t speed; /*!< I2C speed */
|
||||
hal_i2c_address_mode_t address_mode; /*!< I2C address mode */
|
||||
hal_i2c_dutycycle_t dutycycle; /*!< I2C duty cycle */
|
||||
uint16_t own_address1; /*!< I2C own address 1 */
|
||||
hal_gpio_port_t scl_port; /*!< I2C SCL port */
|
||||
hal_gpio_pin_t scl_pin; /*!< I2C SCL pin */
|
||||
hal_gpio_port_t sda_port; /*!< I2C SDA port */
|
||||
hal_gpio_pin_t sda_pin; /*!< I2C SDA pin */
|
||||
uint8_t enable; /*!< I2C 使能标志 */
|
||||
hal_i2c_instance_t instance; /*!< I2C 实例 */
|
||||
hal_i2c_speed_t speed; /*!< I2C 速度 */
|
||||
hal_i2c_address_mode_t address_mode; /*!< I2C 地址模式 */
|
||||
hal_i2c_dutycycle_t dutycycle; /*!< I2C 占空比 */
|
||||
uint16_t own_address1; /*!< I2C 自身地址 1 */
|
||||
hal_gpio_port_t scl_port; /*!< I2C SCL 端口 */
|
||||
hal_gpio_pin_t scl_pin; /*!< I2C SCL 引脚 */
|
||||
hal_gpio_port_t sda_port; /*!< I2C SDA 端口 */
|
||||
hal_gpio_pin_t sda_pin; /*!< I2C SDA 引脚 */
|
||||
} bsp_i2c_config_t;
|
||||
|
||||
/**
|
||||
* @brief Board CAN configuration structure
|
||||
* @brief 板级 CAN 配置结构体
|
||||
*/
|
||||
typedef struct {
|
||||
uint8_t enable; /*!< CAN enable flag */
|
||||
hal_can_instance_t instance; /*!< CAN instance */
|
||||
hal_can_mode_t mode; /*!< CAN mode */
|
||||
uint32_t prescaler; /*!< CAN prescaler */
|
||||
uint8_t sync_jump_width; /*!< CAN sync jump width */
|
||||
uint8_t time_segment1; /*!< CAN time segment 1 */
|
||||
uint8_t time_segment2; /*!< CAN time segment 2 */
|
||||
hal_gpio_port_t rx_port; /*!< CAN RX port */
|
||||
hal_gpio_pin_t rx_pin; /*!< CAN RX pin */
|
||||
hal_gpio_port_t tx_port; /*!< CAN TX port */
|
||||
hal_gpio_pin_t tx_pin; /*!< CAN TX pin */
|
||||
uint8_t enable; /*!< CAN 使能标志 */
|
||||
hal_can_instance_t instance; /*!< CAN 实例 */
|
||||
hal_can_mode_t mode; /*!< CAN 模式 */
|
||||
uint32_t prescaler; /*!< CAN 预分频器 */
|
||||
uint8_t sync_jump_width; /*!< CAN 同步跳转宽度 */
|
||||
uint8_t time_segment1; /*!< CAN 时间段 1 */
|
||||
uint8_t time_segment2; /*!< CAN 时间段 2 */
|
||||
hal_gpio_port_t rx_port; /*!< CAN RX 端口 */
|
||||
hal_gpio_pin_t rx_pin; /*!< CAN RX 引脚 */
|
||||
hal_gpio_port_t tx_port; /*!< CAN TX 端口 */
|
||||
hal_gpio_pin_t tx_pin; /*!< CAN TX 引脚 */
|
||||
} bsp_can_config_t;
|
||||
|
||||
/**
|
||||
* @brief Board ADC channel configuration structure
|
||||
* @brief 板级 ADC 通道配置结构体
|
||||
*/
|
||||
typedef struct {
|
||||
uint8_t enable; /*!< ADC channel enable flag */
|
||||
hal_adc_channel_t channel; /*!< ADC channel */
|
||||
hal_adc_sampletime_t sampletime; /*!< ADC sample time */
|
||||
uint8_t rank; /*!< ADC channel rank */
|
||||
uint8_t enable; /*!< ADC 通道使能标志 */
|
||||
hal_adc_channel_t channel; /*!< ADC 通道 */
|
||||
hal_adc_sampletime_t sampletime; /*!< ADC 采样时间 */
|
||||
uint8_t rank; /*!< ADC 通道优先级 */
|
||||
} bsp_adc_channel_config_t;
|
||||
|
||||
/**
|
||||
* @brief Board ADC configuration structure
|
||||
* @brief 板级 ADC 配置结构体
|
||||
*/
|
||||
typedef struct {
|
||||
uint8_t enable; /*!< ADC enable flag */
|
||||
hal_adc_instance_t instance; /*!< ADC instance */
|
||||
hal_adc_resolution_t resolution; /*!< ADC resolution */
|
||||
uint8_t scan_conversion_mode; /*!< ADC scan conversion mode */
|
||||
uint8_t continuous_conversion_mode; /*!< ADC continuous conversion mode */
|
||||
uint8_t channel_count; /*!< Number of ADC channels */
|
||||
const bsp_adc_channel_config_t* channels; /*!< Pointer to ADC channels configuration array */
|
||||
uint8_t enable; /*!< ADC 使能标志 */
|
||||
hal_adc_instance_t instance; /*!< ADC 实例 */
|
||||
hal_adc_resolution_t resolution; /*!< ADC 分辨率 */
|
||||
uint8_t scan_conversion_mode; /*!< ADC 扫描转换模式 */
|
||||
uint8_t continuous_conversion_mode; /*!< ADC 连续转换模式 */
|
||||
uint8_t channel_count; /*!< ADC 通道数量 */
|
||||
const bsp_adc_channel_config_t* channels; /*!< 指向 ADC 通道配置数组的指针 */
|
||||
} bsp_adc_config_t;
|
||||
|
||||
/**
|
||||
* @brief Board W25QXX configuration structure
|
||||
* @brief 板级 W25QXX 配置结构体
|
||||
*/
|
||||
typedef struct {
|
||||
uint8_t enable; /*!< W25QXX enable flag */
|
||||
hal_gpio_port_t cs_port; /*!< W25QXX CS port */
|
||||
hal_gpio_pin_t cs_pin; /*!< W25QXX CS pin */
|
||||
uint8_t spi_instance; /*!< SPI instance used by W25QXX */
|
||||
uint8_t enable; /*!< W25QXX 使能标志 */
|
||||
hal_gpio_port_t cs_port; /*!< W25QXX CS 端口 */
|
||||
hal_gpio_pin_t cs_pin; /*!< W25QXX CS 引脚 */
|
||||
uint8_t spi_instance; /*!< W25QXX 使用的 SPI 实例 */
|
||||
} bsp_w25qxx_config_t;
|
||||
|
||||
/**
|
||||
* @brief Board peripheral initialization function type
|
||||
* @brief 板级外设初始化函数类型
|
||||
*/
|
||||
typedef hal_ret_t (*bsp_periph_init_func_t)(const void* config);
|
||||
|
||||
/**
|
||||
* @brief Board ID structure
|
||||
* @brief 板级 ID 结构体
|
||||
*/
|
||||
typedef struct {
|
||||
uint16_t vendor_id; /*!< Board vendor ID */
|
||||
uint16_t product_id; /*!< Board product ID */
|
||||
uint32_t serial_number; /*!< Board serial number */
|
||||
uint16_t vendor_id; /*!< 板级厂商 ID */
|
||||
uint16_t product_id; /*!< 板级产品 ID */
|
||||
uint32_t serial_number; /*!< 板级序列号 */
|
||||
} bsp_board_id_t;
|
||||
|
||||
/**
|
||||
* @brief Board feature flags
|
||||
* @brief 板级特性标志
|
||||
*/
|
||||
typedef enum {
|
||||
BSP_BOARD_FEATURE_LED = (1 << 0), /*!< Board has LED support */
|
||||
BSP_BOARD_FEATURE_BUTTON = (1 << 1), /*!< Board has button support */
|
||||
BSP_BOARD_FEATURE_UART = (1 << 2), /*!< Board has UART support */
|
||||
BSP_BOARD_FEATURE_SPI = (1 << 3), /*!< Board has SPI support */
|
||||
BSP_BOARD_FEATURE_I2C = (1 << 4), /*!< Board has I2C support */
|
||||
BSP_BOARD_FEATURE_CAN = (1 << 5), /*!< Board has CAN support */
|
||||
BSP_BOARD_FEATURE_ADC = (1 << 6), /*!< Board has ADC support */
|
||||
BSP_BOARD_FEATURE_DAC = (1 << 7), /*!< Board has DAC support */
|
||||
BSP_BOARD_FEATURE_TIMER = (1 << 8), /*!< Board has TIMER support */
|
||||
BSP_BOARD_FEATURE_RTC = (1 << 9), /*!< Board has RTC support */
|
||||
BSP_BOARD_FEATURE_W25QXX = (1 << 10), /*!< Board has W25QXX support */
|
||||
BSP_BOARD_FEATURE_DMA = (1 << 11), /*!< Board has DMA support */
|
||||
BSP_BOARD_FEATURE_ETH = (1 << 12), /*!< Board has ETH support */
|
||||
BSP_BOARD_FEATURE_USB = (1 << 13), /*!< Board has USB support */
|
||||
BSP_BOARD_FEATURE_SDIO = (1 << 14), /*!< Board has SDIO support */
|
||||
BSP_BOARD_FEATURE_FSMC = (1 << 15), /*!< Board has FSMC support */
|
||||
BSP_BOARD_FEATURE_LED = (1 << 0), /*!< 板级支持 LED */
|
||||
BSP_BOARD_FEATURE_BUTTON = (1 << 1), /*!< 板级支持按键 */
|
||||
BSP_BOARD_FEATURE_UART = (1 << 2), /*!< 板级支持 UART */
|
||||
BSP_BOARD_FEATURE_SPI = (1 << 3), /*!< 板级支持 SPI */
|
||||
BSP_BOARD_FEATURE_I2C = (1 << 4), /*!< 板级支持 I2C */
|
||||
BSP_BOARD_FEATURE_CAN = (1 << 5), /*!< 板级支持 CAN */
|
||||
BSP_BOARD_FEATURE_ADC = (1 << 6), /*!< 板级支持 ADC */
|
||||
BSP_BOARD_FEATURE_DAC = (1 << 7), /*!< 板级支持 DAC */
|
||||
BSP_BOARD_FEATURE_TIMER = (1 << 8), /*!< 板级支持 TIMER */
|
||||
BSP_BOARD_FEATURE_RTC = (1 << 9), /*!< 板级支持 RTC */
|
||||
BSP_BOARD_FEATURE_W25QXX = (1 << 10), /*!< 板级支持 W25QXX */
|
||||
BSP_BOARD_FEATURE_DMA = (1 << 11), /*!< 板级支持 DMA */
|
||||
BSP_BOARD_FEATURE_ETH = (1 << 12), /*!< 板级支持 ETH */
|
||||
BSP_BOARD_FEATURE_USB = (1 << 13), /*!< 板级支持 USB */
|
||||
BSP_BOARD_FEATURE_SDIO = (1 << 14), /*!< 板级支持 SDIO */
|
||||
BSP_BOARD_FEATURE_FSMC = (1 << 15), /*!< 板级支持 FSMC */
|
||||
} bsp_board_feature_t;
|
||||
|
||||
/**
|
||||
* @brief Board hardware information structure
|
||||
* @brief 板级硬件信息结构体
|
||||
*/
|
||||
typedef struct {
|
||||
uint32_t clock_speed; /*!< Board clock speed */
|
||||
uint32_t flash_size; /*!< Flash size in bytes */
|
||||
uint32_t ram_size; /*!< RAM size in bytes */
|
||||
uint32_t eeprom_size; /*!< EEPROM size in bytes */
|
||||
uint32_t sram_size; /*!< SRAM size in bytes */
|
||||
uint8_t cpu_core; /*!< CPU core type */
|
||||
uint8_t cpu_bits; /*!< CPU bits (32 or 64) */
|
||||
uint32_t clock_speed; /*!< 板级时钟速度 */
|
||||
uint32_t flash_size; /*!< Flash 大小(字节) */
|
||||
uint32_t ram_size; /*!< RAM 大小(字节) */
|
||||
uint32_t eeprom_size; /*!< EEPROM 大小(字节) */
|
||||
uint32_t sram_size; /*!< SRAM 大小(字节) */
|
||||
uint8_t cpu_core; /*!< CPU 核心类型 */
|
||||
uint8_t cpu_bits; /*!< CPU 位数(32 或 64) */
|
||||
} bsp_board_hw_info_t;
|
||||
|
||||
/**
|
||||
* @brief Board peripheral configuration structure
|
||||
* @brief 板级外设配置结构体
|
||||
*/
|
||||
typedef struct {
|
||||
/* UART configurations */
|
||||
uint8_t uart_count; /*!< Number of UARTs */
|
||||
const bsp_uart_config_t* uarts; /*!< Pointer to UARTs configuration array */
|
||||
/* UART 配置 */
|
||||
uint8_t uart_count; /*!< UART 数量 */
|
||||
const bsp_uart_config_t* uarts; /*!< 指向 UART 配置数组的指针 */
|
||||
|
||||
/* SPI configurations */
|
||||
uint8_t spi_count; /*!< Number of SPIs */
|
||||
const bsp_spi_config_t* spis; /*!< Pointer to SPIs configuration array */
|
||||
/* SPI 配置 */
|
||||
uint8_t spi_count; /*!< SPI 数量 */
|
||||
const bsp_spi_config_t* spis; /*!< 指向 SPI 配置数组的指针 */
|
||||
|
||||
/* I2C configurations */
|
||||
uint8_t i2c_count; /*!< Number of I2Cs */
|
||||
const bsp_i2c_config_t* i2cs; /*!< Pointer to I2Cs configuration array */
|
||||
/* I2C 配置 */
|
||||
uint8_t i2c_count; /*!< I2C 数量 */
|
||||
const bsp_i2c_config_t* i2cs; /*!< 指向 I2C 配置数组的指针 */
|
||||
|
||||
/* CAN configurations */
|
||||
uint8_t can_count; /*!< Number of CANs */
|
||||
const bsp_can_config_t* cans; /*!< Pointer to CANs configuration array */
|
||||
/* CAN 配置 */
|
||||
uint8_t can_count; /*!< CAN 数量 */
|
||||
const bsp_can_config_t* cans; /*!< 指向 CAN 配置数组的指针 */
|
||||
|
||||
/* ADC configurations */
|
||||
uint8_t adc_count; /*!< Number of ADCs */
|
||||
const bsp_adc_config_t* adcs; /*!< Pointer to ADCs configuration array */
|
||||
/* ADC 配置 */
|
||||
uint8_t adc_count; /*!< ADC 数量 */
|
||||
const bsp_adc_config_t* adcs; /*!< 指向 ADC 配置数组的指针 */
|
||||
} bsp_board_periph_config_t;
|
||||
|
||||
/**
|
||||
* @brief Board initialization function pointers structure
|
||||
* @brief 板级以太网配置结构体
|
||||
*/
|
||||
// bsp_eth_config_t 在 bsp_eth.h 中定义
|
||||
|
||||
/**
|
||||
* @brief 板级初始化函数指针结构体
|
||||
*/
|
||||
typedef struct {
|
||||
bsp_periph_init_func_t led_init; /*!< LED initialization function */
|
||||
bsp_periph_init_func_t button_init; /*!< Button initialization function */
|
||||
bsp_periph_init_func_t uart_init; /*!< UART initialization function */
|
||||
bsp_periph_init_func_t spi_init; /*!< SPI initialization function */
|
||||
bsp_periph_init_func_t i2c_init; /*!< I2C initialization function */
|
||||
bsp_periph_init_func_t can_init; /*!< CAN initialization function */
|
||||
bsp_periph_init_func_t adc_init; /*!< ADC initialization function */
|
||||
bsp_periph_init_func_t w25qxx_init; /*!< W25QXX initialization function */
|
||||
bsp_periph_init_func_t led_init; /*!< LED 初始化函数 */
|
||||
bsp_periph_init_func_t button_init; /*!< 按键初始化函数 */
|
||||
bsp_periph_init_func_t uart_init; /*!< UART 初始化函数 */
|
||||
bsp_periph_init_func_t spi_init; /*!< SPI 初始化函数 */
|
||||
bsp_periph_init_func_t i2c_init; /*!< I2C 初始化函数 */
|
||||
bsp_periph_init_func_t can_init; /*!< CAN 初始化函数 */
|
||||
bsp_periph_init_func_t adc_init; /*!< ADC 初始化函数 */
|
||||
bsp_periph_init_func_t w25qxx_init; /*!< W25QXX 初始化函数 */
|
||||
bsp_periph_init_func_t eth_init; /*!< 以太网初始化函数 */
|
||||
} bsp_board_init_funcs_t;
|
||||
|
||||
/**
|
||||
* @brief Board configuration structure
|
||||
* @brief 板级配置结构体
|
||||
*/
|
||||
typedef struct {
|
||||
uint32_t version; /*!< Configuration version */
|
||||
const char* name; /*!< Board name */
|
||||
const char* description; /*!< Board description */
|
||||
bsp_board_id_t id; /*!< Board ID information */
|
||||
uint32_t version; /*!< 配置版本 */
|
||||
const char* name; /*!< 板级名称 */
|
||||
const char* description; /*!< 板级描述 */
|
||||
bsp_board_id_t id; /*!< 板级 ID 信息 */
|
||||
|
||||
/* Board features */
|
||||
uint32_t features; /*!< Board feature flags */
|
||||
/* 板级特性 */
|
||||
uint32_t features; /*!< 板级特性标志 */
|
||||
|
||||
/* Hardware information */
|
||||
bsp_board_hw_info_t hw_info; /*!< Hardware information */
|
||||
/* 硬件信息 */
|
||||
bsp_board_hw_info_t hw_info; /*!< 硬件信息 */
|
||||
|
||||
/* Peripheral configurations */
|
||||
bsp_leds_config_t leds; /*!< LEDs configuration */
|
||||
bsp_buttons_config_t buttons; /*!< Buttons configuration */
|
||||
bsp_w25qxx_config_t w25qxx; /*!< W25QXX configuration */
|
||||
/* 外设配置 */
|
||||
bsp_leds_config_t leds; /*!< LEDs 配置 */
|
||||
bsp_buttons_config_t buttons; /*!< 按键配置 */
|
||||
bsp_w25qxx_config_t w25qxx; /*!< W25QXX 配置 */
|
||||
bsp_eth_config_t eth; /*!< 以太网配置 */
|
||||
|
||||
/* Peripheral arrays */
|
||||
bsp_board_periph_config_t periphs; /*!< Peripheral configurations */
|
||||
/* 外设数组 */
|
||||
bsp_board_periph_config_t periphs; /*!< 外设配置 */
|
||||
|
||||
/* Initialization functions */
|
||||
bsp_board_init_funcs_t init_funcs; /*!< Initialization function pointers */
|
||||
/* 初始化函数 */
|
||||
bsp_board_init_funcs_t init_funcs; /*!< 初始化函数指针 */
|
||||
|
||||
/* Additional board-specific configuration */
|
||||
void* custom_config; /*!< Custom board configuration pointer */
|
||||
size_t custom_config_size; /*!< Custom board configuration size */
|
||||
/* 板级特定配置 */
|
||||
void* custom_config; /*!< 自定义板级配置指针 */
|
||||
size_t custom_config_size; /*!< 自定义板级配置大小 */
|
||||
|
||||
/* Board revision information */
|
||||
uint8_t major_rev; /*!< Major revision */
|
||||
uint8_t minor_rev; /*!< Minor revision */
|
||||
uint8_t patch_rev; /*!< Patch revision */
|
||||
const char* revision_desc; /*!< Revision description */
|
||||
/* 板级版本信息 */
|
||||
uint8_t major_rev; /*!< 主版本 */
|
||||
uint8_t minor_rev; /*!< 次版本 */
|
||||
uint8_t patch_rev; /*!< 补丁版本 */
|
||||
const char* revision_desc; /*!< 版本描述 */
|
||||
} bsp_board_config_t;
|
||||
|
||||
/**
|
||||
* @brief STM32F407VET6 board configuration extern declaration
|
||||
* @brief STM32F407VET6 板级配置外部声明
|
||||
*/
|
||||
extern const bsp_board_config_t stm32f407vet6_board_config;
|
||||
|
||||
/**
|
||||
* @brief Board hardware initialization
|
||||
* @retval HAL status code
|
||||
* @brief 板级硬件初始化
|
||||
* @retval HAL 状态码
|
||||
*/
|
||||
hal_ret_t bsp_board_init(void);
|
||||
|
||||
/**
|
||||
* @brief Get board name
|
||||
* @retval Board name string
|
||||
* @brief 获取板级名称
|
||||
* @retval 板级名称字符串
|
||||
*/
|
||||
const char* bsp_board_get_name(void);
|
||||
|
||||
/**
|
||||
* @brief Get board configuration
|
||||
* @retval Pointer to board configuration structure
|
||||
* @brief 获取板级配置
|
||||
* @retval 指向板级配置结构体的指针
|
||||
*/
|
||||
const bsp_board_config_t* bsp_board_get_config(void);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user