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:
jeromecoutant
Date:
Tue Sep 24 15:30:09 2019 +0200
Revision:
7:bfe8272ced90
Parent:
6:9dfa42666f03
Update BSP files with STM32Cube L4 V1.14.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 *
jeromecoutant 7:bfe8272ced90 9 * <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
bcostm 3:c6b5944187d5 10 * All rights reserved.</center></h2>
bcostm 3:c6b5944187d5 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 3:c6b5944187d5 16 *
bcostm 3:c6b5944187d5 17 ******************************************************************************
bcostm 3:c6b5944187d5 18 */
bcostm 3:c6b5944187d5 19
bcostm 3:c6b5944187d5 20 /* Includes ------------------------------------------------------------------*/
bcostm 3:c6b5944187d5 21 #include "stm32l475e_iot01_accelero.h"
bcostm 3:c6b5944187d5 22 /** @addtogroup BSP
bcostm 3:c6b5944187d5 23 * @{
bcostm 3:c6b5944187d5 24 */
bcostm 3:c6b5944187d5 25
bcostm 3:c6b5944187d5 26 /** @addtogroup STM32L475E_IOT01
bcostm 3:c6b5944187d5 27 * @{
bcostm 3:c6b5944187d5 28 */
bcostm 3:c6b5944187d5 29
bcostm 3:c6b5944187d5 30 /** @defgroup STM32L475E_IOT01_ACCELERO ACCELERO
bcostm 3:c6b5944187d5 31 * @{
bcostm 3:c6b5944187d5 32 */
bcostm 3:c6b5944187d5 33
bcostm 3:c6b5944187d5 34 /** @defgroup STM32L475E_IOT01_ACCELERO_Private_Variables ACCELERO Private Variables
bcostm 3:c6b5944187d5 35 * @{
bcostm 3:c6b5944187d5 36 */
bcostm 3:c6b5944187d5 37 static ACCELERO_DrvTypeDef *AccelerometerDrv;
bcostm 3:c6b5944187d5 38 /**
bcostm 3:c6b5944187d5 39 * @}
bcostm 3:c6b5944187d5 40 */
bcostm 3:c6b5944187d5 41
bcostm 3:c6b5944187d5 42 /** @defgroup STM32L475E_IOT01_ACCELERO_Private_Functions ACCELERO Private Functions
bcostm 3:c6b5944187d5 43 * @{
bcostm 3:c6b5944187d5 44 */
bcostm 3:c6b5944187d5 45 /**
bcostm 3:c6b5944187d5 46 * @brief Initialize the ACCELERO.
bcostm 3:c6b5944187d5 47 * @retval ACCELERO_OK or ACCELERO_ERROR
bcostm 3:c6b5944187d5 48 */
bcostm 3:c6b5944187d5 49 ACCELERO_StatusTypeDef BSP_ACCELERO_Init(void)
bcostm 3:c6b5944187d5 50 {
bcostm 3:c6b5944187d5 51 ACCELERO_StatusTypeDef ret = ACCELERO_OK;
bcostm 3:c6b5944187d5 52 uint16_t ctrl = 0x0000;
bcostm 3:c6b5944187d5 53 ACCELERO_InitTypeDef LSM6DSL_InitStructure;
bcostm 3:c6b5944187d5 54
bcostm 3:c6b5944187d5 55 if(Lsm6dslAccDrv.ReadID() != LSM6DSL_ACC_GYRO_WHO_AM_I)
bcostm 3:c6b5944187d5 56 {
bcostm 3:c6b5944187d5 57 ret = ACCELERO_ERROR;
bcostm 3:c6b5944187d5 58 }
bcostm 3:c6b5944187d5 59 else
bcostm 3:c6b5944187d5 60 {
bcostm 3:c6b5944187d5 61 /* Initialize the ACCELERO accelerometer driver structure */
bcostm 3:c6b5944187d5 62 AccelerometerDrv = &Lsm6dslAccDrv;
bcostm 3:c6b5944187d5 63
bcostm 3:c6b5944187d5 64 /* MEMS configuration ------------------------------------------------------*/
bcostm 3:c6b5944187d5 65 /* Fill the ACCELERO accelerometer structure */
bcostm 3:c6b5944187d5 66 LSM6DSL_InitStructure.AccOutput_DataRate = LSM6DSL_ODR_52Hz;
bcostm 3:c6b5944187d5 67 LSM6DSL_InitStructure.Axes_Enable = 0;
bcostm 3:c6b5944187d5 68 LSM6DSL_InitStructure.AccFull_Scale = LSM6DSL_ACC_FULLSCALE_2G;
bcostm 3:c6b5944187d5 69 LSM6DSL_InitStructure.BlockData_Update = LSM6DSL_BDU_BLOCK_UPDATE;
bcostm 3:c6b5944187d5 70 LSM6DSL_InitStructure.High_Resolution = 0;
bcostm 3:c6b5944187d5 71 LSM6DSL_InitStructure.Communication_Mode = 0;
bcostm 3:c6b5944187d5 72
bcostm 3:c6b5944187d5 73 /* Configure MEMS: data rate, full scale */
bcostm 3:c6b5944187d5 74 ctrl = (LSM6DSL_InitStructure.AccOutput_DataRate | LSM6DSL_InitStructure.AccFull_Scale);
bcostm 3:c6b5944187d5 75
bcostm 3:c6b5944187d5 76 /* Configure MEMS: BDU and Auto-increment for multi read/write */
bcostm 3:c6b5944187d5 77 ctrl |= ((LSM6DSL_InitStructure.BlockData_Update | LSM6DSL_ACC_GYRO_IF_INC_ENABLED) << 8);
bcostm 3:c6b5944187d5 78
bcostm 3:c6b5944187d5 79 /* Configure the ACCELERO accelerometer main parameters */
bcostm 3:c6b5944187d5 80 AccelerometerDrv->Init(ctrl);
bcostm 3:c6b5944187d5 81 }
bcostm 3:c6b5944187d5 82
bcostm 3:c6b5944187d5 83 return ret;
bcostm 3:c6b5944187d5 84 }
bcostm 3:c6b5944187d5 85
bcostm 3:c6b5944187d5 86 /**
bcostm 3:c6b5944187d5 87 * @brief DeInitialize the ACCELERO.
bcostm 3:c6b5944187d5 88 * @retval None.
bcostm 3:c6b5944187d5 89 */
bcostm 3:c6b5944187d5 90 void BSP_ACCELERO_DeInit(void)
bcostm 3:c6b5944187d5 91 {
bcostm 3:c6b5944187d5 92 /* DeInitialize the accelerometer IO interfaces */
bcostm 3:c6b5944187d5 93 if(AccelerometerDrv != NULL)
bcostm 3:c6b5944187d5 94 {
bcostm 3:c6b5944187d5 95 if(AccelerometerDrv->DeInit != NULL)
bcostm 3:c6b5944187d5 96 {
bcostm 3:c6b5944187d5 97 AccelerometerDrv->DeInit();
bcostm 3:c6b5944187d5 98 }
bcostm 3:c6b5944187d5 99 }
bcostm 3:c6b5944187d5 100 }
bcostm 3:c6b5944187d5 101
bcostm 3:c6b5944187d5 102 /**
bcostm 3:c6b5944187d5 103 * @brief Set/Unset the ACCELERO in low power mode.
bcostm 3:c6b5944187d5 104 * @param status 0 means disable Low Power Mode, otherwise Low Power Mode is enabled
bcostm 3:c6b5944187d5 105 * @retval None
bcostm 3:c6b5944187d5 106 */
bcostm 3:c6b5944187d5 107 void BSP_ACCELERO_LowPower(uint16_t status)
bcostm 3:c6b5944187d5 108 {
bcostm 3:c6b5944187d5 109 /* Set/Unset the ACCELERO in low power mode */
bcostm 3:c6b5944187d5 110 if(AccelerometerDrv != NULL)
bcostm 3:c6b5944187d5 111 {
bcostm 3:c6b5944187d5 112 if(AccelerometerDrv->LowPower != NULL)
bcostm 3:c6b5944187d5 113 {
bcostm 3:c6b5944187d5 114 AccelerometerDrv->LowPower(status);
bcostm 3:c6b5944187d5 115 }
bcostm 3:c6b5944187d5 116 }
bcostm 3:c6b5944187d5 117 }
bcostm 3:c6b5944187d5 118
bcostm 3:c6b5944187d5 119 /**
bcostm 3:c6b5944187d5 120 * @brief Get XYZ acceleration values.
bcostm 3:c6b5944187d5 121 * @param pDataXYZ Pointer on 3 angular accelerations table with
bcostm 3:c6b5944187d5 122 * pDataXYZ[0] = X axis, pDataXYZ[1] = Y axis, pDataXYZ[2] = Z axis
bcostm 3:c6b5944187d5 123 * @retval None
bcostm 3:c6b5944187d5 124 */
bcostm 3:c6b5944187d5 125 void BSP_ACCELERO_AccGetXYZ(int16_t *pDataXYZ)
bcostm 3:c6b5944187d5 126 {
bcostm 3:c6b5944187d5 127 if(AccelerometerDrv != NULL)
bcostm 3:c6b5944187d5 128 {
bcostm 3:c6b5944187d5 129 if(AccelerometerDrv->GetXYZ != NULL)
bcostm 3:c6b5944187d5 130 {
bcostm 3:c6b5944187d5 131 AccelerometerDrv->GetXYZ(pDataXYZ);
bcostm 3:c6b5944187d5 132 }
bcostm 3:c6b5944187d5 133 }
bcostm 3:c6b5944187d5 134 }
bcostm 3:c6b5944187d5 135 /**
bcostm 3:c6b5944187d5 136 * @}
bcostm 3:c6b5944187d5 137 */
bcostm 3:c6b5944187d5 138
bcostm 3:c6b5944187d5 139 /**
bcostm 3:c6b5944187d5 140 * @}
bcostm 3:c6b5944187d5 141 */
bcostm 3:c6b5944187d5 142
bcostm 3:c6b5944187d5 143 /**
bcostm 3:c6b5944187d5 144 * @}
bcostm 3:c6b5944187d5 145 */
bcostm 3:c6b5944187d5 146
bcostm 3:c6b5944187d5 147 /**
bcostm 3:c6b5944187d5 148 * @}
bcostm 3:c6b5944187d5 149 */
bcostm 3:c6b5944187d5 150
bcostm 3:c6b5944187d5 151 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/