東北大学学友会準加盟団体 From The Earth の高高度ロケットFTE-06(通称:海豚)にて使用したソフトウェアです.ご自由にお使いください.このプログラムによって生じた損害について当団体は一切責任を負いません.また,各モジュールのライブラリは当団体が作成したものではないので再配布は禁止します.

Dependencies:   mbed FATFileSystem

Fork of FTE-06 by Tetsushi Amano

Committer:
mizuki_akaike
Date:
Fri Aug 25 03:42:30 2017 +0000
Revision:
57:d78497a079cf
Parent:
23:9be034083282
??????

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mizuki_akaike 23:9be034083282 1 /* Copyright (c) 2011 Pololu Corporation. For more information, see
mizuki_akaike 23:9be034083282 2 *
mizuki_akaike 23:9be034083282 3 * http://www.pololu.com/
mizuki_akaike 23:9be034083282 4 * http://forum.pololu.com/
mizuki_akaike 23:9be034083282 5 *
mizuki_akaike 23:9be034083282 6 * Permission is hereby granted, free of charge, to any person
mizuki_akaike 23:9be034083282 7 * obtaining a copy of this software and associated documentation
mizuki_akaike 23:9be034083282 8 * files (the "Software"), to deal in the Software without
mizuki_akaike 23:9be034083282 9 * restriction, including without limitation the rights to use,
mizuki_akaike 23:9be034083282 10 * copy, modify, merge, publish, distribute, sublicense, and/or sell
mizuki_akaike 23:9be034083282 11 * copies of the Software, and to permit persons to whom the
mizuki_akaike 23:9be034083282 12 * Software is furnished to do so, subject to the following
mizuki_akaike 23:9be034083282 13 * conditions:
mizuki_akaike 23:9be034083282 14 *
mizuki_akaike 23:9be034083282 15 * The above copyright notice and this permission notice shall be
mizuki_akaike 23:9be034083282 16 * included in all copies or substantial portions of the Software.
mizuki_akaike 23:9be034083282 17 *
mizuki_akaike 23:9be034083282 18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
mizuki_akaike 23:9be034083282 19 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
mizuki_akaike 23:9be034083282 20 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
mizuki_akaike 23:9be034083282 21 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
mizuki_akaike 23:9be034083282 22 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
mizuki_akaike 23:9be034083282 23 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
mizuki_akaike 23:9be034083282 24 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
mizuki_akaike 23:9be034083282 25 * OTHER DEALINGS IN THE SOFTWARE.
mizuki_akaike 23:9be034083282 26 */
mizuki_akaike 23:9be034083282 27
mizuki_akaike 23:9be034083282 28 #ifndef __L3GD20_H
mizuki_akaike 23:9be034083282 29 #define __L3GD20_H
mizuki_akaike 23:9be034083282 30
mizuki_akaike 23:9be034083282 31 #include "mbed.h"
mizuki_akaike 23:9be034083282 32
mizuki_akaike 23:9be034083282 33 // register addresses
mizuki_akaike 23:9be034083282 34
mizuki_akaike 23:9be034083282 35 #define L3GD20_WHO_AM_I 0x0F
mizuki_akaike 23:9be034083282 36
mizuki_akaike 23:9be034083282 37 #define L3GD20_CTRL_REG1 0x20
mizuki_akaike 23:9be034083282 38 #define L3GD20_CTRL_REG2 0x21
mizuki_akaike 23:9be034083282 39 #define L3GD20_CTRL_REG3 0x22
mizuki_akaike 23:9be034083282 40 #define L3GD20_CTRL_REG4 0x23
mizuki_akaike 23:9be034083282 41 #define L3GD20_CTRL_REG5 0x24
mizuki_akaike 23:9be034083282 42 #define L3GD20_REFERENCE 0x25
mizuki_akaike 23:9be034083282 43 #define L3GD20_OUT_TEMP 0x26
mizuki_akaike 23:9be034083282 44 #define L3GD20_STATUS_REG 0x27
mizuki_akaike 23:9be034083282 45
mizuki_akaike 23:9be034083282 46 #define L3GD20_OUT_X_L 0x28
mizuki_akaike 23:9be034083282 47 #define L3GD20_OUT_X_H 0x29
mizuki_akaike 23:9be034083282 48 #define L3GD20_OUT_Y_L 0x2A
mizuki_akaike 23:9be034083282 49 #define L3GD20_OUT_Y_H 0x2B
mizuki_akaike 23:9be034083282 50 #define L3GD20_OUT_Z_L 0x2C
mizuki_akaike 23:9be034083282 51 #define L3GD20_OUT_Z_H 0x2D
mizuki_akaike 23:9be034083282 52
mizuki_akaike 23:9be034083282 53 #define L3GD20_FIFO_CTRL_REG 0x2E
mizuki_akaike 23:9be034083282 54 #define L3GD20_FIFO_SRC_REG 0x2F
mizuki_akaike 23:9be034083282 55
mizuki_akaike 23:9be034083282 56 #define L3GD20_INT1_CFG 0x30
mizuki_akaike 23:9be034083282 57 #define L3GD20_INT1_SRC 0x31
mizuki_akaike 23:9be034083282 58 #define L3GD20_INT1_THS_XH 0x32
mizuki_akaike 23:9be034083282 59 #define L3GD20_INT1_THS_XL 0x33
mizuki_akaike 23:9be034083282 60 #define L3GD20_INT1_THS_YH 0x34
mizuki_akaike 23:9be034083282 61 #define L3GD20_INT1_THS_YL 0x35
mizuki_akaike 23:9be034083282 62 #define L3GD20_INT1_THS_ZH 0x36
mizuki_akaike 23:9be034083282 63 #define L3GD20_INT1_THS_ZL 0x37
mizuki_akaike 23:9be034083282 64 #define L3GD20_INT1_DURATION 0x38
mizuki_akaike 23:9be034083282 65 #define L3GD20_LOW_ODR 0x39 // D20H
mizuki_akaike 23:9be034083282 66
mizuki_akaike 23:9be034083282 67 /** Interface library for the ST L3GD20 3-axis gyro
mizuki_akaike 23:9be034083282 68 *
mizuki_akaike 23:9be034083282 69 * Ported from Pololu L3GD20 library for Arduino by
mizuki_akaike 23:9be034083282 70 *
mizuki_akaike 23:9be034083282 71 * @code
mizuki_akaike 23:9be034083282 72 * #include "mbed.h"
mizuki_akaike 23:9be034083282 73 * #include "L3GD20.h"
mizuki_akaike 23:9be034083282 74 * L3GD20 gyro(p28, p27);
mizuki_akaike 23:9be034083282 75 * ...
mizuki_akaike 23:9be034083282 76 * int g[3];
mizuki_akaike 23:9be034083282 77 * gyro.read(g);
mizuki_akaike 23:9be034083282 78 * @endcode
mizuki_akaike 23:9be034083282 79 */
mizuki_akaike 23:9be034083282 80 class L3GD20
mizuki_akaike 23:9be034083282 81 {
mizuki_akaike 23:9be034083282 82 public:
mizuki_akaike 23:9be034083282 83 /** Create a new L3GD20 I2C interface
mizuki_akaike 23:9be034083282 84 * @param sda is the pin for the I2C SDA line
mizuki_akaike 23:9be034083282 85 * @param scl is the pin for the I2C SCL line
mizuki_akaike 23:9be034083282 86 */
mizuki_akaike 23:9be034083282 87 L3GD20(PinName sda, PinName scl);
mizuki_akaike 23:9be034083282 88
mizuki_akaike 23:9be034083282 89 /** Read gyro values
mizuki_akaike 23:9be034083282 90 * @param g Array containing x, y, and z gyro values
mizuki_akaike 23:9be034083282 91 * @return g Array containing x, y, and z gyro values
mizuki_akaike 23:9be034083282 92 */
mizuki_akaike 23:9be034083282 93 bool read(float *gx, float *gy, float *gz);
mizuki_akaike 23:9be034083282 94
mizuki_akaike 23:9be034083282 95 private:
mizuki_akaike 23:9be034083282 96 I2C _L3GD20;
mizuki_akaike 23:9be034083282 97 float gx, gy, gz;
mizuki_akaike 23:9be034083282 98
mizuki_akaike 23:9be034083282 99 bool write_reg(int addr_i2c,int addr_reg, char v);
mizuki_akaike 23:9be034083282 100 bool read_reg(int addr_i2c,int addr_reg, char *v);
mizuki_akaike 23:9be034083282 101 bool recv(char sad, char sub, char *buf, int length);
mizuki_akaike 23:9be034083282 102 };
mizuki_akaike 23:9be034083282 103
mizuki_akaike 23:9be034083282 104 #endif