bmg160.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. /* BOSCH GYROSCOPE Sensor Driver Header File
  2. *
  3. * This software is licensed under the terms of the GNU General Public
  4. * License version 2, as published by the Free Software Foundation, and
  5. * may be copied, distributed, and modified under those terms.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. *
  12. */
  13. #ifndef BMG160_H
  14. #define BMG160_H
  15. #include <linux/ioctl.h>
  16. /*************************************************************
  17. | sensor | chip id | bit number | 7-bit i2c address |
  18. -------------------------------------------------------------|
  19. | bmg160 | 0x0F | 16 |0x68(SDO:low),0x69(SDO:high)|
  20. *************************************************************/
  21. /*
  22. * configuration
  23. */
  24. #define BMG_DRIVER_VERSION "V1.4"
  25. /* apply low pass filter on output */
  26. /* #define CONFIG_BMG_LOWPASS */
  27. #define SW_CALIBRATION
  28. #define BMG_AXIS_X 0
  29. #define BMG_AXIS_Y 1
  30. #define BMG_AXIS_Z 2
  31. #define BMG_AXES_NUM 3
  32. #define BMG_DATA_LEN 6
  33. #define BMG_DEV_NAME "bmg160"
  34. #define C_MAX_FIR_LENGTH (32)
  35. #define MAX_SENSOR_NAME (32)
  36. #define I2C_BUFFER_SIZE (256)
  37. /* common definition */
  38. #define BMG_GET_BITSLICE(regvar, bitname)\
  39. ((regvar & bitname##__MSK) >> bitname##__POS)
  40. #define BMG_SET_BITSLICE(regvar, bitname, val)\
  41. ((regvar & ~bitname##__MSK) | ((val<<bitname##__POS)&bitname##__MSK))
  42. #define BMG_CHIP_ID_REG 0x00
  43. #define BMG_BUFSIZE 128
  44. #define MAX_FIFO_F_LEVEL 100
  45. #define MAX_FIFO_F_BYTES 8
  46. /*
  47. *1 rad = PI*degree/180, about 3.1416*degree/180
  48. *1 degree = rad*180/PI, about rad*180/3.1416
  49. */
  50. #define DEGREE_TO_RAD 57
  51. /*********************************[BMG160]*************************************/
  52. /* chip id */
  53. #define BMG160_CHIP_ID 0x0F
  54. /* i2c address */
  55. /*
  56. *7-bit addr: 0x68 (SDO connected to GND); 0x69 (SDO connected to VDDIO)
  57. */
  58. #define BMG160_I2C_ADDRESS 0x69
  59. /* bandwidth */
  60. #define C_BMG160_No_Filter_U8X 0
  61. #define C_BMG160_BW_230Hz_U8X 1
  62. #define C_BMG160_BW_116Hz_U8X 2
  63. #define C_BMG160_BW_47Hz_U8X 3
  64. #define C_BMG160_BW_23Hz_U8X 4
  65. #define C_BMG160_BW_12Hz_U8X 5
  66. #define C_BMG160_BW_64Hz_U8X 6
  67. #define C_BMG160_BW_32Hz_U8X 7
  68. #define BMG160_BW_ADDR 0x10
  69. #define BMG160_BW_ADDR__POS 0
  70. #define BMG160_BW_ADDR__LEN 3
  71. #define BMG160_BW_ADDR__MSK 0x07
  72. #define BMG160_BW_ADDR__REG BMG160_BW_ADDR
  73. /* range */
  74. #define BMG160_RANGE_2000 0
  75. #define BMG160_RANGE_1000 1
  76. #define BMG160_RANGE_500 2
  77. #define BMG160_RANGE_250 3
  78. #define BMG160_RANGE_125 4
  79. #define BMG160_RANGE_ADDR 0x0F
  80. #define BMG160_RANGE_ADDR_RANGE__POS 0
  81. #define BMG160_RANGE_ADDR_RANGE__LEN 3
  82. #define BMG160_RANGE_ADDR_RANGE__MSK 0x07
  83. #define BMG160_RANGE_ADDR_RANGE__REG BMG160_RANGE_ADDR
  84. /* power mode */
  85. #define BMG160_SUSPEND_MODE 4
  86. #define BMG160_NORMAL_MODE 0
  87. #define BMG160_MODE_LPM1_ADDR 0x11
  88. #define BMG160_MODE_LPM1__POS 5
  89. #define BMG160_MODE_LPM1__LEN 3
  90. #define BMG160_MODE_LPM1__MSK 0xA0
  91. #define BMG160_MODE_LPM1__REG BMG160_MODE_LPM1_ADDR
  92. /* data */
  93. #define BMG160_RATE_X_LSB_ADDR 0x02
  94. #define BMG160_FIFO_DATA_ADDR 0x3F
  95. /* self test */
  96. #define BMG160_SELF_TEST_ADDR 0x3C
  97. #define BMG160_SELF_TEST_ADDR_RATEOK__POS 4
  98. #define BMG160_SELF_TEST_ADDR_RATEOK__LEN 1
  99. #define BMG160_SELF_TEST_ADDR_RATEOK__MSK 0x10
  100. #define BMG160_SELF_TEST_ADDR_RATEOK__REG BMG160_SELF_TEST_ADDR
  101. #define BMG160_SELF_TEST_ADDR_BISTFAIL__POS 2
  102. #define BMG160_SELF_TEST_ADDR_BISTFAIL__LEN 1
  103. #define BMG160_SELF_TEST_ADDR_BISTFAIL__MSK 0x04
  104. #define BMG160_SELF_TEST_ADDR_BISTFAIL__REG BMG160_SELF_TEST_ADDR
  105. #define BMG160_SELF_TEST_ADDR_TRIGBIST__POS 0
  106. #define BMG160_SELF_TEST_ADDR_TRIGBIST__LEN 1
  107. #define BMG160_SELF_TEST_ADDR_TRIGBIST__MSK 0x01
  108. #define BMG160_SELF_TEST_ADDR_TRIGBIST__REG BMG160_SELF_TEST_ADDR
  109. /* fifo */
  110. #define BMG160_FIFO_CGF0_ADDR 0x3E
  111. #define BMG160_FIFO_CGF0_ADDR_MODE__POS 6
  112. #define BMG160_FIFO_CGF0_ADDR_MODE__LEN 2
  113. #define BMG160_FIFO_CGF0_ADDR_MODE__MSK 0xC0
  114. #define BMG160_FIFO_CGF0_ADDR_MODE__REG BMG160_FIFO_CGF0_ADDR
  115. #define BMG160_FIFO_STATUS_ADDR 0x0E
  116. #define BMG160_FIFO_STATUS_FRAME_COUNTER__POS 0
  117. #define BMG160_FIFO_STATUS_FRAME_COUNTER__LEN 7
  118. #define BMG160_FIFO_STATUS_FRAME_COUNTER__MSK 0x7F
  119. #define BMG160_FIFO_STATUS_FRAME_COUNTER__REG BMG160_FIFO_STATUS_ADDR
  120. #endif/* BMG160_H */