107 lines
3.2 KiB
C
107 lines
3.2 KiB
C
/* USER CODE BEGIN Header */
|
|
/**
|
|
******************************************************************************
|
|
* @file : stm32f407vet6_board.c
|
|
* @brief : STM32F407VET6 board configuration implementation
|
|
******************************************************************************
|
|
*/
|
|
/* USER CODE END Header */
|
|
|
|
#include "bsp_board.h"
|
|
#include "bsp_config.h"
|
|
#include "hal_gpio.h"
|
|
#include "hal_uart.h"
|
|
|
|
/**
|
|
* @brief Default LED initialization function
|
|
* @param config: LED configuration structure
|
|
*/
|
|
static void default_led_init(const void* config) {
|
|
const bsp_led_config_t* led_config = (const bsp_led_config_t*)config;
|
|
hal_gpio_config_t gpio_config = {
|
|
.port = led_config->port,
|
|
.pin = led_config->pin,
|
|
.mode = led_config->mode,
|
|
.speed = led_config->speed,
|
|
.pull = led_config->pull
|
|
};
|
|
hal_gpio_configure_pin(&gpio_config);
|
|
}
|
|
|
|
/**
|
|
* @brief Default button initialization function
|
|
* @param config: Button configuration structure
|
|
*/
|
|
static void default_button_init(const void* config) {
|
|
const bsp_button_config_t* button_config = (const bsp_button_config_t*)config;
|
|
hal_gpio_config_t gpio_config = {
|
|
.port = button_config->port,
|
|
.pin = button_config->pin,
|
|
.mode = button_config->mode,
|
|
.speed = button_config->speed,
|
|
.pull = button_config->pull
|
|
};
|
|
hal_gpio_configure_pin(&gpio_config);
|
|
}
|
|
|
|
/**
|
|
* @brief Default UART initialization function
|
|
* @param config: UART configuration structure
|
|
*/
|
|
static void default_uart_init(const void* config) {
|
|
const bsp_uart_config_t* uart_config = (const bsp_uart_config_t*)config;
|
|
hal_uart_config_t uart_cfg = {
|
|
.instance = (hal_uart_instance_t)uart_config->instance,
|
|
.baudrate = uart_config->baudrate,
|
|
.parity = uart_config->parity,
|
|
.stopbits = uart_config->stopbits,
|
|
.databits = uart_config->databits
|
|
};
|
|
hal_uart_config(&uart_cfg);
|
|
}
|
|
|
|
/**
|
|
* @brief STM32F407VET6 board configuration
|
|
*/
|
|
const bsp_board_config_t stm32f407vet6_board_config = {
|
|
.name = BOARD_NAME,
|
|
.led = {
|
|
.port = BSP_LED_PORT,
|
|
.pin = BSP_LED_PIN,
|
|
.mode = HAL_GPIO_MODE_OUTPUT_PP,
|
|
.speed = HAL_GPIO_SPEED_MEDIUM,
|
|
.pull = HAL_GPIO_PULL_NO
|
|
},
|
|
.button = {
|
|
.port = 0, /* Not used */
|
|
.pin = 0, /* Not used */
|
|
.mode = HAL_GPIO_MODE_INPUT,
|
|
.speed = HAL_GPIO_SPEED_LOW,
|
|
.pull = HAL_GPIO_PULL_NO
|
|
},
|
|
.uart = {
|
|
.instance = BSP_UART_INSTANCE,
|
|
.baudrate = BSP_UART_BAUDRATE,
|
|
.parity = BSP_UART_PARITY,
|
|
.stopbits = BSP_UART_STOPBITS,
|
|
.databits = BSP_UART_DATABITS,
|
|
.tx_port = HAL_GPIO_PORT_A, /* USART1_TX - PA9 */
|
|
.tx_pin = HAL_GPIO_PIN_9,
|
|
.rx_port = HAL_GPIO_PORT_A, /* USART1_RX - PA10 */
|
|
.rx_pin = HAL_GPIO_PIN_10
|
|
},
|
|
.led_init = default_led_init,
|
|
.button_init = default_button_init,
|
|
.uart_init = default_uart_init,
|
|
.clock_speed = 168000000, /* 168 MHz */
|
|
.uart_count = 6
|
|
};
|
|
|
|
/**
|
|
* @brief Get board name
|
|
* @retval Board name string
|
|
*/
|
|
const char* bsp_board_get_name(void) {
|
|
return stm32f407vet6_board_config.name;
|
|
}
|