#ifndef __6DOF_
#define __6DOF_

// ACCELEROMETER////////////////////////////////

typedef struct
   { 
	   int rawData[3];
	   int data[3];
	   int offset[3];
   } Dof6Accelero;
#define  KaccScale 0.0039
#define ADDR_ADXL345	0xA6  // acc adress
#define ADXL345_DEVID 0x00 // who am i register
#define  OFSX 0x1E // 0g x offset
#define  OFSY 0x1E // 0g y offset
#define  OFSZ  0x1E // 0g z offset
#define ADXL345_POWER_CTL 0x2D
#define ADXL345_DATAX0 0x32
#define A_TO_READ 6



// get accelero raw data 
// input : adress of Dof6Accelero type variable 
// output : field rawData of struct modified
void getRawAccelerometerData(Dof6Accelero *) ;

// get accelero with 0g bias compensed 
// input : adress of Dof6Accelero type variable 
// output : field accData of struct modified
void getAccelerometerData(Dof6Accelero *) ;

// get  0g bias from accelero 
// input : adress of Dof6Accelero type variable 
// output : field offset of struct modified
 void getOffsetAccelerometer(Dof6Accelero *) ;

// calculate 0g bias
// pcb is on flat surface: we have Xacc=0g Yacc=0g Zacc=+1g
// 1g quivalent to 256
// input : adress of Dof6Accelero type variable 
// output : field offset of struct modified
 void CalcAverageOffsetAccelerometer(Dof6Accelero * );



void InitAcc(void);
unsigned char	GetWhoAmIAcc(void);



//////////////////////////////////////////////

// GYRO

typedef struct
   { 
	   int data[3];
	   int offset[3];
	 //  int temp;
   } Dof6Gyro;
#define  KgyroScale 0.0012141420883


#define ADDR_ITG3200	0xD0

#define ITG3200_WHO_AM_I	0x00
#define  ITG3200_SMPLRT_DIV  0x15
#define  ITG3200_DLPF_FS  0x16
#define  ITG3200_INT_CFG 0x17
#define  ITG3200_INT_STATUS 0x17
#define  ITG3200_GYRO_TEMP   0x1B
#define  ITG3200_GYRO_XOUT   0x1D
#define  ITG3200_GYRO_YOUT   0x1F
#define  ITG3200_GYRO_ZOUT   0x21
#define  ITG3200_GYRO_DATA   0x1D
#define  ITG3200_PWR_MGM  0x3E





extern char getGyroData(Dof6Gyro *  );
extern void CalcAverageOffsetGyro(Dof6Gyro * ); 
extern void InitGyro(void);
extern unsigned char GetWhoAmIGyro(void);
extern void Init6DOF();
extern char getRawGyroData(Dof6Gyro * ) ;


#endif
