mpu6515.h 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. #ifndef MPU6515_H
  2. #define MPU6515_H
  3. #include <linux/ioctl.h>
  4. #define MPU6515_I2C_SLAVE_ADDR 0xD0 /* or 0xD1 */
  5. /* MPU6515 Register Map (Please refer to MPU6515 Specifications) */
  6. #define MPU6515_REG_DEVID 0x75
  7. #define MPU6515_REG_BW_RATE 0x1D
  8. #define MPU6515_REG_POWER_CTL 0x6B
  9. #define MPU6515_REG_POWER_CTL2 0x6C
  10. #define MPU6515_REG_INT_ENABLE 0x38
  11. #define MPU6515_REG_DATA_FORMAT 0x1C
  12. #define MPU6515_REG_DATAX0 0x3B
  13. #define MPU6515_REG_DATAY0 0x3D
  14. #define MPU6515_REG_DATAZ0 0x3F
  15. #define MPU6515_REG_RESET 0x68
  16. /* register Value */
  17. #define MPU6515_FIXED_DEVID 0x74
  18. /* delay(ms) */
  19. #define MPU6515_BW_460HZ 0x00 /* 1.94 */
  20. #define MPU6515_BW_184HZ 0x01 /* 5.8 */
  21. #define MPU6515_BW_92HZ 0x02 /* 7.8 */
  22. #define MPU6515_BW_41HZ 0x03 /* 11.8 */
  23. #define MPU6515_BW_20HZ 0x04 /* 19.8 */
  24. #define MPU6515_BW_10HZ 0x05 /* 35.7 */
  25. #define MPU6515_BW_5HZ 0x06 /* 66.96 */
  26. #define MPU6515_DEV_RESET 0x80
  27. /* #define MPU6515_FULL_RES 0x08 */
  28. #define MPU6515_RANGE_2G (0x00 << 3)
  29. #define MPU6515_RANGE_4G (0x01 << 3)
  30. #define MPU6515_RANGE_8G (0x02 << 3)
  31. #define MPU6515_RANGE_16G (0x03 << 3)
  32. /* #define MPU6515_SELF_TEST 0x80 */
  33. #define MPU6515_SLEEP 0x40 /* enable low power sleep mode */
  34. /* below do not modify */
  35. #define MPU6515_SUCCESS 0
  36. #define MPU6515_ERR_I2C -1
  37. #define MPU6515_ERR_STATUS -3
  38. #define MPU6515_ERR_SETUP_FAILURE -4
  39. #define MPU6515_ERR_GETGSENSORDATA -5
  40. #define MPU6515_ERR_IDENTIFICATION -6
  41. #define MPU6515_BUFSIZE 256
  42. #define MPU6515_AXES_NUM 3
  43. /*----------------------------------------------------------------------------*/
  44. typedef enum{
  45. MPU6515_CUST_ACTION_SET_CUST = 1,
  46. MPU6515_CUST_ACTION_SET_CALI,
  47. MPU6515_CUST_ACTION_RESET_CALI
  48. } CUST_ACTION;
  49. /*----------------------------------------------------------------------------*/
  50. typedef struct {
  51. uint16_t action;
  52. } MPU6515_CUST;
  53. /*----------------------------------------------------------------------------*/
  54. typedef struct {
  55. uint16_t action;
  56. uint16_t part;
  57. int32_t data[0];
  58. } MPU6515_SET_CUST;
  59. /*----------------------------------------------------------------------------*/
  60. typedef struct {
  61. uint16_t action;
  62. int32_t data[MPU6515_AXES_NUM];
  63. } MPU6515_SET_CALI;
  64. /*----------------------------------------------------------------------------*/
  65. typedef MPU6515_CUST MPU6515_RESET_CALI;
  66. /*----------------------------------------------------------------------------*/
  67. typedef union {
  68. uint32_t data[10];
  69. MPU6515_CUST cust;
  70. MPU6515_SET_CUST setCust;
  71. MPU6515_SET_CALI setCali;
  72. MPU6515_RESET_CALI resetCali;
  73. } MPU6515_CUST_DATA;
  74. /*----------------------------------------------------------------------------*/
  75. #endif