icm20645.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #ifndef ICM20645_H
  2. #define ICM20645_H
  3. #include <linux/ioctl.h>
  4. #define ICM20645_I2C_SLAVE_ADDR 0xD0
  5. #define REG_BANK_SEL 0x7F
  6. #define BANK_SEL_0 0x00
  7. #define BANK_SEL_1 0x10
  8. #define BANK_SEL_2 0x20
  9. #define BANK_SEL_3 0x30
  10. /* ICM20645 Register Map (Please refer to ICM20645 Specifications) */
  11. #define ICM20645_REG_DEVID 0x00
  12. #define ICM20645_REG_LP_CONFIG 0x05
  13. #define ICM20645_REG_POWER_CTL 0x06
  14. #define ICM20645_REG_POWER_CTL2 0x07
  15. #define ICM20645_REG_SAMRT_DIV1 0x10
  16. #define ICM20645_REG_SAMRT_DIV2 0x11
  17. #define BIT_ACC_LP_EN 0x20
  18. #define BIT_ACC_I2C_MST 0x40
  19. #define BIT_LP_EN 0x20
  20. #define BIT_CLK_PLL 0x01
  21. #define BIT_TEMP_DIS (1<<3)
  22. #define BIT_PWR_ACCEL_STBY 0x38
  23. #define BIT_PWR_GYRO_STBY 0x07
  24. #define ICM20645_REG_INT_ENABLE 0x11
  25. #define ICM20645_ACC_CONFIG 0x14
  26. #define ICM20645_ACC_CONFIG_2 0x15
  27. #define ACCEL_FCHOICE 1
  28. #define ACCEL_DLPFCFG (7<<3)
  29. #define ACCEL_AVGCFG_1_4X 0
  30. #define ACCEL_AVGCFG_8X 1
  31. #define ACCEL_AVGCFG_16X 2
  32. #define ACCEL_AVGCFG_32X 3
  33. #define ICM20645_REG_DATAX0 0x2d
  34. #define ICM20645_REG_DATAY0 0x2f
  35. #define ICM20645_REG_DATAZ0 0x31
  36. #define ICM20645_RANGE_2G (0x00 << 1)
  37. #define ICM20645_RANGE_4G (0x01 << 1)
  38. #define ICM20645_RANGE_8G (0x02 << 1)
  39. #define ICM20645_RANGE_16G (0x03 << 1)
  40. #define ICM20645_SLEEP 0x40
  41. #define ICM20645_DEV_RESET 0x80
  42. #define ICM20645_SUCCESS 0
  43. #define ICM20645_ERR_I2C -1
  44. #define ICM20645_ERR_STATUS -3
  45. #define ICM20645_ERR_SETUP_FAILURE -4
  46. #define ICM20645_ERR_GETGSENSORDATA -5
  47. #define ICM20645_ERR_IDENTIFICATION -6
  48. #define ICM20645_BUFSIZE 256
  49. extern int ICM20645_gyro_power(void);
  50. extern int ICM20645_gyro_mode(void);
  51. #endif