blob: 1a01d27049b5cbf29601711433d9a5f60904ad47 (
plain)
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
|
//! Functions for all devices specific to each operating mode
use ic;
fn convert_measurement<IC>(register_data: u16) -> i16
where
IC: ic::Resolution
{
let value = register_data;
if IC::BITS == ic::ResolutionBits::_12 {
let is_negative = (value & 0b1000_0000_0000_0000) != 0;
if is_negative {
let value = 0b1111_0000_0000_0000 | (value >> 4);
value as i16
}
else {
(value >> 4) as i16
}
}
else {
value as i16
}
}
mod oneshot;
mod continuous;
|