/******************** (C) COPYRIGHT 2022 SONiX *******************************
* COMPANY:	SONiX
* DATE:		2022/05/19
* AUTHOR:		Eden
* IC:			SN8F5835
*____________________________________________________________________________
* REVISION		Date				User		Description
* 1.0					2022/05/19	Eden		1. First release
*____________________________________________________________________________
*****************************************************************************/
/*_____ I N C L U D E S _________________________________*/
#include <SN8F5762.h>
#include "SPI.h"

/*_____ F U N C T I O N S _______________________________*/
void DUT_FillIn_SPI_TxData(uint8_t head);
/*_____ D E F I N I T I O N S ___________________________*/
#define SPI_TX_DATA_LEN 6
#define SPI_RX_DATA_LEN 16
/*_____ D E C L A R A T I O N S _________________________*/

/*_____ M A C R O S _____________________________________*/
xdata uint8_t bSPI_TxData[SPI_TX_DATA_LEN] = {0};
xdata uint8_t bSPI_RxData[SPI_RX_DATA_LEN] = {0};
/**
 *	@Brief		main: SPI Slave Test Demo Function
 *	@param		None
 *	@retval		None
 */

void main(void)
{
	uint8_t i=0;
	uint8_t clk_rate=3;			//clkdiv select
	uint8_t type=1;					//Mode select	
	uint8_t spi_interrupt=0;// 0:disable 1:enalbe SPI interrupt 
	uint8_t spi_init_data=0xa5;// spi first return data
  /*	Initialize GPIO status	*/
	GPIO_Initialization();		
	/*	Initialize SPI status	*/
	SPI_init(clk_rate,type,spi_interrupt,spi_init_data);
	
		
	// The transmitted Data and Data are shifted by 0x80.
	DUT_FillIn_SPI_TxData(0x80);

	while(1)
	{
		bSPI_RxData[bRX_count]=SPI_rx(bSPI_TxData[bRX_count],SPI_TX_DATA_LEN);
	}
}
void DUT_FillIn_SPI_TxData(uint8_t head)
{
	uint8_t i;
	
	/* Fill in 16 bytes to the tx Data buffer */
	for (i = 0; i < SPI_TX_DATA_LEN; i++)
	{
		bSPI_TxData[i] = head + i;
	}	

}
/**
 *	@Brief		Initialize GPIO status
 *	@param		None
 *	@retval		None
 */
void GPIO_Initialization(void)
{
/*	Set whole IOs to output low	*/
	IO_PORT0_OUTPUT_LOW
	IO_PORT1_OUTPUT_LOW
	IO_PORT2_OUTPUT_LOW
}