arduino-audio-driver
Loading...
Searching...
No Matches
ES8388 Class Reference

Header-only driver class for the ES8388 codec chip. More...

#include <ES8388.h>

Public Member Functions

 ES8388 ()=default
error_t configFmt (codec_mode_t mod, i2s_format_t cfg)
 Configure ES8388 I2S format.
error_t configI2S (codec_mode_t mode, I2SDefinition *iface)
 Configure ES8388 codec mode and I2S interface.
error_t configInputDevice (es8388_input_device_t input)
 Set ES8388 adc input mode.
error_t configOutputDevice (output_device_t output_device)
 Set ES8388 dac output mode.
error_t ctrlStateActive (codec_mode_t mode, bool ctrl_state_active)
 Control ES8388 codec chip.
error_t deinit (void)
 Deinitialize ES8388 codec chip.
error_t getVoiceMute (void)
 Get ES8388 DAC mute status.
error_t getVoiceVolume (int *volume)
 Get voice volume (0~100).
int getVolumeHack ()
 Provides the volume hack in use.
error_t i2sConfigClock (es_i2s_clock_t cfg)
 Configure I2S clock in MASTER mode.
error_t init (codec_config_t *cfg, int volumeHack)
 Initialize ES8388 codec chip.
void readAll ()
 Print all ES8388 registers.
error_t readReg (uint8_t reg_add, uint8_t *p_data)
error_t route (input_device_t in, output_device_t out)
 Routes an analog input directly to an analog output, bypassing the ADC/DAC (e.g. for an analog monitoring/passthrough path). Only ADC_INPUT_LINE1 and ADC_INPUT_LINE2 are supported as input.
error_t routeIn2toOut1 ()
 Routes LIN2/RIN2 directly to LOUT1/ROUT1 (analog passthrough).
error_t setAdcDacVolume (int mode, int volume, int dot)
void setAddress (int addr)
 Defines the I2C device address.
error_t setBitsPerSample (codec_mode_t mode, sample_bits_t bit_per_sample)
 Configure ES8388 data sample bits.
error_t setMicGain (es_mic_gain_t gain)
 Set ES8388 mic gain.
error_t setVoiceMute (bool enable)
 Configure ES8388 DAC mute or not.
error_t setVoiceVolume (int volume)
 Set voice volume.
error_t setVoiceVolume0 (int volume)
error_t setVoiceVolume1 (int volume)
error_t setVoiceVolume2 (int volume)
void setVolumeHack (int volumeHack)
 Defines the volume hack to use (see AI_THINKER_ES8388_VOLUME_HACK).
void setWire (i2c_bus_handle_t handle)
 Defines the I2C bus instance to be used.
error_t start (codec_mode_t mode)
 Start ES8388 codec chip.
error_t stop (codec_mode_t mode)
 Stop ES8388 codec chip.
error_t writeReg (uint8_t reg_add, uint8_t data)

Static Public Attributes

