mpu6500_input.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501
  1. /*
  2. $License:
  3. Copyright (C) 2011 InvenSense Corporation, All Rights Reserved.
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  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. You should have received a copy of the GNU General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>.
  14. $
  15. */
  16. /**
  17. * @defgroup
  18. * @brief
  19. *
  20. * @{
  21. * @file mpu6500_input.h
  22. * @brief
  23. */
  24. #ifndef __MPU6500_INPUT_H_
  25. #define __MPU6500_INPUT_H_
  26. #define MPU_NAME "mpu6500"
  27. #define DEFAULT_MPU_SLAVEADDR 0x68
  28. #define MPU6500_INPUT_DRIVER "mpu6500_input"
  29. #define MPU6500_ID 0x70
  30. #define MPU6515_ID 0x74
  31. /*==== MPU6050B1 REGISTER SET ====*/
  32. enum {
  33. MPUREG_SELF_TEST_X_GYRO = 0, /* 0x00, 0 */
  34. MPUREG_SELF_TEST_Y_GYRO, /* 0x01, 1 */
  35. MPUREG_SELF_TEST_Z_GYRO, /* 0x02, 2 */
  36. MPUREG_SELF_TEST_X_ACCEL = 0xD, /* 0x0D, 13 */
  37. MPUREG_SELF_TEST_Y_ACCEL , /* 0x0E, 14 */
  38. MPUREG_SELF_TEST_Z_ACCEL, /* 0x0F, 15 */
  39. MPUREG_XG_OFFS_USRH = 0x13, /* 0x13, 19 */
  40. MPUREG_XG_OFFS_USRL, /* 0x14, 20 */
  41. MPUREG_YG_OFFS_USRH, /* 0x15, 21 */
  42. MPUREG_YG_OFFS_USRL, /* 0x16, 22 */
  43. MPUREG_ZG_OFFS_USRH, /* 0x17, 23 */
  44. MPUREG_ZG_OFFS_USRL, /* 0x18, 24 */
  45. MPUREG_SMPLRT_DIV, /* 0x19, 25 */
  46. MPUREG_CONFIG, /* 0x1A, 26 */
  47. MPUREG_GYRO_CONFIG, /* 0x1b, 27 */
  48. MPUREG_ACCEL_CONFIG, /* 0x1c, 28 */
  49. MPUREG_ACCEL_CONFIG2, /* 0x1d, 29 */
  50. MPUREG_LP_ACCEL_ODR, /* 0x1e, 30 */
  51. MPUREG_WOM_THR, /* 0x1f, 31 */
  52. MPUREG_ACCEL_INTEL_ENABLE, /* 0x20, 32 */
  53. MPUREG_FIFO_EN = 0x23, /* 0x23, 35 */
  54. MPUREG_I2C_MST_CTRL, /* 0x24, 36 */
  55. MPUREG_I2C_SLV0_ADDR, /* 0x25, 37 */
  56. MPUREG_I2C_SLV0_REG, /* 0x26, 38 */
  57. MPUREG_I2C_SLV0_CTRL, /* 0x27, 39 */
  58. MPUREG_I2C_SLV1_ADDR, /* 0x28, 40 */
  59. MPUREG_I2C_SLV1_REG, /* 0x29, 41 */
  60. MPUREG_I2C_SLV1_CTRL, /* 0x2a, 42 */
  61. MPUREG_I2C_SLV2_ADDR, /* 0x2B, 43 */
  62. MPUREG_I2C_SLV2_REG, /* 0x2c, 44 */
  63. MPUREG_I2C_SLV2_CTRL, /* 0x2d, 45 */
  64. MPUREG_I2C_SLV3_ADDR, /* 0x2E, 46 */
  65. MPUREG_I2C_SLV3_REG, /* 0x2f, 47 */
  66. MPUREG_I2C_SLV3_CTRL, /* 0x30, 48 */
  67. MPUREG_I2C_SLV4_ADDR, /* 0x31, 49 */
  68. MPUREG_I2C_SLV4_REG, /* 0x32, 50 */
  69. MPUREG_I2C_SLV4_DO, /* 0x33, 51 */
  70. MPUREG_I2C_SLV4_CTRL, /* 0x34, 52 */
  71. MPUREG_I2C_SLV4_DI, /* 0x35, 53 */
  72. MPUREG_I2C_MST_STATUS, /* 0x36, 54 */
  73. MPUREG_INT_PIN_CFG, /* 0x37, 55 */
  74. MPUREG_INT_ENABLE, /* 0x38, 56 */
  75. MPUREG_DMP_INT_STATUS, /* 0x39, 57 */
  76. MPUREG_INT_STATUS, /* 0x3A, 58 */
  77. MPUREG_ACCEL_XOUT_H, /* 0x3B, 59 */
  78. MPUREG_ACCEL_XOUT_L, /* 0x3c, 60 */
  79. MPUREG_ACCEL_YOUT_H, /* 0x3d, 61 */
  80. MPUREG_ACCEL_YOUT_L, /* 0x3e, 62 */
  81. MPUREG_ACCEL_ZOUT_H, /* 0x3f, 63 */
  82. MPUREG_ACCEL_ZOUT_L, /* 0x40, 64 */
  83. MPUREG_TEMP_OUT_H, /* 0x41, 65 */
  84. MPUREG_TEMP_OUT_L, /* 0x42, 66 */
  85. MPUREG_GYRO_XOUT_H, /* 0x43, 67 */
  86. MPUREG_GYRO_XOUT_L, /* 0x44, 68 */
  87. MPUREG_GYRO_YOUT_H, /* 0x45, 69 */
  88. MPUREG_GYRO_YOUT_L, /* 0x46, 70 */
  89. MPUREG_GYRO_ZOUT_H, /* 0x47, 71 */
  90. MPUREG_GYRO_ZOUT_L, /* 0x48, 72 */
  91. MPUREG_EXT_SLV_SENS_DATA_00, /* 0x49, 73 */
  92. MPUREG_EXT_SLV_SENS_DATA_01, /* 0x4a, 74 */
  93. MPUREG_EXT_SLV_SENS_DATA_02, /* 0x4b, 75 */
  94. MPUREG_EXT_SLV_SENS_DATA_03, /* 0x4c, 76 */
  95. MPUREG_EXT_SLV_SENS_DATA_04, /* 0x4d, 77 */
  96. MPUREG_EXT_SLV_SENS_DATA_05, /* 0x4e, 78 */
  97. MPUREG_EXT_SLV_SENS_DATA_06, /* 0x4F, 79 */
  98. MPUREG_EXT_SLV_SENS_DATA_07, /* 0x50, 80 */
  99. MPUREG_EXT_SLV_SENS_DATA_08, /* 0x51, 81 */
  100. MPUREG_EXT_SLV_SENS_DATA_09, /* 0x52, 82 */
  101. MPUREG_EXT_SLV_SENS_DATA_10, /* 0x53, 83 */
  102. MPUREG_EXT_SLV_SENS_DATA_11, /* 0x54, 84 */
  103. MPUREG_EXT_SLV_SENS_DATA_12, /* 0x55, 85 */
  104. MPUREG_EXT_SLV_SENS_DATA_13, /* 0x56, 86 */
  105. MPUREG_EXT_SLV_SENS_DATA_14, /* 0x57, 87 */
  106. MPUREG_EXT_SLV_SENS_DATA_15, /* 0x58, 88 */
  107. MPUREG_EXT_SLV_SENS_DATA_16, /* 0x59, 89 */
  108. MPUREG_EXT_SLV_SENS_DATA_17, /* 0x5a, 90 */
  109. MPUREG_EXT_SLV_SENS_DATA_18, /* 0x5B, 91 */
  110. MPUREG_EXT_SLV_SENS_DATA_19, /* 0x5c, 92 */
  111. MPUREG_EXT_SLV_SENS_DATA_20, /* 0x5d, 93 */
  112. MPUREG_EXT_SLV_SENS_DATA_21, /* 0x5e, 94 */
  113. MPUREG_EXT_SLV_SENS_DATA_22, /* 0x5f, 95 */
  114. MPUREG_EXT_SLV_SENS_DATA_23, /* 0x60, 96 */
  115. MPUREG_ACCEL_INTEL_STATUS, /* 0x61, 97 */
  116. MPUREG_62_RSVD, /* 0x62, 98 */
  117. MPUREG_I2C_SLV0_DO, /* 0x63, 99 */
  118. MPUREG_I2C_SLV1_DO, /* 0x64, 100 */
  119. MPUREG_I2C_SLV2_DO, /* 0x65, 101 */
  120. MPUREG_I2C_SLV3_DO, /* 0x66, 102 */
  121. MPUREG_I2C_MST_DELAY_CTRL, /* 0x67, 103 */
  122. MPUREG_SIGNAL_PATH_RESET, /* 0x68, 104 */
  123. MPUREG_ACCEL_INTEL_CTRL, /* 0x69, 105 */
  124. MPUREG_USER_CTRL, /* 0x6A, 106 */
  125. MPUREG_PWR_MGMT_1, /* 0x6B, 107 */
  126. MPUREG_PWR_MGMT_2, /* 0x6C, 108 */
  127. MPUREG_BANK_SEL, /* 0x6D, 109 */
  128. MPUREG_MEM_START_ADDR, /* 0x6E, 100 */
  129. MPUREG_MEM_R_W, /* 0x6F, 111 */
  130. MPUREG_DMP_CFG_1, /* 0x70, 112 */
  131. MPUREG_DMP_CFG_2, /* 0x71, 113 */
  132. MPUREG_FIFO_COUNTH, /* 0x72, 114 */
  133. MPUREG_FIFO_COUNTL, /* 0x73, 115 */
  134. MPUREG_FIFO_R_W, /* 0x74, 116 */
  135. MPUREG_WHOAMI, /* 0x75, 117 */
  136. MPUREG_XA_OFFSET_H = 0x77, /*0x77, 119*/
  137. MPUREG_XA_OFFSET_L, /*0x78, 119*/
  138. MPUREG_YA_OFFSET_H = 0x7A, /*0x7A, 119*/
  139. MPUREG_YA_OFFSET_L, /*0x7B, 119*/
  140. MPUREG_ZA_OFFSET_H = 0x7D, /*0x7D, 119*/
  141. MPUREG_ZA_OFFSET_L, /*0x7E, 119*/
  142. NUM_OF_MPU_REGISTERS /* = 0x76, 118 */
  143. };
  144. /*==== MPU6050B1 MEMORY ====*/
  145. enum MPU_MEMORY_BANKS {
  146. MEM_RAM_BANK_0 = 0,
  147. MEM_RAM_BANK_1,
  148. MEM_RAM_BANK_2,
  149. MEM_RAM_BANK_3,
  150. MEM_RAM_BANK_4,
  151. MEM_RAM_BANK_5,
  152. MEM_RAM_BANK_6,
  153. MEM_RAM_BANK_7,
  154. MEM_RAM_BANK_8,
  155. MEM_RAM_BANK_9,
  156. MEM_RAM_BANK_10,
  157. MEM_RAM_BANK_11,
  158. MPU_MEM_NUM_RAM_BANKS,
  159. MPU_MEM_OTP_BANK_0 = 16
  160. };
  161. /*==== MPU6050B1 parameters ====*/
  162. #define NUM_REGS (NUM_OF_MPU_REGISTERS)
  163. #define START_SENS_REGS (0x3B)
  164. #define NUM_SENS_REGS (0x60 - START_SENS_REGS + 1)
  165. /*---- MPU Memory ----*/
  166. #define NUM_BANKS (MPU_MEM_NUM_RAM_BANKS)
  167. #define BANK_SIZE (256)
  168. #define MEM_SIZE (NUM_BANKS * BANK_SIZE)
  169. #define MPU_MEM_BANK_SIZE (BANK_SIZE) /*alternative name */
  170. #define FIFO_HW_SIZE (1024)
  171. #define NUM_EXT_SLAVES (4)
  172. /*==== BITS FOR MPU6050B1 ====*/
  173. /*---- MPU6050B1 'XG_OFFS_TC' register (0, 1, 2) ----*/
  174. #define BIT_PU_SLEEP_MODE 0x80
  175. #define BITS_XG_OFFS_TC 0x7E
  176. #define BIT_OTP_BNK_VLD 0x01
  177. #define BIT_I2C_MST_VDDIO 0x80
  178. #define BITS_YG_OFFS_TC 0x7E
  179. #define BITS_ZG_OFFS_TC 0x7E
  180. /*---- MPU6050B1 'FIFO_EN' register (23) ----*/
  181. #define BIT_TEMP_OUT 0x80
  182. #define BIT_GYRO_XOUT 0x40
  183. #define BIT_GYRO_YOUT 0x20
  184. #define BIT_GYRO_ZOUT 0x10
  185. #define BIT_ACCEL 0x08
  186. #define BIT_SLV_2 0x04
  187. #define BIT_SLV_1 0x02
  188. #define BIT_SLV_0 0x01
  189. /*---- MPU6050B1 'CONFIG' register (1A) ----*/
  190. /*NONE 0xC0 */
  191. #define BITS_EXT_SYNC_SET 0x38
  192. #define BITS_DLPF_CFG 0x07
  193. /*---- MPU6050B1 'GYRO_CONFIG' register (1B) ----*/
  194. /* voluntarily modified label from BITS_FS_SEL to
  195. * BITS_GYRO_FS_SEL to avoid confusion with MPU
  196. */
  197. #define BITS_GYRO_FS_SEL 0x18
  198. /*NONE 0x07 */
  199. /*---- MPU6050B1 'ACCEL_CONFIG' register (1C) ----*/
  200. #define BITS_ACCEL_FS_SEL 0x18
  201. #define BITS_ACCEL_HPF 0x07
  202. /*---- MPU6050B1 'ACCEL_CONFIG2' register (1D) ----*/
  203. #define BIT_ACCEL_FCHOICE_B 0x08
  204. /*---- MPU6050B1 'I2C_MST_CTRL' register (24) ----*/
  205. #define BIT_MULT_MST_EN 0x80
  206. #define BIT_WAIT_FOR_ES 0x40
  207. #define BIT_SLV_3_FIFO_EN 0x20
  208. #define BIT_I2C_MST_PSR 0x10
  209. #define BITS_I2C_MST_CLK 0x0F
  210. /*---- MPU6050B1 'I2C_SLV?_ADDR' register (27,2A,2D,30) ----*/
  211. #define BIT_I2C_READ 0x80
  212. #define BIT_I2C_WRITE 0x00
  213. #define BITS_I2C_ADDR 0x7F
  214. /*---- MPU6050B1 'I2C_SLV?_CTRL' register (27,2A,2D,30) ----*/
  215. #define BIT_SLV_ENABLE 0x80
  216. #define BIT_SLV_BYTE_SW 0x40
  217. #define BIT_SLV_REG_DIS 0x20
  218. #define BIT_SLV_GRP 0x10
  219. #define BITS_SLV_LENG 0x0F
  220. /*---- MPU6050B1 'I2C_SLV4_ADDR' register (31) ----*/
  221. #define BIT_I2C_SLV4_RNW 0x80
  222. /*---- MPU6050B1 'I2C_SLV4_CTRL' register (34) ----*/
  223. #define BIT_I2C_SLV4_EN 0x80
  224. #define BIT_SLV4_DONE_INT_EN 0x40
  225. #define BIT_SLV4_REG_DIS 0x20
  226. #define MASK_I2C_MST_DLY 0x1F
  227. /*---- MPU6050B1 'I2C_MST_STATUS' register (36) ----*/
  228. #define BIT_PASS_THROUGH 0x80
  229. #define BIT_I2C_SLV4_DONE 0x40
  230. #define BIT_I2C_LOST_ARB 0x20
  231. #define BIT_I2C_SLV4_NACK 0x10
  232. #define BIT_I2C_SLV3_NACK 0x08
  233. #define BIT_I2C_SLV2_NACK 0x04
  234. #define BIT_I2C_SLV1_NACK 0x02
  235. #define BIT_I2C_SLV0_NACK 0x01
  236. /*---- MPU6050B1 'INT_PIN_CFG' register (37) ----*/
  237. #define BIT_ACTL 0x80
  238. #define BIT_ACTL_LOW 0x80
  239. #define BIT_ACTL_HIGH 0x00
  240. #define BIT_OPEN 0x40
  241. #define BIT_LATCH_INT_EN 0x20
  242. #define BIT_INT_ANYRD_2CLEAR 0x10
  243. #define BIT_ACTL_FSYNC 0x08
  244. #define BIT_FSYNC_INT_EN 0x04
  245. #define BIT_BYPASS_EN 0x02
  246. #define BIT_CLKOUT_EN 0x01
  247. /*---- MPU6050B1 'INT_ENABLE' register (38) ----*/
  248. #define BIT_FF_EN 0x80
  249. #define BIT_MOT_EN 0x40
  250. #define BIT_ZMOT_EN 0x20
  251. #define BIT_FIFO_OVERFLOW_EN 0x10
  252. #define BIT_I2C_MST_INT_EN 0x08
  253. #define BIT_PLL_RDY_EN 0x04
  254. #define BIT_DMP_INT_EN 0x02
  255. #define BIT_RAW_RDY_EN 0x01
  256. /*---- MPU6050B1 'DMP_INT_STATUS' register (39) ----*/
  257. /*NONE 0x80 */
  258. /*NONE 0x40 */
  259. #define BIT_DMP_INT_5 0x20
  260. #define BIT_DMP_INT_4 0x10
  261. #define BIT_DMP_INT_3 0x08
  262. #define BIT_DMP_INT_2 0x04
  263. #define BIT_DMP_INT_1 0x02
  264. #define BIT_DMP_INT_0 0x01
  265. /*---- MPU6050B1 'INT_STATUS' register (3A) ----*/
  266. #define BIT_FF_INT 0x80
  267. #define BIT_MOT_INT 0x40
  268. #define BIT_ZMOT_INT 0x20
  269. #define BIT_FIFO_OVERFLOW_INT 0x10
  270. #define BIT_I2C_MST_INT 0x08
  271. #define BIT_PLL_RDY_INT 0x04
  272. #define BIT_DMP_INT 0x02
  273. #define BIT_RAW_DATA_RDY_INT 0x01
  274. /*---- MPU6050B1 'MPUREG_I2C_MST_DELAY_CTRL' register (0x67) ----*/
  275. #define BIT_DELAY_ES_SHADOW 0x80
  276. #define BIT_SLV4_DLY_EN 0x10
  277. #define BIT_SLV3_DLY_EN 0x08
  278. #define BIT_SLV2_DLY_EN 0x04
  279. #define BIT_SLV1_DLY_EN 0x02
  280. #define BIT_SLV0_DLY_EN 0x01
  281. /*---- MPU6050B1 'BANK_SEL' register (6D) ----*/
  282. #define BIT_PRFTCH_EN 0x40
  283. #define BIT_CFG_USER_BANK 0x20
  284. #define BITS_MEM_SEL 0x1f
  285. /*---- MPU6050B1 'USER_CTRL' register (6A) ----*/
  286. #define BIT_DMP_EN 0x80
  287. #define BIT_FIFO_EN 0x40
  288. #define BIT_I2C_MST_EN 0x20
  289. #define BIT_I2C_IF_DIS 0x10
  290. #define BIT_DMP_RST 0x08
  291. #define BIT_FIFO_RST 0x04
  292. #define BIT_I2C_MST_RST 0x02
  293. #define BIT_SIG_COND_RST 0x01
  294. /*---- MPU6050B1 'PWR_MGMT_1' register (6B) ----*/
  295. #define BIT_H_RESET 0x80
  296. #define BIT_SLEEP 0x40
  297. #define BIT_CYCLE 0x20
  298. #define BIT_PD_PTAT 0x08
  299. #define BITS_CLKSEL 0x07
  300. /*---- MPU6050B1 'PWR_MGMT_2' register (6C) ----*/
  301. #define BITS_LPA_WAKE_CTRL 0xC0
  302. #define BITS_LPA_WAKE_1HZ 0x00
  303. #define BITS_LPA_WAKE_2HZ 0x40
  304. #define BITS_LPA_WAKE_20HZ 0x80
  305. #define BITS_LPA_WAKE_40HZ 0xC0
  306. #define BIT_STBY_XA 0x20
  307. #define BIT_STBY_YA 0x10
  308. #define BIT_STBY_ZA 0x08
  309. #define BIT_STBY_XG 0x04
  310. #define BIT_STBY_YG 0x02
  311. #define BIT_STBY_ZG 0x01
  312. #define ACCEL_MOT_THR_LSB (32) /* mg */
  313. #define ACCEL_MOT_DUR_LSB (1)
  314. #define ACCEL_ZRMOT_THR_LSB_CONVERSION(mg) ((mg * 1000) / 255)
  315. #define ACCEL_ZRMOT_DUR_LSB (64)
  316. /*----------------------------------------------------------------------------*/
  317. /*---- Alternative names to take care of conflicts with current mpu3050.h ----*/
  318. /*----------------------------------------------------------------------------*/
  319. /*-- registers --*/
  320. #define MPUREG_DLPF_FS_SYNC MPUREG_CONFIG /* 0x1A */
  321. #define MPUREG_PWR_MGM MPUREG_PWR_MGMT_1 /* 0x6B */
  322. #define MPUREG_FIFO_EN1 MPUREG_FIFO_EN /* 0x23 */
  323. #define MPUREG_INT_CFG MPUREG_INT_ENABLE /* 0x38 */
  324. #define MPUREG_X_OFFS_USRH MPUREG_XG_OFFS_USRH /* 0x13 */
  325. #define MPUREG_WHO_AM_I MPUREG_WHOAMI /* 0x75 */
  326. #define MPUREG_23_RSVD MPUREG_EXT_SLV_SENS_DATA_00 /* 0x49 */
  327. /*-- bits --*/
  328. /* 'USER_CTRL' register */
  329. #define BIT_AUX_IF_EN BIT_I2C_MST_EN
  330. #define BIT_AUX_RD_LENG BIT_I2C_MST_EN
  331. #define BIT_IME_IF_RST BIT_I2C_MST_RST
  332. #define BIT_GYRO_RST BIT_SIG_COND_RST
  333. /* 'INT_ENABLE' register */
  334. #define BIT_RAW_RDY BIT_RAW_DATA_RDY_INT
  335. #define BIT_MPU_RDY_EN BIT_PLL_RDY_EN
  336. /* 'INT_STATUS' register */
  337. #define BIT_INT_STATUS_FIFO_OVERLOW BIT_FIFO_OVERFLOW_INT
  338. /*---- MPU6050 Silicon Revisions ----*/
  339. #define MPU_SILICON_REV_A2 1 /* MPU6050A2 Device */
  340. #define MPU_SILICON_REV_B1 2 /* MPU6050B1 Device */
  341. /*---- MPU6050 notable product revisions ----*/
  342. #define MPU_PRODUCT_KEY_B1_E1_5 105
  343. #define MPU_PRODUCT_KEY_B2_F1 431
  344. /*---- structure containing control variables used by MLDL ----*/
  345. /*---- MPU clock source settings ----*/
  346. /*---- MPU filter selections ----*/
  347. enum mpu_filter {
  348. MPU_FILTER_250HZ_NOLPF2 = 0,
  349. MPU_FILTER_184HZ,
  350. MPU_FILTER_92HZ,
  351. MPU_FILTER_41HZ,
  352. MPU_FILTER_20HZ,
  353. MPU_FILTER_10HZ,
  354. MPU_FILTER_5HZ,
  355. MPU_FILTER_3600HZ_NOLPF,
  356. NUM_MPU_FILTER
  357. };
  358. enum mpu_a_filter {
  359. MPU_A_FILTER_460HZ = 0,
  360. MPU_A_FILTER_184HZ,
  361. MPU_A_FILTER_92HZ,
  362. MPU_A_FILTER_41HZ,
  363. MPU_A_FILTER_20HZ,
  364. MPU_A_FILTER_10HZ,
  365. MPU_A_FILTER_5HZ,
  366. NUM_MPU_A_FILTER
  367. };
  368. enum mpu_fullscale {
  369. MPU_FS_250DPS = 0,
  370. MPU_FS_500DPS,
  371. MPU_FS_1000DPS,
  372. MPU_FS_2000DPS,
  373. NUM_MPU_FS
  374. };
  375. enum mpu_clock_sel {
  376. MPU_CLK_SEL_INTERNAL = 0,
  377. MPU_CLK_SEL_PLLGYROX,
  378. MPU_CLK_SEL_PLLGYROY,
  379. MPU_CLK_SEL_PLLGYROZ,
  380. MPU_CLK_SEL_PLLEXT32K,
  381. MPU_CLK_SEL_PLLEXT19M,
  382. MPU_CLK_SEL_RESERVED,
  383. MPU_CLK_SEL_STOP,
  384. NUM_CLK_SEL
  385. };
  386. enum mpu_ext_sync {
  387. MPU_EXT_SYNC_NONE = 0,
  388. MPU_EXT_SYNC_TEMP,
  389. MPU_EXT_SYNC_GYROX,
  390. MPU_EXT_SYNC_GYROY,
  391. MPU_EXT_SYNC_GYROZ,
  392. MPU_EXT_SYNC_ACCELX,
  393. MPU_EXT_SYNC_ACCELY,
  394. MPU_EXT_SYNC_ACCELZ,
  395. NUM_MPU_EXT_SYNC
  396. };
  397. #define MPUREG_CONFIG_VALUE(ext_sync, lpf) \
  398. ((ext_sync << 3) | lpf)
  399. #define MPUREG_GYRO_CONFIG_VALUE(x_st, y_st, z_st, full_scale) \
  400. ((x_st ? 0x80 : 0) | \
  401. (y_st ? 0x70 : 0) | \
  402. (z_st ? 0x60 : 0) | \
  403. (full_scale << 3))
  404. /*
  405. struct mpu6500_input_platform_data {
  406. __s8 orientation[9];
  407. };*/
  408. #define ACC_CAL_TIME 20
  409. #define ACC_IDEAL 1024
  410. #define ACC_CAL_DIV 16
  411. #define MPU6500_MODE_NORMAL 0
  412. #define MPU6500_MODE_SLEEP 2
  413. #define MPU6500_MODE_WAKE_UP 3
  414. #ifndef MIN
  415. #define MIN(a, b) (((a) < (b)) ? (a) : (b))
  416. #endif
  417. #ifndef MAX
  418. #define MAX(a, b) (((a) > (b)) ? (a) : (b))
  419. #endif
  420. #define MPU6500_SENSOR_ACCEL (0x0f)
  421. #define MPU6500_SENSOR_GYRO (0xf0)
  422. #define MPU6500_SENSOR_LPSO (0x0100)
  423. #define DMP_MASK_TAP 0x3f
  424. #define INT_SRC_TAP 0x01
  425. #define INT_SRC_ORIENT 0x02
  426. #define INT_SRC_DISPLAY_ORIENT 0x08
  427. #define DMP_MASK_DIS_ORIEN 0xC0
  428. #define DMP_DIS_ORIEN_SHIFT 6
  429. #define IS_LP_ENABLED(sensors) (sensors & (MPU6500_SENSOR_LPSO ))
  430. #define LP_MASK(sensors) (sensors & (MPU6500_SENSOR_LPSO ))
  431. struct mpu6500_input_platform_data {
  432. __s8 orientation[9];
  433. void (*power_on) (bool);
  434. const char *acc_cal_path;
  435. const char *gyro_cal_path;
  436. };
  437. void mpu6500_msleep(unsigned int msecs);
  438. void mpu6500_msleep_interruptible(unsigned int msecs);
  439. int mpu6500_i2c_write(struct i2c_client *i2c_client,
  440. unsigned int len, unsigned char *data);
  441. int mpu6500_i2c_read(struct i2c_client *i2c_client,
  442. unsigned int len, unsigned char *data);
  443. int mpu6500_i2c_write_single_reg(struct i2c_client *i2c_client,
  444. unsigned char reg, unsigned char value);
  445. int mpu6500_i2c_read_reg(struct i2c_client *i2c_client,
  446. unsigned char reg,unsigned int len, unsigned char *data);
  447. int mpu6500_i2c_read_fifo( struct i2c_client *i2c_client,
  448. unsigned short length, unsigned char *data);
  449. int mpu6500_i2c_memory_write(struct i2c_client *i2c_client,
  450. unsigned short mem_addr, unsigned int len, unsigned char const *data);
  451. int mpu6500_i2c_memory_read(struct i2c_client *i2c_client,
  452. unsigned short mem_addr, unsigned int len, unsigned char *data);
  453. #endif