bmp180-embedded-hal 0.1.0

A platform agnostic driver to interface with the BMP180 barometric pressure sensor.
Documentation
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
//! Device definition and implementation.

use duplicate::duplicate_item;

/// Identity trait.
///
/// Used to trick the compiler while using [`duplicate_item`] to implement `async` and `blocking` versions of the same module.
/// Using this trait, we can write normal rust code that can also be formatted by `rustfmt`.
trait Identity: Sized {
    fn identity(self) -> Self {
        self
    }
}

impl<T: Sized> Identity for T {}

#[duplicate_item(
    feature_        module        async     await               i2c_trait                       delay_trait;
    ["async"]       [asynch]      [async]   [await.identity()]  [embedded_hal_async::i2c::I2c]  [embedded_hal_async::delay::DelayNs];
    ["blocking"]    [blocking]    []        [identity()]        [embedded_hal::i2c::I2c]        [embedded_hal::delay::DelayNs];
)]
pub mod module {
    //! Device definition and implementation.

    #[cfg(feature=feature_)]
    mod inner {
        use super::super::Identity;

        use crate::{
            address::Address, calibration::Calibration, error::BMP180Error, id::Id, mode::Mode,
            register::Register, tri,
        };

        /// Builder for an uninitialized `BMP180` device.
        ///
        /// Helpful for using default values.
        #[derive(Clone)]
        #[cfg_attr(feature = "impl-defmt-format", derive(defmt::Format))]
        #[cfg_attr(feature = "impl-debug", derive(core::fmt::Debug))]
        pub struct UninitBMP180Builder<I2C, DELAY> {
            inner: UninitBMP180<I2C, DELAY>,
        }

        impl<I2C, DELAY> UninitBMP180Builder<I2C, DELAY>
        where
            I2C: i2c_trait,
            DELAY: delay_trait,
        {
            /// Create a new builder.
            pub fn new(i2c: I2C, delay: DELAY) -> Self {
                Self {
                    inner: UninitBMP180::new(Address::default(), Mode::default(), i2c, delay),
                }
            }

            /// Set the device address.
            pub fn addr(mut self, addr: Address) -> Self {
                self.inner.addr = addr;
                self
            }

            /// Set the device mode.
            pub fn mode(mut self, mode: Mode) -> Self {
                self.inner.mode = mode;
                self
            }

            /// Build the `BMP180` device.
            pub fn build(self) -> UninitBMP180<I2C, DELAY> {
                self.inner
            }
        }

        /// Uninitialized `BMP180` device.
        ///
        /// This struct is used to initialize the `BMP180` device.
        #[derive(Clone)]
        #[cfg_attr(feature = "impl-defmt-format", derive(defmt::Format))]
        #[cfg_attr(feature = "impl-debug", derive(core::fmt::Debug))]
        pub struct UninitBMP180<I2C, DELAY> {
            /// Device I2C address.
            addr: Address,
            /// Device mode.
            mode: Mode,
            /// Device I2C bus.
            i2c: I2C,
            /// Delay provider.
            delay: DELAY,
        }

        impl<I2C, DELAY> UninitBMP180<I2C, DELAY>
        where
            I2C: i2c_trait,
            DELAY: delay_trait,
        {
            /// Create a new uninitialized `BMP180` device.
            pub fn new(addr: Address, mode: Mode, i2c: I2C, delay: DELAY) -> Self {
                Self {
                    addr,
                    mode,
                    i2c,
                    delay,
                }
            }

            /// Create a new builder.
            pub fn builder(i2c: I2C, delay: DELAY) -> UninitBMP180Builder<I2C, DELAY> {
                UninitBMP180Builder::new(i2c, delay)
            }

            /// Device I2C address as `u8`.
            fn addr_u8(&self) -> u8 {
                self.addr.into()
            }

            /// Read device ID.
            async fn read_id(&mut self) -> Result<u8, I2C::Error> {
                let mut data = [0u8; 2];

                tri!(
                    self.i2c
                        .write_read(self.addr_u8(), &[Register::ChipId as u8], &mut data)
                        .await
                );

                Ok(data[0])
            }

            /// Validate device ID.
            fn validate_id(id: u8) -> bool {
                Id::is_valid(id)
            }

            /// Read calibration data.
            async fn read_calibration(&mut self) -> Result<Calibration, I2C::Error> {
                let mut data = [0u8; 22];

                tri!(
                    self.i2c
                        .write_read(self.addr_u8(), &[Register::CalibrationAc1 as u8], &mut data)
                        .await
                );

                Ok(Calibration::from_slice(&data))
            }

            /// Initialize `BMP180` device.
            pub async fn initialize(
                mut self,
            ) -> Result<BMP180<I2C, DELAY>, BMP180Error<I2C::Error>> {
                let id = tri!(self.read_id().await.map_err(BMP180Error::I2C));

                if !Self::validate_id(id) {
                    return Err(BMP180Error::InvalidId(id));
                }

                let calibration = tri!(self.read_calibration().await.map_err(BMP180Error::I2C));

                let bmp180 = BMP180 {
                    addr: self.addr,
                    mode: self.mode,
                    calibration,
                    temperature: 0,
                    pressure: 0,
                    i2c: self.i2c,
                    delay: self.delay,
                };

                Ok(bmp180)
            }
        }

