#pragma once

#include <stm32h7xx_hal.h>
#include <stm32h7xx_ll_gpio.h>

namespace bsp_private
{
void initializeLEDs();
void initializeRTC();
void initializeSystemClocks();
void initializeMotorizedValve();
} // namespace bsp_private

// TODO - prevent these from being copies

constexpr uint8_t LED_COUNT = 2;
const auto LED_OK_PORT = GPIOB; // Green is either PB0 or PA5)
constexpr auto LED_OK_PIN = GPIO_PIN_0;
const auto LED_ERROR_PORT = GPIOB;
constexpr auto LED_ERROR_PIN = GPIO_PIN_14;

// TODO: this is just a placeholder
const auto VALVE_COMMAND_PORT = GPIOD;
constexpr auto VALVE_COMMAND_PIN = GPIO_PIN_5;
const auto VALVE_OPEN_STATUS_PORT = GPIOD;
constexpr auto VALVE_OPEN_STATUS_PIN = GPIO_PIN_5;
const auto VALVE_READY_STATUS_PORT = GPIOD;
constexpr auto VALVE_READY_STATUS_PIN = GPIO_PIN_5;

/*************
 * UART Pins *
 ************/

const auto USART1_TX_PORT = GPIOB;
constexpr auto USART1_TX_PIN = GPIO_PIN_6;
const auto USART1_RX_PORT = GPIOB;
constexpr auto USART1_RX_PIN = GPIO_PIN_7;
constexpr auto USART1_ALT_FUNC_SETTING = LL_GPIO_AF_7;

const auto USART2_TX_PORT = GPIOD;
constexpr auto USART2_TX_PIN = GPIO_PIN_5;
const auto USART2_RX_PORT = GPIOD;
constexpr auto USART2_RX_PIN = GPIO_PIN_7;
constexpr auto USART2_ALT_FUNC_SETTING = LL_GPIO_AF_7;

// TODO: this is just a placeholder
const auto USART3_TX_PORT = GPIOD;
constexpr auto USART3_TX_PIN = GPIO_PIN_5;
const auto USART3_RX_PORT = GPIOD;
constexpr auto USART3_RX_PIN = GPIO_PIN_5;
constexpr auto USART3_ALT_FUNC_SETTING = LL_GPIO_AF_7;

// TODO: this is just a placeholder
const auto UART4_TX_PORT = GPIOD;
constexpr auto UART4_TX_PIN = GPIO_PIN_5;
const auto UART4_RX_PORT = GPIOD;
constexpr auto UART4_RX_PIN = GPIO_PIN_5;
// Could also be AF8 in some pinouts
constexpr auto UART4_ALT_FUNC_SETTING = LL_GPIO_AF_6;

// TODO: this is just a placeholder
const auto UART5_TX_PORT = GPIOD;
constexpr auto UART5_TX_PIN = GPIO_PIN_5;
const auto UART5_RX_PORT = GPIOD;
constexpr auto UART5_RX_PIN = GPIO_PIN_5;
// Could also be AF14 in some pinouts
constexpr auto UART5_ALT_FUNC_SETTING = LL_GPIO_AF_8;

// TODO: this is just a placeholder
const auto USART6_TX_PORT = GPIOD;
constexpr auto USART6_TX_PIN = GPIO_PIN_5;
const auto USART6_RX_PORT = GPIOD;
constexpr auto USART6_RX_PIN = GPIO_PIN_5;
constexpr auto USART6_ALT_FUNC_SETTING = LL_GPIO_AF_7;

// TODO: this is just a placeholder
const auto UART7_TX_PORT = GPIOD;
constexpr auto UART7_TX_PIN = GPIO_PIN_5;
const auto UART7_RX_PORT = GPIOD;
constexpr auto UART7_RX_PIN = GPIO_PIN_5;
// Could also be AF11 in some pinouts
constexpr auto UART7_ALT_FUNC_SETTING = LL_GPIO_AF_7;

// TODO: this is just a placeholder
const auto UART8_TX_PORT = GPIOD;
constexpr auto UART8_TX_PIN = GPIO_PIN_5;
const auto UART8_RX_PORT = GPIOD;
constexpr auto UART8_RX_PIN = GPIO_PIN_5;
constexpr auto UART8_ALT_FUNC_SETTING = LL_GPIO_AF_8;

// TODO: this is just a placeholder
const auto UART9_TX_PORT = GPIOD;
constexpr auto UART9_TX_PIN = GPIO_PIN_5;
const auto UART9_RX_PORT = GPIOD;
constexpr auto UART9_RX_PIN = GPIO_PIN_5;
constexpr auto UART9_ALT_FUNC_SETTING = LL_GPIO_AF_11;

// TODO: this is just a placeholder
const auto USART10_TX_PORT = GPIOD;
constexpr auto USART10_TX_PIN = GPIO_PIN_5;
const auto USART10_RX_PORT = GPIOD;
constexpr auto USART10_RX_PIN = GPIO_PIN_5;
/* USART10 may also be AF11*/
constexpr auto USART10_ALT_FUNC_SETTING = LL_GPIO_AF_4;

/************
 * I2C Pins *
 ***********/

// Could also be PB6/PB7 (AF4)
const auto I2C1_SCL_PORT = GPIOB;
constexpr auto I2C1_SCL_PIN = GPIO_PIN_8;
const auto I2C1_SDA_PORT = GPIOB;
constexpr auto I2C1_SDA_PIN = GPIO_PIN_9;
constexpr auto I2C1_ALT_FUNC_SETTING = LL_GPIO_AF_4;

// Could also be PF0/PF1 (AF4)
const auto I2C2_SCL_PORT = GPIOB;
constexpr auto I2C2_SCL_PIN = GPIO_PIN_10;
const auto I2C2_SDA_PORT = GPIOB;
constexpr auto I2C2_SDA_PIN = GPIO_PIN_11;
constexpr auto I2C2_ALT_FUNC_SETTING = LL_GPIO_AF_4;

const auto I2C3_SCL_PORT = GPIOA;
constexpr auto I2C3_SCL_PIN = GPIO_PIN_8;
const auto I2C3_SDA_PORT = GPIOC;
constexpr auto I2C3_SDA_PIN = GPIO_PIN_9;
constexpr auto I2C3_ALT_FUNC_SETTING = LL_GPIO_AF_4;

// Could also be PB8/PB9 (AF6)
// Could also be PF14, PF15 (AF4)
const auto I2C4_SCL_PORT = GPIOB;
constexpr auto I2C4_SCL_PIN = GPIO_PIN_6;
const auto I2C4_SDA_PORT = GPIOD;
constexpr auto I2C4_SDA_PIN = GPIO_PIN_7;
constexpr auto I2C4_ALT_FUNC_SETTING = LL_GPIO_AF_6;
