EFM32 Giant Gecko Software Documentation  efm32gg-doc-5.1.2
bmp280.h
Go to the documentation of this file.
1 
59 #ifndef __BMP280_H__
60 #define __BMP280_H__
61 
74 #ifdef __KERNEL__
75 
76 #include <linux/types.h>
77 #include <linux/math64.h>
78 #define BMP280_64BITSUPPORT_PRESENT
79 /* singed integer type*/
80 typedef int8_t s8;
81 typedef int16_t s16;
82 typedef int32_t s32;
83 typedef int64_t s64;
85 typedef u_int8_t u8;
86 typedef u_int16_t u16;
87 typedef u_int32_t u32;
88 typedef u_int64_t u64;
92 #else /* ! __KERNEL__ */
93 /**********************************************************
94 * These definition uses for define the C
95 * standard version data types
96 ***********************************************************/
97 #if defined(__STDC_VERSION__)
98 
99 /************************************************
100  * compiler is C11 C standard
101 ************************************************/
102 #if (__STDC_VERSION__ == 201112L)
103 
104 /************************************************/
105 #include <stdint.h>
106 /************************************************/
107 
108 /*unsigned integer types*/
109 typedef uint8_t u8;
110 typedef uint16_t u16;
111 typedef uint32_t u32;
112 typedef uint64_t u64;
114 /*signed integer types*/
115 typedef int8_t s8;
116 typedef int16_t s16;
117 typedef int32_t s32;
118 typedef int64_t s64;
119 #define BMP280_64BITSUPPORT_PRESENT
120 /************************************************
121  * compiler is C99 C standard
122 ************************************************/
123 
124 #elif (__STDC_VERSION__ == 199901L)
125 
126 /* stdint.h is a C99 supported c library.
127 which is used to fixed the integer size*/
128 /************************************************/
129 #include <stdint.h>
130 /************************************************/
131 
132 /*unsigned integer types*/
133 typedef uint8_t u8;
134 typedef uint16_t u16;
135 typedef uint32_t u32;
136 typedef uint64_t u64;
138 /*signed integer types*/
139 typedef int8_t s8;
140 typedef int16_t s16;
141 typedef int32_t s32;
142 typedef int64_t s64;
143 #define BMP280_64BITSUPPORT_PRESENT
144 /************************************************
145  * compiler is C89 or other C standard
146 ************************************************/
147 
148 #else /* !defined(__STDC_VERSION__) */
149 
154 #define MACHINE_32_BIT
155 
160 #ifdef MACHINE_16_BIT
161 #include <limits.h>
162 /*signed integer types*/
163 typedef signed char s8;
164 typedef signed short int s16;
165 typedef signed long int s32;
167 #if defined(LONG_MAX) && LONG_MAX == 0x7fffffffffffffffL
168 typedef long int s64;
169 typedef unsigned long int u64;
170 #define BMP280_64BITSUPPORT_PRESENT
171 #elif defined(LLONG_MAX) && (LLONG_MAX == 0x7fffffffffffffffLL)
172 typedef long long int s64;
173 typedef unsigned long long int u64;
174 #define BMP280_64BITSUPPORT_PRESENT
175 #else
176 #warning Either the correct data type for signed 64 bit integer \
177 could not be found, or 64 bit integers are not supported in your environment.
178 #warning The API will only offer 32 bit pressure calculation.This will \
179 slightly impede accuracy(noise of ~1 pascal RMS will be added to output).
180 #warning If 64 bit integers are supported on your platform, \
181 please set s64 manually and "#define(BMP280_64BITSUPPORT_PRESENT)" manually.
182 #endif
183 
184 /*unsigned integer types*/
185 typedef unsigned char u8;
186 typedef unsigned short int u16;
187 typedef unsigned long int u32;
189 /* If your machine support 32 bit
190 define the MACHINE_32_BIT*/
191 #elif defined MACHINE_32_BIT
192 /*signed integer types*/
193 typedef signed char s8;
194 typedef signed short int s16;
195 typedef signed int s32;
196 typedef signed long long int s64;
198 /*unsigned integer types*/
199 typedef unsigned char u8;
200 typedef unsigned short int u16;
201 typedef unsigned int u32;
202 typedef unsigned long long int u64;
206 #define BMP280_64BITSUPPORT_PRESENT
207 
208 /* If your machine support 64 bit
209 define the MACHINE_64_BIT*/
210 #elif defined MACHINE_64_BIT
211 /*signed integer types*/
212 typedef signed char s8;
213 typedef signed short int s16;
214 typedef signed int s32;
215 typedef signed long int s64;
217 /*unsigned integer types*/
218 typedef unsigned char u8;
219 typedef unsigned short int u16;
220 typedef unsigned int u32;
221 typedef unsigned long int u64;
222 #define BMP280_64BITSUPPORT_PRESENT
223 
224 #else
225 #warning The data types defined above which not supported \
226 define the data types manually
227 #endif
228 #endif
229 
230 /*** This else will execute for the compilers
231  * which are not supported the C standards
232  * Like C89/C99/C11***/
233 #else
234 
239 #define MACHINE_32_BIT
240 
241 /* If your machine support 16 bit
242 define the MACHINE_16_BIT*/
243 #ifdef MACHINE_16_BIT
244 #include <limits.h>
245 /*signed integer types*/
246 typedef signed char s8;
247 typedef signed short int s16;
248 typedef signed long int s32;
250 #if defined(LONG_MAX) && LONG_MAX == 0x7fffffffffffffffL
251 typedef long int s64;
252 typedef unsigned long int u64;
253 #define BMP280_64BITSUPPORT_PRESENT
254 #elif defined(LLONG_MAX) && (LLONG_MAX == 0x7fffffffffffffffLL)
255 typedef long long int s64;
256 typedef unsigned long long int u64;
257 #define BMP280_64BITSUPPORT_PRESENT
258 #else
259 #warning Either the correct data type for signed 64 bit integer \
260 could not be found, or 64 bit integers are not supported in your environment.
261 #warning The API will only offer 32 bit pressure calculation.This will \
262 slightly impede accuracy(noise of ~1 pascal RMS will be added to output).
263 #warning If 64 bit integers are supported on your platform, \
264 please set s64 manually and "#define(BMP280_64BITSUPPORT_PRESENT)" manually.
265 #endif
266 
267 /*unsigned integer types*/
268 typedef unsigned char u8;
269 typedef unsigned short int u16;
270 typedef unsigned long int u32;
274 #elif defined MACHINE_32_BIT
275 /*signed integer types*/
276 typedef signed char s8;
277 typedef signed short int s16;
278 typedef signed int s32;
279 typedef signed long long int s64;
281 /*unsigned integer types*/
282 typedef unsigned char u8;
283 typedef unsigned short int u16;
284 typedef unsigned int u32;
285 typedef unsigned long long int u64;
286 #define BMP280_64BITSUPPORT_PRESENT
287 
288 /* If your machine support 64 bit
289 define the MACHINE_64_BIT*/
290 #elif defined MACHINE_64_BIT
291 /*signed integer types*/
292 typedef signed char s8;
293 typedef signed short int s16;
294 typedef signed int s32;
295 typedef signed long int s64;
297 /*unsigned integer types*/
298 typedef unsigned char u8;
299 typedef unsigned short int u16;
300 typedef unsigned int u32;
301 typedef unsigned long int u64;
302 #define BMP280_64BITSUPPORT_PRESENT
303 
304 #else
305 #warning The data types defined above which not supported \
306 define the data types manually
307 #endif
308 #endif
309 #endif
310 /********************************************/
312 /********************************************/
318 #define BMP280_ENABLE_FLOAT
319 
326 #define BMP280_ENABLE_INT64
327 /************************************************************/
329 /************************************************************/
350 /* defines the return parameter type of the BMP280_WR_FUNCTION */
351 #define BMP280_BUS_WR_RETURN_TYPE s8
352 
353 /* links the order of parameters defined in
354 BMP280_BUS_WR_PARAM_TYPE to function calls used inside the API*/
355 #define BMP280_BUS_WR_PARAM_TYPES u8, u8,\
356  u8 *, u8
357 
358 /* links the order of parameters defined in
359 BMP280_BUS_WR_PARAM_TYPE to function calls used inside the API*/
360 #define BMP280_BUS_WR_PARAM_ORDER(device_addr, register_addr,\
361  register_data, wr_len)
362 
363 /* never change this line */
364 #define BMP280_BUS_WRITE_FUNC(device_addr, register_addr,\
365 register_data, wr_len) bus_write(device_addr, register_addr,\
366  register_data, wr_len)
367 
391 /* defines the return parameter type of the BMP280_RD_FUNCTION
392 */
393 #define BMP280_BUS_RD_RETURN_TYPE s8
394 
395 /* defines the calling parameter types of the BMP280_RD_FUNCTION
396 */
397 #define BMP280_BUS_RD_PARAM_TYPES (u8, u8,\
398  u8 *, u8)
399 
400 /* links the order of parameters defined in \
401 BMP280_BUS_RD_PARAM_TYPE to function calls used inside the API
402 */
403 #define BMP280_BUS_RD_PARAM_ORDER (device_addr, register_addr,\
404  register_data)
405 
406 /* never change this line */
407 #define BMP280_BUS_READ_FUNC(device_addr, register_addr,\
408  register_data, rd_len)bus_read(device_addr, register_addr,\
409  register_data, rd_len)
410 /****************************************/
412 /****************************************/
416 #define BMP280_DELAY_RETURN_TYPE void
417 
421 #define BMP280_DELAY_PARAM_TYPES u16
422 /***************************************************************/
424 /***************************************************************/
425 /* never change this line */
426 #define BMP280_DELAY_FUNC(delay_in_msec)\
427  delay_func(delay_in_msec)
428 
429 #define BMP280_GET_BITSLICE(regvar, bitname)\
430  ((regvar & bitname##__MSK) >> bitname##__POS)
431 
432 #define BMP280_SET_BITSLICE(regvar, bitname, val)\
433  ((regvar & ~bitname##__MSK) | ((val<<bitname##__POS)&bitname##__MSK))
434 
435 /***************************************************************/
437 /***************************************************************/
438 /* Constants */
439 #define BMP280_NULL (0)
440 #define BMP280_RETURN_FUNCTION_TYPE s8
441 /* right shift definitions*/
442 #define BMP280_SHIFT_BIT_POSITION_BY_01_BIT (1)
443 #define BMP280_SHIFT_BIT_POSITION_BY_02_BITS (2)
444 #define BMP280_SHIFT_BIT_POSITION_BY_03_BITS (3)
445 #define BMP280_SHIFT_BIT_POSITION_BY_04_BITS (4)
446 #define BMP280_SHIFT_BIT_POSITION_BY_05_BITS (5)
447 #define BMP280_SHIFT_BIT_POSITION_BY_08_BITS (8)
448 #define BMP280_SHIFT_BIT_POSITION_BY_11_BITS (11)
449 #define BMP280_SHIFT_BIT_POSITION_BY_12_BITS (12)
450 #define BMP280_SHIFT_BIT_POSITION_BY_13_BITS (13)
451 #define BMP280_SHIFT_BIT_POSITION_BY_14_BITS (14)
452 #define BMP280_SHIFT_BIT_POSITION_BY_15_BITS (15)
453 #define BMP280_SHIFT_BIT_POSITION_BY_16_BITS (16)
454 #define BMP280_SHIFT_BIT_POSITION_BY_17_BITS (17)
455 #define BMP280_SHIFT_BIT_POSITION_BY_18_BITS (18)
456 #define BMP280_SHIFT_BIT_POSITION_BY_19_BITS (19)
457 #define BMP280_SHIFT_BIT_POSITION_BY_25_BITS (25)
458 #define BMP280_SHIFT_BIT_POSITION_BY_31_BITS (31)
459 #define BMP280_SHIFT_BIT_POSITION_BY_33_BITS (33)
460 #define BMP280_SHIFT_BIT_POSITION_BY_35_BITS (35)
461 #define BMP280_SHIFT_BIT_POSITION_BY_47_BITS (47)
462 
463 /* numeric definitions */
464 #define BMP280_PRESSURE_TEMPERATURE_CALIB_DATA_LENGTH (24)
465 #define BMP280_GEN_READ_WRITE_DATA_LENGTH (1)
466 #define BMP280_REGISTER_READ_DELAY (1)
467 #define BMP280_TEMPERATURE_DATA_LENGTH (3)
468 #define BMP280_PRESSURE_DATA_LENGTH (3)
469 #define BMP280_ALL_DATA_FRAME_LENGTH (6)
470 #define BMP280_INIT_VALUE (0)
471 #define BMP280_CHIP_ID_READ_COUNT (5)
472 #define BMP280_CHIP_ID_READ_SUCCESS (0)
473 #define BMP280_CHIP_ID_READ_FAIL ((s8)-1)
474 #define BMP280_INVALID_DATA (0)
475 
476 /************************************************/
478 /************************************************/
479 #define SUCCESS ((u8)0)
480 #define E_BMP280_NULL_PTR ((s8)-127)
481 #define E_BMP280_COMM_RES ((s8)-1)
482 #define E_BMP280_OUT_OF_RANGE ((s8)-2)
483 #define ERROR ((s8)-1)
484 /************************************************/
486 /***********************************************/
487 #define BMP280_CHIP_ID1 (0x56)
488 #define BMP280_CHIP_ID2 (0x57)
489 #define BMP280_CHIP_ID3 (0x58)
490 /************************************************/
492 /***********************************************/
493 #define BMP280_I2C_ADDRESS1 (0x76)
494 #define BMP280_I2C_ADDRESS2 (0x77)
495 /************************************************/
497 /***********************************************/
498 /* Sensor Specific constants */
499 #define BMP280_SLEEP_MODE (0x00)
500 #define BMP280_FORCED_MODE (0x01)
501 #define BMP280_NORMAL_MODE (0x03)
502 #define BMP280_SOFT_RESET_CODE (0xB6)
503 /************************************************/
505 /***********************************************/
506 #define BMP280_STANDBY_TIME_1_MS (0x00)
507 #define BMP280_STANDBY_TIME_63_MS (0x01)
508 #define BMP280_STANDBY_TIME_125_MS (0x02)
509 #define BMP280_STANDBY_TIME_250_MS (0x03)
510 #define BMP280_STANDBY_TIME_500_MS (0x04)
511 #define BMP280_STANDBY_TIME_1000_MS (0x05)
512 #define BMP280_STANDBY_TIME_2000_MS (0x06)
513 #define BMP280_STANDBY_TIME_4000_MS (0x07)
514 /************************************************/
516 /***********************************************/
517 #define BMP280_OVERSAMP_SKIPPED (0x00)
518 #define BMP280_OVERSAMP_1X (0x01)
519 #define BMP280_OVERSAMP_2X (0x02)
520 #define BMP280_OVERSAMP_4X (0x03)
521 #define BMP280_OVERSAMP_8X (0x04)
522 #define BMP280_OVERSAMP_16X (0x05)
523 /************************************************/
525 /***********************************************/
526 #define BMP280_ULTRA_LOW_POWER_MODE (0x00)
527 #define BMP280_LOW_POWER_MODE (0x01)
528 #define BMP280_STANDARD_RESOLUTION_MODE (0x02)
529 #define BMP280_HIGH_RESOLUTION_MODE (0x03)
530 #define BMP280_ULTRA_HIGH_RESOLUTION_MODE (0x04)
531 
532 #define BMP280_ULTRALOWPOWER_OVERSAMP_PRESSURE BMP280_OVERSAMP_1X
533 #define BMP280_ULTRALOWPOWER_OVERSAMP_TEMPERATURE BMP280_OVERSAMP_1X
534 
535 #define BMP280_LOWPOWER_OVERSAMP_PRESSURE BMP280_OVERSAMP_2X
536 #define BMP280_LOWPOWER_OVERSAMP_TEMPERATURE BMP280_OVERSAMP_1X
537 
538 #define BMP280_STANDARDRESOLUTION_OVERSAMP_PRESSURE BMP280_OVERSAMP_4X
539 #define BMP280_STANDARDRESOLUTION_OVERSAMP_TEMPERATURE BMP280_OVERSAMP_1X
540 
541 #define BMP280_HIGHRESOLUTION_OVERSAMP_PRESSURE BMP280_OVERSAMP_8X
542 #define BMP280_HIGHRESOLUTION_OVERSAMP_TEMPERATURE BMP280_OVERSAMP_1X
543 
544 #define BMP280_ULTRAHIGHRESOLUTION_OVERSAMP_PRESSURE BMP280_OVERSAMP_16X
545 #define BMP280_ULTRAHIGHRESOLUTION_OVERSAMP_TEMPERATURE BMP280_OVERSAMP_2X
546 /************************************************/
548 /***********************************************/
549 #define BMP280_FILTER_COEFF_OFF (0x00)
550 #define BMP280_FILTER_COEFF_2 (0x01)
551 #define BMP280_FILTER_COEFF_4 (0x02)
552 #define BMP280_FILTER_COEFF_8 (0x03)
553 #define BMP280_FILTER_COEFF_16 (0x04)
554 /************************************************/
556 /***********************************************/
557 #define T_INIT_MAX (20)
558 /* 20/16 = 1.25 ms */
559 #define T_MEASURE_PER_OSRS_MAX (37)
560 /* 37/16 = 2.3125 ms*/
561 #define T_SETUP_PRESSURE_MAX (10)
562 /* 10/16 = 0.625 ms */
563 /************************************************/
565 /***********************************************/
566 /*calibration parameters */
567 #define BMP280_TEMPERATURE_CALIB_DIG_T1_LSB_REG (0x88)
568 #define BMP280_TEMPERATURE_CALIB_DIG_T1_MSB_REG (0x89)
569 #define BMP280_TEMPERATURE_CALIB_DIG_T2_LSB_REG (0x8A)
570 #define BMP280_TEMPERATURE_CALIB_DIG_T2_MSB_REG (0x8B)
571 #define BMP280_TEMPERATURE_CALIB_DIG_T3_LSB_REG (0x8C)
572 #define BMP280_TEMPERATURE_CALIB_DIG_T3_MSB_REG (0x8D)
573 #define BMP280_PRESSURE_CALIB_DIG_P1_LSB_REG (0x8E)
574 #define BMP280_PRESSURE_CALIB_DIG_P1_MSB_REG (0x8F)
575 #define BMP280_PRESSURE_CALIB_DIG_P2_LSB_REG (0x90)
576 #define BMP280_PRESSURE_CALIB_DIG_P2_MSB_REG (0x91)
577 #define BMP280_PRESSURE_CALIB_DIG_P3_LSB_REG (0x92)
578 #define BMP280_PRESSURE_CALIB_DIG_P3_MSB_REG (0x93)
579 #define BMP280_PRESSURE_CALIB_DIG_P4_LSB_REG (0x94)
580 #define BMP280_PRESSURE_CALIB_DIG_P4_MSB_REG (0x95)
581 #define BMP280_PRESSURE_CALIB_DIG_P5_LSB_REG (0x96)
582 #define BMP280_PRESSURE_CALIB_DIG_P5_MSB_REG (0x97)
583 #define BMP280_PRESSURE_CALIB_DIG_P6_LSB_REG (0x98)
584 #define BMP280_PRESSURE_CALIB_DIG_P6_MSB_REG (0x99)
585 #define BMP280_PRESSURE_CALIB_DIG_P7_LSB_REG (0x9A)
586 #define BMP280_PRESSURE_CALIB_DIG_P7_MSB_REG (0x9B)
587 #define BMP280_PRESSURE_CALIB_DIG_P8_LSB_REG (0x9C)
588 #define BMP280_PRESSURE_CALIB_DIG_P8_MSB_REG (0x9D)
589 #define BMP280_PRESSURE_CALIB_DIG_P9_LSB_REG (0x9E)
590 #define BMP280_PRESSURE_CALIB_DIG_P9_MSB_REG (0x9F)
591 /************************************************/
593 /***********************************************/
594 #define BMP280_CHIP_ID_REG (0xD0) /*Chip ID Register */
595 #define BMP280_RST_REG (0xE0) /*Softreset Register */
596 #define BMP280_STAT_REG (0xF3) /*Status Register */
597 #define BMP280_CTRL_MEAS_REG (0xF4) /*Ctrl Measure Register */
598 #define BMP280_CONFIG_REG (0xF5) /*Configuration Register */
599 #define BMP280_PRESSURE_MSB_REG (0xF7) /*Pressure MSB Register */
600 #define BMP280_PRESSURE_LSB_REG (0xF8) /*Pressure LSB Register */
601 #define BMP280_PRESSURE_XLSB_REG (0xF9) /*Pressure XLSB Register */
602 #define BMP280_TEMPERATURE_MSB_REG (0xFA) /*Temperature MSB Reg */
603 #define BMP280_TEMPERATURE_LSB_REG (0xFB) /*Temperature LSB Reg */
604 #define BMP280_TEMPERATURE_XLSB_REG (0xFC) /*Temperature XLSB Reg */
605 /************************************************/
607 /***********************************************/
608 /* Status Register */
609 #define BMP280_STATUS_REG_MEASURING__POS (3)
610 #define BMP280_STATUS_REG_MEASURING__MSK (0x08)
611 #define BMP280_STATUS_REG_MEASURING__LEN (1)
612 #define BMP280_STATUS_REG_MEASURING__REG (BMP280_STAT_REG)
613 
614 #define BMP280_STATUS_REG_IM_UPDATE__POS (0)
615 #define BMP280_STATUS_REG_IM_UPDATE__MSK (0x01)
616 #define BMP280_STATUS_REG_IM_UPDATE__LEN (1)
617 #define BMP280_STATUS_REG_IM_UPDATE__REG (BMP280_STAT_REG)
618 /************************************************/
621 /***********************************************/
622 /* Control Measurement Register */
623 #define BMP280_CTRL_MEAS_REG_OVERSAMP_TEMPERATURE__POS (5)
624 #define BMP280_CTRL_MEAS_REG_OVERSAMP_TEMPERATURE__MSK (0xE0)
625 #define BMP280_CTRL_MEAS_REG_OVERSAMP_TEMPERATURE__LEN (3)
626 #define BMP280_CTRL_MEAS_REG_OVERSAMP_TEMPERATURE__REG \
627 (BMP280_CTRL_MEAS_REG)
628 /************************************************/
631 /***********************************************/
632 #define BMP280_CTRL_MEAS_REG_OVERSAMP_PRESSURE__POS (2)
633 #define BMP280_CTRL_MEAS_REG_OVERSAMP_PRESSURE__MSK (0x1C)
634 #define BMP280_CTRL_MEAS_REG_OVERSAMP_PRESSURE__LEN (3)
635 #define BMP280_CTRL_MEAS_REG_OVERSAMP_PRESSURE__REG \
636 (BMP280_CTRL_MEAS_REG)
637 /************************************************/
640 /***********************************************/
641 #define BMP280_CTRL_MEAS_REG_POWER_MODE__POS (0)
642 #define BMP280_CTRL_MEAS_REG_POWER_MODE__MSK (0x03)
643 #define BMP280_CTRL_MEAS_REG_POWER_MODE__LEN (2)
644 #define BMP280_CTRL_MEAS_REG_POWER_MODE__REG (BMP280_CTRL_MEAS_REG)
645 /************************************************/
648 /***********************************************/
649 /* Configuration Register */
650 #define BMP280_CONFIG_REG_STANDBY_DURN__POS (5)
651 #define BMP280_CONFIG_REG_STANDBY_DURN__MSK (0xE0)
652 #define BMP280_CONFIG_REG_STANDBY_DURN__LEN (3)
653 #define BMP280_CONFIG_REG_STANDBY_DURN__REG (BMP280_CONFIG_REG)
654 /************************************************/
657 /***********************************************/
658 #define BMP280_CONFIG_REG_FILTER__POS (2)
659 #define BMP280_CONFIG_REG_FILTER__MSK (0x1C)
660 #define BMP280_CONFIG_REG_FILTER__LEN (3)
661 #define BMP280_CONFIG_REG_FILTER__REG (BMP280_CONFIG_REG)
662 /************************************************/
665 /***********************************************/
666 #define BMP280_CONFIG_REG_SPI3_ENABLE__POS (0)
667 #define BMP280_CONFIG_REG_SPI3_ENABLE__MSK (0x01)
668 #define BMP280_CONFIG_REG_SPI3_ENABLE__LEN (1)
669 #define BMP280_CONFIG_REG_SPI3_ENABLE__REG (BMP280_CONFIG_REG)
670 /************************************************/
673 /***********************************************/
674 /* Data Register */
675 #define BMP280_PRESSURE_XLSB_REG_DATA__POS (4)
676 #define BMP280_PRESSURE_XLSB_REG_DATA__MSK (0xF0)
677 #define BMP280_PRESSURE_XLSB_REG_DATA__LEN (4)
678 #define BMP280_PRESSURE_XLSB_REG_DATA__REG (BMP280_PRESSURE_XLSB_REG)
679 
680 #define BMP280_TEMPERATURE_XLSB_REG_DATA__POS (4)
681 #define BMP280_TEMPERATURE_XLSB_REG_DATA__MSK (0xF0)
682 #define BMP280_TEMPERATURE_XLSB_REG_DATA__LEN (4)
683 #define BMP280_TEMPERATURE_XLSB_REG_DATA__REG (BMP280_TEMPERATURE_XLSB_REG)
684 /************************************************/
686 /***********************************************/
687 #define BMP280_WR_FUNC_PTR s8 (*bus_write)(u8, u8, u8 *, u8)
688 
689 #define BMP280_RD_FUNC_PTR s8 (*bus_read)(u8, u8, u8 *, u8)
690 
691 #define BMP280_MDELAY_DATA_TYPE u32
692 /****************************************************/
694 /***************************************************/
695 #define BMP280_TEMPERATURE_DATA_SIZE (3)
696 #define BMP280_PRESSURE_DATA_SIZE (3)
697 #define BMP280_DATA_FRAME_SIZE (6)
698 #define BMP280_CALIB_DATA_SIZE (24)
699 
700 #define BMP280_TEMPERATURE_MSB_DATA (0)
701 #define BMP280_TEMPERATURE_LSB_DATA (1)
702 #define BMP280_TEMPERATURE_XLSB_DATA (2)
703 
704 #define BMP280_PRESSURE_MSB_DATA (0)
705 #define BMP280_PRESSURE_LSB_DATA (1)
706 #define BMP280_PRESSURE_XLSB_DATA (2)
707 
708 #define BMP280_DATA_FRAME_PRESSURE_MSB_BYTE (0)
709 #define BMP280_DATA_FRAME_PRESSURE_LSB_BYTE (1)
710 #define BMP280_DATA_FRAME_PRESSURE_XLSB_BYTE (2)
711 #define BMP280_DATA_FRAME_TEMPERATURE_MSB_BYTE (3)
712 #define BMP280_DATA_FRAME_TEMPERATURE_LSB_BYTE (4)
713 #define BMP280_DATA_FRAME_TEMPERATURE_XLSB_BYTE (5)
714 
715 /****************************************************/
717 /***************************************************/
718 #define BMP280_TEMPERATURE_CALIB_DIG_T1_LSB (0)
719 #define BMP280_TEMPERATURE_CALIB_DIG_T1_MSB (1)
720 #define BMP280_TEMPERATURE_CALIB_DIG_T2_LSB (2)
721 #define BMP280_TEMPERATURE_CALIB_DIG_T2_MSB (3)
722 #define BMP280_TEMPERATURE_CALIB_DIG_T3_LSB (4)
723 #define BMP280_TEMPERATURE_CALIB_DIG_T3_MSB (5)
724 #define BMP280_PRESSURE_CALIB_DIG_P1_LSB (6)
725 #define BMP280_PRESSURE_CALIB_DIG_P1_MSB (7)
726 #define BMP280_PRESSURE_CALIB_DIG_P2_LSB (8)
727 #define BMP280_PRESSURE_CALIB_DIG_P2_MSB (9)
728 #define BMP280_PRESSURE_CALIB_DIG_P3_LSB (10)
729 #define BMP280_PRESSURE_CALIB_DIG_P3_MSB (11)
730 #define BMP280_PRESSURE_CALIB_DIG_P4_LSB (12)
731 #define BMP280_PRESSURE_CALIB_DIG_P4_MSB (13)
732 #define BMP280_PRESSURE_CALIB_DIG_P5_LSB (14)
733 #define BMP280_PRESSURE_CALIB_DIG_P5_MSB (15)
734 #define BMP280_PRESSURE_CALIB_DIG_P6_LSB (16)
735 #define BMP280_PRESSURE_CALIB_DIG_P6_MSB (17)
736 #define BMP280_PRESSURE_CALIB_DIG_P7_LSB (18)
737 #define BMP280_PRESSURE_CALIB_DIG_P7_MSB (19)
738 #define BMP280_PRESSURE_CALIB_DIG_P8_LSB (20)
739 #define BMP280_PRESSURE_CALIB_DIG_P8_MSB (21)
740 #define BMP280_PRESSURE_CALIB_DIG_P9_LSB (22)
741 #define BMP280_PRESSURE_CALIB_DIG_P9_MSB (23)
742 /**************************************************************/
744 /**************************************************************/
763 };
767 struct bmp280_t {
778  void (*delay_msec)(BMP280_MDELAY_DATA_TYPE);
779 };
780 /**************************************************************/
782 /**************************************************************/
783 /**************************************************************/
785 /**************************************************************/
811 BMP280_RETURN_FUNCTION_TYPE bmp280_init(struct bmp280_t *bmp280);
812 /**************************************************************/
814 /**************************************************************/
832 BMP280_RETURN_FUNCTION_TYPE bmp280_read_uncomp_temperature(
833  s32 *v_uncomp_temperature_s32);
834 /**************************************************************/
836 /**************************************************************/
852 s32 bmp280_compensate_temperature_int32(s32 v_uncomp_temperature_s32);
853 /**************************************************************/
855 /**************************************************************/
875 BMP280_RETURN_FUNCTION_TYPE bmp280_read_uncomp_pressure(
876  s32 *v_uncomp_pressure_s32);
877 /**************************************************************/
879 /**************************************************************/
896 u32 bmp280_compensate_pressure_int32(s32 v_uncomp_pressure_s32);
897 /**************************************************************/
899 /**************************************************************/
912 BMP280_RETURN_FUNCTION_TYPE bmp280_read_uncomp_pressure_temperature(
913  s32 *v_uncomp_pressure_s32, s32 *v_uncomp_temperature_s32);
914 /**************************************************************/
916 /**************************************************************/
931 BMP280_RETURN_FUNCTION_TYPE bmp280_read_pressure_temperature(
932  u32 *v_pressure_u32, s32 *v_pressure_s32);
933 /**************************************************************/
935 /**************************************************************/
961 BMP280_RETURN_FUNCTION_TYPE bmp280_get_calib_param(void);
962 /**************************************************************/
964 /**************************************************************/
990 BMP280_RETURN_FUNCTION_TYPE bmp280_get_oversamp_temperature(u8 *v_value_u8);
1016 BMP280_RETURN_FUNCTION_TYPE bmp280_set_oversamp_temperature(u8 v_value_u8);
1042 BMP280_RETURN_FUNCTION_TYPE bmp280_get_oversamp_pressure(u8 *v_value_u8);
1068 BMP280_RETURN_FUNCTION_TYPE bmp280_set_oversamp_pressure(u8 v_value_u8);
1069 /**************************************************************/
1071 /**************************************************************/
1091 BMP280_RETURN_FUNCTION_TYPE bmp280_get_power_mode(u8 *v_power_mode_u8);
1111 BMP280_RETURN_FUNCTION_TYPE bmp280_set_power_mode(u8 v_power_mode_u8);
1112 /**************************************************************/
1114 /**************************************************************/
1131 BMP280_RETURN_FUNCTION_TYPE bmp280_set_soft_rst(void);
1132 /**************************************************************/
1134 /**************************************************************/
1155 BMP280_RETURN_FUNCTION_TYPE bmp280_get_spi3(u8 *v_enable_disable_u8);
1176 BMP280_RETURN_FUNCTION_TYPE bmp280_set_spi3(u8 v_enable_disable_u8);
1177 /**************************************************************/
1179 /**************************************************************/
1201 BMP280_RETURN_FUNCTION_TYPE bmp280_get_filter(u8 *v_value_u8);
1223 BMP280_RETURN_FUNCTION_TYPE bmp280_set_filter(u8 v_value_u8);
1224 /**************************************************************/
1226 /**************************************************************/
1251 BMP280_RETURN_FUNCTION_TYPE bmp280_get_standby_durn(u8 *v_standby_durn_u8);
1284 BMP280_RETURN_FUNCTION_TYPE bmp280_set_standby_durn(u8 v_standby_durn_u8);
1285 /**************************************************************/
1287 /**************************************************************/
1308 BMP280_RETURN_FUNCTION_TYPE bmp280_set_work_mode(u8 v_work_mode_u8);
1309 /**************************************************************/
1311 /**************************************************************/
1327 BMP280_RETURN_FUNCTION_TYPE bmp280_get_forced_uncomp_pressure_temperature(
1328  s32 *v_uncomp_pressure_s32, s32 *v_uncomp_temperature_s32);
1329 /**************************************************************/
1331 /**************************************************************/
1349 BMP280_RETURN_FUNCTION_TYPE bmp280_write_register(u8 v_addr_u8,
1350  u8 *v_data_u8, u8 v_len_u8);
1368 BMP280_RETURN_FUNCTION_TYPE bmp280_read_register(u8 v_addr_u8,
1369  u8 *v_data_u8, u8 v_len_u8);
1370 /**************************************************************/
1372 /**************************************************************/
1373 #ifdef BMP280_ENABLE_FLOAT
1374 
1390 double bmp280_compensate_temperature_double(s32 v_uncomp_temperature_s32);
1391 /**************************************************************/
1393 /**************************************************************/
1410 double bmp280_compensate_pressure_double(s32 v_uncomp_pressure_s32);
1411 #endif
1412 #if defined(BMP280_ENABLE_INT64) && defined(BMP280_64BITSUPPORT_PRESENT)
1413 
1429 u32 bmp280_compensate_pressure_int64(s32 v_uncomp_pressure_s32);
1430 #endif
1431 /**************************************************************/
1433 /**************************************************************/
1447 BMP280_RETURN_FUNCTION_TYPE bmp280_compute_wait_time(u8
1448  *v_delaytime_u8r);
1449 #endif
BMP280_RETURN_FUNCTION_TYPE bmp280_get_oversamp_temperature(u8 *v_value_u8)
This API is used to get the temperature oversampling setting in the register 0xF4 bits from 5 to 7...
Definition: bmp280.c:583
BMP280_RETURN_FUNCTION_TYPE bmp280_set_filter(u8 v_value_u8)
This API is used to write filter setting in the register 0xF5 bit 3 and 4.
Definition: bmp280.c:1010
BMP280_RETURN_FUNCTION_TYPE bmp280_set_soft_rst(void)
Used to reset the sensor The value 0xB6 is written to the 0xE0 register the device is reset using the...
Definition: bmp280.c:852
BMP280_RETURN_FUNCTION_TYPE bmp280_set_oversamp_pressure(u8 v_value_u8)
This API is used to set the pressure oversampling setting in the register 0xF4 bits from 2 to 4...
Definition: bmp280.c:725
BMP280_RETURN_FUNCTION_TYPE bmp280_read_uncomp_temperature(s32 *v_uncomp_temperature_s32)
This API is used to read uncompensated temperature in the registers 0xFA, 0xFB and 0xFC...
Definition: bmp280.c:139
u8 dev_addr
Definition: bmp280.h:771
BMP280_RETURN_FUNCTION_TYPE bmp280_set_standby_durn(u8 v_standby_durn_u8)
This API used to Read the standby duration time from the sensor in the register 0xF5 bit 5 to 7...
Definition: bmp280.c:1111
unsigned short int u16
Definition: bmp280.h:283
unsigned int u32
Definition: bmp280.h:284
struct bmp280_calib_param_t calib_param
Definition: bmp280.h:768
void(* delay_msec)(BMP280_MDELAY_DATA_TYPE)
Definition: bmp280.h:778
u8 oversamp_temperature
Definition: bmp280.h:773
This structure holds all device specific calibration parameters.
Definition: bmp280.h:748
BMP280_RETURN_FUNCTION_TYPE bmp280_get_filter(u8 *v_value_u8)
This API is used to reads filter setting in the register 0xF5 bit 3 and 4.
Definition: bmp280.c:971
signed int s32
Definition: bmp280.h:278
BMP280_RETURN_FUNCTION_TYPE bmp280_get_forced_uncomp_pressure_temperature(s32 *v_uncomp_pressure_s32, s32 *v_uncomp_temperature_s32)
This API used to read both uncompensated pressure and temperature in forced mode. ...
Definition: bmp280.c:1236
double bmp280_compensate_temperature_double(s32 v_uncomp_temperature_s32)
This API used to read actual temperature from uncompensated temperature.
Definition: bmp280.c:1343
BMP280_RD_FUNC_PTR
Definition: bmp280.h:777
BMP280_RETURN_FUNCTION_TYPE bmp280_get_calib_param(void)
This API is used to calibration parameters used for calculation in the registers. ...
Definition: bmp280.c:473
BMP280_RETURN_FUNCTION_TYPE bmp280_set_power_mode(u8 v_power_mode_u8)
This API used to set the Operational Mode from the sensor in the register 0xF4 bit 0 and 1...
Definition: bmp280.c:809
signed short int s16
Definition: bmp280.h:277
s32 bmp280_compensate_temperature_int32(s32 v_uncomp_temperature_s32)
Reads actual temperature from uncompensated temperature.
Definition: bmp280.c:185
unsigned char u8
Definition: bmp280.h:282
BMP280_RETURN_FUNCTION_TYPE bmp280_get_oversamp_pressure(u8 *v_value_u8)
This API is used to get the pressure oversampling setting in the register 0xF4 bits from 2 to 4...
Definition: bmp280.c:680
BMP280_RETURN_FUNCTION_TYPE bmp280_read_uncomp_pressure(s32 *v_uncomp_pressure_s32)
This API is used to read uncompensated pressure. in the registers 0xF7, 0xF8 and 0xF9.
Definition: bmp280.c:235
BMP280_WR_FUNC_PTR
Definition: bmp280.h:776
BMP280_RETURN_FUNCTION_TYPE bmp280_set_oversamp_temperature(u8 v_value_u8)
This API is used to set the temperature oversampling setting in the register 0xF4 bits from 5 to 7...
Definition: bmp280.c:628
u8 oversamp_pressure
Definition: bmp280.h:774
BMP280_RETURN_FUNCTION_TYPE bmp280_read_uncomp_pressure_temperature(s32 *v_uncomp_pressure_s32, s32 *v_uncomp_temperature_s32)
reads uncompensated pressure and temperature
Definition: bmp280.c:364
BMP280_RETURN_FUNCTION_TYPE bmp280_get_power_mode(u8 *v_power_mode_u8)
This API used to get the Operational Mode from the sensor in the register 0xF4 bit 0 and 1...
Definition: bmp280.c:772
BMP280_RETURN_FUNCTION_TYPE bmp280_write_register(u8 v_addr_u8, u8 *v_data_u8, u8 v_len_u8)
This API write the data to the given register.
Definition: bmp280.c:1281
u8 chip_id
Definition: bmp280.h:770
BMP280_RETURN_FUNCTION_TYPE bmp280_get_standby_durn(u8 *v_standby_durn_u8)
This API used to Read the standby duration time from the sensor in the register 0xF5 bit 5 to 7...
Definition: bmp280.c:1058
BMP280_RETURN_FUNCTION_TYPE bmp280_init(struct bmp280_t *bmp280)
This function is used for initialize the bus read and bus write functions and assign the chip id and ...
Definition: bmp280.c:85
u32 bmp280_compensate_pressure_int64(s32 v_uncomp_pressure_s32)
This API used to read actual pressure from uncompensated pressure.
Definition: bmp280.c:1432
BMP280_RETURN_FUNCTION_TYPE bmp280_compute_wait_time(u8 *v_delaytime_u8r)
Computing waiting time for sensor data read.
Definition: bmp280.c:1495
BMP280_RETURN_FUNCTION_TYPE bmp280_set_spi3(u8 v_enable_disable_u8)
This API used to set the sensor SPI mode(communication type) in the register 0xF5 bit 0...
Definition: bmp280.c:925
signed long long int s64
Definition: bmp280.h:279
BMP280_RETURN_FUNCTION_TYPE bmp280_get_spi3(u8 *v_enable_disable_u8)
This API used to get the sensor SPI mode(communication type) in the register 0xF5 bit 0...
Definition: bmp280.c:888
BMP280_RETURN_FUNCTION_TYPE bmp280_set_work_mode(u8 v_work_mode_u8)
This API is used to write the working mode of the sensor.
Definition: bmp280.c:1157
BMP280_RETURN_FUNCTION_TYPE bmp280_read_pressure_temperature(u32 *v_pressure_u32, s32 *v_pressure_s32)
This API reads the true pressure and temperature.
Definition: bmp280.c:425
unsigned long long int u64
Definition: bmp280.h:285
double bmp280_compensate_pressure_double(s32 v_uncomp_pressure_s32)
Reads actual pressure from uncompensated pressure and returns pressure in Pa as double.
Definition: bmp280.c:1381
This structure holds BMP280 initialization parameters.
Definition: bmp280.h:767
signed char s8
Definition: bmp280.h:276
BMP280_RETURN_FUNCTION_TYPE bmp280_read_register(u8 v_addr_u8, u8 *v_data_u8, u8 v_len_u8)
This API reads the data from the given register.
Definition: bmp280.c:1312
u32 bmp280_compensate_pressure_int32(s32 v_uncomp_pressure_s32)
Reads actual pressure from uncompensated pressure and returns the value in Pascal(Pa) ...
Definition: bmp280.c:280