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_gyro.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 gyroscope 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_gyro.h"
bcostm 3:c6b5944187d5 22
bcostm 3:c6b5944187d5 23 /** @addtogroup BSP
bcostm 3:c6b5944187d5 24 * @{
bcostm 3:c6b5944187d5 25 */
bcostm 3:c6b5944187d5 26
bcostm 3:c6b5944187d5 27 /** @addtogroup STM32L475E_IOT01
bcostm 3:c6b5944187d5 28 * @{
bcostm 3:c6b5944187d5 29 */
bcostm 3:c6b5944187d5 30
bcostm 3:c6b5944187d5 31 /** @defgroup STM32L475E_IOT01_GYROSCOPE GYROSCOPE
bcostm 3:c6b5944187d5 32 * @{
bcostm 3:c6b5944187d5 33 */
bcostm 3:c6b5944187d5 34
bcostm 3:c6b5944187d5 35 /** @defgroup STM32L475E_IOT01_GYROSCOPE_Private_Variables GYROSCOPE Private Variables
bcostm 3:c6b5944187d5 36 * @{
bcostm 3:c6b5944187d5 37 */
bcostm 3:c6b5944187d5 38 static GYRO_DrvTypeDef *GyroscopeDrv;
bcostm 3:c6b5944187d5 39
bcostm 3:c6b5944187d5 40 /**
bcostm 3:c6b5944187d5 41 * @}
bcostm 3:c6b5944187d5 42 */
bcostm 3:c6b5944187d5 43
bcostm 3:c6b5944187d5 44
bcostm 3:c6b5944187d5 45 /** @defgroup STM32L475E_IOT01_GYROSCOPE_Private_Functions GYROSCOPE Private Functions
bcostm 3:c6b5944187d5 46 * @{
bcostm 3:c6b5944187d5 47 */
bcostm 3:c6b5944187d5 48 /**
bcostm 3:c6b5944187d5 49 * @brief Initialize Gyroscope.
bcostm 3:c6b5944187d5 50 * @retval GYRO_OK or GYRO_ERROR
bcostm 3:c6b5944187d5 51 */
bcostm 3:c6b5944187d5 52 uint8_t BSP_GYRO_Init(void)
bcostm 3:c6b5944187d5 53 {
bcostm 3:c6b5944187d5 54 uint8_t ret = GYRO_ERROR;
bcostm 3:c6b5944187d5 55 uint16_t ctrl = 0x0000;
bcostm 3:c6b5944187d5 56 GYRO_InitTypeDef LSM6DSL_InitStructure;
bcostm 3:c6b5944187d5 57
bcostm 3:c6b5944187d5 58 if(Lsm6dslGyroDrv.ReadID() != LSM6DSL_ACC_GYRO_WHO_AM_I)
bcostm 3:c6b5944187d5 59 {
bcostm 3:c6b5944187d5 60 ret = GYRO_ERROR;
bcostm 3:c6b5944187d5 61 }
bcostm 3:c6b5944187d5 62 else
bcostm 3:c6b5944187d5 63 {
bcostm 3:c6b5944187d5 64 /* Initialize the gyroscope driver structure */
bcostm 3:c6b5944187d5 65 GyroscopeDrv = &Lsm6dslGyroDrv;
bcostm 3:c6b5944187d5 66
bcostm 3:c6b5944187d5 67 /* Configure Mems : data rate, power mode, full scale and axes */
bcostm 3:c6b5944187d5 68 LSM6DSL_InitStructure.Power_Mode = 0;
bcostm 3:c6b5944187d5 69 LSM6DSL_InitStructure.Output_DataRate = LSM6DSL_ODR_52Hz;
bcostm 3:c6b5944187d5 70 LSM6DSL_InitStructure.Axes_Enable = 0;
bcostm 3:c6b5944187d5 71 LSM6DSL_InitStructure.Band_Width = 0;
bcostm 3:c6b5944187d5 72 LSM6DSL_InitStructure.BlockData_Update = LSM6DSL_BDU_BLOCK_UPDATE;
bcostm 3:c6b5944187d5 73 LSM6DSL_InitStructure.Endianness = 0;
bcostm 3:c6b5944187d5 74 LSM6DSL_InitStructure.Full_Scale = LSM6DSL_GYRO_FS_2000;
bcostm 3:c6b5944187d5 75
bcostm 3:c6b5944187d5 76 /* Configure MEMS: data rate, full scale */
bcostm 3:c6b5944187d5 77 ctrl = (LSM6DSL_InitStructure.Full_Scale | LSM6DSL_InitStructure.Output_DataRate);
bcostm 3:c6b5944187d5 78
bcostm 3:c6b5944187d5 79 /* Configure MEMS: BDU and Auto-increment for multi read/write */
bcostm 3:c6b5944187d5 80 ctrl |= ((LSM6DSL_InitStructure.BlockData_Update | LSM6DSL_ACC_GYRO_IF_INC_ENABLED) << 8);
bcostm 3:c6b5944187d5 81
bcostm 3:c6b5944187d5 82 /* Initialize component */
bcostm 3:c6b5944187d5 83 GyroscopeDrv->Init(ctrl);
bcostm 3:c6b5944187d5 84
bcostm 3:c6b5944187d5 85 ret = GYRO_OK;
bcostm 3:c6b5944187d5 86 }
bcostm 3:c6b5944187d5 87
bcostm 3:c6b5944187d5 88 return ret;
bcostm 3:c6b5944187d5 89 }
bcostm 3:c6b5944187d5 90
bcostm 3:c6b5944187d5 91
bcostm 3:c6b5944187d5 92 /**
bcostm 3:c6b5944187d5 93 * @brief DeInitialize Gyroscope.
bcostm 3:c6b5944187d5 94 */
bcostm 3:c6b5944187d5 95 void BSP_GYRO_DeInit(void)
bcostm 3:c6b5944187d5 96 {
bcostm 3:c6b5944187d5 97 /* DeInitialize the Gyroscope IO interfaces */
bcostm 3:c6b5944187d5 98 if(GyroscopeDrv != NULL)
bcostm 3:c6b5944187d5 99 {
bcostm 3:c6b5944187d5 100 if(GyroscopeDrv->DeInit!= NULL)
bcostm 3:c6b5944187d5 101 {
bcostm 3:c6b5944187d5 102 GyroscopeDrv->DeInit();
bcostm 3:c6b5944187d5 103 }
bcostm 3:c6b5944187d5 104 }
bcostm 3:c6b5944187d5 105 }
bcostm 3:c6b5944187d5 106
bcostm 3:c6b5944187d5 107
bcostm 3:c6b5944187d5 108 /**
bcostm 3:c6b5944187d5 109 * @brief Set/Unset Gyroscope in low power mode.
bcostm 3:c6b5944187d5 110 * @param status 0 means disable Low Power Mode, otherwise Low Power Mode is enabled
bcostm 3:c6b5944187d5 111 */
bcostm 3:c6b5944187d5 112 void BSP_GYRO_LowPower(uint16_t status)
bcostm 3:c6b5944187d5 113 {
bcostm 3:c6b5944187d5 114 /* Set/Unset component in low-power mode */
bcostm 3:c6b5944187d5 115 if(GyroscopeDrv != NULL)
bcostm 3:c6b5944187d5 116 {
bcostm 3:c6b5944187d5 117 if(GyroscopeDrv->LowPower!= NULL)
bcostm 3:c6b5944187d5 118 {
bcostm 3:c6b5944187d5 119 GyroscopeDrv->LowPower(status);
bcostm 3:c6b5944187d5 120 }
bcostm 3:c6b5944187d5 121 }
bcostm 3:c6b5944187d5 122 }
bcostm 3:c6b5944187d5 123
bcostm 3:c6b5944187d5 124 /**
bcostm 3:c6b5944187d5 125 * @brief Get XYZ angular acceleration from the Gyroscope.
bcostm 3:c6b5944187d5 126 * @param pfData: pointer on floating array
bcostm 3:c6b5944187d5 127 */
bcostm 3:c6b5944187d5 128 void BSP_GYRO_GetXYZ(float* pfData)
bcostm 3:c6b5944187d5 129 {
bcostm 3:c6b5944187d5 130 if(GyroscopeDrv != NULL)
bcostm 3:c6b5944187d5 131 {
bcostm 3:c6b5944187d5 132 if(GyroscopeDrv->GetXYZ!= NULL)
bcostm 3:c6b5944187d5 133 {
bcostm 3:c6b5944187d5 134 GyroscopeDrv->GetXYZ(pfData);
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 /**
bcostm 3:c6b5944187d5 152 * @}
bcostm 3:c6b5944187d5 153 */
bcostm 3:c6b5944187d5 154
bcostm 3:c6b5944187d5 155 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/