From c4d200330b71276abee2d2c18906991e0f4e5c13 Mon Sep 17 00:00:00 2001 From: HampusM Date: Tue, 23 Nov 2021 09:24:48 +0100 Subject: add core files --- gyroscope.hpp | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 gyroscope.hpp (limited to 'gyroscope.hpp') diff --git a/gyroscope.hpp b/gyroscope.hpp new file mode 100644 index 0000000..627aa8c --- /dev/null +++ b/gyroscope.hpp @@ -0,0 +1,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 \ No newline at end of file -- cgit v1.2.3-18-g5258