88 BMP280_RETURN_FUNCTION_TYPE com_rslt = ERROR;
89 u8 v_data_u8 = BMP280_INIT_VALUE;
90 u8 v_chip_id_read_count = BMP280_CHIP_ID_READ_COUNT;
94 while (v_chip_id_read_count > 0) {
96 com_rslt = p_bmp280->BMP280_BUS_READ_FUNC(p_bmp280->
dev_addr,
97 BMP280_CHIP_ID_REG, &v_data_u8,
98 BMP280_GEN_READ_WRITE_DATA_LENGTH);
100 if ((v_data_u8 == BMP280_CHIP_ID1)
101 || (v_data_u8 == BMP280_CHIP_ID2)
102 || (v_data_u8 == BMP280_CHIP_ID3))
104 v_chip_id_read_count--;
107 p_bmp280->
delay_msec(BMP280_REGISTER_READ_DELAY);
113 com_rslt = (v_chip_id_read_count == BMP280_INIT_VALUE) ?
114 BMP280_CHIP_ID_READ_FAIL : BMP280_CHIP_ID_READ_SUCCESS;
116 if (com_rslt == BMP280_CHIP_ID_READ_SUCCESS) {
140 s32 *v_uncomp_temperature_s32)
143 BMP280_RETURN_FUNCTION_TYPE com_rslt = ERROR;
149 u8 a_data_u8r[BMP280_TEMPERATURE_DATA_SIZE] = {BMP280_INIT_VALUE,
150 BMP280_INIT_VALUE, BMP280_INIT_VALUE};
152 if (p_bmp280 == BMP280_NULL) {
153 com_rslt = E_BMP280_NULL_PTR;
156 com_rslt = p_bmp280->BMP280_BUS_READ_FUNC(p_bmp280->
dev_addr,
157 BMP280_TEMPERATURE_MSB_REG, a_data_u8r,
158 BMP280_TEMPERATURE_DATA_LENGTH);
159 *v_uncomp_temperature_s32 = (
s32)((((
u32)(
160 a_data_u8r[BMP280_TEMPERATURE_MSB_DATA]))
161 << BMP280_SHIFT_BIT_POSITION_BY_12_BITS)
163 a_data_u8r[BMP280_TEMPERATURE_LSB_DATA]))
164 << BMP280_SHIFT_BIT_POSITION_BY_04_BITS)
165 | ((
u32)a_data_u8r[BMP280_TEMPERATURE_XLSB_DATA]
166 >> BMP280_SHIFT_BIT_POSITION_BY_04_BITS));
187 s32 v_x1_u32r = BMP280_INIT_VALUE;
188 s32 v_x2_u32r = BMP280_INIT_VALUE;
189 s32 temperature = BMP280_INIT_VALUE;
192 v_x1_u32r = ((((v_uncomp_temperature_s32
193 >> BMP280_SHIFT_BIT_POSITION_BY_03_BITS)
195 << BMP280_SHIFT_BIT_POSITION_BY_01_BIT)))
197 >> BMP280_SHIFT_BIT_POSITION_BY_11_BITS;
199 v_x2_u32r = (((((v_uncomp_temperature_s32
200 >> BMP280_SHIFT_BIT_POSITION_BY_04_BITS)
202 * ((v_uncomp_temperature_s32
203 >> BMP280_SHIFT_BIT_POSITION_BY_04_BITS)
205 >> BMP280_SHIFT_BIT_POSITION_BY_12_BITS)
207 >> BMP280_SHIFT_BIT_POSITION_BY_14_BITS;
212 >> BMP280_SHIFT_BIT_POSITION_BY_08_BITS;
236 s32 *v_uncomp_pressure_s32)
239 BMP280_RETURN_FUNCTION_TYPE com_rslt = ERROR;
245 u8 a_data_u8[BMP280_PRESSURE_DATA_SIZE] = {BMP280_INIT_VALUE,
246 BMP280_INIT_VALUE, BMP280_INIT_VALUE};
248 if (p_bmp280 == BMP280_NULL) {
249 com_rslt = E_BMP280_NULL_PTR;
251 com_rslt = p_bmp280->BMP280_BUS_READ_FUNC(p_bmp280->
dev_addr,
252 BMP280_PRESSURE_MSB_REG, a_data_u8,
253 BMP280_PRESSURE_DATA_LENGTH);
254 *v_uncomp_pressure_s32 = (
s32)((((
u32)(
255 a_data_u8[BMP280_PRESSURE_MSB_DATA]))
256 << BMP280_SHIFT_BIT_POSITION_BY_12_BITS)
257 | (((
u32)(a_data_u8[BMP280_PRESSURE_LSB_DATA]))
258 << BMP280_SHIFT_BIT_POSITION_BY_04_BITS)
259 | ((
u32)a_data_u8[BMP280_PRESSURE_XLSB_DATA]
260 >> BMP280_SHIFT_BIT_POSITION_BY_04_BITS));
282 s32 v_x1_u32r = BMP280_INIT_VALUE;
283 s32 v_x2_u32r = BMP280_INIT_VALUE;
284 u32 v_pressure_u32 = BMP280_INIT_VALUE;
287 >> BMP280_SHIFT_BIT_POSITION_BY_01_BIT) - (
s32)64000;
289 v_x2_u32r = (((v_x1_u32r >> BMP280_SHIFT_BIT_POSITION_BY_02_BITS)
290 * (v_x1_u32r >> BMP280_SHIFT_BIT_POSITION_BY_02_BITS))
291 >> BMP280_SHIFT_BIT_POSITION_BY_11_BITS)
293 v_x2_u32r = v_x2_u32r + ((v_x1_u32r *
295 << BMP280_SHIFT_BIT_POSITION_BY_01_BIT);
296 v_x2_u32r = (v_x2_u32r >> BMP280_SHIFT_BIT_POSITION_BY_02_BITS)
298 << BMP280_SHIFT_BIT_POSITION_BY_16_BITS);
302 >> BMP280_SHIFT_BIT_POSITION_BY_02_BITS) * (v_x1_u32r
303 >> BMP280_SHIFT_BIT_POSITION_BY_02_BITS))
304 >> BMP280_SHIFT_BIT_POSITION_BY_13_BITS))
305 >> BMP280_SHIFT_BIT_POSITION_BY_03_BITS)
308 >> BMP280_SHIFT_BIT_POSITION_BY_01_BIT))
309 >> BMP280_SHIFT_BIT_POSITION_BY_18_BITS;
310 v_x1_u32r = ((((32768 + v_x1_u32r))
312 >> BMP280_SHIFT_BIT_POSITION_BY_15_BITS);
314 v_pressure_u32 = (((
u32)(((
s32)1048576) - v_uncomp_pressure_s32)
315 - (v_x2_u32r >> BMP280_SHIFT_BIT_POSITION_BY_12_BITS)))
318 if (v_pressure_u32 < 0x80000000)
320 if (v_x1_u32r != BMP280_INIT_VALUE)
321 v_pressure_u32 = (v_pressure_u32
322 << BMP280_SHIFT_BIT_POSITION_BY_01_BIT)
325 return BMP280_INVALID_DATA;
328 if (v_x1_u32r != BMP280_INIT_VALUE)
329 v_pressure_u32 = (v_pressure_u32 / (
u32)v_x1_u32r) * 2;
331 return BMP280_INVALID_DATA;
335 >> BMP280_SHIFT_BIT_POSITION_BY_03_BITS)
337 >> BMP280_SHIFT_BIT_POSITION_BY_03_BITS))
338 >> BMP280_SHIFT_BIT_POSITION_BY_13_BITS)))
339 >> BMP280_SHIFT_BIT_POSITION_BY_12_BITS;
341 v_x2_u32r = (((
s32)(v_pressure_u32 >>
342 BMP280_SHIFT_BIT_POSITION_BY_02_BITS))
344 >> BMP280_SHIFT_BIT_POSITION_BY_13_BITS;
346 v_pressure_u32 = (
u32)((
s32)v_pressure_u32 + ((v_x1_u32r + v_x2_u32r
348 >> BMP280_SHIFT_BIT_POSITION_BY_04_BITS));
350 return v_pressure_u32;
365 s32 *v_uncomp_pressure_s32,
s32 *v_uncomp_temperature_s32)
368 BMP280_RETURN_FUNCTION_TYPE com_rslt = ERROR;
377 u8 a_data_u8[BMP280_ALL_DATA_FRAME_LENGTH] = {BMP280_INIT_VALUE,
378 BMP280_INIT_VALUE, BMP280_INIT_VALUE, BMP280_INIT_VALUE,
379 BMP280_INIT_VALUE, BMP280_INIT_VALUE};
381 if (p_bmp280 == BMP280_NULL) {
382 com_rslt = E_BMP280_NULL_PTR;
384 com_rslt = p_bmp280->BMP280_BUS_READ_FUNC(p_bmp280->
dev_addr,
385 BMP280_PRESSURE_MSB_REG, a_data_u8,
386 BMP280_DATA_FRAME_SIZE);
388 *v_uncomp_pressure_s32 = (
s32)((((
u32)(
389 a_data_u8[BMP280_DATA_FRAME_PRESSURE_MSB_BYTE]))
390 << BMP280_SHIFT_BIT_POSITION_BY_12_BITS)
392 a_data_u8[BMP280_DATA_FRAME_PRESSURE_LSB_BYTE]))
393 << BMP280_SHIFT_BIT_POSITION_BY_04_BITS)
395 BMP280_DATA_FRAME_PRESSURE_XLSB_BYTE]
396 >> BMP280_SHIFT_BIT_POSITION_BY_04_BITS));
399 *v_uncomp_temperature_s32 = (
s32)((((
u32)(a_data_u8[
400 BMP280_DATA_FRAME_TEMPERATURE_MSB_BYTE]))
401 << BMP280_SHIFT_BIT_POSITION_BY_12_BITS)
403 BMP280_DATA_FRAME_TEMPERATURE_LSB_BYTE]))
404 << BMP280_SHIFT_BIT_POSITION_BY_04_BITS)
406 BMP280_DATA_FRAME_TEMPERATURE_XLSB_BYTE]
407 >> BMP280_SHIFT_BIT_POSITION_BY_04_BITS));
426 u32 *v_pressure_u32,
s32 *v_temperature_s32)
429 BMP280_RETURN_FUNCTION_TYPE com_rslt = ERROR;
430 s32 v_uncomp_pressure_s32 = BMP280_INIT_VALUE;
431 s32 v_uncomp_temperature_s32 = BMP280_INIT_VALUE;
433 if (p_bmp280 == BMP280_NULL) {
434 com_rslt = E_BMP280_NULL_PTR;
438 &v_uncomp_pressure_s32,
439 &v_uncomp_temperature_s32);
442 v_uncomp_temperature_s32);
444 v_uncomp_pressure_s32);
476 BMP280_RETURN_FUNCTION_TYPE com_rslt = ERROR;
477 u8 a_data_u8[BMP280_CALIB_DATA_SIZE] = {BMP280_INIT_VALUE,
478 BMP280_INIT_VALUE, BMP280_INIT_VALUE, BMP280_INIT_VALUE,
479 BMP280_INIT_VALUE, BMP280_INIT_VALUE, BMP280_INIT_VALUE,
480 BMP280_INIT_VALUE, BMP280_INIT_VALUE, BMP280_INIT_VALUE,
481 BMP280_INIT_VALUE, BMP280_INIT_VALUE, BMP280_INIT_VALUE,
482 BMP280_INIT_VALUE, BMP280_INIT_VALUE, BMP280_INIT_VALUE,
483 BMP280_INIT_VALUE, BMP280_INIT_VALUE, BMP280_INIT_VALUE,
484 BMP280_INIT_VALUE, BMP280_INIT_VALUE, BMP280_INIT_VALUE,
485 BMP280_INIT_VALUE, BMP280_INIT_VALUE};
487 if (p_bmp280 == BMP280_NULL) {
488 com_rslt = E_BMP280_NULL_PTR;
490 com_rslt = p_bmp280->BMP280_BUS_READ_FUNC(p_bmp280->
dev_addr,
491 BMP280_TEMPERATURE_CALIB_DIG_T1_LSB_REG,
493 BMP280_PRESSURE_TEMPERATURE_CALIB_DATA_LENGTH);
496 BMP280_TEMPERATURE_CALIB_DIG_T1_MSB]))
497 << BMP280_SHIFT_BIT_POSITION_BY_08_BITS)
499 BMP280_TEMPERATURE_CALIB_DIG_T1_LSB]);
501 BMP280_TEMPERATURE_CALIB_DIG_T2_MSB]))
502 << BMP280_SHIFT_BIT_POSITION_BY_08_BITS)
504 BMP280_TEMPERATURE_CALIB_DIG_T2_LSB]);
506 BMP280_TEMPERATURE_CALIB_DIG_T3_MSB]))
507 << BMP280_SHIFT_BIT_POSITION_BY_08_BITS)
509 BMP280_TEMPERATURE_CALIB_DIG_T3_LSB]);
511 BMP280_PRESSURE_CALIB_DIG_P1_MSB]))
512 << BMP280_SHIFT_BIT_POSITION_BY_08_BITS)
514 BMP280_PRESSURE_CALIB_DIG_P1_LSB]);
516 BMP280_PRESSURE_CALIB_DIG_P2_MSB]))
517 << BMP280_SHIFT_BIT_POSITION_BY_08_BITS)
519 BMP280_PRESSURE_CALIB_DIG_P2_LSB]);
521 BMP280_PRESSURE_CALIB_DIG_P3_MSB]))
522 << BMP280_SHIFT_BIT_POSITION_BY_08_BITS)
524 BMP280_PRESSURE_CALIB_DIG_P3_LSB]);
526 BMP280_PRESSURE_CALIB_DIG_P4_MSB]))
527 << BMP280_SHIFT_BIT_POSITION_BY_08_BITS)
529 BMP280_PRESSURE_CALIB_DIG_P4_LSB]);
531 BMP280_PRESSURE_CALIB_DIG_P5_MSB]))
532 << BMP280_SHIFT_BIT_POSITION_BY_08_BITS)
534 BMP280_PRESSURE_CALIB_DIG_P5_LSB]);
536 BMP280_PRESSURE_CALIB_DIG_P6_MSB]))
537 << BMP280_SHIFT_BIT_POSITION_BY_08_BITS)
539 BMP280_PRESSURE_CALIB_DIG_P6_LSB]);
541 BMP280_PRESSURE_CALIB_DIG_P7_MSB]))
542 << BMP280_SHIFT_BIT_POSITION_BY_08_BITS)
544 BMP280_PRESSURE_CALIB_DIG_P7_LSB]);
546 BMP280_PRESSURE_CALIB_DIG_P8_MSB]))
547 << BMP280_SHIFT_BIT_POSITION_BY_08_BITS)
549 BMP280_PRESSURE_CALIB_DIG_P8_LSB]);
551 BMP280_PRESSURE_CALIB_DIG_P9_MSB]))
552 << BMP280_SHIFT_BIT_POSITION_BY_08_BITS)
554 BMP280_PRESSURE_CALIB_DIG_P9_LSB]);
586 BMP280_RETURN_FUNCTION_TYPE com_rslt = ERROR;
587 u8 v_data_u8 = BMP280_INIT_VALUE;
589 if (p_bmp280 == BMP280_NULL) {
590 com_rslt = E_BMP280_NULL_PTR;
593 com_rslt = p_bmp280->BMP280_BUS_READ_FUNC(p_bmp280->
dev_addr,
594 BMP280_CTRL_MEAS_REG_OVERSAMP_TEMPERATURE__REG,
595 &v_data_u8, BMP280_GEN_READ_WRITE_DATA_LENGTH);
596 *v_value_u8 = BMP280_GET_BITSLICE(v_data_u8,
597 BMP280_CTRL_MEAS_REG_OVERSAMP_TEMPERATURE);
631 BMP280_RETURN_FUNCTION_TYPE com_rslt = ERROR;
632 u8 v_data_u8 = BMP280_INIT_VALUE;
634 if (p_bmp280 == BMP280_NULL) {
635 com_rslt = E_BMP280_NULL_PTR;
637 com_rslt = p_bmp280->BMP280_BUS_READ_FUNC(p_bmp280->
dev_addr,
638 BMP280_CTRL_MEAS_REG_OVERSAMP_TEMPERATURE__REG,
639 &v_data_u8, BMP280_GEN_READ_WRITE_DATA_LENGTH);
640 if (com_rslt == SUCCESS) {
642 v_data_u8 = BMP280_SET_BITSLICE(v_data_u8,
643 BMP280_CTRL_MEAS_REG_OVERSAMP_TEMPERATURE,
645 com_rslt += p_bmp280->BMP280_BUS_WRITE_FUNC(
647 BMP280_CTRL_MEAS_REG_OVERSAMP_TEMPERATURE__REG,
649 BMP280_GEN_READ_WRITE_DATA_LENGTH);
683 BMP280_RETURN_FUNCTION_TYPE com_rslt = ERROR;
684 u8 v_data_u8 = BMP280_INIT_VALUE;
686 if (p_bmp280 == BMP280_NULL) {
687 com_rslt = E_BMP280_NULL_PTR;
690 com_rslt = p_bmp280->BMP280_BUS_READ_FUNC(p_bmp280->
dev_addr,
691 BMP280_CTRL_MEAS_REG_OVERSAMP_PRESSURE__REG,
692 &v_data_u8, BMP280_GEN_READ_WRITE_DATA_LENGTH);
693 *v_value_u8 = BMP280_GET_BITSLICE(v_data_u8,
694 BMP280_CTRL_MEAS_REG_OVERSAMP_PRESSURE);
728 BMP280_RETURN_FUNCTION_TYPE com_rslt = ERROR;
729 u8 v_data_u8 = BMP280_INIT_VALUE;
731 if (p_bmp280 == BMP280_NULL) {
732 com_rslt = E_BMP280_NULL_PTR;
734 com_rslt = p_bmp280->BMP280_BUS_READ_FUNC(p_bmp280->
dev_addr,
735 BMP280_CTRL_MEAS_REG_OVERSAMP_PRESSURE__REG,
736 &v_data_u8, BMP280_GEN_READ_WRITE_DATA_LENGTH);
737 if (com_rslt == SUCCESS) {
739 v_data_u8 = BMP280_SET_BITSLICE(v_data_u8,
740 BMP280_CTRL_MEAS_REG_OVERSAMP_PRESSURE,
742 com_rslt += p_bmp280->BMP280_BUS_WRITE_FUNC(
744 BMP280_CTRL_MEAS_REG_OVERSAMP_PRESSURE__REG,
746 BMP280_GEN_READ_WRITE_DATA_LENGTH);
775 BMP280_RETURN_FUNCTION_TYPE com_rslt = ERROR;
776 u8 v_mode_u8 = BMP280_INIT_VALUE;
778 if (p_bmp280 == BMP280_NULL) {
779 com_rslt = E_BMP280_NULL_PTR;
782 com_rslt = p_bmp280->BMP280_BUS_READ_FUNC(p_bmp280->
dev_addr,
783 BMP280_CTRL_MEAS_REG_POWER_MODE__REG,
784 &v_mode_u8, BMP280_GEN_READ_WRITE_DATA_LENGTH);
785 *v_power_mode_u8 = BMP280_GET_BITSLICE(v_mode_u8,
786 BMP280_CTRL_MEAS_REG_POWER_MODE);
812 BMP280_RETURN_FUNCTION_TYPE com_rslt = ERROR;
813 u8 v_mode_u8 = BMP280_INIT_VALUE;
815 if (p_bmp280 == BMP280_NULL) {
816 com_rslt = E_BMP280_NULL_PTR;
818 if (v_power_mode_u8 <= BMP280_NORMAL_MODE) {
821 << BMP280_SHIFT_BIT_POSITION_BY_05_BITS)
823 << BMP280_SHIFT_BIT_POSITION_BY_02_BITS)
825 com_rslt = p_bmp280->BMP280_BUS_WRITE_FUNC(
827 BMP280_CTRL_MEAS_REG_POWER_MODE__REG,
829 BMP280_GEN_READ_WRITE_DATA_LENGTH);
831 com_rslt = E_BMP280_OUT_OF_RANGE;
855 BMP280_RETURN_FUNCTION_TYPE com_rslt = ERROR;
856 u8 v_data_u8 = BMP280_SOFT_RESET_CODE;
858 if (p_bmp280 == BMP280_NULL) {
859 com_rslt = E_BMP280_NULL_PTR;
862 com_rslt = p_bmp280->BMP280_BUS_WRITE_FUNC(p_bmp280->
dev_addr,
863 BMP280_RST_REG, &v_data_u8,
864 BMP280_GEN_READ_WRITE_DATA_LENGTH);
891 BMP280_RETURN_FUNCTION_TYPE com_rslt = ERROR;
892 u8 v_data_u8 = BMP280_INIT_VALUE;
894 if (p_bmp280 == BMP280_NULL) {
895 com_rslt = E_BMP280_NULL_PTR;
897 com_rslt = p_bmp280->BMP280_BUS_READ_FUNC(p_bmp280->
dev_addr,
898 BMP280_CONFIG_REG_SPI3_ENABLE__REG, &v_data_u8,
899 BMP280_GEN_READ_WRITE_DATA_LENGTH);
900 *v_enable_disable_u8 = BMP280_GET_BITSLICE(v_data_u8,
901 BMP280_CONFIG_REG_SPI3_ENABLE);
928 BMP280_RETURN_FUNCTION_TYPE com_rslt = ERROR;
929 u8 v_data_u8 = BMP280_INIT_VALUE;
931 if (p_bmp280 == BMP280_NULL) {
932 com_rslt = E_BMP280_NULL_PTR;
934 com_rslt = p_bmp280->BMP280_BUS_READ_FUNC(p_bmp280->
dev_addr,
935 BMP280_CONFIG_REG_SPI3_ENABLE__REG, &v_data_u8,
936 BMP280_GEN_READ_WRITE_DATA_LENGTH);
937 if (com_rslt == SUCCESS) {
938 v_data_u8 = BMP280_SET_BITSLICE(v_data_u8,
939 BMP280_CONFIG_REG_SPI3_ENABLE,
940 v_enable_disable_u8);
941 com_rslt += p_bmp280->BMP280_BUS_WRITE_FUNC(
943 BMP280_CONFIG_REG_SPI3_ENABLE__REG,
945 BMP280_GEN_READ_WRITE_DATA_LENGTH);
974 BMP280_RETURN_FUNCTION_TYPE com_rslt = ERROR;
975 u8 v_data_u8 = BMP280_INIT_VALUE;
977 if (p_bmp280 == BMP280_NULL) {
978 com_rslt = E_BMP280_NULL_PTR;
981 com_rslt = p_bmp280->BMP280_BUS_READ_FUNC(p_bmp280->
dev_addr,
982 BMP280_CONFIG_REG_FILTER__REG, &v_data_u8,
983 BMP280_GEN_READ_WRITE_DATA_LENGTH);
984 *v_value_u8 = BMP280_GET_BITSLICE(v_data_u8,
985 BMP280_CONFIG_REG_FILTER);
1012 BMP280_RETURN_FUNCTION_TYPE com_rslt = SUCCESS;
1013 u8 v_data_u8 = BMP280_INIT_VALUE;
1015 if (p_bmp280 == BMP280_NULL) {
1016 com_rslt = E_BMP280_NULL_PTR;
1019 com_rslt = p_bmp280->BMP280_BUS_READ_FUNC(p_bmp280->
dev_addr,
1020 BMP280_CONFIG_REG_FILTER__REG, &v_data_u8,
1021 BMP280_GEN_READ_WRITE_DATA_LENGTH);
1022 if (com_rslt == SUCCESS) {
1023 v_data_u8 = BMP280_SET_BITSLICE(v_data_u8,
1024 BMP280_CONFIG_REG_FILTER, v_value_u8);
1025 com_rslt += p_bmp280->BMP280_BUS_WRITE_FUNC(
1027 BMP280_CONFIG_REG_FILTER__REG,
1029 BMP280_GEN_READ_WRITE_DATA_LENGTH);
1061 BMP280_RETURN_FUNCTION_TYPE com_rslt = ERROR;
1062 u8 v_data_u8 = BMP280_INIT_VALUE;
1064 if (p_bmp280 == BMP280_NULL) {
1065 com_rslt = E_BMP280_NULL_PTR;
1068 com_rslt = p_bmp280->BMP280_BUS_READ_FUNC(p_bmp280->
dev_addr,
1069 BMP280_CONFIG_REG_STANDBY_DURN__REG, &v_data_u8,
1070 BMP280_GEN_READ_WRITE_DATA_LENGTH);
1071 *v_standby_durn_u8 = BMP280_GET_BITSLICE(v_data_u8,
1072 BMP280_CONFIG_REG_STANDBY_DURN);
1114 BMP280_RETURN_FUNCTION_TYPE com_rslt = ERROR;
1115 u8 v_data_u8 = BMP280_INIT_VALUE;
1117 if (p_bmp280 == BMP280_NULL) {
1118 com_rslt = E_BMP280_NULL_PTR;
1121 com_rslt = p_bmp280->BMP280_BUS_READ_FUNC(p_bmp280->
dev_addr,
1122 BMP280_CONFIG_REG_STANDBY_DURN__REG, &v_data_u8,
1123 BMP280_GEN_READ_WRITE_DATA_LENGTH);
1124 if (com_rslt == SUCCESS) {
1125 v_data_u8 = BMP280_SET_BITSLICE(v_data_u8,
1126 BMP280_CONFIG_REG_STANDBY_DURN,
1128 com_rslt += p_bmp280->BMP280_BUS_WRITE_FUNC(
1130 BMP280_CONFIG_REG_STANDBY_DURN__REG,
1132 BMP280_GEN_READ_WRITE_DATA_LENGTH);
1160 BMP280_RETURN_FUNCTION_TYPE com_rslt = ERROR;
1161 u8 v_data_u8 = BMP280_INIT_VALUE;
1163 if (p_bmp280 == BMP280_NULL) {
1164 com_rslt = E_BMP280_NULL_PTR;
1166 if (v_work_mode_u8 <= BMP280_ULTRA_HIGH_RESOLUTION_MODE) {
1167 com_rslt = p_bmp280->BMP280_BUS_READ_FUNC(
1169 BMP280_CTRL_MEAS_REG, &v_data_u8,
1170 BMP280_GEN_READ_WRITE_DATA_LENGTH);
1171 if (com_rslt == SUCCESS) {
1172 switch (v_work_mode_u8) {
1174 case BMP280_ULTRA_LOW_POWER_MODE:
1176 BMP280_ULTRALOWPOWER_OVERSAMP_TEMPERATURE;
1178 BMP280_ULTRALOWPOWER_OVERSAMP_PRESSURE;
1180 case BMP280_LOW_POWER_MODE:
1182 BMP280_LOWPOWER_OVERSAMP_TEMPERATURE;
1184 BMP280_LOWPOWER_OVERSAMP_PRESSURE;
1186 case BMP280_STANDARD_RESOLUTION_MODE:
1188 BMP280_STANDARDRESOLUTION_OVERSAMP_TEMPERATURE;
1190 BMP280_STANDARDRESOLUTION_OVERSAMP_PRESSURE;
1192 case BMP280_HIGH_RESOLUTION_MODE:
1194 BMP280_HIGHRESOLUTION_OVERSAMP_TEMPERATURE;
1196 BMP280_HIGHRESOLUTION_OVERSAMP_PRESSURE;
1198 case BMP280_ULTRA_HIGH_RESOLUTION_MODE:
1200 BMP280_ULTRAHIGHRESOLUTION_OVERSAMP_TEMPERATURE;
1202 BMP280_ULTRAHIGHRESOLUTION_OVERSAMP_PRESSURE;
1205 v_data_u8 = BMP280_SET_BITSLICE(v_data_u8,
1206 BMP280_CTRL_MEAS_REG_OVERSAMP_TEMPERATURE,
1208 v_data_u8 = BMP280_SET_BITSLICE(v_data_u8,
1209 BMP280_CTRL_MEAS_REG_OVERSAMP_PRESSURE,
1211 com_rslt += p_bmp280->BMP280_BUS_WRITE_FUNC(
1212 p_bmp280->
dev_addr, BMP280_CTRL_MEAS_REG,
1213 &v_data_u8, BMP280_GEN_READ_WRITE_DATA_LENGTH);
1216 com_rslt = E_BMP280_OUT_OF_RANGE;
1237 s32 *v_uncomp_pressure_s32,
s32 *v_uncomp_temperature_s32)
1240 BMP280_RETURN_FUNCTION_TYPE com_rslt = ERROR;
1241 u8 v_data_u8 = BMP280_INIT_VALUE;
1242 u8 v_waittime_u8 = BMP280_INIT_VALUE;
1244 if (p_bmp280 == BMP280_NULL) {
1245 com_rslt = E_BMP280_NULL_PTR;
1249 << BMP280_SHIFT_BIT_POSITION_BY_05_BITS)
1251 << BMP280_SHIFT_BIT_POSITION_BY_02_BITS)
1252 + BMP280_FORCED_MODE;
1253 com_rslt = p_bmp280->BMP280_BUS_WRITE_FUNC(p_bmp280->
dev_addr,
1254 BMP280_CTRL_MEAS_REG, &v_data_u8,
1255 BMP280_GEN_READ_WRITE_DATA_LENGTH);
1259 v_uncomp_pressure_s32,
1260 v_uncomp_temperature_s32);
1285 BMP280_RETURN_FUNCTION_TYPE com_rslt = ERROR;
1287 if (p_bmp280 == BMP280_NULL) {
1288 com_rslt = E_BMP280_NULL_PTR;
1290 com_rslt = p_bmp280->BMP280_BUS_WRITE_FUNC(p_bmp280->
dev_addr,
1291 v_addr_u8, v_data_u8, v_len_u8);
1316 BMP280_RETURN_FUNCTION_TYPE com_rslt = ERROR;
1318 if (p_bmp280 == BMP280_NULL) {
1319 com_rslt = E_BMP280_NULL_PTR;
1321 com_rslt = p_bmp280->BMP280_BUS_READ_FUNC(p_bmp280->
dev_addr,
1322 v_addr_u8, v_data_u8, v_len_u8);
1326 #ifdef BMP280_ENABLE_FLOAT
1345 double v_x1_u32r = BMP280_INIT_VALUE;
1346 double v_x2_u32r = BMP280_INIT_VALUE;
1347 double temperature = BMP280_INIT_VALUE;
1349 v_x1_u32r = (((double)v_uncomp_temperature_s32) / 16384.0 -
1353 v_x2_u32r = ((((double)v_uncomp_temperature_s32) / 131072.0 -
1355 (((double)v_uncomp_temperature_s32) / 131072.0 -
1361 temperature = (v_x1_u32r + v_x2_u32r) / 5120.0;
1383 double v_x1_u32r = BMP280_INIT_VALUE;
1384 double v_x2_u32r = BMP280_INIT_VALUE;
1385 double pressure = BMP280_INIT_VALUE;
1388 v_x2_u32r = v_x1_u32r * v_x1_u32r *
1390 v_x2_u32r = v_x2_u32r + v_x1_u32r *
1392 v_x2_u32r = (v_x2_u32r / 4.0) +
1395 v_x1_u32r * v_x1_u32r / 524288.0 +
1397 v_x1_u32r = (1.0 + v_x1_u32r / 32768.0) *
1399 pressure = 1048576.0 - (double)v_uncomp_pressure_s32;
1401 if ((v_x1_u32r > 0) || (v_x1_u32r < 0))
1402 pressure = (pressure - (v_x2_u32r / 4096.0)) *
1405 return BMP280_INVALID_DATA;
1407 pressure * pressure / 2147483648.0;
1409 pressure = pressure + (v_x1_u32r + v_x2_u32r +
1415 #if defined(BMP280_ENABLE_INT64) && defined(BMP280_64BITSUPPORT_PRESENT)
1434 s64 v_x1_s64r = BMP280_INIT_VALUE;
1435 s64 v_x2_s64r = BMP280_INIT_VALUE;
1436 s64 pressure = BMP280_INIT_VALUE;
1439 v_x2_s64r = v_x1_s64r * v_x1_s64r *
1443 << BMP280_SHIFT_BIT_POSITION_BY_17_BITS);
1444 v_x2_s64r = v_x2_s64r +
1446 << BMP280_SHIFT_BIT_POSITION_BY_35_BITS);
1447 v_x1_s64r = ((v_x1_s64r * v_x1_s64r *
1449 >> BMP280_SHIFT_BIT_POSITION_BY_08_BITS) +
1451 << BMP280_SHIFT_BIT_POSITION_BY_12_BITS);
1452 v_x1_s64r = (((((
s64)1) << BMP280_SHIFT_BIT_POSITION_BY_47_BITS)
1454 BMP280_SHIFT_BIT_POSITION_BY_33_BITS;
1455 pressure = 1048576 - v_uncomp_pressure_s32;
1456 if (v_x1_s64r != BMP280_INIT_VALUE)
1457 #if defined __KERNEL__
1458 pressure = div64_s64((((pressure
1459 << BMP280_SHIFT_BIT_POSITION_BY_31_BITS)
1460 - v_x2_s64r) * 3125), v_x1_s64r);
1462 pressure = (((pressure
1463 << BMP280_SHIFT_BIT_POSITION_BY_31_BITS)
1464 - v_x2_s64r) * 3125) / v_x1_s64r;
1467 return BMP280_INVALID_DATA;
1469 (pressure >> BMP280_SHIFT_BIT_POSITION_BY_13_BITS) *
1470 (pressure >> BMP280_SHIFT_BIT_POSITION_BY_13_BITS))
1471 >> BMP280_SHIFT_BIT_POSITION_BY_25_BITS;
1473 pressure) >> BMP280_SHIFT_BIT_POSITION_BY_19_BITS;
1475 pressure = ((pressure + v_x1_s64r + v_x2_s64r)
1476 >> BMP280_SHIFT_BIT_POSITION_BY_08_BITS) +
1478 << BMP280_SHIFT_BIT_POSITION_BY_04_BITS);
1479 return (
u32)pressure;
1498 BMP280_RETURN_FUNCTION_TYPE com_rslt = SUCCESS;
1500 *v_delaytime_u8r = (T_INIT_MAX + T_MEASURE_PER_OSRS_MAX * (((1
1502 >> BMP280_SHIFT_BIT_POSITION_BY_01_BIT)
1504 >> BMP280_SHIFT_BIT_POSITION_BY_01_BIT))
1506 T_SETUP_PRESSURE_MAX : 0) + 15) / 16;
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 ...
BMP280_RETURN_FUNCTION_TYPE bmp280_read_uncomp_pressure_temperature(s32 *v_uncomp_pressure_s32, s32 *v_uncomp_temperature_s32)
reads uncompensated pressure and temperature
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...
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.
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...
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...
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.
u32 bmp280_compensate_pressure_int32(s32 v_uncomp_pressure_s32)
Reads actual pressure from uncompensated pressure and returns the value in Pascal(Pa) ...
u32 bmp280_compensate_pressure_int64(s32 v_uncomp_pressure_s32)
This API used to read actual pressure from uncompensated pressure.
BMP280_RETURN_FUNCTION_TYPE bmp280_compute_wait_time(u8 *v_delaytime_u8r)
Computing waiting time for sensor data read.
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...
static struct bmp280_t * p_bmp280
BMP280 Sensor Driver Support Header File.
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...
struct bmp280_calib_param_t calib_param
void(* delay_msec)(BMP280_MDELAY_DATA_TYPE)
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.
BMP280_RETURN_FUNCTION_TYPE bmp280_read_pressure_temperature(u32 *v_pressure_u32, s32 *v_temperature_s32)
This API reads the true pressure and temperature.
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...
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...
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...
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...
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.
double bmp280_compensate_temperature_double(s32 v_uncomp_temperature_s32)
This API used to read actual temperature from uncompensated temperature.
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...
double bmp280_compensate_pressure_double(s32 v_uncomp_pressure_s32)
Reads actual pressure from uncompensated pressure and returns pressure in Pa as double.
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.
s32 bmp280_compensate_temperature_int32(s32 v_uncomp_temperature_s32)
Reads actual temperature from uncompensated temperature.
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. ...
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.
BMP280_RETURN_FUNCTION_TYPE bmp280_get_calib_param(void)
This API is used to calibration parameters used for calculation in the registers. ...
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...
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...
This structure holds BMP280 initialization parameters.