        /// `BMP180` device.
        ///
        /// Represents an initialized BMP180 device valid id and its calibration data set.
        #[derive(Clone)]
        #[cfg_attr(feature = "impl-defmt-format", derive(defmt::Format))]
        #[cfg_attr(feature = "impl-debug", derive(core::fmt::Debug))]
        pub struct BMP180<I2C, DELAY> {
            addr: Address,
            mode: Mode,
            calibration: Calibration,
            temperature: i32,
            pressure: i32,
            i2c: I2C,
            delay: DELAY,
        }

        impl<I2C, DELAY> BMP180<I2C, DELAY>
        where
            I2C: i2c_trait,
            DELAY: delay_trait,
        {
            /// Device I2C address.
            pub fn addr(&self) -> Address {
                self.addr
            }

            /// Device I2C address as `u8`.
            fn addr_u8(&self) -> u8 {
                self.addr.into()
            }

            /// Device operating mode.
            pub fn mode(&self) -> Mode {
                self.mode
            }

            /// Device calibration data.
            pub fn calibration(&self) -> &Calibration {
                &self.calibration
            }

            /// True temperature in `0.1 C` according to the calibration data.
            pub fn temperature(&self) -> i32 {
                self.temperature
            }

            /// Temperature in Celsius.
            pub fn temperature_celsius(&self) -> f32 {
                self.temperature() as f32 / 10.0
            }

            /// True pressure in `Pa`according to the calibration data.
            pub fn pressure(&self) -> i32 {
                self.pressure
            }

            /// Pressure in `Pa` at sea level.
            pub fn sea_level_pressure(&self, altitude_meters: f32) -> i32 {
                let pressure = self.pressure() as f32;

                (pressure / libm::powf(1.0 - altitude_meters / 44330.0, 5.255)) as i32
            }

            /// Altitude in meters.
            ///
            /// Standard pressure at sea level is `101325 Pa`.
            pub fn altitude(&self, sea_level_pressure: f32) -> f32 {
                let pressure = self.pressure();

                44330.0 * (1.0 - libm::powf(pressure as f32 / sea_level_pressure, 0.1903))
            }

            /// Read raw temperature.
            async fn read_raw_temperature(&mut self) -> Result<i16, BMP180Error<I2C::Error>> {
                tri!(self
                    .i2c
                    .write(
                        self.addr_u8(),
                        &[Register::Control as u8, Register::ReadTempCmd as u8]
                    )
                    .await
                    .map_err(BMP180Error::I2C));

                self.delay.delay_ms(5).await;

                let mut data = [0u8; 2];

                tri!(self
                    .i2c
                    .write_read(
                        self.addr_u8(),
                        &[Register::TempPressureData as u8],
                        &mut data
                    )
                    .await
                    .map_err(BMP180Error::I2C));

                let raw_temperature = ((data[0] as i16) << 8) | data[1] as i16;

                Ok(raw_temperature)
            }

            /// Read raw pressure.
            async fn read_raw_pressure(&mut self) -> Result<i32, BMP180Error<I2C::Error>> {
                let mode = self.mode();

                tri!(self
                    .i2c
                    .write(
                        self.addr_u8(),
                        &[
                            Register::Control as u8,
                            Register::ReadPressureCmd as u8 + ((mode as u8) << 6)
                        ],
                    )
                    .await
                    .map_err(BMP180Error::I2C));

                self.delay.delay_ms(mode.delay_ms()).await;

                let mut data = [0u8; 3];

                tri!(self
                    .i2c
                    .write_read(
                        self.addr_u8(),
                        &[Register::TempPressureData as u8],
                        &mut data
                    )
                    .await
                    .map_err(BMP180Error::I2C));

                let raw_pressure =
                    (((data[0] as i32) << 16) + ((data[1] as i32) << 8) + data[2] as i32)
                        >> (8 - mode as u8);

                Ok(raw_pressure)
            }

            /// Update temperature in `self`.
            pub async fn update_temperature(&mut self) -> Result<(), BMP180Error<I2C::Error>> {
                let raw_temperature = tri!(self.read_raw_temperature().await);

                self.temperature = tri!(self
                    .compute_temperature(raw_temperature)
                    .ok_or(BMP180Error::Arithmetic));

                Ok(())
            }

            /// Update pressure in `self`.
            pub async fn update_pressure(&mut self) -> Result<(), BMP180Error<I2C::Error>> {
                let raw_temperature = tri!(self.read_raw_temperature().await);
                let raw_pressure = tri!(self.read_raw_pressure().await);

                self.pressure = tri!(self
                    .compute_pressure(raw_temperature, raw_pressure)
                    .ok_or(BMP180Error::Arithmetic));

                Ok(())
            }

            /// Update both temperature and pressure in `self`.
            pub async fn update(&mut self) -> Result<(), BMP180Error<I2C::Error>> {
                let raw_temperature = tri!(self.read_raw_temperature().await);
                let raw_pressure = tri!(self.read_raw_pressure().await);

                self.temperature = tri!(self
                    .compute_temperature(raw_temperature)
                    .ok_or(BMP180Error::Arithmetic));

                self.pressure = tri!(self
                    .compute_pressure(raw_temperature, raw_pressure)
                    .ok_or(BMP180Error::Arithmetic));

                Ok(())
            }
        }