static constexpr uint8_t ES8388_ADCCONTROL1 = 0x09
static constexpr uint8_t ES8388_ADCCONTROL10 = 0x12
static constexpr uint8_t ES8388_ADCCONTROL11 = 0x13
static constexpr uint8_t ES8388_ADCCONTROL12 = 0x14
static constexpr uint8_t ES8388_ADCCONTROL13 = 0x15
static constexpr uint8_t ES8388_ADCCONTROL14 = 0x16
static constexpr uint8_t ES8388_ADCCONTROL2 = 0x0a
static constexpr uint8_t ES8388_ADCCONTROL3 = 0x0b
static constexpr uint8_t ES8388_ADCCONTROL4 = 0x0c
static constexpr uint8_t ES8388_ADCCONTROL5 = 0x0d
static constexpr uint8_t ES8388_ADCCONTROL6 = 0x0e
static constexpr uint8_t ES8388_ADCCONTROL7 = 0x0f
static constexpr uint8_t ES8388_ADCCONTROL8 = 0x10
static constexpr uint8_t ES8388_ADCCONTROL9 = 0x11
static constexpr uint8_t ES8388_ADCPOWER = 0x03
static constexpr int ES8388_ADDR = 0x10
static constexpr uint8_t ES8388_ANAVOLMANAG = 0x07
static constexpr uint8_t ES8388_CHIPLOPOW1 = 0x05
static constexpr uint8_t ES8388_CHIPLOPOW2 = 0x06
static constexpr uint8_t ES8388_CHIPPOWER = 0x02
static constexpr uint8_t ES8388_CONTROL1 = 0x00
static constexpr uint8_t ES8388_CONTROL2 = 0x01
static constexpr uint8_t ES8388_DACCONTROL1 = 0x17
static constexpr uint8_t ES8388_DACCONTROL10 = 0x20
static constexpr uint8_t ES8388_DACCONTROL11 = 0x21
static constexpr uint8_t ES8388_DACCONTROL12 = 0x22
static constexpr uint8_t ES8388_DACCONTROL13 = 0x23
static constexpr uint8_t ES8388_DACCONTROL14 = 0x24
static constexpr uint8_t ES8388_DACCONTROL15 = 0x25
static constexpr uint8_t ES8388_DACCONTROL16 = 0x26
static constexpr uint8_t ES8388_DACCONTROL17 = 0x27
static constexpr uint8_t ES8388_DACCONTROL18 = 0x28
static constexpr uint8_t ES8388_DACCONTROL19 = 0x29
static constexpr uint8_t ES8388_DACCONTROL2 = 0x18
static constexpr uint8_t ES8388_DACCONTROL20 = 0x2a
static constexpr uint8_t ES8388_DACCONTROL21 = 0x2b
static constexpr uint8_t ES8388_DACCONTROL22 = 0x2c
static constexpr uint8_t ES8388_DACCONTROL23 = 0x2d
static constexpr uint8_t ES8388_DACCONTROL24 = 0x2e
static constexpr uint8_t ES8388_DACCONTROL25 = 0x2f
static constexpr uint8_t ES8388_DACCONTROL26 = 0x30
static constexpr uint8_t ES8388_DACCONTROL27 = 0x31
static constexpr uint8_t ES8388_DACCONTROL28 = 0x32
static constexpr uint8_t ES8388_DACCONTROL29 = 0x33
static constexpr uint8_t ES8388_DACCONTROL3 = 0x19
static constexpr uint8_t ES8388_DACCONTROL30 = 0x34
static constexpr uint8_t ES8388_DACCONTROL4 = 0x1a
static constexpr uint8_t ES8388_DACCONTROL5 = 0x1b
static constexpr uint8_t ES8388_DACCONTROL6 = 0x1c
static constexpr uint8_t ES8388_DACCONTROL7 = 0x1d
static constexpr uint8_t ES8388_DACCONTROL8 = 0x1e
static constexpr uint8_t ES8388_DACCONTROL9 = 0x1f
static constexpr uint8_t ES8388_DACPOWER = 0x04
static constexpr uint8_t ES8388_MASTERMODE = 0x08

Protected Attributes

int dac_power = 0x3c
int i2c_addr = ES8388_ADDR
i2c_bus_handle_t i2c_handle = nullptr
int volume_hack = AI_THINKER_ES8388_VOLUME_HACK

Detailed Description

Header-only driver class for the ES8388 codec chip.

Author
Phil Schatzmann

Constructor & Destructor Documentation

◆ ES8388()

ES8388 ( )
default

Member Function Documentation

◆ configFmt()

error_t configFmt ( codec_mode_t mod,
i2s_format_t cfg )
inline

Configure ES8388 I2S format.

◆ configI2S()

error_t configI2S ( codec_mode_t mode,
I2SDefinition * iface )
inline

Configure ES8388 codec mode and I2S interface.

◆ configInputDevice()

error_t configInputDevice ( es8388_input_device_t input)
inline

Set ES8388 adc input mode.

◆ configOutputDevice()

error_t configOutputDevice ( output_device_t output_device)
inline

Set ES8388 dac output mode.

◆ ctrlStateActive()

error_t ctrlStateActive ( codec_mode_t mode,
bool ctrl_state_active )
inline

Control ES8388 codec chip.

◆ deinit()

error_t deinit ( void )
inline

Deinitialize ES8388 codec chip.

◆ getVoiceMute()

error_t getVoiceMute ( void )
inline

Get ES8388 DAC mute status.

◆ getVoiceVolume()

error_t getVoiceVolume ( int * volume)
inline

Get voice volume (0~100).

◆ getVolumeHack()

int getVolumeHack ( )
inline

Provides the volume hack in use.

◆ i2sConfigClock()

error_t i2sConfigClock ( es_i2s_clock_t cfg)
inline

Configure I2S clock in MASTER mode.

◆ init()

error_t init ( codec_config_t * cfg,
int volumeHack )
inline

Initialize ES8388 codec chip.

◆ readAll()

void readAll ( )
inline

Print all ES8388 registers.

◆ readReg()

error_t readReg ( uint8_t reg_add,
uint8_t * p_data )
inline

◆ route()

error_t route ( input_device_t in,
output_device_t out )
inline

Routes an analog input directly to an analog output, bypassing the ADC/DAC (e.g. for an analog monitoring/passthrough path). Only ADC_INPUT_LINE1 and ADC_INPUT_LINE2 are supported as input.

