ES8374 Driver

Driver for ES8374 codec chip.

API Reference

Functions

esp_err_t es8374_codec_init(audio_hal_codec_config_t *cfg)

Initialize ES8374 codec chip.

Return
  • ESP_OK
  • ESP_FAIL
Parameters
  • cfg: configuration of ES8374

esp_err_t es8374_codec_deinit(void)

Deinitialize ES8374 codec chip.

Return
  • ESP_OK
  • ESP_FAIL

esp_err_t es8374_config_fmt(es_module_t mode, es_i2s_fmt_t fmt)

Configure ES8374 I2S format.

Return
  • ESP_OK
  • ESP_FAIL
Parameters
  • mode: set ADC or DAC or both
  • fmt: ES8374 I2S format

esp_err_t es8374_i2s_config_clock(es_i2s_clock_t cfg)

Configure I2S clock in MSATER mode.

Return
  • ESP_OK
  • ESP_FAIL
Parameters
  • cfg: set bits clock and WS clock

esp_err_t es8374_set_bits_per_sample(es_module_t mode, es_bits_length_t bit_per_sample)

Configure ES8374 data sample bits.

Return
  • ESP_OK
  • ESP_FAIL
Parameters
  • mode: set ADC or DAC or both
  • bit_per_sample: bit number of per sample

esp_err_t es8374_start(es_module_t mode)

Start ES8374 codec chip.

Return
  • ESP_OK
  • ESP_FAIL
Parameters
  • mode: set ADC or DAC or both

esp_err_t es8374_stop(es_module_t mode)

Stop ES8374 codec chip.

Return
  • ESP_OK
  • ESP_FAIL
Parameters
  • mode: set ADC or DAC or both

esp_err_t es8374_codec_set_voice_volume(int volume)

Set voice volume.

Return
  • ESP_OK
  • ESP_FAIL
Parameters
  • volume: voice volume (0~100)

esp_err_t es8374_codec_get_voice_volume(int *volume)

Get voice volume.

Return
  • ESP_OK
  • ESP_FAIL
Parameters
  • *volume: voice volume (0~100)

esp_err_t es8374_set_voice_mute(bool enable)

Mute or unmute ES8374 DAC. Basically you can use this function to mute or unmute the output.

Return
  • ESP_FAIL Parameter error
  • ESP_OK Success
Parameters
  • enable: mute(1) or unmute(0)

esp_err_t es8374_get_voice_mute(void)

Get ES8374 DAC mute status.

Return
  • ESP_FAIL
  • ESP_OK

esp_err_t es8374_set_mic_gain(es_mic_gain_t gain)

Set ES8374 mic gain.

Return
  • ESP_FAIL Parameter error
  • ESP_OK Success
Parameters
  • gain: db of mic gain

esp_err_t es8374_config_adc_input(es_adc_input_t input)

Set ES8374 ADC input mode.

Return
  • ESP_FAIL Parameter error
  • ESP_OK Success
Parameters
  • input: adc input mode

esp_err_t es8374_config_dac_output(es_dac_output_t output)

Set ES8374 DAC output mode.

Return
  • ESP_FAIL Parameter error
  • ESP_OK Success
Parameters
  • output: dac output mode

esp_err_t es8374_write_reg(uint8_t reg_add, uint8_t data)

Write ES8374 register.

Return
  • ESP_FAIL Parameter error
  • ESP_OK Success
Parameters
  • reg_add: address of register
  • data: data of register

void es8374_read_all()

Print all ES8374 registers.

Return
  • void

esp_err_t es8374_codec_config_i2s(audio_hal_codec_mode_t mode, audio_hal_codec_i2s_iface_t *iface)

Configure ES8374 codec mode and I2S interface.

Return
  • ESP_FAIL Parameter error
  • ESP_OK Success
Parameters
  • mode: codec mode
  • iface: I2S config

esp_err_t es8374_codec_ctrl_state(audio_hal_codec_mode_t mode, audio_hal_ctrl_t ctrl_state)

Control ES8374 codec chip.

Return
  • ESP_FAIL Parameter error
  • ESP_OK Success
Parameters
  • mode: codec mode
  • ctrl_state: start or stop decode or encode progress

void es8374_pa_power(bool enable)

Set ES8374 PA power.

Return
  • void
Parameters
  • enable: true for enable PA power, false for disable PA power

Macros

ES8374_ADDR