]>
git.gir.st - tmk_keyboard.git/blob - tmk_core/tool/mbed/mbed-sdk/libraries/tests/peripherals/MMA8451Q/MMA8451Q.h
1 /* Copyright (c) 2010-2011 mbed.org, MIT License
3 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
4 * and associated documentation files (the "Software"), to deal in the Software without
5 * restriction, including without limitation the rights to use, copy, modify, merge, publish,
6 * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
7 * Software is furnished to do so, subject to the following conditions:
9 * The above copyright notice and this permission notice shall be included in all copies or
10 * substantial portions of the Software.
12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
13 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
14 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
15 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 * MMA8451Q accelerometer example
27 * #include "MMA8451Q.h"
29 * #define MMA8451_I2C_ADDRESS (0x1d<<1)
32 * DigitalOut led(LED_GREEN);
33 * MMA8451Q acc(P_E25, P_E24, MMA8451_I2C_ADDRESS);
34 * printf("WHO AM I: 0x%2X\r\n", acc.getWhoAmI());
37 * printf("-----------\r\n");
38 * printf("acc_x: %d\r\n", acc.getAccX());
39 * printf("acc_y: %d\r\n", acc.getAccY());
40 * printf("acc_z: %d\r\n", acc.getAccZ());
51 * MMA8451Q constructor
55 * @param addr addr of the I2C peripheral
57 MMA8451Q(PinName sda
, PinName scl
, int addr
);
65 * Get the value of the WHO_AM_I register
67 * @returns WHO_AM_I value
72 * Get X axis acceleration
74 * @returns X axis acceleration
79 * Get Y axis acceleration
81 * @returns Y axis acceleration
86 * Get Z axis acceleration
88 * @returns Z axis acceleration
93 * Get XYZ axis acceleration
95 * @param res array where acceleration data will be stored
97 void getAccAllAxis(int16_t * res
);
102 void readRegs(int addr
, uint8_t * data
, int len
);
103 void writeRegs(uint8_t * data
, int len
);
104 int16_t getAccAxis(uint8_t addr
);