upm  1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
mma7660_regs.h
1 /*
2  * Author: Jon Trulson <jtrulson@ics.com>
3  * Copyright (c) 2016 Intel Corporation.
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining
6  * a copy of this software and associated documentation files (the
7  * "Software"), to deal in the Software without restriction, including
8  * without limitation the rights to use, copy, modify, merge, publish,
9  * distribute, sublicense, and/or sell copies of the Software, and to
10  * permit persons to whom the Software is furnished to do so, subject to
11  * the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be
14  * included in all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23  */
24 #pragma once
25 
26 #define MMA7660_DEFAULT_I2C_BUS 0
27 #define MMA7660_DEFAULT_I2C_ADDR 0x4c
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
33  // MMA7660 registers
34  typedef enum {
35  MMA7660_REG_XOUT = 0x00,
36  MMA7660_REG_YOUT = 0x01,
37  MMA7660_REG_ZOUT = 0x02,
38  MMA7660_REG_TILT = 0x03,
39  MMA7660_REG_SRST = 0x04, // Sampling Rate Status
40  MMA7660_REG_SPCNT = 0x05, // sleep count
41  MMA7660_REG_INTSU = 0x06, // Interrupt setup
42  MMA7660_REG_MODE = 0x07, // operating mode
43  MMA7660_REG_SR = 0x08, // auto-wake/sleep, SPS, and debounce
44  MMA7660_REG_PDET = 0x09, // tap detection
45  MMA7660_REG_PD = 0x0a // tap debounce count
46  // 0x0b-0x1f reserved
47  } MMA7660_REG_T;
48 
49  // interrupt enable register bits
50  typedef enum {
51  MMA7660_INTR_NONE = 0x00, // disabled
52  MMA7660_INTR_FBINT = 0x01, // front/back
53  MMA7660_INTR_PLINT = 0x02, // up/down/right/left
54  MMA7660_INTR_PDINT = 0x04, // tap detection
55  MMA7660_INTR_ASINT = 0x08, // exit auto-sleep
56  MMA7660_INTR_GINT = 0x10, // measurement intr
57  MMA7660_INTR_SHINTZ = 0x20, // shake on Z
58  MMA7660_INTR_SHINTY = 0x40, // shake on Y
59  MMA7660_INTR_SHINTX = 0x80 // shake on X
60  } MMA7660_INTR_T;
61 
62  // operating mode register bits
63  typedef enum {
64  MMA7660_MODE_MODE = 0x01, // determines mode with MODE_TON
65  // 0x02 reserved
66  MMA7660_MODE_TON = 0x04, // determines mode with MODE_MODE
67  MMA7660_MODE_AWE = 0x08, // auto-wake
68  MMA7660_MODE_ASE = 0x10, // auto-sleep
69  MMA7660_MODE_SCPS = 0x20, // sleep count prescale
70  MMA7660_MODE_IPP = 0x40, // intr out push-pull/open drain
71  MMA7660_MODE_IAH = 0x80 // intr active low/high
72  } MMA7660_MODE_T;
73 
74  // tilt BackFront (BF) bits
75  typedef enum {
76  MMA7660_BF_UNKNOWN = 0x00,
77  MMA7660_BF_LYING_FRONT = 0x01,
78  MMA7660_BF_LYING_BACK = 0x02
79  } MMA7660_TILT_BF_T;
80 
81  // tilt LandscapePortrait (LP) bits
82  typedef enum {
83  MMA7660_LP_UNKNOWN = 0x00,
84  MMA7660_LP_LANDSCAPE_LEFT = 0x01,
85  MMA7660_LP_LANDSCAPE_RIGHT = 0x02,
86  MMA7660_LP_VERT_DOWN = 0x05,
87  MMA7660_LP_VERT_UP = 0x06
88  } MMA7660_TILT_LP_T;
89 
90  // sample rate (auto-sleep) values
91  typedef enum {
92  MMA7660_AUTOSLEEP_120 = 0x00,
93  MMA7660_AUTOSLEEP_64 = 0x01,
94  MMA7660_AUTOSLEEP_32 = 0x02,
95  MMA7660_AUTOSLEEP_16 = 0x03,
96  MMA7660_AUTOSLEEP_8 = 0x04,
97  MMA7660_AUTOSLEEP_4 = 0x05,
98  MMA7660_AUTOSLEEP_2 = 0x06,
99  MMA7660_AUTOSLEEP_1 = 0x07
100  } MMA7660_AUTOSLEEP_T;
101 
102 #ifdef __cplusplus
103 }
104 #endif