ST / GYRO_DISCO_L476VG

Dependents:   DISCO_L476VG_Gyro DISCO_L476VG_AccGy1 DISCO_AcGy1_OK DISCO_L476VG_AccGy2 ... more

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers GYRO_DISCO_L476VG.h Source File

GYRO_DISCO_L476VG.h

00001 /* Copyright (c) 2010-2011 mbed.org, MIT License
00002 *
00003 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
00004 * and associated documentation files (the "Software"), to deal in the Software without
00005 * restriction, including without limitation the rights to use, copy, modify, merge, publish,
00006 * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
00007 * Software is furnished to do so, subject to the following conditions:
00008 *
00009 * The above copyright notice and this permission notice shall be included in all copies or
00010 * substantial portions of the Software.
00011 *
00012 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
00013 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00014 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
00015 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00016 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00017 */
00018 
00019 #ifndef __GYRO_DISCO_L476VG_H
00020 #define __GYRO_DISCO_L476VG_H
00021 
00022 #ifdef TARGET_DISCO_L476VG
00023 
00024 #include "mbed.h"
00025 #include "stm32l476g_discovery_gyroscope.h"
00026 
00027 /*
00028   Class to drive the Gyroscope (L3GD20 device)
00029   present on DISCO_L476VG board.
00030 
00031   Usage:
00032  
00033   #include "mbed.h"
00034   #include "GYRO_DISCO_L476VG.h"
00035  
00036   GYRO_DISCO_L476VG gyro;
00037  
00038   int main()
00039   {
00040     float GyroBuffer[3];
00041     while(1) {
00042         // Read Gyroscope values
00043         gyro.GetXYZ(GyroBuffer);
00044         // Display values      
00045         printf("X = %f\n", GyroBuffer[0]);
00046         printf("Y = %f\n", GyroBuffer[1]);
00047         printf("Z = %f\n", GyroBuffer[2]);
00048         wait(1);
00049     }
00050   }
00051 */
00052 class GYRO_DISCO_L476VG
00053 {
00054   
00055 public:
00056     //! Constructor
00057     GYRO_DISCO_L476VG();
00058 
00059     //! Destructor
00060     ~GYRO_DISCO_L476VG();
00061 
00062 /**
00063   * @brief  Initialize Gyroscope.
00064   * @retval GYRO_OK or GYRO_ERROR
00065   */
00066     uint8_t Init(void);
00067 
00068 /**
00069   * @brief  DeInitialize Gyroscope.
00070   * @retval None
00071   */
00072     void DeInit(void);
00073 
00074 /**
00075   * @brief  Put Gyroscope in low power mode.
00076   * @retval None
00077   */
00078     void LowPower(void);
00079     
00080 /**
00081   * @brief  Reboot memory content of Gyroscope.
00082   * @retval None
00083   */    
00084     void Reset(void);
00085     
00086 /**
00087   * @brief  Read ID of Gyroscope component.
00088   * @retval ID
00089   */    
00090     uint8_t ReadID(void);
00091     
00092 /**
00093   * @brief  Configure Gyroscope interrupts (INT1 or INT2).
00094   * @param  pIntConfig: pointer to a GYRO_InterruptConfigTypeDef 
00095   *         structure that contains the configuration setting for the L3GD20 Interrupt.
00096   * @retval None
00097   */    
00098     void ITConfig(GYRO_InterruptConfigTypeDef *pIntConfigStruct);
00099     
00100 /**
00101   * @brief  Enable Gyroscope interrupts (INT1 or INT2).
00102   * @param  IntPin: Interrupt pin 
00103   *      This parameter can be: 
00104   *        @arg L3GD20_INT1
00105   *        @arg L3GD20_INT2
00106   * @retval None
00107   */    
00108     void EnableIT(uint8_t IntPin);
00109     
00110 /**
00111   * @brief  Disable Gyroscope interrupts (INT1 or INT2).
00112   * @param  IntPin: Interrupt pin 
00113   *      This parameter can be: 
00114   *        @arg L3GD20_INT1
00115   *        @arg L3GD20_INT2
00116   * @retval None
00117   */    
00118     void DisableIT(uint8_t IntPin);
00119     
00120 /**
00121   * @brief  Get XYZ angular acceleration from the Gyroscope.
00122   * @param  pfData: pointer on floating array         
00123   * @retval None
00124   */    
00125     void GetXYZ(float* pfData);
00126 
00127 private:
00128 
00129 };
00130 
00131 #else
00132 #error "This class must be used with DISCO_L476VG board only."
00133 #endif // TARGET_DISCO_L476VG
00134 
00135 #endif