Parameters
inADC_INPUT_LINE1 or ADC_INPUT_LINE2
outDAC_OUTPUT_NONE, DAC_OUTPUT_LINE1, DAC_OUTPUT_LINE2 or DAC_OUTPUT_ALL see https://m5stack-doc.oss-cn-shenzhen.aliyuncs.com/1141/ES8388.pdf

◆ routeIn2toOut1()

error_t routeIn2toOut1 ( )
inline

Routes LIN2/RIN2 directly to LOUT1/ROUT1 (analog passthrough).

◆ setAdcDacVolume()

error_t setAdcDacVolume ( int mode,
int volume,
int dot )
inline

◆ setAddress()

void setAddress ( int addr)
inline

Defines the I2C device address.

◆ setBitsPerSample()

error_t setBitsPerSample ( codec_mode_t mode,
sample_bits_t bit_per_sample )
inline

Configure ES8388 data sample bits.

◆ setMicGain()

error_t setMicGain ( es_mic_gain_t gain)
inline

Set ES8388 mic gain.

◆ setVoiceMute()

error_t setVoiceMute ( bool enable)
inline

Configure ES8388 DAC mute or not.

◆ setVoiceVolume()

error_t setVoiceVolume ( int volume)
inline

Set voice volume.

Parameters
volumevoice volume (0~100)

◆ setVoiceVolume0()

error_t setVoiceVolume0 ( int volume)
inline

◆ setVoiceVolume1()

error_t setVoiceVolume1 ( int volume)
inline

◆ setVoiceVolume2()

error_t setVoiceVolume2 ( int volume)
inline

◆ setVolumeHack()

void setVolumeHack ( int volumeHack)
inline

Defines the volume hack to use (see AI_THINKER_ES8388_VOLUME_HACK).

◆ setWire()

void setWire ( i2c_bus_handle_t handle)
inline

Defines the I2C bus instance to be used.

◆ start()

error_t start ( codec_mode_t mode)
inline

Start ES8388 codec chip.

◆ stop()

error_t stop ( codec_mode_t mode)
inline

Stop ES8388 codec chip.

◆ writeReg()

error_t writeReg ( uint8_t reg_add,
uint8_t data )
inline

Member Data Documentation

◆ dac_power

int dac_power = 0x3c
protected

◆ ES8388_ADCCONTROL1

uint8_t ES8388_ADCCONTROL1 = 0x09
staticconstexpr

◆ ES8388_ADCCONTROL10

uint8_t ES8388_ADCCONTROL10 = 0x12
staticconstexpr

◆ ES8388_ADCCONTROL11

uint8_t ES8388_ADCCONTROL11 = 0x13
staticconstexpr

◆ ES8388_ADCCONTROL12

uint8_t ES8388_ADCCONTROL12 = 0x14
staticconstexpr

◆ ES8388_ADCCONTROL13

uint8_t ES8388_ADCCONTROL13 = 0x15
staticconstexpr

◆ ES8388_ADCCONTROL14

uint8_t ES8388_ADCCONTROL14 = 0x16
staticconstexpr

◆ ES8388_ADCCONTROL2

uint8_t ES8388_ADCCONTROL2 = 0x0a
staticconstexpr

◆ ES8388_ADCCONTROL3

uint8_t ES8388_ADCCONTROL3 = 0x0b
staticconstexpr

◆ ES8388_ADCCONTROL4

uint8_t ES8388_ADCCONTROL4 = 0x0c
staticconstexpr

◆ ES8388_ADCCONTROL5

uint8_t ES8388_ADCCONTROL5 = 0x0d
staticconstexpr

◆ ES8388_ADCCONTROL6

uint8_t ES8388_ADCCONTROL6 = 0x0e
staticconstexpr

◆ ES8388_ADCCONTROL7

uint8_t ES8388_ADCCONTROL7 = 0x0f
staticconstexpr

◆ ES8388_ADCCONTROL8

uint8_t ES8388_ADCCONTROL8 = 0x10
staticconstexpr

◆ ES8388_ADCCONTROL9

uint8_t ES8388_ADCCONTROL9 = 0x11
staticconstexpr

◆ ES8388_ADCPOWER

uint8_t ES8388_ADCPOWER = 0x03
staticconstexpr

◆ ES8388_ADDR

int ES8388_ADDR = 0x10
staticconstexpr

◆ ES8388_ANAVOLMANAG

uint8_t ES8388_ANAVOLMANAG = 0x07
staticconstexpr

◆ ES8388_CHIPLOPOW1

uint8_t ES8388_CHIPLOPOW1 = 0x05
staticconstexpr

◆ ES8388_CHIPLOPOW2

uint8_t ES8388_CHIPLOPOW2 = 0x06
staticconstexpr

