3-axis MEMS ultra low power magnetometer

Dependencies:   X_NUCLEO_COMMON ST_INTERFACES

Dependents:   X_NUCLEO_IKS01A3

Committer:
cparata
Date:
Wed Jul 24 14:18:39 2019 +0000
Revision:
1:8562ae1a0534
Parent:
0:671edf39d961
Format with Astyle

Who changed what in which revision?

UserRevisionLine numberNew contents of line
cparata 0:671edf39d961 1 /*
cparata 0:671edf39d961 2 ******************************************************************************
cparata 0:671edf39d961 3 * @file lis2mdl_reg.h
cparata 0:671edf39d961 4 * @author Sensors Software Solution Team
cparata 0:671edf39d961 5 * @brief This file contains all the functions prototypes for the
cparata 0:671edf39d961 6 * lis2mdl_reg.c driver.
cparata 0:671edf39d961 7 ******************************************************************************
cparata 0:671edf39d961 8 * @attention
cparata 0:671edf39d961 9 *
cparata 0:671edf39d961 10 * <h2><center>&copy; COPYRIGHT(c) 2018 STMicroelectronics</center></h2>
cparata 0:671edf39d961 11 *
cparata 0:671edf39d961 12 * Redistribution and use in source and binary forms, with or without
cparata 0:671edf39d961 13 * modification, are permitted provided that the following conditions
cparata 0:671edf39d961 14 * are met:
cparata 0:671edf39d961 15 * 1. Redistributions of source code must retain the above copyright notice,
cparata 0:671edf39d961 16 * this list of conditions and the following disclaimer.
cparata 0:671edf39d961 17 * 2. Redistributions in binary form must reproduce the above copyright
cparata 0:671edf39d961 18 * notice, this list of conditions and the following disclaimer in the
cparata 0:671edf39d961 19 * documentation and/or other materials provided with the distribution.
cparata 0:671edf39d961 20 * 3. Neither the name of STMicroelectronics nor the names of its
cparata 0:671edf39d961 21 * contributors may be used to endorse or promote products derived from
cparata 0:671edf39d961 22 * this software without specific prior written permission.
cparata 0:671edf39d961 23 *
cparata 0:671edf39d961 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
cparata 0:671edf39d961 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
cparata 0:671edf39d961 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
cparata 0:671edf39d961 27 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
cparata 0:671edf39d961 28 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
cparata 0:671edf39d961 29 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
cparata 0:671edf39d961 30 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
cparata 0:671edf39d961 31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
cparata 0:671edf39d961 32 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
cparata 0:671edf39d961 33 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
cparata 0:671edf39d961 34 * POSSIBILITY OF SUCH DAMAGE.
cparata 0:671edf39d961 35 *
cparata 0:671edf39d961 36 */
cparata 0:671edf39d961 37 /* Define to prevent recursive inclusion -------------------------------------*/
cparata 0:671edf39d961 38 #ifndef LIS2MDL_REGS_H
cparata 0:671edf39d961 39 #define LIS2MDL_REGS_H
cparata 0:671edf39d961 40
cparata 0:671edf39d961 41 #ifdef __cplusplus
cparata 1:8562ae1a0534 42 extern "C" {
cparata 0:671edf39d961 43 #endif
cparata 0:671edf39d961 44
cparata 0:671edf39d961 45 /* Includes ------------------------------------------------------------------*/
cparata 0:671edf39d961 46 #include <stdint.h>
cparata 0:671edf39d961 47 #include <math.h>
cparata 0:671edf39d961 48
cparata 0:671edf39d961 49
cparata 0:671edf39d961 50 #ifndef float_t
cparata 0:671edf39d961 51 #define float_t float
cparata 0:671edf39d961 52 #endif
cparata 0:671edf39d961 53
cparata 0:671edf39d961 54 /** @addtogroup LIS2MDL
cparata 0:671edf39d961 55 * @{
cparata 0:671edf39d961 56 *
cparata 0:671edf39d961 57 */
cparata 0:671edf39d961 58
cparata 0:671edf39d961 59 /** @defgroup LIS2MDL_sensors_common_types
cparata 0:671edf39d961 60 * @{
cparata 0:671edf39d961 61 *
cparata 0:671edf39d961 62 */
cparata 0:671edf39d961 63
cparata 0:671edf39d961 64 #ifndef MEMS_SHARED_TYPES
cparata 0:671edf39d961 65 #define MEMS_SHARED_TYPES
cparata 0:671edf39d961 66
cparata 0:671edf39d961 67 /**
cparata 0:671edf39d961 68 * @defgroup axisXbitXX_t
cparata 0:671edf39d961 69 * @brief These unions are useful to represent different sensors data type.
cparata 0:671edf39d961 70 * These unions are not need by the driver.
cparata 0:671edf39d961 71 *
cparata 0:671edf39d961 72 * REMOVING the unions you are compliant with:
cparata 0:671edf39d961 73 * MISRA-C 2012 [Rule 19.2] -> " Union are not allowed "
cparata 0:671edf39d961 74 *
cparata 0:671edf39d961 75 * @{
cparata 0:671edf39d961 76 *
cparata 0:671edf39d961 77 */
cparata 0:671edf39d961 78
cparata 1:8562ae1a0534 79 typedef union {
cparata 1:8562ae1a0534 80 int16_t i16bit[3];
cparata 1:8562ae1a0534 81 uint8_t u8bit[6];
cparata 0:671edf39d961 82 } axis3bit16_t;
cparata 0:671edf39d961 83
cparata 1:8562ae1a0534 84 typedef union {
cparata 1:8562ae1a0534 85 int16_t i16bit;
cparata 1:8562ae1a0534 86 uint8_t u8bit[2];
cparata 0:671edf39d961 87 } axis1bit16_t;
cparata 0:671edf39d961 88
cparata 1:8562ae1a0534 89 typedef union {
cparata 1:8562ae1a0534 90 int32_t i32bit[3];
cparata 1:8562ae1a0534 91 uint8_t u8bit[12];
cparata 0:671edf39d961 92 } axis3bit32_t;
cparata 0:671edf39d961 93
cparata 1:8562ae1a0534 94 typedef union {
cparata 1:8562ae1a0534 95 int32_t i32bit;
cparata 1:8562ae1a0534 96 uint8_t u8bit[4];
cparata 0:671edf39d961 97 } axis1bit32_t;
cparata 0:671edf39d961 98
cparata 0:671edf39d961 99 /**
cparata 0:671edf39d961 100 * @}
cparata 0:671edf39d961 101 *
cparata 0:671edf39d961 102 */
cparata 0:671edf39d961 103
cparata 1:8562ae1a0534 104 typedef struct {
cparata 1:8562ae1a0534 105 uint8_t bit0 : 1;
cparata 1:8562ae1a0534 106 uint8_t bit1 : 1;
cparata 1:8562ae1a0534 107 uint8_t bit2 : 1;
cparata 1:8562ae1a0534 108 uint8_t bit3 : 1;
cparata 1:8562ae1a0534 109 uint8_t bit4 : 1;
cparata 1:8562ae1a0534 110 uint8_t bit5 : 1;
cparata 1:8562ae1a0534 111 uint8_t bit6 : 1;
cparata 1:8562ae1a0534 112 uint8_t bit7 : 1;
cparata 0:671edf39d961 113 } bitwise_t;
cparata 0:671edf39d961 114
cparata 0:671edf39d961 115 #define PROPERTY_DISABLE (0U)
cparata 0:671edf39d961 116 #define PROPERTY_ENABLE (1U)
cparata 0:671edf39d961 117
cparata 0:671edf39d961 118 #endif /* MEMS_SHARED_TYPES */
cparata 0:671edf39d961 119
cparata 0:671edf39d961 120 /**
cparata 0:671edf39d961 121 * @}
cparata 0:671edf39d961 122 *
cparata 0:671edf39d961 123 */
cparata 0:671edf39d961 124
cparata 1:8562ae1a0534 125 /** @addtogroup LIS2MDL_Interfaces_Functions
cparata 1:8562ae1a0534 126 * @brief This section provide a set of functions used to read and
cparata 1:8562ae1a0534 127 * write a generic register of the device.
cparata 1:8562ae1a0534 128 * MANDATORY: return 0 -> no Error.
cparata 1:8562ae1a0534 129 * @{
cparata 1:8562ae1a0534 130 *
cparata 1:8562ae1a0534 131 */
cparata 0:671edf39d961 132
cparata 1:8562ae1a0534 133 typedef int32_t (*lis2mdl_write_ptr)(void *, uint8_t, uint8_t *, uint16_t);
cparata 1:8562ae1a0534 134 typedef int32_t (*lis2mdl_read_ptr)(void *, uint8_t, uint8_t *, uint16_t);
cparata 0:671edf39d961 135
cparata 0:671edf39d961 136 typedef struct {
cparata 1:8562ae1a0534 137 /** Component mandatory fields **/
cparata 1:8562ae1a0534 138 lis2mdl_write_ptr write_reg;
cparata 1:8562ae1a0534 139 lis2mdl_read_ptr read_reg;
cparata 1:8562ae1a0534 140 /** Customizable optional pointer **/
cparata 1:8562ae1a0534 141 void *handle;
cparata 0:671edf39d961 142 } lis2mdl_ctx_t;
cparata 0:671edf39d961 143
cparata 0:671edf39d961 144 /**
cparata 0:671edf39d961 145 * @}
cparata 0:671edf39d961 146 *
cparata 0:671edf39d961 147 */
cparata 0:671edf39d961 148
cparata 0:671edf39d961 149 /** @defgroup LSM9DS1_Infos
cparata 0:671edf39d961 150 * @{
cparata 0:671edf39d961 151 *
cparata 0:671edf39d961 152 */
cparata 0:671edf39d961 153
cparata 1:8562ae1a0534 154 /** I2C Device Address 8 bit format **/
cparata 0:671edf39d961 155 #define LIS2MDL_I2C_ADD 0x3DU
cparata 0:671edf39d961 156
cparata 0:671edf39d961 157 /** Device Identification (Who am I) **/
cparata 0:671edf39d961 158 #define LIS2MDL_ID 0x40U
cparata 0:671edf39d961 159
cparata 0:671edf39d961 160 /**
cparata 0:671edf39d961 161 * @}
cparata 0:671edf39d961 162 *
cparata 0:671edf39d961 163 */
cparata 0:671edf39d961 164
cparata 0:671edf39d961 165 #define LIS2MDL_OFFSET_X_REG_L 0x45U
cparata 0:671edf39d961 166 #define LIS2MDL_OFFSET_X_REG_H 0x46U
cparata 0:671edf39d961 167 #define LIS2MDL_OFFSET_Y_REG_L 0x47U
cparata 0:671edf39d961 168 #define LIS2MDL_OFFSET_Y_REG_H 0x48U
cparata 0:671edf39d961 169 #define LIS2MDL_OFFSET_Z_REG_L 0x49U
cparata 0:671edf39d961 170 #define LIS2MDL_OFFSET_Z_REG_H 0x4AU
cparata 0:671edf39d961 171 #define LIS2MDL_WHO_AM_I 0x4FU
cparata 0:671edf39d961 172 #define LIS2MDL_CFG_REG_A 0x60U
cparata 0:671edf39d961 173 typedef struct {
cparata 1:8562ae1a0534 174 uint8_t md : 2;
cparata 1:8562ae1a0534 175 uint8_t odr : 2;
cparata 1:8562ae1a0534 176 uint8_t lp : 1;
cparata 1:8562ae1a0534 177 uint8_t soft_rst : 1;
cparata 1:8562ae1a0534 178 uint8_t reboot : 1;
cparata 1:8562ae1a0534 179 uint8_t comp_temp_en : 1;
cparata 0:671edf39d961 180 } lis2mdl_cfg_reg_a_t;
cparata 0:671edf39d961 181
cparata 0:671edf39d961 182 #define LIS2MDL_CFG_REG_B 0x61U
cparata 0:671edf39d961 183 typedef struct {
cparata 1:8562ae1a0534 184 uint8_t lpf : 1;
cparata 1:8562ae1a0534 185 uint8_t set_rst : 2; /* OFF_CANC + Set_FREQ */
cparata 1:8562ae1a0534 186 uint8_t int_on_dataoff : 1;
cparata 1:8562ae1a0534 187 uint8_t off_canc_one_shot : 1;
cparata 1:8562ae1a0534 188 uint8_t not_used_01 : 3;
cparata 0:671edf39d961 189 } lis2mdl_cfg_reg_b_t;
cparata 0:671edf39d961 190
cparata 0:671edf39d961 191 #define LIS2MDL_CFG_REG_C 0x62U
cparata 0:671edf39d961 192 typedef struct {
cparata 1:8562ae1a0534 193 uint8_t drdy_on_pin : 1;
cparata 1:8562ae1a0534 194 uint8_t self_test : 1;
cparata 1:8562ae1a0534 195 uint8_t not_used_01 : 1;
cparata 1:8562ae1a0534 196 uint8_t ble : 1;
cparata 1:8562ae1a0534 197 uint8_t bdu : 1;
cparata 1:8562ae1a0534 198 uint8_t i2c_dis : 1;
cparata 1:8562ae1a0534 199 uint8_t int_on_pin : 1;
cparata 1:8562ae1a0534 200 uint8_t not_used_02 : 1;
cparata 0:671edf39d961 201 } lis2mdl_cfg_reg_c_t;
cparata 0:671edf39d961 202
cparata 0:671edf39d961 203 #define LIS2MDL_INT_CRTL_REG 0x63U
cparata 0:671edf39d961 204 typedef struct {
cparata 1:8562ae1a0534 205 uint8_t ien : 1;
cparata 1:8562ae1a0534 206 uint8_t iel : 1;
cparata 1:8562ae1a0534 207 uint8_t iea : 1;
cparata 1:8562ae1a0534 208 uint8_t not_used_01 : 2;
cparata 1:8562ae1a0534 209 uint8_t zien : 1;
cparata 1:8562ae1a0534 210 uint8_t yien : 1;
cparata 1:8562ae1a0534 211 uint8_t xien : 1;
cparata 0:671edf39d961 212 } lis2mdl_int_crtl_reg_t;
cparata 0:671edf39d961 213
cparata 0:671edf39d961 214 #define LIS2MDL_INT_SOURCE_REG 0x64U
cparata 0:671edf39d961 215 typedef struct {
cparata 1:8562ae1a0534 216 uint8_t _int : 1;
cparata 1:8562ae1a0534 217 uint8_t mroi : 1;
cparata 1:8562ae1a0534 218 uint8_t n_th_s_z : 1;
cparata 1:8562ae1a0534 219 uint8_t n_th_s_y : 1;
cparata 1:8562ae1a0534 220 uint8_t n_th_s_x : 1;
cparata 1:8562ae1a0534 221 uint8_t p_th_s_z : 1;
cparata 1:8562ae1a0534 222 uint8_t p_th_s_y : 1;
cparata 1:8562ae1a0534 223 uint8_t p_th_s_x : 1;
cparata 0:671edf39d961 224 } lis2mdl_int_source_reg_t;
cparata 0:671edf39d961 225
cparata 0:671edf39d961 226 #define LIS2MDL_INT_THS_L_REG 0x65U
cparata 0:671edf39d961 227 #define LIS2MDL_INT_THS_H_REG 0x66U
cparata 0:671edf39d961 228 #define LIS2MDL_STATUS_REG 0x67U
cparata 0:671edf39d961 229 typedef struct {
cparata 1:8562ae1a0534 230 uint8_t xda : 1;
cparata 1:8562ae1a0534 231 uint8_t yda : 1;
cparata 1:8562ae1a0534 232 uint8_t zda : 1;
cparata 1:8562ae1a0534 233 uint8_t zyxda : 1;
cparata 1:8562ae1a0534 234 uint8_t xior : 1; //changed as xor is a reserved word in c++
cparata 1:8562ae1a0534 235 uint8_t yor : 1;
cparata 1:8562ae1a0534 236 uint8_t zor : 1;
cparata 1:8562ae1a0534 237 uint8_t zyxor : 1;
cparata 0:671edf39d961 238 } lis2mdl_status_reg_t;
cparata 0:671edf39d961 239
cparata 0:671edf39d961 240 #define LIS2MDL_OUTX_L_REG 0x68U
cparata 0:671edf39d961 241 #define LIS2MDL_OUTX_H_REG 0x69U
cparata 0:671edf39d961 242 #define LIS2MDL_OUTY_L_REG 0x6AU
cparata 0:671edf39d961 243 #define LIS2MDL_OUTY_H_REG 0x6BU
cparata 0:671edf39d961 244 #define LIS2MDL_OUTZ_L_REG 0x6CU
cparata 0:671edf39d961 245 #define LIS2MDL_OUTZ_H_REG 0x6DU
cparata 0:671edf39d961 246 #define LIS2MDL_TEMP_OUT_L_REG 0x6EU
cparata 0:671edf39d961 247 #define LIS2MDL_TEMP_OUT_H_REG 0x6FU
cparata 0:671edf39d961 248
cparata 0:671edf39d961 249 /**
cparata 0:671edf39d961 250 * @defgroup LIS2MDL_Register_Union
cparata 0:671edf39d961 251 * @brief This union group all the registers that has a bit-field
cparata 0:671edf39d961 252 * description.
cparata 0:671edf39d961 253 * This union is useful but not need by the driver.
cparata 0:671edf39d961 254 *
cparata 0:671edf39d961 255 * REMOVING this union you are compliant with:
cparata 0:671edf39d961 256 * MISRA-C 2012 [Rule 19.2] -> " Union are not allowed "
cparata 0:671edf39d961 257 *
cparata 0:671edf39d961 258 * @{
cparata 0:671edf39d961 259 *
cparata 0:671edf39d961 260 */
cparata 1:8562ae1a0534 261 typedef union {
cparata 1:8562ae1a0534 262 lis2mdl_cfg_reg_a_t cfg_reg_a;
cparata 1:8562ae1a0534 263 lis2mdl_cfg_reg_b_t cfg_reg_b;
cparata 1:8562ae1a0534 264 lis2mdl_cfg_reg_c_t cfg_reg_c;
cparata 1:8562ae1a0534 265 lis2mdl_int_crtl_reg_t int_crtl_reg;
cparata 1:8562ae1a0534 266 lis2mdl_int_source_reg_t int_source_reg;
cparata 1:8562ae1a0534 267 lis2mdl_status_reg_t status_reg;
cparata 1:8562ae1a0534 268 bitwise_t bitwise;
cparata 1:8562ae1a0534 269 uint8_t byte;
cparata 0:671edf39d961 270 } lis2mdl_reg_t;
cparata 0:671edf39d961 271
cparata 0:671edf39d961 272 /**
cparata 0:671edf39d961 273 * @}
cparata 0:671edf39d961 274 *
cparata 0:671edf39d961 275 */
cparata 0:671edf39d961 276
cparata 1:8562ae1a0534 277 int32_t lis2mdl_read_reg(lis2mdl_ctx_t *ctx, uint8_t reg, uint8_t *data,
cparata 0:671edf39d961 278 uint16_t len);
cparata 1:8562ae1a0534 279 int32_t lis2mdl_write_reg(lis2mdl_ctx_t *ctx, uint8_t reg, uint8_t *data,
cparata 0:671edf39d961 280 uint16_t len);
cparata 1:8562ae1a0534 281
cparata 0:671edf39d961 282 extern float_t lis2mdl_from_lsb_to_mgauss(int16_t lsb);
cparata 0:671edf39d961 283 extern float_t lis2mdl_from_lsb_to_celsius(int16_t lsb);
cparata 0:671edf39d961 284
cparata 0:671edf39d961 285 int32_t lis2mdl_mag_user_offset_set(lis2mdl_ctx_t *ctx, uint8_t *buff);
cparata 0:671edf39d961 286 int32_t lis2mdl_mag_user_offset_get(lis2mdl_ctx_t *ctx, uint8_t *buff);
cparata 0:671edf39d961 287
cparata 0:671edf39d961 288 typedef enum {
cparata 1:8562ae1a0534 289 LIS2MDL_CONTINUOUS_MODE = 0,
cparata 1:8562ae1a0534 290 LIS2MDL_SINGLE_TRIGGER = 1,
cparata 1:8562ae1a0534 291 LIS2MDL_POWER_DOWN = 2,
cparata 0:671edf39d961 292 } lis2mdl_md_t;
cparata 0:671edf39d961 293 int32_t lis2mdl_operating_mode_set(lis2mdl_ctx_t *ctx, lis2mdl_md_t val);
cparata 0:671edf39d961 294 int32_t lis2mdl_operating_mode_get(lis2mdl_ctx_t *ctx, lis2mdl_md_t *val);
cparata 0:671edf39d961 295
cparata 0:671edf39d961 296 typedef enum {
cparata 1:8562ae1a0534 297 LIS2MDL_ODR_10Hz = 0,
cparata 1:8562ae1a0534 298 LIS2MDL_ODR_20Hz = 1,
cparata 1:8562ae1a0534 299 LIS2MDL_ODR_50Hz = 2,
cparata 1:8562ae1a0534 300 LIS2MDL_ODR_100Hz = 3,
cparata 0:671edf39d961 301 } lis2mdl_odr_t;
cparata 0:671edf39d961 302 int32_t lis2mdl_data_rate_set(lis2mdl_ctx_t *ctx, lis2mdl_odr_t val);
cparata 0:671edf39d961 303 int32_t lis2mdl_data_rate_get(lis2mdl_ctx_t *ctx, lis2mdl_odr_t *val);
cparata 0:671edf39d961 304
cparata 0:671edf39d961 305 typedef enum {
cparata 1:8562ae1a0534 306 LIS2MDL_HIGH_RESOLUTION = 0,
cparata 1:8562ae1a0534 307 LIS2MDL_LOW_POWER = 1,
cparata 0:671edf39d961 308 } lis2mdl_lp_t;
cparata 0:671edf39d961 309 int32_t lis2mdl_power_mode_set(lis2mdl_ctx_t *ctx, lis2mdl_lp_t val);
cparata 0:671edf39d961 310 int32_t lis2mdl_power_mode_get(lis2mdl_ctx_t *ctx, lis2mdl_lp_t *val);
cparata 0:671edf39d961 311
cparata 0:671edf39d961 312 int32_t lis2mdl_offset_temp_comp_set(lis2mdl_ctx_t *ctx, uint8_t val);
cparata 0:671edf39d961 313 int32_t lis2mdl_offset_temp_comp_get(lis2mdl_ctx_t *ctx, uint8_t *val);
cparata 0:671edf39d961 314
cparata 0:671edf39d961 315 typedef enum {
cparata 1:8562ae1a0534 316 LIS2MDL_ODR_DIV_2 = 0,
cparata 1:8562ae1a0534 317 LIS2MDL_ODR_DIV_4 = 1,
cparata 0:671edf39d961 318 } lis2mdl_lpf_t;
cparata 0:671edf39d961 319 int32_t lis2mdl_low_pass_bandwidth_set(lis2mdl_ctx_t *ctx,
cparata 0:671edf39d961 320 lis2mdl_lpf_t val);
cparata 0:671edf39d961 321 int32_t lis2mdl_low_pass_bandwidth_get(lis2mdl_ctx_t *ctx,
cparata 0:671edf39d961 322 lis2mdl_lpf_t *val);
cparata 0:671edf39d961 323
cparata 0:671edf39d961 324 typedef enum {
cparata 1:8562ae1a0534 325 LIS2MDL_SET_SENS_ODR_DIV_63 = 0,
cparata 1:8562ae1a0534 326 LIS2MDL_SENS_OFF_CANC_EVERY_ODR = 1,
cparata 1:8562ae1a0534 327 LIS2MDL_SET_SENS_ONLY_AT_POWER_ON = 2,
cparata 0:671edf39d961 328 } lis2mdl_set_rst_t;
cparata 0:671edf39d961 329 int32_t lis2mdl_set_rst_mode_set(lis2mdl_ctx_t *ctx,
cparata 0:671edf39d961 330 lis2mdl_set_rst_t val);
cparata 0:671edf39d961 331 int32_t lis2mdl_set_rst_mode_get(lis2mdl_ctx_t *ctx,
cparata 0:671edf39d961 332 lis2mdl_set_rst_t *val);
cparata 0:671edf39d961 333
cparata 0:671edf39d961 334 int32_t lis2mdl_set_rst_sensor_single_set(lis2mdl_ctx_t *ctx,
cparata 0:671edf39d961 335 uint8_t val);
cparata 0:671edf39d961 336 int32_t lis2mdl_set_rst_sensor_single_get(lis2mdl_ctx_t *ctx,
cparata 0:671edf39d961 337 uint8_t *val);
cparata 0:671edf39d961 338
cparata 0:671edf39d961 339 int32_t lis2mdl_block_data_update_set(lis2mdl_ctx_t *ctx, uint8_t val);
cparata 0:671edf39d961 340 int32_t lis2mdl_block_data_update_get(lis2mdl_ctx_t *ctx, uint8_t *val);
cparata 0:671edf39d961 341
cparata 0:671edf39d961 342 int32_t lis2mdl_mag_data_ready_get(lis2mdl_ctx_t *ctx, uint8_t *val);
cparata 0:671edf39d961 343
cparata 0:671edf39d961 344 int32_t lis2mdl_mag_data_ovr_get(lis2mdl_ctx_t *ctx, uint8_t *val);
cparata 0:671edf39d961 345
cparata 0:671edf39d961 346 int32_t lis2mdl_magnetic_raw_get(lis2mdl_ctx_t *ctx, uint8_t *buff);
cparata 0:671edf39d961 347
cparata 0:671edf39d961 348 int32_t lis2mdl_temperature_raw_get(lis2mdl_ctx_t *ctx, uint8_t *buff);
cparata 0:671edf39d961 349
cparata 0:671edf39d961 350 int32_t lis2mdl_device_id_get(lis2mdl_ctx_t *ctx, uint8_t *buff);
cparata 0:671edf39d961 351
cparata 0:671edf39d961 352 int32_t lis2mdl_reset_set(lis2mdl_ctx_t *ctx, uint8_t val);
cparata 0:671edf39d961 353 int32_t lis2mdl_reset_get(lis2mdl_ctx_t *ctx, uint8_t *val);
cparata 0:671edf39d961 354
cparata 0:671edf39d961 355 int32_t lis2mdl_boot_set(lis2mdl_ctx_t *ctx, uint8_t val);
cparata 0:671edf39d961 356 int32_t lis2mdl_boot_get(lis2mdl_ctx_t *ctx, uint8_t *val);
cparata 0:671edf39d961 357
cparata 0:671edf39d961 358 int32_t lis2mdl_self_test_set(lis2mdl_ctx_t *ctx, uint8_t val);
cparata 0:671edf39d961 359 int32_t lis2mdl_self_test_get(lis2mdl_ctx_t *ctx, uint8_t *val);
cparata 0:671edf39d961 360
cparata 0:671edf39d961 361 typedef enum {
cparata 1:8562ae1a0534 362 LIS2MDL_LSB_AT_LOW_ADD = 0,
cparata 1:8562ae1a0534 363 LIS2MDL_MSB_AT_LOW_ADD = 1,
cparata 0:671edf39d961 364 } lis2mdl_ble_t;
cparata 0:671edf39d961 365 int32_t lis2mdl_data_format_set(lis2mdl_ctx_t *ctx, lis2mdl_ble_t val);
cparata 0:671edf39d961 366 int32_t lis2mdl_data_format_get(lis2mdl_ctx_t *ctx, lis2mdl_ble_t *val);
cparata 0:671edf39d961 367
cparata 0:671edf39d961 368 int32_t lis2mdl_status_get(lis2mdl_ctx_t *ctx, lis2mdl_status_reg_t *val);
cparata 0:671edf39d961 369
cparata 0:671edf39d961 370 typedef enum {
cparata 1:8562ae1a0534 371 LIS2MDL_CHECK_BEFORE = 0,
cparata 1:8562ae1a0534 372 LIS2MDL_CHECK_AFTER = 1,
cparata 0:671edf39d961 373 } lis2mdl_int_on_dataoff_t;
cparata 0:671edf39d961 374 int32_t lis2mdl_offset_int_conf_set(lis2mdl_ctx_t *ctx,
cparata 0:671edf39d961 375 lis2mdl_int_on_dataoff_t val);
cparata 0:671edf39d961 376 int32_t lis2mdl_offset_int_conf_get(lis2mdl_ctx_t *ctx,
cparata 0:671edf39d961 377 lis2mdl_int_on_dataoff_t *val);
cparata 0:671edf39d961 378
cparata 0:671edf39d961 379 int32_t lis2mdl_drdy_on_pin_set(lis2mdl_ctx_t *ctx, uint8_t val);
cparata 0:671edf39d961 380 int32_t lis2mdl_drdy_on_pin_get(lis2mdl_ctx_t *ctx, uint8_t *val);
cparata 0:671edf39d961 381
cparata 0:671edf39d961 382 int32_t lis2mdl_int_on_pin_set(lis2mdl_ctx_t *ctx, uint8_t val);
cparata 0:671edf39d961 383 int32_t lis2mdl_int_on_pin_get(lis2mdl_ctx_t *ctx, uint8_t *val);
cparata 0:671edf39d961 384
cparata 0:671edf39d961 385 int32_t lis2mdl_int_gen_conf_set(lis2mdl_ctx_t *ctx,
cparata 0:671edf39d961 386 lis2mdl_int_crtl_reg_t *val);
cparata 0:671edf39d961 387 int32_t lis2mdl_int_gen_conf_get(lis2mdl_ctx_t *ctx,
cparata 0:671edf39d961 388 lis2mdl_int_crtl_reg_t *val);
cparata 0:671edf39d961 389
cparata 0:671edf39d961 390 int32_t lis2mdl_int_gen_source_get(lis2mdl_ctx_t *ctx,
cparata 0:671edf39d961 391 lis2mdl_int_source_reg_t *val);
cparata 0:671edf39d961 392
cparata 0:671edf39d961 393 int32_t lis2mdl_int_gen_treshold_set(lis2mdl_ctx_t *ctx, uint8_t *buff);
cparata 0:671edf39d961 394 int32_t lis2mdl_int_gen_treshold_get(lis2mdl_ctx_t *ctx, uint8_t *buff);
cparata 0:671edf39d961 395
cparata 0:671edf39d961 396 typedef enum {
cparata 1:8562ae1a0534 397 LIS2MDL_I2C_ENABLE = 0,
cparata 1:8562ae1a0534 398 LIS2MDL_I2C_DISABLE = 1,
cparata 0:671edf39d961 399 } lis2mdl_i2c_dis_t;
cparata 0:671edf39d961 400 int32_t lis2mdl_i2c_interface_set(lis2mdl_ctx_t *ctx,
cparata 0:671edf39d961 401 lis2mdl_i2c_dis_t val);
cparata 0:671edf39d961 402 int32_t lis2mdl_i2c_interface_get(lis2mdl_ctx_t *ctx,
cparata 0:671edf39d961 403 lis2mdl_i2c_dis_t *val);
cparata 0:671edf39d961 404
cparata 0:671edf39d961 405 /**
cparata 0:671edf39d961 406 *@}
cparata 0:671edf39d961 407 *
cparata 0:671edf39d961 408 */
cparata 0:671edf39d961 409
cparata 0:671edf39d961 410 #ifdef __cplusplus
cparata 0:671edf39d961 411 }
cparata 0:671edf39d961 412 #endif
cparata 0:671edf39d961 413
cparata 0:671edf39d961 414 #endif /* LIS2MDL_REGS_H */
cparata 0:671edf39d961 415
cparata 0:671edf39d961 416 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/