Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
L3G4200D.h
00001 /* Copyright (c) 2011 Pololu Corporation. For more information, see 00002 * 00003 * http://www.pololu.com/ 00004 * http://forum.pololu.com/ 00005 * 00006 * Permission is hereby granted, free of charge, to any person 00007 * obtaining a copy of this software and associated documentation 00008 * files (the "Software"), to deal in the Software without 00009 * restriction, including without limitation the rights to use, 00010 * copy, modify, merge, publish, distribute, sublicense, and/or sell 00011 * copies of the Software, and to permit persons to whom the 00012 * Software is furnished to do so, subject to the following 00013 * conditions: 00014 * 00015 * The above copyright notice and this permission notice shall be 00016 * included in all copies or substantial portions of the Software. 00017 * 00018 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 00019 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 00020 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 00021 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 00022 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 00023 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 00024 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 00025 * OTHER DEALINGS IN THE SOFTWARE. 00026 */ 00027 00028 #ifndef __L3G4200D_H 00029 #define __L3G4200D_H 00030 00031 #include "mbed.h" 00032 00033 // register addresses 00034 00035 #define L3G4200D_WHO_AM_I 0x0F 00036 00037 #define L3G4200D_CTRL_REG1 0x20 00038 #define L3G4200D_CTRL_REG2 0x21 00039 #define L3G4200D_CTRL_REG3 0x22 00040 #define L3G4200D_CTRL_REG4 0x23 00041 #define L3G4200D_CTRL_REG5 0x24 00042 #define L3G4200D_REFERENCE 0x25 00043 #define L3G4200D_OUT_TEMP 0x26 00044 #define L3G4200D_STATUS_REG 0x27 00045 00046 #define L3G4200D_OUT_X_L 0x28 00047 #define L3G4200D_OUT_X_H 0x29 00048 #define L3G4200D_OUT_Y_L 0x2A 00049 #define L3G4200D_OUT_Y_H 0x2B 00050 #define L3G4200D_OUT_Z_L 0x2C 00051 #define L3G4200D_OUT_Z_H 0x2D 00052 00053 #define L3G4200D_FIFO_CTRL_REG 0x2E 00054 #define L3G4200D_FIFO_SRC_REG 0x2F 00055 00056 #define L3G4200D_INT1_CFG 0x30 00057 #define L3G4200D_INT1_SRC 0x31 00058 #define L3G4200D_INT1_THS_XH 0x32 00059 #define L3G4200D_INT1_THS_XL 0x33 00060 #define L3G4200D_INT1_THS_YH 0x34 00061 #define L3G4200D_INT1_THS_YL 0x35 00062 #define L3G4200D_INT1_THS_ZH 0x36 00063 #define L3G4200D_INT1_THS_ZL 0x37 00064 #define L3G4200D_INT1_DURATION 0x38 00065 00066 typedef char byte; 00067 00068 /** Interface library for the ST L3G4200D 3-axis gyro 00069 * 00070 * Ported from Pololu L3G4200D library for Arduino by 00071 * Michael Shimniok http://bot-thoughts.com 00072 * 00073 * @code 00074 * #include "mbed.h" 00075 * #include "L3G4200D.h" 00076 * L3G4200D gyro(p28, p27); 00077 * ... 00078 * int g[3]; 00079 * gyro.read(g); 00080 * @endcode 00081 */ 00082 class L3G4200D 00083 { 00084 public: 00085 /** Create a new L3G4200D I2C interface 00086 * @param sda is the pin for the I2C SDA line 00087 * @param scl is the pin for the I2C SCL line 00088 */ 00089 L3G4200D(PinName sda, PinName scl); 00090 00091 /** Read gyro values 00092 * @param g Array containing x, y, and z gyro values 00093 * @return g Array containing x, y, and z gyro values 00094 */ 00095 void read(int g[3]); 00096 00097 private: 00098 byte data[6]; 00099 int _rates[3]; 00100 I2C _device; 00101 void writeReg(byte reg, byte value); 00102 byte readReg(byte reg); 00103 void enableDefault(void); 00104 }; 00105 00106 #endif
Generated on Sat Jul 16 2022 23:33:02 by
1.7.2