arduino-audio-driver
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Attributes | List of all members
ES8311 Class Reference

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

#include <ES8311.h>

Public Member Functions

 ES8311 ()=default
 
error_t configFmt (I2SDefinition fmt)
 Configure ES8311 I2S format.
 
error_t configI2S (codec_mode_t mode, I2SDefinition *iface)
 Configure ES8311 codec mode and I2S interface.
 
error_t ctrlStateActive (codec_mode_t mode, bool ctrl_state_active)
 Control ES8311 codec chip.
 
error_t deinit ()
 Deinitialize ES8311 codec chip.
 
int getCoeff (uint32_t mclk, uint32_t rate)
 look for the coefficient in es8311_coeff_div[] table
 
int8_t getMclkSrc (void)
 
error_t getVoiceMute (int *mute)
 Get ES8311 DAC mute status.
 
error_t getVoiceVolume (int *volume)
 Get voice volume (0~100)
 
error_t init (codec_config_t *codec_cfg)
 Initialize ES8311 codec chip.
 
void mute (int do_mute)
 set es8311 dac mute (1) or unmute (0)
 
void readAll ()
 Print all ES8311 registers.
 
int readReg (uint8_t reg_addr)
 
void setAddress (int addr)
 Defines the I2C device address.
 
error_t setBitsPerSample (sample_bits_t bits)
 Configure ES8311 data sample bits.
 
void setMclkSrc (int8_t src)
 Defines the source of the master clock (FROM_MCLK_PIN or FROM_SCLK_PIN)
 
error_t setMicGain (es8311_mic_gain_t gain_db)
 Set ES8311 mic gain.
 
error_t setVoiceMute (bool enable)
 Configure ES8311 DAC mute or not.
 
error_t setVoiceVolume (int volume)
 Set voice volume (0~100)
 
void setWire (i2c_bus_handle_t handle)
 Defines the I2C bus instance to be used.
 
error_t start (codec_mode_t mode)
 Start ES8311 codec chip.
 
error_t stop (codec_mode_t mode)
 Stop ES8311 codec chip.
 
void suspend (void)
 set es8311 into suspend mode
 
error_t writeReg (uint8_t reg_addr, uint8_t data)
 

Static Public Member Functions

static constexpr int bitVal (int nr)
 

Static Public Attributes

static constexpr uint8_t ES8311_ADC_REG15 = 0x15
 
static constexpr uint8_t ES8311_ADC_REG16 = 0x16
 
static constexpr uint8_t ES8311_ADC_REG17 = 0x17
 
static constexpr uint8_t ES8311_ADC_REG18 = 0x18
 
static constexpr uint8_t ES8311_ADC_REG19 = 0x19
 
static constexpr uint8_t ES8311_ADC_REG1A = 0x1A
 
static constexpr uint8_t ES8311_ADC_REG1B = 0x1B
 
static constexpr uint8_t ES8311_ADC_REG1C = 0x1C
 
static constexpr int ES8311_ADDR = 0x18
 
static constexpr uint8_t ES8311_CHD1_REGFD = 0xFD
 
static constexpr uint8_t ES8311_CHD2_REGFE = 0xFE
 
static constexpr uint8_t ES8311_CHVER_REGFF = 0xFF
 
static constexpr uint8_t ES8311_CLK_MANAGER_REG01 = 0x01
 
static constexpr uint8_t ES8311_CLK_MANAGER_REG02 = 0x02
 
static constexpr uint8_t ES8311_CLK_MANAGER_REG03 = 0x03
 
static constexpr uint8_t ES8311_CLK_MANAGER_REG04 = 0x04
 
static constexpr uint8_t ES8311_CLK_MANAGER_REG05 = 0x05
 
static constexpr uint8_t ES8311_CLK_MANAGER_REG06 = 0x06
 
static constexpr uint8_t ES8311_CLK_MANAGER_REG07 = 0x07
 
static constexpr uint8_t ES8311_CLK_MANAGER_REG08 = 0x08
 
