/* USER CODE BEGIN Header */
/**
  ******************************************************************************
  * @file           : hal_stm32f4.h
  * @brief          : STM32F4 architecture specific HAL header file
  ******************************************************************************
  */
/* USER CODE END Header */

#ifndef HAL_STM32F4_H
#define HAL_STM32F4_H

/* Include STM32F4 HAL headers */
#include "stm32f4xx_hal.h"

/* Include common HAL headers */
#include "../../hal_delay.h"
#include "../../hal_gpio.h"
#include "../../hal_uart.h"

/**
 * @brief STM32F4 specific initialization
 */
void hal_stm32f4_init(void);

/**
 * @brief STM32F4 specific delay initialization
 */
void hal_stm32f4_delay_init(void);

/**
 * @brief STM32F4 specific delay in milliseconds
 * @param ms: Delay time in milliseconds
 */
void hal_stm32f4_delay_ms(uint32_t ms);

/**
 * @brief STM32F4 specific delay in microseconds
 * @param us: Delay time in microseconds
 */
void hal_stm32f4_delay_us(uint32_t us);

/**
 * @brief STM32F4 specific get tick implementation
 * @return Current tick count in milliseconds
 */
uint32_t hal_stm32f4_get_tick(void);

/**
 * @brief STM32F4 specific GPIO initialization
 */
void hal_stm32f4_gpio_init(void);

/**
 * @brief STM32F4 specific GPIO configure pin implementation
 * @param config: Pointer to GPIO configuration structure
 */
void hal_stm32f4_gpio_configure_pin(const hal_gpio_config_t *config);

/**
 * @brief STM32F4 specific GPIO write pin implementation
 * @param port: GPIO port
 * @param pin: GPIO pin
 * @param state: GPIO pin state
 */
void hal_stm32f4_gpio_write_pin(hal_gpio_port_t port, hal_gpio_pin_t pin, hal_gpio_pin_state_t state);

/**
 * @brief STM32F4 specific GPIO toggle pin implementation
 * @param port: GPIO port
 * @param pin: GPIO pin
 */
void hal_stm32f4_gpio_toggle_pin(hal_gpio_port_t port, hal_gpio_pin_t pin);

/**
 * @brief STM32F4 specific GPIO read pin implementation
 * @param port: GPIO port
 * @param pin: GPIO pin
 * @retval GPIO pin state
 */
hal_gpio_pin_state_t hal_stm32f4_gpio_read_pin(hal_gpio_port_t port, hal_gpio_pin_t pin);

/**
 * @brief STM32F4 specific UART initialization
 */
void hal_stm32f4_uart_init(void);

/**
 * @brief STM32F4 specific UART configuration
 * @param config: Pointer to UART configuration structure
 */
void hal_stm32f4_uart_config(const hal_uart_config_t *config);

/**
 * @brief STM32F4 specific UART send implementation
 * @param instance: UART instance
 * @param data: Pointer to data buffer
 * @param length: Data length
 */
void hal_stm32f4_uart_send(hal_uart_instance_t instance, const uint8_t *data, size_t length);

/**
 * @brief STM32F4 specific UART receive implementation
 * @param instance: UART instance
 * @param data: Pointer to data buffer
 * @param length: Data length
 * @retval Number of bytes received
 */
size_t hal_stm32f4_uart_receive(hal_uart_instance_t instance, uint8_t *data, size_t length);

/**
 * @brief STM32F4 specific UART TX ready check
 * @param instance: UART instance
 * @retval 1 if TX is ready, 0 otherwise
 */
uint8_t hal_stm32f4_uart_is_tx_ready(hal_uart_instance_t instance);

/**
 * @brief STM32F4 specific UART RX ready check
 * @param instance: UART instance
 * @retval 1 if RX is ready, 0 otherwise
 */
uint8_t hal_stm32f4_uart_is_rx_ready(hal_uart_instance_t instance);

#endif /* HAL_STM32F4_H */
