pub struct Configuration {
pub high_alert: bool,
pub low_alert: bool,
pub data_ready: bool,
pub eeprom_busy: bool,
pub mode: ConversionMode,
pub cycle: ConversionCycle,
pub averaging: Averaging,
pub alert_mode: AlertMode,
pub alert_polarity: AlertPolarity,
pub alert_pin: AlertPin,
pub soft_reset: bool,
}Expand description
A decoded TMP117 configuration register.
Build one, set the fields, and turn it into the 16-bit register value with
bits; or parse a register read with
from_bits. Configuration::default is the factory
state, 0x0220. The four flags are read-only on the device and are ignored when
written; soft_reset triggers a 2 ms reset when written and always reads back
clear.
§Examples
use pamoja_sensors::tmp117::{Averaging, Configuration, ConversionCycle};
// Average 32 conversions every 4 s, leaving everything else at the factory default.
let config = Configuration {
cycle: ConversionCycle::S4,
averaging: Averaging::X32,
..Configuration::default()
};
// The high byte then the low byte are written to the configuration register.
let [hi, lo] = config.bits().to_be_bytes();
assert_eq!(Configuration::from_bits(u16::from_be_bytes([hi, lo])), config);
assert_eq!(config.cycle.cycle_micros(config.averaging), 4_000_000);Fields§
§high_alert: boolHIGH_Alert flag (bit 15), read-only.
low_alert: boolLOW_Alert flag (bit 14), read-only.
data_ready: boolData_Ready flag (bit 13), read-only.
eeprom_busy: boolEEPROM_Busy flag (bit 12), read-only.
mode: ConversionModeThe conversion mode.
cycle: ConversionCycleThe continuous-mode conversion cycle.
averaging: AveragingThe number of conversions averaged per result.
alert_mode: AlertModeWhether the limits act as alerts or as a therm hysteresis band.
alert_polarity: AlertPolarityThe ALERT pin’s active level.
alert_pin: AlertPinWhat the ALERT pin reflects.
soft_reset: boolSoft_Reset (bit 1): set to trigger a software reset when written.
Implementations§
Trait Implementations§
Source§impl Clone for Configuration
impl Clone for Configuration
Source§fn clone(&self) -> Configuration
fn clone(&self) -> Configuration
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more