// I-8123W_API.h : main header file for the I-8123W_API DLL
//

//#ifndef __I8123W_H
//#define __I8123W_H

#ifdef __cplusplus
extern "C" {
#endif


//define type in Windows
#ifndef bool
#define bool int
#define false 	0
#define true	1
#endif
/*
#ifndef LARGE_INTEGER
typedef union _LARGE_INTEGER {
  struct {
    DWORD LowPart;
    long  HighPart;
  };
  struct {
    DWORD LowPart;
    long  HighPart;
  } u;
  long long QuadPart;
} LARGE_INTEGER;
#endif
*/
#ifndef HANDLE
#define HANDLE void*
#endif

/*typedef unsigned long 	DWORD
typedef unsigned short 	WORD
typedef unsigned char 	BYTE*/



// CANopen Master Error Code Define
#define CPM_NoError         0

#define CPM_SlotNumberErr   3

#define CPM_ConfigErr       5
#define CPM_MasterInitErr   6
#define CPM_MasterNotInit   7
#define CPM_ListenMode      8
#define CPM_NodeErr         9
#define CPM_NodeExist       10
#define CPM_AddModeErr		  11
#define CPM_TxBusy          12
#define CPM_UnknowCmd       13
#define CPM_CmdReceErr      14
#define CPM_DataEmpty       15
#define CPM_MemAllocErr     16
#define CPM_SendCycMsgErr   17
#define CPM_StatusErr       18

#define CPM_SetGuardErr     20 
#define CPM_SetHbeatErr     21 
#define CPM_SegLenErr       22
#define CPM_SegToggleErr    23
#define CPM_SegWriteErr     24 
#define CPM_Abort           25
#define CPM_PDOLenErr       26 
#define CPM_COBIDErr        27
#define CPM_PDOInstErr      28
#define CPM_PDODynaErr      29
#define CPM_PDONumErr       30
#define CPM_PDOSetErr       31
#define CPM_PDOEntryErr     32
#define CPM_SetCobIdErr     33
#define CPM_CycFullErr      34
#define CPM_Timeout         35
#define CPM_DataLenErr		36
#define CPM_SyncIdDifferent 37

#define CPM_Wait			40
#define CPM_Processing		41

#define CPM_LoadEDSErr		50
#define CPM_EDSFormatErr	51

// CANopen Master NMTErr Event Define
#define CPM_Node_Guarding_Event		1
#define CPM_Heartbeat_Event			2

// SYNC Group Send Stop State
#define CPM_SYNC_GROUP_COMPLETE		1
#define CPM_SYNC_GROUP_FAIL			2



////////////////////////////////////////
//	I-8123W function library
////////////////////////////////////////

////////////////////////////////////////
// Driver Version: 2.00
// Firmware Version: 2.01
// Function: I8123_GetVersion
// Description: Return I8123.dll version
// Parameter: void
////////////////////////////////////////
 WORD I8123_GetVersion(void);

////////////////////////////////////////
// Driver Version: 2.01
// Firmware Version: 2.01
// Function: I8123_SetFunctionTimeout
// Description: Set function timeout
// Parameter: SlotNo: WinPAC/ViewPAC slot no. 0 ~ 7. XPAC slot no. 1 ~ 7
//			  FunTimeout: Max timeout ms of per function (default value = 1000 ms).
////////////////////////////////////////
 void I8123_SetFunctionTimeout(BYTE SlotNo, DWORD FunTimeout);

////////////////////////////////////////
// Driver Version: 2.01
// Firmware Version: 2.01
// Function: I8123_GetCANStatus
// Description: Get CAN error status of the I-8123W slot module
// Parameter: SlotNo: WinPAC/ViewPAC slot no. 0 ~ 7. XPAC slot no. 1 ~ 7
//            *bStatus: get CAN error status 
////////////////////////////////////////
 WORD I8123_GetCANStatus(BYTE SlotNo, BYTE *bStatus);

///////////////////////////////////////
// Driver Version: 2.00
// Firmware Version: 2.01
// Function: I8123_InitMaster
// Description: Initial Master, must be call once before all others function
// Parameter: SlotNo: WinPAC/ViewPAC slot no. 0 ~ 7. XPAC slot no. 1 ~ 7
//			  Node: 0 is for normal Master, 1 ~ 127 are for Master of slave-mode.
//					The slave-mode Master has node id and can be controled by other CANopen device.
//					We have provided some ISR function for user to do this.
//			  BaudRate: 0 ~ 7 ==> 10 k ~ 1000 k bps
//			  BlockMode: Function Mode: Non-block function mode = 0, Block function mode = 1
////////////////////////////////////////
 WORD I8123_InitMaster(BYTE SlotNo, BYTE Node, BYTE BaudRate, BYTE BlockMode);

////////////////////////////////////////
// Driver Version: 2.00
// Firmware Version: 2.01
// Function: I8123_ShutdownMaster
// Description: Let I-8123W shutdown (reset)
// Parameter: SlotNo: WinPAC/ViewPAC slot no. 0 ~ 7. XPAC slot no. 1 ~ 7
////////////////////////////////////////
 WORD I8123_ShutdownMaster(BYTE SlotNo);

////////////////////////////////////////
// Driver Version: 2.01
// Firmware Version: 2.01
// Function: I8123_MasterSendBootupMsg
// Description: Let I-8123W send a boot up message (only for Master Node >= 1)
// Parameter: SlotNo: WinPAC/ViewPAC slot no. 0 ~ 7. XPAC slot no. 1 ~ 7
////////////////////////////////////////
 WORD I8123_MasterSendBootupMsg(BYTE SlotNo, BYTE BlockMode);

////////////////////////////////////////
// Driver Version: 2.00
// Firmware Version: 2.01
// Function: I8123_SetMasterMode
// Description: Set Master to normal mode or listen mode
// Parameter: SlotNo: WinPAC/ViewPAC slot no. 0 ~ 7. XPAC slot no. 1 ~ 7
//		      Mode: 0 is normal mode (default), 1 is listen mode (default)
//					If set the Master to listen mode, the Master will can't send any CANopen message
//			  BlockMode: Function Mode: Non-block function mode = 0, Block function mode = 1
////////////////////////////////////////
 WORD I8123_SetMasterMode(BYTE SlotNo, BYTE Mode, BYTE BlockMode);

////////////////////////////////////////
// Driver Version: 2.00
// Firmware Version: 2.01
// Function: I8123_GetMasterMode
// Description: Get Master mode
// Parameter: SlotNo: WinPAC/ViewPAC slot no. 0 ~ 7. XPAC slot no. 1 ~ 7
//		      *Mode: 0 is normal mode (default), 1 is listen mode
//			  BlockMode: Function Mode: Non-block function mode = 0, Block function mode = 1
////////////////////////////////////////
 WORD I8123_GetMasterMode(BYTE SlotNo, BYTE *Mode, BYTE BlockMode);

////////////////////////////////////////
// Driver Version: 2.00
// Firmware Version: 2.01
// Function: I8123_GetFirmwareVersion
// Description: Get I8123 firmware version
// Parameter: SlotNo: WinPAC/ViewPAC slot no. 0 ~ 7. XPAC slot no. 1 ~ 7
//			  *Fir_Ver: I-8123 firmware version
//			  BlockMode: Function Mode: Non-block function mode = 0, Block function mode = 1
////////////////////////////////////////
 WORD I8123_GetFirmwareVersion(BYTE SlotNo, WORD *Fir_Ver, BYTE BlockMode);

////////////////////////////////////////
// Driver Version: 2.01
// Firmware Version: 2.01
// Function: I8123_EDS_Load
// Description: Load EDS File
// Parameter: SlotNo: WinPAC/ViewPAC slot no. 0 ~ 7. XPAC slot no. 1 ~ 7
//		      Node: Slave Node
//			  *FilePath: EDS file path (ex: "\\Temp\\ABC.EDS")
//			  DelayTime: After send a CAN message will delay some time
//			  ResTimeout: Set CAN message timeout
////////////////////////////////////////
 WORD I8123_EDS_Load(BYTE SlotNo, BYTE Node, char* FilePath, WORD DelayTime, WORD ResTimeout, BYTE BlockMode);

////////////////////////////////////////
// Driver Version: 2.00 (AddMode 3 is for 2.01)
// Firmware Version: 2.01
// Function: I8123_AddNode
// Description: Add Slave Node to Master
// Parameter: SlotNo: WinPAC/ViewPAC slot no. 0 ~ 7. XPAC slot no. 1 ~ 7
//		      Node: Slave Node
//            AddMode: 1:Auto Add Node, 2:Add Manual, 3:Wait to Add
//			  DelayTime: After send a CAN message will delay some time
//			  ResTimeout: Set CAN message timeout
//			  BlockMode: Function Mode: Non-block function mode = 0, Block function mode = 1
////////////////////////////////////////
 WORD I8123_AddNode(BYTE SlotNo, BYTE Node, BYTE AddMode, WORD DelayTime, WORD ResTimeout, BYTE BlockMode);

////////////////////////////////////////
// Driver Version: 2.00
// Firmware Version: 2.01
// Function: I8123_RemoveNode
// Description: Remove Slave Node from Master
// Parameter: SlotNo: WinPAC/ViewPAC slot no. 0 ~ 7. XPAC slot no. 1 ~ 7
//		      Node: Slave Node Id
//			  BlockMode: Function Mode: Non-block function mode = 0, Block function mode = 1
////////////////////////////////////////
 WORD I8123_RemoveNode(BYTE SlotNo, BYTE Node, BYTE BlockMode);

////////////////////////////////////////
// Driver Version: 2.02
// Firmware Version: 2.03
// Function: I8123_RemoveAndResetNode
// Description: Remove Slave and then Reset Node from Master
// Parameter: SlotNo: WinPAC/ViewPAC slot no. 0 ~ 7. XPAC slot no. 1 ~ 7
//		      Node: Slave Node Id
//			  BlockMode: Function Mode: Non-block function mode = 0, Block function mode = 1
////////////////////////////////////////
 WORD I8123_RemoveAndResetNode(BYTE SlotNo, BYTE Node, BYTE BlockMode);

////////////////////////////////////////
// Driver Version: 2.04
// Firmware Version: 2.06
// Function: I8123_DelayAndResponseTimeout
// Description: Change delay time and response timeout value of the node
// Parameter: SlotNo: WinPAC/ViewPAC slot no. 0 ~ 7. XPAC slot no. 1 ~ 7
//		      Node: Slave Node Id
//			  DelayTime: After send a CAN message will delay some time
//			  ResTimeout: Set CAN message timeout 
//			  BlockMode: Function Mode: Non-block function mode = 0, Block function mode = 1
////////////////////////////////////////
 WORD I8123_DelayAndResponseTimeout(BYTE SlotNo, BYTE Node, WORD DelayTime, WORD ResTimeout, BYTE BlockMode);

////////////////////////////////////////
// Driver Version: 2.00
// Firmware Version: 2.01
// Function: I8123_ScanNode
// Description: Scan real node id on the CANopen bus
// Parameter: SlotNo: WinPAC/ViewPAC slot no. 0 ~ 7. XPAC slot no. 1 ~ 7
//		      S_Node: Start scan node id
//			  E_Node: End scan node id
//					  If S_Node > E_Node or E_Node = 0, will scan all node id (1~127)
//			  *NodeList: 16 BYTE Array. Return Node Id List of the CANopen Bus. Each bit represents a slave node
//			  BlockMode: Function Mode: Non-block function mode = 0, Block function mode = 1
////////////////////////////////////////
 WORD I8123_ScanNode(BYTE SlotNo, BYTE S_Node, BYTE E_Node, BYTE *NodeList, BYTE BlockMode);

////////////////////////////////////////
// Driver Version: 2.00
// Firmware Version: 2.01
// Function: I8123_GetNodeList
// Description: Get Node Id List of the Master had added
// Parameter: SlotNo: WinPAC/ViewPAC slot no. 0 ~ 7. XPAC slot no. 1 ~ 7
//			  *NodeList: 16 BYTE Array. Return Node Id List of the Master had added. Each bit represents a slave node
//			  BlockMode: Function Mode: Non-block function mode = 0, Block function mode = 1
////////////////////////////////////////
 WORD I8123_GetNodeList(BYTE SlotNo, BYTE *NodeList, BYTE BlockMode);

////////////////////////////////////////
// Driver Version: 2.00
// Firmware Version: 2.01
// Function: I8123_NMTChangeState
// Description: Set Node State
// Parameter: SlotNo: WinPAC/ViewPAC slot no. 0 ~ 7. XPAC slot no. 1 ~ 7
//			  Node: Slave Node Id
//			  State: NMT State 
//			        (1:Operation mode, 2:Stop mode, 128:Pre-operation mode, 129:Reset node, 130:Reset communication)
//			  BlockMode: Function Mode: Non-block function mode = 0, Block function mode = 1
////////////////////////////////////////
 WORD I8123_NMTChangeState(BYTE SlotNo, BYTE Node, BYTE State, BYTE BlockMode);

////////////////////////////////////////
// Driver Version: 2.00
// Firmware Version: 2.01
// Function: I8123_NMTGetState
// Description: Get Node State
// Parameter: SlotNo: WinPAC/ViewPAC slot no. 0 ~ 7. XPAC slot no. 1 ~ 7
//			  Node: Slave Node Id
//			  *State: Return NMT State
//					 (4:Stop mode, 5:Operation mode, 127:Pre-operation mode)
//			  BlockMode: Function Mode: Non-block function mode = 0, Block function mode = 1
////////////////////////////////////////
 WORD I8123_NMTGetState(BYTE SlotNo, BYTE Node, BYTE *State, BYTE BlockMode);

////////////////////////////////////////
// Driver Version: 2.00
// Firmware Version: 2.01
// Function: I8123_NMTGuarding
// Description: Start Guarding
// Parameter: SlotNo: WinPAC/ViewPAC slot no. 0 ~ 7. XPAC slot no. 1 ~ 7
//			  Node: Slave Node Id
//			  GuardTime: set index 0x100C 
//						(Master will send Guarding message per GuardTime ms).
//			  LiftTime: set index 0x100D 
//						(If Master doesn't receive Guarding response over LiftTime times, it will timeout and Node_Guarding_Event occur)
//						(The Guarding timeout = GuardTime * LiftTime )
//			  BlockMode: Function Mode: Non-block function mode = 0, Block function mode = 1
// Note 1: It is not allowed for one slave to use both Guarding protocol and Heartbeat protocol at the same time. 
// Node 2: In listen mode, the function will listen the Guarding message send from other Master to slave on the CANopen bus. 
////////////////////////////////////////
 WORD I8123_NMTGuarding(BYTE SlotNo, BYTE Node, WORD GuardTime, BYTE LiftTime, BYTE BlockMode);

////////////////////////////////////////
// Driver Version: 2.00
// Firmware Version: 2.01
// Function: I8123_NMTHeartbeat
// Description: Start Heartbeat
// Parameter: SlotNo: WinPAC/ViewPAC slot no. 0 ~ 7. XPAC slot no. 1 ~ 7
//			  Node: Slave Node Id
//			  ProduceTime: set index 0x1017
//			  ConsumeTime: Timeout of Heartbeat
//						   (ConsumeTime must more then ProduceTime)
//						   (If Master doesn't receive slave Heartbeat over ConsumeTime ms, it will timeout and Heartbeat_Event occur)
//			  BlockMode: Function Mode: Non-block function mode = 0, Block function mode = 1
// Note: It is not allowed for one slave to use both Guarding protocol and Heartbeat protocol at the same time.
// Node 2: In listen mode, the function will listen only and can't start Heartbeat protocol. So Heartbeat protocol must start from other Master. 
////////////////////////////////////////
 WORD I8123_NMTHeartbeat(BYTE SlotNo, BYTE Node, WORD ProduceTime, WORD ConsumeTime, BYTE BlockMode);

////////////////////////////////////////
// Driver Version: 2.00
// Firmware Version: 2.01
// Function: I8123_SDOReadData
// Description: SDO Read Data. If the data length is more than 1024 bytes, the Data will return NULL,
//				and user need uses CPM100_SDOReadFile to read the SDO data.
// Parameter: SlotNo: WinPAC/ViewPAC slot no. 0 ~ 7. XPAC slot no. 1 ~ 7
//			  Node: Slave Node Id
//			  Index: Index of Object Dectionary
//			  SubIndex: SubIndex of Object Dectionary
//			  *RDLen: Response Data Length
//			  *RData: Response Data (If RDLen >= 1024, this parameter will return NULL.)
//			  BlockMode: Function Mode: Non-block function mode = 0, Block function mode = 1
////////////////////////////////////////
 WORD I8123_SDOReadData(BYTE SlotNo, BYTE Node, WORD Index, BYTE SubIndex, DWORD *RDLen, BYTE *RData, BYTE BlockMode);

////////////////////////////////////////
// Driver Version: 2.01
// Firmware Version: 2.01
// Function: I8123_SDOReadFile
// Description: SDO Read File. After I8123_SDOReadData, if the data length is more than 1024 bytes,
//				user need uses this function to read the SDO data file.
// Parameter: SlotNo: WinPAC/ViewPAC slot no. 0 ~ 7. XPAC slot no. 1 ~ 7
//			  Node: Slave Node
//			  *Index: Index of Object Dectionary
//			  *SubIndex: SubIndex of Object Dectionary
//			  Start: Start position to read the SDO data file
//			  Len: Max read byte
//			  RDLen: Return read data length
//			  RData: Return data
////////////////////////////////////////
 WORD I8123_SDOReadFile(BYTE SlotNo, BYTE Node, WORD Index, BYTE SubIndex, DWORD Start, DWORD Len, DWORD *RDLen, BYTE *RData);

////////////////////////////////////////
// Driver Version: 2.00
// Firmware Version: 2.01
// Function: I8123_SDOWriteData
// Description: SDO Write Data
// Parameter: SlotNo: WinPAC/ViewPAC slot no. 0 ~ 7. XPAC slot no. 1 ~ 7
//			  Node: Slave Node Id
//			  Index: Index of Object Dectionary
//			  SubIndex: SubIndex of Object Dectionary
//			  TDLen: Write Data Length
//			  *TData: Write Data
//			  *RDLen: Response Data Length
//			  *RData: Response Data
//			  BlockMode: Function Mode: Non-block function mode = 0, Block function mode = 1
////////////////////////////////////////
 WORD I8123_SDOWriteData(BYTE SlotNo, BYTE Node, WORD Index, BYTE SubIndex, DWORD TDLen, BYTE *TData, WORD *RDLen, BYTE *RData, BYTE BlockMode);

////////////////////////////////////////
// Driver Version: 2.00
// Firmware Version: 2.01
// Function: I8123_SDOAbortTransmit
// Description: Send SDO Abort Message
// Parameter: SlotNo: WinPAC/ViewPAC slot no. 0 ~ 7. XPAC slot no. 1 ~ 7
//		      Node: Slave Node Id
//			  Index: Index of Object Dectionary
//			  SubIndex: SubIndex of Object Dectionary
//			  *TData:  Abort Data
//			  BlockMode: Function Mode: Non-block function mode = 0, Block function mode = 1
////////////////////////////////////////
 WORD I8123_SDOAbortTransmit(BYTE SlotNo, BYTE Node, WORD Index, BYTE SubIndex, DWORD TData, BYTE BlockMode);

////////////////////////////////////////
// Driver Version: 2.00
// Firmware Version: 2.01
// Function: I8123_PDOWrite
// Description: Output PDO data
// Parameter: SlotNo: WinPAC/ViewPAC slot no. 0 ~ 7. XPAC slot no. 1 ~ 7
//		      Cobid: PDO Cob Id
//			  DLen: Data Length
//			  *Data: PDO Data
//			  BlockMode: Function Mode: Non-block function mode = 0, Block function mode = 1
////////////////////////////////////////
 WORD I8123_PDOWrite(BYTE SlotNo, WORD Cobid, BYTE Offset, BYTE DLen, BYTE *Data, BYTE BlockMode);

////////////////////////////////////////
// Driver Version: 2.02
// Firmware Version: 2.02
// Function: I8123_PDOWrite_Fast
// Description: Output PDO data directly
// Parameter: SlotNo: WinPAC/ViewPAC slot no. 0 ~ 7. XPAC slot no. 1 ~ 7
//		      Cobid: PDO Cob Id
//			  DLen: Data Length
//			  Data: PDO Data
////////////////////////////////////////
 WORD I8123_PDOWrite_Fast(BYTE SlotNo, WORD Cobid, BYTE Offset, BYTE DLen, BYTE *Data);

////////////////////////////////////////
// Driver Version: 2.00
// Firmware Version: 2.01
// Function: I8123_PDORemote
// Description: Remote PDO data
// Parameter: SlotNo: WinPAC/ViewPAC slot no. 0 ~ 7. XPAC slot no. 1 ~ 7
//		      Cobid: PDO Cob Id
//			  *DLen: Response Data Length
//			  *Data: Response PDO Data
//			  BlockMode: Function Mode: Non-block function mode = 0, Block function mode = 1
////////////////////////////////////////
 WORD I8123_PDORemote(BYTE SlotNo, WORD Cobid, BYTE *DLen, BYTE *Data, BYTE BlockMode);

////////////////////////////////////////
// Driver Version: 2.03
// Firmware Version: 2.04
// Function: I8123_PDORemote_Fast
// Description: Send requst to remote PDO data, but do not check the response
// Parameter: SlotNo: WinPAC/ViewPAC slot no. 0 ~ 7. XPAC slot no. 1 ~ 7
//		      Cobid: PDO Cob Id
////////////////////////////////////////
 WORD I8123_PDORemote_Fast(BYTE SlotNo, WORD Cobid);

////////////////////////////////////////
// Driver Version: 2.01
// Firmware Version: 2.01
// Function: I8123_SetPDORemotePolling
// Description: Set PDO polling list for remote PDO (max 125 PDO one time)
// Parameter: SlotNo: WinPAC/ViewPAC slot no. 0 ~ 7. XPAC slot no. 1 ~ 7
//		      PDOCnt: Total PDO number that want to be polling 
//			  Cobid: PDO list that want to be polling
//			  PollingTime: Min. polling Time
//			  BlockMode: Function Mode: Non-block function mode = 0, Block function mode = 1
////////////////////////////////////////
 WORD I8123_SetPDORemotePolling(BYTE SlotNo, BYTE PDOCnt, WORD *Cobid, WORD PollingTime, BYTE BlockMode);

////////////////////////////////////////
// Driver Version: 2.00
// Firmware Version: 2.01
// Function: I8123_GetPDOLastData
// Description: Get PDO last data
// Parameter: SlotNo: WinPAC/ViewPAC slot no. 0 ~ 7. XPAC slot no. 1 ~ 7
//		      Cobid: PDO Cob Id
//			  *IsNew: Is new data, 0 is old data, 1 is new data
//			  *DLen: Get PDO Data Length
//			  *Data: Get PDO Data
//			  BlockMode: Function Mode: Non-block function mode = 0, Block function mode = 1
////////////////////////////////////////
 WORD I8123_GetPDOLastData(BYTE SlotNo, WORD Cobid, BYTE *IsNew, BYTE *DLen, BYTE *Data, BYTE BlockMode);

////////////////////////////////////////
// Driver Version: 2.03
// Firmware Version: 2.04
// Function: I8123_GetPDOLastData_Fast
// Description: Get PDO data from DPRAM directly
// Parameter: SlotNo: WinPAC/ViewPAC slot no. 0 ~ 7. XPAC slot no. 1 ~ 7
//		      Cobid: PDO Cob Id
//			  DLen: PDO Data Length
//			  Data: PDO Data
////////////////////////////////////////
 WORD I8123_GetPDOLastData_Fast(BYTE SlotNo, WORD Cobid, BYTE *DLen, BYTE *Data);

////////////////////////////////////////
// Driver Version: 2.01
// Firmware Version: 2.01
// Function: I8123_GetMultiPDOData
// Description: Get multi PDO data (this function can get max 50 PDO data every times)
// Parameter: SlotNo: WinPAC/ViewPAC slot no. 0 ~ 7. XPAC slot no. 1 ~ 7
//		      PDOCnt: Total PDO number that want to get 
//		      Cobid: All PDO Cob Id that want to get
//			  IsNew: Is new data, 0 is old data, 1 is new data
//			  DLen: PDO Data Length
//			  Data: PDO Data
//			  BlockMode: Function Mode: Non-block function mode = 0, Block function mode = 1
////////////////////////////////////////
 WORD I8123_GetMultiPDOData(BYTE SlotNo, BYTE PDOCnt, WORD *Cobid, BYTE *IsNew, BYTE *DLen, BYTE *Data, BYTE BlockMode);

////////////////////////////////////////
// Driver Version: 2.02
// Firmware Version: 2.02
// Function: I8123_GetMultiPDOData_Fast
// Description: Get multi PDO data from DPRAM directly
// Parameter: SlotNo: WinPAC/ViewPAC slot no. 0 ~ 7. XPAC slot no. 1 ~ 7
//		      PDOCnt: Total PDO number that want to get 
//		      Cobid: All PDO Cob Id that want to get
//			  DLen: PDO Data Length
//			  Data: PDO Data
////////////////////////////////////////
 WORD I8123_GetMultiPDOData_Fast(BYTE SlotNo, BYTE PDOCnt, WORD *Cobid, BYTE *DLen, BYTE *Data);

////////////////////////////////////////
// Driver Version: 2.00
// Firmware Version: 2.01
// Function: I8123_GetRxPDOID
// Description: Get Rx PDO Cob ID List of slave
// Parameter: SlotNo: WinPAC/ViewPAC slot no. 0 ~ 7. XPAC slot no. 1 ~ 7
//		      Node: Slave Node Id
//			  *PDO_Cnt: Response RxPDO ID total number
//			  *Id_List: Response *PDO_Cnt number RxPDO ID List
//			  BlockMode: Function Mode: Non-block function mode = 0, Block function mode = 1
////////////////////////////////////////
 WORD I8123_GetRxPDOID(BYTE SlotNo, BYTE Node, BYTE *PDO_Cnt, WORD *Id_List, BYTE BlockMode);

////////////////////////////////////////
// Driver Version: 2.00
// Firmware Version: 2.01
// Function: I8123_GetTxPDOID
// Description: Get Tx PDO Cob ID List of slave
// Parameter: SlotNo: WinPAC/ViewPAC slot no. 0 ~ 7. XPAC slot no. 1 ~ 7
//		      Node: Slave Node Id
//			  *PDO_Cnt: Response TxPDO ID total number
//			  *Id_List: Response *PDO_Cnt number TxPDO ID List
//			  BlockMode: Function Mode: Non-block function mode = 0, Block function mode = 1
////////////////////////////////////////
 WORD I8123_GetTxPDOID(BYTE SlotNo, BYTE Node, BYTE *PDO_Cnt, WORD *Id_List, BYTE BlockMode);

////////////////////////////////////////
// Driver Version: 2.00
// Firmware Version: 2.01
// Function: I8123_InstallPDO
// Description: Install PDO ID to Master
// Parameter: SlotNo: WinPAC/ViewPAC slot no. 0 ~ 7. XPAC slot no. 1 ~ 7
//		      Node: Slave Node Id
//			  Cobid: PDO Cob ID
//			  RxTx: 0 is RxPDO, 1 is TxPDO 
//			  PDO_No: PDO No. 0 ~ 511
//			  BlockMode: Function Mode: Non-block function mode = 0, Block function mode = 1
////////////////////////////////////////
 WORD I8123_InstallPDO(BYTE SlotNo, BYTE Node, WORD Cobid, BYTE RxTx, WORD PDO_No, BYTE BlockMode);

////////////////////////////////////////
// Driver Version: 2.00
// Firmware Version: 2.01
// Function: I8123_DynamicPDO
// Description: Dynamic PDO Mapping to Master
// Parameter: SlotNo: WinPAC/ViewPAC slot no. 0 ~ 7. XPAC slot no. 1 ~ 7
//		      Node: Slave Node Id
//			  Cobid: PDO Cob ID
//			  RxTx: 0 is RxPDO, 1 is TxPDO 
//			  Entry: Mapping Entry
//			  EntryData: Mapping Data
//			  BlockMode: Function Mode: Non-block function mode = 0, Block function mode = 1
////////////////////////////////////////
 WORD I8123_DynamicPDO(BYTE SlotNo, BYTE Node, WORD Cobid, BYTE RxTx, BYTE Entry, DWORD EntryData, BYTE BlockMode);

////////////////////////////////////////
// Driver Version: 2.00
// Firmware Version: 2.01
// Function: I8123_RemovePDO
// Description: Remove POD Entry
// Parameter: SlotNo: WinPAC/ViewPAC slot no. 0 ~ 7. XPAC slot no. 1 ~ 7
//		      Node: Slave Node Id
//			  Cobid: PDO Cob ID
//			  Entry: Remove Entry, 0 is for whole PDO
//			  BlockMode: Function Mode: Non-block function mode = 0, Block function mode = 1
////////////////////////////////////////
 WORD I8123_RemovePDO(BYTE SlotNo, BYTE Node, WORD Cobid, BYTE Entry, BYTE BlockMode);

////////////////////////////////////////
// Driver Version: 2.00
// Firmware Version: 2.01
// Function: I8123_ChangePDOID
// Description: Change POD ID
// Parameter: SlotNo: WinPAC/ViewPAC slot no. 0 ~ 7. XPAC slot no. 1 ~ 7
//		      Old_Cobid: Old Cobid
//			  New_Cobid: Want to change to New Cobid
//			  BlockMode: Function Mode: Non-block function mode = 0, Block function mode = 1
////////////////////////////////////////
 WORD I8123_ChangePDOID(BYTE SlotNo, WORD Old_Cobid, WORD New_Cobid, BYTE BlockMode);

////////////////////////////////////////
// Driver Version: 2.00
// Firmware Version: 2.01
// Function: I8123_GetPDOMapInfo
// Description: Get PDO mapping information
// Parameter: SlotNo: WinPAC/ViewPAC slot no. 0 ~ 7. XPAC slot no. 1 ~ 7
//		      Cobid: PDO Cobid
//			  *PDONo: Get PDO No.
//			  *RxTx: 0 is RxPDO, 1 is TxPDO
//			  *Tx_Type: Transmission Type
//			  *Event_Timer: Event Timer
//			  *Entry_Cnt: Total entry number
//			  *Map_Data: Mapping Data
//			  BlockMode: Function Mode: Non-block function mode = 0, Block function mode = 1
////////////////////////////////////////
 WORD I8123_GetPDOMapInfo(BYTE SlotNo, WORD Cobid, WORD *PDONo, BYTE *RxTx, BYTE *Tx_Type, WORD *Event_Timer, BYTE *Entry_Cnt, DWORD *Map_Data, BYTE BlockMode);

////////////////////////////////////////
// Driver Version: 2.00
// Firmware Version: 2.01
// Function: I8123_InstallPDO_List (Virtual List)
// Description: Install PDO and Mapping PDO Data to Master List.
//				This function like I8123_InstallPDO_List, but it only build a virtual PDO let Master
//				can control the PDO. The virtual PDO is not the real node slave necessarily.
// Parameter: SlotNo: WinPAC/ViewPAC slot no. 0 ~ 7. XPAC slot no. 1 ~ 7
//		      Node: Slave Node Id
//			  Cobid: PDO Cob ID
//			  RxTx: 0 is RxPDO, 1 is TxPDO
//			  PDO_No: PDO No. 
//			  TransmitType: Set transmission type
//			  EventTimer: Set event timer
//			  EntryUse: Total Mapping Entry
//			  *EntryData: DWORD array for Total Mapping Data
//			  BlockMode: Function Mode: Non-block function mode = 0, Block function mode = 1
////////////////////////////////////////
 WORD I8123_InstallPDO_List(BYTE SlotNo, BYTE Node, WORD Cobid, BYTE RxTx, WORD PDO_No, BYTE TransmitType, WORD EventTimer, BYTE EntryUse, DWORD *EntryData, BYTE BlockMode);

////////////////////////////////////////
// Driver Version: 2.00
// Firmware Version: 2.01
// Function: I8123_RemovePDO_List (Virtual List)
// Description: Remove PDO build from I8123_InstallPDO_List function
// Parameter: SlotNo: WinPAC/ViewPAC slot no. 0 ~ 7. XPAC slot no. 1 ~ 7
//		      Node: Slave Node Id
//			  Cobid: PDO Cob ID
//			  Entry: Remove Entry, 0 is for whole PDO
//			  BlockMode: Function Mode: Non-block function mode = 0, Block function mode = 1
////////////////////////////////////////
 WORD I8123_RemovePDO_List(BYTE SlotNo, BYTE Node, WORD Cobid, BYTE Entry, BYTE BlockMode);

////////////////////////////////////////
// Driver Version: 2.00
// Firmware Version: 2.01
// Function: I8123_PDOUseEntry
// Description: Change useful entry
// Parameter: SlotNo: WinPAC/ViewPAC slot no. 0 ~ 7. XPAC slot no. 1 ~ 7
//			  Cobid: PDO Cob ID
//			  Entry: useful entry
//			  BlockMode: Function Mode: Non-block function mode = 0, Block function mode = 1
////////////////////////////////////////
 WORD I8123_PDOUseEntry(BYTE SlotNo, WORD Cobid, BYTE Entry, BYTE BlockMode);

////////////////////////////////////////
// Driver Version: 2.00
// Firmware Version: 2.01
// Function: I8123_PDOTxType
// Description: Set PDO Transmission Type
// Parameter: SlotNo: WinPAC/ViewPAC slot no. 0 ~ 7. XPAC slot no. 1 ~ 7
//			  Cobid: PDO Cob ID
//			  Tx_Type: Transmission Type
//			  BlockMode: Function Mode: Non-block function mode = 0, Block function mode = 1
////////////////////////////////////////
 WORD I8123_PDOTxType(BYTE SlotNo, WORD Cobid, BYTE Tx_Type, BYTE BlockMode);

////////////////////////////////////////
// Driver Version: 2.00
// Firmware Version: 2.01
// Function: I8123_PDOEventTimer
// Description: Set PDO Event Timer
// Parameter: SlotNo: WinPAC/ViewPAC slot no. 0 ~ 7. XPAC slot no. 1 ~ 7
//			  Cobid: PDO Cob ID
//			  Timer: Event Timer
//			  BlockMode: Function Mode: Non-block function mode = 0, Block function mode = 1
////////////////////////////////////////
 WORD I8123_PDOEventTimer(BYTE SlotNo, WORD Cobid, WORD Timer, BYTE BlockMode);

////////////////////////////////////////
// Driver Version: 2.04
// Firmware Version: 2.06
// Function: I8123_PDOInhibitTime
// Description: Set PDO Inhibit Timer
// Parameter: SlotNo: WinPAC/ViewPAC slot no. 0 ~ 7. XPAC slot no. 1 ~ 7
//			  Cobid: PDO Cob ID
//			  Time: Inhibit Time
//			  BlockMode: Function Mode: Non-block function mode = 0, Block function mode = 1
////////////////////////////////////////
 WORD I8123_PDOInhibitTime(BYTE SlotNo, WORD Cobid, WORD Time, BYTE BlockMode);

////////////////////////////////////////
// Driver Version: 2.00
// Firmware Version: 2.01
// Function: I8123_ChangeSYNCID
// Description: Change SYNC ID
// Parameter: SlotNo: WinPAC/ViewPAC slot no. 0 ~ 7. XPAC slot no. 1 ~ 7
//			  Node: Slave Node Id
//			  Cobid: SYNC ID
//			  BlockMode: Function Mode: Non-block function mode = 0, Block function mode = 1
////////////////////////////////////////
 WORD I8123_ChangeSYNCID(BYTE SlotNo, BYTE Node, WORD Cobid, BYTE BlockMode);

////////////////////////////////////////
// Driver Version: 2.00
// Firmware Version: 2.01
// Function: I8123_SetSYNC_List (Virtual List)
// Description: Set or Change SYNC ID from Master
//				The function only build a virtual SYNC ID let Master can control it. 
//				The virtual SYNC ID is not the real one necessarily.
// Parameter: SlotNo: WinPAC/ViewPAC slot no. 0 ~ 7. XPAC slot no. 1 ~ 7
//		      Node: Slave Node Id
//			  Cobid: PDO Cob ID
//			  BlockMode: Function Mode: Non-block function mode = 0, Block function mode = 1
////////////////////////////////////////
 WORD I8123_SetSYNC_List(BYTE SlotNo, BYTE Node, WORD Cobid, BYTE BlockMode);

////////////////////////////////////////
// Driver Version: 2.00
// Firmware Version: 2.01
// Function: I8123_GetSYNCID
// Description: Get SYNC ID
// Parameter: SlotNo: WinPAC/ViewPAC slot no. 0 ~ 7. XPAC slot no. 1 ~ 7
//			  Node: Slave Node Id
//			  *Cobid: SYNC ID
//			  BlockMode: Function Mode: Non-block function mode = 0, Block function mode = 1
////////////////////////////////////////
 WORD I8123_GetSYNCID(BYTE SlotNo, BYTE Node, WORD *Cobid, BYTE BlockMode);

////////////////////////////////////////
// Driver Version: 2.00
// Firmware Version: 2.01
// Function: I8123_SendSYNCMsg
// Description: Send SYNC message, most send 5 different SYNC at the same time
// Parameter: SlotNo: WinPAC/ViewPAC slot no. 0 ~ 7. XPAC slot no. 1 ~ 7
//			  Cobid: SYNC ID
//			  Timer: Cyclic timer, 0 is stop or send 1 time SYNC message
//			  Times: Cyclic times, 0 is always contiune
//			  BlockMode: Function Mode: Non-block function mode = 0, Block function mode = 1
////////////////////////////////////////
 WORD I8123_SendSYNCMsg(BYTE SlotNo, WORD Cobid, WORD Timer, DWORD Times, BYTE BlockMode);

////////////////////////////////////////
// Driver Version: 2.05
// Firmware Version: 2.07
// Function: I8123_SyncGroupCycUpdata
// Description: Updata Step to SYNC Group Send Data, The Max Step buffer is 10 and Max PDO  
//				number per step is 5.
// Parameter: SlotNo: WinPAC/ViewPAC slot no. 0 ~ 7. XPAC slot no. 1 ~ 7
//			  StepNum: Cycle number of this update mission. This parameter is < 15 ( StepNum * RecordNum < 60 ).
//			  RecordNum: PDO number of this SYNC group. This parameter is < 32. (Every update, the PDO number of the group data must be the same.)
//			  *PDOId: PDO ID Array of these group data (Array type: WORD [RecordNum])
//			  *GroupData: Initial Data of output every PDO (Array type: BYTE [StepNum][RecordNum][8])
//			  BlockMode: Function Mode: Non-block function mode = 0, Block function mode = 1
////////////////////////////////////////
 WORD I8123_SyncGroupCycUpdata(BYTE SlotNo, BYTE StepNum, BYTE RecordNum, WORD *PDOId, BYTE *GroupData, BYTE BlockMode);

////////////////////////////////////////
// Driver Version: 2.05
// Firmware Version: 2.07
// Function: I8123_SyncGroupCycSend
// Description: Send SYNC Group Data with PDO message (Updata from I8123_SyncGroupCycUpdata)
// Parameter: SlotNo: WinPAC/ViewPAC slot no. 0 ~ 7. XPAC slot no. 1 ~ 7
//			  TotalCycle: Total Cycle for this Sync Group (must >= StepCycle of I8123_SyncGroupCycUpdata)
//			  StepInterval: Timer per cycle (unit 100us, Min is 5)
//			  BlockMode: Function Mode: Non-block function mode = 0, Block function mode = 1
////////////////////////////////////////
 WORD I8123_SyncGroupCycSend(BYTE SlotNo, DWORD TotalCycle, DWORD StepInterval, BYTE BlockMode);

////////////////////////////////////////
// Driver Version: 2.05
// Firmware Version: 2.07
// Function: I8123_SyncGroupClear
// Description: Clear All Step of the SYNC Group Send
// Parameter: SlotNo: WinPAC/ViewPAC slot no. 0 ~ 7. XPAC slot no. 1 ~ 7
//			  BlockMode: Function Mode: Non-block function mode = 0, Block function mode = 1
// Return: CPM_NoError, CPM_Timeout
////////////////////////////////////////
 WORD I8123_SyncGroupClear(BYTE SlotNo, BYTE BlockMode);

////////////////////////////////////////
// Driver Version: 2.00
// Firmware Version: 2.01
// Function: CPM_GetCyclicSYNCInfo
// Description: Get Cyclic SYNC Info
// Parameter: SlotNo: WinPAC/ViewPAC slot no. 0 ~ 7. XPAC slot no. 1 ~ 7
//			  *Cobid: 5 WORD Array, SYNC ID
//			  *Timer: 5 WORD Array, Cyclic timer, 0 is stop or 1 time and
//			  *Times: 5 DWORD Array, Cyclic times, 0 is always contiune
//			  BlockMode: Function Mode: Non-block function mode = 0, Block function mode = 1
////////////////////////////////////////
 WORD I8123_GetCyclicSYNCInfo(BYTE SlotNo, WORD *Cobid, WORD *Timer, DWORD *Times, BYTE BlockMode);

////////////////////////////////////////
// Driver Version: 2.00
// Firmware Version: 2.01
// Function: I8123_ChangeEMCYID
// Description: Change EMCY ID
// Parameter: SlotNo: WinPAC/ViewPAC slot no. 0 ~ 7. XPAC slot no. 1 ~ 7
//			  Node: Slave Node Id
//			  Cobid: EMCY ID
//			  BlockMode: Function Mode: Non-block function mode = 0, Block function mode = 1
////////////////////////////////////////
 WORD I8123_ChangeEMCYID(BYTE SlotNo, BYTE Node, WORD Cobid, BYTE BlockMode);

//////////////////////////////////////// 
// Driver Version: 2.00
// Firmware Version: 2.01
// Function: I8123_SetEMCY_List (Virtual List)
// Description: Set or Change EMCY ID from Master
//				The function only build a virtual EMCY ID let Master can control it. 
//				The virtual EMCY ID is not the real one necessarily.
// Parameter: SlotNo: WinPAC/ViewPAC slot no. 0 ~ 7. XPAC slot no. 1 ~ 7
//		      Node: Slave Node Id
//			  Cobid: PDO Cob ID
//			  BlockMode: Function Mode: Non-block function mode = 0, Block function mode = 1
////////////////////////////////////////
 WORD I8123_SetEMCY_List(BYTE SlotNo, BYTE Node, WORD Cobid, BYTE BlockMode);

////////////////////////////////////////
// Driver Version: 2.00
// Firmware Version: 2.01
// Function: I8123_GetEMCYID
// Description: Get EMCY ID
// Parameter: SlotNo: WinPAC/ViewPAC slot no. 0 ~ 7. XPAC slot no. 1 ~ 7
//			  Node: Slave Node
//			  *Cobid: EMCY ID
//			  BlockMode: Function Mode: Non-block function mode = 0, Block function mode = 1
////////////////////////////////////////
 WORD I8123_GetEMCYID(BYTE SlotNo, BYTE Node, WORD *Cobid, BYTE BlockMode);

////////////////////////////////////////
// Driver Version: 2.01 ( = V2.00 I8123_ReadEMCY)
// Firmware Version: 2.01
// Function: I8123_ReadLastEMCY
// Description: Get last message of the slave node
// Parameter: SlotNo: WinPAC/ViewPAC slot no. 0 ~ 7. XPAC slot no. 1 ~ 7
//		      Node: Slave Node Id
//			  *IsNew: Is new data, 0 is old data, 1 is new data
//			  *Data: EMCY Data
//			  BlockMode: Function Mode: Non-block function mode = 0, Block function mode = 1
////////////////////////////////////////
 WORD I8123_ReadLastEMCY(BYTE SlotNo, BYTE Node, BYTE *IsNew, BYTE *Data, BYTE BlockMode);

////////////////////////////////////////
// Driver Version: 2.05
// Firmware Version: 2.07
// Function: I8123_GetSYNCGroupStopState
// Description: Get SYNC Group Send Stop State after SYNC Group Send Stop
// Parameter: *SlotNo: WinPAC/ViewPAC slot no. 0 ~ 7. XPAC slot no. 1 ~ 7
//		      *State: 1: SYNC Group Send Complete, 2: SYNC Group Send Fail
////////////////////////////////////////
 WORD I8123_GetSYNCGroupStopState(BYTE *SlotNo, BYTE *State);

////////////////////////////////////////
// Driver Version: 2.01
// Firmware Version: 2.01
// Function: I8123_GetBootUpNodeAfterAdd
// Description: Get Boot up message after add node
// Parameter: *SlotNo: WinPAC/ViewPAC slot no. 0 ~ 7. XPAC slot no. 1 ~ 7
//		      *Node: Slave Node Id
////////////////////////////////////////
 WORD I8123_GetBootUpNodeAfterAdd(BYTE *SlotNo, BYTE *Node);

////////////////////////////////////////
// Driver Version: 2.01
// Firmware Version: 2.01
// Function: I8123_GetEMCYData
// Description: Get EMCY data received from the PISO-CPM100(U)
// Parameter: *SlotNo: WinPAC/ViewPAC slot no. 0 ~ 7. XPAC slot no. 1 ~ 7
//		      *Node: Slave Node Id
//			  *Data: EMCY Data
////////////////////////////////////////
 WORD I8123_GetEMCYData(BYTE *SlotNo, BYTE *Node, BYTE *Data);

////////////////////////////////////////
// Driver Version: 2.01
// Firmware Version: 2.01
// Function: I8123_GetNMTError
// Description: Get NMT Error Control message from CANopen slave. 
// Parameter: *SlotNo: WinPAC/ViewPAC slot no. 0 ~ 7. XPAC slot no. 1 ~ 7
//		      *Node: Slave Node Id
//			  *NMTErrMode: Get NMT Error mode.
//                         If Node_Guarding_Event, Mode = CPM_Node_Guarding_Event.
//                         And if Heartbeat_Event, Mode = CPM_Heartbeat_Event.
////////////////////////////////////////
 WORD I8123_GetNMTError(BYTE *SlotNo, BYTE *Node, BYTE *NMTErrMode);

// I8123_InstallSYNCGroupISR:
// Driver Version: 2.05
// Firmware Version: 2.07
// After called I8123_InstallSYNCGroupISR to install SYNC Group ISR function.
// When the SYNC Group Send is stopped, a stop state event will produce. And than
// the SYNC Group ISR will be executed.
 WORD I8123_InstallSYNCGroupISR(BYTE BoardNo, void (*SYNCISR)());
 WORD I8123_RemoveSYNCGroupISR(BYTE BoardNo);

// I8123_InstallBootUpISR:
// Driver Version: 2.01
// Firmware Version: 2.01
// After called I8123_InstallBootUpISR to install Boot ISR function.
// When the Master received a Boot up message send from other slave device witch
// had been added to the Master by calling I8123_AddNode, the Boot up ISR will be executed.
 WORD I8123_InstallBootUpISR(BYTE SlotNo, void (*BOOTISR)());
 WORD I8123_RemoveBootUpISR(BYTE SlotNo);

// I8123_InstallRxSDOISR:
// Driver Version: 2.00
// Firmware Version: 2.01
// After called I8123_InstallEMCYISR to install EMCY ISR function.
// When the Master received a EMCY message send from other slave device witch
// had been added to the Master by calling I8123_AddNode, the EMCY ISR will be executed.
 WORD I8123_InstallEMCYISR(BYTE SlotNo, void (*EMCYISR)());
 WORD I8123_RemoveEMCYISR(BYTE SlotNo);

// I8123_InstallNMTErrISR:
// Driver Version: 2.00
// Firmware Version: 2.01
// After called I8123_InstallNMTErrISR to install NMTErr ISR function.
// When the Master occured a Node_Guarding_Event or Heartbeat_Event, the NMTErr ISR will be executed.
 WORD I8123_InstallNMTErrISR(BYTE SlotNo, void (*NMTERRISR)());
 WORD I8123_RemoveNMTErrISR(BYTE SlotNo);


///////////////////////////////////////////////////////////////////////////////////////////////////
// Following ISR Funtions are only for Master with node id > 0.
// It means if the "Node" parameter of I8123_InitMaster is 0, the following functions will useless.
///////////////////////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////
// Driver Version: 2.00
// Firmware Version: 2.01
// Function: I8123_GetMasterReadSDOEvent
// Description: Get the Read SDO message for Master node id. 
// Parameter: *SlotNo: WinPAC/ViewPAC slot no. 0 ~ 7. XPAC slot no. 1 ~ 7
//		      *Index: Index of Object Dectionary.
//			  *SubIndex: SubIndex of Object Dectionary.
////////////////////////////////////////
 WORD I8123_GetMasterReadSDOEvent(BYTE *SlotNo, WORD *Index, BYTE *SubIndex);

////////////////////////////////////////
// Driver Version: 2.00
// Firmware Version: 2.01
// Function: I8123_GetMasterWriteSDOEvent
// Description: Get the Write SDO message for Master node id. 
// Parameter: *SlotNo: WinPAC/ViewPAC slot no. 0 ~ 7. XPAC slot no. 1 ~ 7
//		      *Index: Index of Object Dectionary.
//			  *SubIndex: SubIndex of Object Dectionary.
//			  *WLen: Write Data Length.
//			  *WData: Write Data.
////////////////////////////////////////
 WORD I8123_GetMasterWriteSDOEvent(BYTE *SlotNo, WORD *Index, BYTE *SubIndex, BYTE *WLen, BYTE *WData);

////////////////////////////////////////
// Driver Version: 2.00
// Firmware Version: 2.01
// Function: I8123_ResponseMasterSDO
// Description: Response SDO message from CPM100U
// Parameter: SlotNo: WinPAC/ViewPAC slot no. 0 ~ 7. XPAC slot no. 1 ~ 7
//			  ResType: Response read/write to SDO message (0 is read response, 1 is write response)
//			  Index: Response Index of Object Dectionary
//			  SubIndex: Response SubIndex of Object Dectionary
//			  Len: Response data length (0 ~ 4) (Note: Write response must 0-byte)
//			  *Data: Response data array (max. 4-bytes)
////////////////////////////////////////
 WORD I8123_ResponseMasterSDO(BYTE SlotNo, BYTE ResType, WORD Index, BYTE SubIndex, BYTE Len, BYTE *Data);

////////////////////////////////////////
// Driver Version: 2.00
// Firmware Version: 2.01
// Function: I8123_GetMasterRemotePDOEvent
// Description: Get the Remote PDO message for Master's PDO COB-ID. 
// Parameter: *SlotNo: WinPAC/ViewPAC slot no. 0 ~ 7. XPAC slot no. 1 ~ 7
//		      *CobId: PDO Cob Id.
////////////////////////////////////////
 WORD I8123_GetMasterRemotePDOEvent(BYTE *SlotNo, WORD *CobId);

////////////////////////////////////////
// Driver Version: 2.00
// Firmware Version: 2.01
// Function: I8123_GetMasterRxPDOEvent
// Description: Get the Write PDO message for Master's PDO COB-ID. 
// Parameter: *SlotNo: WinPAC/ViewPAC slot no. 0 ~ 7. XPAC slot no. 1 ~ 7
//		      *CobId: PDO Cob Id.
//			  *WLen: Write Data Length.
//			  *WData: Write Data.
////////////////////////////////////////
 WORD I8123_GetMasterRxPDOEvent(BYTE *SlotNo, WORD *CobId, BYTE *WLen, BYTE *WData);

////////////////////////////////////////
// Driver Version: 2.00
// Firmware Version: 2.01
// Function: I8123_ResponseMasterPDO
// Description: Response remote PDO message from CPM100U
// Parameter: SlotNo: WinPAC/ViewPAC slot no. 0 ~ 7. XPAC slot no. 1 ~ 7
//			  CobId: Response remote PDO Cob Id.
//			  Len: Response data length (1 ~ 8).
//			  *Data: Response data array (max. 8-bytes).
////////////////////////////////////////
 WORD I8123_ResponseMasterPDO(BYTE SlotNo, WORD CobId, BYTE Len, BYTE *Data);

// I8123_InstallReadSDOISR:
// Driver Version: 2.00
// Firmware Version: 2.01
// If the Master had called I8123_InitMaster to initial Master with node n (128 > n > 0).
// After installed I8123_InstallReadSDOISR, when the Master received a Read RxSDO message (message Cob ID is 0x600+n)
// and the Master will produce an interrupt to execute the RSDOISR ISR function.
 WORD I8123_InstallReadSDOISR(BYTE SlotNo, void (*RSDOISR)());
 WORD I8123_RemoveReadSDOISR(BYTE SlotNo);

// I8123_InstallWriteSDOISR:
// Driver Version: 2.00
// Firmware Version: 2.01
// If the Master had called I8123_InitMaster to initial Master with node n (128 > n > 0).
// After installed I8123_InstallWriteSDOISR, when the Master received a Write RxSDO message (message Cob ID is 0x600+n)
// and the Master will produce an interrupt to execute the WSDOISR ISR function.
 WORD I8123_InstallWriteSDOISR(BYTE SlotNo, void (*WSDOISR)());
 WORD I8123_RemoveWriteSDOISR(BYTE SlotNo);

// I8123_InstallRxPDOISR:
// Driver Version: 2.00
// Firmware Version: 2.01
// If the Master had called I8123_InitMaster to initial Master with node n (128 > n > 0).
// And if the Master also had called I8123_InstallPDO_List to install a RxPDO to itself (ex: PDO Cob ID is 0x200+n).
// After installed I8123_InstallRxPDOISR, when the Master received the RxPDO message
// and the Master will produce an interrupt to execute the RXPDOISR ISR function.
 WORD I8123_InstallRxPDOISR(BYTE SlotNo, void (*RXPDOISR)());
 WORD I8123_RemoveRxPDOISR(BYTE SlotNo);

// I8123_InstallRemotePDOISR:
// Driver Version: 2.00
// Firmware Version: 2.01
// If the Master had called I8123_InitMaster to initial Master with node n (128 > n > 0).
// And if the Master also had called I8123_InstallPDO_List to install a TxPDO to itself (ex: PDO Cob ID is 0x180+n).
// After installed I8123_InstallRemotePDOISR, when the Master received the TxPDO message
// and the Master will produce an interrupt to execute the REMOTEPDOISR ISR function.
 WORD I8123_InstallRemotePDOISR(BYTE SlotNo, void (*REMOTEPDOISR)());
 WORD I8123_RemoveRemotePDOISR(BYTE SlotNo);


#ifdef __cplusplus
}
#endif


//#endif // __I8123W_H
