Skip to main content

TempSensor

Struct TempSensor 

Source
pub struct TempSensor<'d> { /* private fields */ }
Expand description

Temperature sensor driver.

Implementations§

Source§

impl<'d> TempSensor<'d>

Source

pub fn new(tsensor: Tsensor<'d>) -> Self

Create a new temperature sensor driver.

Source

pub fn enable(&mut self)

Enable the temperature sensor.

Source

pub fn disable(&mut self)

Disable the temperature sensor.

Source

pub fn set_mode(&mut self, mode: u8)

Set the operating mode.

  • mode — Mode value (0-3). The exact meaning depends on the chip configuration.
Source

pub fn start_conversion(&mut self)

Trigger a single temperature reading (software start).

Writes 1 to the start register to refresh the temperature value.

Source

pub fn data_ready(&self) -> bool

Check if a temperature reading is ready.

Source

pub fn read_raw(&self) -> Option<u16>

Read the raw temperature code (10-bit, range 114-896).

Returns None if data is not ready.

Source

pub fn read_blocking(&self) -> u16

Read the temperature code, blocking until ready.

Source

pub fn clear_status(&mut self)

Clear the temperature sensor status.

Source

pub fn set_high_limit(&mut self, code: u16)

Set the high temperature limit.

Interrupt triggers when temperature code exceeds this value.

Source

pub fn set_low_limit(&mut self, code: u16)

Set the low temperature limit.

Interrupt triggers when temperature code falls below this value.

Source

pub fn set_over_temp_threshold(&mut self, code: u16, enable_interrupt: bool)

Set the over-temperature threshold.

Source

pub fn enable_interrupts( &mut self, done_int: bool, out_thresh_int: bool, overtemp_int: bool, )

Enable specific temperature interrupts.

  • done_int — Conversion done interrupt
  • out_thresh_int — Out-of-threshold interrupt
  • overtemp_int — Over-temperature interrupt
Source

pub fn disable_all_interrupts(&mut self)

Disable all temperature interrupts.

Source

pub fn interrupt_status(&self) -> (bool, bool, bool)

Check interrupt status.

Returns (done, out_thresh, overtemp).

Source

pub fn clear_interrupts(&mut self, done: bool, out_thresh: bool, overtemp: bool)

Clear specific temperature interrupts.

Source

pub fn configure_auto_refresh(&mut self, period: u16, enable: bool)

Configure automatic temperature refresh.

  • period — Refresh period in 32kHz clock cycles.
  • enable — Enable auto refresh.
Source

pub fn enable_calibration(&mut self)

Enable temperature calibration.

Source

pub fn disable_calibration(&mut self)

Disable temperature calibration.

Auto Trait Implementations§

§

impl<'d> Freeze for TempSensor<'d>

§

impl<'d> RefUnwindSafe for TempSensor<'d>

§

impl<'d> Send for TempSensor<'d>

§

impl<'d> Sync for TempSensor<'d>

§

impl<'d> Unpin for TempSensor<'d>

§

impl<'d> UnsafeUnpin for TempSensor<'d>

§

impl<'d> UnwindSafe for TempSensor<'d>

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>,

Source§

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>,

Source§

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.