ble

Dependencies:   HC_SR04_Ultrasonic_Library Servo mbed

Fork of FIP_REV1 by Robotique FIP

Committer:
julientiron
Date:
Tue May 19 16:53:44 2015 +0000
Revision:
1:bdbf36f8408d
ddd; ;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
julientiron 1:bdbf36f8408d 1 /**
julientiron 1:bdbf36f8408d 2 ******************************************************************************
julientiron 1:bdbf36f8408d 3 * @file lis3mdl.h
julientiron 1:bdbf36f8408d 4 * @author MEMS Application Team
julientiron 1:bdbf36f8408d 5 * @version V1.0.0
julientiron 1:bdbf36f8408d 6 * @date 30-July-2014
julientiron 1:bdbf36f8408d 7 * @brief This file contains definitions for the lis3mdl.c
julientiron 1:bdbf36f8408d 8 * firmware driver.
julientiron 1:bdbf36f8408d 9 ******************************************************************************
julientiron 1:bdbf36f8408d 10 * @attention
julientiron 1:bdbf36f8408d 11 *
julientiron 1:bdbf36f8408d 12 * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
julientiron 1:bdbf36f8408d 13 *
julientiron 1:bdbf36f8408d 14 * Redistribution and use in source and binary forms, with or without modification,
julientiron 1:bdbf36f8408d 15 * are permitted provided that the following conditions are met:
julientiron 1:bdbf36f8408d 16 * 1. Redistributions of source code must retain the above copyright notice,
julientiron 1:bdbf36f8408d 17 * this list of conditions and the following disclaimer.
julientiron 1:bdbf36f8408d 18 * 2. Redistributions in binary form must reproduce the above copyright notice,
julientiron 1:bdbf36f8408d 19 * this list of conditions and the following disclaimer in the documentation
julientiron 1:bdbf36f8408d 20 * and/or other materials provided with the distribution.
julientiron 1:bdbf36f8408d 21 * 3. Neither the name of STMicroelectronics nor the names of its contributors
julientiron 1:bdbf36f8408d 22 * may be used to endorse or promote products derived from this software
julientiron 1:bdbf36f8408d 23 * without specific prior written permission.
julientiron 1:bdbf36f8408d 24 *
julientiron 1:bdbf36f8408d 25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
julientiron 1:bdbf36f8408d 26 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
julientiron 1:bdbf36f8408d 27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
julientiron 1:bdbf36f8408d 28 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
julientiron 1:bdbf36f8408d 29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
julientiron 1:bdbf36f8408d 30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
julientiron 1:bdbf36f8408d 31 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
julientiron 1:bdbf36f8408d 32 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
julientiron 1:bdbf36f8408d 33 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
julientiron 1:bdbf36f8408d 34 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
julientiron 1:bdbf36f8408d 35 *
julientiron 1:bdbf36f8408d 36 ******************************************************************************
julientiron 1:bdbf36f8408d 37 */
julientiron 1:bdbf36f8408d 38
julientiron 1:bdbf36f8408d 39 /* Define to prevent recursive inclusion -------------------------------------*/
julientiron 1:bdbf36f8408d 40 #ifndef __LIS3MDL_H
julientiron 1:bdbf36f8408d 41 #define __LIS3MDL_H
julientiron 1:bdbf36f8408d 42
julientiron 1:bdbf36f8408d 43 #ifdef __cplusplus
julientiron 1:bdbf36f8408d 44 extern "C" {
julientiron 1:bdbf36f8408d 45 #endif
julientiron 1:bdbf36f8408d 46
julientiron 1:bdbf36f8408d 47 /* Includes ------------------------------------------------------------------*/
julientiron 1:bdbf36f8408d 48 #include "magneto.h"
julientiron 1:bdbf36f8408d 49
julientiron 1:bdbf36f8408d 50 /** @addtogroup BSP
julientiron 1:bdbf36f8408d 51 * @{
julientiron 1:bdbf36f8408d 52 */
julientiron 1:bdbf36f8408d 53
julientiron 1:bdbf36f8408d 54 /** @addtogroup LIS3MDL
julientiron 1:bdbf36f8408d 55 * @{
julientiron 1:bdbf36f8408d 56 */
julientiron 1:bdbf36f8408d 57
julientiron 1:bdbf36f8408d 58 /** @defgroup LIS3MDL_Exported_Constants
julientiron 1:bdbf36f8408d 59 * @{
julientiron 1:bdbf36f8408d 60 */
julientiron 1:bdbf36f8408d 61
julientiron 1:bdbf36f8408d 62
julientiron 1:bdbf36f8408d 63
julientiron 1:bdbf36f8408d 64 /******************************************************************************/
julientiron 1:bdbf36f8408d 65 /***************** START MAGNETIC SENSOR REGISTER MAPPING ********************/
julientiron 1:bdbf36f8408d 66 /******************************************************************************/
julientiron 1:bdbf36f8408d 67
julientiron 1:bdbf36f8408d 68 /**
julientiron 1:bdbf36f8408d 69 * @brief Device identifier register.
julientiron 1:bdbf36f8408d 70 * \code
julientiron 1:bdbf36f8408d 71 * Read
julientiron 1:bdbf36f8408d 72 * Default value:
julientiron 1:bdbf36f8408d 73 * 7:0 This read-only register contains the device identifier
julientiron 1:bdbf36f8408d 74 * \endcode
julientiron 1:bdbf36f8408d 75 */
julientiron 1:bdbf36f8408d 76 #define LIS3MDL_M_WHO_AM_I_ADDR 0x0F
julientiron 1:bdbf36f8408d 77
julientiron 1:bdbf36f8408d 78
julientiron 1:bdbf36f8408d 79 /**
julientiron 1:bdbf36f8408d 80 * @brief Magnetic sensor Control Register 1
julientiron 1:bdbf36f8408d 81 * \code
julientiron 1:bdbf36f8408d 82 * Read/write
julientiron 1:bdbf36f8408d 83 * Default value: 0x10
julientiron 1:bdbf36f8408d 84 * [7] TEMP_COMP: Temperature compensation enable
julientiron 1:bdbf36f8408d 85 * [6:5] OM1-0: X and Y axes operative mode selection
julientiron 1:bdbf36f8408d 86 * [4:2] DO2-0: Output data rate selection
julientiron 1:bdbf36f8408d 87 * [1] This bit must be set to �0� for the correct operation of the device
julientiron 1:bdbf36f8408d 88 * [0] ST: Self-test enable
julientiron 1:bdbf36f8408d 89 * \endcode
julientiron 1:bdbf36f8408d 90 */
julientiron 1:bdbf36f8408d 91 #define LIS3MDL_M_CTRL_REG1_M 0x20
julientiron 1:bdbf36f8408d 92
julientiron 1:bdbf36f8408d 93
julientiron 1:bdbf36f8408d 94 /**
julientiron 1:bdbf36f8408d 95 * @brief Magnetic sensor Control Register 2
julientiron 1:bdbf36f8408d 96 * \code
julientiron 1:bdbf36f8408d 97 * Read/write
julientiron 1:bdbf36f8408d 98 * Default value: 0x00
julientiron 1:bdbf36f8408d 99 * [7] These bits must be set to �0� for the correct operation of the device
julientiron 1:bdbf36f8408d 100 * [6:5] FS1-0: Full-scale configuration
julientiron 1:bdbf36f8408d 101 * [4] These bits must be set to �0� for the correct operation of the device
julientiron 1:bdbf36f8408d 102 * [3] REBOOT: Reboot memory content
julientiron 1:bdbf36f8408d 103 * [2] SOFT_RST: Configuration registers and user register reset function
julientiron 1:bdbf36f8408d 104 * [1:0] These bits must be set to �0� for the correct operation of the device
julientiron 1:bdbf36f8408d 105 * \endcode
julientiron 1:bdbf36f8408d 106 */
julientiron 1:bdbf36f8408d 107 #define LIS3MDL_M_CTRL_REG2_M 0x21
julientiron 1:bdbf36f8408d 108
julientiron 1:bdbf36f8408d 109
julientiron 1:bdbf36f8408d 110 /**
julientiron 1:bdbf36f8408d 111 * @brief Magnetic sensor Control Register 3
julientiron 1:bdbf36f8408d 112 * \code
julientiron 1:bdbf36f8408d 113 * Read/write
julientiron 1:bdbf36f8408d 114 * Default value: 0x03
julientiron 1:bdbf36f8408d 115 * [7] I2C_DISABLE: Disable I2C interface
julientiron 1:bdbf36f8408d 116 * [6] These bits must be set to �0� for the correct operation of the device
julientiron 1:bdbf36f8408d 117 * [5] LP: Low-power mode configuration
julientiron 1:bdbf36f8408d 118 * [4:3] These bits must be set to �0� for the correct operation of the device
julientiron 1:bdbf36f8408d 119 * [2] SIM: SPI Serial Interface mode selection
julientiron 1:bdbf36f8408d 120 * [1:0] MD1-0: Operating mode selection
julientiron 1:bdbf36f8408d 121 * \endcode
julientiron 1:bdbf36f8408d 122 */
julientiron 1:bdbf36f8408d 123 #define LIS3MDL_M_CTRL_REG3_M 0x22
julientiron 1:bdbf36f8408d 124
julientiron 1:bdbf36f8408d 125
julientiron 1:bdbf36f8408d 126 /**
julientiron 1:bdbf36f8408d 127 * @brief Magnetic sensor data (LSB)
julientiron 1:bdbf36f8408d 128 * \code
julientiron 1:bdbf36f8408d 129 * Read
julientiron 1:bdbf36f8408d 130 * \endcode
julientiron 1:bdbf36f8408d 131 */
julientiron 1:bdbf36f8408d 132 #define LIS3MDL_M_OUT_X_L_M 0x28
julientiron 1:bdbf36f8408d 133
julientiron 1:bdbf36f8408d 134
julientiron 1:bdbf36f8408d 135 /**
julientiron 1:bdbf36f8408d 136 * @brief Magnetic sensor data (MSB)
julientiron 1:bdbf36f8408d 137 * \code
julientiron 1:bdbf36f8408d 138 * Read
julientiron 1:bdbf36f8408d 139 * \endcode
julientiron 1:bdbf36f8408d 140 */
julientiron 1:bdbf36f8408d 141 #define LIS3MDL_M_OUT_X_H_M 0x29
julientiron 1:bdbf36f8408d 142
julientiron 1:bdbf36f8408d 143
julientiron 1:bdbf36f8408d 144 /**
julientiron 1:bdbf36f8408d 145 * @brief Magnetic sensor data (LSB)
julientiron 1:bdbf36f8408d 146 * \code
julientiron 1:bdbf36f8408d 147 * Read
julientiron 1:bdbf36f8408d 148 * \endcode
julientiron 1:bdbf36f8408d 149 */
julientiron 1:bdbf36f8408d 150 #define LIS3MDL_M_OUT_Y_L_M 0x2A
julientiron 1:bdbf36f8408d 151
julientiron 1:bdbf36f8408d 152
julientiron 1:bdbf36f8408d 153 /**
julientiron 1:bdbf36f8408d 154 * @brief Magnetic sensor data (MSB)
julientiron 1:bdbf36f8408d 155 * \code
julientiron 1:bdbf36f8408d 156 * Read
julientiron 1:bdbf36f8408d 157 * \endcode
julientiron 1:bdbf36f8408d 158 */
julientiron 1:bdbf36f8408d 159 #define LIS3MDL_M_OUT_Y_H_M 0x2B
julientiron 1:bdbf36f8408d 160
julientiron 1:bdbf36f8408d 161
julientiron 1:bdbf36f8408d 162 /**
julientiron 1:bdbf36f8408d 163 * @brief Magnetic sensor data (LSB)
julientiron 1:bdbf36f8408d 164 * \code
julientiron 1:bdbf36f8408d 165 * Read
julientiron 1:bdbf36f8408d 166 * \endcode
julientiron 1:bdbf36f8408d 167 */
julientiron 1:bdbf36f8408d 168 #define LIS3MDL_M_OUT_Z_L_M 0x2C
julientiron 1:bdbf36f8408d 169
julientiron 1:bdbf36f8408d 170
julientiron 1:bdbf36f8408d 171 /**
julientiron 1:bdbf36f8408d 172 * @brief Magnetic sensor data (MSB)
julientiron 1:bdbf36f8408d 173 * \code
julientiron 1:bdbf36f8408d 174 * Read
julientiron 1:bdbf36f8408d 175 * \endcode
julientiron 1:bdbf36f8408d 176 */
julientiron 1:bdbf36f8408d 177 #define LIS3MDL_M_OUT_Z_H_M 0x2D
julientiron 1:bdbf36f8408d 178
julientiron 1:bdbf36f8408d 179
julientiron 1:bdbf36f8408d 180 /**
julientiron 1:bdbf36f8408d 181 * @brief Magnetic sensor Interrupt config register
julientiron 1:bdbf36f8408d 182 * \code
julientiron 1:bdbf36f8408d 183 * Read/write
julientiron 1:bdbf36f8408d 184 * Default value: 0x00
julientiron 1:bdbf36f8408d 185 * [7] XIEN: Enable interrupt generation on X axis
julientiron 1:bdbf36f8408d 186 * [6] YIEN: Enable interrupt generation on Y axis
julientiron 1:bdbf36f8408d 187 * [5] ZIEN: Enable interrupt generation on Z axis
julientiron 1:bdbf36f8408d 188 * [4:3] Must be 0
julientiron 1:bdbf36f8408d 189 * [2] IEA: Interrupt active configuration on INT
julientiron 1:bdbf36f8408d 190 * [1] LIR: Latch interrupt request
julientiron 1:bdbf36f8408d 191 * [0] IEN: Interrupt enable on INT pin
julientiron 1:bdbf36f8408d 192 * \endcode
julientiron 1:bdbf36f8408d 193 */
julientiron 1:bdbf36f8408d 194 #define LIS3MDL_M_INT_CFG 0x30
julientiron 1:bdbf36f8408d 195
julientiron 1:bdbf36f8408d 196
julientiron 1:bdbf36f8408d 197 /**
julientiron 1:bdbf36f8408d 198 * @brief Magnetic sensor Interrupt source register
julientiron 1:bdbf36f8408d 199 * \code
julientiron 1:bdbf36f8408d 200 * Read/write
julientiron 1:bdbf36f8408d 201 * Default value: 0x00
julientiron 1:bdbf36f8408d 202 * [7] PTH_X: Value on X-axis exceeds the threshold on the positive side
julientiron 1:bdbf36f8408d 203 * [6] PTH_Y: Value on Y-axis exceeds the threshold on the positive side
julientiron 1:bdbf36f8408d 204 * [5] PTH_Z: Value on Z-axis exceeds the threshold on the positive side
julientiron 1:bdbf36f8408d 205 * [4] NTH_X: Value on X-axis exceeds the threshold on the negative side
julientiron 1:bdbf36f8408d 206 * [3] NTH_Y: Value on Y-axis exceeds the threshold on the negative side
julientiron 1:bdbf36f8408d 207 * [2] NTH_Z: Value on Z-axis exceeds the threshold on the negative side
julientiron 1:bdbf36f8408d 208 * [1] MROI: Internal measurement range overflow on magnetic value
julientiron 1:bdbf36f8408d 209 * [0] INT: This bit signals when interrupt event occours
julientiron 1:bdbf36f8408d 210 * \endcode
julientiron 1:bdbf36f8408d 211 */
julientiron 1:bdbf36f8408d 212 #define LIS3MDL_M_INT_SRC 0x31
julientiron 1:bdbf36f8408d 213
julientiron 1:bdbf36f8408d 214
julientiron 1:bdbf36f8408d 215 /**
julientiron 1:bdbf36f8408d 216 * @brief Magnetic sensor Interrupt threshold register low
julientiron 1:bdbf36f8408d 217 * \code
julientiron 1:bdbf36f8408d 218 * Read/write
julientiron 1:bdbf36f8408d 219 * Default value: 0x00
julientiron 1:bdbf36f8408d 220 * [7:0] THS7-0: Least 8 significant bits of interrupt threshold
julientiron 1:bdbf36f8408d 221 * \endcode
julientiron 1:bdbf36f8408d 222 */
julientiron 1:bdbf36f8408d 223 #define LIS3MDL_M_INT_THS_L_M 0x32
julientiron 1:bdbf36f8408d 224
julientiron 1:bdbf36f8408d 225
julientiron 1:bdbf36f8408d 226 /**
julientiron 1:bdbf36f8408d 227 * @brief Magnetic sensor Interrupt threshold register high
julientiron 1:bdbf36f8408d 228 * \code
julientiron 1:bdbf36f8408d 229 * Read/write
julientiron 1:bdbf36f8408d 230 * Default value: 0x00
julientiron 1:bdbf36f8408d 231 * [7] Must be 0
julientiron 1:bdbf36f8408d 232 * [6:0] THS14-8: Most 7 significant bits of interrupt threshold
julientiron 1:bdbf36f8408d 233 * \endcode
julientiron 1:bdbf36f8408d 234 */
julientiron 1:bdbf36f8408d 235 #define LIS3MDL_M_INT_THS_H_M 0x33
julientiron 1:bdbf36f8408d 236
julientiron 1:bdbf36f8408d 237 /******************************************************************************/
julientiron 1:bdbf36f8408d 238 /******************* END MAGNETIC SENSOR REGISTER MAPPING ********************/
julientiron 1:bdbf36f8408d 239 /******************************************************************************/
julientiron 1:bdbf36f8408d 240
julientiron 1:bdbf36f8408d 241
julientiron 1:bdbf36f8408d 242
julientiron 1:bdbf36f8408d 243 /**
julientiron 1:bdbf36f8408d 244 * @brief Device Address
julientiron 1:bdbf36f8408d 245 */
julientiron 1:bdbf36f8408d 246 #define LIS3MDL_M_MEMS_ADDRESS 0x38 // SAD[1] = 0
julientiron 1:bdbf36f8408d 247 //#define LIS3MDL_M_MEMS_ADDRESS 0x3C // SAD[1] = 1
julientiron 1:bdbf36f8408d 248
julientiron 1:bdbf36f8408d 249 /**
julientiron 1:bdbf36f8408d 250 * @brief Device Identifier. Default value of the WHO_AM_I register.
julientiron 1:bdbf36f8408d 251 */
julientiron 1:bdbf36f8408d 252 #define I_AM_LIS3MDL_M ((uint8_t)0x3D)
julientiron 1:bdbf36f8408d 253
julientiron 1:bdbf36f8408d 254
julientiron 1:bdbf36f8408d 255 /*********************************** MAGNETIC SENSOR REGISTERS VALUE ****************************************/
julientiron 1:bdbf36f8408d 256
julientiron 1:bdbf36f8408d 257 /** @defgroup LIS3MDL_M Temperature compensation enable selection CTRL_REG1_M
julientiron 1:bdbf36f8408d 258 * @{
julientiron 1:bdbf36f8408d 259 */
julientiron 1:bdbf36f8408d 260 #define LIS3MDL_M_TEMP_COMP_DISABLE ((uint8_t)0x00) /*!< Temperature compensation: disable */
julientiron 1:bdbf36f8408d 261 #define LIS3MDL_M_TEMP_COMP_ENABLE ((uint8_t)0x80) /*!< Temperature compensation: enable */
julientiron 1:bdbf36f8408d 262
julientiron 1:bdbf36f8408d 263 #define LIS3MDL_M_TEMP_COMP_MASK ((uint8_t)0x80)
julientiron 1:bdbf36f8408d 264
julientiron 1:bdbf36f8408d 265
julientiron 1:bdbf36f8408d 266 /** @defgroup LIS3MDL_M X and Y axes operative mode selection CTRL_REG1_M
julientiron 1:bdbf36f8408d 267 * @{
julientiron 1:bdbf36f8408d 268 */
julientiron 1:bdbf36f8408d 269 #define LIS3MDL_M_OM_LP ((uint8_t)0x00) /*!< X and Y axes operative mode: Low-power mode */
julientiron 1:bdbf36f8408d 270 #define LIS3MDL_M_OM_MP ((uint8_t)0x20) /*!< X and Y axes operative mode: Medium-performance mode */
julientiron 1:bdbf36f8408d 271 #define LIS3MDL_M_OM_HP ((uint8_t)0x40) /*!< X and Y axes operative mode: High-performance mode */
julientiron 1:bdbf36f8408d 272 #define LIS3MDL_M_OM_UHP ((uint8_t)0x60) /*!< X and Y axes operative mode: Ultra-high performance mode */
julientiron 1:bdbf36f8408d 273
julientiron 1:bdbf36f8408d 274 #define LIS3MDL_M_OM_MASK ((uint8_t)0x60)
julientiron 1:bdbf36f8408d 275
julientiron 1:bdbf36f8408d 276
julientiron 1:bdbf36f8408d 277 /** @defgroup LIS3MDL_M Output data rate selection CTRL_REG1_M
julientiron 1:bdbf36f8408d 278 * @{
julientiron 1:bdbf36f8408d 279 */
julientiron 1:bdbf36f8408d 280 #define LIS3MDL_M_DO_0_625 ((uint8_t)0x00) /*!< Output data rate selection: 0.625 */
julientiron 1:bdbf36f8408d 281 #define LIS3MDL_M_DO_1_25 ((uint8_t)0x04) /*!< Output data rate selection: 1.25 */
julientiron 1:bdbf36f8408d 282 #define LIS3MDL_M_DO_2_5 ((uint8_t)0x08) /*!< Output data rate selection: 2.5 */
julientiron 1:bdbf36f8408d 283 #define LIS3MDL_M_DO_5 ((uint8_t)0x0C) /*!< Output data rate selection: 5 */
julientiron 1:bdbf36f8408d 284 #define LIS3MDL_M_DO_10 ((uint8_t)0x10) /*!< Output data rate selection: 10 */
julientiron 1:bdbf36f8408d 285 #define LIS3MDL_M_DO_20 ((uint8_t)0x14) /*!< Output data rate selection: 20 */
julientiron 1:bdbf36f8408d 286 #define LIS3MDL_M_DO_40 ((uint8_t)0x18) /*!< Output data rate selection: 40 */
julientiron 1:bdbf36f8408d 287 #define LIS3MDL_M_DO_80 ((uint8_t)0x1C) /*!< Output data rate selection: 80 */
julientiron 1:bdbf36f8408d 288
julientiron 1:bdbf36f8408d 289 #define LIS3MDL_M_DO_MASK ((uint8_t)0x1C)
julientiron 1:bdbf36f8408d 290
julientiron 1:bdbf36f8408d 291
julientiron 1:bdbf36f8408d 292 /** @defgroup LIS3MDL_M Self-test enable selection CTRL_REG1_M
julientiron 1:bdbf36f8408d 293 * @{
julientiron 1:bdbf36f8408d 294 */
julientiron 1:bdbf36f8408d 295 #define LIS3MDL_M_ST_DISABLE ((uint8_t)0x00) /*!< Self-test: disable */
julientiron 1:bdbf36f8408d 296 #define LIS3MDL_M_ST_ENABLE ((uint8_t)0x01) /*!< Self-test: enable */
julientiron 1:bdbf36f8408d 297
julientiron 1:bdbf36f8408d 298 #define LIS3MDL_M_ST_MASK ((uint8_t)0x01)
julientiron 1:bdbf36f8408d 299
julientiron 1:bdbf36f8408d 300
julientiron 1:bdbf36f8408d 301 /** @defgroup LIS3MDL_M Full scale selection CTRL_REG2_M
julientiron 1:bdbf36f8408d 302 * @{
julientiron 1:bdbf36f8408d 303 */
julientiron 1:bdbf36f8408d 304 #define LIS3MDL_M_FS_4 ((uint8_t)0x00) /*!< Full scale: +-4 guass */
julientiron 1:bdbf36f8408d 305 #define LIS3MDL_M_FS_8 ((uint8_t)0x20) /*!< Full scale: +-8 gauss */
julientiron 1:bdbf36f8408d 306 #define LIS3MDL_M_FS_12 ((uint8_t)0x40) /*!< Full scale: +-12 gauss */
julientiron 1:bdbf36f8408d 307 #define LIS3MDL_M_FS_16 ((uint8_t)0x60) /*!< Full scale: +-16 gauss */
julientiron 1:bdbf36f8408d 308
julientiron 1:bdbf36f8408d 309 #define LIS3MDL_M_FS_MASK ((uint8_t)0x60)
julientiron 1:bdbf36f8408d 310
julientiron 1:bdbf36f8408d 311
julientiron 1:bdbf36f8408d 312 /** @defgroup LIS3MDL_M Reboot memory selection CTRL_REG2_M
julientiron 1:bdbf36f8408d 313 * @{
julientiron 1:bdbf36f8408d 314 */
julientiron 1:bdbf36f8408d 315 #define LIS3MDL_M_REBOOT_NORMAL ((uint8_t)0x00) /*!< Reboot mode: normal mode */
julientiron 1:bdbf36f8408d 316 #define LIS3MDL_M_REBOOT_MEM_CONTENT ((uint8_t)0x08) /*!< Reboot mode: reboot memory content */
julientiron 1:bdbf36f8408d 317
julientiron 1:bdbf36f8408d 318 #define LIS3MDL_M_REBOOT_MASK ((uint8_t)0x08)
julientiron 1:bdbf36f8408d 319
julientiron 1:bdbf36f8408d 320
julientiron 1:bdbf36f8408d 321 /** @defgroup LIS3MDL_M Configuration registers and user register reset CTRL_REG2_M
julientiron 1:bdbf36f8408d 322 * @{
julientiron 1:bdbf36f8408d 323 */
julientiron 1:bdbf36f8408d 324 #define LIS3MDL_M_SOFT_RST_DEFAULT ((uint8_t)0x00) /*!< Reset function: default value */
julientiron 1:bdbf36f8408d 325 #define LIS3MDL_M_SOFT_RST_RESET ((uint8_t)0x04) /*!< Reset function: reset operation */
julientiron 1:bdbf36f8408d 326
julientiron 1:bdbf36f8408d 327 #define LIS3MDL_M_SOFT_RST_MASK ((uint8_t)0x04)
julientiron 1:bdbf36f8408d 328
julientiron 1:bdbf36f8408d 329
julientiron 1:bdbf36f8408d 330 /** @defgroup LIS3MDL_M Disable I2C interface selection CTRL_REG3_M
julientiron 1:bdbf36f8408d 331 * @{
julientiron 1:bdbf36f8408d 332 */
julientiron 1:bdbf36f8408d 333 #define LIS3MDL_M_I2C_ENABLE ((uint8_t)0x00) /*!< I2C interface: enable */
julientiron 1:bdbf36f8408d 334 #define LIS3MDL_M_I2C_DISABLE ((uint8_t)0x80) /*!< I2C interface: disable */
julientiron 1:bdbf36f8408d 335
julientiron 1:bdbf36f8408d 336 #define LIS3MDL_M_I2C_MASK ((uint8_t)0x80)
julientiron 1:bdbf36f8408d 337
julientiron 1:bdbf36f8408d 338
julientiron 1:bdbf36f8408d 339 /** @defgroup LIS3MDL_M Low-power mode selection CTRL_REG3_M
julientiron 1:bdbf36f8408d 340 * @{
julientiron 1:bdbf36f8408d 341 */
julientiron 1:bdbf36f8408d 342 #define LIS3MDL_M_LP_ENABLE ((uint8_t)0x00) /*!< Low-power mode: magnetic data rate is configured by
julientiron 1:bdbf36f8408d 343 the DO bits in the CTRL_REG1_M */
julientiron 1:bdbf36f8408d 344 #define LIS3MDL_M_LP_DISABLE ((uint8_t)0x20) /*!< Low-power mode: the DO bits is set to 0.625 Hz and the system performs,
julientiron 1:bdbf36f8408d 345 for each channel, the minimum number of averages */
julientiron 1:bdbf36f8408d 346
julientiron 1:bdbf36f8408d 347 #define LIS3MDL_M_LP_MASK ((uint8_t)0x20)
julientiron 1:bdbf36f8408d 348
julientiron 1:bdbf36f8408d 349
julientiron 1:bdbf36f8408d 350 /** @defgroup LIS3MDL_M SPI Serial Interface mode selection CTRL_REG3_M
julientiron 1:bdbf36f8408d 351 * @{
julientiron 1:bdbf36f8408d 352 */
julientiron 1:bdbf36f8408d 353 #define LIS3MDL_M_SPI_R_ENABLE ((uint8_t)0x00) /*!< SPI Serial Interface mode: only write operations enabled */
julientiron 1:bdbf36f8408d 354 #define LIS3MDL_M_SPI_R_DISABLE ((uint8_t)0x40) /*!< SPI Serial Interface mode: read and write operations enable */
julientiron 1:bdbf36f8408d 355
julientiron 1:bdbf36f8408d 356 #define LIS3MDL_M_SPI_R_MASK ((uint8_t)0x40)
julientiron 1:bdbf36f8408d 357
julientiron 1:bdbf36f8408d 358
julientiron 1:bdbf36f8408d 359 /** @defgroup LIS3MDL_M Operating mode selection CTRL_REG3_M
julientiron 1:bdbf36f8408d 360 * @{
julientiron 1:bdbf36f8408d 361 */
julientiron 1:bdbf36f8408d 362 #define LIS3MDL_M_MD_CONTINUOUS ((uint8_t)0x00) /*!< Operating mode: Continuous-conversion mode */
julientiron 1:bdbf36f8408d 363 #define LIS3MDL_M_MD_SINGLE ((uint8_t)0x01) /*!< Operating mode: Single-conversion mode has to be used with sampling frequency from 0.625 Hz to 80 Hz. */
julientiron 1:bdbf36f8408d 364 #define LIS3MDL_M_MD_PD ((uint8_t)0x02) /*!< Operating mode: Power-down mode */
julientiron 1:bdbf36f8408d 365
julientiron 1:bdbf36f8408d 366 #define LIS3MDL_M_MD_MASK ((uint8_t)0x03)
julientiron 1:bdbf36f8408d 367
julientiron 1:bdbf36f8408d 368 /**
julientiron 1:bdbf36f8408d 369 * @}
julientiron 1:bdbf36f8408d 370 */
julientiron 1:bdbf36f8408d 371
julientiron 1:bdbf36f8408d 372
julientiron 1:bdbf36f8408d 373 /** @defgroup LIS3MDL_Imported_Functions
julientiron 1:bdbf36f8408d 374 * @{
julientiron 1:bdbf36f8408d 375 */
julientiron 1:bdbf36f8408d 376
julientiron 1:bdbf36f8408d 377 /* Magneto sensor driver structure */
julientiron 1:bdbf36f8408d 378 extern MAGNETO_DrvTypeDef LIS3MDLDrv;
julientiron 1:bdbf36f8408d 379
julientiron 1:bdbf36f8408d 380 /* Magneto sensor IO functions */
julientiron 1:bdbf36f8408d 381 void MAGNETO_IO_Init(void);
julientiron 1:bdbf36f8408d 382 void MAGNETO_IO_Write(uint8_t* pBuffer, uint8_t DeviceAddr, uint8_t WriteAddr,
julientiron 1:bdbf36f8408d 383 uint16_t NumByteToWrite);
julientiron 1:bdbf36f8408d 384 void MAGNETO_IO_Read(uint8_t* pBuffer, uint8_t DeviceAddr,
julientiron 1:bdbf36f8408d 385 uint8_t RegisterAddr, uint16_t NumByteToRead);
julientiron 1:bdbf36f8408d 386
julientiron 1:bdbf36f8408d 387 /**
julientiron 1:bdbf36f8408d 388 * @}
julientiron 1:bdbf36f8408d 389 */
julientiron 1:bdbf36f8408d 390
julientiron 1:bdbf36f8408d 391
julientiron 1:bdbf36f8408d 392 /** @defgroup LIS3MDL_Exported_Functions
julientiron 1:bdbf36f8408d 393 * @{
julientiron 1:bdbf36f8408d 394 */
julientiron 1:bdbf36f8408d 395
julientiron 1:bdbf36f8408d 396 /* Sensor Functions */
julientiron 1:bdbf36f8408d 397 void LIS3MDL_Init(MAGNETO_InitTypeDef *LIS3MDL_Init);
julientiron 1:bdbf36f8408d 398 uint8_t LIS3MDL_Read_M_ID(void);
julientiron 1:bdbf36f8408d 399 void LIS3MDL_M_GetAxes(int32_t *pData);
julientiron 1:bdbf36f8408d 400
julientiron 1:bdbf36f8408d 401 /**
julientiron 1:bdbf36f8408d 402 * @}
julientiron 1:bdbf36f8408d 403 */
julientiron 1:bdbf36f8408d 404
julientiron 1:bdbf36f8408d 405 /**
julientiron 1:bdbf36f8408d 406 * @}
julientiron 1:bdbf36f8408d 407 */
julientiron 1:bdbf36f8408d 408
julientiron 1:bdbf36f8408d 409 /**
julientiron 1:bdbf36f8408d 410 * @}
julientiron 1:bdbf36f8408d 411 */
julientiron 1:bdbf36f8408d 412
julientiron 1:bdbf36f8408d 413 #ifdef __cplusplus
julientiron 1:bdbf36f8408d 414 }
julientiron 1:bdbf36f8408d 415 #endif
julientiron 1:bdbf36f8408d 416
julientiron 1:bdbf36f8408d 417 #endif /* __LIS3MDL_H */
julientiron 1:bdbf36f8408d 418
julientiron 1:bdbf36f8408d 419 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
julientiron 1:bdbf36f8408d 420