bma255.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /* BMA255 motion sensor driver
  2. *
  3. *
  4. * This software program is licensed subject to the GNU General Public License
  5. * (GPL).Version 2,June 1991, available at http://www.fsf.org/copyleft/gpl.html
  6. * (C) Copyright 2011 Bosch Sensortec GmbH
  7. * All Rights Reserved
  8. */
  9. #ifndef BMA255_H
  10. #define BMA255_H
  11. #include <linux/ioctl.h>
  12. /* 7-bit addr: 0x18 (SDO connected to GND); 0x19 (SDO connected to VDDIO) */
  13. #define BMA255_I2C_ADDR 0x18
  14. /* chip ID */
  15. #define BMA255_FIXED_DEVID 0xFA
  16. /* BMA255 Register Map (Please refer to BMA255 Specifications) */
  17. #define BMA255_REG_DEVID 0x00
  18. #define BMA255_REG_OFSX 0x16
  19. #define BMA255_REG_OFSX_HIGH 0x1A
  20. #define BMA255_REG_BW_RATE 0x10
  21. #define BMA255_BW_MASK 0x1f
  22. #define BMA255_BW_200HZ 0x0d
  23. #define BMA255_BW_100HZ 0x0c
  24. #define BMA255_BW_50HZ 0x0b
  25. #define BMA255_BW_25HZ 0x0a
  26. #define BMA255_REG_POWER_CTL 0x11
  27. #define BMA255_REG_DATA_FORMAT 0x0f
  28. #define BMA255_RANGE_MASK 0x0f
  29. #define BMA255_RANGE_2G 0x03
  30. #define BMA255_RANGE_4G 0x05
  31. #define BMA255_RANGE_8G 0x08
  32. #define BMA255_REG_DATAXLOW 0x02
  33. #define BMA255_REG_DATA_RESOLUTION 0x14
  34. #define BMA255_MEASURE_MODE 0x80
  35. #define BMA255_SELF_TEST 0x32
  36. #define BMA255_SELF_TEST_AXIS_X 0x01
  37. #define BMA255_SELF_TEST_AXIS_Y 0x02
  38. #define BMA255_SELF_TEST_AXIS_Z 0x03
  39. #define BMA255_SELF_TEST_POSITIVE 0x00
  40. #define BMA255_SELF_TEST_NEGATIVE 0x04
  41. #define BMA255_INT_REG_1 0x16
  42. #define BMA255_INT_REG_2 0x17
  43. #define BMA255_FIFO_MODE_REG 0x3E
  44. #define BMA255_FIFO_DATA_OUTPUT_REG 0x3F
  45. #define BMA255_STATUS_FIFO_REG 0x0E
  46. #define BMA255_SUCCESS 0
  47. #define BMA255_ERR_I2C -1
  48. #define BMA255_ERR_STATUS -3
  49. #define BMA255_ERR_SETUP_FAILURE -4
  50. #define BMA255_ERR_GETGSENSORDATA -5
  51. #define BMA255_ERR_IDENTIFICATION -6
  52. #define BMA255_BUFSIZE 256
  53. /* power mode */
  54. #define BMA255_MODE_CTRL_REG 0x11
  55. #define BMA255_MODE_CTRL__POS 5
  56. #define BMA255_MODE_CTRL__LEN 3
  57. #define BMA255_MODE_CTRL__MSK 0xE0
  58. #define BMA255_MODE_CTRL__REG BMA255_MODE_CTRL_REG
  59. #define BMA255_LOW_POWER_CTRL_REG 0x12
  60. #define BMA255_LOW_POWER_MODE__POS 6
  61. #define BMA255_LOW_POWER_MODE__LEN 1
  62. #define BMA255_LOW_POWER_MODE__MSK 0x40
  63. #define BMA255_LOW_POWER_MODE__REG BMA255_LOW_POWER_CTRL_REG
  64. /* range */
  65. #define BMA255_RANGE_SEL_REG 0x0F
  66. #define BMA255_RANGE_SEL__POS 0
  67. #define BMA255_RANGE_SEL__LEN 4
  68. #define BMA255_RANGE_SEL__MSK 0x0F
  69. #define BMA255_RANGE_SEL__REG BMA255_RANGE_SEL_REG
  70. /* bandwidth */
  71. #define BMA255_BW_7_81HZ 0x08
  72. #define BMA255_BW_15_63HZ 0x09
  73. #define BMA255_BW_31_25HZ 0x0A
  74. #define BMA255_BW_62_50HZ 0x0B
  75. #define BMA255_BW_125HZ 0x0C
  76. #define BMA255_BW_250HZ 0x0D
  77. #define BMA255_BW_500HZ 0x0E
  78. #define BMA255_BW_1000HZ 0x0F
  79. #define BMA255_BW_SEL_REG 0x10
  80. #define BMA255_BANDWIDTH__POS 0
  81. #define BMA255_BANDWIDTH__LEN 5
  82. #define BMA255_BANDWIDTH__MSK 0x1F
  83. #define BMA255_BANDWIDTH__REG BMA255_BW_SEL_REG
  84. //tad3sgh add ++
  85. #define CONVERT_M 1
  86. #define CONVERT_M_DIV 4
  87. #define CONVERT_O 1
  88. #define CONVERT_O_DIV 71 //(C_PI_F32X * AXIS_RESOLUTION_FACTOR / 180)
  89. #define CONVERT_G 1
  90. #define CONVERT_G_DIV 938
  91. #define CONVERT_VRV 1
  92. #define CONVERT_VRV_DIV (0x40000000)
  93. #define CONVERT_VLA_DIV 16384
  94. #define CONVERT_VG_DIV 16384
  95. //tad3sgh add --
  96. #endif