        #[cfg(not(feature = "disable-arithmetic-checks"))]
        impl<I2C, DELAY> BMP180<I2C, DELAY>
        where
            I2C: i2c_trait,
            DELAY: delay_trait,
        {
            /// Compute B5 value.
            fn compute_b5(&self, raw_temperature: i16) -> Option<i32> {
                let calibration = self.calibration();

                let rt = raw_temperature as i32;
                let ac6 = calibration.ac6 as i32;
                let ac5 = calibration.ac5 as i32;
                let mc = calibration.mc as i32;
                let md = calibration.md as i32;

                let x1 = rt.checked_sub(ac6)?.checked_mul(ac5)?.checked_shr(15)?;

                let x2 = mc.checked_shl(11)?.checked_div(x1.checked_add(md)?)?;

                Some(x1 + x2)
            }

            /// Compute true temprature in `0.1 C`.
            fn compute_temperature(&self, raw_temperature: i16) -> Option<i32> {
                let b5 = self.compute_b5(raw_temperature)?;

                #[cfg(feature = "defmt")]
                {
                    defmt::debug!("Computing temperature");
                    defmt::debug!("Raw temperature: {}", raw_temperature);
                    defmt::debug!("B5: {}", b5);
                }

                #[cfg(feature = "log")]
                {
                    log::debug!("Computing temperature");
                    log::debug!("Raw temperature: {}", raw_temperature);
                    log::debug!("B5: {}", b5);
                }

                let temperature = b5.checked_add(8)?;
                let temperature = temperature.checked_shr(4)?;

                Some(temperature)
            }

            /// Compute true pressure in `Pa`.
            fn compute_pressure(&self, raw_temperature: i16, raw_pressure: i32) -> Option<i32> {
                let calibration = self.calibration();
                let mode = self.mode();

                #[cfg(feature = "defmt")]
                {
                    defmt::debug!("Computing pressure");
                    defmt::debug!("Raw temperature: {}", raw_temperature);
                    defmt::debug!("Raw pressure: {}", raw_pressure);
                }

                #[cfg(feature = "log")]
                {
                    log::debug!("Computing pressure");
                    log::debug!("Raw temperature: {}", raw_temperature);
                    log::debug!("Raw pressure: {}", raw_pressure);
                }

                let b2 = calibration.b2 as i32;
                let ac2 = calibration.ac2 as i32;
                let ac1 = calibration.ac1 as i32;

                let b5 = self.compute_b5(raw_temperature)?;

                let b6 = b5.checked_sub(4000)?;
                let x1 = b2
                    .checked_mul(b6.checked_mul(b6)?.checked_shr(12)?)?
                    .checked_shr(11)?;
                let x2 = ac2.checked_mul(b6)?.checked_shr(11)?;
                let x3 = x1.checked_add(x2)?;
                let b3 = ac1
                    .checked_mul(4)?
                    .checked_add(x3)?
                    // in "disable-arithmetic-checks" it is: mode as u8
                    .checked_shl(mode as u32)?
                    .checked_add(2)?
                    .checked_div(4)?;

                #[cfg(feature = "defmt")]
                {
                    defmt::debug!("B5: {}", b5);
                    defmt::debug!("B6: {}", b6);
                    defmt::debug!("X1: {}", x1);
                    defmt::debug!("X2: {}", x2);
                    defmt::debug!("X3: {}", x3);
                    defmt::debug!("B3: {}", b3);
                }

                #[cfg(feature = "log")]
                {
                    log::debug!("B5: {}", b5);
                    log::debug!("B6: {}", b6);
                    log::debug!("X1: {}", x1);
                    log::debug!("X2: {}", x2);
                    log::debug!("X3: {}", x3);
                    log::debug!("B3: {}", b3);
                }

                let ac3 = calibration.ac3 as i32;
                let b1 = calibration.b1 as i32;
                let ac4 = calibration.ac4 as u32;

                let x1 = ac3.checked_mul(b6)?.checked_shr(13)?;
                let x2 = b1
                    .checked_mul(b6.checked_mul(b6)?.checked_shr(12)?)?
                    .checked_shr(16)?;
                let x3 = x1.checked_add(x2)?.checked_add(2)?.checked_shr(2)?;
                let b4 = ac4
                    .checked_mul(x3.checked_add(32768)? as u32)?
                    .checked_shr(15)?;
                let b7 = (raw_pressure as u32)
                    .checked_sub(b3 as u32)?
                    // in "disable-arithmetic-checks" it is: mode as u8
                    .checked_mul(50000_u32.checked_shr(mode as u32)?)?;

                #[cfg(feature = "defmt")]
                {
                    defmt::debug!("X1: {}", x1);
                    defmt::debug!("X2: {}", x2);
                    defmt::debug!("X3: {}", x3);
                    defmt::debug!("B4: {}", b4);
                    defmt::debug!("B7: {}", b7);
                }

                #[cfg(feature = "log")]
                {
                    log::debug!("X1: {}", x1);
                    log::debug!("X2: {}", x2);
                    log::debug!("X3: {}", x3);
                    log::debug!("B4: {}", b4);
                    log::debug!("B7: {}", b7);
                }

                let p = if b7 < 0x80000000 {
                    b7.checked_mul(2)?.checked_div(b4)?
                } else {
                    b7.checked_div(b4)?.checked_mul(2)?
                } as i32;

                let x1 = p.checked_shr(8)?.checked_mul(p.checked_shr(8)?)?;
                let x1 = x1.checked_mul(3038)?.checked_shr(16)?;
                let x2 = -7357_i32.checked_mul(p)?.checked_shr(16)?;

                let p =
                    p.checked_add(x1.checked_add(x2)?.checked_add(3791_i32)?.checked_shr(4)?)?;

                #[cfg(feature = "defmt")]
                {
                    defmt::debug!("X1: {}", x1);
                    defmt::debug!("X2: {}", x2);
                    defmt::debug!("P: {}", p);
                }

                #[cfg(feature = "log")]
                {
                    log::debug!("X1: {}", x1);
                    log::debug!("X2: {}", x2);
                    log::debug!("P: {}", p);
                }

                Some(p)
            }
        }

