BSP_DISCO_F429ZI updated for gyroscope use on DISC1 board (i3g4250d)
Revision 3:d06d6759139b, committed 2021-12-15
- Comitter:
- ovcharka132
- Date:
- Wed Dec 15 15:20:57 2021 +0000
- Parent:
- 2:53d9067a4feb
- Commit message:
- Changed gyroscope driver to i3g4250d for f429-DISC1 board
Changed in this revision
diff -r 53d9067a4feb -r d06d6759139b Drivers/BSP/Components/i3g4250d/i3g4250d.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Drivers/BSP/Components/i3g4250d/i3g4250d.c Wed Dec 15 15:20:57 2021 +0000 @@ -0,0 +1,399 @@ +/** + ****************************************************************************** + * @file i3g4250d.c + * @author MCD Application Team + * @brief This file provides a set of functions needed to manage the I3G4250D, + * ST MEMS motion sensor, 3-axis digital output gyroscope. + ****************************************************************************** + * @attention + * + * <h2><center>© Copyright (c) 2020 STMicroelectronics. + * All rights reserved.</center></h2> + * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ +/* Includes ------------------------------------------------------------------*/ +#include "i3g4250d.h" + +/** @addtogroup BSP + * @{ + */ + +/** @addtogroup Components + * @{ + */ + +/** @addtogroup I3G4250D + * @{ + */ + +/** @defgroup I3G4250D_Private_TypesDefinitions Private Types Definitions + * @{ + */ + +/** + * @} + */ + +/** @defgroup I3G4250D_Private_Defines Private Defines + * @{ + */ + +/** + * @} + */ + +/** @defgroup I3G4250D_Private_Macros Private Macros + * @{ + */ + +/** + * @} + */ + +/** @defgroup I3G4250D_Private_Variables Private Variables + * @{ + */ +GYRO_DrvTypeDef I3g4250Drv = +{ + I3G4250D_Init, + I3G4250D_DeInit, + I3G4250D_ReadID, + I3G4250D_RebootCmd, + I3G4250D_LowPower, + I3G4250D_INT1InterruptConfig, + I3G4250D_EnableIT, + I3G4250D_DisableIT, + 0, + 0, + I3G4250D_FilterConfig, + I3G4250D_FilterCmd, + I3G4250D_ReadXYZAngRate +}; + +/** + * @} + */ + +/** @defgroup I3G4250D_Private_FunctionPrototypes Private Function Prototypes + * @{ + */ + +/** + * @} + */ + +/** @defgroup I3G4250D_Private_Functions Private Functions + * @{ + */ + +/** + * @brief Set I3G4250D Initialization. + * @param I3G4250D_InitStruct: pointer to a I3G4250D_InitTypeDef structure + * that contains the configuration setting for the I3G4250D. + * @retval None + */ +void I3G4250D_Init(uint16_t InitStruct) +{ + uint8_t ctrl = 0x00; + + /* Configure the low level interface */ + GYRO_IO_Init(); + + /* Write value to MEMS CTRL_REG1 register */ + ctrl = (uint8_t) InitStruct; + GYRO_IO_Write(&ctrl, I3G4250D_CTRL_REG1_ADDR, 1); + + /* Write value to MEMS CTRL_REG4 register */ + ctrl = (uint8_t)(InitStruct >> 8); + GYRO_IO_Write(&ctrl, I3G4250D_CTRL_REG4_ADDR, 1); +} + + + +/** + * @brief I3G4250D De-initialization + * @param None + * @retval None + */ +void I3G4250D_DeInit(void) +{ +} + +/** + * @brief Read ID address of I3G4250D + * @param None + * @retval ID name + */ +uint8_t I3G4250D_ReadID(void) +{ + uint8_t tmp; + + /* Configure the low level interface */ + GYRO_IO_Init(); + + /* Read WHO I AM register */ + GYRO_IO_Read(&tmp, I3G4250D_WHO_AM_I_ADDR, 1); + + /* Return the ID */ + return (uint8_t)tmp; +} + +/** + * @brief Reboot memory content of I3G4250D + * @param None + * @retval None + */ +void I3G4250D_RebootCmd(void) +{ + uint8_t tmpreg; + + /* Read CTRL_REG5 register */ + GYRO_IO_Read(&tmpreg, I3G4250D_CTRL_REG5_ADDR, 1); + + /* Enable or Disable the reboot memory */ + tmpreg |= I3G4250D_BOOT_REBOOTMEMORY; + + /* Write value to MEMS CTRL_REG5 register */ + GYRO_IO_Write(&tmpreg, I3G4250D_CTRL_REG5_ADDR, 1); +} + +/** + * @brief Set I3G4250D in low-power mode + * @param I3G4250D_InitStruct: pointer to a I3G4250D_InitTypeDef structure + * that contains the configuration setting for the I3G4250D. + * @retval None + */ +void I3G4250D_LowPower(uint16_t InitStruct) +{ + uint8_t ctrl = 0x00; + + /* Write value to MEMS CTRL_REG1 register */ + ctrl = (uint8_t) InitStruct; + GYRO_IO_Write(&ctrl, I3G4250D_CTRL_REG1_ADDR, 1); +} + +/** + * @brief Set I3G4250D Interrupt INT1 configuration + * @param Int1Config: the configuration setting for the I3G4250D Interrupt. + * @retval None + */ +void I3G4250D_INT1InterruptConfig(uint16_t Int1Config) +{ + uint8_t ctrl_cfr = 0x00, ctrl3 = 0x00; + + /* Read INT1_CFG register */ + GYRO_IO_Read(&ctrl_cfr, I3G4250D_INT1_CFG_ADDR, 1); + + /* Read CTRL_REG3 register */ + GYRO_IO_Read(&ctrl3, I3G4250D_CTRL_REG3_ADDR, 1); + + ctrl_cfr &= 0x80; + ctrl_cfr |= ((uint8_t) Int1Config >> 8); + + ctrl3 &= 0xDF; + ctrl3 |= ((uint8_t) Int1Config); + + /* Write value to MEMS INT1_CFG register */ + GYRO_IO_Write(&ctrl_cfr, I3G4250D_INT1_CFG_ADDR, 1); + + /* Write value to MEMS CTRL_REG3 register */ + GYRO_IO_Write(&ctrl3, I3G4250D_CTRL_REG3_ADDR, 1); +} + +/** + * @brief Enable INT1 or INT2 interrupt + * @param IntSel: choice of INT1 or INT2 + * This parameter can be: + * @arg I3G4250D_INT1 + * @arg I3G4250D_INT2 + * @retval None + */ +void I3G4250D_EnableIT(uint8_t IntSel) +{ + uint8_t tmpreg; + + /* Read CTRL_REG3 register */ + GYRO_IO_Read(&tmpreg, I3G4250D_CTRL_REG3_ADDR, 1); + + if (IntSel == I3G4250D_INT1) + { + tmpreg &= 0x7F; + tmpreg |= I3G4250D_INT1INTERRUPT_ENABLE; + } + else if (IntSel == I3G4250D_INT2) + { + tmpreg &= 0xF7; + tmpreg |= I3G4250D_INT2INTERRUPT_ENABLE; + } + + /* Write value to MEMS CTRL_REG3 register */ + GYRO_IO_Write(&tmpreg, I3G4250D_CTRL_REG3_ADDR, 1); +} + +/** + * @brief Disable INT1 or INT2 interrupt + * @param IntSel: choice of INT1 or INT2 + * This parameter can be: + * @arg I3G4250D_INT1 + * @arg I3G4250D_INT2 + * @retval None + */ +void I3G4250D_DisableIT(uint8_t IntSel) +{ + uint8_t tmpreg; + + /* Read CTRL_REG3 register */ + GYRO_IO_Read(&tmpreg, I3G4250D_CTRL_REG3_ADDR, 1); + + if (IntSel == I3G4250D_INT1) + { + tmpreg &= 0x7F; + tmpreg |= I3G4250D_INT1INTERRUPT_DISABLE; + } + else if (IntSel == I3G4250D_INT2) + { + tmpreg &= 0xF7; + tmpreg |= I3G4250D_INT2INTERRUPT_DISABLE; + } + + /* Write value to MEMS CTRL_REG3 register */ + GYRO_IO_Write(&tmpreg, I3G4250D_CTRL_REG3_ADDR, 1); +} + +/** + * @brief Set High Pass Filter Modality + * @param FilterStruct: contains the configuration setting for the L3GD20. + * @retval None + */ +void I3G4250D_FilterConfig(uint8_t FilterStruct) +{ + uint8_t tmpreg; + + /* Read CTRL_REG2 register */ + GYRO_IO_Read(&tmpreg, I3G4250D_CTRL_REG2_ADDR, 1); + + tmpreg &= 0xC0; + + /* Configure MEMS: mode and cutoff frequency */ + tmpreg |= FilterStruct; + + /* Write value to MEMS CTRL_REG2 register */ + GYRO_IO_Write(&tmpreg, I3G4250D_CTRL_REG2_ADDR, 1); +} + +/** + * @brief Enable or Disable High Pass Filter + * @param HighPassFilterState: new state of the High Pass Filter feature. + * This parameter can be: + * @arg: I3G4250D_HIGHPASSFILTER_DISABLE + * @arg: I3G4250D_HIGHPASSFILTER_ENABLE + * @retval None + */ +void I3G4250D_FilterCmd(uint8_t HighPassFilterState) +{ + uint8_t tmpreg; + + /* Read CTRL_REG5 register */ + GYRO_IO_Read(&tmpreg, I3G4250D_CTRL_REG5_ADDR, 1); + + tmpreg &= 0xEF; + + tmpreg |= HighPassFilterState; + + /* Write value to MEMS CTRL_REG5 register */ + GYRO_IO_Write(&tmpreg, I3G4250D_CTRL_REG5_ADDR, 1); +} + +/** + * @brief Get status for I3G4250D data + * @param None + * @retval Data status in a I3G4250D Data + */ +uint8_t I3G4250D_GetDataStatus(void) +{ + uint8_t tmpreg; + + /* Read STATUS_REG register */ + GYRO_IO_Read(&tmpreg, I3G4250D_STATUS_REG_ADDR, 1); + + return tmpreg; +} + +/** +* @brief Calculate the I3G4250D angular data. +* @param pfData: Data out pointer +* @retval None +*/ +void I3G4250D_ReadXYZAngRate(float *pfData) +{ + uint8_t tmpbuffer[6] = {0}; + int16_t RawData[3] = {0}; + uint8_t tmpreg = 0; + float sensitivity = 0; + int i = 0; + + GYRO_IO_Read(&tmpreg, I3G4250D_CTRL_REG4_ADDR, 1); + + GYRO_IO_Read(tmpbuffer, I3G4250D_OUT_X_L_ADDR, 6); + + /* check in the control register 4 the data alignment (Big Endian or Little Endian)*/ + if (!(tmpreg & I3G4250D_BLE_MSB)) + { + for (i = 0; i < 3; i++) + { + RawData[i] = (int16_t)(((uint16_t)tmpbuffer[2 * i + 1] << 8) + tmpbuffer[2 * i]); + } + } + else + { + for (i = 0; i < 3; i++) + { + RawData[i] = (int16_t)(((uint16_t)tmpbuffer[2 * i] << 8) + tmpbuffer[2 * i + 1]); + } + } + + /* Switch the sensitivity value set in the CRTL4 */ + switch (tmpreg & I3G4250D_FULLSCALE_SELECTION) + { + case I3G4250D_FULLSCALE_245: + sensitivity = I3G4250D_SENSITIVITY_245DPS; + break; + + case I3G4250D_FULLSCALE_500: + sensitivity = I3G4250D_SENSITIVITY_500DPS; + break; + + case I3G4250D_FULLSCALE_2000: + sensitivity = I3G4250D_SENSITIVITY_2000DPS; + break; + } + /* Multiplied by sensitivity */ + for (i = 0; i < 3; i++) + { + pfData[i] = (float)(RawData[i] * sensitivity); + } +} + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ \ No newline at end of file
diff -r 53d9067a4feb -r d06d6759139b Drivers/BSP/Components/i3g4250d/i3g4250d.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Drivers/BSP/Components/i3g4250d/i3g4250d.h Wed Dec 15 15:20:57 2021 +0000 @@ -0,0 +1,305 @@ +/** + ****************************************************************************** + * @file i3g4250d.h + * @author MCD Application Team + * @brief This file contains all the functions prototypes for the i3g4250d.c driver. + ****************************************************************************** + * @attention + * + * <h2><center>© Copyright (c) 2020 STMicroelectronics. + * All rights reserved.</center></h2> + * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __I3G4250D_H +#define __I3G4250D_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include "../Common/gyro.h" + +/** @addtogroup BSP + * @{ + */ + +/** @addtogroup Components + * @{ + */ + +/** @addtogroup I3G4250D + * @{ + */ + +/** @defgroup I3G4250D_Exported_Constants + * @{ + */ + +/******************************************************************************/ +/*************************** START REGISTER MAPPING **************************/ +/******************************************************************************/ +#define I3G4250D_WHO_AM_I_ADDR 0x0F /* device identification register */ +#define I3G4250D_CTRL_REG1_ADDR 0x20 /* Control register 1 */ +#define I3G4250D_CTRL_REG2_ADDR 0x21 /* Control register 2 */ +#define I3G4250D_CTRL_REG3_ADDR 0x22 /* Control register 3 */ +#define I3G4250D_CTRL_REG4_ADDR 0x23 /* Control register 4 */ +#define I3G4250D_CTRL_REG5_ADDR 0x24 /* Control register 5 */ +#define I3G4250D_REFERENCE_REG_ADDR 0x25 /* Reference register */ +#define I3G4250D_OUT_TEMP_ADDR 0x26 /* Out temp register */ +#define I3G4250D_STATUS_REG_ADDR 0x27 /* Status register */ +#define I3G4250D_OUT_X_L_ADDR 0x28 /* Output Register X */ +#define I3G4250D_OUT_X_H_ADDR 0x29 /* Output Register X */ +#define I3G4250D_OUT_Y_L_ADDR 0x2A /* Output Register Y */ +#define I3G4250D_OUT_Y_H_ADDR 0x2B /* Output Register Y */ +#define I3G4250D_OUT_Z_L_ADDR 0x2C /* Output Register Z */ +#define I3G4250D_OUT_Z_H_ADDR 0x2D /* Output Register Z */ +#define I3G4250D_FIFO_CTRL_REG_ADDR 0x2E /* Fifo control Register */ +#define I3G4250D_FIFO_SRC_REG_ADDR 0x2F /* Fifo src Register */ + +#define I3G4250D_INT1_CFG_ADDR 0x30 /* Interrupt 1 configuration Register */ +#define I3G4250D_INT1_SRC_ADDR 0x31 /* Interrupt 1 source Register */ +#define I3G4250D_INT1_TSH_XH_ADDR 0x32 /* Interrupt 1 Threshold X register */ +#define I3G4250D_INT1_TSH_XL_ADDR 0x33 /* Interrupt 1 Threshold X register */ +#define I3G4250D_INT1_TSH_YH_ADDR 0x34 /* Interrupt 1 Threshold Y register */ +#define I3G4250D_INT1_TSH_YL_ADDR 0x35 /* Interrupt 1 Threshold Y register */ +#define I3G4250D_INT1_TSH_ZH_ADDR 0x36 /* Interrupt 1 Threshold Z register */ +#define I3G4250D_INT1_TSH_ZL_ADDR 0x37 /* Interrupt 1 Threshold Z register */ +#define I3G4250D_INT1_DURATION_ADDR 0x38 /* Interrupt 1 DURATION register */ + +/******************************************************************************/ +/**************************** END REGISTER MAPPING ***************************/ +/******************************************************************************/ + +#define I_AM_I3G4250D ((uint8_t)0xD3) + +/** @defgroup Power_Mode_selection Power Mode selection + * @{ + */ +#define I3G4250D_MODE_POWERDOWN ((uint8_t)0x00) +#define I3G4250D_MODE_ACTIVE ((uint8_t)0x08) +/** + * @} + */ + +/** @defgroup OutPut_DataRate_Selection OutPut DataRate Selection + * @{ + */ +#define I3G4250D_OUTPUT_DATARATE_1 ((uint8_t)0x00) +#define I3G4250D_OUTPUT_DATARATE_2 ((uint8_t)0x40) +#define I3G4250D_OUTPUT_DATARATE_3 ((uint8_t)0x80) +#define I3G4250D_OUTPUT_DATARATE_4 ((uint8_t)0xC0) +/** + * @} + */ + +/** @defgroup Axes_Selection Axes Selection + * @{ + */ +#define I3G4250D_X_ENABLE ((uint8_t)0x02) +#define I3G4250D_Y_ENABLE ((uint8_t)0x01) +#define I3G4250D_Z_ENABLE ((uint8_t)0x04) +#define I3G4250D_AXES_ENABLE ((uint8_t)0x07) +#define I3G4250D_AXES_DISABLE ((uint8_t)0x00) +/** + * @} + */ + +/** @defgroup Bandwidth_Selection Bandwidth Selection + * @{ + */ +#define I3G4250D_BANDWIDTH_1 ((uint8_t)0x00) +#define I3G4250D_BANDWIDTH_2 ((uint8_t)0x10) +#define I3G4250D_BANDWIDTH_3 ((uint8_t)0x20) +#define I3G4250D_BANDWIDTH_4 ((uint8_t)0x30) +/** + * @} + */ + +/** @defgroup Full_Scale_Selection Full Scale Selection + * @{ + */ +#define I3G4250D_FULLSCALE_245 ((uint8_t)0x00) +#define I3G4250D_FULLSCALE_500 ((uint8_t)0x10) +#define I3G4250D_FULLSCALE_2000 ((uint8_t)0x20) +#define I3G4250D_FULLSCALE_SELECTION ((uint8_t)0x30) +/** + * @} + */ + +/** @defgroup Full_Scale_Sensitivity Full Scale Sensitivity + * @{ + */ +#define I3G4250D_SENSITIVITY_245DPS ((float)8.75f) /*!< gyroscope sensitivity with 250 dps full scale [DPS/LSB] */ +#define I3G4250D_SENSITIVITY_500DPS ((float)17.50f) /*!< gyroscope sensitivity with 500 dps full scale [DPS/LSB] */ +#define I3G4250D_SENSITIVITY_2000DPS ((float)70.00f) /*!< gyroscope sensitivity with 2000 dps full scale [DPS/LSB] */ +/** + * @} + */ + + +/** @defgroup Block_Data_Update Block Data Update + * @{ + */ +#define I3G4250D_BlockDataUpdate_Continous ((uint8_t)0x00) +#define I3G4250D_BlockDataUpdate_Single ((uint8_t)0x80) +/** + * @} + */ + +/** @defgroup Endian_Data_selection Endian Data selection + * @{ + */ +#define I3G4250D_BLE_LSB ((uint8_t)0x00) +#define I3G4250D_BLE_MSB ((uint8_t)0x40) +/** + * @} + */ + +/** @defgroup High_Pass_Filter_status High Pass Filter status + * @{ + */ +#define I3G4250D_HIGHPASSFILTER_DISABLE ((uint8_t)0x00) +#define I3G4250D_HIGHPASSFILTER_ENABLE ((uint8_t)0x10) +/** + * @} + */ + +/** @defgroup INT1_INT2_selection Selection + * @{ + */ +#define I3G4250D_INT1 ((uint8_t)0x00) +#define I3G4250D_INT2 ((uint8_t)0x01) +/** + * @} + */ + +/** @defgroup INT1_Interrupt_status Interrupt Status + * @{ + */ +#define I3G4250D_INT1INTERRUPT_DISABLE ((uint8_t)0x00) +#define I3G4250D_INT1INTERRUPT_ENABLE ((uint8_t)0x80) +/** + * @} + */ + +/** @defgroup INT2_Interrupt_status Interrupt Status + * @{ + */ +#define I3G4250D_INT2INTERRUPT_DISABLE ((uint8_t)0x00) +#define I3G4250D_INT2INTERRUPT_ENABLE ((uint8_t)0x08) +/** + * @} + */ + +/** @defgroup INT1_Interrupt_ActiveEdge Interrupt Active Edge + * @{ + */ +#define I3G4250D_INT1INTERRUPT_LOW_EDGE ((uint8_t)0x20) +#define I3G4250D_INT1INTERRUPT_HIGH_EDGE ((uint8_t)0x00) +/** + * @} + */ + +/** @defgroup Boot_Mode_selection Boot Mode Selection + * @{ + */ +#define I3G4250D_BOOT_NORMALMODE ((uint8_t)0x00) +#define I3G4250D_BOOT_REBOOTMEMORY ((uint8_t)0x80) +/** + * @} + */ + +/** @defgroup High_Pass_Filter_Mode High Pass Filter Mode + * @{ + */ +#define I3G4250D_HPM_NORMAL_MODE_RES ((uint8_t)0x00) +#define I3G4250D_HPM_REF_SIGNAL ((uint8_t)0x10) +#define I3G4250D_HPM_NORMAL_MODE ((uint8_t)0x20) +#define I3G4250D_HPM_AUTORESET_INT ((uint8_t)0x30) +/** + * @} + */ + +/** @defgroup High_Pass_CUT OFF_Frequency High Pass CUT OFF Frequency + * @{ + */ +#define I3G4250D_HPFCF_0 0x00 +#define I3G4250D_HPFCF_1 0x01 +#define I3G4250D_HPFCF_2 0x02 +#define I3G4250D_HPFCF_3 0x03 +#define I3G4250D_HPFCF_4 0x04 +#define I3G4250D_HPFCF_5 0x05 +#define I3G4250D_HPFCF_6 0x06 +#define I3G4250D_HPFCF_7 0x07 +#define I3G4250D_HPFCF_8 0x08 +#define I3G4250D_HPFCF_9 0x09 +/** + * @} + */ + +/** + * @} + */ +/** @defgroup I3G4250D_Exported_Functions Exported Functions + * @{ + */ +/* Sensor Configuration Functions */ +void I3G4250D_Init(uint16_t InitStruct); +void I3G4250D_DeInit(void); +void I3G4250D_LowPower(uint16_t InitStruct); +uint8_t I3G4250D_ReadID(void); +void I3G4250D_RebootCmd(void); + +/* Interrupt Configuration Functions */ +void I3G4250D_INT1InterruptConfig(uint16_t Int1Config); +void I3G4250D_EnableIT(uint8_t IntSel); +void I3G4250D_DisableIT(uint8_t IntSel); + +/* High Pass Filter Configuration Functions */ +void I3G4250D_FilterConfig(uint8_t FilterStruct); +void I3G4250D_FilterCmd(uint8_t HighPassFilterState); +void I3G4250D_ReadXYZAngRate(float *pfData); +uint8_t I3G4250D_GetDataStatus(void); + +/* Gyroscope IO functions */ +void GYRO_IO_Init(void); +void GYRO_IO_DeInit(void); +void GYRO_IO_Write(uint8_t *pBuffer, uint8_t WriteAddr, uint16_t NumByteToWrite); +void GYRO_IO_Read(uint8_t *pBuffer, uint8_t ReadAddr, uint16_t NumByteToRead); + +/* Gyroscope driver structure */ +extern GYRO_DrvTypeDef I3g4250Drv; + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* __I3G4250D_H */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ \ No newline at end of file
diff -r 53d9067a4feb -r d06d6759139b Drivers/BSP/Components/l3gd20/l3gd20.c --- a/Drivers/BSP/Components/l3gd20/l3gd20.c Wed Feb 28 13:17:14 2018 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,416 +0,0 @@ -/** - ****************************************************************************** - * @file l3gd20.c - * @author MCD Application Team - * @version V2.0.0 - * @date 26-June-2015 - * @brief This file provides a set of functions needed to manage the L3GD20, - * ST MEMS motion sensor, 3-axis digital output gyroscope. - ****************************************************************************** - * @attention - * - * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2> - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ -/* Includes ------------------------------------------------------------------*/ -#include "l3gd20.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup Components - * @{ - */ - -/** @addtogroup L3GD20 - * @{ - */ - -/** @defgroup L3GD20_Private_TypesDefinitions - * @{ - */ - -/** - * @} - */ - -/** @defgroup L3GD20_Private_Defines - * @{ - */ - -/** - * @} - */ - -/** @defgroup L3GD20_Private_Macros - * @{ - */ - -/** - * @} - */ - -/** @defgroup L3GD20_Private_Variables - * @{ - */ -GYRO_DrvTypeDef L3gd20Drv = -{ - L3GD20_Init, - L3GD20_DeInit, - L3GD20_ReadID, - L3GD20_RebootCmd, - L3GD20_LowPower, - L3GD20_INT1InterruptConfig, - L3GD20_EnableIT, - L3GD20_DisableIT, - 0, - 0, - L3GD20_FilterConfig, - L3GD20_FilterCmd, - L3GD20_ReadXYZAngRate -}; - -/** - * @} - */ - -/** @defgroup L3GD20_Private_FunctionPrototypes - * @{ - */ - -/** - * @} - */ - -/** @defgroup L3GD20_Private_Functions - * @{ - */ - -/** - * @brief Set L3GD20 Initialization. - * @param L3GD20_InitStruct: pointer to a L3GD20_InitTypeDef structure - * that contains the configuration setting for the L3GD20. - * @retval None - */ -void L3GD20_Init(uint16_t InitStruct) -{ - uint8_t ctrl = 0x00; - - /* Configure the low level interface */ - GYRO_IO_Init(); - - /* Write value to MEMS CTRL_REG1 register */ - ctrl = (uint8_t) InitStruct; - GYRO_IO_Write(&ctrl, L3GD20_CTRL_REG1_ADDR, 1); - - /* Write value to MEMS CTRL_REG4 register */ - ctrl = (uint8_t) (InitStruct >> 8); - GYRO_IO_Write(&ctrl, L3GD20_CTRL_REG4_ADDR, 1); -} - - - -/** - * @brief L3GD20 De-initialization - * @param None - * @retval None - */ -void L3GD20_DeInit(void) -{ -} - -/** - * @brief Read ID address of L3GD20 - * @param None - * @retval ID name - */ -uint8_t L3GD20_ReadID(void) -{ - uint8_t tmp; - - /* Configure the low level interface */ - GYRO_IO_Init(); - - /* Read WHO I AM register */ - GYRO_IO_Read(&tmp, L3GD20_WHO_AM_I_ADDR, 1); - - /* Return the ID */ - return (uint8_t)tmp; -} - -/** - * @brief Reboot memory content of L3GD20 - * @param None - * @retval None - */ -void L3GD20_RebootCmd(void) -{ - uint8_t tmpreg; - - /* Read CTRL_REG5 register */ - GYRO_IO_Read(&tmpreg, L3GD20_CTRL_REG5_ADDR, 1); - - /* Enable or Disable the reboot memory */ - tmpreg |= L3GD20_BOOT_REBOOTMEMORY; - - /* Write value to MEMS CTRL_REG5 register */ - GYRO_IO_Write(&tmpreg, L3GD20_CTRL_REG5_ADDR, 1); -} - -/** - * @brief Set L3GD20 in low-power mode - * @param - * @retval None - */ -void L3GD20_LowPower(uint16_t InitStruct) -{ - uint8_t ctrl = 0x00; - - /* Write value to MEMS CTRL_REG1 register */ - ctrl = (uint8_t) InitStruct; - GYRO_IO_Write(&ctrl, L3GD20_CTRL_REG1_ADDR, 1); -} - -/** - * @brief Set L3GD20 Interrupt INT1 configuration - * @param Int1Config: the configuration setting for the L3GD20 Interrupt. - * @retval None - */ -void L3GD20_INT1InterruptConfig(uint16_t Int1Config) -{ - uint8_t ctrl_cfr = 0x00, ctrl3 = 0x00; - - /* Read INT1_CFG register */ - GYRO_IO_Read(&ctrl_cfr, L3GD20_INT1_CFG_ADDR, 1); - - /* Read CTRL_REG3 register */ - GYRO_IO_Read(&ctrl3, L3GD20_CTRL_REG3_ADDR, 1); - - ctrl_cfr &= 0x80; - ctrl_cfr |= ((uint8_t) Int1Config >> 8); - - ctrl3 &= 0xDF; - ctrl3 |= ((uint8_t) Int1Config); - - /* Write value to MEMS INT1_CFG register */ - GYRO_IO_Write(&ctrl_cfr, L3GD20_INT1_CFG_ADDR, 1); - - /* Write value to MEMS CTRL_REG3 register */ - GYRO_IO_Write(&ctrl3, L3GD20_CTRL_REG3_ADDR, 1); -} - -/** - * @brief Enable INT1 or INT2 interrupt - * @param IntSel: choice of INT1 or INT2 - * This parameter can be: - * @arg L3GD20_INT1 - * @arg L3GD20_INT2 - * @retval None - */ -void L3GD20_EnableIT(uint8_t IntSel) -{ - uint8_t tmpreg; - - /* Read CTRL_REG3 register */ - GYRO_IO_Read(&tmpreg, L3GD20_CTRL_REG3_ADDR, 1); - - if(IntSel == L3GD20_INT1) - { - tmpreg &= 0x7F; - tmpreg |= L3GD20_INT1INTERRUPT_ENABLE; - } - else if(IntSel == L3GD20_INT2) - { - tmpreg &= 0xF7; - tmpreg |= L3GD20_INT2INTERRUPT_ENABLE; - } - - /* Write value to MEMS CTRL_REG3 register */ - GYRO_IO_Write(&tmpreg, L3GD20_CTRL_REG3_ADDR, 1); -} - -/** - * @brief Disable INT1 or INT2 interrupt - * @param IntSel: choice of INT1 or INT2 - * This parameter can be: - * @arg L3GD20_INT1 - * @arg L3GD20_INT2 - * @retval None - */ -void L3GD20_DisableIT(uint8_t IntSel) -{ - uint8_t tmpreg; - - /* Read CTRL_REG3 register */ - GYRO_IO_Read(&tmpreg, L3GD20_CTRL_REG3_ADDR, 1); - - if(IntSel == L3GD20_INT1) - { - tmpreg &= 0x7F; - tmpreg |= L3GD20_INT1INTERRUPT_DISABLE; - } - else if(IntSel == L3GD20_INT2) - { - tmpreg &= 0xF7; - tmpreg |= L3GD20_INT2INTERRUPT_DISABLE; - } - - /* Write value to MEMS CTRL_REG3 register */ - GYRO_IO_Write(&tmpreg, L3GD20_CTRL_REG3_ADDR, 1); -} - -/** - * @brief Set High Pass Filter Modality - * @param FilterStruct: contains the configuration setting for the L3GD20. - * @retval None - */ -void L3GD20_FilterConfig(uint8_t FilterStruct) -{ - uint8_t tmpreg; - - /* Read CTRL_REG2 register */ - GYRO_IO_Read(&tmpreg, L3GD20_CTRL_REG2_ADDR, 1); - - tmpreg &= 0xC0; - - /* Configure MEMS: mode and cutoff frequency */ - tmpreg |= FilterStruct; - - /* Write value to MEMS CTRL_REG2 register */ - GYRO_IO_Write(&tmpreg, L3GD20_CTRL_REG2_ADDR, 1); -} - -/** - * @brief Enable or Disable High Pass Filter - * @param HighPassFilterState: new state of the High Pass Filter feature. - * This parameter can be: - * @arg: L3GD20_HIGHPASSFILTER_DISABLE - * @arg: L3GD20_HIGHPASSFILTER_ENABLE - * @retval None - */ -void L3GD20_FilterCmd(uint8_t HighPassFilterState) -{ - uint8_t tmpreg; - - /* Read CTRL_REG5 register */ - GYRO_IO_Read(&tmpreg, L3GD20_CTRL_REG5_ADDR, 1); - - tmpreg &= 0xEF; - - tmpreg |= HighPassFilterState; - - /* Write value to MEMS CTRL_REG5 register */ - GYRO_IO_Write(&tmpreg, L3GD20_CTRL_REG5_ADDR, 1); -} - -/** - * @brief Get status for L3GD20 data - * @param None - * @retval Data status in a L3GD20 Data - */ -uint8_t L3GD20_GetDataStatus(void) -{ - uint8_t tmpreg; - - /* Read STATUS_REG register */ - GYRO_IO_Read(&tmpreg, L3GD20_STATUS_REG_ADDR, 1); - - return tmpreg; -} - -/** -* @brief Calculate the L3GD20 angular data. -* @param pfData: Data out pointer -* @retval None -*/ -void L3GD20_ReadXYZAngRate(float *pfData) -{ - uint8_t tmpbuffer[6] ={0}; - int16_t RawData[3] = {0}; - uint8_t tmpreg = 0; - float sensitivity = 0; - int i =0; - - GYRO_IO_Read(&tmpreg,L3GD20_CTRL_REG4_ADDR,1); - - GYRO_IO_Read(tmpbuffer,L3GD20_OUT_X_L_ADDR,6); - - /* check in the control register 4 the data alignment (Big Endian or Little Endian)*/ - if(!(tmpreg & L3GD20_BLE_MSB)) - { - for(i=0; i<3; i++) - { - RawData[i]=(int16_t)(((uint16_t)tmpbuffer[2*i+1] << 8) + tmpbuffer[2*i]); - } - } - else - { - for(i=0; i<3; i++) - { - RawData[i]=(int16_t)(((uint16_t)tmpbuffer[2*i] << 8) + tmpbuffer[2*i+1]); - } - } - - /* Switch the sensitivity value set in the CRTL4 */ - switch(tmpreg & L3GD20_FULLSCALE_SELECTION) - { - case L3GD20_FULLSCALE_250: - sensitivity=L3GD20_SENSITIVITY_250DPS; - break; - - case L3GD20_FULLSCALE_500: - sensitivity=L3GD20_SENSITIVITY_500DPS; - break; - - case L3GD20_FULLSCALE_2000: - sensitivity=L3GD20_SENSITIVITY_2000DPS; - break; - } - /* Divide by sensitivity */ - for(i=0; i<3; i++) - { - pfData[i]=(float)(RawData[i] * sensitivity); - } -} - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff -r 53d9067a4feb -r d06d6759139b Drivers/BSP/Components/l3gd20/l3gd20.h --- a/Drivers/BSP/Components/l3gd20/l3gd20.h Wed Feb 28 13:17:14 2018 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,324 +0,0 @@ -/** - ****************************************************************************** - * @file l3gd20.h - * @author MCD Application Team - * @version V2.0.0 - * @date 26-June-2015 - * @brief This file contains all the functions prototypes for the l3gd20.c driver. - ****************************************************************************** - * @attention - * - * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2> - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __L3GD20_H -#define __L3GD20_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "../Common/gyro.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup Components - * @{ - */ - -/** @addtogroup L3GD20 - * @{ - */ - -/** @defgroup L3GD20_Exported_Constants - * @{ - */ - -/******************************************************************************/ -/*************************** START REGISTER MAPPING **************************/ -/******************************************************************************/ -#define L3GD20_WHO_AM_I_ADDR 0x0F /* device identification register */ -#define L3GD20_CTRL_REG1_ADDR 0x20 /* Control register 1 */ -#define L3GD20_CTRL_REG2_ADDR 0x21 /* Control register 2 */ -#define L3GD20_CTRL_REG3_ADDR 0x22 /* Control register 3 */ -#define L3GD20_CTRL_REG4_ADDR 0x23 /* Control register 4 */ -#define L3GD20_CTRL_REG5_ADDR 0x24 /* Control register 5 */ -#define L3GD20_REFERENCE_REG_ADDR 0x25 /* Reference register */ -#define L3GD20_OUT_TEMP_ADDR 0x26 /* Out temp register */ -#define L3GD20_STATUS_REG_ADDR 0x27 /* Status register */ -#define L3GD20_OUT_X_L_ADDR 0x28 /* Output Register X */ -#define L3GD20_OUT_X_H_ADDR 0x29 /* Output Register X */ -#define L3GD20_OUT_Y_L_ADDR 0x2A /* Output Register Y */ -#define L3GD20_OUT_Y_H_ADDR 0x2B /* Output Register Y */ -#define L3GD20_OUT_Z_L_ADDR 0x2C /* Output Register Z */ -#define L3GD20_OUT_Z_H_ADDR 0x2D /* Output Register Z */ -#define L3GD20_FIFO_CTRL_REG_ADDR 0x2E /* Fifo control Register */ -#define L3GD20_FIFO_SRC_REG_ADDR 0x2F /* Fifo src Register */ - -#define L3GD20_INT1_CFG_ADDR 0x30 /* Interrupt 1 configuration Register */ -#define L3GD20_INT1_SRC_ADDR 0x31 /* Interrupt 1 source Register */ -#define L3GD20_INT1_TSH_XH_ADDR 0x32 /* Interrupt 1 Threshold X register */ -#define L3GD20_INT1_TSH_XL_ADDR 0x33 /* Interrupt 1 Threshold X register */ -#define L3GD20_INT1_TSH_YH_ADDR 0x34 /* Interrupt 1 Threshold Y register */ -#define L3GD20_INT1_TSH_YL_ADDR 0x35 /* Interrupt 1 Threshold Y register */ -#define L3GD20_INT1_TSH_ZH_ADDR 0x36 /* Interrupt 1 Threshold Z register */ -#define L3GD20_INT1_TSH_ZL_ADDR 0x37 /* Interrupt 1 Threshold Z register */ -#define L3GD20_INT1_DURATION_ADDR 0x38 /* Interrupt 1 DURATION register */ - -/******************************************************************************/ -/**************************** END REGISTER MAPPING ***************************/ -/******************************************************************************/ - -#define I_AM_L3GD20 ((uint8_t)0xD4) -#define I_AM_L3GD20_TR ((uint8_t)0xD5) - -/** @defgroup Power_Mode_selection - * @{ - */ -#define L3GD20_MODE_POWERDOWN ((uint8_t)0x00) -#define L3GD20_MODE_ACTIVE ((uint8_t)0x08) -/** - * @} - */ - -/** @defgroup OutPut_DataRate_Selection - * @{ - */ -#define L3GD20_OUTPUT_DATARATE_1 ((uint8_t)0x00) -#define L3GD20_OUTPUT_DATARATE_2 ((uint8_t)0x40) -#define L3GD20_OUTPUT_DATARATE_3 ((uint8_t)0x80) -#define L3GD20_OUTPUT_DATARATE_4 ((uint8_t)0xC0) -/** - * @} - */ - -/** @defgroup Axes_Selection - * @{ - */ -#define L3GD20_X_ENABLE ((uint8_t)0x02) -#define L3GD20_Y_ENABLE ((uint8_t)0x01) -#define L3GD20_Z_ENABLE ((uint8_t)0x04) -#define L3GD20_AXES_ENABLE ((uint8_t)0x07) -#define L3GD20_AXES_DISABLE ((uint8_t)0x00) -/** - * @} - */ - -/** @defgroup Bandwidth_Selection - * @{ - */ -#define L3GD20_BANDWIDTH_1 ((uint8_t)0x00) -#define L3GD20_BANDWIDTH_2 ((uint8_t)0x10) -#define L3GD20_BANDWIDTH_3 ((uint8_t)0x20) -#define L3GD20_BANDWIDTH_4 ((uint8_t)0x30) -/** - * @} - */ - -/** @defgroup Full_Scale_Selection - * @{ - */ -#define L3GD20_FULLSCALE_250 ((uint8_t)0x00) -#define L3GD20_FULLSCALE_500 ((uint8_t)0x10) -#define L3GD20_FULLSCALE_2000 ((uint8_t)0x20) -#define L3GD20_FULLSCALE_SELECTION ((uint8_t)0x30) -/** - * @} - */ - -/** @defgroup Full_Scale_Sensitivity - * @{ - */ -#define L3GD20_SENSITIVITY_250DPS ((float)8.75f) /*!< gyroscope sensitivity with 250 dps full scale [DPS/LSB] */ -#define L3GD20_SENSITIVITY_500DPS ((float)17.50f) /*!< gyroscope sensitivity with 500 dps full scale [DPS/LSB] */ -#define L3GD20_SENSITIVITY_2000DPS ((float)70.00f) /*!< gyroscope sensitivity with 2000 dps full scale [DPS/LSB] */ -/** - * @} - */ - - -/** @defgroup Block_Data_Update - * @{ - */ -#define L3GD20_BlockDataUpdate_Continous ((uint8_t)0x00) -#define L3GD20_BlockDataUpdate_Single ((uint8_t)0x80) -/** - * @} - */ - -/** @defgroup Endian_Data_selection - * @{ - */ -#define L3GD20_BLE_LSB ((uint8_t)0x00) -#define L3GD20_BLE_MSB ((uint8_t)0x40) -/** - * @} - */ - -/** @defgroup High_Pass_Filter_status - * @{ - */ -#define L3GD20_HIGHPASSFILTER_DISABLE ((uint8_t)0x00) -#define L3GD20_HIGHPASSFILTER_ENABLE ((uint8_t)0x10) -/** - * @} - */ - -/** @defgroup INT1_INT2_selection - * @{ - */ -#define L3GD20_INT1 ((uint8_t)0x00) -#define L3GD20_INT2 ((uint8_t)0x01) -/** - * @} - */ - -/** @defgroup INT1_Interrupt_status - * @{ - */ -#define L3GD20_INT1INTERRUPT_DISABLE ((uint8_t)0x00) -#define L3GD20_INT1INTERRUPT_ENABLE ((uint8_t)0x80) -/** - * @} - */ - -/** @defgroup INT2_Interrupt_status - * @{ - */ -#define L3GD20_INT2INTERRUPT_DISABLE ((uint8_t)0x00) -#define L3GD20_INT2INTERRUPT_ENABLE ((uint8_t)0x08) -/** - * @} - */ - -/** @defgroup INT1_Interrupt_ActiveEdge - * @{ - */ -#define L3GD20_INT1INTERRUPT_LOW_EDGE ((uint8_t)0x20) -#define L3GD20_INT1INTERRUPT_HIGH_EDGE ((uint8_t)0x00) -/** - * @} - */ - -/** @defgroup Boot_Mode_selection - * @{ - */ -#define L3GD20_BOOT_NORMALMODE ((uint8_t)0x00) -#define L3GD20_BOOT_REBOOTMEMORY ((uint8_t)0x80) -/** - * @} - */ - -/** @defgroup High_Pass_Filter_Mode - * @{ - */ -#define L3GD20_HPM_NORMAL_MODE_RES ((uint8_t)0x00) -#define L3GD20_HPM_REF_SIGNAL ((uint8_t)0x10) -#define L3GD20_HPM_NORMAL_MODE ((uint8_t)0x20) -#define L3GD20_HPM_AUTORESET_INT ((uint8_t)0x30) -/** - * @} - */ - -/** @defgroup High_Pass_CUT OFF_Frequency - * @{ - */ -#define L3GD20_HPFCF_0 0x00 -#define L3GD20_HPFCF_1 0x01 -#define L3GD20_HPFCF_2 0x02 -#define L3GD20_HPFCF_3 0x03 -#define L3GD20_HPFCF_4 0x04 -#define L3GD20_HPFCF_5 0x05 -#define L3GD20_HPFCF_6 0x06 -#define L3GD20_HPFCF_7 0x07 -#define L3GD20_HPFCF_8 0x08 -#define L3GD20_HPFCF_9 0x09 -/** - * @} - */ - -/** - * @} - */ -/** @defgroup L3GD20_Exported_Functions - * @{ - */ -/* Sensor Configuration Functions */ -void L3GD20_Init(uint16_t InitStruct); -void L3GD20_DeInit(void); -void L3GD20_LowPower(uint16_t InitStruct); -uint8_t L3GD20_ReadID(void); -void L3GD20_RebootCmd(void); - -/* Interrupt Configuration Functions */ -void L3GD20_INT1InterruptConfig(uint16_t Int1Config); -void L3GD20_EnableIT(uint8_t IntSel); -void L3GD20_DisableIT(uint8_t IntSel); - -/* High Pass Filter Configuration Functions */ -void L3GD20_FilterConfig(uint8_t FilterStruct); -void L3GD20_FilterCmd(uint8_t HighPassFilterState); -void L3GD20_ReadXYZAngRate(float *pfData); -uint8_t L3GD20_GetDataStatus(void); - -/* Gyroscope IO functions */ -void GYRO_IO_Init(void); -void GYRO_IO_DeInit(void); -void GYRO_IO_Write(uint8_t *pBuffer, uint8_t WriteAddr, uint16_t NumByteToWrite); -void GYRO_IO_Read(uint8_t *pBuffer, uint8_t ReadAddr, uint16_t NumByteToRead); - -/* Gyroscope driver structure */ -extern GYRO_DrvTypeDef L3gd20Drv; - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -#ifdef __cplusplus - } -#endif - -#endif /* __L3GD20_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff -r 53d9067a4feb -r d06d6759139b Drivers/BSP/STM32F429I-Discovery/stm32f429i_discovery_gyroscope.c --- a/Drivers/BSP/STM32F429I-Discovery/stm32f429i_discovery_gyroscope.c Wed Feb 28 13:17:14 2018 +0100 +++ b/Drivers/BSP/STM32F429I-Discovery/stm32f429i_discovery_gyroscope.c Wed Dec 15 15:20:57 2021 +0000 @@ -97,44 +97,44 @@ { uint8_t ret = GYRO_ERROR; uint16_t ctrl = 0x0000; - GYRO_InitTypeDef L3GD20_InitStructure; - GYRO_FilterConfigTypeDef L3GD20_FilterStructure={0,0}; + GYRO_InitTypeDef I3G4250D_InitStructure; + GYRO_FilterConfigTypeDef I3G4250D_FilterStructure={0,0}; - if((L3gd20Drv.ReadID() == I_AM_L3GD20) || (L3gd20Drv.ReadID() == I_AM_L3GD20_TR)) + if((I3g4250Drv.ReadID() == I_AM_I3G4250D) || (I3g4250Drv.ReadID() == I_AM_I3G4250D)) { /* Initialize the Gyroscope driver structure */ - GyroscopeDrv = &L3gd20Drv; + GyroscopeDrv = &I3g4250Drv; /* MEMS configuration ----------------------------------------------------*/ /* Fill the Gyroscope structure */ - L3GD20_InitStructure.Power_Mode = L3GD20_MODE_ACTIVE; - L3GD20_InitStructure.Output_DataRate = L3GD20_OUTPUT_DATARATE_1; - L3GD20_InitStructure.Axes_Enable = L3GD20_AXES_ENABLE; - L3GD20_InitStructure.Band_Width = L3GD20_BANDWIDTH_4; - L3GD20_InitStructure.BlockData_Update = L3GD20_BlockDataUpdate_Continous; - L3GD20_InitStructure.Endianness = L3GD20_BLE_LSB; - L3GD20_InitStructure.Full_Scale = L3GD20_FULLSCALE_500; + I3G4250D_InitStructure.Power_Mode = I3G4250D_MODE_ACTIVE; + I3G4250D_InitStructure.Output_DataRate = I3G4250D_OUTPUT_DATARATE_1; + I3G4250D_InitStructure.Axes_Enable = I3G4250D_AXES_ENABLE; + I3G4250D_InitStructure.Band_Width = I3G4250D_BANDWIDTH_4; + I3G4250D_InitStructure.BlockData_Update = I3G4250D_BlockDataUpdate_Continous; + I3G4250D_InitStructure.Endianness = I3G4250D_BLE_LSB; + I3G4250D_InitStructure.Full_Scale = I3G4250D_FULLSCALE_500; /* Configure MEMS: data rate, power mode, full scale and axes */ - ctrl = (uint16_t) (L3GD20_InitStructure.Power_Mode | L3GD20_InitStructure.Output_DataRate | \ - L3GD20_InitStructure.Axes_Enable | L3GD20_InitStructure.Band_Width); + ctrl = (uint16_t) (I3G4250D_InitStructure.Power_Mode | I3G4250D_InitStructure.Output_DataRate | \ + I3G4250D_InitStructure.Axes_Enable | I3G4250D_InitStructure.Band_Width); - ctrl |= (uint16_t) ((L3GD20_InitStructure.BlockData_Update | L3GD20_InitStructure.Endianness | \ - L3GD20_InitStructure.Full_Scale) << 8); + ctrl |= (uint16_t) ((I3G4250D_InitStructure.BlockData_Update | I3G4250D_InitStructure.Endianness | \ + I3G4250D_InitStructure.Full_Scale) << 8); /* Configure the Gyroscope main parameters */ GyroscopeDrv->Init(ctrl); - L3GD20_FilterStructure.HighPassFilter_Mode_Selection = L3GD20_HPM_NORMAL_MODE_RES; - L3GD20_FilterStructure.HighPassFilter_CutOff_Frequency = L3GD20_HPFCF_0; + I3G4250D_FilterStructure.HighPassFilter_Mode_Selection = I3G4250D_HPM_NORMAL_MODE_RES; + I3G4250D_FilterStructure.HighPassFilter_CutOff_Frequency = I3G4250D_HPFCF_0; - ctrl = (uint8_t) ((L3GD20_FilterStructure.HighPassFilter_Mode_Selection |\ - L3GD20_FilterStructure.HighPassFilter_CutOff_Frequency)); + ctrl = (uint8_t) ((I3G4250D_FilterStructure.HighPassFilter_Mode_Selection |\ + I3G4250D_FilterStructure.HighPassFilter_CutOff_Frequency)); /* Configure the Gyroscope main parameters */ GyroscopeDrv->FilterConfig(ctrl) ; - GyroscopeDrv->FilterCmd(L3GD20_HIGHPASSFILTER_ENABLE); + GyroscopeDrv->FilterCmd(I3G4250D_HIGHPASSFILTER_ENABLE); ret = GYRO_OK; } @@ -173,8 +173,8 @@ /** * @brief Configures INT1 interrupt. - * @param pIntConfig: pointer to a L3GD20_InterruptConfig_TypeDef - * structure that contains the configuration setting for the L3GD20 Interrupt. + * @param pIntConfig: pointer to a I3G4250D_InterruptConfig_TypeDef + * structure that contains the configuration setting for the I3G4250D Interrupt. */ void BSP_GYRO_ITConfig(GYRO_InterruptConfigTypeDef *pIntConfig) { @@ -196,8 +196,8 @@ * @brief Enables INT1 or INT2 interrupt. * @param IntPin: Interrupt pin * This parameter can be: - * @arg L3GD20_INT1 - * @arg L3GD20_INT2 + * @arg I3G4250D_INT1 + * @arg I3G4250D_INT2 */ void BSP_GYRO_EnableIT(uint8_t IntPin) { @@ -211,8 +211,8 @@ * @brief Disables INT1 or INT2 interrupt. * @param IntPin: Interrupt pin * This parameter can be: - * @arg L3GD20_INT1 - * @arg L3GD20_INT2 + * @arg I3G4250D_INT1 + * @arg I3G4250D_INT2 */ void BSP_GYRO_DisableIT(uint8_t IntPin) {
diff -r 53d9067a4feb -r d06d6759139b Drivers/BSP/STM32F429I-Discovery/stm32f429i_discovery_gyroscope.h --- a/Drivers/BSP/STM32F429I-Discovery/stm32f429i_discovery_gyroscope.h Wed Feb 28 13:17:14 2018 +0100 +++ b/Drivers/BSP/STM32F429I-Discovery/stm32f429i_discovery_gyroscope.h Wed Dec 15 15:20:57 2021 +0000 @@ -45,7 +45,7 @@ /* Includes ------------------------------------------------------------------*/ #include "stm32f429i_discovery.h" /* Include Gyroscope component driver */ -#include "../Components/l3gd20/l3gd20.h" +#include "../Components/i3g4250d/i3g4250d.h" /** @addtogroup BSP * @{