embassy-nrf

Crates

git

Versions

nrf51

Flavors

Skip to main content

Temp

Struct Temp 

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

Builtin temperature sensor driver.

Implementations§

Source§

impl<'d> Temp<'d>

Source

pub fn new( _peri: Peri<'d, TEMP>, _irq: impl Binding<TEMP, InterruptHandler> + 'd, ) -> Self

Create a new temperature sensor driver.

Source

pub async fn read_celsius_x4(&mut self) -> i32

Perform an asynchronous temperature measurement. The returned future can be awaited to obtain the measurement.

The result is in units of 0.25 °C, i.e. divide by 4 to get °C.

If the future is dropped, the measurement is cancelled.

§Example
use embassy_nrf::{bind_interrupts, temp};
use embassy_nrf::temp::Temp;

bind_interrupts!(struct Irqs {
    TEMP => temp::InterruptHandler;
});

let mut t = Temp::new(p.TEMP, Irqs);
let celsius: i32 = t.read_celsius_x4().await / 4;

Auto Trait Implementations§

§

impl<'d> !UnwindSafe for Temp<'d>

§

impl<'d> Freeze for Temp<'d>

§

impl<'d> RefUnwindSafe for Temp<'d>

§

impl<'d> Send for Temp<'d>

§

impl<'d> Sync for Temp<'d>

§

impl<'d> Unpin for Temp<'d>

§

impl<'d> UnsafeUnpin for Temp<'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 = !

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.