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