#ifndef _JESD_CSU_H_
#define _JESD_CSU_H_

#include "typedef.h"

#define JS_204B_CONVERTER_BITS		16	// 12
#define JS_204B_CS_BITS				0	// 2
#define JS_204B_CF_VAL				0

#define JESD_CSU_RX0_TAG				0
#define JESD_CSU_RX1_TAG				1
#define JESD_CSU_TX0_TAG				2
#define JESD_CSU_TX1_TAG				3
typedef enum _tagJesdCsuCh
{
	JESD_CSU_CH0 = 0,
	JESD_CSU_CH1 = 1
}numJesdCsuCh;

typedef struct _tagJesdCsuPara
{
	uint8_t antNum;	// 天线数
	uint8_t cf;
	uint8_t cs;		// 控制字, =2
	uint8_t n;		// iq数据精度, = 12
	uint8_t m;		// 天线数*2
	uint8_t nTotal;	// n+cs+padding
	uint8_t seq;	
	uint8_t margin;
	uint8_t reserved;
}stJesdCsuPara;

typedef struct _tagJesdCsuNodePara
{
	uint32_t dataAddr;
	uint32_t yStep;
	uint32_t allNum;
}stJesdCsuNodePara; 

int32_t jesd_csu_init(uint8_t antNum, uint8_t margin);

int32_t jesd_csu_rx_inlatch_thres_cfg(uint8_t ch, uint32_t send_threshold, uint32_t almostfull_threshold);

int32_t jesd_csu_rx_list_init(uint32_t listAddr, uint32_t nodeNum, stJesdCsuNodePara* pListNode);

int32_t jesd_csu_tx_list_init(uint32_t listAddr, uint32_t nodeNum, stJesdCsuNodePara* pListNode);

int32_t jesd_csu_rx_dmaReg_Cfg(uint8_t ch, uint32_t listAddr, uint32_t nodeNum);

int32_t jesd_csu_tx_dmaReg_Cfg(uint8_t ch, uint32_t listAddr, uint32_t nodeNum);

int32_t jesd_csu_rx_start(uint8_t ch);

int32_t jesd_csu_tx_start(uint8_t ch);

int32_t jesd_csu_start();

#endif

