#ifndef __UART_LOG_H__
#define __UART_LOG_H__

#include "stm32h7xx_hal.h"

#define UART_LOG_BAUDRATE (2 * 1000 * 1000)

#define HAL_TIMEOUT_VALUE 0xFFFFFFFF

#define USART_LOG                        USART1
#define USART_LOG_CLK_ENABLE()           __HAL_RCC_USART1_CLK_ENABLE()
#define USART_LOG_RX_GPIO_CLK_ENABLE()   __HAL_RCC_GPIOB_CLK_ENABLE()
#define USART_LOG_TX_GPIO_CLK_ENABLE()   __HAL_RCC_GPIOB_CLK_ENABLE()

#define __HAL_RCC_UART_LOG_CONFIG        __HAL_RCC_USART1_CONFIG
#define RCC_UART_LOG_CLKSOURCE_HSI       RCC_USART16CLKSOURCE_HSI

#define RCC_PERIPHCLK_USART_LOG          RCC_PERIPHCLK_USART16
#define RCC_USART_LOG_CLKSOURCE_HSI      RCC_USART16CLKSOURCE_HSI

#define USART_LOG_FORCE_RESET()          __HAL_RCC_USART1_FORCE_RESET()
#define USART_LOG_RELEASE_RESET()        __HAL_RCC_USART1_RELEASE_RESET()

#define USART_LOG_IRQn                   USART1_IRQn
#define USART_LOG_IRQHandler             USART1_IRQHandler

#define USART_LOG_TX_PIN                 GPIO_PIN_14
#define USART_LOG_TX_GPIO_PORT           GPIOB
#define USART_LOG_TX_AF                  GPIO_AF4_USART1
#define USART_LOG_RX_PIN                 GPIO_PIN_15
#define USART_LOG_RX_GPIO_PORT           GPIOB
#define USART_LOG_RX_AF                  GPIO_AF4_USART1

#ifdef __cplusplus
 extern "C" {
#endif

void uart_log_init(void);

#ifdef __cplusplus
}
#endif

#endif /* __UART_LOG_H__ */