static constexpr uint8_t ES8311_DAC_REG31 = 0x31
 
static constexpr uint8_t ES8311_DAC_REG32 = 0x32
 
static constexpr uint8_t ES8311_DAC_REG33 = 0x33
 
static constexpr uint8_t ES8311_DAC_REG34 = 0x34
 
static constexpr uint8_t ES8311_DAC_REG35 = 0x35
 
static constexpr uint8_t ES8311_DAC_REG37 = 0x37
 
static constexpr uint8_t ES8311_GP_REG45 = 0x45
 
static constexpr uint8_t ES8311_GPIO_REG44 = 0x44
 
static constexpr uint8_t ES8311_MAX_REGISTER = 0xFF
 
static constexpr uint8_t ES8311_RESET_REG00 = 0x00
 
static constexpr uint8_t ES8311_SDPIN_REG09 = 0x09
 
static constexpr uint8_t ES8311_SDPOUT_REG0A = 0x0A
 
static constexpr uint8_t ES8311_SYSTEM_REG0B = 0x0B
 
static constexpr uint8_t ES8311_SYSTEM_REG0C = 0x0C
 
static constexpr uint8_t ES8311_SYSTEM_REG0D = 0x0D
 
static constexpr uint8_t ES8311_SYSTEM_REG0E = 0x0E
 
static constexpr uint8_t ES8311_SYSTEM_REG0F = 0x0F
 
static constexpr uint8_t ES8311_SYSTEM_REG10 = 0x10
 
static constexpr uint8_t ES8311_SYSTEM_REG11 = 0x11
 
static constexpr uint8_t ES8311_SYSTEM_REG12 = 0x12
 
static constexpr uint8_t ES8311_SYSTEM_REG13 = 0x13
 
static constexpr uint8_t ES8311_SYSTEM_REG14 = 0x14
 
static constexpr int FROM_MCLK_PIN = 0
 
static constexpr int FROM_SCLK_PIN = 1
 
static constexpr int INVERT_MCLK = 0
 
static constexpr int INVERT_SCLK = 0
 
static constexpr int IS_DMIC = 0
 
static constexpr int MCLK_DIV_FRE = 256
 

Protected Attributes

int i2c_addr = ES8311_ADDR
 
i2c_bus_handle_t i2c_handle = nullptr
 
int8_t mclk_src = 0
 

Detailed Description

Header-only driver class for the ES8311 codec chip.

Author
Phil Schatzmann

Constructor & Destructor Documentation

◆ ES8311()

ES8311 ( )
default

Member Function Documentation

◆ bitVal()

static constexpr int bitVal ( int  nr)
inlinestaticconstexpr

◆ configFmt()

error_t configFmt ( I2SDefinition  fmt)
inline

Configure ES8311 I2S format.

◆ configI2S()

error_t configI2S ( codec_mode_t  mode,
I2SDefinition *  iface 
)
inline

Configure ES8311 codec mode and I2S interface.

◆ ctrlStateActive()

error_t ctrlStateActive ( codec_mode_t  mode,
bool  ctrl_state_active 
)
inline

Control ES8311 codec chip.

◆ deinit()

error_t deinit ( )
inline

Deinitialize ES8311 codec chip.

◆ getCoeff()

int getCoeff ( uint32_t  mclk,
uint32_t  rate 
)
inline

look for the coefficient in es8311_coeff_div[] table

◆ getMclkSrc()

int8_t getMclkSrc ( void  )
inline

◆ getVoiceMute()

error_t getVoiceMute ( int *  mute)
inline

Get ES8311 DAC mute status.

◆ getVoiceVolume()

error_t getVoiceVolume ( int *  volume)
inline

Get voice volume (0~100)

◆ init()

error_t init ( codec_config_t *  codec_cfg)
inline

Initialize ES8311 codec chip.

◆ mute()

void mute ( int  do_mute)
inline

set es8311 dac mute (1) or unmute (0)

◆ readAll()

void readAll ( )
inline

Print all ES8311 registers.

◆ readReg()

int readReg ( uint8_t  reg_addr)
inline

