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/

Committer:
bcostm
Date:
Fri Jan 19 14:27:51 2018 +0100
Revision:
6:9dfa42666f03
Parent:
5:0c70bc6d2dc0
Child:
7:bfe8272ced90
Update BSP files with STM32Cube L4 V1.11.0

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bcostm 3:c6b5944187d5 1 /**
bcostm 3:c6b5944187d5 2 ******************************************************************************
bcostm 3:c6b5944187d5 3 * @file stm32l475e_iot01_accelero.c
bcostm 3:c6b5944187d5 4 * @author MCD Application Team
bcostm 3:c6b5944187d5 5 * @brief This file provides a set of functions needed to manage the accelerometer sensor
bcostm 3:c6b5944187d5 6 ******************************************************************************
bcostm 3:c6b5944187d5 7 * @attention
bcostm 3:c6b5944187d5 8 *
bcostm 3:c6b5944187d5 9 * <h2><center>&copy; Copyright (c) 2017 STMicroelectronics International N.V.
bcostm 3:c6b5944187d5 10 * All rights reserved.</center></h2>
bcostm 3:c6b5944187d5 11 *
bcostm 3:c6b5944187d5 12 * Redistribution and use in source and binary forms, with or without
bcostm 3:c6b5944187d5 13 * modification, are permitted, provided that the following conditions are met:
bcostm 3:c6b5944187d5 14 *
bcostm 3:c6b5944187d5 15 * 1. Redistribution of source code must retain the above copyright notice,
bcostm 3:c6b5944187d5 16 * this list of conditions and the following disclaimer.
bcostm 3:c6b5944187d5 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
bcostm 3:c6b5944187d5 18 * this list of conditions and the following disclaimer in the documentation
bcostm 3:c6b5944187d5 19 * and/or other materials provided with the distribution.
bcostm 3:c6b5944187d5 20 * 3. Neither the name of STMicroelectronics nor the names of other
bcostm 3:c6b5944187d5 21 * contributors to this software may be used to endorse or promote products
bcostm 3:c6b5944187d5 22 * derived from this software without specific written permission.
bcostm 3:c6b5944187d5 23 * 4. This software, including modifications and/or derivative works of this
bcostm 3:c6b5944187d5 24 * software, must execute solely and exclusively on microcontroller or
bcostm 3:c6b5944187d5 25 * microprocessor devices manufactured by or for STMicroelectronics.
bcostm 3:c6b5944187d5 26 * 5. Redistribution and use of this software other than as permitted under
bcostm 3:c6b5944187d5 27 * this license is void and will automatically terminate your rights under
bcostm 3:c6b5944187d5 28 * this license.
bcostm 3:c6b5944187d5 29 *
bcostm 3:c6b5944187d5 30 * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS"
bcostm 3:c6b5944187d5 31 * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT
bcostm 3:c6b5944187d5 32 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
bcostm 3:c6b5944187d5 33 * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY
bcostm 3:c6b5944187d5 34 * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT
bcostm 3:c6b5944187d5 35 * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
bcostm 3:c6b5944187d5 36 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
bcostm 3:c6b5944187d5 37 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
bcostm 3:c6b5944187d5 38 * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
bcostm 3:c6b5944187d5 39 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
bcostm 3:c6b5944187d5 40 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
bcostm 3:c6b5944187d5 41 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
bcostm 3:c6b5944187d5 42 *
bcostm 3:c6b5944187d5 43 ******************************************************************************
bcostm 3:c6b5944187d5 44 */
bcostm 3:c6b5944187d5 45
bcostm 3:c6b5944187d5 46 /* Includes ------------------------------------------------------------------*/
bcostm 3:c6b5944187d5 47 #include "stm32l475e_iot01_accelero.h"
bcostm 3:c6b5944187d5 48 /** @addtogroup BSP
bcostm 3:c6b5944187d5 49 * @{
bcostm 3:c6b5944187d5 50 */
bcostm 3:c6b5944187d5 51
bcostm 3:c6b5944187d5 52 /** @addtogroup STM32L475E_IOT01
bcostm 3:c6b5944187d5 53 * @{
bcostm 3:c6b5944187d5 54 */
bcostm 3:c6b5944187d5 55
bcostm 3:c6b5944187d5 56 /** @defgroup STM32L475E_IOT01_ACCELERO ACCELERO
bcostm 3:c6b5944187d5 57 * @{
bcostm 3:c6b5944187d5 58 */
bcostm 3:c6b5944187d5 59
bcostm 3:c6b5944187d5 60 /** @defgroup STM32L475E_IOT01_ACCELERO_Private_Variables ACCELERO Private Variables
bcostm 3:c6b5944187d5 61 * @{
bcostm 3:c6b5944187d5 62 */
bcostm 3:c6b5944187d5 63 static ACCELERO_DrvTypeDef *AccelerometerDrv;
bcostm 3:c6b5944187d5 64 /**
bcostm 3:c6b5944187d5 65 * @}
bcostm 3:c6b5944187d5 66 */
bcostm 3:c6b5944187d5 67
bcostm 3:c6b5944187d5 68 /** @defgroup STM32L475E_IOT01_ACCELERO_Private_Functions ACCELERO Private Functions
bcostm 3:c6b5944187d5 69 * @{
bcostm 3:c6b5944187d5 70 */
bcostm 3:c6b5944187d5 71 /**
bcostm 3:c6b5944187d5 72 * @brief Initialize the ACCELERO.
bcostm 3:c6b5944187d5 73 * @retval ACCELERO_OK or ACCELERO_ERROR
bcostm 3:c6b5944187d5 74 */
bcostm 3:c6b5944187d5 75 ACCELERO_StatusTypeDef BSP_ACCELERO_Init(void)
bcostm 3:c6b5944187d5 76 {
bcostm 3:c6b5944187d5 77 ACCELERO_StatusTypeDef ret = ACCELERO_OK;
bcostm 3:c6b5944187d5 78 uint16_t ctrl = 0x0000;
bcostm 3:c6b5944187d5 79 ACCELERO_InitTypeDef LSM6DSL_InitStructure;
bcostm 3:c6b5944187d5 80
bcostm 3:c6b5944187d5 81 if(Lsm6dslAccDrv.ReadID() != LSM6DSL_ACC_GYRO_WHO_AM_I)
bcostm 3:c6b5944187d5 82 {
bcostm 3:c6b5944187d5 83 ret = ACCELERO_ERROR;
bcostm 3:c6b5944187d5 84 }
bcostm 3:c6b5944187d5 85 else
bcostm 3:c6b5944187d5 86 {
bcostm 3:c6b5944187d5 87 /* Initialize the ACCELERO accelerometer driver structure */
bcostm 3:c6b5944187d5 88 AccelerometerDrv = &Lsm6dslAccDrv;
bcostm 3:c6b5944187d5 89
bcostm 3:c6b5944187d5 90 /* MEMS configuration ------------------------------------------------------*/
bcostm 3:c6b5944187d5 91 /* Fill the ACCELERO accelerometer structure */
bcostm 3:c6b5944187d5 92 LSM6DSL_InitStructure.AccOutput_DataRate = LSM6DSL_ODR_52Hz;
bcostm 3:c6b5944187d5 93 LSM6DSL_InitStructure.Axes_Enable = 0;
bcostm 3:c6b5944187d5 94 LSM6DSL_InitStructure.AccFull_Scale = LSM6DSL_ACC_FULLSCALE_2G;
bcostm 3:c6b5944187d5 95 LSM6DSL_InitStructure.BlockData_Update = LSM6DSL_BDU_BLOCK_UPDATE;
bcostm 3:c6b5944187d5 96 LSM6DSL_InitStructure.High_Resolution = 0;
bcostm 3:c6b5944187d5 97 LSM6DSL_InitStructure.Communication_Mode = 0;
bcostm 3:c6b5944187d5 98
bcostm 3:c6b5944187d5 99 /* Configure MEMS: data rate, full scale */
bcostm 3:c6b5944187d5 100 ctrl = (LSM6DSL_InitStructure.AccOutput_DataRate | LSM6DSL_InitStructure.AccFull_Scale);
bcostm 3:c6b5944187d5 101
bcostm 3:c6b5944187d5 102 /* Configure MEMS: BDU and Auto-increment for multi read/write */
bcostm 3:c6b5944187d5 103 ctrl |= ((LSM6DSL_InitStructure.BlockData_Update | LSM6DSL_ACC_GYRO_IF_INC_ENABLED) << 8);
bcostm 3:c6b5944187d5 104
bcostm 3:c6b5944187d5 105 /* Configure the ACCELERO accelerometer main parameters */
bcostm 3:c6b5944187d5 106 AccelerometerDrv->Init(ctrl);
bcostm 3:c6b5944187d5 107 }
bcostm 3:c6b5944187d5 108
bcostm 3:c6b5944187d5 109 return ret;
bcostm 3:c6b5944187d5 110 }
bcostm 3:c6b5944187d5 111
bcostm 3:c6b5944187d5 112 /**
bcostm 3:c6b5944187d5 113 * @brief DeInitialize the ACCELERO.
bcostm 3:c6b5944187d5 114 * @retval None.
bcostm 3:c6b5944187d5 115 */
bcostm 3:c6b5944187d5 116 void BSP_ACCELERO_DeInit(void)
bcostm 3:c6b5944187d5 117 {
bcostm 3:c6b5944187d5 118 /* DeInitialize the accelerometer IO interfaces */
bcostm 3:c6b5944187d5 119 if(AccelerometerDrv != NULL)
bcostm 3:c6b5944187d5 120 {
bcostm 3:c6b5944187d5 121 if(AccelerometerDrv->DeInit != NULL)
bcostm 3:c6b5944187d5 122 {
bcostm 3:c6b5944187d5 123 AccelerometerDrv->DeInit();
bcostm 3:c6b5944187d5 124 }
bcostm 3:c6b5944187d5 125 }
bcostm 3:c6b5944187d5 126 }
bcostm 3:c6b5944187d5 127
bcostm 3:c6b5944187d5 128 /**
bcostm 3:c6b5944187d5 129 * @brief Set/Unset the ACCELERO in low power mode.
bcostm 3:c6b5944187d5 130 * @param status 0 means disable Low Power Mode, otherwise Low Power Mode is enabled
bcostm 3:c6b5944187d5 131 * @retval None
bcostm 3:c6b5944187d5 132 */
bcostm 3:c6b5944187d5 133 void BSP_ACCELERO_LowPower(uint16_t status)
bcostm 3:c6b5944187d5 134 {
bcostm 3:c6b5944187d5 135 /* Set/Unset the ACCELERO in low power mode */
bcostm 3:c6b5944187d5 136 if(AccelerometerDrv != NULL)
bcostm 3:c6b5944187d5 137 {
bcostm 3:c6b5944187d5 138 if(AccelerometerDrv->LowPower != NULL)
bcostm 3:c6b5944187d5 139 {
bcostm 3:c6b5944187d5 140 AccelerometerDrv->LowPower(status);
bcostm 3:c6b5944187d5 141 }
bcostm 3:c6b5944187d5 142 }
bcostm 3:c6b5944187d5 143 }
bcostm 3:c6b5944187d5 144
bcostm 3:c6b5944187d5 145 /**
bcostm 3:c6b5944187d5 146 * @brief Get XYZ acceleration values.
bcostm 3:c6b5944187d5 147 * @param pDataXYZ Pointer on 3 angular accelerations table with
bcostm 3:c6b5944187d5 148 * pDataXYZ[0] = X axis, pDataXYZ[1] = Y axis, pDataXYZ[2] = Z axis
bcostm 3:c6b5944187d5 149 * @retval None
bcostm 3:c6b5944187d5 150 */
bcostm 3:c6b5944187d5 151 void BSP_ACCELERO_AccGetXYZ(int16_t *pDataXYZ)
bcostm 3:c6b5944187d5 152 {
bcostm 3:c6b5944187d5 153 if(AccelerometerDrv != NULL)
bcostm 3:c6b5944187d5 154 {
bcostm 3:c6b5944187d5 155 if(AccelerometerDrv->GetXYZ != NULL)
bcostm 3:c6b5944187d5 156 {
bcostm 3:c6b5944187d5 157 AccelerometerDrv->GetXYZ(pDataXYZ);
bcostm 3:c6b5944187d5 158 }
bcostm 3:c6b5944187d5 159 }
bcostm 3:c6b5944187d5 160 }
bcostm 3:c6b5944187d5 161 /**
bcostm 3:c6b5944187d5 162 * @}
bcostm 3:c6b5944187d5 163 */
bcostm 3:c6b5944187d5 164
bcostm 3:c6b5944187d5 165 /**
bcostm 3:c6b5944187d5 166 * @}
bcostm 3:c6b5944187d5 167 */
bcostm 3:c6b5944187d5 168
bcostm 3:c6b5944187d5 169 /**
bcostm 3:c6b5944187d5 170 * @}
bcostm 3:c6b5944187d5 171 */
bcostm 3:c6b5944187d5 172
bcostm 3:c6b5944187d5 173 /**
bcostm 3:c6b5944187d5 174 * @}
bcostm 3:c6b5944187d5 175 */
bcostm 3:c6b5944187d5 176
bcostm 3:c6b5944187d5 177 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/