Skip to main content

Crate es8311_ng

Crate es8311_ng 

Source
Expand description

§Everest Semiconductor ES8311 audio codec driver

A platform-agnostic driver to configure the Everest Semiconductor ES8311 mono audio codec over I²C.

This driver was built using embedded-hal 1.0 and es8311-registers. Enable the async feature for an equivalent driver on embedded-hal-async in the asynch module.

The driver only configures the codec. Audio data flows over I²S, which the host drives: the codec runs in slave mode, with MCLK, SCLK and LRCK supplied by the host.

§Safe defaults

After Es8311::init, the DAC is muted at minimum volume and all analog blocks are powered down. Nothing reaches the output until Es8311::dac_power_up and set_mute(false). Boards with an always-on speaker amplifier play sound as soon as the DAC is unmuted.

§Volume limit

Es8311::set_volume never writes a value above Es8311::max_volume. The limit defaults to the chip’s full scale, DAC_VOLUME_MAX (+32 dB). Lower it with Es8311::set_max_volume when an amplifier after the codec adds gain, so the speaker or the amplifier cannot be overdriven. On the Kode Dot, with an NS4150B class-D amplifier, the limit is 0xA9 (-11 dB).

The raw register access (Es8311::write_register) bypasses the limit.

Re-exports§

pub use es8311_registers as registers;

Modules§

asynchasync
Async driver on embedded-hal-async.

Structs§

Config
The audio interface configuration.
Es8311
ES8311 driver.

Enums§

Error
A driver error.
SerialFormat
The serial audio data format, as set in SdpIn and SdpOut.
WordLength
The serial audio data word length, as set in SdpIn and SdpOut.

Constants§

ALTERNATE_DEVICE_ADDRESS
The 7-bit I²C address with the CE pin high.
DAC_VOLUME_0DB
The DacVolume value for 0 dB. Each step is 0.5 dB.
DAC_VOLUME_MAX
The highest DacVolume value: +32 dB.
DEFAULT_DEVICE_ADDRESS
The 7-bit I²C address with the CE pin low.
ES8311_CHIP_ID
The ID read from ChipId1 and ChipId2 (0xFD, 0xFE) of an ES8311.
RESET_DELAY_MS
How long Es8311::init holds the digital blocks in reset, in milliseconds.