hige dura / Mbed 2 deprecated dotHR_EKF_phithe

Dependencies:   mbed FatFileSystem

Committer:
higedura
Date:
Mon Sep 17 09:39:54 2012 +0000
Revision:
1:0c42db451cb9
Parent:
0:75227c386257
dotHR_phothe

Who changed what in which revision?

UserRevisionLine numberNew contents of line
higedura 0:75227c386257 1 /**
higedura 0:75227c386257 2 * @author Uwe Gartmann
higedura 0:75227c386257 3 * @author Used HMC5883L library developed by Jose R. Padron and Aaron Berk as template
higedura 0:75227c386257 4 *
higedura 0:75227c386257 5 * @section LICENSE
higedura 0:75227c386257 6 *
higedura 0:75227c386257 7 * Copyright (c) 2010 ARM Limited
higedura 0:75227c386257 8 *
higedura 0:75227c386257 9 * Permission is hereby granted, free of charge, to any person obtaining a copy
higedura 0:75227c386257 10 * of this software and associated documentation files (the "Software"), to deal
higedura 0:75227c386257 11 * in the Software without restriction, including without limitation the rights
higedura 0:75227c386257 12 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
higedura 0:75227c386257 13 * copies of the Software, and to permit persons to whom the Software is
higedura 0:75227c386257 14 * furnished to do so, subject to the following conditions:
higedura 0:75227c386257 15 *
higedura 0:75227c386257 16 * The above copyright notice and this permission notice shall be included in
higedura 0:75227c386257 17 * all copies or substantial portions of the Software.
higedura 0:75227c386257 18 *
higedura 0:75227c386257 19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
higedura 0:75227c386257 20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
higedura 0:75227c386257 21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
higedura 0:75227c386257 22 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
higedura 0:75227c386257 23 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
higedura 0:75227c386257 24 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
higedura 0:75227c386257 25 * THE SOFTWARE.
higedura 0:75227c386257 26 *
higedura 0:75227c386257 27 * @section DESCRIPTION
higedura 0:75227c386257 28 *
higedura 0:75227c386257 29 * Honeywell HMC5883L digital compass.
higedura 0:75227c386257 30 *
higedura 0:75227c386257 31 * Datasheet:
higedura 0:75227c386257 32 *
higedura 0:75227c386257 33 * http://www.ssec.honeywell.com/magnetic/datasheets/HMC5883L.pdf
higedura 0:75227c386257 34 */
higedura 0:75227c386257 35
higedura 0:75227c386257 36 #ifndef HMC5883L_H
higedura 0:75227c386257 37 #define HMC5883L_H
higedura 0:75227c386257 38
higedura 0:75227c386257 39 /**
higedura 0:75227c386257 40 * Includes
higedura 0:75227c386257 41 */
higedura 0:75227c386257 42 #include "mbed.h"
higedura 0:75227c386257 43
higedura 0:75227c386257 44 /**
higedura 0:75227c386257 45 * Defines
higedura 0:75227c386257 46 */
higedura 0:75227c386257 47 #define HMC5883L_I2C_ADDRESS 0x1E //7-bit address. 0x3C write, 0x3D read.
higedura 0:75227c386257 48 #define HMC5883L_I2C_WRITE 0x3C
higedura 0:75227c386257 49 #define HMC5883L_I2C_READ 0x3D
higedura 0:75227c386257 50
higedura 0:75227c386257 51 //Values Config A
higedura 0:75227c386257 52 #define HMC5883L_0_5HZ_NORMAL 0x00
higedura 0:75227c386257 53 #define HMC5883L_0_5HZ_POSITIVE 0x01
higedura 0:75227c386257 54 #define HMC5883L_0_5HZ_NEGATIVE 0x02
higedura 0:75227c386257 55
higedura 0:75227c386257 56 #define HMC5883L_1HZ_NORMAL 0x04
higedura 0:75227c386257 57 #define HMC5883L_1HZ_POSITIVE 0x05
higedura 0:75227c386257 58 #define HMC5883L_1HZ_NEGATIVE 0x06
higedura 0:75227c386257 59
higedura 0:75227c386257 60 #define HMC5883L_2HZ_NORMAL 0x08
higedura 0:75227c386257 61 #define HMC5883L_2HZ_POSITIVE 0x09
higedura 0:75227c386257 62 #define HMC5883L_2HZ_NEGATIVE 0x0A
higedura 0:75227c386257 63
higedura 0:75227c386257 64 #define HMC5883L_5HZ_NORMAL 0x0C
higedura 0:75227c386257 65 #define HMC5883L_5HZ_POSITIVE 0x0D
higedura 0:75227c386257 66 #define HMC5883L_5HZ_NEGATIVE 0x0E
higedura 0:75227c386257 67
higedura 0:75227c386257 68 #define HMC5883L_10HZ_NORMAL 0x10
higedura 0:75227c386257 69 #define HMC5883L_10HZ_POSITIVE 0x11
higedura 0:75227c386257 70 #define HMC5883L_10HZ_NEGATIVE 0x12
higedura 0:75227c386257 71
higedura 0:75227c386257 72 #define HMC5883L_20HZ_NORMAL 0x14
higedura 0:75227c386257 73 #define HMC5883L_20HZ_POSITIVE 0x15
higedura 0:75227c386257 74 #define HMC5883L_20HZ_NEGATIVE 0x16
higedura 0:75227c386257 75
higedura 0:75227c386257 76 #define HMC5883L_50HZ_NORMAL 0x18
higedura 0:75227c386257 77 #define HMC5883L_50HZ_POSITIVE 0x19
higedura 0:75227c386257 78 #define HMC5883L_50HZ_NEGATIVE 0x1A
higedura 0:75227c386257 79
higedura 0:75227c386257 80 //Values Config B
higedura 0:75227c386257 81 #define HMC5883L_0_7GA 0x00
higedura 0:75227c386257 82 #define HMC5883L_1_0GA 0x20
higedura 0:75227c386257 83 #define HMC5883L_1_5GA 0x40
higedura 0:75227c386257 84 #define HMC5883L_2_0GA 0x60
higedura 0:75227c386257 85 #define HMC5883L_3_2GA 0x80
higedura 0:75227c386257 86 #define HMC5883L_3_8GA 0xA0
higedura 0:75227c386257 87 #define HMC5883L_4_5GA 0xC0
higedura 0:75227c386257 88 #define HMC5883L_6_5GA 0xE0
higedura 0:75227c386257 89
higedura 0:75227c386257 90 //Values MODE
higedura 0:75227c386257 91 #define HMC5883L_CONTINUOUS 0x00
higedura 0:75227c386257 92 #define HMC5883L_SINGLE 0x01
higedura 0:75227c386257 93 #define HMC5883L_IDLE 0x02
higedura 0:75227c386257 94 #define HMC5883L_SLEEP 0x03
higedura 0:75227c386257 95
higedura 0:75227c386257 96
higedura 0:75227c386257 97
higedura 0:75227c386257 98 #define HMC5883L_CONFIG_A 0x00
higedura 0:75227c386257 99 #define HMC5883L_CONFIG_B 0x01
higedura 0:75227c386257 100 #define HMC5883L_MODE 0x02
higedura 0:75227c386257 101 #define HMC5883L_X_MSB 0x03
higedura 0:75227c386257 102 #define HMC5883L_X_LSB 0x04
higedura 0:75227c386257 103 #define HMC5883L_Z_MSB 0x05
higedura 0:75227c386257 104 #define HMC5883L_Z_LSB 0x06
higedura 0:75227c386257 105 #define HMC5883L_Y_MSB 0x07
higedura 0:75227c386257 106 #define HMC5883L_Y_LSB 0x08
higedura 0:75227c386257 107 #define HMC5883L_STATUS 0x09
higedura 0:75227c386257 108 #define HMC5883L_IDENT_A 0x0A
higedura 0:75227c386257 109 #define HMC5883L_IDENT_B 0x0B
higedura 0:75227c386257 110 #define HMC5883L_IDENT_C 0x0C
higedura 0:75227c386257 111
higedura 0:75227c386257 112
higedura 0:75227c386257 113
higedura 0:75227c386257 114 /**
higedura 0:75227c386257 115 * Honeywell HMC5883L digital compass.
higedura 0:75227c386257 116 */
higedura 0:75227c386257 117 class HMC5883L {
higedura 0:75227c386257 118
higedura 0:75227c386257 119 public:
higedura 0:75227c386257 120
higedura 0:75227c386257 121 /**
higedura 0:75227c386257 122 * Constructor.
higedura 0:75227c386257 123 *
higedura 0:75227c386257 124 * @param sda mbed pin to use for SDA line of I2C interface.
higedura 0:75227c386257 125 * @param scl mbed pin to use for SCL line of I2C interface.
higedura 0:75227c386257 126 */
higedura 0:75227c386257 127 HMC5883L(PinName sda, PinName scl);
higedura 0:75227c386257 128
higedura 0:75227c386257 129
higedura 0:75227c386257 130 /**
higedura 0:75227c386257 131 * Enter into sleep mode.
higedura 0:75227c386257 132 *
higedura 0:75227c386257 133 */
higedura 0:75227c386257 134 void setSleepMode();
higedura 0:75227c386257 135
higedura 0:75227c386257 136
higedura 0:75227c386257 137 /**
higedura 0:75227c386257 138 * Set Device in Default Mode.
higedura 0:75227c386257 139 * HMC5883L_CONTINUOUS, HMC5883L_10HZ_NORMAL HMC5883L_1_0GA
higedura 0:75227c386257 140 */
higedura 0:75227c386257 141 void setDefault();
higedura 0:75227c386257 142
higedura 0:75227c386257 143
higedura 0:75227c386257 144 /**
higedura 0:75227c386257 145 * Read the memory location on the device which contains the address.
higedura 0:75227c386257 146 *
higedura 0:75227c386257 147 * @param Pointer to a buffer to hold the address value
higedura 0:75227c386257 148 * Expected H, 4 and 3.
higedura 0:75227c386257 149 */
higedura 0:75227c386257 150 void getAddress(char * address);
higedura 0:75227c386257 151
higedura 0:75227c386257 152
higedura 0:75227c386257 153
higedura 0:75227c386257 154 /**
higedura 0:75227c386257 155 * Set the operation mode.
higedura 0:75227c386257 156 *
higedura 0:75227c386257 157 * @param mode 0x00 -> Continuous
higedura 0:75227c386257 158 * 0x01 -> Single
higedura 0:75227c386257 159 * 0x02 -> Idle
higedura 0:75227c386257 160 * @param ConfigA values
higedura 0:75227c386257 161 * @param ConfigB values
higedura 0:75227c386257 162 */
higedura 0:75227c386257 163 void setOpMode(int mode, int ConfigA, int ConfigB);
higedura 0:75227c386257 164
higedura 0:75227c386257 165 /**
higedura 0:75227c386257 166 * Write to on the device.
higedura 0:75227c386257 167 *
higedura 0:75227c386257 168 * @param address Address to write to.
higedura 0:75227c386257 169 * @param data Data to write.
higedura 0:75227c386257 170 */
higedura 0:75227c386257 171
higedura 0:75227c386257 172 void write(int address, int data);
higedura 0:75227c386257 173
higedura 0:75227c386257 174 /**
higedura 0:75227c386257 175 * Get the output of all three axes.
higedura 0:75227c386257 176 *
higedura 0:75227c386257 177 * @param Pointer to a buffer to hold the magnetics value for the
higedura 0:75227c386257 178 * x-axis, y-axis and z-axis [in that order].
higedura 0:75227c386257 179 */
higedura 0:75227c386257 180 void readData(int* getMag);
higedura 0:75227c386257 181
higedura 0:75227c386257 182 /**
higedura 0:75227c386257 183 * Get the output of X axis.
higedura 0:75227c386257 184 *
higedura 0:75227c386257 185 * @return x-axis magnetic value
higedura 0:75227c386257 186 */
higedura 0:75227c386257 187 int getMx();
higedura 0:75227c386257 188
higedura 0:75227c386257 189 /**
higedura 0:75227c386257 190 * Get the output of Y axis.
higedura 0:75227c386257 191 *
higedura 0:75227c386257 192 * @return y-axis magnetic value
higedura 0:75227c386257 193 */
higedura 0:75227c386257 194 int getMy();
higedura 0:75227c386257 195
higedura 0:75227c386257 196 /**
higedura 0:75227c386257 197 * Get the output of Z axis.
higedura 0:75227c386257 198 *
higedura 0:75227c386257 199 * @return z-axis magnetic value
higedura 0:75227c386257 200 */
higedura 0:75227c386257 201 int getMz();
higedura 0:75227c386257 202
higedura 0:75227c386257 203
higedura 0:75227c386257 204 /**
higedura 0:75227c386257 205 * Get the current operation mode.
higedura 0:75227c386257 206 *
higedura 0:75227c386257 207 * @return Status register values
higedura 0:75227c386257 208 */
higedura 0:75227c386257 209 int getStatus(void);
higedura 0:75227c386257 210
higedura 0:75227c386257 211
higedura 0:75227c386257 212
higedura 0:75227c386257 213 I2C* i2c_;
higedura 0:75227c386257 214
higedura 0:75227c386257 215
higedura 0:75227c386257 216
higedura 0:75227c386257 217 };
higedura 0:75227c386257 218
higedura 0:75227c386257 219 #endif /* HMC5883L_H */