accelgyro.c
Go to the documentation of this file.
1 /*
2  accelgyro.c : report accelerometer and gyroscope values
3 
4  Copyright (C) 2016 James Jackson
5 
6  This file is part of BreezySTM32.
7 
8  BreezySTM32 is free software: you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation, either version 3 of the License, or
11  (at your option) any later version.
12 
13  BreezySTM32 is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with BreezySTM32. If not, see <http://www.gnu.org/licenses/>.
20  */
21 
22 #include <breezystm32.h>
23 
24 #define BOARD_REV 2
25 
26 float accel_scale; // converts to units of m/s^2
27 float gyro_scale; // converts to units of rad/s
28 
29 volatile int16_t accel_data[3];
30 volatile int16_t gyro_data[3];
31 volatile int16_t temp_data;
32 
33 volatile uint8_t accel_status = 0;
34 volatile uint8_t gyro_status = 0;
35 volatile uint8_t temp_status = 0;
36 volatile bool mpu_new_measurement = false;
37 
38 uint32_t start_time = 0;
39 
40 void setup(void)
41 {
42  delay(500);
44 
45  uint16_t acc1G;
46  mpu6050_init(true, &acc1G, &gyro_scale, BOARD_REV);
47  accel_scale = 9.80665f / acc1G;
48 }
49 
50 void loop(void)
51 {
52 // printf("test");
53 // delay(100);
54  if (mpu6050_new_data())
55  {
57  volatile uint64_t time_us;
59  printf("%d\t %d\t %d\t %d\t %d\t %d\t %d\t %d\t \n",
60  (int32_t)(accel_data[0]*accel_scale*1000.0f),
61  (int32_t)(accel_data[1]*accel_scale*1000.0f),
62  (int32_t)(accel_data[2]*accel_scale*1000.0f),
63  (int32_t)(gyro_data[0]*gyro_scale*1000.0f),
64  (int32_t)(gyro_data[1]*gyro_scale*1000.0f),
65  (int32_t)(gyro_data[2]*gyro_scale*1000.0f),
66  (int32_t)temp_data,
67  (int32_t)time_us);
68 // printf("test");
69  delay(50);
70  }
71 }
#define LED0_TOGGLE
Definition: drv_system.h:41
void i2cInit(I2CDevice index)
Definition: drv_i2c.c:420
volatile uint8_t accel_status
Definition: accelgyro.c:33
#define printf
Definition: printf.h:119
float accel_scale
Definition: accelgyro.c:26
void loop(void)
Definition: accelgyro.c:50
void mpu6050_async_read_all(volatile int16_t *accData, volatile int16_t *tempData, volatile int16_t *gyroData, volatile uint64_t *timeData)
Definition: drv_mpu6050.c:316
volatile uint8_t temp_status
Definition: accelgyro.c:35
volatile int16_t temp_data
Definition: accelgyro.c:31
void mpu6050_init(bool enableInterrupt, uint16_t *acc1G, float *gyroScale, int boardVersion)
Definition: drv_mpu6050.c:175
bool mpu6050_new_data()
Definition: drv_mpu6050.c:328
volatile bool mpu_new_measurement
Definition: accelgyro.c:36
volatile int16_t accel_data[3]
Definition: accelgyro.c:29
float gyro_scale
Definition: accelgyro.c:27
#define BOARD_REV
Definition: accelgyro.c:24
volatile uint8_t gyro_status
Definition: accelgyro.c:34
uint32_t start_time
Definition: accelgyro.c:38
void setup(void)
Definition: accelgyro.c:40
volatile int16_t gyro_data[3]
Definition: accelgyro.c:30
void delay(uint32_t ms)
Definition: system.c:98


rosflight_firmware
Author(s): Daniel Koch , James Jackson
autogenerated on Thu Oct 24 2019 03:17:18