summaryrefslogtreecommitdiff
path: root/gyroscope.hpp
blob: b57eafa65cf771d83e0fc9e7537ef39f67ceed88 (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
#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 Gyroscope
{
public:
	void setup(int id);
	void readCoordinates(int16_t *x, int16_t *y, int16_t *z);
	void writeRegistry(int8_t registry, int8_t value);
	static int initialize();
	static int testRegistry(int gyroscope_id, int8_t registry);

private:
	int _gyroscope_id;
	int16_t _read_next_coordinate();
};

#endif