/* board_init.h */
#ifndef __BOARD_INIT_H__
#define __BOARD_INIT_H__

#include <stdio.h>
#include <stdint.h>

#include "hal_common.h"
#include "hal_rcc.h"
#include "hal_uart.h"
#include "hal_qspi.h"

#include "clock_init.h"
#include "pin_init.h"

/* DEBUG UART. */
#define BOARD_DEBUG_UART_PORT        UART1
#define BOARD_DEBUG_UART_BAUDRATE    9600u
#define BOARD_DEBUG_UART_FREQ        CLOCK_APB2_FREQ

/* SOFT SPI. */
#define BOARD_SOFTSPI_DELAY_CNT         100
#define BOARD_SOFTSPI_NSS_GPIO_PORT     GPIOB
#define BOARD_SOFTSPI_NSS_GPIO_PIN      GPIO_PIN_10
#define BOARD_SOFTSPI_SCK_GPIO_PORT     GPIOG
#define BOARD_SOFTSPI_SCK_GPIO_PIN      GPIO_PIN_7
#define BOARD_SOFTSPI_MOSI_GPIO_PORT    GPIOG
#define BOARD_SOFTSPI_MOSI_GPIO_PIN     GPIO_PIN_6
#define BOARD_SOFTSPI_MISO_GPIO_PORT    GPIOA
#define BOARD_SOFTSPI_MISO_GPIO_PIN     GPIO_PIN_3

#define BOARD_SPIFLASH_WRITE_TIMEOUT    1000

void BOARD_Init(void);
void softspi_xfer(uint8_t * write_buf, uint32_t write_size, uint8_t * read_buf, uint32_t read_size);

#endif /* __BOARD_INIT_H__ */
