embassy-nrf

Crates

git

Versions

nrf9161-ns

Flavors

Skip to main content

Pdm

Struct Pdm 

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

PDM microphone interface

Implementations§

Source§

impl<'d> Pdm<'d>

Source

pub fn new<T: Instance>( pdm: Peri<'d, T>, clk: Peri<'d, impl GpioPin>, din: Peri<'d, impl GpioPin>, _irq: impl Binding<T::Interrupt, InterruptHandler<T>> + 'd, config: Config, ) -> Self

Create PDM driver

Source

pub fn set_gain(&mut self, gain_left: i8, gain_right: i8)

Adjust the gain of the PDM microphone on the fly.

Gains are in units of 0.5 dB, from -40 (-20 dB) to 40 (+20 dB). Values outside that range are clamped.

Source

pub async fn start(&mut self)

Start sampling microphone data into a dummy buffer. Useful to start the microphone and keep it active between recording samples.

Source

pub async fn stop(&mut self)

Stop sampling microphone data inta a dummy buffer

Source

pub async fn sample(&mut self, buffer: &mut [i16]) -> Result<(), Error>

Sample data into the given buffer

Source

pub async fn run_task_sampler<S, const N: usize>( &mut self, bufs: &mut [[i16; N]; 2], sampler: S, ) -> Result<(), Error>
where S: FnMut(&[i16; N]) -> SamplerState,

Continuous sampling with double buffers.

A sampler closure is provided that receives the buffer of samples, noting that the size of this buffer can be less than the original buffer’s size. A command is return from the closure that indicates whether the sampling should continue or stop.

NOTE: The time spent within the callback supplied should not exceed the time taken to acquire the samples into a single buffer. You should measure the time taken by the callback and set the sample buffer size accordingly. Exceeding this time can lead to samples becoming dropped.

Trait Implementations§

Source§

impl<'d> Drop for Pdm<'d>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

§

impl<'d> !RefUnwindSafe for Pdm<'d>

§

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

§

impl<'d> Freeze for Pdm<'d>

§

impl<'d> Send for Pdm<'d>

§

impl<'d> Sync for Pdm<'d>

§

impl<'d> Unpin for Pdm<'d>

§

impl<'d> UnsafeUnpin for Pdm<'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.