Advertisement
nilold

main.c

Dec 28th, 2015
319
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.23 KB | None | 0 0
  1. /**
  2.  *  Keil project example for 2 MPU6050 6-axes sensors
  3.  *
  4.  *  Before you start, select your target, on the right of the "Load" button
  5.  *
  6.  *  @author     Tilen Majerle
  7.  *  @email      tilen@majerle.eu
  8.  *  @website    http://stm32f4-discovery.com
  9.  *  @ide        Keil uVision 5
  10.  *  @packs      STM32F4xx Keil packs version 2.2.0 or greater required
  11.  *  @stdperiph  STM32F4xx Standard peripheral drivers version 1.4.0 or greater required
  12.  */
  13. /* Include core modules */
  14. #include "stm32f4xx.h"
  15. #include "tm_stm32f4_mpu6050.h"
  16. #include "stm32f4xx_rcc.h"
  17. #include "stm32f4xx_gpio.h"
  18.  
  19. int main(void) {
  20.  
  21.     GPIO_InitTypeDef GPIO_InitDef;
  22.     RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE);
  23.     GPIO_InitDef.GPIO_Pin = GPIO_Pin_13;
  24.     GPIO_InitDef.GPIO_Mode = GPIO_Mode_OUT;
  25.     GPIO_InitDef.GPIO_OType = GPIO_OType_PP;
  26.     GPIO_InitDef.GPIO_PuPd = GPIO_PuPd_NOPULL;
  27.     GPIO_InitDef.GPIO_Speed = GPIO_Speed_100MHz;
  28.     //Initialize pins
  29.     GPIO_Init(GPIOD, &GPIO_InitDef);
  30.     //General configs
  31.     SystemInit();
  32.  
  33.     //MPU6050 configs and start
  34.     TM_MPU6050_t MPU6050_Data0;
  35.     TM_MPU6050_Init(&MPU6050_Data0, TM_MPU6050_Device_0, TM_MPU6050_Accelerometer_2G, TM_MPU6050_Gyroscope_250s);
  36.  
  37.     while (1){
  38.         GPIO_ToggleBits(GPIOD, GPIO_Pin_13);
  39.         TM_MPU6050_ReadAll(&MPU6050_Data0);
  40.     }
  41.  
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement