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: mbed-os-example-ble-Thermometer DISCO_L475VG_IOT01-Telegram-BOT DISCO_L475VG_IOT01-sche_cheveux DISCO_L475VG_IOT01-QSPI_FLASH_FILE_SYSTEM ... more
stm32l475e_iot01_accelero.c
00001 /** 00002 ****************************************************************************** 00003 * @file stm32l475e_iot01_accelero.c 00004 * @author MCD Application Team 00005 * @brief This file provides a set of functions needed to manage the accelerometer sensor 00006 ****************************************************************************** 00007 * @attention 00008 * 00009 * <h2><center>© Copyright (c) 2017 STMicroelectronics. 00010 * All rights reserved.</center></h2> 00011 * 00012 * This software component is licensed by ST under BSD 3-Clause license, 00013 * the "License"; You may not use this file except in compliance with the 00014 * License. You may obtain a copy of the License at: 00015 * opensource.org/licenses/BSD-3-Clause 00016 * 00017 ****************************************************************************** 00018 */ 00019 00020 /* Includes ------------------------------------------------------------------*/ 00021 #include "stm32l475e_iot01_accelero.h" 00022 /** @addtogroup BSP 00023 * @{ 00024 */ 00025 00026 /** @addtogroup STM32L475E_IOT01 00027 * @{ 00028 */ 00029 00030 /** @defgroup STM32L475E_IOT01_ACCELERO ACCELERO 00031 * @{ 00032 */ 00033 00034 /** @defgroup STM32L475E_IOT01_ACCELERO_Private_Variables ACCELERO Private Variables 00035 * @{ 00036 */ 00037 static ACCELERO_DrvTypeDef *AccelerometerDrv; 00038 /** 00039 * @} 00040 */ 00041 00042 /** @defgroup STM32L475E_IOT01_ACCELERO_Private_Functions ACCELERO Private Functions 00043 * @{ 00044 */ 00045 /** 00046 * @brief Initialize the ACCELERO. 00047 * @retval ACCELERO_OK or ACCELERO_ERROR 00048 */ 00049 ACCELERO_StatusTypeDef BSP_ACCELERO_Init(void) 00050 { 00051 ACCELERO_StatusTypeDef ret = ACCELERO_OK; 00052 uint16_t ctrl = 0x0000; 00053 ACCELERO_InitTypeDef LSM6DSL_InitStructure; 00054 00055 if(Lsm6dslAccDrv.ReadID() != LSM6DSL_ACC_GYRO_WHO_AM_I) 00056 { 00057 ret = ACCELERO_ERROR; 00058 } 00059 else 00060 { 00061 /* Initialize the ACCELERO accelerometer driver structure */ 00062 AccelerometerDrv = &Lsm6dslAccDrv; 00063 00064 /* MEMS configuration ------------------------------------------------------*/ 00065 /* Fill the ACCELERO accelerometer structure */ 00066 LSM6DSL_InitStructure.AccOutput_DataRate = LSM6DSL_ODR_52Hz; 00067 LSM6DSL_InitStructure.Axes_Enable = 0; 00068 LSM6DSL_InitStructure.AccFull_Scale = LSM6DSL_ACC_FULLSCALE_2G; 00069 LSM6DSL_InitStructure.BlockData_Update = LSM6DSL_BDU_BLOCK_UPDATE; 00070 LSM6DSL_InitStructure.High_Resolution = 0; 00071 LSM6DSL_InitStructure.Communication_Mode = 0; 00072 00073 /* Configure MEMS: data rate, full scale */ 00074 ctrl = (LSM6DSL_InitStructure.AccOutput_DataRate | LSM6DSL_InitStructure.AccFull_Scale); 00075 00076 /* Configure MEMS: BDU and Auto-increment for multi read/write */ 00077 ctrl |= ((LSM6DSL_InitStructure.BlockData_Update | LSM6DSL_ACC_GYRO_IF_INC_ENABLED) << 8); 00078 00079 /* Configure the ACCELERO accelerometer main parameters */ 00080 AccelerometerDrv->Init(ctrl); 00081 } 00082 00083 return ret; 00084 } 00085 00086 /** 00087 * @brief DeInitialize the ACCELERO. 00088 * @retval None. 00089 */ 00090 void BSP_ACCELERO_DeInit(void) 00091 { 00092 /* DeInitialize the accelerometer IO interfaces */ 00093 if(AccelerometerDrv != NULL) 00094 { 00095 if(AccelerometerDrv->DeInit != NULL) 00096 { 00097 AccelerometerDrv->DeInit(); 00098 } 00099 } 00100 } 00101 00102 /** 00103 * @brief Set/Unset the ACCELERO in low power mode. 00104 * @param status 0 means disable Low Power Mode, otherwise Low Power Mode is enabled 00105 * @retval None 00106 */ 00107 void BSP_ACCELERO_LowPower(uint16_t status) 00108 { 00109 /* Set/Unset the ACCELERO in low power mode */ 00110 if(AccelerometerDrv != NULL) 00111 { 00112 if(AccelerometerDrv->LowPower != NULL) 00113 { 00114 AccelerometerDrv->LowPower(status); 00115 } 00116 } 00117 } 00118 00119 /** 00120 * @brief Get XYZ acceleration values. 00121 * @param pDataXYZ Pointer on 3 angular accelerations table with 00122 * pDataXYZ[0] = X axis, pDataXYZ[1] = Y axis, pDataXYZ[2] = Z axis 00123 * @retval None 00124 */ 00125 void BSP_ACCELERO_AccGetXYZ(int16_t *pDataXYZ) 00126 { 00127 if(AccelerometerDrv != NULL) 00128 { 00129 if(AccelerometerDrv->GetXYZ != NULL) 00130 { 00131 AccelerometerDrv->GetXYZ(pDataXYZ); 00132 } 00133 } 00134 } 00135 /** 00136 * @} 00137 */ 00138 00139 /** 00140 * @} 00141 */ 00142 00143 /** 00144 * @} 00145 */ 00146 00147 /** 00148 * @} 00149 */ 00150 00151 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
Generated on Tue Jul 12 2022 13:55:42 by
1.7.2