Struct imxrt_hal::tempmon::TempMon

source ·
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

source

pub fn new(tempmon: TEMPMON) -> Self

Initialize and create the temperature monitor.

source

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.

source

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

source

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

source

pub fn start(&mut self) -> Result<(), PowerDownError>

Starts the measurement process. If the measurement frequency is zero, this results in a single conversion.

source

pub fn stop(&self)

Stops the measurement process. This only has an effect If the measurement frequency is not zero.

source

pub fn is_powered_up(&self) -> bool

Returns the true if the tempmon module is powered up.

source

pub fn power_down(&self)

This powers down the temperature sensor.

source

pub fn power_up(&self)

This powers up the temperature sensor.

source

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)

source

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)

source

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.

valuenote
0x0000Defines a single measurement with no repeat.
0x0001Updates the temperature value at a RTC clock rate.
0x0002Updates the temperature value at a RTC/2 clock rate.
0xFFFFDetermines a two second sample period with a 32.768KHz RTC clock. Exact timings depend on the accuracy of the RTC clock.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.