1 | /*
|
---|
2 | ****************************************************************************
|
---|
3 | * This file is part of Arduino Lucky Shield Library
|
---|
4 | *
|
---|
5 | * Copyright (c) 2016 Arduino srl. All right reserved.
|
---|
6 | *
|
---|
7 | * File : MMA8491Q.h
|
---|
8 | * Date : 2016/03/21
|
---|
9 | * Revision : 0.0.1 $
|
---|
10 | * Author: andrea[at]arduino[dot]org
|
---|
11 | *
|
---|
12 | ****************************************************************************
|
---|
13 |
|
---|
14 | This library is free software; you can redistribute it and/or
|
---|
15 | modify it under the terms of the GNU Lesser General Public
|
---|
16 | License as published by the Free Software Foundation; either
|
---|
17 | version 2.1 of the License, or (at your option) any later version.
|
---|
18 |
|
---|
19 | This library is distributed in the hope that it will be useful,
|
---|
20 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
21 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
22 | Lesser General Public License for more details.
|
---|
23 |
|
---|
24 | You should have received a copy of the GNU Lesser General Public
|
---|
25 | License along with this library; if not, write to the Free Software
|
---|
26 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
---|
27 |
|
---|
28 | ******************************************************************************/
|
---|
29 |
|
---|
30 | #ifndef MMA8491Q_h
|
---|
31 | #define MMA8491Q_h
|
---|
32 |
|
---|
33 | #include <Arduino.h>
|
---|
34 |
|
---|
35 | ///////////////////////////////////
|
---|
36 | // MMA8491Q Register Definitions //
|
---|
37 | ///////////////////////////////////
|
---|
38 |
|
---|
39 | #define STATE (uint8_t)0x00
|
---|
40 | #define GPIO_ADDRESS (uint8_t)0x20
|
---|
41 | #define GPIO_READ (uint8_t)0x00
|
---|
42 | #define GPIO_WRITE_PORT0 (uint8_t)0x02
|
---|
43 | #define ADDRESS (uint8_t)0x55
|
---|
44 |
|
---|
45 | ////////////////////////////////
|
---|
46 | // MMA8491Q Class Declaration //
|
---|
47 | ////////////////////////////////
|
---|
48 | class MMA8491Q
|
---|
49 | {
|
---|
50 | public:
|
---|
51 | MMA8491Q(uint8_t addr = ADDRESS);
|
---|
52 | void read();
|
---|
53 | float x(){return x_;};
|
---|
54 | float y(){return y_;};
|
---|
55 | float z(){return z_;};
|
---|
56 |
|
---|
57 | private:
|
---|
58 | byte address;
|
---|
59 | uint8_t data_read;
|
---|
60 | void readRegister(int reg);
|
---|
61 | float value(int val);
|
---|
62 | void enable();
|
---|
63 | void disable();
|
---|
64 | float x_;
|
---|
65 | float y_;
|
---|
66 | float z_;
|
---|
67 | uint16_t cx;
|
---|
68 | uint16_t cy;
|
---|
69 | uint16_t cz;
|
---|
70 | uint16_t state;
|
---|
71 |
|
---|
72 | };
|
---|
73 |
|
---|
74 | extern MMA8491Q mma8491q;
|
---|
75 |
|
---|
76 | #endif
|
---|