pub struct Temp<'d> { /* private fields */ }Expand description
Builtin temperature sensor driver.
Implementations§
Source§impl<'d> Temp<'d>
impl<'d> Temp<'d>
Sourcepub fn new(
_peri: Peri<'d, TEMP>,
_irq: impl Binding<TEMP, InterruptHandler> + 'd,
) -> Self
pub fn new( _peri: Peri<'d, TEMP>, _irq: impl Binding<TEMP, InterruptHandler> + 'd, ) -> Self
Create a new temperature sensor driver.
Sourcepub async fn read_celsius_x4(&mut self) -> i32
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more