summaryrefslogtreecommitdiff
path: root/gyroscope.hpp
blob: 627aa8c644c705924ff7564f798620e0c5150e20 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#ifndef GYROSCOPE_H
#define GYROSCOPE_H

namespace Addresses
{
	const int ID_HIGH = 0b1101011;
	const int ID_LOW = 0b1101010;
	const int WHO_ID = 0xD7;
}

namespace RegisterAddresses
{
	const int WHO_AM_I = 0x0F;
	const int LOW_ODR = 0x39;
	const int CTRL4 = 0x23;
	const int CTRL1 = 0x20;
	const int OUT_X_L = 0x28;
}

class ReadGyroscopeData
{
public:
	int16_t x, y, z;
};

class Gyroscope
{
public:
	int gyroscope_id;
	Gyroscope(int gyroscope_id);
	ReadGyroscopeData read();
	void writeRegistry(uint8_t registry, uint8_t value);
	static int initialize();
	static int testRegistry(int gyroscope_id, uint8_t registry);
};

#endif