/*!
 * @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_Soft_Slave
  @{
*/

/** @defgroup SPI_Soft_Slave_INT_Variables INT_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_IN,
    .speed = GPIO_SPEED_50MHz,
    .pupd = GPIO_PUPD_PU,
    .pin = (uint16_t)SPI_NSS_PIN,
};

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

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

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

Eint_ConfigType g_spiSckEintConfig = {
    .line    =  (uint32_t)SPI_SCK_EXTI_LINE,
    .lineCmd =  ENABLE,
    .mode    =  EINT_MODE_INTERRUPT,
    .trigger =  EINT_TRIGGER_ALL,
};

SoftSpi_ConfigType g_spi_slave_cfg = {
    .mode = SPI_MODE_0,
    .set_miso = (SoftSpi_PinSetPtr)&Spi_SetMiso,
    .set_miso_output_type = (SoftSpi_PinSetPtr)&Spi_SetMisoOutputType,
    .read_mosi = (SoftSpi_PinReadPtr)&Spi_ReadMosi,
    .set_sck = (SoftSpi_PinSetPtr)&Spi_SetSck,
    .read_sck = (SoftSpi_PinReadPtr)&Spi_ReadSck,
    .read_cs = (SoftSpi_PinReadPtr)&Spi_ReadCs,
};
    
/**@} end of group SPI_Soft_Slave_INT_Variables */
/**@} end of group SPI_Soft_Slave */
/**@} end of group SPI_Examples */
/**@} end of group Examples */
