#pragma once

#ifdef TUSB0214DAM_EXPORTS
#define TUSB0214DAM_API __declspec(dllexport) __stdcall
#else
#define TUSB0214DAM_API __declspec(dllexport) __stdcall
#endif

typedef	ULONG	TU_STATUS;

// DAC動作設定構造体
typedef	struct
{
	UINT8 Mode;			//動作モード 0:固定値出力 1:連続波形ゲート動作 2:連続波形トリガ動作 3:FIFO動作
	UINT8 ClkSel;		//連続波形の時のクロックソース 0:内部 1:外部入力
	UINT8 GTSel;		//連続波形の時のゲート/トリガソース 0:内部 1:外部入力
	UINT8 ExGtInv;		//外部ゲート信号論理反転 0:反転しない(Lowの時出力) 1:反転する ※ゲートの時のみ　トリガの場合は反転しない
	UINT8 Rstc;			//波形出力モードがゲートの時にゲート停止から再びゲート開始になった時に波形メモリカウンタをリセットするか　0:する 1:しない
	UINT8 Option;		//オプション　予約機能 0を設定する
	UINT8 FStat;		//波形出力停止時の状態選択(2ch分) 0:波形メモリの最終値 1:停止時出力指定値
	UINT16 FVal;		//波形停止時出力指定値
	UINT16 RepCyc;		//トリガ動作波形出力回数 0~65535 (0の時は制限なし)
}stSettings;

#ifdef __cplusplus
extern "C" {
#endif

	TU_STATUS TUSB0214DAM_API TUSB0214DAM_Connect(LPCSTR SerialNumber);
	TU_STATUS TUSB0214DAM_API TUSB0214DAM_DisConnect(LPCSTR SerialNumber);
	TU_STATUS TUSB0214DAM_API TUSB0214DAM_Dio_Dir(LPCSTR SerialNumber, UINT8 DirData);
	TU_STATUS TUSB0214DAM_API TUSB0214DAM_Dio_Dir_R(LPCSTR SerialNumber, UINT8 *DirData);
	TU_STATUS TUSB0214DAM_API TUSB0214DAM_Dio_In(LPCSTR SerialNumber, UINT8 *InData);
	TU_STATUS TUSB0214DAM_API TUSB0214DAM_Dio_Out(LPCSTR SerialNumber, UINT8 OutData);
	TU_STATUS TUSB0214DAM_API TUSB0214DAM_Dio_Out_R(LPCSTR SerialNumber, UINT8 *OutData);
	TU_STATUS TUSB0214DAM_API TUSB0214DAM_Exs_Sel(LPCSTR SerialNumber, UINT8 OutSel0, UINT8 OutSel1);
	TU_STATUS TUSB0214DAM_API TUSB0214DAM_Exs_Sel_R(LPCSTR SerialNumber, UINT8 *OutSel0, UINT8 *OutSel1);
	TU_STATUS TUSB0214DAM_API TUSB0214DAM_Clock_Gen(LPCSTR SerialNumber, UINT8 MSel, UINT32 DivideN);
	TU_STATUS TUSB0214DAM_API TUSB0214DAM_DacChSet(LPCSTR SerialNumber, UINT8 MSel, stSettings* Damset);
	TU_STATUS TUSB0214DAM_API TUSB0214DAM_DacChSet_R(LPCSTR SerialNumber, UINT8 MSel, stSettings* Damset);
	TU_STATUS TUSB0214DAM_API TUSB0214DAM_WavImgSet(LPCSTR SerialNumber, UINT8 MSel, UINT16 *WImage, INT32 Len);
	TU_STATUS TUSB0214DAM_API TUSB0214DAM_Fifo_ImgSet(LPCSTR SerialNumber, UINT8 Ch, UINT16 *WImage, INT32 Len);
	TU_STATUS TUSB0214DAM_API TUSB0214DAM_Fifo_Clr(LPCSTR SerialNumber, UINT8 Ch);
	TU_STATUS TUSB0214DAM_API TUSB0214DAM_Fifo_Status(LPCSTR SerialNumber, UINT8 *Over, UINT8 *Under, UINT32 *DataLen);
	TU_STATUS TUSB0214DAM_API TUSB0214DAM_Trigger(LPCSTR SerialNumber, UINT8 MSel, UINT8 SSel);
	TU_STATUS TUSB0214DAM_API TUSB0214DAM_Trigger_Stat(LPCSTR SerialNumber, UINT8 MSel, UINT8 *Stat);
	TU_STATUS TUSB0214DAM_API TUSB0214DAM_GateSet(LPCSTR SerialNumber, UINT8 MSel, UINT8 GateEn);
	TU_STATUS TUSB0214DAM_API TUSB0214DAM_GateSet_R(LPCSTR SerialNumber, UINT8 MSel, UINT8 *GateEn);
	TU_STATUS TUSB0214DAM_API TUSB0214DAM_RangeSet(LPCSTR SerialNumber, UINT8 Ch, UINT8 Range);
	TU_STATUS TUSB0214DAM_API TUSB0214DAM_RangeSet_R(LPCSTR SerialNumber, UINT8 Ch, UINT8 *Range);
	TU_STATUS TUSB0214DAM_API TUSB0214DAM_DacValSet(LPCSTR SerialNumber, UINT8 Ch, UINT16 NVal);
	TU_STATUS TUSB0214DAM_API TUSB0214DAM_DacValSet_R(LPCSTR SerialNumber, UINT8 Ch, UINT16 *NVal);
	TU_STATUS TUSB0214DAM_API TUSB0214GetCalibedVal(LPCSTR SerialNumber, UINT8 Ch, UINT8 range, UINT16 rawVal, UINT16* calibedVal);
	TU_STATUS TUSB0214DAM_API TUSB0214GetRawValFromCalibed(LPCSTR SerialNumber, UINT8 Ch, UINT8 range, UINT16 calibedVal, UINT16* pRawVal);
	TU_STATUS TUSB0214DAM_API TUSB0214DAM_EXIO_Sel(LPCSTR SerialNumber, UINT8 EXIOSel0, UINT8 EXIOSel1);
	TU_STATUS TUSB0214DAM_API TUSB0214DAM_EXIO_Sel_R(LPCSTR SerialNumber, UINT8 *EXIOSel0, UINT8 *EXIOSel1);
	TU_STATUS TUSB0214DAM_API TUSB0214DAM_EXIO_In(LPCSTR SerialNumber, UINT8 *InData);

#ifdef __cplusplus
}
#endif
