Contains the BSP driver for the B-L475E-IOT01 board.
Dependents: mbed-os-example-ble-Thermometer DISCO_L475VG_IOT01-Telegram-BOT DISCO_L475VG_IOT01-sche_cheveux DISCO_L475VG_IOT01-QSPI_FLASH_FILE_SYSTEM ... more
https://os.mbed.com/platforms/ST-Discovery-L475E-IOT01A/
Drivers/BSP/Components/lis3mdl/lis3mdl.h@7:bfe8272ced90, 2019-09-24 (annotated)
- Committer:
- jeromecoutant
- Date:
- Tue Sep 24 15:30:09 2019 +0200
- Revision:
- 7:bfe8272ced90
- Parent:
- 4:137bb367ba50
Update BSP files with STM32Cube L4 V1.14.0
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
bcostm | 4:137bb367ba50 | 1 | /** |
bcostm | 4:137bb367ba50 | 2 | ****************************************************************************** |
bcostm | 4:137bb367ba50 | 3 | * @file lis3mdl.h |
bcostm | 4:137bb367ba50 | 4 | * @author MCD Application Team |
bcostm | 4:137bb367ba50 | 5 | * @brief LIS3MDL header driver file |
bcostm | 4:137bb367ba50 | 6 | ****************************************************************************** |
bcostm | 4:137bb367ba50 | 7 | * @attention |
bcostm | 4:137bb367ba50 | 8 | * |
jeromecoutant | 7:bfe8272ced90 | 9 | * <h2><center>© Copyright (c) 2017 STMicroelectronics. |
jeromecoutant | 7:bfe8272ced90 | 10 | * All rights reserved.</center></h2> |
bcostm | 4:137bb367ba50 | 11 | * |
jeromecoutant | 7:bfe8272ced90 | 12 | * This software component is licensed by ST under BSD 3-Clause license, |
jeromecoutant | 7:bfe8272ced90 | 13 | * the "License"; You may not use this file except in compliance with the |
jeromecoutant | 7:bfe8272ced90 | 14 | * License. You may obtain a copy of the License at: |
jeromecoutant | 7:bfe8272ced90 | 15 | * opensource.org/licenses/BSD-3-Clause |
bcostm | 4:137bb367ba50 | 16 | * |
bcostm | 4:137bb367ba50 | 17 | ****************************************************************************** |
bcostm | 4:137bb367ba50 | 18 | */ |
bcostm | 4:137bb367ba50 | 19 | |
bcostm | 4:137bb367ba50 | 20 | /* Define to prevent recursive inclusion -------------------------------------*/ |
bcostm | 4:137bb367ba50 | 21 | #ifndef __LIS3MDL__H |
bcostm | 4:137bb367ba50 | 22 | #define __LIS3MDL__H |
bcostm | 4:137bb367ba50 | 23 | |
bcostm | 4:137bb367ba50 | 24 | #ifdef __cplusplus |
bcostm | 4:137bb367ba50 | 25 | extern "C" { |
bcostm | 4:137bb367ba50 | 26 | #endif |
bcostm | 4:137bb367ba50 | 27 | |
bcostm | 4:137bb367ba50 | 28 | /* Includes ------------------------------------------------------------------*/ |
bcostm | 4:137bb367ba50 | 29 | #include "../Common/magneto.h" |
bcostm | 4:137bb367ba50 | 30 | |
bcostm | 4:137bb367ba50 | 31 | /** @addtogroup BSP |
bcostm | 4:137bb367ba50 | 32 | * @{ |
bcostm | 4:137bb367ba50 | 33 | */ |
bcostm | 4:137bb367ba50 | 34 | |
bcostm | 4:137bb367ba50 | 35 | /** @addtogroup Component |
bcostm | 4:137bb367ba50 | 36 | * @{ |
bcostm | 4:137bb367ba50 | 37 | */ |
bcostm | 4:137bb367ba50 | 38 | |
bcostm | 4:137bb367ba50 | 39 | /** @addtogroup LIS3MDL |
bcostm | 4:137bb367ba50 | 40 | * @{ |
bcostm | 4:137bb367ba50 | 41 | */ |
bcostm | 4:137bb367ba50 | 42 | |
bcostm | 4:137bb367ba50 | 43 | /** @defgroup LIS3MDL_Exported_Constants LIS3MDL Exported Constants |
bcostm | 4:137bb367ba50 | 44 | * @{ |
bcostm | 4:137bb367ba50 | 45 | */ |
bcostm | 4:137bb367ba50 | 46 | /************** I2C Address *****************/ |
bcostm | 4:137bb367ba50 | 47 | |
bcostm | 4:137bb367ba50 | 48 | #define LIS3MDL_MAG_I2C_ADDRESS_LOW ((uint8_t)0x38) // SAD[0] = 0 |
bcostm | 4:137bb367ba50 | 49 | #define LIS3MDL_MAG_I2C_ADDRESS_HIGH ((uint8_t)0x3C) // SAD[0] = 1 |
bcostm | 4:137bb367ba50 | 50 | |
bcostm | 4:137bb367ba50 | 51 | /************** Who am I *******************/ |
bcostm | 4:137bb367ba50 | 52 | |
bcostm | 4:137bb367ba50 | 53 | #define I_AM_LIS3MDL ((uint8_t)0x3D) |
bcostm | 4:137bb367ba50 | 54 | |
bcostm | 4:137bb367ba50 | 55 | /************** Device Register *******************/ |
bcostm | 4:137bb367ba50 | 56 | |
bcostm | 4:137bb367ba50 | 57 | #define LIS3MDL_MAG_WHO_AM_I_REG 0x0F |
bcostm | 4:137bb367ba50 | 58 | #define LIS3MDL_MAG_CTRL_REG1 0x20 |
bcostm | 4:137bb367ba50 | 59 | #define LIS3MDL_MAG_CTRL_REG2 0x21 |
bcostm | 4:137bb367ba50 | 60 | #define LIS3MDL_MAG_CTRL_REG3 0x22 |
bcostm | 4:137bb367ba50 | 61 | #define LIS3MDL_MAG_CTRL_REG4 0x23 |
bcostm | 4:137bb367ba50 | 62 | #define LIS3MDL_MAG_CTRL_REG5 0x24 |
bcostm | 4:137bb367ba50 | 63 | #define LIS3MDL_MAG_STATUS_REG 0x27 |
bcostm | 4:137bb367ba50 | 64 | #define LIS3MDL_MAG_OUTX_L 0x28 |
bcostm | 4:137bb367ba50 | 65 | #define LIS3MDL_MAG_OUTX_H 0x29 |
bcostm | 4:137bb367ba50 | 66 | #define LIS3MDL_MAG_OUTY_L 0x2A |
bcostm | 4:137bb367ba50 | 67 | #define LIS3MDL_MAG_OUTY_H 0x2B |
bcostm | 4:137bb367ba50 | 68 | #define LIS3MDL_MAG_OUTZ_L 0x2C |
bcostm | 4:137bb367ba50 | 69 | #define LIS3MDL_MAG_OUTZ_H 0x2D |
bcostm | 4:137bb367ba50 | 70 | #define LIS3MDL_MAG_TEMP_OUT_L 0x2E |
bcostm | 4:137bb367ba50 | 71 | #define LIS3MDL_MAG_TEMP_OUT_H 0x2F |
bcostm | 4:137bb367ba50 | 72 | #define LIS3MDL_MAG_INT_CFG 0x30 |
bcostm | 4:137bb367ba50 | 73 | #define LIS3MDL_MAG_INT_SRC 0x31 |
bcostm | 4:137bb367ba50 | 74 | #define LIS3MDL_MAG_INT_THS_L 0x32 |
bcostm | 4:137bb367ba50 | 75 | #define LIS3MDL_MAG_INT_THS_H 0x33 |
bcostm | 4:137bb367ba50 | 76 | |
bcostm | 4:137bb367ba50 | 77 | /* Mag Temperature Sensor Control*/ |
bcostm | 4:137bb367ba50 | 78 | #define LIS3MDL_MAG_TEMPSENSOR_ENABLE ((uint8_t) 0x80) /*!< Temp sensor Enable */ |
bcostm | 4:137bb367ba50 | 79 | #define LIS3MDL_MAG_TEMPSENSOR_DISABLE ((uint8_t) 0x00) /*!< Temp sensor Disable */ |
bcostm | 4:137bb367ba50 | 80 | |
bcostm | 4:137bb367ba50 | 81 | /* Mag_XY-axis Operating Mode */ |
bcostm | 4:137bb367ba50 | 82 | #define LIS3MDL_MAG_OM_XY_LOWPOWER ((uint8_t) 0x00) |
bcostm | 4:137bb367ba50 | 83 | #define LIS3MDL_MAG_OM_XY_MEDIUM ((uint8_t) 0x20) |
bcostm | 4:137bb367ba50 | 84 | #define LIS3MDL_MAG_OM_XY_HIGH ((uint8_t) 0x40) |
bcostm | 4:137bb367ba50 | 85 | #define LIS3MDL_MAG_OM_XY_ULTRAHIGH ((uint8_t) 0x60) |
bcostm | 4:137bb367ba50 | 86 | |
bcostm | 4:137bb367ba50 | 87 | /* Mag Data Rate */ |
bcostm | 4:137bb367ba50 | 88 | #define LIS3MDL_MAG_ODR_0_625_HZ ((uint8_t) 0x00) /*!< Output Data Rate = 0.625 Hz */ |
bcostm | 4:137bb367ba50 | 89 | #define LIS3MDL_MAG_ODR_1_25_HZ ((uint8_t) 0x04) /*!< Output Data Rate = 1.25 Hz */ |
bcostm | 4:137bb367ba50 | 90 | #define LIS3MDL_MAG_ODR_2_5_HZ ((uint8_t) 0x08) /*!< Output Data Rate = 2.5 Hz */ |
bcostm | 4:137bb367ba50 | 91 | #define LIS3MDL_MAG_ODR_5_0_HZ ((uint8_t) 0x0C) /*!< Output Data Rate = 5.0 Hz */ |
bcostm | 4:137bb367ba50 | 92 | #define LIS3MDL_MAG_ODR_10_HZ ((uint8_t) 0x10) /*!< Output Data Rate = 10 Hz */ |
bcostm | 4:137bb367ba50 | 93 | #define LIS3MDL_MAG_ODR_20_HZ ((uint8_t) 0x14) /*!< Output Data Rate = 20 Hz */ |
bcostm | 4:137bb367ba50 | 94 | #define LIS3MDL_MAG_ODR_40_HZ ((uint8_t) 0x18) /*!< Output Data Rate = 40 Hz */ |
bcostm | 4:137bb367ba50 | 95 | #define LIS3MDL_MAG_ODR_80_HZ ((uint8_t) 0x1C) /*!< Output Data Rate = 80 Hz */ |
bcostm | 4:137bb367ba50 | 96 | |
bcostm | 4:137bb367ba50 | 97 | /* Mag Data Rate */ |
bcostm | 4:137bb367ba50 | 98 | #define LMS303C_MAG_SELFTEST_DISABLE ((uint8_t 0x00) |
bcostm | 4:137bb367ba50 | 99 | #define LMS303C_MAG_SELFTEST_ENABLE ((uint8_t 0x01) |
bcostm | 4:137bb367ba50 | 100 | |
bcostm | 4:137bb367ba50 | 101 | /* Mag Full Scale */ |
bcostm | 4:137bb367ba50 | 102 | #define LIS3MDL_MAG_FS_DEFAULT ((uint8_t) 0x00) |
bcostm | 4:137bb367ba50 | 103 | #define LIS3MDL_MAG_FS_4_GA ((uint8_t) 0x00) |
bcostm | 4:137bb367ba50 | 104 | #define LIS3MDL_MAG_FS_8_GA ((uint8_t) 0x20) |
bcostm | 4:137bb367ba50 | 105 | #define LIS3MDL_MAG_FS_12_GA ((uint8_t) 0x40) |
bcostm | 4:137bb367ba50 | 106 | #define LIS3MDL_MAG_FS_16_GA ((uint8_t) 0x60) /*!< Full scale = ±16 Gauss */ |
bcostm | 4:137bb367ba50 | 107 | |
bcostm | 4:137bb367ba50 | 108 | /* Mag_Reboot */ |
bcostm | 4:137bb367ba50 | 109 | #define LIS3MDL_MAG_REBOOT_DEFAULT ((uint8_t) 0x00) |
bcostm | 4:137bb367ba50 | 110 | #define LIS3MDL_MAG_REBOOT_ENABLE ((uint8_t) 0x08) |
bcostm | 4:137bb367ba50 | 111 | |
bcostm | 4:137bb367ba50 | 112 | /* Mag Soft reset */ |
bcostm | 4:137bb367ba50 | 113 | #define LIS3MDL_MAG_SOFT_RESET_DEFAULT ((uint8_t) 0x00) |
bcostm | 4:137bb367ba50 | 114 | #define LIS3MDL_MAG_SOFT_RESET_ENABLE ((uint8_t) 0x04) |
bcostm | 4:137bb367ba50 | 115 | |
bcostm | 4:137bb367ba50 | 116 | /* Mag_Communication_Mode */ |
bcostm | 4:137bb367ba50 | 117 | #define LIS3MDL_MAG_SIM_4_WIRE ((uint8_t) 0x00) |
bcostm | 4:137bb367ba50 | 118 | #define LIS3MDL_MAG_SIM_3_WIRE ((uint8_t) 0x04) |
bcostm | 4:137bb367ba50 | 119 | |
bcostm | 4:137bb367ba50 | 120 | /* Mag Lowpower mode config */ |
bcostm | 4:137bb367ba50 | 121 | #define LIS3MDL_MAG_CONFIG_NORMAL_MODE ((uint8_t) 0x00) |
bcostm | 4:137bb367ba50 | 122 | #define LIS3MDL_MAG_CONFIG_LOWPOWER_MODE ((uint8_t) 0x20) |
bcostm | 4:137bb367ba50 | 123 | |
bcostm | 4:137bb367ba50 | 124 | /* Mag Operation Mode */ |
bcostm | 4:137bb367ba50 | 125 | #define LIS3MDL_MAG_SELECTION_MODE ((uint8_t) 0x03) /* CTRL_REG3 */ |
bcostm | 4:137bb367ba50 | 126 | #define LIS3MDL_MAG_CONTINUOUS_MODE ((uint8_t) 0x00) |
bcostm | 4:137bb367ba50 | 127 | #define LIS3MDL_MAG_SINGLE_MODE ((uint8_t) 0x01) |
bcostm | 4:137bb367ba50 | 128 | #define LIS3MDL_MAG_POWERDOWN1_MODE ((uint8_t) 0x02) |
bcostm | 4:137bb367ba50 | 129 | #define LIS3MDL_MAG_POWERDOWN2_MODE ((uint8_t) 0x03) |
bcostm | 4:137bb367ba50 | 130 | |
bcostm | 4:137bb367ba50 | 131 | /* Mag_Z-axis Operation Mode */ |
bcostm | 4:137bb367ba50 | 132 | #define LIS3MDL_MAG_OM_Z_LOWPOWER ((uint8_t) 0x00) |
bcostm | 4:137bb367ba50 | 133 | #define LIS3MDL_MAG_OM_Z_MEDIUM ((uint8_t) 0x04) |
bcostm | 4:137bb367ba50 | 134 | #define LIS3MDL_MAG_OM_Z_HIGH ((uint8_t) 0x08) |
bcostm | 4:137bb367ba50 | 135 | #define LIS3MDL_MAG_OM_Z_ULTRAHIGH ((uint8_t) 0x0C) |
bcostm | 4:137bb367ba50 | 136 | |
bcostm | 4:137bb367ba50 | 137 | /* Mag Big little-endian selection */ |
bcostm | 4:137bb367ba50 | 138 | #define LIS3MDL_MAG_BLE_LSB ((uint8_t) 0x00) |
bcostm | 4:137bb367ba50 | 139 | #define LIS3MDL_MAG_BLE_MSB ((uint8_t) 0x02) |
bcostm | 4:137bb367ba50 | 140 | |
bcostm | 4:137bb367ba50 | 141 | |
bcostm | 4:137bb367ba50 | 142 | /* Mag_Bloc_update_magnetic_data */ |
bcostm | 4:137bb367ba50 | 143 | #define LIS3MDL_MAG_BDU_CONTINUOUS ((uint8_t) 0x00) |
bcostm | 4:137bb367ba50 | 144 | #define LIS3MDL_MAG_BDU_MSBLSB ((uint8_t) 0x40) |
bcostm | 4:137bb367ba50 | 145 | |
bcostm | 4:137bb367ba50 | 146 | |
bcostm | 4:137bb367ba50 | 147 | /* Magnetometer_Sensitivity */ |
bcostm | 4:137bb367ba50 | 148 | #define LIS3MDL_MAG_SENSITIVITY_FOR_FS_4GA ((float)0.14f) /**< Sensitivity value for 4 gauss full scale [mgauss/LSB] */ |
bcostm | 4:137bb367ba50 | 149 | #define LIS3MDL_MAG_SENSITIVITY_FOR_FS_8GA ((float)0.29f) /**< Sensitivity value for 8 gauss full scale [mgauss/LSB] */ |
bcostm | 4:137bb367ba50 | 150 | #define LIS3MDL_MAG_SENSITIVITY_FOR_FS_12GA ((float)0.43f) /**< Sensitivity value for 12 gauss full scale [mgauss/LSB] */ |
bcostm | 4:137bb367ba50 | 151 | #define LIS3MDL_MAG_SENSITIVITY_FOR_FS_16GA ((float)0.58f) /**< Sensitivity value for 16 gauss full scale [mgauss/LSB] */ |
bcostm | 4:137bb367ba50 | 152 | |
bcostm | 4:137bb367ba50 | 153 | /** |
bcostm | 4:137bb367ba50 | 154 | * @} |
bcostm | 4:137bb367ba50 | 155 | */ |
bcostm | 4:137bb367ba50 | 156 | |
bcostm | 4:137bb367ba50 | 157 | |
bcostm | 4:137bb367ba50 | 158 | /** @defgroup LIS3MDL_Exported_Functions LIS3MDL Exported Functions |
bcostm | 4:137bb367ba50 | 159 | * @{ |
bcostm | 4:137bb367ba50 | 160 | */ |
bcostm | 4:137bb367ba50 | 161 | |
bcostm | 4:137bb367ba50 | 162 | void LIS3MDL_MagInit(MAGNETO_InitTypeDef LIS3MDL_InitStruct); |
bcostm | 4:137bb367ba50 | 163 | void LIS3MDL_MagDeInit(void); |
bcostm | 4:137bb367ba50 | 164 | uint8_t LIS3MDL_MagReadID(void); |
bcostm | 4:137bb367ba50 | 165 | void LIS3MDL_MagLowPower(uint16_t status); |
bcostm | 4:137bb367ba50 | 166 | void LIS3MDL_MagReadXYZ(int16_t* pData); |
bcostm | 4:137bb367ba50 | 167 | |
bcostm | 4:137bb367ba50 | 168 | /** |
bcostm | 4:137bb367ba50 | 169 | * @} |
bcostm | 4:137bb367ba50 | 170 | */ |
bcostm | 4:137bb367ba50 | 171 | |
bcostm | 4:137bb367ba50 | 172 | |
bcostm | 4:137bb367ba50 | 173 | /** @defgroup LIS3MDL_Imported_Functions LIS3MDL Imported Functions |
bcostm | 4:137bb367ba50 | 174 | * @{ |
bcostm | 4:137bb367ba50 | 175 | */ |
bcostm | 4:137bb367ba50 | 176 | /* IO functions */ |
bcostm | 4:137bb367ba50 | 177 | extern void SENSOR_IO_Init(void); |
bcostm | 4:137bb367ba50 | 178 | extern void SENSOR_IO_DeInit(void); |
bcostm | 4:137bb367ba50 | 179 | extern void SENSOR_IO_Write(uint8_t Addr, uint8_t Reg, uint8_t Value); |
bcostm | 4:137bb367ba50 | 180 | extern uint8_t SENSOR_IO_Read(uint8_t Addr, uint8_t Reg); |
bcostm | 4:137bb367ba50 | 181 | extern uint16_t SENSOR_IO_ReadMultiple(uint8_t Addr, uint8_t Reg, uint8_t *Buffer, uint16_t Length); |
bcostm | 4:137bb367ba50 | 182 | extern void SENSOR_IO_WriteMultiple(uint8_t Addr, uint8_t Reg, uint8_t *Buffer, uint16_t Length); |
bcostm | 4:137bb367ba50 | 183 | /** |
bcostm | 4:137bb367ba50 | 184 | * @} |
bcostm | 4:137bb367ba50 | 185 | */ |
bcostm | 4:137bb367ba50 | 186 | |
bcostm | 4:137bb367ba50 | 187 | /** @defgroup LIS3MDL_Imported_Globals Imported Globals |
bcostm | 4:137bb367ba50 | 188 | * @{ |
bcostm | 4:137bb367ba50 | 189 | */ |
bcostm | 4:137bb367ba50 | 190 | /* MAG driver structure */ |
bcostm | 4:137bb367ba50 | 191 | extern MAGNETO_DrvTypeDef Lis3mdlMagDrv; |
bcostm | 4:137bb367ba50 | 192 | /** |
bcostm | 4:137bb367ba50 | 193 | * @} |
bcostm | 4:137bb367ba50 | 194 | */ |
bcostm | 4:137bb367ba50 | 195 | |
bcostm | 4:137bb367ba50 | 196 | #ifdef __cplusplus |
bcostm | 4:137bb367ba50 | 197 | } |
bcostm | 4:137bb367ba50 | 198 | #endif |
bcostm | 4:137bb367ba50 | 199 | |
bcostm | 4:137bb367ba50 | 200 | #endif /* __LIS3MDL__H */ |
bcostm | 4:137bb367ba50 | 201 | |
bcostm | 4:137bb367ba50 | 202 | /** |
bcostm | 4:137bb367ba50 | 203 | * @} |
bcostm | 4:137bb367ba50 | 204 | */ |
bcostm | 4:137bb367ba50 | 205 | |
bcostm | 4:137bb367ba50 | 206 | /** |
bcostm | 4:137bb367ba50 | 207 | * @} |
bcostm | 4:137bb367ba50 | 208 | */ |
bcostm | 4:137bb367ba50 | 209 | |
bcostm | 4:137bb367ba50 | 210 | /** |
bcostm | 4:137bb367ba50 | 211 | * @} |
bcostm | 4:137bb367ba50 | 212 | */ |
bcostm | 4:137bb367ba50 | 213 | |
bcostm | 4:137bb367ba50 | 214 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |