2 * Copyright © 2012 Keith Packard <keithp@keithp.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
19 #ifndef _AO_HMC5883_H_
20 #define _AO_HMC5883_H_
22 #define HMC5883_ADDR_WRITE 0x3c
23 #define HMC5883_ADDR_READ 0x3d
25 #define HMC5883_CONFIG_A 0
27 #define HMC5883_CONFIG_A_MA 5
28 #define HMC5883_CONFIG_A_MA_1 0
29 #define HMC5883_CONFIG_A_MA_2 1
30 #define HMC5883_CONFIG_A_MA_4 2
31 #define HMC5883_CONFIG_A_MA_8 3
32 #define HMC5883_CONFIG_A_MA_MASK 3
34 #define HMC5883_CONFIG_A_DO 2
35 #define HMC5883_CONFIG_A_DO_0_75 0
36 #define HMC5883_CONFIG_A_DO_1_5 1
37 #define HMC5883_CONFIG_A_DO_3 2
38 #define HMC5883_CONFIG_A_DO_7_5 3
39 #define HMC5883_CONFIG_A_DO_15 4
40 #define HMC5883_CONFIG_A_DO_30 5
41 #define HMC5883_CONFIG_A_DO_75 6
42 #define HMC5883_CONFIG_A_DO_MASK 7
44 #define HMC5883_CONFIG_A_MS 0
45 #define HMC5883_CONFIG_A_MS_NORMAL 0
46 #define HMC5883_CONFIG_A_MS_POSITIVE_BIAS 1
47 #define HMC5883_CONFIG_A_MS_NEGATIVE_BIAS 2
48 #define HMC5883_CONFIG_A_MS_MASK 3
50 #define HMC5883_CONFIG_B 1
52 #define HMC5883_CONFIG_B_GN 5
53 #define HMC5883_CONFIG_B_GN_0_88 0
54 #define HMC5883_CONFIG_B_GN_1_3 1
55 #define HMC5883_CONFIG_B_GN_1_9 2
56 #define HMC5883_CONFIG_B_GN_2_5 3
57 #define HMC5883_CONFIG_B_GN_4_0 4
58 #define HMC5883_CONFIG_B_GN_4_7 5
59 #define HMC5883_CONFIG_B_GN_5_6 6
60 #define HMC5883_CONFIG_B_GN_8_1 7
61 #define HMC5883_CONFIG_B_GN_MASK 7
63 #define HMC5883_MODE 2
64 #define HMC5883_MODE_CONTINUOUS 0
65 #define HMC5883_MODE_SINGLE 1
66 #define HMC5883_MODE_IDLE 2
68 #define HMC5883_X_MSB 3
69 #define HMC5883_X_LSB 4
70 #define HMC5883_Y_MSB 5
71 #define HMC5883_Y_LSB 6
72 #define HMC5883_Z_MSB 7
73 #define HMC5883_Z_LSB 8
74 #define HMC5883_STATUS 9
75 #define HMC5883_ID_A 10
76 #define HMC5883_ID_B 11
77 #define HMC5883_ID_C 12
79 struct ao_hmc5883_sample {
83 extern struct ao_hmc5883_sample ao_hmc5883_current;
86 ao_hmc5883_init(void);
88 #endif /* _AO_HMC5883_H_ */