PICSimLab - Programmable IC Simulator Laboratory 0.9.2
PICSimLab - API
Loading...
Searching...
No Matches
sen_mpu6050.h
1/* ########################################################################
2
3 PICSimLab - Programmable IC Simulator Laboratory
4
5 ########################################################################
6
7 Copyright (c) : 2010-2024 Luis Claudio GambĂ´a Lopes <lcgamboa@yahoo.com>
8
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2, or (at your option)
12 any later version.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22
23 For e-mail suggestions : lcgamboa@yahoo.com
24 ######################################################################## */
25
26#include "bitbang_i2c.h"
27
28typedef struct {
29 unsigned char regs[0x76];
30 unsigned char addr;
31 bitbang_i2c_t bb_i2c;
32 unsigned int update;
33} mpu6050_t;
34
35void mpu6050_rst(mpu6050_t* mpu);
36void mpu6050_init(mpu6050_t* mpu);
37void mpu6050_end(mpu6050_t* mpu);
38void mpu6050_set_addr(mpu6050_t* mpu, unsigned char addr);
39
40void mpu6050_set_temp(mpu6050_t* mpu, double temp); // degrees
41void mpu6050_set_accel(mpu6050_t* mpu, double x, double y, double z); // g
42void mpu6050_set_gyro(mpu6050_t* mpu, double x, double y, double z); // degrees/s
43void mpu6050_set_accel_raw(mpu6050_t* mpu, short x, short y, short z); // g
44void mpu6050_set_gyro_raw(mpu6050_t* mpu, short x, short y, short z); // degrees/s
45
46unsigned char mpu6050_io_I2C(mpu6050_t* mpu, unsigned char scl, unsigned char sda);
47
48// REGISTERS ADDRESS
49#define SELF_TEST_X 0x0D
50#define SELF_TEST_Y 0x0E
51#define SELF_TEST_Z 0x0F
52
53#define SELF_TEST_A 0x10
54
55#define SMPLRT_DIV 0x19
56#define CONFIG 0x1A
57#define GYRO_CONFIG 0x1B
58#define ACCEL_CONFIG 0x1C
59
60#define FIFO_EN 0x23
61#define I2C_MST_CTRL 0x24
62//..
63#define I2C_MST_STATUS 0x36
64#define INT_PIN_CONFIG 0x37
65#define INT_ENABLED 0x38
66
67#define INT_STATUS 0x3A
68#define ACCEL_XOUT_H 0x3B
69#define ACCEL_XOUT_L 0x3C
70#define ACCEL_YOUT_H 0x3D
71#define ACCEL_YOUT_L 0x3E
72#define ACCEL_ZOUT_H 0x3F
73#define ACCEL_ZOUT_L 0x40
74#define TEMP_OUT_H 0x41
75#define TEMP_OUT_L 0x42
76#define GYRO_XOUT_H 0x43
77#define GYRO_XOUT_L 0x44
78#define GYRO_YOUT_H 0x45
79#define GYRO_YOUT_L 0x46
80#define GYRO_ZOUT_H 0x47
81#define GYRO_ZOUT_L 0x48
82#define EXT_SENS_DATA_00 0x49
83//...
84#define EXT_SENS_DATA_23 0x60
85
86#define I2C_SLV0_DO 0x63
87#define I2C_SLV0_D1 0x64
88#define I2C_SLV0_D2 0x65
89#define I2C_SLV0_D3 0x66
90#define I2C_MST_DELAY_CTRL 0x67
91#define SIGNAL_PATH_RESET 0x68
92
93#define USER_CTRL 0x6A
94#define PWR_MGMT_1 0x6B
95#define PWR_MGMT_2 0x6C
96
97#define FIFO_COUNT_H 0x72
98#define FIFO_COUNT_L 0x73
99#define FIFO_R_W 0x74
100#define WHO_AM_I 0x75
Definition bitbang_i2c.h:39
Definition sen_mpu6050.h:28