bmp280.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /* BOSCH Pressure Sensor Driver
  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 BOSCH_BARO_H
  14. #define BOSCH_BARO_H
  15. #include <linux/ioctl.h>
  16. /*****************************************************
  17. | sensor | chip id | 7-bit i2c address |
  18. -----------------------------------------------------|
  19. | bmp280 | 0x56 |0x76(SDO:Low)|0x77(SDO:High)|
  20. *****************************************************/
  21. /* apply low pass filter on output */
  22. /*#define CONFIG_BMP_LOWPASS*/
  23. /*#define CONFIG_ID_TEMPERATURE*/
  24. /*#define CONFIG_I2C_BASIC_FUNCTION*/
  25. #define BMP_DRIVER_VERSION "V1.3"
  26. #define BMP_DEV_NAME "bmp280"
  27. #define C_MAX_FIR_LENGTH (32)
  28. #define MAX_SENSOR_NAME (32)
  29. #define BMP_DATA_NUM 1
  30. #define BMP_PRESSURE 0
  31. #define BMP_BUFSIZE 128
  32. /* common definition */
  33. #define BMP_GET_BITSLICE(regvar, bitname)\
  34. ((regvar & bitname##__MSK) >> bitname##__POS)
  35. #define BMP_SET_BITSLICE(regvar, bitname, val)\
  36. ((regvar & ~bitname##__MSK) | ((val<<bitname##__POS)&bitname##__MSK))
  37. #define BMP_CHIP_ID_REG 0xD0
  38. /*********************************[BMP280]*************************************/
  39. /* data type */
  40. #define BMP280_U16_t u16
  41. #define BMP280_S16_t s16
  42. #define BMP280_U32_t u32
  43. #define BMP280_S32_t s32
  44. #define BMP280_U64_t u64
  45. #define BMP280_S64_t s64
  46. /* chip id */
  47. #define BMP280_CHIP_ID1 0x56
  48. #define BMP280_CHIP_ID2 0x57
  49. #define BMP280_CHIP_ID3 0x58
  50. /* i2c address */
  51. /* 7-bit addr: 0x76 (SDO connected to GND); 0x77 (SDO connected to VDDIO) */
  52. #define BMP280_I2C_ADDRESS 0x77
  53. /* calibration data */
  54. #define BMP280_CALIBRATION_DATA_START 0x88 /* BMP280_DIG_T1_LSB_REG */
  55. #define BMP280_CALIBRATION_DATA_LENGTH 24
  56. #define SHIFT_RIGHT_4_POSITION 4
  57. #define SHIFT_LEFT_2_POSITION 2
  58. #define SHIFT_LEFT_4_POSITION 4
  59. #define SHIFT_LEFT_5_POSITION 5
  60. #define SHIFT_LEFT_8_POSITION 8
  61. #define SHIFT_LEFT_12_POSITION 12
  62. #define SHIFT_LEFT_16_POSITION 16
  63. /* power mode */
  64. #define BMP280_SLEEP_MODE 0x00
  65. #define BMP280_FORCED_MODE 0x01
  66. #define BMP280_NORMAL_MODE 0x03
  67. #define BMP280_CTRLMEAS_REG 0xF4 /* Ctrl Measure Register */
  68. #define BMP280_CTRLMEAS_REG_MODE__POS 0
  69. #define BMP280_CTRLMEAS_REG_MODE__MSK 0x03
  70. #define BMP280_CTRLMEAS_REG_MODE__LEN 2
  71. #define BMP280_CTRLMEAS_REG_MODE__REG BMP280_CTRLMEAS_REG
  72. /* filter */
  73. #define BMP280_FILTERCOEFF_OFF 0x00
  74. #define BMP280_FILTERCOEFF_2 0x01
  75. #define BMP280_FILTERCOEFF_4 0x02
  76. #define BMP280_FILTERCOEFF_8 0x03
  77. #define BMP280_FILTERCOEFF_16 0x04
  78. #define BMP280_CONFIG_REG 0xF5 /* Configuration Register */
  79. #define BMP280_CONFIG_REG_FILTER__POS 2
  80. #define BMP280_CONFIG_REG_FILTER__MSK 0x1C
  81. #define BMP280_CONFIG_REG_FILTER__LEN 3
  82. #define BMP280_CONFIG_REG_FILTER__REG BMP280_CONFIG_REG
  83. /* oversampling */
  84. #define BMP280_OVERSAMPLING_SKIPPED 0x00
  85. #define BMP280_OVERSAMPLING_1X 0x01
  86. #define BMP280_OVERSAMPLING_2X 0x02
  87. #define BMP280_OVERSAMPLING_4X 0x03
  88. #define BMP280_OVERSAMPLING_8X 0x04
  89. #define BMP280_OVERSAMPLING_16X 0x05
  90. #define BMP280_CTRLMEAS_REG_OSRST__POS 5
  91. #define BMP280_CTRLMEAS_REG_OSRST__MSK 0xE0
  92. #define BMP280_CTRLMEAS_REG_OSRST__LEN 3
  93. #define BMP280_CTRLMEAS_REG_OSRST__REG BMP280_CTRLMEAS_REG
  94. #define BMP280_CTRLMEAS_REG_OSRSP__POS 2
  95. #define BMP280_CTRLMEAS_REG_OSRSP__MSK 0x1C
  96. #define BMP280_CTRLMEAS_REG_OSRSP__LEN 3
  97. #define BMP280_CTRLMEAS_REG_OSRSP__REG BMP280_CTRLMEAS_REG
  98. /* data */
  99. #define BMP280_PRESSURE_MSB_REG 0xF7 /* Pressure MSB Register */
  100. #define BMP280_TEMPERATURE_MSB_REG 0xFA /* Temperature MSB Reg */
  101. /* i2c disable switch */
  102. #define BMP280_I2C_DISABLE_SWITCH 0x87
  103. #endif/* BOSCH_BARO_H */