In development. It changes without notice.
Topic
Audio Drivers
The ES8311 codec, the ES7210 microphone converter, the AW88298 amplifier, and amplifiers switched by a power chip or a pin.
| Part | Boards |
|---|---|
| Es8311 | M5StickS3. On the M5Cardputer ADV it is only powered down. |
| ES7210 | CoreS3 SE, LILYGO T-Deck. It is only powered down: the firmware uses no microphone. |
| Aw88298 | CoreS3 SE |
| Axp192Amp | Core2 v1.3, whose amplifier hangs off the AXP192 |
| GpioAmp | An amplifier switched by a pin, or that is always on |
These drivers set up a chip; the samples go through the I2S facade (GPIO & Buses). An amplifier is off when nothing plays.
Files | |
| file | src/ |
| Compile-time selection of the speaker amplifier driver. | |
| file | src/ |
| Compile-time selection of the I2S codec driver. | |
| file | src/ |
| Driver for the Awinic AW88298 I2S smart amplifier. | |
| file | src/ |
| Register map and bring-up values of the AW88298 amplifier. | |
| file | src/ |
| Driver for an amplifier gated by the AXP192 PMIC GPIO2 line. | |
| file | src/ |
| Power-down helper for the unused Everest ES7210 microphone-array ADC. | |
| file | src/ |
| Register map and power-down values for the unused ES7210 mic ADC. | |
| file | src/ |
| Driver for the Everest ES8311 mono audio codec. | |
| file | src/ |
| Register map and bring-up values of the ES8311 codec. | |
| file | src/ |
| Driver for a GPIO-gated analog Class-D amplifier. | |
| file | src/ |
| Abstract contract for the speaker power amplifier after the codec DAC. | |
| file | src/ |
| Abstract contract for an external I2S audio codec (DAC/ADC chip). | |
Classes | |
| class | kleidos:: |
| Awinic AW88298 mono Class-D amplifier with an embedded DAC sitting on the I2S data-out line. On the CoreS3 SE the chip's reset input RSTN is a pin of the AW9523B I/O expander, so the driver owns both the amplifier (I2C 0x36) and the expander bit that holds it in reset (I2C 0x58, P0.2). The I2S clocks must already run before setEnabled(true), as the amplifier locks its sample-rate divider from the bit clock. More about kleidos:: | |
| class | kleidos:: |
| Amplifier whose enable line is wired to GPIO2 of the AXP192 power chip: the NS4168 I2S amplifier of the Core2 v1.3. The amplifier embeds its own DAC and sits on the I2S data-out line; only its shutdown pin is on the power chip. The driver keeps its own small I2C view of the power chip and writes the function field of GPIO2_CTL (0x93) directly, apart from the power manager's instance. More about kleidos:: | |
| class | kleidos:: |
| Everest ES8311 low-power mono codec driver (DAC playback + ADC capture). More about kleidos:: | |
| struct | kleidos:: |
| One register write of a sequence. More about kleidos:: | |
| class | kleidos:: |
| Generic enable-line amplifier for "dumb" analog Class-D parts (e.g. NS4150B, NS4168) whose shutdown pin is wired to a plain MCU GPIO. When the enable pin is negative the amplifier has no software gate (always on); the driver then behaves as a no-op so the rest of the audio path stays uniform. More about kleidos:: | |
| class | kleidos:: |
| Speaker power-amplifier driver interface. More about kleidos:: | |
| struct | kleidos:: |
| Sample format requested from a codec at begin(). More about kleidos:: | |
| class | kleidos:: |
| External I2S audio-codec driver interface. More about kleidos:: | |
Functions | |
| bool | kleidos:: |
| Force an ES7210 microphone-array ADC into its lowest-power state. | |
| bool | kleidos:: |
Power down an ES8311 that no Es8311 instance drives. | |
| bool | kleidos:: |
| List the ES8311 with the introspection engine when it is on the board. | |
| IAudioAmp * | kleidos:: |
| Returns the board's amplifier instance, or nullptr when the board has no software-gated amplifier (always-on part or codec-internal drive). The concrete type is selected at compile time from the board's configuration. The returned pointer has static storage duration; callers must not delete it. | |
| IAudioCodec * | kleidos:: |
| Returns the codec driver selected for this build (fixed per board at build time) at the given I2C address, or nullptr if the board declares no I2S codec. The returned pointer is owned by the driver layer (static storage); callers must not delete it. | |
Variables | |
| constexpr uint8_t | kleidos:: |
| I2SEN / AMPPD / PWDN. | |
| constexpr uint8_t | kleidos:: |
| RMSE / HAGCE / HDCCE / HMUTE. | |
| constexpr uint8_t | kleidos:: |
| I2S format + sample-rate code. | |
| constexpr uint8_t | kleidos:: |
| Volume. | |
| constexpr uint8_t | kleidos:: |
| Boost mode. | |
| constexpr uint16_t | kleidos:: |
| reg 0x61: boost mode disabled. | |
| constexpr uint16_t | kleidos:: |
| reg 0x04: I2SEN=1 AMPPD=0 PWDN=0. | |
| constexpr uint16_t | kleidos:: |
| reg 0x04: I2SEN=0 (mute output). | |
| constexpr uint16_t | kleidos:: |
| reg 0x05: no AGC/DCC/mute. | |
| constexpr uint16_t | kleidos:: |
| reg 0x0C: full volume. | |
| constexpr uint16_t | kleidos:: |
| reg 0x06 base: I2SBCK=0 (16*2 BCLK per frame). | |
| constexpr uint8_t | kleidos:: |
| Output port 0 register. | |
| constexpr uint8_t | kleidos:: |
| Direction port 0 (0 = output). | |
| constexpr uint8_t | kleidos:: |
| P0.2 drives the amp's RSTN (0 = reset). | |
| constexpr uint8_t | kleidos:: |
| Rate-code buckets. | |
| constexpr size_t | kleidos:: |
| Table length. | |
| constexpr uint8_t | kleidos:: |
| Reset / CSM control (used only as a presence probe). | |
| constexpr uint8_t | kleidos:: |
| Master-clock and ADC-clock gating. | |
| constexpr uint8_t | kleidos:: |
| Global power-down bits. | |
| constexpr uint8_t | kleidos:: |
| Analog power (VMID / LDO). | |
| constexpr uint8_t | kleidos:: |
| Mic 1 power. | |
| constexpr uint8_t | kleidos:: |
| Mic 2 power. | |
| constexpr uint8_t | kleidos:: |
| Mic 3 power. | |
| constexpr uint8_t | kleidos:: |
| Mic 4 power. | |
| constexpr uint8_t | kleidos:: |
| Mic 1/2 bias + ADC + PGA power. | |
| constexpr uint8_t | kleidos:: |
| Mic 3/4 bias + ADC + PGA power. | |
| constexpr uint8_t | kleidos:: |
| reg 0x01: gate all ADC clocks. | |
| constexpr uint8_t | kleidos:: |
| reg 0x06: assert power-down bits. | |
| constexpr uint8_t | kleidos:: |
| reg 0x40: power down analog (VMID/LDO). | |
| constexpr uint8_t | kleidos:: |
| regs 0x47..0x4C: mic bias + ADC + PGA off. | |
| constexpr uint8_t | kleidos:: |
| CSM power on/off. | |
| constexpr uint8_t | kleidos:: |
| Clock manager (MCLK source). | |
| constexpr uint8_t | kleidos:: |
| Clock manager (MULT_PRE). | |
| constexpr uint8_t | kleidos:: |
| Serial port, playback side (SDP_IN). | |
| constexpr uint8_t | kleidos:: |
| Analog circuitry power. | |
| constexpr uint8_t | kleidos:: |
| PGA / ADC modulator. | |
| constexpr uint8_t | kleidos:: |
| DAC power. | |
| constexpr uint8_t | kleidos:: |
| HP/output drive enable. | |
| constexpr uint8_t | kleidos:: |
| Mic select / PGA gain. | |
| constexpr uint8_t | kleidos:: |
| ADC volume. | |
| constexpr uint8_t | kleidos:: |
| ADC EQ bypass / DC offset. | |
| constexpr uint8_t | kleidos:: |
| DAC volume (0xBF == 0 dB). | |
| constexpr uint8_t | kleidos:: |
| DAC EQ bypass. | |
| constexpr uint8_t | kleidos:: |
| Read-only ID high. | |
| constexpr uint8_t | kleidos:: |
| Read-only ID low. | |
| constexpr uint8_t | kleidos:: |
| Expected ID high byte. | |
| constexpr uint8_t | kleidos:: |
| Expected ID low byte. | |
| constexpr uint8_t | kleidos:: |
| reg 0x00: CSM power on. | |
| constexpr uint8_t | kleidos:: |
| reg 0x00: CSM off, every block in reset (power-on value). | |
| constexpr uint8_t | kleidos:: |
| MCLK=BCLK (DAC path). | |
| constexpr uint8_t | kleidos:: |
| MCLK=BCLK (ADC path). | |
| constexpr uint8_t | kleidos:: |
| reg 0x01: every clock gate off. | |
| constexpr uint8_t | kleidos:: |
| reg 0x02: MULT_PRE=3 (MCLK from BCLK). | |
| constexpr uint8_t | kleidos:: |
| reg 0x09/0x0A: I2S, 16-bit words, left slot, unmuted. | |
| constexpr uint8_t | kleidos:: |
| reg 0x0D: analog circuitry on. | |
| constexpr uint8_t | kleidos:: |
| reg 0x0D: analog circuitry off. | |
| constexpr uint8_t | kleidos:: |
| reg 0x0E: PGA + ADC modulator on. | |
| constexpr uint8_t | kleidos:: |
| reg 0x0E: PGA + ADC modulator off. | |
| constexpr uint8_t | kleidos:: |
| reg 0x12: DAC power on. | |
| constexpr uint8_t | kleidos:: |
| reg 0x12: DAC power down (power-on value). | |
| constexpr uint8_t | kleidos:: |
| reg 0x13: HP/output drive enable. | |
| constexpr uint8_t | kleidos:: |
| reg 0x13: output drive off. | |
| constexpr uint8_t | kleidos:: |
| reg 0x14: minimum mic PGA gain. | |
| constexpr uint8_t | kleidos:: |
| reg 0x17: ADC volume at full scale. | |
| constexpr uint8_t | kleidos:: |
| reg 0x1C: ADC EQ bypass / DC offset default. | |
| constexpr uint8_t | kleidos:: |
| reg 0x32: DAC volume at 0 dB. | |
| constexpr uint8_t | kleidos:: |
| reg 0x32: DAC volume at -95.5 dB (mute). | |
| constexpr uint8_t | kleidos:: |
| reg 0x37: DAC EQ bypass. | |
| constexpr uint8_t | kleidos:: |
| constexpr uint32_t | kleidos:: |
| Lowest sample rate the codec's clock tree takes (datasheet: 8 to 96 kHz). | |
| constexpr uint32_t | kleidos:: |
| Highest sample rate the codec's clock tree takes. | |
| constexpr std::array | kleidos:: |
| constexpr size_t | kleidos:: |
| Index of the DAC volume write in kSpeakerBringUp. | |
| constexpr std::array | kleidos:: |
| constexpr size_t | kleidos:: |
| Index of the state machine's write in kPowerDown. | |
| constexpr size_t | kleidos:: |
Function Documentation
createAmp() #
Returns the board's amplifier instance, or nullptr when the board has no software-gated amplifier (always-on part or codec-internal drive). The concrete type is selected at compile time from the board's configuration. The returned pointer has static storage duration; callers must not delete it.
- Returns
- Pointer to the static amp instance, or nullptr if no gated amp exists.
- See also
- IAudioCodec, createCodec
createCodec() #
Returns the codec driver selected for this build (fixed per board at build time) at the given I2C address, or nullptr if the board declares no I2S codec. The returned pointer is owned by the driver layer (static storage); callers must not delete it.
- Parameters
-
Name Direction Meaning address in I2C address of the codec chip.
- Returns
- Pointer to the static codec instance, or nullptr.
powerDownEs7210() #
Force an ES7210 microphone-array ADC into its lowest-power state.
Kleidos never captures audio, but on the boards that carry an ES7210 (T-Deck, CoreS3 SE) the chip powers up with its clocks running and its analog supply on. This probes the device and, if present, writes the power-down sequence (microphone inputs off, analog off, clocks gated, global power-down) and registers the chip's register table for introspection. It only ever touches the ES7210's own address, so it does not disturb the other chips sharing the bus.
- Parameters
-
Name Direction Meaning address in 7-bit ES7210 I2C address. A negative value is a no-op (board has no ES7210), returning true.
- Return values
-
Value Meaning true The chip was absent (nothing to do) or powered down successfully. false The chip acknowledged but a power-down register write failed.
powerDownEs8311() #
Power down an ES8311 that no Es8311 instance drives.
For a codec whose supply outlives the firmware's hold on it: on the M5Cardputer ADV the chip keeps its supply while the board sleeps, and keeps whatever state the last firmware (another image, or this one before a crash) left it in. The sleep path calls this whether or not the speaker HAL ever started the codec. It probes the chip-id pair 0xFD / 0xFE and, when it matches, writes es8311::, every step of it, which leaves the chip as it reads at power-on. It touches only the codec's own address, so the keyboard and IMU sharing the bus are left alone.
- Parameters
-
Name Direction Meaning address in 7-bit ES8311 I2C address.
- Return values
-
Value Meaning true The chip did not answer (nothing to do) or was powered down. false Another chip answered at address, or a power-down write failed.
registerEs8311Introspection() #
List the ES8311 with the introspection engine when it is on the board.
Reads the chip-id pair 0xFD / 0xFE at address and, when it matches, registers the codec's register table. It writes nothing to the chip. Call it once during single-threaded board bring-up, as the registry asks: the codec driver itself starts only with the first tone, and not at all while the sound setting is off.
- Parameters
-
Name Direction Meaning address in 7-bit ES8311 I2C address.
- Return values
-
Value Meaning true The chip answered with its id and its table is registered. false No ES8311 at address, the address is not the one the table reads through, or the registry refused the table.
Variable Documentation
kBitsPerSample #
The only sample width the clock scheme serves: two 16-bit slots per frame are the 32 bit clocks MULT_PRE=3 multiplies to 256 times the sample rate.
kPowerDown #
The power-down, written in this order: the DAC volume to mute first, so nothing that still reaches the output is heard, then the output driver, the DAC and the microphone PGA and ADC modulator off, then the state machine off with every block held in reset, and only then the analog circuitry and every clock gate off. The analog write comes after the state machine's: while the state machine runs it owns SYSTEM3's bias and reference bits, and a 0xFC written then read back 0x84 on a Cardputer ADV, its bias generators left on; written after, it holds. The sequence leaves the codec as it reads at power-on (RESET 0x1F, SYSTEM3 0xFC, SYSTEM8 0x02), whatever state it was in before, so the same sequence serves a codec the driver started and one it never did.
kPowerDownAnalogIndex #
Index of the analog power-down in kPowerDown, which must follow the state machine's write.
kSpeakerBringUp #
The speaker's bring-up, written in this order once the bit clock runs: state machine on, master clock from the bit clock times 8, the playback port at I2S 16-bit, analog circuitry, DAC and output driver on, the DAC volume at 0 dB and its equalizer bypassed. The driver writes its own level over the volume entry, the one at kBringUpVolumeIndex.