#ifndef __SN32F100_I2S_H
#define __SN32F100_I2S_H

/*_____ I N C L U D E S ____________________________________________________*/


/*_____ D E F I N I T I O N S ______________________________________________*/
#define INTERNAL_CODEC

#ifdef INTERNAL_CODEC
	#include "..\Codec\Audio_codec.h"
#else		// external 
	#define I2S_CHANNEL_LENGTH  32
	#define I2S_DATA_LENGTH     24
	#include <SN32F100.h>
#endif

#define I2S_TXFIFO_THRESHOLD  4
#define I2S_RXFIFO_THRESHOLD  4

#define I2S_TX_SEND_MAX (8-I2S_TXFIFO_THRESHOLD+1)

#define I2S_STANDARD_FORMAT  0
#define I2S_LEFTJUST_FORMAT  1
#define I2S_RIGHTJUST_FORMAT 2

#define I2S_MASTER_MODE 0
#define I2S_SLAVE_MODE  1

#define I2S_TX 0
#define I2S_RX 1

#define I2S_STEREO 0
#define I2S_MONO   1

#define I2S_CLK_PCLK 0
#define I2S_CLK_AUEHS 1

#define I2S_LOCAL_BUF_NUM 16

/*_____ M A C R O S ________________________________________________________*/
//I2S HCLK Enable/Disable
#define	__I2S_ENABLE_I2SHCLK					SN_SYS1->AHBCLKEN |= (1<<22)
#define	__I2S_DISABLE_I2SHCLK					SN_SYS1->AHBCLKEN &= ~(1<<22)

//I2S Clear FIFO
#define	__I2S_RESET_FIFO		(SN_I2S->CTRL_b.CLRFIFO = I2S_CLRFIFO_RESET_FIFO)

//I2S Start
#define	__I2S_START					(SN_I2S->CTRL_b.START = 1)

/*_____ D E C L A R A T I O N S ____________________________________________*/
extern uint8_t Tx_Pointer;
extern uint8_t Rx_Pointer;

extern void I2S_init(void);
extern void I2S_SendData(uint32_t *data);
extern void I2S_ReceiveData(uint32_t *data);
extern uint32_t I2S_FIFO[I2S_LOCAL_BUF_NUM];

#endif	/*__SN32F100_I2S_H*/
