-
Notifications
You must be signed in to change notification settings - Fork 43
/
Copy pathbmp180.h
731 lines (648 loc) · 24.6 KB
/
bmp180.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
/** \mainpage
*
****************************************************************************
* Copyright (C) 2008 - 2014 Bosch Sensortec GmbH
*
* File : bmp180.h
*
* Date : 2014/12/12
*
* Revision : 2.2.1
*
* Usage: Sensor Driver for BMP180 sensor
*
****************************************************************************
*
* \section License
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of the copyright holder nor the names of the
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDER
* OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
* OR CONSEQUENTIAL DAMAGES(INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
*
* The information provided is believed to be accurate and reliable.
* The copyright holder assumes no responsibility
* for the consequences of use
* of such information nor for any infringement of patents or
* other rights of third parties which may result from its use.
* No license is granted by implication or otherwise under any patent or
* patent rights of the copyright holder.
**************************************************************************/
/** \file bmp180.h
\brief Header file for all define constants and function prototypes
*/
#ifndef __BMP180_H__
#define __BMP180_H__
/*!
* @brief The following definition uses for define the data types
*
* @note While porting the API please consider the following
* @note Please check the version of C standard
* @note Are you using Linux platform
*/
/*!
* @brief For the Linux platform support
* Please use the types.h for your data types definitions
*/
#ifdef __KERNEL__
#include <linux/types.h>
/* singed integer type*/
typedef int8_t s8;/**< used for signed 8bit */
typedef int16_t s16;/**< used for signed 16bit */
typedef int32_t s32;/**< used for signed 32bit */
typedef int64_t s64;/**< used for signed 64bit */
typedef u_int8_t u8;/**< used for unsigned 8bit */
typedef u_int16_t u16;/**< used for unsigned 16bit */
typedef u_int32_t u32;/**< used for unsigned 32bit */
typedef u_int64_t u64;/**< used for unsigned 64bit */
#else /* ! __KERNEL__ */
/**********************************************************
* These definition uses for define the C
* standard version data types
***********************************************************/
# if !defined(__STDC_VERSION__)
/************************************************
* compiler is C11 C standard
************************************************/
#if (__STDC_VERSION__ == 201112L)
/************************************************/
#include <stdint.h>
/************************************************/
/*unsigned integer types*/
typedef uint8_t u8;/**< used for unsigned 8bit */
typedef uint16_t u16;/**< used for unsigned 16bit */
typedef uint32_t u32;/**< used for unsigned 32bit */
typedef uint64_t u64;/**< used for unsigned 64bit */
/*signed integer types*/
typedef int8_t s8;/**< used for signed 8bit */
typedef int16_t s16;/**< used for signed 16bit */
typedef int32_t s32;/**< used for signed 32bit */
typedef int64_t s64;/**< used for signed 64bit */
/************************************************
* compiler is C99 C standard
************************************************/
#elif (__STDC_VERSION__ == 199901L)
/* stdint.h is a C99 supported c library.
which is used to fixed the integer size*/
/************************************************/
#include <stdint.h>
/************************************************/
/*unsigned integer types*/
typedef uint8_t u8;/**< used for unsigned 8bit */
typedef uint16_t u16;/**< used for unsigned 16bit */
typedef uint32_t u32;/**< used for unsigned 32bit */
typedef uint64_t u64;/**< used for unsigned 64bit */
/*signed integer types*/
typedef int8_t s8;/**< used for signed 8bit */
typedef int16_t s16;/**< used for signed 16bit */
typedef int32_t s32;/**< used for signed 32bit */
typedef int64_t s64;/**< used for signed 64bit */
/************************************************
* compiler is C89 or other C standard
************************************************/
#else /* !defined(__STDC_VERSION__) */
/*!
* @brief By default it is defined as 32 bit machine configuration
* define your data types based on your
* machine/compiler/controller configuration
*/
#define MACHINE_32_BIT
/*! @brief
* If your machine support 16 bit
* define the MACHINE_16_BIT
*/
#ifdef MACHINE_16_BIT
#include <limits.h>
/*signed integer types*/
typedef signed char s8;/**< used for signed 8bit */
typedef signed short int s16;/**< used for signed 16bit */
typedef signed long int s32;/**< used for signed 32bit */
#if defined(LONG_MAX) && LONG_MAX == 0x7fffffffffffffffL
typedef long int s64;/**< used for signed 64bit */
typedef unsigned long int u64;/**< used for unsigned 64bit */
#elif defined(LLONG_MAX) && (LLONG_MAX == 0x7fffffffffffffffLL)
typedef long long int s64;/**< used for signed 64bit */
typedef unsigned long long int u64;/**< used for unsigned 64bit */
#else
#warning Either the correct data type for signed 64 bit integer \
could not be found, or 64 bit integers are not supported in your environment.
#warning If 64 bit integers are supported on your platform, \
please set s64 manually.
#endif
/*unsigned integer types*/
typedef unsigned char u8;/**< used for unsigned 8bit */
typedef unsigned short int u16;/**< used for unsigned 16bit */
typedef unsigned long int u32;/**< used for unsigned 32bit */
/* If your machine support 32 bit
define the MACHINE_32_BIT*/
#elif defined MACHINE_32_BIT
/*signed integer types*/
typedef signed char s8;/**< used for signed 8bit */
typedef signed short int s16;/**< used for signed 16bit */
typedef signed int s32;/**< used for signed 32bit */
typedef signed long long int s64;/**< used for signed 64bit */
/*unsigned integer types*/
typedef unsigned char u8;/**< used for unsigned 8bit */
typedef unsigned short int u16;/**< used for unsigned 16bit */
typedef unsigned int u32;/**< used for unsigned 32bit */
typedef unsigned long long int u64;/**< used for unsigned 64bit */
/* If your machine support 64 bit
define the MACHINE_64_BIT*/
#elif defined MACHINE_64_BIT
/*signed integer types*/
typedef signed char s8;/**< used for signed 8bit */
typedef signed short int s16;/**< used for signed 16bit */
typedef signed int s32;/**< used for signed 32bit */
typedef signed long int s64;/**< used for signed 64bit */
/*unsigned integer types*/
typedef unsigned char u8;/**< used for unsigned 8bit */
typedef unsigned short int u16;/**< used for unsigned 16bit */
typedef unsigned int u32;/**< used for unsigned 32bit */
typedef unsigned long int u64;/**< used for unsigned 64bit */
#else
#warning The data types defined above which not supported \
define the data types manually
#endif
#endif
/*** This else will execute for the compilers
* which are not supported the C standards
* Like C89/C99/C11***/
#else
/*!
* @brief By default it is defined as 32 bit machine configuration
* define your data types based on your
* machine/compiler/controller configuration
*/
#define MACHINE_32_BIT
/* If your machine support 16 bit
define the MACHINE_16_BIT*/
#ifdef MACHINE_16_BIT
#include <limits.h>
/*signed integer types*/
typedef signed char s8;/**< used for signed 8bit */
typedef signed short int s16;/**< used for signed 16bit */
typedef signed long int s32;/**< used for signed 32bit */
#if defined(LONG_MAX) && LONG_MAX == 0x7fffffffffffffffL
typedef long int s64;/**< used for signed 64bit */
typedef unsigned long int u64;/**< used for unsigned 64bit */
#elif defined(LLONG_MAX) && (LLONG_MAX == 0x7fffffffffffffffLL)
typedef long long int s64;/**< used for signed 64bit */
typedef unsigned long long int u64;/**< used for unsigned 64bit */
#else
#warning Either the correct data type for signed 64 bit integer \
could not be found, or 64 bit integers are not supported in your environment.
#warning If 64 bit integers are supported on your platform, \
please set s64 manually.
#endif
/*unsigned integer types*/
typedef unsigned char u8;/**< used for unsigned 8bit */
typedef unsigned short int u16;/**< used for unsigned 16bit */
typedef unsigned long int u32;/**< used for unsigned 32bit */
/*! @brief If your machine support 32 bit
define the MACHINE_32_BIT*/
#elif defined MACHINE_32_BIT
/*signed integer types*/
typedef signed char s8;/**< used for signed 8bit */
typedef signed short int s16;/**< used for signed 16bit */
typedef signed int s32;/**< used for signed 32bit */
typedef signed long long int s64;/**< used for signed 64bit */
/*unsigned integer types*/
typedef unsigned char u8;/**< used for unsigned 8bit */
typedef unsigned short int u16;/**< used for unsigned 16bit */
typedef unsigned int u32;/**< used for unsigned 32bit */
typedef unsigned long long int u64;/**< used for unsigned 64bit */
/* If your machine support 64 bit
define the MACHINE_64_BIT*/
#elif defined MACHINE_64_BIT
/*signed integer types*/
typedef signed char s8;/**< used for signed 8bit */
typedef signed short int s16;/**< used for signed 16bit */
typedef signed int s32;/**< used for signed 32bit */
typedef signed long int s64;/**< used for signed 64bit */
/*unsigned integer types*/
typedef unsigned char u8;/**< used for unsigned 8bit */
typedef unsigned short int u16;/**< used for unsigned 16bit */
typedef unsigned int u32;/**< used for unsigned 32bit */
typedef unsigned long int u64;/**< used for unsigned 64bit */
#else
#warning The data types defined above which not supported \
define the data types manually
#endif
#endif
#endif
/***************************************************************/
/**\name FUNCTION DEFINITIONS */
/***************************************************************/
#define bmp180_calc_temperature(ut)\
bmp180_get_temperature(ut)
#define bmp180_calc_pressure(up)\
bmp180_get_pressure(up)
#define bmp180_read_ut()\
bmp180_get_ut()
#define bmp180_read_up()\
bmp180_get_up()
#define bmp180_read_cal_param()\
bmp180_get_cal_param()
#define smd500_read_cal_param()\
smd500_get_cal_param()
/***************************************************************/
/**\name BUS READ AND WRITE FUNCTION */
/***************************************************************/
/*!
@brief Define the calling convention of YOUR bus communication routine.
@note This includes types of parameters. This example shows the
configuration for an SPI bus link.
If your communication function looks like this:
write_my_bus_xy(u8 device_addr, u8 register_addr,
u8 * data, u8 length);
The BMP180_WR_FUNC_PTR would equal:
BMP180_WR_FUNC_PTR s8 (* bus_write)(u8,
u8, u8 *, u8)
Parameters can be mixed as needed refer to the
refer BMP180_BUS_WRITE_FUNC macro.
*/
#define BMP180_BUS_WR_RETURN_TYPE s8
/** defines the calling parameter types of the BMP180_WR_FUNCTION
*/
#define BMP180_BUS_WR_PARAM_TYPES u8, u8,\
u8 *, u8
/** links the order of parameters defined in
BMP180_BUS_WR_PARAM_TYPE to function calls used inside the API
*/
#define BMP180_BUS_WR_PARAM_ORDER (device_addr, register_addr,\
register_data, write_length)
/* never change this line */
#define BMP180_BUS_WRITE_FUNC(device_addr, register_addr, \
register_data, write_length)\
bus_write(device_addr, register_addr, register_data, write_length)
/*!
@brief link macro between API function calls and bus read function
@note The bus write function can change since this is a
system dependant issue.
If the bus_read parameter calling order is like: reg_addr,
reg_data, wr_len it would be as it is here.
If the parameters are differently ordered or your communication
function like I2C need to know the device address,
you can change this macro accordingly.
BMP180_BUS_READ_FUNC(dev_addr, reg_addr, reg_data, wr_len)\
bus_read(dev_addr, reg_addr, reg_data, wr_len)
This macro lets all API functions call YOUR communication routine in a
way that equals your definition in the
refer BMP180_WR_FUNC_PTR definition.
@note: this macro also includes the "MSB='1'
for reading BMP180 addresses.
*/
/** defines the return parameter type of the BMP180_WR_FUNCTION
*/
#define BMP180_BUS_RD_RETURN_TYPE s8
/** defines the calling parameter types of the BMP180_WR_FUNCTION
*/
#define BMP180_BUS_RD_PARAM_TYPES (u8,\
u8, u8 *, u8)
/** links the order of parameters defined in
BMP180_BUS_WR_PARAM_TYPE to function calls used inside the API
*/
#define BMP180_BUS_RD_PARAM_ORDER (device_addr, \
register_addr, register_data, read_length)
/* never change this line */
#define BMP180_BUS_READ_FUNC(device_addr, register_addr, \
register_data, read_length)\
bus_read(device_addr, register_addr, register_data, read_length)
/***************************************************************/
/**\name BUS READ AND WRITE FUNCTION POINTERS DEFINITIONS */
/***************************************************************/
#define BMP180_WR_FUNC_PTR \
s8 (*bus_write)(u8, u8, u8 *, u8)
#define BMP180_RD_FUNC_PTR \
s8 (*bus_read)(u8, u8, u8 *, u8)
/* register write and read delays */
#define BMP180_MDELAY_DATA_TYPE u32
/***************************************************************/
/**\name I2C ADDRESS DEFINITION OF BMP180 */
/***************************************************************/
/*BMP180 I2C Address*/
#define BMP180_I2C_ADDR (0xEE>>1)
/***************************************************************/
/**\name ERROR CODE DEFINITIONS */
/***************************************************************/
#define E_BMP_NULL_PTR ((s8)-127)
#define E_BMP_COMM_RES ((s8)-1)
#define E_BMP_OUT_OF_RANGE ((s8)-2)
/***************************************************************/
/**\name CONSTANTS */
/***************************************************************/
#define C_BMP180_ZERO_U8X ((u8)0)
#define C_BMP180_ONE_U8X ((u8)1)
#define C_BMP180_TWO_U8X ((u8)2)
#define C_BMP180_THREE_U8X ((u8)3)
#define C_BMP180_FOUR_U8X ((u8)4)
#define C_BMP180_EIGHT_U8X ((u8)8)
#define C_BMP180_SIXTEEN_U8X ((u8)16)
#define BMP180_RETURN_FUNCTION_TYPE s8
#define BMP180_SHIFT_1_POSITION 1
#define BMP180_SHIFT_2_POSITION 2
#define BMP180_SHIFT_3_POSITION 3
#define BMP180_SHIFT_4_POSITION 4
#define BMP180_SHIFT_6_POSITION 6
#define BMP180_SHIFT_8_POSITION 8
#define BMP180_SHIFT_11_POSITION 11
#define BMP180_SHIFT_12_POSITION 12
#define BMP180_SHIFT_13_POSITION 13
#define BMP180_SHIFT_14_POSITION 14
#define BMP180_SHIFT_15_POSITION 15
#define BMP180_SHIFT_16_POSITION 16
/***************************************************************/
/**\name REGISTER ADDRESS DEFINITION */
/***************************************************************/
/*register definitions */
#define BMP180_PROM_START__ADDR 0xAA
#define BMP180_PROM_DATA__LEN 22
#define BMP180_CHIP_ID_REG 0xD0
#define BMP180_VERSION_REG 0xD1
#define BMP180_CTRL_MEAS_REG 0xF4
#define BMP180_ADC_OUT_MSB_REG 0xF6
#define BMP180_ADC_OUT_LSB_REG 0xF7
#define BMP180_SOFT_RESET_REG 0xE0
/* temperature measurement */
#define BMP180_T_MEASURE 0x2E
/* pressure measurement*/
#define BMP180_P_MEASURE 0x34
/* TO be spec'd by GL or SB*/
#define BMP180_TEMP_CONVERSION_TIME 5
#define BMP180_PARAM_MG 3038
#define BMP180_PARAM_MH -7357
#define BMP180_PARAM_MI 3791
/****************************************************/
/**\name ARRAY SIZE DEFINITIONS */
/***************************************************/
#define ARRAY_SIZE_TWO 2
#define ARRAY_SIZE_THREE 3
#define ARRAY_SIZE_SIX 6
#define ARRAY_SIZE_FIVE 5
#define ARRAY_SIZE_EIGHT 8
#define ARRAY_SIZE_TWELVE 12
#define ARRAY_SIZE_FOURTEEN 14
#define ARRAY_SIZE_TWENTY_TWO 22
#define INDEX_ZERO 0
#define INDEX_ONE 1
#define INDEX_TWO 2
#define INDEX_THREE 3
#define INDEX_FOUR 4
#define INDEX_FIVE 5
#define INDEX_SIX 6
#define INDEX_SEVEN 7
#define INDEX_EIGHT 8
#define INDEX_NINE 9
#define INDEX_TEN 10
#define INDEX_ELEVEN 11
#define INDEX_TWELVE 12
#define INDEX_THIRTEEN 13
#define INDEX_FOURTEEN 14
#define INDEX_FIVETEEN 15
#define INDEX_SIXTEEN 16
#define INDEX_SEVENTEEN 17
#define INDEX_EIGHTEEN 18
#define INDEX_NINETEEN 19
#define INDEX_TWENTY 20
#define INDEX_TWENTY_ONE 21
#define INDEX_TWENTY_TWO 22
#define INDEX_TWENTY_THREE 23
/****************************************************/
/**\name ARRAY PARAMETERS */
/***************************************************/
#define LSB_ZERO 0
#define MSB_ONE 1
#define LSB_TWO 2
#define MSB_THREE 3
#define LSB_FOUR 4
#define MSB_FIVE 5
#define LSB_SIX 6
#define MSB_SEVEN 7
/***************************************************************/
/**\name CALCULATION DEFINITIONS */
/***************************************************************/
#define BMP180_PRESSURE_4_0_0_0_DATA 4000
#define BMP180_PRESSURE_3_2_7_6_8_DATA 32768
#define BMP180_PRESSURE_5_0_0_0_0_DATA 50000
#define BMP180_PRESSURE_HEX_8_0_0_0_0_0_0_0_DATA 0x80000000
/**************************************************************/
/**\name STRUCTURE DEFINITIONS */
/**************************************************************/
/*!
* @brief This structure holds all device specific calibration parameters
*/
struct bmp180_calib_param_t {
s16 ac1;/**<calibration ac1 data*/
s16 ac2;/**<calibration ac2 data*/
s16 ac3;/**<calibration ac3 data*/
u16 ac4;/**<calibration ac4 data*/
u16 ac5;/**<calibration ac5 data*/
u16 ac6;/**<calibration ac6 data*/
s16 b1;/**<calibration b1 data*/
s16 b2;/**<calibration b2 data*/
s16 mb;/**<calibration mb data*/
s16 mc;/**<calibration mc data*/
s16 md;/**<calibration md data*/
};
/*!
* @brief This structure holds BMP180 initialization parameters
*/
struct bmp180_t {
struct bmp180_calib_param_t calib_param;/**<calibration data*/
u8 mode;/**<power mode*/
u8 chip_id, /**<chip id*/
ml_version,/**<ml version*/
al_version;/**<al version*/
u8 dev_addr;/**<device address*/
u8 sensortype;/**< sensor type*/
s32 param_b5;/**<pram*/
s32 number_of_samples;/**<sample calculation*/
s16 oversamp_setting;/**<oversampling setting*/
s16 sw_oversamp;/**<software oversampling*/
BMP180_WR_FUNC_PTR;/**< bus write function pointer*/
BMP180_RD_FUNC_PTR;/**< bus read function pointer*/
void(*delay_msec)(BMP180_MDELAY_DATA_TYPE);/**< delay function pointer*/
};
/**************************************************************/
/**\name BIT MASK, LENGTH AND POSITION FOR REGISTERS */
/**************************************************************/
/**************************************************************/
/**\name BIT MASK, LENGTH AND POSITION FOR
CHIP ID REGISTERS */
/**************************************************************/
#define BMP180_CHIP_ID__POS 0
#define BMP180_CHIP_ID__MSK 0xFF
#define BMP180_CHIP_ID__LEN 8
#define BMP180_CHIP_ID__REG BMP180_CHIP_ID_REG
/**************************************************************/
/**\name BIT MASK, LENGTH AND POSITION FOR
ML VERSION */
/**************************************************************/
#define BMP180_ML_VERSION__POS 0
#define BMP180_ML_VERSION__LEN 4
#define BMP180_ML_VERSION__MSK 0x0F
#define BMP180_ML_VERSION__REG BMP180_VERSION_REG
/**************************************************************/
/**\name BIT MASK, LENGTH AND POSITION FOR
AL VERSION */
/**************************************************************/
#define BMP180_AL_VERSION__POS 4
#define BMP180_AL_VERSION__LEN 4
#define BMP180_AL_VERSION__MSK 0xF0
#define BMP180_AL_VERSION__REG BMP180_VERSION_REG
/**************************************************************/
/**\name GET AND SET BITSLICE FUNCTIONS*/
/**************************************************************/
/* DATA REGISTERS */
/* LG/HG thresholds are in LSB and depend on RANGE setting */
/* no range check on threshold calculation */
#define BMP180_GET_BITSLICE(regvar, bitname)\
((regvar & bitname##__MSK) >> (bitname##__POS))
#define BMP180_SET_BITSLICE(regvar, bitname, val)\
((regvar & ~bitname##__MSK) | ((val<<bitname##__POS)&bitname##__MSK))
/**************************************************************/
/**\name FUNCTION DECLARATIONS */
/**************************************************************/
/**************************************************************/
/**\name FUNCTION FOR INTIALIZATION */
/**************************************************************/
/*!
* @brief This function is used for initialize
* the bus read and bus write functions
* and assign the chip id and I2C address of the BMP180
* chip id is read in the register 0xD0 bit from 0 to 7
*
* @param bmp180 structure pointer.
*
* @note While changing the parameter of the bmp180_t
* @note consider the following point:
* Changing the reference value of the parameter
* will changes the local copy or local reference
* make sure your changes will not
* affect the reference value of the parameter
* (Better case don't change the reference value of the parameter)
*
*
*
*
* @return results of bus communication function
* @retval 0 -> Success
* @retval -1 -> Error
*
*
*/
BMP180_RETURN_FUNCTION_TYPE bmp180_init(struct bmp180_t *bmp180);
/**************************************************************/
/**\name FUNCTION FOR TEMPERATURE AND PRESSURE READ */
/**************************************************************/
/*!
* @brief this API is used to calculate the true
* temperature using the uncompensated temperature(ut)
* @note For reading the ut data refer : bmp180_read_ut()
*
* @param v_uncomp_temperature_u32:
* the value of uncompensated temperature
*
* @return Return the temperature in steps of 0.1 deg Celsius
*
*
*/
s16 bmp180_get_temperature(u32 v_uncomp_temperature_u32);
/*!
* @brief this API is used to calculate the true
* pressure using the uncompensated pressure(up)
* @note For reading the up data refer : bmp180_read_up()
*
* @param v_uncomp_pressure_u32: the value of uncompensated pressure
*
* @return Return the value of pressure in steps of 1.0 Pa
*
*/
s32 bmp180_get_pressure(u32 v_uncomp_pressure_u32);
/**************************************************************/
/**\name FUNCTION FOR UNCOMPENSATED PRESSURE AND TEMPERATURE */
/**************************************************************/
/*!
* @brief this API is used to read the
* uncompensated temperature(ut) from the register
* @note 0xF6(MSB) bit from 0 to 7
* @note 0xF7(LSB) bit from 0 to 7
*
*
* @return results of bus communication function
* @retval 0 -> Success
* @retval -1 -> Error
*
*
*/
u16 bmp180_get_uncomp_temperature(void);
/*!
* @brief this API is used to read the
* uncompensated pressure(up) from the register
* @note 0xF6(MSB) bit from 0 to 7
* @note 0xF7(LSB) bit from 0 to 7
* @note 0xF8(LSB) bit from 3 to 7
*
*
* @return results of bus communication function
* @retval 0 -> Success
* @retval -1 -> Error
*
*/
u32 bmp180_get_uncomp_pressure(void);
/**************************************************************/
/**\name FUNCTION FOR CALIBRATION */
/**************************************************************/
/*!
* @brief this function used for read the calibration
* parameter from the register
*
* Parameter | MSB | LSB | bit
* ------------|---------|---------|-----------
* AC1 | 0xAA | 0xAB | 0 to 7
* AC2 | 0xAC | 0xAD | 0 to 7
* AC3 | 0xAE | 0xAF | 0 to 7
* AC4 | 0xB0 | 0xB1 | 0 to 7
* AC5 | 0xB2 | 0xB3 | 0 to 7
* AC6 | 0xB4 | 0xB5 | 0 to 7
* B1 | 0xB6 | 0xB7 | 0 to 7
* B2 | 0xB8 | 0xB9 | 0 to 7
* MB | 0xBA | 0xBB | 0 to 7
* MC | 0xBC | 0xBD | 0 to 7
* MD | 0xBE | 0xBF | 0 to 7
*
*
* @return results of bus communication function
* @retval 0 -> Success
* @retval -1 -> Error
*
*
*/
BMP180_RETURN_FUNCTION_TYPE bmp180_get_calib_param(void);
/* __BMP180_H__*/
#endif