/*!
 * @file        user_spi_config.c
 *
 * @brief       SPI configurations
 *
 * @version     V1.0.0
 *
 * @date        2026-03-25
 *
 * @attention
 *
 *  Copyright (C) 2026 Geehy Semiconductor
 *
 *  You may not use this file except in compliance with the
 *  GEEHY COPYRIGHT NOTICE (Geehy Semiconductor Software License Agreement).
 *
 *  The program is only for reference, which is distributed in the hope
 *  that it will be useful and instructional for customers to develop
 *  their software. Unless required by applicable law or agreed to in
 *  writing, the program is distributed on an "AS IS" BASIS, WITHOUT
 *  ANY WARRANTY OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the Geehy Semiconductor Software License Agreement for the governing permissions
 *  and limitations under the License.
 */

/* Includes */
#include "user_spi_config.h"

/** @addtogroup Examples
  @{
*/

/** @addtogroup SPI_Examples
  @{
*/

/** @addtogroup SPI_TwoBoards_Slave
  @{
*/

/** @defgroup SPI_TwoBoards_Slave_Variables Variables
  @{
*/

/* SPI TX Buffer*/
uint8_t g_spiBufferTx[BUFF_SIZE] =
{
    0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0X07,
    0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0X07,
    0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0X07,
    0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0X07,
    0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0X07,
    0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0X07,
    0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0X07,
    0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0X07,
};

/* SPI Receive Buffer*/
uint8_t g_spiBufferRx[BUFF_SIZE] = {0};

Gpio_ConfigType g_spiNssConfig = {
    .mode = GPIO_MODE_AF,
    .speed = GPIO_SPEED_50MHz,
    .pupd = GPIO_PUPD_PU,
    .pin = (uint16_t)SPI_NSS_PIN,
};

Gpio_ConfigType g_spiSckConfig = {
    .mode = GPIO_MODE_AF,
    .speed = GPIO_SPEED_50MHz,
    .pupd = GPIO_PUPD_PU,
    .pin = (uint16_t)SPI_SCK_PIN,
};

Gpio_ConfigType g_spiMisoConfig = {
    .mode = GPIO_MODE_AF,
    .outtype = GPIO_OUT_TYPE_PP,
    .speed = GPIO_SPEED_50MHz,
    .pupd = GPIO_PUPD_PU,
    .pin = (uint16_t)SPI_MISO_PIN,
};

Gpio_ConfigType g_spiMosiConfig = {
    .mode = GPIO_MODE_AF,
    .speed = GPIO_SPEED_50MHz,
    .pupd = GPIO_PUPD_PU,
    .pin = (uint16_t)SPI_MOSI_PIN,
};

Spi_ConfigType g_spiFullDuplexConfig = {
    .mode = SPI_MODE_SLAVE,
    .polarity  = SPI_CLKPOL_LOW,
    .firstBit = SPI_FIRST_BIT_MSB,
    .slaveSelect = SPI_SSC_DISABLE,
    .phase = SPI_CLKPHA_1EDGE,
    .baudrateDiv = SPI_BAUDRATE_DIV_256,
    .length = SPI_DATA_LENGTH_8B,
    .direction   = SPI_DIRECTION_2LINES_FULLDUPLEX,
    .crcPolynomial = 7,
    .ssOutput = SPI_SSOEN_ENABLE,
    .threshold = SPI_RXFIFO_QUARTER,
    .bidirection = SPI_BMEN_ENABLE,
    .receiveOnly = SPI_RXOMEN_DISABLE,
};

Spi_ConfigType g_spiHalfDuplexConfig = {
    .mode = SPI_MODE_SLAVE,
    .polarity  = SPI_CLKPOL_LOW,
    .firstBit = SPI_FIRST_BIT_MSB,
    .slaveSelect = SPI_SSC_DISABLE,
    .phase = SPI_CLKPHA_1EDGE,
    .baudrateDiv = SPI_BAUDRATE_DIV_256,
    .length = SPI_DATA_LENGTH_8B,
    .direction   = SPI_DIRECTION_2LINES_FULLDUPLEX,
    .crcPolynomial = 7,
    .ssOutput = SPI_SSOEN_ENABLE,
    .threshold = SPI_RXFIFO_QUARTER,
    .bidirection = SPI_BMEN_DISABLE,
    .dataTransferDirection = SPI_BMOEN_DISABLE,
};

Spi_ConfigType g_spiSingleWireMrxStxConfig = {
    .mode = SPI_MODE_SLAVE,
    .polarity  = SPI_CLKPOL_LOW,
    .firstBit = SPI_FIRST_BIT_MSB,
    .slaveSelect = SPI_SSC_DISABLE,
    .phase = SPI_CLKPHA_1EDGE,
    .baudrateDiv = SPI_BAUDRATE_DIV_256,
    .length = SPI_DATA_LENGTH_8B,
    .direction   = SPI_DIRECTION_2LINES_FULLDUPLEX,
    .crcPolynomial = 7,
    .ssOutput = SPI_SSOEN_ENABLE,
    .threshold = SPI_RXFIFO_QUARTER,
    .bidirection = SPI_BMEN_DISABLE,
    .dataTransferDirection = SPI_BMOEN_ENABLE,
};

Spi_ConfigType g_spiSingleWireMtxSrxConfig = {
    .mode = SPI_MODE_SLAVE,
    .polarity  = SPI_CLKPOL_LOW,
    .firstBit = SPI_FIRST_BIT_MSB,
    .slaveSelect = SPI_SSC_DISABLE,
    .phase = SPI_CLKPHA_1EDGE,
    .baudrateDiv = SPI_BAUDRATE_DIV_256,
    .length = SPI_DATA_LENGTH_8B,
    .direction   = SPI_DIRECTION_2LINES_FULLDUPLEX,
    .crcPolynomial = 7,
    .ssOutput = SPI_SSOEN_ENABLE,
    .threshold = SPI_RXFIFO_QUARTER,
    .receiveOnly = SPI_RXOMEN_ENABLE,
};

/**@} end of group SPI_TwoBoards_Slave_Variables*/
/**@} end of group SPI_TwoBoards_Slave */
/**@} end of group SPI_Examples */
/**@} end of group Examples */
