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
pub const ID: u8 = 0x58;

pub const RESET: u8 = 0xb6;

#[derive(Copy, Clone)]
pub enum Register {
    Calib0 = 0x88,
    Id = 0xd0,
    Reset = 0xe0,
    Status = 0xf3,
    ControlMeasurement = 0xf4,
    Config = 0xf5,
    PressureMsb = 0xf7,
    PressureLsb = 0xf8,
    PressureXLsb = 0xf9,
    TemperatureMsb = 0xfa,
    TemperatureLsb = 0xfb,
    TemperatureXLsb = 0xfc,
}

pub enum TemperatureOversampling {
    Skipped = 0x0,
    UltraLowPower = 0x1,
    LowPower = 0x2,
    StandardResolution = 0x3,
    HighResolution = 0x4,
    UltraHighResolution = 0x5,
}

#[macro_export]
macro_rules! temperature_resolution {
    (16bit/0.0050dC) => {
        TemperatureOversampling::UltraLowPower
    };
    (17bit/0.0025dC) => {
        TemperatureOversampling::LowPower
    };
    (18bit/0.0012dC) => {
        TemperatureOversampling::StandardResolution
    };
    (19bit/0.0006dC) => {
        TemperatureOversampling::HighResolution
    };
    (20bit/0.0003dC) => {
        TemperatureOversampling::UltraHighResolution
    };
}

pub enum PressureOversampling {
    Skipped = 0x0,
    UltraLowPower = 0x1,
    LowPower = 0x2,
    StandardResolution = 0x3,
    HighResolution = 0x4,
    UltraHighResolution = 0x5,
}

#[macro_export]
macro_rules! pressure_resolution {
    (16bit/2.62Pa) => {
        PressureOversampling::UltraLowPower
    };
    (17bit/1.31Pa) => {
        PressureOversampling::LowPower
    };
    (18bit/0.66Pa) => {
        PressureOversampling::StandardResolution
    };
    (19bit/0.33Pa) => {
        PressureOversampling::HighResolution
    };
    (20bit/0.16Pa) => {
        PressureOversampling::UltraHighResolution
    };
}