◆ setAddress()

void setAddress ( int  addr)
inline

Defines the I2C device address.

◆ setBitsPerSample()

error_t setBitsPerSample ( sample_bits_t  bits)
inline

Configure ES8311 data sample bits.

◆ setMclkSrc()

void setMclkSrc ( int8_t  src)
inline

Defines the source of the master clock (FROM_MCLK_PIN or FROM_SCLK_PIN)

◆ setMicGain()

error_t setMicGain ( es8311_mic_gain_t  gain_db)
inline

Set ES8311 mic gain.

◆ setVoiceMute()

error_t setVoiceMute ( bool  enable)
inline

Configure ES8311 DAC mute or not.

◆ setVoiceVolume()

error_t setVoiceVolume ( int  volume)
inline

Set voice volume (0~100)

◆ 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 ES8311 codec chip.

◆ stop()

error_t stop ( codec_mode_t  mode)
inline

Stop ES8311 codec chip.

◆ suspend()

void suspend ( void  )
inline

set es8311 into suspend mode

◆ writeReg()

error_t writeReg ( uint8_t  reg_addr,
uint8_t  data 
)
inline

Member Data Documentation

◆ ES8311_ADC_REG15

constexpr uint8_t ES8311_ADC_REG15 = 0x15
staticconstexpr

◆ ES8311_ADC_REG16

constexpr uint8_t ES8311_ADC_REG16 = 0x16
staticconstexpr

◆ ES8311_ADC_REG17

constexpr uint8_t ES8311_ADC_REG17 = 0x17
staticconstexpr

◆ ES8311_ADC_REG18

constexpr uint8_t ES8311_ADC_REG18 = 0x18
staticconstexpr

◆ ES8311_ADC_REG19

constexpr uint8_t ES8311_ADC_REG19 = 0x19
staticconstexpr

◆ ES8311_ADC_REG1A

constexpr uint8_t ES8311_ADC_REG1A = 0x1A
staticconstexpr

◆ ES8311_ADC_REG1B

constexpr uint8_t ES8311_ADC_REG1B = 0x1B
staticconstexpr

◆ ES8311_ADC_REG1C

constexpr uint8_t ES8311_ADC_REG1C = 0x1C
staticconstexpr

◆ ES8311_ADDR

constexpr int ES8311_ADDR = 0x18
staticconstexpr

◆ ES8311_CHD1_REGFD

constexpr uint8_t ES8311_CHD1_REGFD = 0xFD
staticconstexpr

◆ ES8311_CHD2_REGFE

constexpr uint8_t ES8311_CHD2_REGFE = 0xFE
staticconstexpr

◆ ES8311_CHVER_REGFF

constexpr uint8_t ES8311_CHVER_REGFF = 0xFF
staticconstexpr

◆ ES8311_CLK_MANAGER_REG01

constexpr uint8_t ES8311_CLK_MANAGER_REG01 = 0x01
staticconstexpr

◆ ES8311_CLK_MANAGER_REG02

constexpr uint8_t ES8311_CLK_MANAGER_REG02 = 0x02
staticconstexpr

◆ ES8311_CLK_MANAGER_REG03

constexpr uint8_t ES8311_CLK_MANAGER_REG03 = 0x03
staticconstexpr

◆ ES8311_CLK_MANAGER_REG04

constexpr uint8_t ES8311_CLK_MANAGER_REG04 = 0x04
staticconstexpr

◆ ES8311_CLK_MANAGER_REG05

constexpr uint8_t ES8311_CLK_MANAGER_REG05 = 0x05
staticconstexpr

◆ ES8311_CLK_MANAGER_REG06

constexpr uint8_t ES8311_CLK_MANAGER_REG06 = 0x06
staticconstexpr

◆ ES8311_CLK_MANAGER_REG07

constexpr uint8_t ES8311_CLK_MANAGER_REG07 = 0x07
staticconstexpr

◆ ES8311_CLK_MANAGER_REG08