        #[cfg(feature = "disable-arithmetic-checks")]
        impl<I2C, DELAY> BMP180<I2C, DELAY>
        where
            I2C: i2c_trait,
            DELAY: delay_trait,
        {
            /// Compute B5 value.
            fn compute_b5(&self, raw_temperature: i16) -> Option<i32> {
                let calibration = self.calibration();

                let x1 = ((raw_temperature as i32 - calibration.ac6 as i32)
                    * calibration.ac5 as i32)
                    >> 15;
                let x2 = ((calibration.mc as i32) << 11) / (x1 + calibration.md as i32);

                Some(x1 + x2)
            }

            /// Compute true temprature in `0.1 C`.
            fn compute_temperature(&self, raw_temperature: i16) -> Option<i32> {
                let b5 = self.compute_b5(raw_temperature)?;

                #[cfg(feature = "defmt")]
                {
                    defmt::debug!("Computing temperature");
                    defmt::debug!("Raw temperature: {}", raw_temperature);
                    defmt::debug!("B5: {}", b5);
                }

                #[cfg(feature = "log")]
                {
                    log::debug!("Computing temperature");
                    log::debug!("Raw temperature: {}", raw_temperature);
                    log::debug!("B5: {}", b5);
                }

                Some((b5 + 8) >> 4)
            }

            /// Compute true pressure in `Pa`.
            fn compute_pressure(&self, raw_temperature: i16, raw_pressure: i32) -> Option<i32> {
                let calibration = self.calibration();
                let mode = self.mode();

                #[cfg(feature = "defmt")]
                {
                    defmt::debug!("Computing pressure");
                    defmt::debug!("Raw temperature: {}", raw_temperature);
                    defmt::debug!("Raw pressure: {}", raw_pressure);
                }

                #[cfg(feature = "log")]
                {
                    log::debug!("Computing pressure");
                    log::debug!("Raw temperature: {}", raw_temperature);
                    log::debug!("Raw pressure: {}", raw_pressure);
                }

                let b5 = self.compute_b5(raw_temperature)?;

                let b6 = b5 - 4000;
                let x1 = (calibration.b2 as i32 * ((b6 * b6) >> 12)) >> 11;
                let x2 = (calibration.ac2 as i32 * b6) >> 11;
                let x3 = x1 + x2;
                let b3 = ((((calibration.ac1 as i32) * 4 + x3) << mode as u8) + 2) / 4;

                #[cfg(feature = "defmt")]
                {
                    defmt::debug!("B5: {}", b5);
                    defmt::debug!("B6: {}", b6);
                    defmt::debug!("X1: {}", x1);
                    defmt::debug!("X2: {}", x2);
                    defmt::debug!("X3: {}", x3);
                    defmt::debug!("B3: {}", b3);
                }

                #[cfg(feature = "log")]
                {
                    log::debug!("B5: {}", b5);
                    log::debug!("B6: {}", b6);
                    log::debug!("X1: {}", x1);
                    log::debug!("X2: {}", x2);
                    log::debug!("X3: {}", x3);
                    log::debug!("B3: {}", b3);
                }

                let x1 = (calibration.ac3 as i32 * b6) >> 13;
                let x2 = (calibration.b1 as i32 * ((b6 * b6) >> 12)) >> 16;
                let x3 = ((x1 + x2) + 2) >> 2;
                let b4 = ((calibration.ac4 as u32) * ((x3 + 32768) as u32)) >> 15;
                let b7 = (raw_pressure as u32 - b3 as u32) * (50000 >> mode as u8);

                #[cfg(feature = "defmt")]
                {
                    defmt::debug!("X1: {}", x1);
                    defmt::debug!("X2: {}", x2);
                    defmt::debug!("X3: {}", x3);
                    defmt::debug!("B4: {}", b4);
                    defmt::debug!("B7: {}", b7);
                }

                #[cfg(feature = "log")]
                {
                    log::debug!("X1: {}", x1);
                    log::debug!("X2: {}", x2);
                    log::debug!("X3: {}", x3);
                    log::debug!("B4: {}", b4);
                    log::debug!("B7: {}", b7);
                }

                let p = if b7 < 0x80000000 {
                    (b7 * 2) / b4
                } else {
                    (b7 / b4) * 2
                } as i32;

                let x1 = (p >> 8) * (p >> 8);
                let x1 = (x1 * 3038) >> 16;
                let x2 = (-7357 * p) >> 16;

                let p = p + ((x1 + x2 + 3791_i32) >> 4);

                #[cfg(feature = "defmt")]
                {
                    defmt::debug!("X1: {}", x1);
                    defmt::debug!("X2: {}", x2);
                    defmt::debug!("P: {}", p);
                }

                #[cfg(feature = "log")]
                {
                    log::debug!("X1: {}", x1);
                    log::debug!("X2: {}", x2);
                    log::debug!("P: {}", p);
                }

                Some(p)
            }
        }

        #[cfg(feature = "i-know-what-i-am-doing")]
        impl<I2C, DELAY> BMP180<I2C, DELAY> {
            /// Split the `BMP180` device into its parts.
            ///
            /// Only available when the `i-know-what-i-am-doing` feature is enabled.
            pub fn into_parts(self) -> (Address, Mode, Calibration, i32, i32, I2C, DELAY) {
                (
                    self.addr,
                    self.mode,
                    self.calibration,
                    self.temperature,
                    self.pressure,
                    self.i2c,
                    self.delay,
                )
            }

            /// Create a `BMP180` device from its parts.
            ///
            /// Only available when the `i-know-what-i-am-doing` feature is enabled.
            pub fn from_parts(
                addr: Address,
                mode: Mode,
                calibration: Calibration,
                temperature: i32,
                pressure: i32,
                i2c: I2C,
                delay: DELAY,
            ) -> Self {
                Self {
                    addr,
                    mode,
                    calibration,
                    temperature,
                    pressure,
                    i2c,
                    delay,
                }
            }
        }
    }

    #[cfg(feature=feature_)]
    pub use inner::*;
}