summaryrefslogtreecommitdiff
path: root/include/driver
diff options
context:
space:
mode:
authorDaniel Friesel <daniel.friesel@uos.de>2019-10-21 16:39:32 +0200
committerDaniel Friesel <daniel.friesel@uos.de>2019-10-21 16:39:32 +0200
commit386be4780922d8c6107163d044c557c59178200c (patch)
treeeb3386d5cb15fbeaa1d4163d582c5db41ae337fa /include/driver
parent7fe932417c4e36f89e4ce250788afa3f3f115443 (diff)
Add basic MPU9250 driver
Diffstat (limited to 'include/driver')
-rw-r--r--include/driver/mpu9250.h30
1 files changed, 30 insertions, 0 deletions
diff --git a/include/driver/mpu9250.h b/include/driver/mpu9250.h
new file mode 100644
index 0000000..e362994
--- /dev/null
+++ b/include/driver/mpu9250.h
@@ -0,0 +1,30 @@
+#ifndef MPU9250_H
+#define MPU9250_H
+
+class MPU9250 {
+ private:
+ MPU9250(const MPU9250 &copy);
+ unsigned char const address = 0x68;
+ unsigned char txbuf[3];
+ unsigned char rxbuf[8];
+ signed int getWordReg(unsigned char const regBase);
+
+ public:
+ MPU9250() {}
+ void init();
+ int getAccelX() { return getWordReg(59); }
+ int getAccelY() { return getWordReg(61); }
+ int getAccelZ() { return getWordReg(63); }
+ int getGyroX() { return getWordReg(67); }
+ int getGyroY() { return getWordReg(69); }
+ int getGyroZ() { return getWordReg(71); }
+ void getMagnet(int *x, int *y, int *z);
+ void setAccelEnable(bool x, bool y, bool z);
+ void setGyroEnable(bool x, bool y, bool z);
+ void setPower(bool sleep, bool gyroStandby);
+ float getTemperature();
+};
+
+extern MPU9250 mpu9250;
+
+#endif