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