#ifndef bexus_vars_h
#define bexus_vars_h
#ifdef __cplusplus
 extern "C" {
#endif
	 
//#include "cmsis_os.h"
#include "main.h"
#include <stddef.h>

#define DATASET_LENGTH 100

struct vector {
	double x,y,z;
};

struct vector_Uint {
	int32_t x,y,z;
};	 

#define BOARD_HAS_ETHERNET
	 
/*
Memory align rules - for struct
Rules:

Before each individual member, there will be padding so that to make it start at an address that is divisible by its size. e.g on 64 bit system,int should start at address divisible by 4, and long by 8, short by 2.
char and char[] is special, could be any memory address, so they don't need padding before them.
For struct, other than the alignment need for each individual member, the size of whole struct itself will be aligned to a size divisible by size of largest individual member, by padding at end. e.g if struct's largest member is long then divisible by 8, int then by 4, short then by 2.

32 bit system
Starts from (n * 8) bytes.
Reason: the largest individual struct member is 8 bytes.
*/	  
	 
struct Dataset{ // packed size: 312 bytes
	/*-------RAW-----------*/
	uint32_t pressure_cis_raw;    // pack 1 x 4
	uint32_t temperature_cis_raw; //    + 1 x 4
	
	uint32_t pressure_spi_raw;
	uint32_t temperature_i2c_raw;
	
	uint32_t temperature_spi_raw;
	uint32_t adc_temperature_raw;
	
	int32_t  temperature_mpu_raw;
	uint32_t adc_temperature_internal_raw;
	
	uint32_t	adc_voltage_raw;
	uint32_t	adc_current_raw;
	
	struct vector_Uint accel_raw; // pack 3 x 4
	struct vector_Uint gyro_raw;  //    + 3 x 4
	
	struct vector_Uint mag_raw; // pack 3 x 4
	                            //    + 1 x 4
  int32_t temperature_mag_raw;
	
	/*-----Computed--------*/
	
	double pressure_cis; // no packing needed 1 x 8
	
	double temperature_cis;	
	
	double pressure_spi;	
	
	double temperature_i2c;	
	
	double temperature_spi;	
	
	double adc_temperature;	
	
	double adc_temperature_internal;			
	
	double adc_voltage;	

	double adc_current;		

	double temperature_mpu;	
	
	struct vector accel; // no packing needed 3 x 8
	struct vector gyro;
	struct vector rot;
	
	struct vector mag;
	double temperature_mag;
	
	struct vector global_accel;
	struct vector pos;

	/*-----------gps------------*/
	float longitude;
	float latitude;
	
	int32_t altitude;
	uint32_t time;
	
	uint32_t hdop;
	int32_t mag_head; //heading
	
	uint32_t count;
	uint32_t crc;

}; //38 x 8 bytes <-- wichtig für lzo

/* We want to compress the data block at 'in' with length 'IN_LEN' to
 * the block at 'out'. Because the input block may be incompressible,
 * we must provide a little more output space in case that compression
 * is not possible.
 */

#define IN_LEN  (43UL * 8) // AKTUELL HALTEN!

extern struct Dataset Dataset_Master[DATASET_LENGTH];
extern struct Dataset Dataset_Slave[DATASET_LENGTH];
extern struct Dataset Dataset_Fusion[DATASET_LENGTH];

extern uint16_t buff_sensor_data_index;//up to DATASET_LENGTH 
/*
extern struct CompressedDataset Dataset_SD;
extern uint32_t DataLength;
*/
#ifdef __cplusplus
 }
#endif
#endif

