Atsushi Hattori
/
20210627_Logger
hattori&ide
Embed:
(wiki syntax)
Show/hide line numbers
MMA8652.h
00001 /* Copyright (c) 2010-2011 mbed.org, MIT License 00002 * 00003 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 00004 * and associated documentation files (the "Software"), to deal in the Software without 00005 * restriction, including without limitation the rights to use, copy, modify, merge, publish, 00006 * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the 00007 * Software is furnished to do so, subject to the following conditions: 00008 * 00009 * The above copyright notice and this permission notice shall be included in all copies or 00010 * substantial portions of the Software. 00011 * 00012 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING 00013 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 00014 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 00015 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00016 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 00017 */ 00018 00019 #ifndef MMA8652_H 00020 #define MMA8652_H 00021 00022 #include "mbed.h" 00023 00024 00025 // MMA8652 Slave Address 00026 #define MMA8652_SLAVE_ADDR 0x38 00027 00028 // MMA8652 internal register addresses 00029 #define MMA8652_STATUS 0x00 00030 #define MMA8652_OUT_X_MSB 0x01 00031 #define MMA8652_WHOAMI 0x0D 00032 #define MMA8652_XYZ_DATA_CFG 0x0E 00033 #define MMA8652_CTRL_REG1 0x2A 00034 #define MMA8652_WHOAMI_VAL 0x4A 00035 00036 /** 00037 * MMA8652 Xtrinsic accelerometer on I2C 00038 */ 00039 class MMA8652 00040 { 00041 public: 00042 /** 00043 * MMA8652 constructor 00044 * 00045 * @param sda SDA pin 00046 * @param sdl SCL pin 00047 */ 00048 MMA8652(PinName sda, PinName scl); 00049 00050 /** 00051 * MMA8652 destructor 00052 */ 00053 ~MMA8652(); 00054 00055 /** 00056 * Get XYZ axis acceleration in floating point G's 00057 * 00058 * @param res array where acceleration data will be stored 00059 */ 00060 void ReadXYZ(float * a); 00061 00062 /** 00063 * Get XYZ axis acceleration, signed 16 bit values 00064 * 00065 * @param res array where acceleration data will be stored 00066 */ 00067 void ReadXYZraw(int16_t * d); 00068 00069 /** 00070 * Get the value of the WHO_AM_I register 00071 * 00072 * @returns DEVICE_ID value == 0x3A 00073 */ 00074 char getWhoAmI(void); 00075 00076 private: 00077 I2C _i2c; 00078 00079 /** 00080 * Set the device in active mode 00081 */ 00082 void begin( void); 00083 00084 void RegRead( char reg, char * d, int len); 00085 00086 }; 00087 00088 #endif
Generated on Sun Dec 18 2022 08:16:46 by 1.7.2