constexpr uint8_t ES8311_CLK_MANAGER_REG08 = 0x08
staticconstexpr

◆ ES8311_DAC_REG31

constexpr uint8_t ES8311_DAC_REG31 = 0x31
staticconstexpr

◆ ES8311_DAC_REG32

constexpr uint8_t ES8311_DAC_REG32 = 0x32
staticconstexpr

◆ ES8311_DAC_REG33

constexpr uint8_t ES8311_DAC_REG33 = 0x33
staticconstexpr

◆ ES8311_DAC_REG34

constexpr uint8_t ES8311_DAC_REG34 = 0x34
staticconstexpr

◆ ES8311_DAC_REG35

constexpr uint8_t ES8311_DAC_REG35 = 0x35
staticconstexpr

◆ ES8311_DAC_REG37

constexpr uint8_t ES8311_DAC_REG37 = 0x37
staticconstexpr

◆ ES8311_GP_REG45

constexpr uint8_t ES8311_GP_REG45 = 0x45
staticconstexpr

◆ ES8311_GPIO_REG44

constexpr uint8_t ES8311_GPIO_REG44 = 0x44
staticconstexpr

◆ ES8311_MAX_REGISTER

constexpr uint8_t ES8311_MAX_REGISTER = 0xFF
staticconstexpr

◆ ES8311_RESET_REG00

constexpr uint8_t ES8311_RESET_REG00 = 0x00
staticconstexpr

◆ ES8311_SDPIN_REG09

constexpr uint8_t ES8311_SDPIN_REG09 = 0x09
staticconstexpr

◆ ES8311_SDPOUT_REG0A

constexpr uint8_t ES8311_SDPOUT_REG0A = 0x0A
staticconstexpr

◆ ES8311_SYSTEM_REG0B

constexpr uint8_t ES8311_SYSTEM_REG0B = 0x0B
staticconstexpr

◆ ES8311_SYSTEM_REG0C

constexpr uint8_t ES8311_SYSTEM_REG0C = 0x0C
staticconstexpr

◆ ES8311_SYSTEM_REG0D

constexpr uint8_t ES8311_SYSTEM_REG0D = 0x0D
staticconstexpr

◆ ES8311_SYSTEM_REG0E

constexpr uint8_t ES8311_SYSTEM_REG0E = 0x0E
staticconstexpr

◆ ES8311_SYSTEM_REG0F

constexpr uint8_t ES8311_SYSTEM_REG0F = 0x0F
staticconstexpr

◆ ES8311_SYSTEM_REG10

constexpr uint8_t ES8311_SYSTEM_REG10 = 0x10
staticconstexpr

◆ ES8311_SYSTEM_REG11

constexpr uint8_t ES8311_SYSTEM_REG11 = 0x11
staticconstexpr

◆ ES8311_SYSTEM_REG12

constexpr uint8_t ES8311_SYSTEM_REG12 = 0x12
staticconstexpr

◆ ES8311_SYSTEM_REG13

constexpr uint8_t ES8311_SYSTEM_REG13 = 0x13
staticconstexpr

◆ ES8311_SYSTEM_REG14

constexpr uint8_t ES8311_SYSTEM_REG14 = 0x14
staticconstexpr

◆ FROM_MCLK_PIN

constexpr int FROM_MCLK_PIN = 0
staticconstexpr

◆ FROM_SCLK_PIN

constexpr int FROM_SCLK_PIN = 1
staticconstexpr

◆ i2c_addr

int i2c_addr = ES8311_ADDR
protected

◆ i2c_handle

i2c_bus_handle_t i2c_handle = nullptr
protected

◆ INVERT_MCLK

constexpr int INVERT_MCLK = 0
staticconstexpr

◆ INVERT_SCLK

constexpr int INVERT_SCLK = 0
staticconstexpr

◆ IS_DMIC

constexpr int IS_DMIC = 0
staticconstexpr

◆ MCLK_DIV_FRE

constexpr int MCLK_DIV_FRE = 256
staticconstexpr

◆ mclk_src

int8_t mclk_src = 0
protected

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