/***************************************************************************
   Copyright (c) 1995-2004, ADLink Technology Inc.  All rights reserved.   
                                                                          
   File Name   :   HSL.H		                                            
   Purpose     :   Header file for HSL-init.C module                       
   Date        :   06/25/2004
   Programmer  :   Gilbert Yen	                                            
***************************************************************************/

#ifndef HSL_H
#define HSL_H

#ifdef __cplusplus
extern "C" {
#endif

#ifndef HSL_RTX
	#define HSL_WINDOWS
#endif

#if defined ( HSL_WINDOWS ) || defined ( HSL_RTX )
	#ifndef FNTYPE
		#define FNTYPE _stdcall
	#endif
#elif defined ( HSL_LINUX )
	#ifndef FNTYPE
	   #define FNTYPE
	#endif	
#endif

#include "type_def.h"
/***************************************************************************
*		Mode Code of Value-Keeping Mode
****************************************************************************/
#define	KEEP_MODE_KEEP	(0)
#define KEEP_MODE_CLEAR	(1)

/****************************************************************************/
/*      Function  Declerations                                              */
/****************************************************************************/

// Initialization and System Information Section
I16 FNTYPE HSL_initial(I16 card_ID);
I16 FNTYPE HSL_close(I16 card_ID);
I16 FNTYPE HSL_auto_start(I16 card_ID, I16 connect_index);
I16 FNTYPE HSL_start(I16 card_ID, I16 connect_index, I16 max_slave_No);
I16 FNTYPE HSL_stop(I16 card_ID, I16 connect_index);
I16 FNTYPE HSL_connect_status(I16 card_ID, I16 connect_index, I16 slave_No, I16 *sts_data);
I16 FNTYPE HSL_slave_live(I16 card_ID, I16 connect_index, I16 slave_No, I16 *live_data);
void FNTYPE HSL_get_irq_channel(I16 card_ID, I16 *irq_no);
I16 FNTYPE HSL_get_slave_type(I16 card_ID, I16 connect_index, I16 slave_No, U16 *type_data);
I16 FNTYPE HSL_get_slave_ID_types(I16 card_ID, I16 connect_index, I16 slave_No, I16 *type_data, I16 *count);
I16 FNTYPE HSL_get_start_axisno(I16 card_ID, I16 connect_index, I16 slave_No, I16 *start_axis);                         /* RTX don't support */
I16 FNTYPE HSL_set_scan_condition(I16 card_ID, I16 connect_index, I16 comm_type, I16 transfer_rate, I16 hub_number);	/* ONLY FOR 7853/54) */
I16 FNTYPE HSL_get_scan_condition(I16 card_ID, I16 connect_index, I16 *comm_type, I16 *transfer_rate, I16 *hub_number); /* ONLY FOR 7853/54) */
 
/* Reserved function */
I16 FNTYPE HSL_initial_without_reset(I16 card_ID);
I16 FNTYPE HSL_auto_start_without_reset(I16 card_ID, I16 connect_index);
I16 FNTYPE HSL_start_without_reset(I16 card_ID, I16 connect_index, I16 max_slave_No);
I16 FNTYPE HSL_initial_sw(I32 *card_ID_inBit, I16 sw_enable );
I16 FNTYPE HSL_get_version(I16 card_ID, I32 *Firmware_Version, I32 *Driver_Version, I32 *Software_Version);
I16 FNTYPE HSL_set_handshake_method(I16 card_ID, I16 connect_index, I16 Handshake_Method);                             /* ONLY 7853/4 & RTX don't support */
I16 FNTYPE HSL_get_handshake_method(I16 card_ID, I16 connect_index, I16 *Handshake_Method);                            /* ONLY 7853/4 & RTX don't support */

// Timer Control Section
I16 FNTYPE HSL_set_timer(I16 card_ID, I16 c1, I16 c2);			                                                       /* ONLY FOR 7851/2 & RTX don't support */
I16 FNTYPE HSL_enable_timer_interrupt(I16 card_ID, HANDLE *phEvent);                                                   /* ONLY FOR 7851/2 & RTX don't support */
I16 FNTYPE HSL_disable_timer_interrupt(I16 card_ID);                                                                   /* ONLY FOR 7851/2 & RTX don't support */

I16 FNTYPE HSL_set_int_timer(I16 card_ID, U16 c1);					                                                   /* ONLY FOR 7853/54 */
I16 FNTYPE HSL_set_int_timer_enable(I16 card_ID, I16 enable);							                               /* ONLY FOR 7853/54 */
I16 FNTYPE HSL_wait_timer_interrupt(I16 card_ID, I32 time_out_ms);						                               /* ONLY FOR 7853/54 */

// DIO
I16 FNTYPE HSL_D_write_output(I16 card_ID, I16 connect_index, I16 slave_No, U32 out_data);
I16 FNTYPE HSL_D_write_channel_output(I16 card_ID, I16 connect_index, I16 slave_No, I16 channel, U16 out_data);
I16 FNTYPE HSL_D_read_input(I16 card_ID, I16 connect_index, I16 slave_No, U32 *in_data);
I16 FNTYPE HSL_D_read_channel_input(I16 card_ID, I16 connect_index, I16 slave_No, I16 channel, U16 *in_data);
I16 FNTYPE HSL_D_read_output(I16 card_ID, I16 connect_index, I16 slave_No, U32 *out_data_in_ram);
I16 FNTYPE HSL_D_read_all_slave_input(I16 card_ID, I16 connect_index, U16 *in_data);
I16 FNTYPE HSL_D_write_all_slave_output(I16 card_ID, I16 connect_index, U16 *out_data);
I16 FNTYPE HSL_D_set_input_logic(I16 card_ID, I16 connect_index, I16 slave_No, I16 input_logic);
I16 FNTYPE HSL_D_set_output_logic(I16 card_ID, I16 connect_index, I16 slave_No, I16 output_logic);
I16 FNTYPE HSL_D_write_slave_output(I16 card_ID, I16 connect_index, I16 slave_No, U16 out_data);
I16 FNTYPE HSL_D_read_slave_output(U16 card_ID, U16 connect_index, I16 slave_No, U16 *data_out);
I16 FNTYPE HSL_D_read_slave_input(U16 card_ID, U16 connect_index, I16 slave_No, U16 *data_in);

//DI INTERRUPT (ONLY FOR 7853/54)
I16 FNTYPE HSL_D_set_int_renewal_type(I16 card_ID, I16 connect_index, I16 renewal_type);					           /* ONLY FOR 7853/54 */
I16 FNTYPE HSL_D_set_int_renewal_bit(I16 card_ID, I16 connect_index, I16 slave_No, U16 bitsOfCheck);	               /* ONLY FOR 7853/54 */
I16 FNTYPE HSL_D_set_int_control(I16 card_ID, I16 connect_index, I16 enable);						                   /* ONLY FOR 7853/54 */
I16 FNTYPE HSL_D_wait_di_interrupt(I16 card_ID, I32 time_out_ms);

//DI Interrupt for call back function
I16 FNTYPE HSL_D_link_interrupt(I16 card_ID,void ( __stdcall *callbackAddr)(void));		                               /* ONLY FOR 7853/54 & RTX don't support */
I16 FNTYPE HSL_D_manual_reset_dievent(I16 card_ID);		                                                               /* ONLY FOR 7853/54 */

// FOR DI16-UL
I16 FNTYPE HSL_D_set_di_latch_function(I16 card_ID, I16 connect_index, I16 slave_No, I16 channel, I16 active_mode, I16 duration);
I16 FNTYPE HSL_D_set_di_latch_functionA(I16 card_ID, I16 connect_index, I16 slave_No, I16 edge, I16 duration);
I16 FNTYPE HSL_D_get_di_latch_function(I16 card_ID, I16 connect_index, I16 slave_No, I16 channel, I16 *active_mode, I16 *duration);

// AIO
I16 FNTYPE HSL_A_start_read(I16 card_ID, I16 connect_index);
I16 FNTYPE HSL_A_stop_read(I16 card_ID, I16 connect_index);
I16 FNTYPE HSL_A_set_signal_range(I16 card_ID, I16 connect_index, I16 slave_No, I16 signal_range);
I16 FNTYPE HSL_A_get_signal_range(I16 card_ID, I16 connect_index, I16 slave_No, I16 *signal_range);
I16 FNTYPE HSL_A_get_input_mode(I16 card_ID, I16 connect_index, I16 slave_No, I16 *mode);
I16 FNTYPE HSL_A_set_last_channel(I16 card_ID, I16 connect_index, I16 slave_No, I16 last_channel);
I16 FNTYPE HSL_A_get_last_channel(I16 card_ID, I16 connect_index, I16 slave_No, I16 *last_channel);
I16 FNTYPE HSL_A_read_input(I16 card_ID, I16 connect_index, I16 slave_No, I16 ai_channel, F64 *ai_data);
I16 FNTYPE HSL_A_write_output(I16 card_ID, I16 connect_index, I16 slave_No, I16 ao_channel, F64 ao_data);
I16 FNTYPE HSL_A_read_output(I16 card_ID, I16 connect_index, I16 slave_No, I16 ao_channel, F64 *ao_data);
I16 FNTYPE HSL_A_sync_rw(I16 card_ID, I16 connect_index, I16 slave_No, I16 ai_channel, F64 *ai_data, I16 ao_channel, F64 ao_data);
I16 FNTYPE HSL_A_get_version(I16 card_ID, I16 connect_index, I16 slave_No, I16 *ver);
// AO4
I16 FNTYPE HSL_set_keep_mode(I16 card_ID, I16 connect_index, I16 slave_No, I16 Mode);

//ODM function
I16 FNTYPE HSL_D_write_channel_output_SP(I16 card_ID, I16 connect_index, I16 slave_No, I16 channel, U16 out_data);

/****************************************************************************/
// The following function declarations are old								*/
/****************************************************************************/
U16 FNTYPE W_HSL_Initial(U16 card_ID);
U16 FNTYPE W_HSL_Close(U16 card_ID);
U16 FNTYPE W_HSL_Auto_Start(U16 card_ID, U16 connect_index);
U16 FNTYPE W_HSL_Start(U16 card_ID, U16 connect_index, U16 max_slave_No);
U16 FNTYPE W_HSL_Stop(U16 card_ID, U16 connect_index);
U16 FNTYPE W_HSL_Connect_Status(U16 card_ID, U16 connect_index, U16 slave_No, U8 *sts_data);
U16 FNTYPE W_HSL_Slave_Live(U16 card_ID, U16 connect_index, U16 slave_No, U8 *live_data);

void FNTYPE W_HSL_Software_Reset(U16 card_ID);
void FNTYPE W_HSL_Get_IRQ_Channel(U16 card_ID, U16 *irq_no);

U16 FNTYPE W_HSL_DIO_In(U16 card_ID, U16 connect_index, U16 slave_No, U32 *in_data);
U16 FNTYPE W_HSL_DIO_Channel_In(U16 card_ID, U16 connect_index, U16 slave_No, U16 channel, U16 *in_data);
U16 FNTYPE W_HSL_DIO_Out(U16 card_ID, U16 connect_index, U16 slave_No, U32 out_data);
U16 FNTYPE W_HSL_DIO_Channel_Out(U16 card_ID, U16 connect_index, U16 slave_No, U16 channel, U16 out_data);
U16 FNTYPE W_HSL_DI8DO8_DIO_In(U16 card_ID, U16 connect_index, U16 slave_No, U16 *in_data);
U16 FNTYPE W_HSL_DI8DO8_DIO_Channel_In(U16 card_ID, U16 connect_index, U16 slave_No, U16 channel, U16 *in_data);
U16 FNTYPE W_HSL_DI8DO8_DIO_Out(U16 card_ID, U16 connect_index, U16 slave_No, U16 out_data);
U16 FNTYPE W_HSL_DI8DO8_DIO_Channel_Out(U16 card_ID, U16 connect_index, U16 slave_No, U16 channel, U16 out_data);
U16 FNTYPE W_HSL_Read_DIO_Out(U16 card_ID, U16 connect_index, U16 slave_No, U32 *out_data_in_ram);
U16 FNTYPE W_HSL_Read_DIO_Channel_Out(U16 card_ID, U16 connect_index, U16 slave_No, U16 channel, U16 *out_channel_data_in_ram);
U16 FNTYPE W_HSL_Read_DI8DO8_Out(U16 card_ID, U16 connect_index, U16 slave_No, U16 *out_data_in_ram);
U16 FNTYPE W_HSL_Read_DI8DO8_Channel_Out(U16 card_ID, U16 connect_index, U16 slave_No, U16 channel, U16 *out_channel_data_in_ram);
U16 FNTYPE W_HSL_Set_In_Out_Logic(U16 card_ID, U16 connect_index, U16 slave_No, U16 Input_Logic, U16 Output_Logic);

U16 FNTYPE W_HSL_AI_Start_Read(U16 card_ID, U16 connect_index);
U16 FNTYPE W_HSL_AI_Stop_Read(U16 card_ID, U16 connect_index);
U16 FNTYPE W_HSL_AI_Channel_In(U16 card_ID, U16 connect_index, U16 slave_No, U16 channel, F64 *ai_data);
U16 FNTYPE W_HSL_AI_SetConfig(U16 card_ID, U16 connect_index, U16 slave_No, U16 signal_range, U16 signal_type, U16 cjc_status);
U16 FNTYPE W_HSL_AI_GetConfig(U16 card_ID, U16 connect_index, U16 slave_No, U16 *signal_range, U16 *signal_type, U16 *cjc_status);
U16 FNTYPE W_HSL_AI_OffsetCalib(U16 card_ID, U16 connect_index, U16 slave_No);
U16 FNTYPE W_HSL_AI_SpanCalib(U16 card_ID, U16 connect_index, U16 slave_No);
U16 FNTYPE W_HSL_AI_WriteDefault(U16 card_ID, U16 connect_index, U16 slave_No);
U16 FNTYPE W_HSL_AI_SetCJCOffset(U16 card_ID, U16 connect_index, U16 slave_No, F64 CJC_data2);
U16 FNTYPE W_HSL_AI_GetCJCOffset(U16 card_ID, U16 connect_index, U16 slave_No, F64 *CJC_data);
U16 FNTYPE W_HSL_AI_SetChannelStatus(U16 card_ID, U16 connect_index, U16 slave_No, U32 enable_chans);
U16 FNTYPE W_HSL_AI_GetChannelStatus(U16 card_ID, U16 connect_index, U16 slave_No, U32 *enable_chans);

U16 FNTYPE W_HSL_Timer_Set(U16 card_ID, U16 c1, U16 c2);
U16 FNTYPE W_HSL_TMRINT_Enable(U16 card_ID, HANDLE *phEvent);
U16 FNTYPE W_HSL_TMRINT_Disable(U16 card_ID);

U16 FNTYPE W_HSL_DIO_Memory_In(U16 card_ID, U16 connect_index, U16 *data_in);
U16 FNTYPE W_HSL_DIO_Memory_Out(U16 card_ID, U16 connect_index, U16 *data_out);

// AI16AO2 Module Use
U16 FNTYPE W_HSL_AI_Set_Last_Channel(U16 card_ID, U16 connect_index, U16 slave_No, U16 Last_Channel); // Used to set last channel
U16 FNTYPE W_HSL_AI_Get_Last_Channel(U16 card_ID, U16 connect_index, U16 slave_No, U16 *Last_Channel); // Used to set last channel
U16 FNTYPE W_HSL_AI_Get_Version(U16 card_ID, U16 connect_index, U16 slave_No, U8 *Ver);
U16 FNTYPE W_HSL_AIO_LoadConfig(U16 card_ID, U16 connect_index, U16 slave_No);
U16 FNTYPE W_HSL_AIO_SaveConfig(U16 card_ID, U16 connect_index, U16 slave_No);
U16 FNTYPE W_HSL_AO_Channel_Out(U16 card_ID, U16 connect_index, U16 slave_No, U16 AO_Ch_No, F64 AO_data);
U16 FNTYPE W_HSL_AIO_Channel_InOut(U16 card_ID, U16 connect_index, U16 slave_No, U16 AI_CH_No, F64 *AI_data, U16 AO_Ch_No, F64 AO_data);
U16 FNTYPE W_HSL_AO_Channel_In(U16 card_ID, U16 connect_index, U16 slave_No, U16 AO_Ch_No, U16 *AO_data);
U16 FNTYPE W_HSL_AO_OffsetCalib(U16 card_ID, U16 connect_index, U16 slave_No, U16 DA_CH);
U16 FNTYPE W_HSL_AO_GainCalib(U16 card_ID, U16 connect_index, U16 slave_No, U16 DA_CH);

// TC08 Use
U16 FNTYPE W_HSL_TC08_Offset_Calib(U16 card_ID, U16 connect_index, U16 slave_No, U16 channel);
U16 FNTYPE W_HSL_TC08_Span_Calib(U16 card_ID, U16 connect_index, U16 slave_No, U16 channel);
U16 FNTYPE W_HSL_TC08_Get_Temperature(U16 card_ID, U16 connect_index, U16 slave_No, U16 channel, U16 TC_type, F64 *Temperature);

U32* FNTYPE W_HSL_DIO_Memory_Ptr(U16 card_ID, U16 connect_index);

#ifdef __cplusplus
}
#endif

#endif
