//MAGNETOMETER1MMC.h

#ifndef MAGNETOMETER2BM_H
#define	MAGNETOMETER2BM_H

#define BM_Address 0x0E
#define BM_Contr_Reg_1 0x1B
#define BM_Contr_Reg_2 0x1C
#define BM_Contr_Reg_3 0x1D
#define BM_Contr_Reg_4L 0x5C
#define BM_Contr_Reg_4H 0x5D
#define BM_X_Off_0 0x6C
#define BM_X_Off_1 0x6D
#define BM_Y_Off_0 0x72
#define BM_Y_Off_1 0x73
#define BM_Z_Off_0 0x78
#define BM_Z_Off_1 0x79
#define BM_X_out_0 0x10
#define BM_X_out_1 0x11
#define BM_Y_out_0 0x12
#define BM_Y_out_1 0x13
#define BM_Z_out_0 0x14
#define BM_Z_out_1 0x15
#define BM_Temp_out_0 0x60
#define BM_Temp_out_1 0x61

#define BM_Contr_Reg_1_Set_sleep 0x22 //PowerDown, 12bit Output, reset, meas output data rates 10 Hz, single mode
#define BM_Contr_Reg_1_Set 0xC8 //Power active, 14bit Output, reset_LV, meas output data rates 10 Hz, single mode
#define BM_Contr_Reg_2_Set_sleep 0x04 //DRDY disable & active high
#define BM_Contr_Reg_2_Set 0x0C //DRDY enable & active high
#define BM_Contr_Reg_3_Set 0x40 //Start meas trigger
#define BM_Contr_Reg_4H_Set 0x00 //


typedef struct BM_DATA{
    float bm_x;
    float bm_y;
    float bm_z;
}BM_DATA;

typedef struct {
    int16_t x;
    int16_t y;
    int16_t z;
} _axesBMInt;

void BM_Calib(uint16_t loop);
void BM_SI_Calib(uint16_t loop);
void BM_Meas_HI_Compensated(uint16_t loop);
void BM_Meas_Compensated(uint16_t loop);
void BM_Meas_Azimuth(uint16_t loop);
float BM_Single_Meas_Azimuth(void);
void BM_init(void);
void BM_Meas_Set(uint8_t Contr_Reg_Num, uint8_t Contr_Reg_Num_Set);
void BM_Separate_XYZ(uint8_t *data);
float BM_Read_Data(uint8_t address);
void BM_Get_Float_Data(BM_DATA *);

#endif	/* MAGNETOMETER2BM_H */

