altos/telefireone-v1.0: Track ao_led_init API change
[fw/altos] / src / drivers / ao_mma655x.h
1 /*
2  * Copyright © 2012 Keith Packard <keithp@keithp.com>
3  *
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.
8  *
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.
13  *
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.
17  */
18
19 #ifndef _AO_MMA655X_H_
20 #define _AO_MMA655X_H_
21
22
23 #define AO_MMA655X_SN0          0x00
24 #define AO_MMA655X_SN1          0x01
25 #define AO_MMA655X_SN2          0x02
26 #define AO_MMA655X_SN3          0x03
27 #define AO_MMA655X_SN3          0x03
28 #define AO_MMA655X_STDEFL       0x04
29 #define AO_MMA655X_FCTCFG       0x06
30 # define AO_MMA655X_FCTCFG_STMAG        7
31
32 #define AO_MMA655X_PN           0x08
33 #define AO_MMA655X_DEVCTL       0x0a
34 #define AO_MMA655X_DEVCTL_RES_1         7
35 #define AO_MMA655X_DEVCTL_RES_0         6
36 #define AO_MMA655X_DEVCTL_OCPHASE       4
37 #define AO_MMA655X_DEVCTL_OCPHASE_MASK  3
38 #define AO_MMA655X_DEVCTL_OFFCFG_EN     3
39
40 #define AO_MMA655X_DEVCFG       0x0b
41 #define AO_MMA655X_DEVCFG_OC            7
42 #define AO_MMA655X_DEVCFG_ENDINIT       5
43 #define AO_MMA655X_DEVCFG_SD            4
44 #define AO_MMA655X_DEVCFG_OFMON         3
45 #define AO_MMA655X_DEVCFG_A_CFG         0
46 #define AO_MMA655X_DEVCFG_A_CFG_DISABLE         0
47 #define AO_MMA655X_DEVCFG_A_CFG_PCM             1
48 #define AO_MMA655X_DEVCFG_A_CFG_MOVING_AVG_HIGH 2
49 #define AO_MMA655X_DEVCFG_A_CFG_MOVING_AVG_LOW  3
50 #define AO_MMA655X_DEVCFG_A_CFG_COUNT_HIGH      4
51 #define AO_MMA655X_DEVCFG_A_CFG_COUNT_LOW       5
52 #define AO_MMA655X_DEVCFG_A_CFG_UNFILTERED_HIGH 6
53 #define AO_MMA655X_DEVCFG_A_CFG_UNFILTERED_LOW  7
54 #define AO_MMA655X_DEVCFG_A_CFG_MASK            7
55
56 #define AO_MMA655X_AXISCFG      0x0c
57 #define AO_MMA655X_AXISCFG_ST           7
58 #define AO_MMA655X_AXISCFG_LPF          0
59 #define AO_MMA655X_AXISCFG_LPF_MASK     0xf
60
61 #define AO_MMA655X_ARMCFG       0x0e
62 #define AO_MMA655X_ARMCFG_APS           4
63 #define AO_MMA655X_ARMCFG_APS_MASK      3
64 #define AO_MMA655X_ARMCFG_AWS_N         2
65 #define AO_MMA655X_ARMCFG_AWS_N_MASK    3
66 #define AO_MMA655X_ARMCFG_AWS_P         0
67 #define AO_MMA655X_ARMCFG_AWS_P_MASK    3
68
69 #define AO_MMA655X_ARMT_P       0x10
70 #define AO_MMA655X_ARMT_N       0x12
71
72 #define AO_MMA655X_DEVSTAT      0x14
73 #define AO_MMA655X_DEVSTAT_IDE          6
74 #define AO_MMA655X_DEVSTAT_DEVINIT      4
75 #define AO_MMA655X_DEVSTAT_MISOERR      3
76 #define AO_MMA655X_DEVSTAT_OFFSET       1
77 #define AO_MMA655X_DEVSTAT_DEVRES       0
78
79 #define AO_MMA655X_COUNT        0x15
80 #define AO_MMA655X_OFFCORR      0x16
81
82 /*
83  * Range of valid self-test difference from
84  * normal measurement
85  */
86
87 #define AO_ST_MIN       300
88 #define AO_ST_MAX       800
89
90 extern uint16_t ao_mma655x_current;
91
92 void
93 ao_mma655x_init(void);
94
95 #endif /* _AO_MMA655X_H_ */