调整适配目录层级
This commit is contained in:
@ -39,6 +39,15 @@ typedef struct {
|
||||
hal_gpio_pull_t pull; /*!< LED GPIO pull configuration */
|
||||
} bsp_led_config_t;
|
||||
|
||||
/**
|
||||
* @brief Board LEDs configuration structure
|
||||
*/
|
||||
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 */
|
||||
} bsp_leds_config_t;
|
||||
|
||||
/**
|
||||
* @brief Board button configuration structure
|
||||
*/
|
||||
@ -278,7 +287,7 @@ typedef struct {
|
||||
bsp_board_hw_info_t hw_info; /*!< Hardware information */
|
||||
|
||||
/* Peripheral configurations */
|
||||
bsp_led_config_t led; /*!< LED configuration */
|
||||
bsp_leds_config_t leds; /*!< LEDs configuration */
|
||||
bsp_buttons_config_t buttons; /*!< Buttons configuration */
|
||||
bsp_w25qxx_config_t w25qxx; /*!< W25QXX configuration */
|
||||
|
||||
|
||||
@ -32,24 +32,28 @@ hal_ret_t bsp_init(void) {
|
||||
|
||||
/* Initialize peripherals based on configuration */
|
||||
|
||||
/* Initialize LED */
|
||||
if (board_config->led.enable && board_config->init_funcs.led_init != NULL) {
|
||||
status = board_config->init_funcs.led_init(&board_config->led);
|
||||
if (status != HAL_RET_OK) {
|
||||
return status;
|
||||
}
|
||||
} else if (board_config->led.enable) {
|
||||
/* Use default initialization if no function provided */
|
||||
hal_gpio_config_t gpio_config = {
|
||||
.port = board_config->led.port,
|
||||
.pin = board_config->led.pin,
|
||||
.mode = board_config->led.mode,
|
||||
.speed = board_config->led.speed,
|
||||
.pull = board_config->led.pull
|
||||
};
|
||||
status = hal_gpio_configure_pin(&gpio_config);
|
||||
if (status != HAL_RET_OK) {
|
||||
return status;
|
||||
/* Initialize LEDs */
|
||||
if (board_config->leds.enable) {
|
||||
for (i = 0; i < board_config->leds.count; i++) {
|
||||
if (board_config->init_funcs.led_init != NULL) {
|
||||
status = board_config->init_funcs.led_init(&board_config->leds.leds[i]);
|
||||
if (status != HAL_RET_OK) {
|
||||
return status;
|
||||
}
|
||||
} else {
|
||||
/* Use default initialization if no function provided */
|
||||
hal_gpio_config_t gpio_config = {
|
||||
.port = board_config->leds.leds[i].port,
|
||||
.pin = board_config->leds.leds[i].pin,
|
||||
.mode = board_config->leds.leds[i].mode,
|
||||
.speed = board_config->leds.leds[i].speed,
|
||||
.pull = board_config->leds.leds[i].pull
|
||||
};
|
||||
status = hal_gpio_configure_pin(&gpio_config);
|
||||
if (status != HAL_RET_OK) {
|
||||
return status;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -142,18 +146,20 @@ hal_ret_t bsp_gpio_init(void) {
|
||||
hal_ret_t status = HAL_RET_OK;
|
||||
uint8_t i;
|
||||
|
||||
/* Initialize LED GPIO */
|
||||
if (board_config->led.enable) {
|
||||
hal_gpio_config_t gpio_config = {
|
||||
.port = board_config->led.port,
|
||||
.pin = board_config->led.pin,
|
||||
.mode = board_config->led.mode,
|
||||
.speed = board_config->led.speed,
|
||||
.pull = board_config->led.pull
|
||||
};
|
||||
status = hal_gpio_configure_pin(&gpio_config);
|
||||
if (status != HAL_RET_OK) {
|
||||
return status;
|
||||
/* Initialize LED GPIOs */
|
||||
if (board_config->leds.enable) {
|
||||
for (i = 0; i < board_config->leds.count; i++) {
|
||||
hal_gpio_config_t gpio_config = {
|
||||
.port = board_config->leds.leds[i].port,
|
||||
.pin = board_config->leds.leds[i].pin,
|
||||
.mode = board_config->leds.leds[i].mode,
|
||||
.speed = board_config->leds.leds[i].speed,
|
||||
.pull = board_config->leds.leds[i].pull
|
||||
};
|
||||
status = hal_gpio_configure_pin(&gpio_config);
|
||||
if (status != HAL_RET_OK) {
|
||||
return status;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -306,6 +306,30 @@ static const bsp_adc_config_t stm32f407vet6_adcs[] = {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief STM32F407VET6 board LED configurations
|
||||
*/
|
||||
static const bsp_led_config_t stm32f407vet6_leds[] = {
|
||||
/* LED0 - PA6 */
|
||||
{
|
||||
.enable = 1,
|
||||
.port = HAL_GPIO_PORT_A,
|
||||
.pin = HAL_GPIO_PIN_6,
|
||||
.mode = HAL_GPIO_MODE_OUTPUT_PP,
|
||||
.speed = HAL_GPIO_SPEED_MEDIUM,
|
||||
.pull = HAL_GPIO_PULL_NO
|
||||
},
|
||||
/* LED1 - PA7 */
|
||||
{
|
||||
.enable = 1,
|
||||
.port = HAL_GPIO_PORT_A,
|
||||
.pin = HAL_GPIO_PIN_7,
|
||||
.mode = HAL_GPIO_MODE_OUTPUT_PP,
|
||||
.speed = HAL_GPIO_SPEED_MEDIUM,
|
||||
.pull = HAL_GPIO_PULL_NO
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief STM32F407VET6 board configuration
|
||||
*/
|
||||
@ -343,13 +367,10 @@ const bsp_board_config_t stm32f407vet6_board_config = {
|
||||
},
|
||||
|
||||
/* Peripheral configurations */
|
||||
.led = {
|
||||
.leds = {
|
||||
.enable = 1,
|
||||
.port = HAL_GPIO_PORT_E,
|
||||
.pin = HAL_GPIO_PIN_5,
|
||||
.mode = HAL_GPIO_MODE_OUTPUT_PP,
|
||||
.speed = HAL_GPIO_SPEED_MEDIUM,
|
||||
.pull = HAL_GPIO_PULL_NO
|
||||
.count = sizeof(stm32f407vet6_leds) / sizeof(bsp_led_config_t),
|
||||
.leds = stm32f407vet6_leds
|
||||
},
|
||||
.buttons = stm32f407vet6_buttons_config,
|
||||
.w25qxx = {
|
||||
|
||||
Reference in New Issue
Block a user