Needed for FXAS21000 NXP gyroscope
Fork of FXAS21000 by
FXAS21000.h@1:88a036a417bf, 2014-04-19 (annotated)
- Committer:
- JimCarver
- Date:
- Sat Apr 19 00:13:03 2014 +0000
- Revision:
- 1:88a036a417bf
- Parent:
- 0:4cfc774d6d85
- Child:
- 2:cd21ef326977
Basic component library for the FXAS21000 gyro from Freescale
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
JimCarver | 1:88a036a417bf | 1 | /* Copyright (c) 2010-2011 mbed.org, MIT License |
JimCarver | 1:88a036a417bf | 2 | * |
JimCarver | 1:88a036a417bf | 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software |
JimCarver | 1:88a036a417bf | 4 | * and associated documentation files (the "Software"), to deal in the Software without |
JimCarver | 1:88a036a417bf | 5 | * restriction, including without limitation the rights to use, copy, modify, merge, publish, |
JimCarver | 1:88a036a417bf | 6 | * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the |
JimCarver | 1:88a036a417bf | 7 | * Software is furnished to do so, subject to the following conditions: |
JimCarver | 1:88a036a417bf | 8 | * |
JimCarver | 1:88a036a417bf | 9 | * The above copyright notice and this permission notice shall be included in all copies or |
JimCarver | 1:88a036a417bf | 10 | * substantial portions of the Software. |
JimCarver | 1:88a036a417bf | 11 | * |
JimCarver | 1:88a036a417bf | 12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING |
JimCarver | 1:88a036a417bf | 13 | * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
JimCarver | 1:88a036a417bf | 14 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
JimCarver | 1:88a036a417bf | 15 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
JimCarver | 1:88a036a417bf | 16 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
JimCarver | 1:88a036a417bf | 17 | */ |
JimCarver | 1:88a036a417bf | 18 | |
JimCarver | 0:4cfc774d6d85 | 19 | #ifndef FXAS21000_H |
JimCarver | 0:4cfc774d6d85 | 20 | #define FXAS21000_H |
JimCarver | 0:4cfc774d6d85 | 21 | |
JimCarver | 0:4cfc774d6d85 | 22 | #include "mbed.h" |
JimCarver | 0:4cfc774d6d85 | 23 | |
JimCarver | 0:4cfc774d6d85 | 24 | |
JimCarver | 0:4cfc774d6d85 | 25 | // MMA8652 Slave Address |
JimCarver | 0:4cfc774d6d85 | 26 | #define FXAS21000_SLAVE_ADDR 0x40 |
JimCarver | 0:4cfc774d6d85 | 27 | |
JimCarver | 0:4cfc774d6d85 | 28 | // MMA8652 internal register addresses |
JimCarver | 0:4cfc774d6d85 | 29 | #define FXAS21000_STATUS 0x00 |
JimCarver | 0:4cfc774d6d85 | 30 | #define FXAS21000_WHOAMI 0x0C |
JimCarver | 0:4cfc774d6d85 | 31 | #define FXAS21000_XYZ_DATA_CFG 0x0E |
JimCarver | 0:4cfc774d6d85 | 32 | #define FXAS21000_CTRL_REG0 0x0D |
JimCarver | 0:4cfc774d6d85 | 33 | #define FXAS21000_CTRL_REG1 0x13 |
JimCarver | 0:4cfc774d6d85 | 34 | #define FXAS21000_WHOAMI_VAL 0xD1 |
JimCarver | 0:4cfc774d6d85 | 35 | |
JimCarver | 0:4cfc774d6d85 | 36 | class FXAS21000 |
JimCarver | 0:4cfc774d6d85 | 37 | { |
JimCarver | 0:4cfc774d6d85 | 38 | public: |
JimCarver | 0:4cfc774d6d85 | 39 | /** |
JimCarver | 0:4cfc774d6d85 | 40 | * FXAS21000 constructor |
JimCarver | 0:4cfc774d6d85 | 41 | * |
JimCarver | 0:4cfc774d6d85 | 42 | * @param sda SDA pin |
JimCarver | 0:4cfc774d6d85 | 43 | * @param sdl SCL pin |
JimCarver | 0:4cfc774d6d85 | 44 | * |
JimCarver | 0:4cfc774d6d85 | 45 | */ |
JimCarver | 0:4cfc774d6d85 | 46 | FXAS21000(PinName sda, PinName scl); |
JimCarver | 0:4cfc774d6d85 | 47 | |
JimCarver | 0:4cfc774d6d85 | 48 | |
JimCarver | 0:4cfc774d6d85 | 49 | /** |
JimCarver | 0:4cfc774d6d85 | 50 | * Get the Gyro values |
JimCarver | 0:4cfc774d6d85 | 51 | * Result is floating point degrees / second |
JimCarver | 0:4cfc774d6d85 | 52 | * |
JimCarver | 0:4cfc774d6d85 | 53 | * @param floating point array where the results will be placed |
JimCarver | 0:4cfc774d6d85 | 54 | */ |
JimCarver | 0:4cfc774d6d85 | 55 | void ReadXYZ(float * a); |
JimCarver | 0:4cfc774d6d85 | 56 | |
JimCarver | 0:4cfc774d6d85 | 57 | |
JimCarver | 0:4cfc774d6d85 | 58 | /** |
JimCarver | 0:4cfc774d6d85 | 59 | * Get the Gyro values |
JimCarver | 0:4cfc774d6d85 | 60 | * Result is signed 16 bit value |
JimCarver | 0:4cfc774d6d85 | 61 | * |
JimCarver | 0:4cfc774d6d85 | 62 | * @param int16_t point array where the results will be placed |
JimCarver | 0:4cfc774d6d85 | 63 | */ |
JimCarver | 0:4cfc774d6d85 | 64 | void ReadXYZraw(int16_t * t); |
JimCarver | 0:4cfc774d6d85 | 65 | |
JimCarver | 0:4cfc774d6d85 | 66 | |
JimCarver | 0:4cfc774d6d85 | 67 | /** |
JimCarver | 0:4cfc774d6d85 | 68 | * Get the value of the WHO_AM_I register |
JimCarver | 0:4cfc774d6d85 | 69 | * |
JimCarver | 0:4cfc774d6d85 | 70 | * @returns DEVICE_ID value == 0xD1 |
JimCarver | 0:4cfc774d6d85 | 71 | */ |
JimCarver | 0:4cfc774d6d85 | 72 | //char getWhoAmI(); |
JimCarver | 0:4cfc774d6d85 | 73 | char getWhoAmI(void); |
JimCarver | 0:4cfc774d6d85 | 74 | |
JimCarver | 0:4cfc774d6d85 | 75 | private: |
JimCarver | 0:4cfc774d6d85 | 76 | |
JimCarver | 0:4cfc774d6d85 | 77 | I2C _i2c; |
JimCarver | 0:4cfc774d6d85 | 78 | /** Set the device in active mode |
JimCarver | 0:4cfc774d6d85 | 79 | */ |
JimCarver | 0:4cfc774d6d85 | 80 | void begin( void); |
JimCarver | 0:4cfc774d6d85 | 81 | |
JimCarver | 0:4cfc774d6d85 | 82 | void RegRead( char reg, char * d, int len); |
JimCarver | 0:4cfc774d6d85 | 83 | |
JimCarver | 0:4cfc774d6d85 | 84 | |
JimCarver | 0:4cfc774d6d85 | 85 | }; |
JimCarver | 0:4cfc774d6d85 | 86 | |
JimCarver | 0:4cfc774d6d85 | 87 | #endif |