You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
1.6 KiB

  1. /* Copyright 2021 bryan065
  2. *
  3. * This program is free software: you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License as published by
  5. * the Free Software Foundation, either version 2 of the License, or
  6. * (at your option) any later version.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #pragma once
  17. #include "mpu9250registermap.h"
  18. #include "i2c_master.h"
  19. enum Axis {
  20. x,
  21. y,
  22. z,
  23. kAxis,
  24. };
  25. typedef int16_t mpu_data_t;
  26. #define MPU9250_ADDR (0x68 << 1)
  27. #define I2C_TIMEOUT 1000
  28. #define MPU_POLLRATE 50
  29. #ifndef MPU_ANGLE_SENS
  30. #define MPU_ANGLE_SENS 60
  31. #endif
  32. #ifndef MPU_SPEED_SENS
  33. #define MPU_SPEED_SENS -700
  34. #endif
  35. i2c_status_t mpu_readAccel(int16_t* read);
  36. i2c_status_t mpu_readGyro(int16_t* read);
  37. i2c_status_t mpu_readAccelGyro(int16_t* read);
  38. extern i2c_status_t update_accel_gyro(void);
  39. extern int16_t mpu_readTemp(void);
  40. extern void initMPU9250(void);
  41. extern float getAcc(const uint8_t i);
  42. extern float getGyro(const uint8_t i);
  43. extern int16_t getAccScaled(const uint8_t i, const uint8_t o);
  44. extern int16_t getGyroScaled(const uint8_t i, const uint8_t o);
  45. extern mpu_data_t getAccRaw(const uint8_t i);
  46. extern mpu_data_t getGyroRaw(const uint8_t i);