From 386be4780922d8c6107163d044c557c59178200c Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Mon, 21 Oct 2019 16:39:32 +0200 Subject: Add basic MPU9250 driver --- include/driver/mpu9250.h | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 include/driver/mpu9250.h (limited to 'include/driver') 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 ©); + 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 -- cgit v1.2.3