pub struct Es8311<I2C> { /* private fields */ }Expand description
ES8311 driver.
Implementations§
Source§impl<I2C: I2c> Es8311<I2C>
impl<I2C: I2c> Es8311<I2C>
Sourcepub const fn new(i2c: I2C, addr: u8) -> Self
pub const fn new(i2c: I2C, addr: u8) -> Self
Wraps a bus handle. Call init before anything else.
Sourcepub async fn chip_id(&mut self) -> Result<[u8; 2], I2C::Error>
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.
Sourcepub async fn init(&mut self, delay: &mut impl DelayNs) -> Result<(), I2C::Error>
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.
Sourcepub async fn set_mode(&mut self, mode: Mode) -> Result<(), I2C::Error>
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.
Sourcepub async fn set_mic_gain(&mut self, gain: MicGain) -> Result<(), I2C::Error>
pub async fn set_mic_gain(&mut self, gain: MicGain) -> Result<(), I2C::Error>
Microphone pre-amplifier gain (applied now if recording).
Sourcepub async fn set_adc_volume(&mut self, volume: Volume) -> Result<(), I2C::Error>
pub async fn set_adc_volume(&mut self, volume: Volume) -> Result<(), I2C::Error>
Digital ADC volume.
Sourcepub async fn set_dac_volume(&mut self, volume: Volume) -> Result<(), I2C::Error>
pub async fn set_dac_volume(&mut self, volume: Volume) -> Result<(), I2C::Error>
Digital DAC volume.
Sourcepub async fn set_dac_mute(&mut self, mute: bool) -> Result<(), I2C::Error>
pub async fn set_dac_mute(&mut self, mute: bool) -> Result<(), I2C::Error>
Soft-mutes the DAC (both mute bits).