Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: Space_Invaders_Demo neopixels gpio_test_stm32f3_discovery gpio_test_systimer ... more
stm32f3_discovery_lsm303dlhc.h
00001 /** 00002 ****************************************************************************** 00003 * @file stm32f3_discovery_lsm303dlhc.h 00004 * @author MCD Application Team 00005 * @version V1.1.0 00006 * @date 20-September-2012 00007 * @brief This file contains definitions for stm32f3_discovery_lsm303dlhc.c 00008 * firmware driver. 00009 ****************************************************************************** 00010 * @attention 00011 * 00012 * <h2><center>© COPYRIGHT 2012 STMicroelectronics</center></h2> 00013 * 00014 * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 00015 * You may not use this file except in compliance with the License. 00016 * You may obtain a copy of the License at: 00017 * 00018 * http://www.st.com/software_license_agreement_liberty_v2 00019 * 00020 * Unless required by applicable law or agreed to in writing, software 00021 * distributed under the License is distributed on an "AS IS" BASIS, 00022 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00023 * See the License for the specific language governing permissions and 00024 * limitations under the License. 00025 * 00026 ****************************************************************************** 00027 */ 00028 00029 00030 /* Define to prevent recursive inclusion -------------------------------------*/ 00031 #ifndef __STM32F3_DISCOVERY_LSM303DLHC_H 00032 #define __STM32F3_DISCOVERY_LSM303DLHC_H 00033 00034 #ifdef __cplusplus 00035 extern "C" { 00036 #endif 00037 00038 /* Includes ------------------------------------------------------------------*/ 00039 #include "stm32f30x.h" 00040 00041 /** @addtogroup Utilities 00042 * @{ 00043 */ 00044 00045 /** @addtogroup STM32F3_DISCOVERY 00046 * @{ 00047 */ 00048 00049 /** @addtogroup STM32F3_DISCOVERY_LSM303DLHC 00050 * @{ 00051 */ 00052 00053 /** @defgroup STM32F3_DISCOVERY_LSM303DLHC_Exported_Types 00054 * @{ 00055 */ 00056 00057 /** 00058 * @brief LSM303DLHC Status 00059 */ 00060 00061 /* LSM303DLHC ACC struct */ 00062 typedef struct 00063 { 00064 uint8_t Power_Mode; /* Power-down/Normal Mode */ 00065 uint8_t AccOutput_DataRate; /* OUT data rate */ 00066 uint8_t Axes_Enable; /* Axes enable */ 00067 uint8_t High_Resolution; /* High Resolution enabling/disabling */ 00068 uint8_t BlockData_Update; /* Block Data Update */ 00069 uint8_t Endianness; /* Endian Data selection */ 00070 uint8_t AccFull_Scale; /* Full Scale selection */ 00071 }LSM303DLHCAcc_InitTypeDef; 00072 00073 /* LSM303DLHC Acc High Pass Filter struct */ 00074 typedef struct 00075 { 00076 uint8_t HighPassFilter_Mode_Selection; /* Internal filter mode */ 00077 uint8_t HighPassFilter_CutOff_Frequency; /* High pass filter cut-off frequency */ 00078 uint8_t HighPassFilter_AOI1; /* HPF_enabling/disabling for AOI function on interrupt 1 */ 00079 uint8_t HighPassFilter_AOI2; /* HPF_enabling/disabling for AOI function on interrupt 2 */ 00080 }LSM303DLHCAcc_FilterConfigTypeDef; 00081 00082 /* LSM303DLHC Mag struct */ 00083 typedef struct 00084 { 00085 uint8_t Temperature_Sensor; /* Temperature sensor enable/disable */ 00086 uint8_t MagOutput_DataRate; /* OUT data rate */ 00087 uint8_t Working_Mode; /* operating mode */ 00088 uint8_t MagFull_Scale; /* Full Scale selection */ 00089 }LSM303DLHCMag_InitTypeDef; 00090 /** 00091 * @} 00092 */ 00093 00094 /** @defgroup STM32F3_DISCOVERY_LSM303DLHC_Exported_Constants 00095 * @{ 00096 */ 00097 #define LSM303DLHC_OK ((uint32_t) 0) 00098 #define LSM303DLHC_FAIL ((uint32_t) 0) 00099 00100 /* Uncomment the following line to use the default LSM303DLHC_TIMEOUT_UserCallback() 00101 function implemented in stm32f3_discovery_lgd20.c file. 00102 LSM303DLHC_TIMEOUT_UserCallback() function is called whenever a timeout condition 00103 occure during communication (waiting transmit data register empty flag(TXE) 00104 or waiting receive data register is not empty flag (RXNE)). */ 00105 #define USE_DEFAULT_TIMEOUT_CALLBACK 00106 00107 /* Maximum Timeout values for flags waiting loops. These timeouts are not based 00108 on accurate values, they just guarantee that the application will not remain 00109 stuck if the I2C communication is corrupted. 00110 You may modify these timeout values depending on CPU frequency and application 00111 conditions (interrupts routines ...). */ 00112 #define LSM303DLHC_FLAG_TIMEOUT ((uint32_t)0x1000) 00113 #define LSM303DLHC_LONG_TIMEOUT ((uint32_t)(10 * LSM303DLHC_FLAG_TIMEOUT)) 00114 /** 00115 * @brief LSM303DLHC I2C Interface pins 00116 */ 00117 #define LSM303DLHC_I2C I2C1 00118 #define LSM303DLHC_I2C_CLK RCC_APB1Periph_I2C1 00119 00120 #define LSM303DLHC_I2C_SCK_PIN GPIO_Pin_6 /* PB.06 */ 00121 #define LSM303DLHC_I2C_SCK_GPIO_PORT GPIOB /* GPIOB */ 00122 #define LSM303DLHC_I2C_SCK_GPIO_CLK RCC_AHBPeriph_GPIOB 00123 #define LSM303DLHC_I2C_SCK_SOURCE GPIO_PinSource6 00124 #define LSM303DLHC_I2C_SCK_AF GPIO_AF_4 00125 00126 #define LSM303DLHC_I2C_SDA_PIN GPIO_Pin_7 /* PB.7 */ 00127 #define LSM303DLHC_I2C_SDA_GPIO_PORT GPIOB /* GPIOB */ 00128 #define LSM303DLHC_I2C_SDA_GPIO_CLK RCC_AHBPeriph_GPIOB 00129 #define LSM303DLHC_I2C_SDA_SOURCE GPIO_PinSource7 00130 #define LSM303DLHC_I2C_SDA_AF GPIO_AF_4 00131 00132 #define LSM303DLHC_DRDY_PIN GPIO_Pin_2 /* PE.02 */ 00133 #define LSM303DLHC_DRDY_GPIO_PORT GPIOE /* GPIOE */ 00134 #define LSM303DLHC_DRDY_GPIO_CLK RCC_AHBPeriph_GPIOE 00135 #define LSM303DLHC_DRDY_EXTI_LINE EXTI_Line2 00136 #define LSM303DLHC_DRDY_EXTI_PORT_SOURCE EXTI_PortSourceGPIOE 00137 #define LSM303DLHC_DRDY_EXTI_PIN_SOURCE EXTI_PinSource2 00138 #define LSM303DLHC_DRDY_EXTI_IRQn EXTI2_TS_IRQn 00139 00140 #define LSM303DLHC_I2C_INT1_PIN GPIO_Pin_4 /* PE.04 */ 00141 #define LSM303DLHC_I2C_INT1_GPIO_PORT GPIOE /* GPIOE */ 00142 #define LSM303DLHC_I2C_INT1_GPIO_CLK RCC_AHBPeriph_GPIOE 00143 #define LSM303DLHC_I2C_INT1_EXTI_LINE EXTI_Line4 00144 #define LSM303DLHC_I2C_INT1_EXTI_PORT_SOURCE EXTI_PortSourceGPIOE 00145 #define LSM303DLHC_I2C_INT1_EXTI_PIN_SOURCE EXTI_PinSource4 00146 #define LSM303DLHC_I2C_INT1_EXTI_IRQn EXTI4_IRQn 00147 00148 #define LSM303DLHC_I2C_INT2_PIN GPIO_Pin_5 /* PE.05 */ 00149 #define LSM303DLHC_I2C_INT2_GPIO_PORT GPIOE /* GPIOE */ 00150 #define LSM303DLHC_I2C_INT2_GPIO_CLK RCC_AHBPeriph_GPIOE 00151 #define LSM303DLHC_I2C_INT2_EXTI_LINE EXTI_Line5 00152 #define LSM303DLHC_I2C_INT2_EXTI_PORT_SOURCE EXTI_PortSourceGPIOE 00153 #define LSM303DLHC_I2C_INT2_EXTI_PIN_SOURCE EXTI_PinSource5ss 00154 #define LSM303DLHC_I2C_INT2_EXTI_IRQn EXTI9_5_IRQn 00155 00156 /******************************************************************************/ 00157 /*************************** START REGISTER MAPPING **************************/ 00158 /******************************************************************************/ 00159 /* Acceleration Registers */ 00160 #define LSM303DLHC_CTRL_REG1_A 0x20 /* Control register 1 acceleration */ 00161 #define LSM303DLHC_CTRL_REG2_A 0x21 /* Control register 2 acceleration */ 00162 #define LSM303DLHC_CTRL_REG3_A 0x22 /* Control register 3 acceleration */ 00163 #define LSM303DLHC_CTRL_REG4_A 0x23 /* Control register 4 acceleration */ 00164 #define LSM303DLHC_CTRL_REG5_A 0x24 /* Control register 5 acceleration */ 00165 #define LSM303DLHC_CTRL_REG6_A 0x25 /* Control register 6 acceleration */ 00166 #define LSM303DLHC_REFERENCE_A 0x26 /* Reference register acceleration */ 00167 #define LSM303DLHC_STATUS_REG_A 0x27 /* Status register acceleration */ 00168 #define LSM303DLHC_OUT_X_L_A 0x28 /* Output Register X acceleration */ 00169 #define LSM303DLHC_OUT_X_H_A 0x29 /* Output Register X acceleration */ 00170 #define LSM303DLHC_OUT_Y_L_A 0x2A /* Output Register Y acceleration */ 00171 #define LSM303DLHC_OUT_Y_H_A 0x2B /* Output Register Y acceleration */ 00172 #define LSM303DLHC_OUT_Z_L_A 0x2C /* Output Register Z acceleration */ 00173 #define LSM303DLHC_OUT_Z_H_A 0x2D /* Output Register Z acceleration */ 00174 #define LSM303DLHC_FIFO_CTRL_REG_A 0x2E /* Fifo control Register acceleration */ 00175 #define LSM303DLHC_FIFO_SRC_REG_A 0x2F /* Fifo src Register acceleration */ 00176 00177 #define LSM303DLHC_INT1_CFG_A 0x30 /* Interrupt 1 configuration Register acceleration */ 00178 #define LSM303DLHC_INT1_SOURCE_A 0x31 /* Interrupt 1 source Register acceleration */ 00179 #define LSM303DLHC_INT1_THS_A 0x32 /* Interrupt 1 Threshold register acceleration */ 00180 #define LSM303DLHC_INT1_DURATION_A 0x33 /* Interrupt 1 DURATION register acceleration */ 00181 00182 #define LSM303DLHC_INT2_CFG_A 0x34 /* Interrupt 2 configuration Register acceleration */ 00183 #define LSM303DLHC_INT2_SOURCE_A 0x35 /* Interrupt 2 source Register acceleration */ 00184 #define LSM303DLHC_INT2_THS_A 0x36 /* Interrupt 2 Threshold register acceleration */ 00185 #define LSM303DLHC_INT2_DURATION_A 0x37 /* Interrupt 2 DURATION register acceleration */ 00186 00187 #define LSM303DLHC_CLICK_CFG_A 0x38 /* Click configuration Register acceleration */ 00188 #define LSM303DLHC_CLICK_SOURCE_A 0x39 /* Click 2 source Register acceleration */ 00189 #define LSM303DLHC_CLICK_THS_A 0x3A /* Click 2 Threshold register acceleration */ 00190 00191 #define LSM303DLHC_TIME_LIMIT_A 0x3B /* Time Limit Register acceleration */ 00192 #define LSM303DLHC_TIME_LATENCY_A 0x3C /* Time Latency Register acceleration */ 00193 #define LSM303DLHC_TIME_WINDOW_A 0x3D /* Time window register acceleration */ 00194 00195 /* Magnetic field Registers */ 00196 #define LSM303DLHC_CRA_REG_M 0x00 /* Control register A magnetic field */ 00197 #define LSM303DLHC_CRB_REG_M 0x01 /* Control register B magnetic field */ 00198 #define LSM303DLHC_MR_REG_M 0x02 /* Control register MR magnetic field */ 00199 #define LSM303DLHC_OUT_X_H_M 0x03 /* Output Register X magnetic field */ 00200 #define LSM303DLHC_OUT_X_L_M 0x04 /* Output Register X magnetic field */ 00201 #define LSM303DLHC_OUT_Z_H_M 0x05 /* Output Register Z magnetic field */ 00202 #define LSM303DLHC_OUT_Z_L_M 0x06 /* Output Register Z magnetic field */ 00203 #define LSM303DLHC_OUT_Y_H_M 0x07 /* Output Register Y magnetic field */ 00204 #define LSM303DLHC_OUT_Y_L_M 0x08 /* Output Register Y magnetic field */ 00205 00206 #define LSM303DLHC_SR_REG_M 0x09 /* Status Register magnetic field */ 00207 #define LSM303DLHC_IRA_REG_M 0x0A /* IRA Register magnetic field */ 00208 #define LSM303DLHC_IRB_REG_M 0x0B /* IRB Register magnetic field */ 00209 #define LSM303DLHC_IRC_REG_M 0x0C /* IRC Register magnetic field */ 00210 00211 #define LSM303DLHC_TEMP_OUT_H_M 0x31 /* Temperature Register magnetic field */ 00212 #define LSM303DLHC_TEMP_OUT_L_M 0x32 /* Temperature Register magnetic field */ 00213 /******************************************************************************/ 00214 /**************************** END REGISTER MAPPING ***************************/ 00215 /******************************************************************************/ 00216 00217 #define ACC_I2C_ADDRESS 0x32 00218 #define MAG_I2C_ADDRESS 0x3C 00219 00220 /** @defgroup Acc_Power_Mode_selection 00221 * @{ 00222 */ 00223 #define LSM303DLHC_NORMAL_MODE ((uint8_t)0x00) 00224 #define LSM303DLHC_LOWPOWER_MODE ((uint8_t)0x08) 00225 /** 00226 * @} 00227 */ 00228 00229 /** @defgroup Acc_OutPut_DataRate_Selection 00230 * @{ 00231 */ 00232 #define LSM303DLHC_ODR_1_HZ ((uint8_t)0x10) /*!< Output Data Rate = 1 Hz */ 00233 #define LSM303DLHC_ODR_10_HZ ((uint8_t)0x20) /*!< Output Data Rate = 10 Hz */ 00234 #define LSM303DLHC_ODR_25_HZ ((uint8_t)0x30) /*!< Output Data Rate = 25 Hz */ 00235 #define LSM303DLHC_ODR_50_HZ ((uint8_t)0x40) /*!< Output Data Rate = 50 Hz */ 00236 #define LSM303DLHC_ODR_100_HZ ((uint8_t)0x50) /*!< Output Data Rate = 100 Hz */ 00237 #define LSM303DLHC_ODR_200_HZ ((uint8_t)0x60) /*!< Output Data Rate = 200 Hz */ 00238 #define LSM303DLHC_ODR_400_HZ ((uint8_t)0x70) /*!< Output Data Rate = 400 Hz */ 00239 #define LSM303DLHC_ODR_1620_HZ_LP ((uint8_t)0x80) /*!< Output Data Rate = 1620 Hz only in Low Power Mode */ 00240 #define LSM303DLHC_ODR_1344_HZ ((uint8_t)0x90) /*!< Output Data Rate = 1344 Hz in Normal mode and 5376 Hz in Low Power Mode */ 00241 00242 /** 00243 * @} 00244 */ 00245 00246 /** @defgroup Acc_Axes_Selection 00247 * @{ 00248 */ 00249 #define LSM303DLHC_X_ENABLE ((uint8_t)0x01) 00250 #define LSM303DLHC_Y_ENABLE ((uint8_t)0x02) 00251 #define LSM303DLHC_Z_ENABLE ((uint8_t)0x04) 00252 #define LSM303DLHC_AXES_ENABLE ((uint8_t)0x07) 00253 #define LSM303DLHC_AXES_DISABLE ((uint8_t)0x00) 00254 /** 00255 * @} 00256 */ 00257 00258 /** @defgroup Acc_High_Resolution 00259 * @{ 00260 */ 00261 #define LSM303DLHC_HR_ENABLE ((uint8_t)0x08) 00262 #define LSM303DLHC_HR_DISABLE ((uint8_t)0x00) 00263 /** 00264 * @} 00265 */ 00266 00267 /** @defgroup Acc_Full_Scale_Selection 00268 * @{ 00269 */ 00270 #define LSM303DLHC_FULLSCALE_2G ((uint8_t)0x00) /*!< �2 g */ 00271 #define LSM303DLHC_FULLSCALE_4G ((uint8_t)0x10) /*!< �4 g */ 00272 #define LSM303DLHC_FULLSCALE_8G ((uint8_t)0x20) /*!< �8 g */ 00273 #define LSM303DLHC_FULLSCALE_16G ((uint8_t)0x30) /*!< �16 g */ 00274 /** 00275 * @} 00276 */ 00277 00278 /** @defgroup Acc_Block_Data_Update 00279 * @{ 00280 */ 00281 #define LSM303DLHC_BlockUpdate_Continous ((uint8_t)0x00) /*!< Continuos Update */ 00282 #define LSM303DLHC_BlockUpdate_Single ((uint8_t)0x80) /*!< Single Update: output registers not updated until MSB and LSB reading */ 00283 /** 00284 * @} 00285 */ 00286 00287 /** @defgroup Acc_Endian_Data_selection 00288 * @{ 00289 */ 00290 #define LSM303DLHC_BLE_LSB ((uint8_t)0x00) /*!< Little Endian: data LSB @ lower address */ 00291 #define LSM303DLHC_BLE_MSB ((uint8_t)0x40) /*!< Big Endian: data MSB @ lower address */ 00292 /** 00293 * @} 00294 */ 00295 00296 /** @defgroup Acc_Boot_Mode_selection 00297 * @{ 00298 */ 00299 #define LSM303DLHC_BOOT_NORMALMODE ((uint8_t)0x00) 00300 #define LSM303DLHC_BOOT_REBOOTMEMORY ((uint8_t)0x80) 00301 /** 00302 * @} 00303 */ 00304 00305 /** @defgroup Acc_High_Pass_Filter_Mode 00306 * @{ 00307 */ 00308 #define LSM303DLHC_HPM_NORMAL_MODE_RES ((uint8_t)0x00) 00309 #define LSM303DLHC_HPM_REF_SIGNAL ((uint8_t)0x40) 00310 #define LSM303DLHC_HPM_NORMAL_MODE ((uint8_t)0x80) 00311 #define LSM303DLHC_HPM_AUTORESET_INT ((uint8_t)0xC0) 00312 /** 00313 * @} 00314 */ 00315 00316 /** @defgroup Acc_High_Pass_CUT OFF_Frequency 00317 * @{ 00318 */ 00319 #define LSM303DLHC_HPFCF_8 ((uint8_t)0x00) 00320 #define LSM303DLHC_HPFCF_16 ((uint8_t)0x10) 00321 #define LSM303DLHC_HPFCF_32 ((uint8_t)0x20) 00322 #define LSM303DLHC_HPFCF_64 ((uint8_t)0x30) 00323 /** 00324 * @} 00325 */ 00326 00327 /** @defgroup Acc_High_Pass_Filter_status 00328 * @{ 00329 */ 00330 #define LSM303DLHC_HIGHPASSFILTER_DISABLE ((uint8_t)0x00) 00331 #define LSM303DLHC_HIGHPASSFILTER_ENABLE ((uint8_t)0x08) 00332 /** 00333 * @} 00334 */ 00335 00336 /** @defgroup Acc_High_Pass_Filter_Click_status 00337 * @{ 00338 */ 00339 #define LSM303DLHC_HPF_CLICK_DISABLE ((uint8_t)0x00) 00340 #define LSM303DLHC_HPF_CLICK_ENABLE ((uint8_t)0x04) 00341 /** 00342 * @} 00343 */ 00344 00345 /** @defgroup Acc_High_Pass_Filter_AOI1_status 00346 * @{ 00347 */ 00348 #define LSM303DLHC_HPF_AOI1_DISABLE ((uint8_t)0x00) 00349 #define LSM303DLHC_HPF_AOI1_ENABLE ((uint8_t)0x01) 00350 /** 00351 * @} 00352 */ 00353 00354 /** @defgroup Acc_High_Pass_Filter_AOI2_status 00355 * @{ 00356 */ 00357 #define LSM303DLHC_HPF_AOI2_DISABLE ((uint8_t)0x00) 00358 #define LSM303DLHC_HPF_AOI2_ENABLE ((uint8_t)0x02) 00359 /** 00360 * @} 00361 */ 00362 00363 /** @defgroup Acc_LSM303DLHC_Interrupt1_Configuration_definition 00364 * @{ 00365 */ 00366 #define LSM303DLHC_IT1_CLICK ((uint8_t)0x80) 00367 #define LSM303DLHC_IT1_AOI1 ((uint8_t)0x40) 00368 #define LSM303DLHC_IT1_AOI2 ((uint8_t)0x20) 00369 #define LSM303DLHC_IT1_DRY1 ((uint8_t)0x10) 00370 #define LSM303DLHC_IT1_DRY2 ((uint8_t)0x08) 00371 #define LSM303DLHC_IT1_WTM ((uint8_t)0x04) 00372 #define LSM303DLHC_IT1_OVERRUN ((uint8_t)0x02) 00373 /** 00374 * @} 00375 */ 00376 00377 /** @defgroup Acc_LSM303DLHC_Interrupt2_Configuration_definition 00378 * @{ 00379 */ 00380 #define LSM303DLHC_IT2_CLICK ((uint8_t)0x80) 00381 #define LSM303DLHC_IT2_INT1 ((uint8_t)0x40) 00382 #define LSM303DLHC_IT2_INT2 ((uint8_t)0x20) 00383 #define LSM303DLHC_IT2_BOOT ((uint8_t)0x10) 00384 #define LSM303DLHC_IT2_ACT ((uint8_t)0x08) 00385 #define LSM303DLHC_IT2_HLACTIVE ((uint8_t)0x02) 00386 /** 00387 * @} 00388 */ 00389 00390 /** @defgroup Acc_INT_Combination_Status 00391 * @{ 00392 */ 00393 #define LSM303DLHC_OR_COMBINATION ((uint8_t)0x00) /*!< OR combination of enabled IRQs */ 00394 #define LSM303DLHC_AND_COMBINATION ((uint8_t)0x80) /*!< AND combination of enabled IRQs */ 00395 #define LSM303DLHC_MOV_RECOGNITION ((uint8_t)0x40) /*!< 6D movement recognition */ 00396 #define LSM303DLHC_POS_RECOGNITION ((uint8_t)0xC0) /*!< 6D position recognition */ 00397 /** 00398 * @} 00399 */ 00400 00401 /** @defgroup Acc_INT_Axes 00402 * @{ 00403 */ 00404 #define LSM303DLHC_Z_HIGH ((uint8_t)0x20) /*!< Z High enabled IRQs */ 00405 #define LSM303DLHC_Z_LOW ((uint8_t)0x10) /*!< Z low enabled IRQs */ 00406 #define LSM303DLHC_Y_HIGH ((uint8_t)0x08) /*!< Y High enabled IRQs */ 00407 #define LSM303DLHC_Y_LOW ((uint8_t)0x04) /*!< Y low enabled IRQs */ 00408 #define LSM303DLHC_X_HIGH ((uint8_t)0x02) /*!< X High enabled IRQs */ 00409 #define LSM303DLHC_X_LOW ((uint8_t)0x01) /*!< X low enabled IRQs */ 00410 /** 00411 * @} 00412 */ 00413 00414 /** @defgroup Acc_INT_Click 00415 * @{ 00416 */ 00417 #define LSM303DLHC_Z_DOUBLE_CLICK ((uint8_t)0x20) /*!< Z double click IRQs */ 00418 #define LSM303DLHC_Z_SINGLE_CLICK ((uint8_t)0x10) /*!< Z single click IRQs */ 00419 #define LSM303DLHC_Y_DOUBLE_CLICK ((uint8_t)0x08) /*!< Y double click IRQs */ 00420 #define LSM303DLHC_Y_SINGLE_CLICK ((uint8_t)0x04) /*!< Y single click IRQs */ 00421 #define LSM303DLHC_X_DOUBLE_CLICK ((uint8_t)0x02) /*!< X double click IRQs */ 00422 #define LSM303DLHC_X_SINGLE_CLICK ((uint8_t)0x01) /*!< X single click IRQs */ 00423 /** 00424 * @} 00425 */ 00426 00427 /** @defgroup Acc_INT1_Interrupt_status 00428 * @{ 00429 */ 00430 #define LSM303DLHC_INT1INTERRUPT_DISABLE ((uint8_t)0x00) 00431 #define LSM303DLHC_INT1INTERRUPT_ENABLE ((uint8_t)0x80) 00432 /** 00433 * @} 00434 */ 00435 00436 /** @defgroup Acc_INT1_Interrupt_ActiveEdge 00437 * @{ 00438 */ 00439 #define LSM303DLHC_INT1INTERRUPT_LOW_EDGE ((uint8_t)0x20) 00440 #define LSM303DLHC_INT1INTERRUPT_HIGH_EDGE ((uint8_t)0x00) 00441 /** 00442 * @} 00443 */ 00444 00445 /** @defgroup Mag_Data_Rate 00446 * @{ 00447 */ 00448 #define LSM303DLHC_ODR_0_75_HZ ((uint8_t) 0x00) /*!< Output Data Rate = 0.75 Hz */ 00449 #define LSM303DLHC_ODR_1_5_HZ ((uint8_t) 0x04) /*!< Output Data Rate = 1.5 Hz */ 00450 #define LSM303DLHC_ODR_3_0_HZ ((uint8_t) 0x08) /*!< Output Data Rate = 3 Hz */ 00451 #define LSM303DLHC_ODR_7_5_HZ ((uint8_t) 0x0C) /*!< Output Data Rate = 7.5 Hz */ 00452 #define LSM303DLHC_ODR_15_HZ ((uint8_t) 0x10) /*!< Output Data Rate = 15 Hz */ 00453 #define LSM303DLHC_ODR_30_HZ ((uint8_t) 0x14) /*!< Output Data Rate = 30 Hz */ 00454 #define LSM303DLHC_ODR_75_HZ ((uint8_t) 0x18) /*!< Output Data Rate = 75 Hz */ 00455 #define LSM303DLHC_ODR_220_HZ ((uint8_t) 0x1C) /*!< Output Data Rate = 220 Hz */ 00456 /** 00457 * @} 00458 */ 00459 00460 /** @defgroup Mag_Full_Scale 00461 * @{ 00462 */ 00463 #define LSM303DLHC_FS_1_3_GA ((uint8_t) 0x20) /*!< Full scale = �1.3 Gauss */ 00464 #define LSM303DLHC_FS_1_9_GA ((uint8_t) 0x40) /*!< Full scale = �1.9 Gauss */ 00465 #define LSM303DLHC_FS_2_5_GA ((uint8_t) 0x60) /*!< Full scale = �2.5 Gauss */ 00466 #define LSM303DLHC_FS_4_0_GA ((uint8_t) 0x80) /*!< Full scale = �4.0 Gauss */ 00467 #define LSM303DLHC_FS_4_7_GA ((uint8_t) 0xA0) /*!< Full scale = �4.7 Gauss */ 00468 #define LSM303DLHC_FS_5_6_GA ((uint8_t) 0xC0) /*!< Full scale = �5.6 Gauss */ 00469 #define LSM303DLHC_FS_8_1_GA ((uint8_t) 0xE0) /*!< Full scale = �8.1 Gauss */ 00470 /** 00471 * @} 00472 */ 00473 00474 /** 00475 * @defgroup Magnetometer_Sensitivity 00476 * @{ 00477 */ 00478 #define LSM303DLHC_M_SENSITIVITY_XY_1_3Ga 1100 /*!< magnetometer X Y axes sensitivity for 1.3 Ga full scale [LSB/Ga] */ 00479 #define LSM303DLHC_M_SENSITIVITY_XY_1_9Ga 855 /*!< magnetometer X Y axes sensitivity for 1.9 Ga full scale [LSB/Ga] */ 00480 #define LSM303DLHC_M_SENSITIVITY_XY_2_5Ga 670 /*!< magnetometer X Y axes sensitivity for 2.5 Ga full scale [LSB/Ga] */ 00481 #define LSM303DLHC_M_SENSITIVITY_XY_4Ga 450 /*!< magnetometer X Y axes sensitivity for 4 Ga full scale [LSB/Ga] */ 00482 #define LSM303DLHC_M_SENSITIVITY_XY_4_7Ga 400 /*!< magnetometer X Y axes sensitivity for 4.7 Ga full scale [LSB/Ga] */ 00483 #define LSM303DLHC_M_SENSITIVITY_XY_5_6Ga 330 /*!< magnetometer X Y axes sensitivity for 5.6 Ga full scale [LSB/Ga] */ 00484 #define LSM303DLHC_M_SENSITIVITY_XY_8_1Ga 230 /*!< magnetometer X Y axes sensitivity for 8.1 Ga full scale [LSB/Ga] */ 00485 #define LSM303DLHC_M_SENSITIVITY_Z_1_3Ga 980 /*!< magnetometer Z axis sensitivity for 1.3 Ga full scale [LSB/Ga] */ 00486 #define LSM303DLHC_M_SENSITIVITY_Z_1_9Ga 760 /*!< magnetometer Z axis sensitivity for 1.9 Ga full scale [LSB/Ga] */ 00487 #define LSM303DLHC_M_SENSITIVITY_Z_2_5Ga 600 /*!< magnetometer Z axis sensitivity for 2.5 Ga full scale [LSB/Ga] */ 00488 #define LSM303DLHC_M_SENSITIVITY_Z_4Ga 400 /*!< magnetometer Z axis sensitivity for 4 Ga full scale [LSB/Ga] */ 00489 #define LSM303DLHC_M_SENSITIVITY_Z_4_7Ga 355 /*!< magnetometer Z axis sensitivity for 4.7 Ga full scale [LSB/Ga] */ 00490 #define LSM303DLHC_M_SENSITIVITY_Z_5_6Ga 295 /*!< magnetometer Z axis sensitivity for 5.6 Ga full scale [LSB/Ga] */ 00491 #define LSM303DLHC_M_SENSITIVITY_Z_8_1Ga 205 /*!< magnetometer Z axis sensitivity for 8.1 Ga full scale [LSB/Ga] */ 00492 /** 00493 * @} 00494 */ 00495 00496 /** @defgroup Mag_Working_Mode 00497 * @{ 00498 */ 00499 #define LSM303DLHC_CONTINUOS_CONVERSION ((uint8_t) 0x00) /*!< Continuous-Conversion Mode */ 00500 #define LSM303DLHC_SINGLE_CONVERSION ((uint8_t) 0x01) /*!< Single-Conversion Mode */ 00501 #define LSM303DLHC_SLEEP ((uint8_t) 0x02) /*!< Sleep Mode */ 00502 /** 00503 * @} 00504 */ 00505 00506 /** @defgroup Mag_Temperature_Sensor 00507 * @{ 00508 */ 00509 #define LSM303DLHC_TEMPSENSOR_ENABLE ((uint8_t) 0x80) /*!< Temp sensor Enable */ 00510 #define LSM303DLHC_TEMPSENSOR_DISABLE ((uint8_t) 0x00) /*!< Temp sensor Disable */ 00511 /** 00512 * @} 00513 */ 00514 00515 /** @defgroup STM32F3_DISCOVERY_LSM303DLHC_Exported_Functions 00516 * @{ 00517 */ 00518 /* Acc functions */ 00519 void LSM303DLHC_AccInit(LSM303DLHCAcc_InitTypeDef *LSM303DLHC_InitStruct); 00520 void LSM303DLHC_AccRebootCmd(void); 00521 void LSM303DLHC_AccFilterConfig(LSM303DLHCAcc_FilterConfigTypeDef *LSM303DLHC_FilterStruct) ; 00522 void LSM303DLHC_AccFilterCmd(uint8_t HighPassFilterState); 00523 void LSM303DLHC_AccFilterClickCmd(uint8_t HighPassFilterClickState); 00524 void LSM303DLHC_AccIT1Config(uint8_t LSM303DLHC_IT, FunctionalState NewState); 00525 void LSM303DLHC_AccIT2Config(uint8_t LSM303DLHC_IT, FunctionalState NewState); 00526 void LSM303DLHC_AccINT1InterruptConfig(uint8_t ITCombination, uint8_t ITAxes, FunctionalState NewState ); 00527 void LSM303DLHC_AccINT2InterruptConfig(uint8_t ITCombination, uint8_t ITAxes, FunctionalState NewState ); 00528 void LSM303DLHC_AccClickITConfig(uint8_t ITClick, FunctionalState NewState); 00529 uint8_t LSM303DLHC_AccGetDataStatus(void); 00530 00531 /* Mag functions */ 00532 void LSM303DLHC_MagInit(LSM303DLHCMag_InitTypeDef *LSM303DLHC_InitStruct); 00533 uint8_t LSM303DLHC_MagGetDataStatus(void); 00534 00535 /* read write funtions */ 00536 uint16_t LSM303DLHC_Write(uint8_t DeviceAddr, uint8_t RegAddr, uint8_t* pBuffer); 00537 uint16_t LSM303DLHC_Read(uint8_t DeviceAddr, uint8_t RegAddr,uint8_t* pBuffer, uint16_t NumByteToRead); 00538 00539 /* USER Callbacks: This is function for which prototype only is declared in 00540 MEMS accelerometre driver and that should be implemented into user applicaiton. */ 00541 /* LSM303DLHC_TIMEOUT_UserCallback() function is called whenever a timeout condition 00542 occure during communication (waiting transmit data register empty flag(TXE) 00543 or waiting receive data register is not empty flag (RXNE)). 00544 You can use the default timeout callback implementation by uncommenting the 00545 define USE_DEFAULT_TIMEOUT_CALLBACK in stm32f3_discovery_LSM303DLHC.h file. 00546 Typically the user implementation of this callback should reset MEMS peripheral 00547 and re-initialize communication or in worst case reset all the application. */ 00548 uint32_t LSM303DLHC_TIMEOUT_UserCallback(void); 00549 00550 #ifdef __cplusplus 00551 } 00552 #endif 00553 00554 #endif /* __STM32F3_DISCOVERY_LSM303DLHC_H */ 00555 /** 00556 * @} 00557 */ 00558 00559 /** 00560 * @} 00561 */ 00562 00563 /** 00564 * @} 00565 */ 00566 00567 /** 00568 * @} 00569 */ 00570 00571 00572 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
Generated on Tue Jul 12 2022 17:34:45 by
1.7.2