HRI board firmware v2.1 Microcontroller firmware of the board used during the HRI labs.

mpu_6050.h
Go to the documentation of this file.
1 /*
2 * Copyright (C) 2017 EPFL-LSRO (Laboratoire de Systemes Robotiques).
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #ifndef __MPU_6050_H
18 #define __MPU_6050_H
19
20 #include "../main.h"
21
40 typedef enum
41 {
42 MPU_ACCEL_RANGE_2G = 0,
43 MPU_ACCEL_RANGE_4G = 1,
44 MPU_ACCEL_RANGE_8G = 2,
45 MPU_ACCEL_RANGE_16G = 3
46 } mpu_AccelRange;
47
51 typedef enum
52 {
53 MPU_GYRO_RANGE_250DPS = 0,
54 MPU_GYRO_RANGE_500DPS = 1,
55 MPU_GYRO_RANGE_1000DPS = 2,
56 MPU_GYRO_RANGE_2000DPS = 3
57 } mpu_GyroRange;
58
62 typedef enum
63 {
64 MPU_DLPF_BW_256HZ = 0,
65 MPU_DLPF_BW_188HZ = 1,
66 MPU_DLPF_BW_98HZ = 2,
67 MPU_DLPF_BW_42HZ = 3,
68 MPU_DLPF_BW_20HZ = 4,
69 MPU_DLPF_BW_10HZ = 5,
70 MPU_DLPF_BW_5HZ = 6
71 } mpu_Bandwidth;
72
76 typedef enum
77 {
78 MPU_AXIS_ACCEL_X = 0x3b,
79 MPU_AXIS_ACCEL_Y = 0x3d,
80 MPU_AXIS_ACCEL_Z = 0x3f,
81 MPU_AXIS_TEMPERATURE = 0x41,
82 MPU_AXIS_GYRO_X = 0x43,
83 MPU_AXIS_GYRO_Y = 0x45,
84 MPU_AXIS_GYRO_Z = 0x47
85 } mpu_Axis;
86
87 bool mpu_Init(mpu_AccelRange accelRange, mpu_GyroRange gyroRange,
88 mpu_Bandwidth bandwidth);
89 void mpu_GetAxis(mpu_Axis axis, float32_t *value);
90 void mpu_GetAcceleration(float32_t *ax, float32_t *ay, float32_t *az);
91 void mpu_GetAngularSpeed(float32_t *gx, float32_t *gy, float32_t *gz);
92 float mpu_GetTemperature(void);
93
98 #endif
MPU_AXIS_GYRO_Z
Definition: mpu_6050.h:84
mpu_Init
bool mpu_Init(mpu_AccelRange accelRange, mpu_GyroRange gyroRange, mpu_Bandwidth bandwidth)
Initializes the MPU-6050 device.
Definition: mpu_6050.c:73
MPU_ACCEL_RANGE_16G
+-16 G (+-156.96 m/s^2).
Definition: mpu_6050.h:45
MPU_DLPF_BW_42HZ
Cut-off freq: 42 Hz. IMU sampling freq: 1kHz.
Definition: mpu_6050.h:67
MPU_ACCEL_RANGE_2G
+-2 G (+-19.62 m/s^2).
Definition: mpu_6050.h:42
MPU_DLPF_BW_188HZ
Cut-off freq: 188 Hz. IMU sampling freq: 1kHz.
Definition: mpu_6050.h:65
MPU_AXIS_TEMPERATURE
Definition: mpu_6050.h:81
MPU_DLPF_BW_98HZ
Cut-off freq: 98 Hz. IMU sampling freq: 1kHz.
Definition: mpu_6050.h:66
MPU_DLPF_BW_256HZ
Cut-off freq: 256 Hz. IMU sampling freq: 8kHz.
Definition: mpu_6050.h:64
MPU_AXIS_ACCEL_Y
Definition: mpu_6050.h:79
MPU_AXIS_ACCEL_Z
Definition: mpu_6050.h:80
mpu_GetAcceleration
void mpu_GetAcceleration(float32_t *ax, float32_t *ay, float32_t *az)
Acquires the acceleration from the IMU.
Definition: mpu_6050.c:208
MPU_GYRO_RANGE_1000DPS
+- 1000 deg/s.
Definition: mpu_6050.h:55
MPU_DLPF_BW_10HZ
Cut-off freq: 10 Hz. IMU sampling freq: 1kHz.
Definition: mpu_6050.h:69
MPU_GYRO_RANGE_500DPS
+- 500 deg/s.
Definition: mpu_6050.h:54
MPU_AXIS_GYRO_Y
Definition: mpu_6050.h:83
mpu_Axis
mpu_Axis
Enumeration of all the measurement registers.
Definition: mpu_6050.h:76
mpu_GetAngularSpeed
void mpu_GetAngularSpeed(float32_t *gx, float32_t *gy, float32_t *gz)
Acquires the angular speed from the IMU.
Definition: mpu_6050.c:240
mpu_GetAxis
void mpu_GetAxis(mpu_Axis axis, float32_t *value)
Acquires the value of a single axis, from the IMU.
Definition: mpu_6050.c:159
MPU_DLPF_BW_20HZ
Cut-off freq: 20 Hz. IMU sampling freq: 1kHz.
Definition: mpu_6050.h:68
MPU_GYRO_RANGE_2000DPS
+- 2000 deg/s.
Definition: mpu_6050.h:56
MPU_ACCEL_RANGE_8G
+-8 G (+-78.48 m/s^2).
Definition: mpu_6050.h:44
mpu_Bandwidth
mpu_Bandwidth
Enumeration of the possible bandwidths.
Definition: mpu_6050.h:62
mpu_GetTemperature
float mpu_GetTemperature(void)
Acquires the temperature from the IMU.
Definition: mpu_6050.c:265
MPU_GYRO_RANGE_250DPS
+- 250 deg/s.
Definition: mpu_6050.h:53
mpu_AccelRange
mpu_AccelRange
Enumeration of the possible accelerometer ranges.
Definition: mpu_6050.h:40
MPU_DLPF_BW_5HZ
Cut-off freq: 5 Hz. IMU sampling freq: 1kHz.
Definition: mpu_6050.h:70
MPU_AXIS_ACCEL_X
Definition: mpu_6050.h:78
MPU_AXIS_GYRO_X
Definition: mpu_6050.h:82
mpu_GyroRange
mpu_GyroRange
Enumeration of the possible gyrometer ranges.
Definition: mpu_6050.h:51
MPU_ACCEL_RANGE_4G
+-4 G (+-39.24 m/s^2).
Definition: mpu_6050.h:43