Subversion Repositories Projects

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2194 - 1
/*
2
hmc5883l lib 0x01
3
 
4
copyright (c) Davide Gironi, 2012
5
 
6
Released under GPLv3.
7
Please refer to LICENSE file for licensing information.
8
 
9
References:
10
  - HMC5883L Triple Axis Magnetometer Arduino Library
11
    http://bildr.org/2012/02/hmc5883l_arduino/
12
*/
13
 
14
 
15
#ifndef HMC5883L_H_
16
#define HMC5883L_H_
17
 
18
//definitions
19
#define HMC5883L_ADDR (0x1E<<1) //device address
20
 
21
//i2c settings
22
#define HMC5883L_I2CFLEURYPATH "i2cmaster.h" //define the path to i2c fleury lib
23
#define HMC5883L_I2CINIT 1 //init i2c
24
 
25
//registers
26
#define HMC5883L_CONFREGA 0x00
27
#define HMC5883L_CONFREGB 0x01
28
#define HMC5883L_MODEREG 0x02
29
#define HMC5883L_DATAREGBEGIN 0x03
30
 
31
//setup measurement mode
32
#define HMC5883L_MEASURECONTINOUS 0x00
33
#define HMC5883L_MEASURESINGLESHOT 0x01
34
#define HMC5883L_MEASUREIDLE 0x03
35
#define HMC5883L_MEASUREMODE HMC5883L_MEASURECONTINOUS
36
 
37
//setup scale
38
#define HMC5883L_SCALE088 1 //0.88
39
#define HMC5883L_SCALE13 2 //1.3
40
#define HMC5883L_SCALE19 3 //1.9
41
#define HMC5883L_SCALE25 4 //2.5
42
#define HMC5883L_SCALE40 5 //4.0
43
#define HMC5883L_SCALE47 6 //4.7
44
#define HMC5883L_SCALE56 7 //5.6
45
#define HMC5883L_SCALE81 8 //8.1
46
#define HMC5883L_SCALE HMC5883L_SCALE13
47
 
48
#define HMC5883L_CALIBRATED 1 //enable this if this magn is calibrated
49
 
50
//calibration values
51
#if HMC5883L_CALIBRATED == 1
52
#define HMC5883L_OFFSETX -99.7
53
#define HMC5883L_OFFSETY -154.0
54
#define HMC5883L_OFFSETZ -22.7
55
#define HMC5883L_GAINX1 0.952017
56
#define HMC5883L_GAINX2 0.00195895
57
#define HMC5883L_GAINX3 0.0139661
58
#define HMC5883L_GAINY1 0.00195895
59
#define HMC5883L_GAINY2 0.882824
60
#define HMC5883L_GAINY3 0.00760243
61
#define HMC5883L_GAINZ1 0.0139661
62
#define HMC5883L_GAINZ2 0.00760243
63
#define HMC5883L_GAINZ3 0.995365
64
#endif
65
 
66
//functions
67
extern void hmc5883l_init();
68
extern void hmc5883l_getrawdata(int16_t *mxraw, int16_t *myraw, int16_t *mzraw);
69
extern void hmc5883l_getdata(double *mx, double *my, double *mz);
70
 
71
#endif