/* USER CODE BEGIN Header */
/**
  ******************************************************************************
  * @file           : bsp_board.h
  * @brief          : Board support package board abstraction header file
  ******************************************************************************
  */
/* USER CODE END Header */

#ifndef BSP_BOARD_H
#define BSP_BOARD_H

#include <stdint.h>
#include "hal_gpio.h"
#include "hal_uart.h"
#include "hal_spi.h"

/**
 * @brief Board LED configuration structure
 */
typedef struct {
    hal_gpio_port_t port;
    hal_gpio_pin_t pin;
    hal_gpio_mode_t mode;
    hal_gpio_speed_t speed;
    hal_gpio_pull_t pull;
} bsp_led_config_t;

/**
 * @brief Board button configuration structure
 */
typedef struct {
    hal_gpio_port_t port;
    hal_gpio_pin_t pin;
    hal_gpio_mode_t mode;
    hal_gpio_speed_t speed;
    hal_gpio_pull_t pull;
    uint8_t active_high;
} bsp_button_config_t;

/**
 * @brief Board buttons configuration structure
 */
typedef struct {
    uint8_t count;
    const bsp_button_config_t* buttons;
} bsp_buttons_config_t;

/**
 * @brief UART instance identifier definitions
 */
typedef enum {
    BSP_UART_INSTANCE_1 = 0,
    BSP_UART_INSTANCE_2,
    BSP_UART_INSTANCE_3,
    BSP_UART_INSTANCE_4,
    BSP_UART_INSTANCE_5,
    BSP_UART_INSTANCE_6,
    BSP_UART_INSTANCE_MAX
} bsp_uart_instance_t;

/**
 * @brief Board UART configuration structure
 */
typedef struct {
    bsp_uart_instance_t instance;
    uint32_t baudrate;
    hal_uart_parity_t parity;
    hal_uart_stopbits_t stopbits;
    hal_uart_databits_t databits;
    hal_gpio_port_t tx_port;
    hal_gpio_pin_t tx_pin;
    hal_gpio_port_t rx_port;
    hal_gpio_pin_t rx_pin;
} bsp_uart_config_t;

/**
 * @brief Board SPI configuration structure
 */
typedef struct {
    hal_spi_instance_t instance;
    hal_spi_mode_t mode;
    uint32_t baudrate;
    hal_spi_polarity_t polarity;
    hal_spi_phase_t phase;
    hal_spi_databits_t databits;
} bsp_spi_config_t;

/**
 * @brief Board W25QXX configuration structure
 */
typedef struct {
    hal_gpio_port_t cs_port;
    hal_gpio_pin_t cs_pin;
    bsp_spi_config_t spi_config;
} bsp_w25qxx_config_t;

/**
 * @brief Board peripheral initialization function type
 */
typedef void (*bsp_periph_init_func_t)(const void* config);

/**
 * @brief Board configuration structure
 */
typedef struct {
    const char* name;
    bsp_led_config_t led;
    bsp_buttons_config_t buttons;
    bsp_uart_config_t uart;
    bsp_w25qxx_config_t w25qxx;
    
    /* Initialization function pointers */
    bsp_periph_init_func_t led_init;
    bsp_periph_init_func_t button_init;
    bsp_periph_init_func_t uart_init;
    bsp_periph_init_func_t w25qxx_init;
    
    /* Additional board-specific configuration */
    uint32_t clock_speed;
    uint8_t uart_count;
} bsp_board_config_t;

/**
 * @brief STM32F407VET6 board configuration extern declaration
 */
extern const bsp_board_config_t stm32f407vet6_board_config;

/**
 * @brief Board hardware initialization
 */
void bsp_board_init(void);

/**
 * @brief Get board name
 * @retval Board name string
 */
const char* bsp_board_get_name(void);

#endif /* BSP_BOARD_H */
