#ifndef BUSIFVVDRIVE_H
#pragma once
#define BUSIFVVDRIVE_H

// Attention! 
// This Header File is used in Hardware und Custom Library. 
// When making  changes to this file make sure to update both Libraries

//*****************************************************************************
//** NEWINST COMMANDS (Range reserved for bus interface: 0x8510 - 0x851F)    **
//*****************************************************************************

// Commands that the Bus IF provides
// Commands id range from 0x8510 to 0x851F
#define _BUSIF_VVDRIVE_ADD_ISO_DATAOBJECT       16#8510  // add isochrone dataobjects
#define _BUSIF_VVDRIVE_ADD_ASY_DATAOBJECT       16#8511  // add asynchrone dataobjects
#define _BUSIF_VVDRIVE_START_ISO_DATAOBJECT     16#8512  // start isochrone dataobjects
#define _BUSIF_VVDRIVE_CHANGE_DO_ADDRESSES      16#8513  // set correct DO offsets
#define _BUSIF_VVDRIVE_GET_MAILBOX              16#8514  // Get Info from Mailbox
#define _BUSIF_VVDRIVE_GET_SAFETY_INFOS         16#8515  // get safety infos from module
#define _BUSIF_VVDRIVE_SET_SAFETY_STATE         16#8516  // set safety state

#define _BUSIF_VVDRIVE_ADD_MDD2000_MDP_ERROR    16#8517  // get drive info pointer from mdp hardware to route it to mdd hardware

#define _BUSIF_VVDRIVE_ACTIVATEBOOTMODE         16#8518  // Allow the VV-Class to start when the FW is in Bootmode

#define _BUSIF_VVDRIVE_ACTIVATEBOOTMODE_VER_1                    1                   //version 1
#define _BUSIF_VVDRIVE_ACTIVATEBOOTMODE_MAX     _BUSIF_VVDRIVE_ACTIVATEBOOTMODE_VER_1   //newest implemented version
//  Command Version 1 **  
//  CmdStruct
//  aPara[0]$DINT     : Command Version : 1  
//  aPara[1]$DINT     : 1 .. Allow Bootmode, 0 .. do not allow Bootmode

//  results
//  uiLng         : 4 Byte
//  aData[0]$DINT : Command Version : max supported version
//  retcode
//  READY
//  ERROR

//mailbox IDs
#define _BUSIF_VVDRIVE_SERVICE_LSL_MDD100        0x4150
#define _BUSIF_VVDRIVE_SERVICE_APP_MDD100        0x4C41
#define _BUSIF_VVDRIVE_SERVICE_LSL_DS402         0x444C
#define _BUSIF_VVDRIVE_SERVICE_APP_DS402         0x4453
#define _BUSIF_VVDRIVE_SERVICE_LSL_CMDIN         0x1979
#define _BUSIF_VVDRIVE_SERVICE_APP_CMDIN         0x1972
#define _BUSIF_VVDRIVE_SERVICE_APP_FSOE          0x4653
#define _BUSIF_VVDRIVE_SERVICE_APP_SSDO          0x5344

#define _BUSIF_VVDRIVE_READ_PARA_CMD     	 	 	 	 	   12  //Parameter Read Command for Vandal Mailbox
#define _BUSIF_VVDRIVE_WRITE_PARA_CMD    	 	 	 	 	   13  //Parameter Write Command for Vandal Mailbox

//datatypes for parameters    
#define _BUSIF_VVDRIVE_NULL              	 	 	 	 	 0x00
#define _BUSIF_VVDRIVE_BOOLEAN           	 	 	 	 	 0x01
#define _BUSIF_VVDRIVE_INTEGER8          	 	 	 	 	 0x02
#define _BUSIF_VVDRIVE_INTEGER16         	 	 	 	 	 0x03
#define _BUSIF_VVDRIVE_INTEGER32         	 	 	 	 	 0x04
#define _BUSIF_VVDRIVE_UNSIGNED8         	 	 	 	 	 0x05
#define _BUSIF_VVDRIVE_UNSIGNED16        	 	 	 	 	 0x06
#define _BUSIF_VVDRIVE_UNSIGNED32        	 	 	 	 	 0x07
#define _BUSIF_VVDRIVE_REAL32            	 	 	 	 	 0x08
#define _BUSIF_VVDRIVE_VISIBLESTRING     	 	 	 	 	 0x09
#define _BUSIF_VVDRIVE_OCTETSTRING       	 	 	 	 	 0x0A
#define _BUSIF_VVDRIVE_REAL64            	 	 	 	 	 0x11

//#define _BUSIF_VVDRIVE_READ_NPARA_MB

//*****************************************************************************
//** TYPES                                                                   **
//*****************************************************************************

	TYPE
  
	  t_MapEntry : STRUCT
	    hiAddress : HINT;
	    uiLength : UINT;
	  END_STRUCT;
    
	  t_MailboxTypes :
	  (
	    LSL_MDD100:=_BUSIF_VVDRIVE_SERVICE_LSL_MDD100,
	    APP_MDD100:=_BUSIF_VVDRIVE_SERVICE_APP_MDD100,
	    LSL_DS402:=_BUSIF_VVDRIVE_SERVICE_LSL_DS402,
	    APP_DS402:=_BUSIF_VVDRIVE_SERVICE_APP_DS402,
	    LSL_CMDInterpreter:=_BUSIF_VVDRIVE_SERVICE_LSL_CMDIN,  
	    APP_CMDInterpreter:=_BUSIF_VVDRIVE_SERVICE_APP_CMDIN,    
	    APP_FSOE:=_BUSIF_VVDRIVE_SERVICE_APP_FSOE,
	    APP_SSDO:=_BUSIF_VVDRIVE_SERVICE_APP_SSDO
	  )$UINT;
    
#pragma pack(push, 2)
	  t_MailBox : STRUCT
	    ID : t_MailboxTypes;
	    Request : t_MapEntry;
	    Response : t_MapEntry;
	  END_STRUCT;
#pragma pack(pop)
            
	  tsMailboxFooter : STRUCT
	    uiDatalength : UINT;
	    usCmd : USINT;
	    bsControl : BSINT
	    [
	    1 MsgCnt1,
      2 MsgCnt2,
      3 MsgCnt3,
      4 ErrorFlag,
      5 res1,
      6 res2,
      7 res3,
      8 res4,
	    ];
	  END_STRUCT;
      
	  tsDS402RdRequ : STRUCT
	    hiIndex : HINT;
	    hsSubIndex : HSINT;
	    usParaType : USINT;
	  END_STRUCT;
    
	  tsDS402WrRequ : STRUCT
	    hiIndex : HINT;
	    hsSubIndex : HSINT;
	    usParaType : USINT;
      usData    : DINT;
	  END_STRUCT;
    
  END_TYPE 
#endif