#ifndef _SPI_H_
#define _SPI_H_

#include "spi_drv.h"


//SPI1
void  SPI1_Init(void);
UINT16  SPI1_ReadWriteByte(uint16_t TxData);

//SPI2
void SPI2_Initial(void);
UINT16  SPI2_ReadWriteByte(UINT16 TxData);

//SPI3
void SPI3_Initial(void);
u16  SPI3_ReadWriteByte(UINT16 TxData);
void SPI3_SetSpeed(u16 speed);
void SPI3_DMA_Tran(UINT8* Tx_Addr, UINT8* Rx_Addr, UINT32 length);
void SPI3_DMA_Wait(void);


void SPIMaster_Init(SPI_TypeDef* SPIx,u32 speedScaler,u8 dataBit);
void SPISlave_Init(SPI_TypeDef* SPIx,u32 speedScaler,u8 dataBit);

u8 SPIMaster_ReadByte(SPI_TypeDef* SPIx);
u16 SPIMaster_ReadHWord(SPI_TypeDef* SPIx);
u32 SPIMaster_ReadWord(SPI_TypeDef* SPIx);
void SPIMaster_ReadBytes(SPI_TypeDef* SPIx, u8 *buffer, UINT16 lenght);
void SPIMaster_WriteByte(SPI_TypeDef* SPIx,u8 data); 
void SPIMaster_WriteHWord(SPI_TypeDef* SPIx,u16 data);
void SPIMaster_WriteWord(SPI_TypeDef* SPIx,u32 data);
void SPIMaster_WriteBytes(SPI_TypeDef* SPIx,u8 *buffer,u16 length);
u8 SPISlave_ReadByte(SPI_TypeDef* SPIx); 
u16 SPISlave_ReadHWord(SPI_TypeDef* SPIx);
u32 SPISlave_ReadWord(SPI_TypeDef* SPIx);
void SPISlave_ReadBytes(SPI_TypeDef* SPIx,u8 *buffer,u16 length);
void SPISlave_WriteByte(SPI_TypeDef* SPIx,u8 data); 
void SPISlave_WriteHWord(SPI_TypeDef* SPIx,u16 data);
void SPISlave_WriteWord(SPI_TypeDef* SPIx,u32);
void SPISlave_WriteBytes(SPI_TypeDef* SPIx,u8 *buffer,u16 length);



#endif
