ES8374 Driver
Driver for ES8374 codec chip.
API Reference
Header File
Functions
-
esp_err_t es8374_codec_init(audio_hal_codec_config_t *cfg)
Initialize ES8374 codec chip.
- Parameters
cfg – configuration of ES8374
- Returns
ESP_OK
ESP_FAIL
-
esp_err_t es8374_codec_deinit(void)
Deinitialize ES8374 codec chip.
- Returns
ESP_OK
ESP_FAIL
-
esp_err_t es8374_config_fmt(es_module_t mode, es_i2s_fmt_t fmt)
Configure ES8374 I2S format.
- Parameters
mode – Set ADC or DAC or both
fmt – ES8374 I2S format
- Returns
ESP_OK
ESP_FAIL
-
esp_err_t es8374_i2s_config_clock(es_i2s_clock_t cfg)
Configure I2S clock in MSATER mode.
- Parameters
cfg – Set bits clock and WS clock
- Returns
ESP_OK
ESP_FAIL
-
esp_err_t es8374_set_bits_per_sample(es_module_t mode, es_bits_length_t bit_per_sample)
Configure ES8374 data sample bits.
- Parameters
mode – Set ADC or DAC or both
bit_per_sample – Bit number of per sample
- Returns
ESP_OK
ESP_FAIL
-
esp_err_t es8374_start(es_module_t mode)
Start ES8374 codec chip.
- Parameters
mode – Set ADC or DAC or both
- Returns
ESP_OK
ESP_FAIL
-
esp_err_t es8374_stop(es_module_t mode)
Stop ES8374 codec chip.
- Parameters
mode – Set ADC or DAC or both
- Returns
ESP_OK
ESP_FAIL
-
esp_err_t es8374_codec_set_voice_volume(int volume)
Set voice volume.
- Parameters
volume – Voice volume (0~100)
- Returns
ESP_OK
ESP_FAIL
-
esp_err_t es8374_codec_get_voice_volume(int *volume)
Get voice volume.
- Parameters
*volume – [out] Voice volume (0~100)
- Returns
ESP_OK
ESP_FAIL
-
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.
- Parameters
enable – [inout] Enable Mute(1) or Unmute(0)
- Returns
ESP_FAIL Parameter error
ESP_OK Success
-
esp_err_t es8374_get_voice_mute(void)
Get ES8374 DAC mute status.
- Returns
ESP_FAIL
ESP_OK
-
esp_err_t es8374_set_mic_gain(es_mic_gain_t gain)
Set ES8374 mic gain.
- Parameters
gain – [inout] gain db of mic gain
- Returns
ESP_FAIL Parameter error
ESP_OK Success
-
esp_err_t es8374_config_adc_input(es_adc_input_t input)
Set ES8374 ADC input mode.
- Parameters
input – [in] ADC input mode
- Returns
ESP_FAIL Parameter error
ESP_OK Success
-
esp_err_t es8374_config_dac_output(es_dac_output_t output)
Set ES8374 DAC output mode.
- Parameters
output – [in] DAC output mode
- Returns
ESP_FAIL Parameter error
ESP_OK Success
-
esp_err_t es8374_write_reg(uint8_t reg_add, uint8_t data)
Write ES8374 register.
- Parameters
reg_add – Address of register
data – Data of register
- Returns
ESP_FAIL Parameter error
ESP_OK Success
-
void es8374_read_all(void)
Print all ES8374 registers.
-
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.
- Parameters
mode – Codec mode
iface – I2S config
- Returns
ESP_FAIL Parameter error
ESP_OK Success
-
esp_err_t es8374_codec_ctrl_state(audio_hal_codec_mode_t mode, audio_hal_ctrl_t ctrl_state)
Control ES8374 codec chip.
- Parameters
mode – Codec mode
ctrl_state – Start or stop decode or encode progress
- Returns
ESP_FAIL Parameter error
ESP_OK Success
-
esp_err_t es8374_pa_power(bool enable)
Set ES8374 PA power.
- Parameters
enable – True for enable PA power, false for disable PA power
- Returns
ESP_ERR_INVALID_ARG
ESP_OK
Macros
-
ES8374_ADDR