/* 
 *  Copyright 2004 by Soos, Antal 
 *  All rights reserved. Property of Soos, Antal. 
 *  Restricted rights to use, duplicate or disclose this code are 
 *  granted through contract.   
 */ 
//  DSP 2 <=> TMS320C6713
#ifndef _GLOBAL_DEF_H_ 
#define _GLOBAL_DEF_H_    
//------------------------------
#define  CHIP_6713 1
#include "csl.h"

//------------------------------------------------------------------
#define  LIMIT(min, x, max)      ( ((x) < (min)) ? (min) :       \
                                 (((x) > (max)) ? (max) : x ) )
//------------------------------------------------------------------

//-----------------------------------------------
// Control selection
//-----------------------------------------------
#define H8_CONTROL  1
#define PID_CONTROL  0

// COUNSTANT DEFINITION for VCTOR ALLOCATIONS
//-----------------------------------------------

// Control System order definition:
#define MPC_H8 5

//Model order dimensions:
#define ARMAX_DC 0			/* DC component from ARMAX  */
#define ARMAX_a MPC_H8		/* AR components from ARMAX */
#define ARMAX_b MPC_H8		/* MA components from ARMAX */
#define ARMAX_c 0			/* X  components from ARMAX */

#define ARMAX_dim  (ARMAX_DC+ARMAX_a+ARMAX_b+ARMAX_c)    /* ARMAX dimension */

#define H8_m MPC_H8			/* H8MPC control system_dimension = m_a or  m_b  */
#define H8_l MPC_H8			/* H8MPC # of system disturbances  */
#define H8_r 1				/* H8MPC # of system control input  */
#define H8_p (H8_m + H8_r)	/* H8MPC # of system controlled output */
#define H8_q 1				/* H8MPC # of system measured outputs */



#define NxTs  30   /* the lenght beatwen two decision t=N*T  */

#define SATRT_OF_VECTOR  1.1   /* For test the start of the vector */
#define END_OF_VECTOR    9.9   /* For test the end of the vector */


#define REC_BUF_SZ  16
#define TRA_BUF_SZ  REC_BUF_SZ
#define McBSP_MARKER 0x5ABCDEF5


 typedef struct DSP2DSP_com{
	Uint32 TR_McBSP_MARKER;
	float x[REC_BUF_SZ-2];
	Uint32 RE_McBSP_MARKER;
  } D2D_com;

#define RAND_MAX_HALF  16383
#define INV_RAND_MAX_HALF  6.103702e-5
#define RANDOM_SIGNAL_LEVEL  0.05   /* 0.05 <=> 5% of the 1 pu. control signal */
#define MAXgama 2e+3

#define delta_t  0.033333333333 /* time step */


 typedef struct F2X_con{  /* For LOG_event data */
	float x;
	float y;
	float z;
  } F2Xcon;




  #define LED1_PERIOD 1
  #define LED2_PERIOD 3



 



#endif  /* _GLOBAL_DEF_H_ */
