Class to drive the Gyroscope (L3GD20 device) present on DISCO_F429ZI board.

Dependents:   DISCO-F429ZI_LCDTS_and_GYRO_test DISCO-F429ZI_Gyro_demo DISCO-F429ZI_Gyr WIRE-BANDING_FT810 ... more

Committer:
bcostm
Date:
Fri Dec 18 14:39:07 2015 +0000
Revision:
0:dfe10fcd7524
Initial version

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bcostm 0:dfe10fcd7524 1 /* Copyright (c) 2010-2011 mbed.org, MIT License
bcostm 0:dfe10fcd7524 2 *
bcostm 0:dfe10fcd7524 3 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
bcostm 0:dfe10fcd7524 4 * and associated documentation files (the "Software"), to deal in the Software without
bcostm 0:dfe10fcd7524 5 * restriction, including without limitation the rights to use, copy, modify, merge, publish,
bcostm 0:dfe10fcd7524 6 * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
bcostm 0:dfe10fcd7524 7 * Software is furnished to do so, subject to the following conditions:
bcostm 0:dfe10fcd7524 8 *
bcostm 0:dfe10fcd7524 9 * The above copyright notice and this permission notice shall be included in all copies or
bcostm 0:dfe10fcd7524 10 * substantial portions of the Software.
bcostm 0:dfe10fcd7524 11 *
bcostm 0:dfe10fcd7524 12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
bcostm 0:dfe10fcd7524 13 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
bcostm 0:dfe10fcd7524 14 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
bcostm 0:dfe10fcd7524 15 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
bcostm 0:dfe10fcd7524 16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
bcostm 0:dfe10fcd7524 17 */
bcostm 0:dfe10fcd7524 18
bcostm 0:dfe10fcd7524 19 #ifndef __GYRO_DISCO_F429ZI_H
bcostm 0:dfe10fcd7524 20 #define __GYRO_DISCO_F429ZI_H
bcostm 0:dfe10fcd7524 21
bcostm 0:dfe10fcd7524 22 #ifdef TARGET_DISCO_F429ZI
bcostm 0:dfe10fcd7524 23
bcostm 0:dfe10fcd7524 24 #include "mbed.h"
bcostm 0:dfe10fcd7524 25 #include "stm32f429i_discovery_gyroscope.h"
bcostm 0:dfe10fcd7524 26
bcostm 0:dfe10fcd7524 27 /*
bcostm 0:dfe10fcd7524 28 Class to drive the Gyroscope (L3GD20 device) present on DISCO_F429ZI board.
bcostm 0:dfe10fcd7524 29
bcostm 0:dfe10fcd7524 30 Usage:
bcostm 0:dfe10fcd7524 31
bcostm 0:dfe10fcd7524 32 #include "mbed.h"
bcostm 0:dfe10fcd7524 33 #include "GYRO_DISCO_F429ZI.h"
bcostm 0:dfe10fcd7524 34
bcostm 0:dfe10fcd7524 35 GYRO_DISCO_F429ZI gyro;
bcostm 0:dfe10fcd7524 36
bcostm 0:dfe10fcd7524 37 int main()
bcostm 0:dfe10fcd7524 38 {
bcostm 0:dfe10fcd7524 39 float GyroBuffer[3];
bcostm 0:dfe10fcd7524 40 while(1) {
bcostm 0:dfe10fcd7524 41 // Read Gyroscope values
bcostm 0:dfe10fcd7524 42 gyro.GetXYZ(GyroBuffer);
bcostm 0:dfe10fcd7524 43 // Display values
bcostm 0:dfe10fcd7524 44 printf("X = %f\n", GyroBuffer[0]);
bcostm 0:dfe10fcd7524 45 printf("Y = %f\n", GyroBuffer[1]);
bcostm 0:dfe10fcd7524 46 printf("Z = %f\n", GyroBuffer[2]);
bcostm 0:dfe10fcd7524 47 wait(1);
bcostm 0:dfe10fcd7524 48 }
bcostm 0:dfe10fcd7524 49 }
bcostm 0:dfe10fcd7524 50 */
bcostm 0:dfe10fcd7524 51 class GYRO_DISCO_F429ZI
bcostm 0:dfe10fcd7524 52 {
bcostm 0:dfe10fcd7524 53
bcostm 0:dfe10fcd7524 54 public:
bcostm 0:dfe10fcd7524 55 //! Constructor
bcostm 0:dfe10fcd7524 56 GYRO_DISCO_F429ZI();
bcostm 0:dfe10fcd7524 57
bcostm 0:dfe10fcd7524 58 //! Destructor
bcostm 0:dfe10fcd7524 59 ~GYRO_DISCO_F429ZI();
bcostm 0:dfe10fcd7524 60
bcostm 0:dfe10fcd7524 61 /**
bcostm 0:dfe10fcd7524 62 * @brief Set Gyroscope Initialization.
bcostm 0:dfe10fcd7524 63 * @param None
bcostm 0:dfe10fcd7524 64 * @retval GYRO_OK if no problem during initialization
bcostm 0:dfe10fcd7524 65 */
bcostm 0:dfe10fcd7524 66 uint8_t Init(void);
bcostm 0:dfe10fcd7524 67
bcostm 0:dfe10fcd7524 68 /**
bcostm 0:dfe10fcd7524 69 * @brief Read ID of Gyroscope component.
bcostm 0:dfe10fcd7524 70 * @param None
bcostm 0:dfe10fcd7524 71 * @retval ID
bcostm 0:dfe10fcd7524 72 */
bcostm 0:dfe10fcd7524 73 uint8_t ReadID(void);
bcostm 0:dfe10fcd7524 74
bcostm 0:dfe10fcd7524 75 /**
bcostm 0:dfe10fcd7524 76 * @brief Reboot memory content of Gyroscope.
bcostm 0:dfe10fcd7524 77 * @param None
bcostm 0:dfe10fcd7524 78 * @retval None
bcostm 0:dfe10fcd7524 79 */
bcostm 0:dfe10fcd7524 80 void Reset(void);
bcostm 0:dfe10fcd7524 81
bcostm 0:dfe10fcd7524 82 /**
bcostm 0:dfe10fcd7524 83 * @brief Configures INT1 interrupt.
bcostm 0:dfe10fcd7524 84 * @param pIntConfig: pointer to a L3GD20_InterruptConfig_TypeDef
bcostm 0:dfe10fcd7524 85 * structure that contains the configuration setting for the L3GD20 Interrupt.
bcostm 0:dfe10fcd7524 86 * @retval None
bcostm 0:dfe10fcd7524 87 */
bcostm 0:dfe10fcd7524 88 void ITConfig(GYRO_InterruptConfigTypeDef *pIntConfig);
bcostm 0:dfe10fcd7524 89
bcostm 0:dfe10fcd7524 90 /**
bcostm 0:dfe10fcd7524 91 * @brief Enables INT1 or INT2 interrupt.
bcostm 0:dfe10fcd7524 92 * @param IntPin: Interrupt pin
bcostm 0:dfe10fcd7524 93 * This parameter can be:
bcostm 0:dfe10fcd7524 94 * @arg L3GD20_INT1
bcostm 0:dfe10fcd7524 95 * @arg L3GD20_INT2
bcostm 0:dfe10fcd7524 96 * @retval None
bcostm 0:dfe10fcd7524 97 */
bcostm 0:dfe10fcd7524 98 void EnableIT(uint8_t IntPin);
bcostm 0:dfe10fcd7524 99
bcostm 0:dfe10fcd7524 100 /**
bcostm 0:dfe10fcd7524 101 * @brief Disables INT1 or INT2 interrupt.
bcostm 0:dfe10fcd7524 102 * @param IntPin: Interrupt pin
bcostm 0:dfe10fcd7524 103 * This parameter can be:
bcostm 0:dfe10fcd7524 104 * @arg L3GD20_INT1
bcostm 0:dfe10fcd7524 105 * @arg L3GD20_INT2
bcostm 0:dfe10fcd7524 106 * @retval None
bcostm 0:dfe10fcd7524 107 */
bcostm 0:dfe10fcd7524 108 void DisableIT(uint8_t IntPin);
bcostm 0:dfe10fcd7524 109
bcostm 0:dfe10fcd7524 110 /**
bcostm 0:dfe10fcd7524 111 * @brief Gets XYZ angular acceleration/
bcostm 0:dfe10fcd7524 112 * @param pfData: pointer on floating array
bcostm 0:dfe10fcd7524 113 * @retval None
bcostm 0:dfe10fcd7524 114 */
bcostm 0:dfe10fcd7524 115 void GetXYZ(float *pfData);
bcostm 0:dfe10fcd7524 116
bcostm 0:dfe10fcd7524 117 private:
bcostm 0:dfe10fcd7524 118
bcostm 0:dfe10fcd7524 119 };
bcostm 0:dfe10fcd7524 120
bcostm 0:dfe10fcd7524 121 #else
bcostm 0:dfe10fcd7524 122 #error "This class must be used with DISCO_F429ZI board only."
bcostm 0:dfe10fcd7524 123 #endif // TARGET_DISCO_F429ZI
bcostm 0:dfe10fcd7524 124
bcostm 0:dfe10fcd7524 125 #endif