Pololu Minimu-9 library

Committer:
bengo
Date:
Tue Feb 21 13:34:27 2012 +0000
Revision:
0:6ee4ef99c382
first release

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bengo 0:6ee4ef99c382 1 /* mbed L3G4200D Library version 0beta1
bengo 0:6ee4ef99c382 2 * Copyright (c) 2012 bengo
bengo 0:6ee4ef99c382 3 *
bengo 0:6ee4ef99c382 4 * Permission is hereby granted, free of charge, to any person obtaining a copy
bengo 0:6ee4ef99c382 5 * of this software and associated documentation files (the "Software"), to deal
bengo 0:6ee4ef99c382 6 * in the Software without restriction, including without limitation the rights
bengo 0:6ee4ef99c382 7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
bengo 0:6ee4ef99c382 8 * copies of the Software, and to permit persons to whom the Software is
bengo 0:6ee4ef99c382 9 * furnished to do so, subject to the following conditions:
bengo 0:6ee4ef99c382 10 *
bengo 0:6ee4ef99c382 11 * The above copyright notice and this permission notice shall be included in
bengo 0:6ee4ef99c382 12 * all copies or substantial portions of the Software.
bengo 0:6ee4ef99c382 13 *
bengo 0:6ee4ef99c382 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
bengo 0:6ee4ef99c382 15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
bengo 0:6ee4ef99c382 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
bengo 0:6ee4ef99c382 17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
bengo 0:6ee4ef99c382 18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
bengo 0:6ee4ef99c382 19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
bengo 0:6ee4ef99c382 20 * THE SOFTWARE.
bengo 0:6ee4ef99c382 21 */
bengo 0:6ee4ef99c382 22
bengo 0:6ee4ef99c382 23 #ifndef L3G4200D_h
bengo 0:6ee4ef99c382 24 #define L3G4200D_h
bengo 0:6ee4ef99c382 25
bengo 0:6ee4ef99c382 26 #include "mbed.h"
bengo 0:6ee4ef99c382 27 #include <vector>
bengo 0:6ee4ef99c382 28
bengo 0:6ee4ef99c382 29 class L3G4200D {
bengo 0:6ee4ef99c382 30
bengo 0:6ee4ef99c382 31 public:
bengo 0:6ee4ef99c382 32
bengo 0:6ee4ef99c382 33 /**
bengo 0:6ee4ef99c382 34 * Create an L3G4200D object connected to the specified I2C pins
bengo 0:6ee4ef99c382 35 * @param sda I2C SDA pin
bengo 0:6ee4ef99c382 36 * @param scl I2C SCL pin
bengo 0:6ee4ef99c382 37 */
bengo 0:6ee4ef99c382 38 L3G4200D( PinName sda, PinName scl );
bengo 0:6ee4ef99c382 39
bengo 0:6ee4ef99c382 40 /**
bengo 0:6ee4ef99c382 41 * Return status code of prevoius function call
bengo 0:6ee4ef99c382 42 */
bengo 0:6ee4ef99c382 43 inline int getStatus( void ) { return( _status ); }
bengo 0:6ee4ef99c382 44
bengo 0:6ee4ef99c382 45 /**
bengo 0:6ee4ef99c382 46 * Read specified register content
bengo 0:6ee4ef99c382 47 * @param reg register address
bengo 0:6ee4ef99c382 48 */
bengo 0:6ee4ef99c382 49 int registerRead( int reg );
bengo 0:6ee4ef99c382 50
bengo 0:6ee4ef99c382 51 /**
bengo 0:6ee4ef99c382 52 * Write to specified register
bengo 0:6ee4ef99c382 53 * @param reg register address
bengo 0:6ee4ef99c382 54 * @parma data data to be written
bengo 0:6ee4ef99c382 55 */
bengo 0:6ee4ef99c382 56 void registerWrite( int reg, char data );
bengo 0:6ee4ef99c382 57
bengo 0:6ee4ef99c382 58 /**
bengo 0:6ee4ef99c382 59 * read gyroscope vector
bengo 0:6ee4ef99c382 60 */
bengo 0:6ee4ef99c382 61 std::vector<short> read( void );
bengo 0:6ee4ef99c382 62
bengo 0:6ee4ef99c382 63 /**
bengo 0:6ee4ef99c382 64 * Read angular velogity (in degrees per second)
bengo 0:6ee4ef99c382 65 */
bengo 0:6ee4ef99c382 66 std::vector<float> angularVelocity( void );
bengo 0:6ee4ef99c382 67
bengo 0:6ee4ef99c382 68 /**
bengo 0:6ee4ef99c382 69 * Read temperature (in celsius)
bengo 0:6ee4ef99c382 70 */
bengo 0:6ee4ef99c382 71 int temperature( void );
bengo 0:6ee4ef99c382 72
bengo 0:6ee4ef99c382 73 // Device registers addresses
bengo 0:6ee4ef99c382 74 static const int WHO_AM_I;
bengo 0:6ee4ef99c382 75 static const int CTRL_REG1;
bengo 0:6ee4ef99c382 76 static const int CTRL_REG2;
bengo 0:6ee4ef99c382 77 static const int CTRL_REG3;
bengo 0:6ee4ef99c382 78 static const int CTRL_REG4;
bengo 0:6ee4ef99c382 79 static const int CTRL_REG5;
bengo 0:6ee4ef99c382 80 static const int REFERENCE;
bengo 0:6ee4ef99c382 81 static const int OUT_TEMP;
bengo 0:6ee4ef99c382 82 static const int STATUS_REG;
bengo 0:6ee4ef99c382 83 static const int OUT_X_L;
bengo 0:6ee4ef99c382 84 static const int OUT_X_H;
bengo 0:6ee4ef99c382 85 static const int OUT_Y_L;
bengo 0:6ee4ef99c382 86 static const int OUT_Y_H;
bengo 0:6ee4ef99c382 87 static const int OUT_Z_L;
bengo 0:6ee4ef99c382 88 static const int OUT_Z_H;
bengo 0:6ee4ef99c382 89 static const int FIFO_CTRL_REG;
bengo 0:6ee4ef99c382 90 static const int FIFO_SRC_REG;
bengo 0:6ee4ef99c382 91 static const int INT1_CFG;
bengo 0:6ee4ef99c382 92 static const int INT1_SRC;
bengo 0:6ee4ef99c382 93 static const int INT1_THS_XH;
bengo 0:6ee4ef99c382 94 static const int INT1_THS_XL;
bengo 0:6ee4ef99c382 95 static const int INT1_THS_YH;
bengo 0:6ee4ef99c382 96 static const int INT1_THS_YL;
bengo 0:6ee4ef99c382 97 static const int INT1_THS_ZH;
bengo 0:6ee4ef99c382 98 static const int INT1_THS_ZL;
bengo 0:6ee4ef99c382 99 static const int INT1_DURATION;
bengo 0:6ee4ef99c382 100
bengo 0:6ee4ef99c382 101 private:
bengo 0:6ee4ef99c382 102
bengo 0:6ee4ef99c382 103 int _status;
bengo 0:6ee4ef99c382 104 I2C _i2c;
bengo 0:6ee4ef99c382 105 char _bytes[7];
bengo 0:6ee4ef99c382 106
bengo 0:6ee4ef99c382 107 static const int GYR_ADDRESS;
bengo 0:6ee4ef99c382 108
bengo 0:6ee4ef99c382 109 };
bengo 0:6ee4ef99c382 110
bengo 0:6ee4ef99c382 111 #endif // L3G4200D_h