pub struct TempMon { /* private fields */ }
Expand description
A Temperature Monitor (TEMPMON)
See the module-level documentation for important notes.
Example
use imxrt_hal as hal;
use imxrt_ral as ral;
let inst = unsafe { ral::tempmon::TEMPMON::instance() };
let mut temp_mon = hal::tempmon::TempMon::new(inst);
loop {
if let Ok(_temperature) = nb::block!(temp_mon.measure_temp()) {
// _temperature in mC (1°C = 1000°mC)
}
}
Implementations§
source§impl TempMon
impl TempMon
sourcepub fn with_measure_freq(tempmon: TEMPMON, measure_freq: u16) -> Self
pub fn with_measure_freq(tempmon: TEMPMON, measure_freq: u16) -> Self
Initialize the temperature monitor.
The measure_freq
determines how many RTC clocks to wait before automatically repeating a temperature
measurement. The pause time before remeasuring is the field value multiplied by the RTC period.
Find more details set_measure_frequency
.
sourcepub fn measure_temp(&mut self) -> Result<i32, PowerDownError>
pub fn measure_temp(&mut self) -> Result<i32, PowerDownError>
Triggers a new measurement
If you configured automatically repeating, this will trigger additional measurement. Use get_temp instate to get the last read value
The returning temperature in 1/1000 Celsius (°mC)
Example: 25500°mC -> 25.5°C
sourcepub fn get_temp(&self) -> Result<i32, PowerDownError>
pub fn get_temp(&self) -> Result<i32, PowerDownError>
Returns the last read value from the temperature sensor
The returning temperature in 1/1000 Celsius (°mC)
Example: 25500°mC -> 25.5°C
sourcepub fn start(&mut self) -> Result<(), PowerDownError>
pub fn start(&mut self) -> Result<(), PowerDownError>
Starts the measurement process. If the measurement frequency is zero, this results in a single conversion.
sourcepub fn stop(&self)
pub fn stop(&self)
Stops the measurement process. This only has an effect If the measurement frequency is not zero.
sourcepub fn is_powered_up(&self) -> bool
pub fn is_powered_up(&self) -> bool
Returns the true if the tempmon module is powered up.
sourcepub fn power_down(&self)
pub fn power_down(&self)
This powers down the temperature sensor.
sourcepub fn set_alarm_values(
&mut self,
low_alarm_mc: i32,
high_alarm_mc: i32,
panic_alarm_mc: i32
)
pub fn set_alarm_values( &mut self, low_alarm_mc: i32, high_alarm_mc: i32, panic_alarm_mc: i32 )
Set the temperature that will generate a low alarm, high alarm, and panic alarm interrupt when the temperature exceeded this values.
Note:
low_alarm_mc, high_alarm_mc, and panic_alarm_mc are in milli Celsius (1/1000 °C)
sourcepub fn alarm_values(&self) -> (i32, i32, i32)
pub fn alarm_values(&self) -> (i32, i32, i32)
Queries the temperature that will generate a low alarm, high alarm, and panic alarm interrupt.
Returns (low_alarm_temp, high_alarm_temp, panic_alarm_temp)
sourcepub fn set_measure_frequency(&mut self, measure_freq: u16)
pub fn set_measure_frequency(&mut self, measure_freq: u16)
This bits determines how many RTC clocks to wait before automatically repeating a temperature measurement. The pause time before remeasuring is the field value multiplied by the RTC period.
value | note |
---|---|
0x0000 | Defines a single measurement with no repeat. |
0x0001 | Updates the temperature value at a RTC clock rate. |
0x0002 | Updates the temperature value at a RTC/2 clock rate. |
… | … |
0xFFFF | Determines a two second sample period with a 32.768KHz RTC clock. Exact timings depend on the accuracy of the RTC clock. |