◆ ES8388_CHIPPOWER

uint8_t ES8388_CHIPPOWER = 0x02
staticconstexpr

◆ ES8388_CONTROL1

uint8_t ES8388_CONTROL1 = 0x00
staticconstexpr

◆ ES8388_CONTROL2

uint8_t ES8388_CONTROL2 = 0x01
staticconstexpr

◆ ES8388_DACCONTROL1

uint8_t ES8388_DACCONTROL1 = 0x17
staticconstexpr

◆ ES8388_DACCONTROL10

uint8_t ES8388_DACCONTROL10 = 0x20
staticconstexpr

◆ ES8388_DACCONTROL11

uint8_t ES8388_DACCONTROL11 = 0x21
staticconstexpr

◆ ES8388_DACCONTROL12

uint8_t ES8388_DACCONTROL12 = 0x22
staticconstexpr

◆ ES8388_DACCONTROL13

uint8_t ES8388_DACCONTROL13 = 0x23
staticconstexpr

◆ ES8388_DACCONTROL14

uint8_t ES8388_DACCONTROL14 = 0x24
staticconstexpr

◆ ES8388_DACCONTROL15

uint8_t ES8388_DACCONTROL15 = 0x25
staticconstexpr

◆ ES8388_DACCONTROL16

uint8_t ES8388_DACCONTROL16 = 0x26
staticconstexpr

◆ ES8388_DACCONTROL17

uint8_t ES8388_DACCONTROL17 = 0x27
staticconstexpr

◆ ES8388_DACCONTROL18

uint8_t ES8388_DACCONTROL18 = 0x28
staticconstexpr

◆ ES8388_DACCONTROL19

uint8_t ES8388_DACCONTROL19 = 0x29
staticconstexpr

◆ ES8388_DACCONTROL2

uint8_t ES8388_DACCONTROL2 = 0x18
staticconstexpr

◆ ES8388_DACCONTROL20

uint8_t ES8388_DACCONTROL20 = 0x2a
staticconstexpr

◆ ES8388_DACCONTROL21

uint8_t ES8388_DACCONTROL21 = 0x2b
staticconstexpr

◆ ES8388_DACCONTROL22

uint8_t ES8388_DACCONTROL22 = 0x2c
staticconstexpr

◆ ES8388_DACCONTROL23

uint8_t ES8388_DACCONTROL23 = 0x2d
staticconstexpr

◆ ES8388_DACCONTROL24

uint8_t ES8388_DACCONTROL24 = 0x2e
staticconstexpr

◆ ES8388_DACCONTROL25

uint8_t ES8388_DACCONTROL25 = 0x2f
staticconstexpr

◆ ES8388_DACCONTROL26

uint8_t ES8388_DACCONTROL26 = 0x30
staticconstexpr

◆ ES8388_DACCONTROL27

uint8_t ES8388_DACCONTROL27 = 0x31
staticconstexpr

◆ ES8388_DACCONTROL28

uint8_t ES8388_DACCONTROL28 = 0x32
staticconstexpr

◆ ES8388_DACCONTROL29

uint8_t ES8388_DACCONTROL29 = 0x33
staticconstexpr

◆ ES8388_DACCONTROL3

uint8_t ES8388_DACCONTROL3 = 0x19
staticconstexpr

◆ ES8388_DACCONTROL30

uint8_t ES8388_DACCONTROL30 = 0x34
staticconstexpr

◆ ES8388_DACCONTROL4

uint8_t ES8388_DACCONTROL4 = 0x1a
staticconstexpr

◆ ES8388_DACCONTROL5

uint8_t ES8388_DACCONTROL5 = 0x1b
staticconstexpr

◆ ES8388_DACCONTROL6

uint8_t ES8388_DACCONTROL6 = 0x1c
staticconstexpr

◆ ES8388_DACCONTROL7

uint8_t ES8388_DACCONTROL7 = 0x1d
staticconstexpr

◆ ES8388_DACCONTROL8

uint8_t ES8388_DACCONTROL8 = 0x1e
staticconstexpr

◆ ES8388_DACCONTROL9

uint8_t ES8388_DACCONTROL9 = 0x1f
staticconstexpr

◆ ES8388_DACPOWER

uint8_t ES8388_DACPOWER = 0x04
staticconstexpr

◆ ES8388_MASTERMODE

uint8_t ES8388_MASTERMODE = 0x08
staticconstexpr

◆ i2c_addr

int i2c_addr = ES8388_ADDR
protected

◆ i2c_handle

i2c_bus_handle_t i2c_handle = nullptr
protected

◆ volume_hack

int volume_hack = AI_THINKER_ES8388_VOLUME_HACK
protected

The documentation for this class was generated from the following file: