89 lines
1.8 KiB
C
89 lines
1.8 KiB
C
#ifndef QMC5883L_H
|
|
#define QMC5883L_H
|
|
|
|
/* Device i2c address */
|
|
#define QMC5883L_I2C_ADDR 0x0D
|
|
|
|
/* Device registers list */
|
|
#define QMC5883L_DATA_X_LSB_REG 0x00
|
|
#define QMC5883L_STATUS_REG 0x06
|
|
#define QMC5883L_TEMP_LSB_REG 0x07
|
|
#define QMC5883L_TEMP_MSB_REG 0x08
|
|
#define QMC5883L_CTRL1_REG 0x09
|
|
#define QMC5883L_CTRL2_REG 0x0A
|
|
#define QMC5883L_SETRES_REG 0x0B
|
|
|
|
/* Field masks */
|
|
#define QMC5883L_DRDY_BIT 0x01
|
|
#define QMC5883L_OVL_BIT 0x02
|
|
#define QMC5883L_DOR_BIT 0x04
|
|
|
|
/* Configuration enumerations */
|
|
typedef enum
|
|
{
|
|
Standby = 0,
|
|
Continuous = 1,
|
|
} QMC5883L_Mode_Control_e;
|
|
|
|
typedef enum
|
|
{
|
|
ODR_10HZ = 0,
|
|
ODR_50HZ = 1,
|
|
ODR_100HZ = 2,
|
|
ODR_200HZ = 3,
|
|
} QMC5883L_Output_Data_Rate_e;
|
|
|
|
typedef enum
|
|
{
|
|
FS_2G = 0,
|
|
FS_8G = 1,
|
|
} QMC5883L_Full_Scale_e;
|
|
|
|
typedef enum
|
|
{
|
|
OSR_512 = 0,
|
|
OSR_256 = 1,
|
|
OSR_128 = 2,
|
|
OSR_64 = 3,
|
|
} QMC5883L_Over_Sample_Ratio_e;
|
|
|
|
|
|
typedef struct
|
|
{
|
|
int16_t MFieldX;
|
|
int16_t MFieldY;
|
|
int16_t MFieldZ;
|
|
} QMC5883L_MData_t;
|
|
|
|
typedef struct
|
|
{
|
|
int16_t MFieldX;
|
|
int16_t MFieldY;
|
|
int16_t MFieldZ;
|
|
} QMC5883L_MData_calibrated_t;
|
|
|
|
|
|
/* QMC5883L Driver API */
|
|
bool QMC5883L_init(void);
|
|
|
|
bool QMC5883L_software_reset(void);
|
|
|
|
float QMC5883L_get_temperature(void);
|
|
|
|
bool QMC5883L_is_data_available(void);
|
|
|
|
void QMC5883L_set_calibration_data(int16_t x_min, int16_t x_max, int16_t y_min, int16_t y_max, int16_t z_min, int16_t z_max);
|
|
|
|
QMC5883L_MData_t QMC5883L_get_MFields_raw(void);
|
|
|
|
QMC5883L_MData_calibrated_t QMC5883L_get_MFields_calibrated(void);
|
|
|
|
int16_t QMC5883L_get_azimuth(const QMC5883L_MData_calibrated_t data);
|
|
|
|
bool QMC5883L_configure_1(QMC5883L_Output_Data_Rate_e ODR, QMC5883L_Full_Scale_e RNG, QMC5883L_Over_Sample_Ratio_e OSR);
|
|
|
|
bool QMC5883L_configure_2(bool rolling_ptr, bool data_ready_int);
|
|
|
|
bool QMC5883L_set_power_mode(QMC5883L_Mode_Control_e MC);
|
|
|
|
#endif //QMC5883L_H
|