Skip to main content

Es8311

Struct Es8311 

Source
pub struct Es8311<I2C> { /* private fields */ }
Expand description

ES8311 driver.

Implementations§

Source§

impl<I2C: I2c> Es8311<I2C>

Source

pub const fn new(i2c: I2C, addr: u8) -> Self

Wraps a bus handle. Call init before anything else.

Source

pub async fn chip_id(&mut self) -> Result<[u8; 2], I2C::Error>

Reads CHD1/CHD2. Expect CHIP_ID. The chip doesn’t auto-increment on reads, so this reads one register at a time.

Source

pub async fn init(&mut self, delay: &mut impl DelayNs) -> Result<(), I2C::Error>

Resets the codec and programs clocking and the 16-bit I²S format. Leaves it in Mode::Off, DAC muted at Volume::MIN.

Source

pub const fn mode(&self) -> Mode

Current power mode.

Source

pub async fn set_mode(&mut self, mode: Mode) -> Result<(), I2C::Error>

Powers the requested paths. Silence outside playback modes rests on four independent controls: DAC power-down (0x12), DAC mute (0x31), minimum volume until set (0x32), and gated DAC clocks (0x01).

The I²S clock must be running before entering any mode other than Mode::Off.

Paths are powered down before others are powered up, and the DAC mute is left as it is. Call set_dac_mute after the first samples are flowing to avoid a pop.

Source

pub async fn set_mic_gain(&mut self, gain: MicGain) -> Result<(), I2C::Error>

Microphone pre-amplifier gain (applied now if recording).

Source

pub async fn set_adc_volume(&mut self, volume: Volume) -> Result<(), I2C::Error>

Digital ADC volume.

Source

pub async fn set_dac_volume(&mut self, volume: Volume) -> Result<(), I2C::Error>

Digital DAC volume.

Source

pub async fn set_dac_mute(&mut self, mute: bool) -> Result<(), I2C::Error>

Soft-mutes the DAC (both mute bits).

Source

pub fn release(self) -> I2C

Returns the bus handle.

Auto Trait Implementations§

§

impl<I2C> Freeze for Es8311<I2C>
where I2C: Freeze,

§

impl<I2C> RefUnwindSafe for Es8311<I2C>
where I2C: RefUnwindSafe,

§

impl<I2C> Send for Es8311<I2C>
where I2C: Send,

§

impl<I2C> Sync for Es8311<I2C>
where I2C: Sync,

§

impl<I2C> Unpin for Es8311<I2C>
where I2C: Unpin,

§

impl<I2C> UnsafeUnpin for Es8311<I2C>
where I2C: UnsafeUnpin,

§

impl<I2C> UnwindSafe for Es8311<I2C>
where I2C: UnwindSafe,

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn into(self) -> U

Calls U::from(self).

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

§

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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.
§

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

Performs the conversion.