Additional font macro

Dependents:   EspSerial

Committer:
SomeRandomBloke
Date:
Fri Feb 05 09:20:30 2016 +0000
Revision:
1:a6fd0931a9e9
Parent:
0:e1d164542663
Added additional font macro

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bcostm 0:e1d164542663 1 /**
bcostm 0:e1d164542663 2 ******************************************************************************
bcostm 0:e1d164542663 3 * @file stm32f429i_discovery_gyroscope.c
bcostm 0:e1d164542663 4 * @author MCD Application Team
bcostm 0:e1d164542663 5 * @version V2.1.2
bcostm 0:e1d164542663 6 * @date 02-March-2015
bcostm 0:e1d164542663 7 * @brief This file provides a set of functions needed to manage the
bcostm 0:e1d164542663 8 * MEMS gyroscope available on STM32F429I-Discovery Kit.
bcostm 0:e1d164542663 9 ******************************************************************************
bcostm 0:e1d164542663 10 * @attention
bcostm 0:e1d164542663 11 *
bcostm 0:e1d164542663 12 * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
bcostm 0:e1d164542663 13 *
bcostm 0:e1d164542663 14 * Redistribution and use in source and binary forms, with or without modification,
bcostm 0:e1d164542663 15 * are permitted provided that the following conditions are met:
bcostm 0:e1d164542663 16 * 1. Redistributions of source code must retain the above copyright notice,
bcostm 0:e1d164542663 17 * this list of conditions and the following disclaimer.
bcostm 0:e1d164542663 18 * 2. Redistributions in binary form must reproduce the above copyright notice,
bcostm 0:e1d164542663 19 * this list of conditions and the following disclaimer in the documentation
bcostm 0:e1d164542663 20 * and/or other materials provided with the distribution.
bcostm 0:e1d164542663 21 * 3. Neither the name of STMicroelectronics nor the names of its contributors
bcostm 0:e1d164542663 22 * may be used to endorse or promote products derived from this software
bcostm 0:e1d164542663 23 * without specific prior written permission.
bcostm 0:e1d164542663 24 *
bcostm 0:e1d164542663 25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
bcostm 0:e1d164542663 26 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
bcostm 0:e1d164542663 27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
bcostm 0:e1d164542663 28 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
bcostm 0:e1d164542663 29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
bcostm 0:e1d164542663 30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
bcostm 0:e1d164542663 31 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
bcostm 0:e1d164542663 32 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
bcostm 0:e1d164542663 33 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
bcostm 0:e1d164542663 34 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
bcostm 0:e1d164542663 35 *
bcostm 0:e1d164542663 36 ******************************************************************************
bcostm 0:e1d164542663 37 */
bcostm 0:e1d164542663 38 /* Includes ------------------------------------------------------------------*/
bcostm 0:e1d164542663 39 #include "stm32f429i_discovery_gyroscope.h"
bcostm 0:e1d164542663 40
bcostm 0:e1d164542663 41 /** @addtogroup BSP
bcostm 0:e1d164542663 42 * @{
bcostm 0:e1d164542663 43 */
bcostm 0:e1d164542663 44
bcostm 0:e1d164542663 45 /** @addtogroup STM32F429I_DISCOVERY
bcostm 0:e1d164542663 46 * @{
bcostm 0:e1d164542663 47 */
bcostm 0:e1d164542663 48
bcostm 0:e1d164542663 49 /** @defgroup STM32F429I_DISCOVERY_GYROSCOPE
bcostm 0:e1d164542663 50 * @{
bcostm 0:e1d164542663 51 */
bcostm 0:e1d164542663 52
bcostm 0:e1d164542663 53 /** @defgroup STM32F429I_DISCOVERY_GYROSCOPE_Private_TypesDefinitions
bcostm 0:e1d164542663 54 * @{
bcostm 0:e1d164542663 55 */
bcostm 0:e1d164542663 56 /**
bcostm 0:e1d164542663 57 * @}
bcostm 0:e1d164542663 58 */
bcostm 0:e1d164542663 59
bcostm 0:e1d164542663 60 /** @defgroup STM32F429I_DISCOVERY_GYROSCOPE_Private_Defines
bcostm 0:e1d164542663 61 * @{
bcostm 0:e1d164542663 62 */
bcostm 0:e1d164542663 63 /**
bcostm 0:e1d164542663 64 * @}
bcostm 0:e1d164542663 65 */
bcostm 0:e1d164542663 66
bcostm 0:e1d164542663 67 /** @defgroup STM32F429I_DISCOVERY_GYROSCOPE_Private_Macros
bcostm 0:e1d164542663 68 * @{
bcostm 0:e1d164542663 69 */
bcostm 0:e1d164542663 70 /**
bcostm 0:e1d164542663 71 * @}
bcostm 0:e1d164542663 72 */
bcostm 0:e1d164542663 73
bcostm 0:e1d164542663 74 /** @defgroup STM32F429I_DISCOVERY_GYROSCOPE_Private_Variables
bcostm 0:e1d164542663 75 * @{
bcostm 0:e1d164542663 76 */
bcostm 0:e1d164542663 77 static GYRO_DrvTypeDef *GyroscopeDrv;
bcostm 0:e1d164542663 78
bcostm 0:e1d164542663 79 /**
bcostm 0:e1d164542663 80 * @}
bcostm 0:e1d164542663 81 */
bcostm 0:e1d164542663 82
bcostm 0:e1d164542663 83 /** @defgroup STM32F429I_DISCOVERY_GYROSCOPE_Private_FunctionPrototypes
bcostm 0:e1d164542663 84 * @{
bcostm 0:e1d164542663 85 */
bcostm 0:e1d164542663 86 /**
bcostm 0:e1d164542663 87 * @}
bcostm 0:e1d164542663 88 */
bcostm 0:e1d164542663 89
bcostm 0:e1d164542663 90 /** @defgroup STM32F429I_DISCOVERY_GYROSCOPE_Private_Functions
bcostm 0:e1d164542663 91 * @{
bcostm 0:e1d164542663 92 */
bcostm 0:e1d164542663 93
bcostm 0:e1d164542663 94 /**
bcostm 0:e1d164542663 95 * @brief Set Gyroscope Initialization.
bcostm 0:e1d164542663 96 * @param None
bcostm 0:e1d164542663 97 * @retval GYRO_OK if no problem during initialization
bcostm 0:e1d164542663 98 */
bcostm 0:e1d164542663 99 uint8_t BSP_GYRO_Init(void)
bcostm 0:e1d164542663 100 {
bcostm 0:e1d164542663 101 uint8_t ret = GYRO_ERROR;
bcostm 0:e1d164542663 102 uint16_t ctrl = 0x0000;
bcostm 0:e1d164542663 103 GYRO_InitTypeDef L3GD20_InitStructure;
bcostm 0:e1d164542663 104 GYRO_FilterConfigTypeDef L3GD20_FilterStructure={0,0};
bcostm 0:e1d164542663 105
bcostm 0:e1d164542663 106 if((L3gd20Drv.ReadID() == I_AM_L3GD20) || (L3gd20Drv.ReadID() == I_AM_L3GD20_TR))
bcostm 0:e1d164542663 107 {
bcostm 0:e1d164542663 108 /* Initialize the Gyroscope driver structure */
bcostm 0:e1d164542663 109 GyroscopeDrv = &L3gd20Drv;
bcostm 0:e1d164542663 110
bcostm 0:e1d164542663 111 /* MEMS configuration ----------------------------------------------------*/
bcostm 0:e1d164542663 112 /* Fill the Gyroscope structure */
bcostm 0:e1d164542663 113 L3GD20_InitStructure.Power_Mode = L3GD20_MODE_ACTIVE;
bcostm 0:e1d164542663 114 L3GD20_InitStructure.Output_DataRate = L3GD20_OUTPUT_DATARATE_1;
bcostm 0:e1d164542663 115 L3GD20_InitStructure.Axes_Enable = L3GD20_AXES_ENABLE;
bcostm 0:e1d164542663 116 L3GD20_InitStructure.Band_Width = L3GD20_BANDWIDTH_4;
bcostm 0:e1d164542663 117 L3GD20_InitStructure.BlockData_Update = L3GD20_BlockDataUpdate_Continous;
bcostm 0:e1d164542663 118 L3GD20_InitStructure.Endianness = L3GD20_BLE_LSB;
bcostm 0:e1d164542663 119 L3GD20_InitStructure.Full_Scale = L3GD20_FULLSCALE_500;
bcostm 0:e1d164542663 120
bcostm 0:e1d164542663 121 /* Configure MEMS: data rate, power mode, full scale and axes */
bcostm 0:e1d164542663 122 ctrl = (uint16_t) (L3GD20_InitStructure.Power_Mode | L3GD20_InitStructure.Output_DataRate | \
bcostm 0:e1d164542663 123 L3GD20_InitStructure.Axes_Enable | L3GD20_InitStructure.Band_Width);
bcostm 0:e1d164542663 124
bcostm 0:e1d164542663 125 ctrl |= (uint16_t) ((L3GD20_InitStructure.BlockData_Update | L3GD20_InitStructure.Endianness | \
bcostm 0:e1d164542663 126 L3GD20_InitStructure.Full_Scale) << 8);
bcostm 0:e1d164542663 127
bcostm 0:e1d164542663 128 /* Configure the Gyroscope main parameters */
bcostm 0:e1d164542663 129 GyroscopeDrv->Init(ctrl);
bcostm 0:e1d164542663 130
bcostm 0:e1d164542663 131 L3GD20_FilterStructure.HighPassFilter_Mode_Selection = L3GD20_HPM_NORMAL_MODE_RES;
bcostm 0:e1d164542663 132 L3GD20_FilterStructure.HighPassFilter_CutOff_Frequency = L3GD20_HPFCF_0;
bcostm 0:e1d164542663 133
bcostm 0:e1d164542663 134 ctrl = (uint8_t) ((L3GD20_FilterStructure.HighPassFilter_Mode_Selection |\
bcostm 0:e1d164542663 135 L3GD20_FilterStructure.HighPassFilter_CutOff_Frequency));
bcostm 0:e1d164542663 136
bcostm 0:e1d164542663 137 /* Configure the Gyroscope main parameters */
bcostm 0:e1d164542663 138 GyroscopeDrv->FilterConfig(ctrl) ;
bcostm 0:e1d164542663 139
bcostm 0:e1d164542663 140 GyroscopeDrv->FilterCmd(L3GD20_HIGHPASSFILTER_ENABLE);
bcostm 0:e1d164542663 141
bcostm 0:e1d164542663 142 ret = GYRO_OK;
bcostm 0:e1d164542663 143 }
bcostm 0:e1d164542663 144 else
bcostm 0:e1d164542663 145 {
bcostm 0:e1d164542663 146 ret = GYRO_ERROR;
bcostm 0:e1d164542663 147 }
bcostm 0:e1d164542663 148 return ret;
bcostm 0:e1d164542663 149 }
bcostm 0:e1d164542663 150
bcostm 0:e1d164542663 151 /**
bcostm 0:e1d164542663 152 * @brief Read ID of Gyroscope component.
bcostm 0:e1d164542663 153 * @param None
bcostm 0:e1d164542663 154 * @retval ID
bcostm 0:e1d164542663 155 */
bcostm 0:e1d164542663 156 uint8_t BSP_GYRO_ReadID(void)
bcostm 0:e1d164542663 157 {
bcostm 0:e1d164542663 158 uint8_t id = 0x00;
bcostm 0:e1d164542663 159
bcostm 0:e1d164542663 160 if(GyroscopeDrv->ReadID != NULL)
bcostm 0:e1d164542663 161 {
bcostm 0:e1d164542663 162 id = GyroscopeDrv->ReadID();
bcostm 0:e1d164542663 163 }
bcostm 0:e1d164542663 164 return id;
bcostm 0:e1d164542663 165 }
bcostm 0:e1d164542663 166
bcostm 0:e1d164542663 167 /**
bcostm 0:e1d164542663 168 * @brief Reboot memory content of Gyroscope.
bcostm 0:e1d164542663 169 * @param None
bcostm 0:e1d164542663 170 * @retval None
bcostm 0:e1d164542663 171 */
bcostm 0:e1d164542663 172 void BSP_GYRO_Reset(void)
bcostm 0:e1d164542663 173 {
bcostm 0:e1d164542663 174 if(GyroscopeDrv->Reset != NULL)
bcostm 0:e1d164542663 175 {
bcostm 0:e1d164542663 176 GyroscopeDrv->Reset();
bcostm 0:e1d164542663 177 }
bcostm 0:e1d164542663 178 }
bcostm 0:e1d164542663 179
bcostm 0:e1d164542663 180 /**
bcostm 0:e1d164542663 181 * @brief Configures INT1 interrupt.
bcostm 0:e1d164542663 182 * @param pIntConfig: pointer to a L3GD20_InterruptConfig_TypeDef
bcostm 0:e1d164542663 183 * structure that contains the configuration setting for the L3GD20 Interrupt.
bcostm 0:e1d164542663 184 * @retval None
bcostm 0:e1d164542663 185 */
bcostm 0:e1d164542663 186 void BSP_GYRO_ITConfig(GYRO_InterruptConfigTypeDef *pIntConfig)
bcostm 0:e1d164542663 187 {
bcostm 0:e1d164542663 188 uint16_t interruptconfig = 0x0000;
bcostm 0:e1d164542663 189
bcostm 0:e1d164542663 190 if(GyroscopeDrv->ConfigIT != NULL)
bcostm 0:e1d164542663 191 {
bcostm 0:e1d164542663 192 /* Configure latch Interrupt request and axe interrupts */
bcostm 0:e1d164542663 193 interruptconfig |= ((uint8_t)(pIntConfig->Latch_Request| \
bcostm 0:e1d164542663 194 pIntConfig->Interrupt_Axes) << 8);
bcostm 0:e1d164542663 195
bcostm 0:e1d164542663 196 interruptconfig |= (uint8_t)(pIntConfig->Interrupt_ActiveEdge);
bcostm 0:e1d164542663 197
bcostm 0:e1d164542663 198 GyroscopeDrv->ConfigIT(interruptconfig);
bcostm 0:e1d164542663 199 }
bcostm 0:e1d164542663 200 }
bcostm 0:e1d164542663 201
bcostm 0:e1d164542663 202 /**
bcostm 0:e1d164542663 203 * @brief Enables INT1 or INT2 interrupt.
bcostm 0:e1d164542663 204 * @param IntPin: Interrupt pin
bcostm 0:e1d164542663 205 * This parameter can be:
bcostm 0:e1d164542663 206 * @arg L3GD20_INT1
bcostm 0:e1d164542663 207 * @arg L3GD20_INT2
bcostm 0:e1d164542663 208 * @retval None
bcostm 0:e1d164542663 209 */
bcostm 0:e1d164542663 210 void BSP_GYRO_EnableIT(uint8_t IntPin)
bcostm 0:e1d164542663 211 {
bcostm 0:e1d164542663 212 if(GyroscopeDrv->EnableIT != NULL)
bcostm 0:e1d164542663 213 {
bcostm 0:e1d164542663 214 GyroscopeDrv->EnableIT(IntPin);
bcostm 0:e1d164542663 215 }
bcostm 0:e1d164542663 216 }
bcostm 0:e1d164542663 217
bcostm 0:e1d164542663 218 /**
bcostm 0:e1d164542663 219 * @brief Disables INT1 or INT2 interrupt.
bcostm 0:e1d164542663 220 * @param IntPin: Interrupt pin
bcostm 0:e1d164542663 221 * This parameter can be:
bcostm 0:e1d164542663 222 * @arg L3GD20_INT1
bcostm 0:e1d164542663 223 * @arg L3GD20_INT2
bcostm 0:e1d164542663 224 * @retval None
bcostm 0:e1d164542663 225 */
bcostm 0:e1d164542663 226 void BSP_GYRO_DisableIT(uint8_t IntPin)
bcostm 0:e1d164542663 227 {
bcostm 0:e1d164542663 228 if(GyroscopeDrv->DisableIT != NULL)
bcostm 0:e1d164542663 229 {
bcostm 0:e1d164542663 230 GyroscopeDrv->DisableIT(IntPin);
bcostm 0:e1d164542663 231 }
bcostm 0:e1d164542663 232 }
bcostm 0:e1d164542663 233
bcostm 0:e1d164542663 234 /**
bcostm 0:e1d164542663 235 * @brief Gets XYZ angular acceleration/
bcostm 0:e1d164542663 236 * @param pfData: pointer on floating array
bcostm 0:e1d164542663 237 * @retval None
bcostm 0:e1d164542663 238 */
bcostm 0:e1d164542663 239 void BSP_GYRO_GetXYZ(float *pfData)
bcostm 0:e1d164542663 240 {
bcostm 0:e1d164542663 241 if(GyroscopeDrv->GetXYZ!= NULL)
bcostm 0:e1d164542663 242 {
bcostm 0:e1d164542663 243 GyroscopeDrv->GetXYZ(pfData);
bcostm 0:e1d164542663 244 }
bcostm 0:e1d164542663 245 }
bcostm 0:e1d164542663 246
bcostm 0:e1d164542663 247 /**
bcostm 0:e1d164542663 248 * @}
bcostm 0:e1d164542663 249 */
bcostm 0:e1d164542663 250
bcostm 0:e1d164542663 251 /**
bcostm 0:e1d164542663 252 * @}
bcostm 0:e1d164542663 253 */
bcostm 0:e1d164542663 254
bcostm 0:e1d164542663 255 /**
bcostm 0:e1d164542663 256 * @}
bcostm 0:e1d164542663 257 */
bcostm 0:e1d164542663 258
bcostm 0:e1d164542663 259 /**
bcostm 0:e1d164542663 260 * @}
bcostm 0:e1d164542663 261 */
bcostm 0:e1d164542663 262
bcostm 0:e1d164542663 263 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/