ES8388 Driver
Driver for ES8388 codec chip used in ESP32 LyraT audio board.
API Reference
Header File
Functions
-
esp_err_t es8388_init(audio_hal_codec_config_t *cfg)
Initialize ES8388 codec chip.
- 参数
cfg – configuration of ES8388
- 返回
ESP_OK
ESP_FAIL
-
esp_err_t es8388_deinit(void)
Deinitialize ES8388 codec chip.
- 返回
ESP_OK
ESP_FAIL
-
esp_err_t es8388_config_fmt(es_module_t mod, es_i2s_fmt_t cfg)
Configure ES8388 I2S format.
- 参数
mod – set ADC or DAC or both
cfg – ES8388 I2S format
- 返回
ESP_OK
ESP_FAIL
-
esp_err_t es8388_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 es8388_set_bits_per_sample(es_module_t mode, es_bits_length_t bit_per_sample)
Configure ES8388 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 es8388_start(es_module_t mode)
Start ES8388 codec chip.
- 参数
mode – set ADC or DAC or both
- 返回
ESP_OK
ESP_FAIL
-
esp_err_t es8388_stop(es_module_t mode)
Stop ES8388 codec chip.
- 参数
mode – set ADC or DAC or both
- 返回
ESP_OK
ESP_FAIL
-
esp_err_t es8388_set_voice_volume(int volume)
Set voice volume.
- 参数
volume – voice volume (0~100)
- 返回
ESP_OK
ESP_FAIL
-
esp_err_t es8388_get_voice_volume(int *volume)
Get voice volume.
- 参数
*volume – [out] voice volume (0~100)
- 返回
ESP_OK
ESP_FAIL
-
esp_err_t es8388_set_voice_mute(bool enable)
Configure ES8388 DAC mute or not. Basically you can use this function to mute the output or unmute.
- 参数
enable – enable(1) or disable(0)
- 返回
ESP_FAIL Parameter error
ESP_OK Success
-
esp_err_t es8388_get_voice_mute(void)
Get ES8388 DAC mute status.
- 返回
ESP_FAIL Parameter error
ESP_OK Success
-
esp_err_t es8388_set_mic_gain(es_mic_gain_t gain)
Set ES8388 mic gain.
- 参数
gain – db of mic gain
- 返回
ESP_FAIL Parameter error
ESP_OK Success
-
esp_err_t es8388_config_adc_input(es_adc_input_t input)
Set ES8388 adc input mode.
- 参数
input – adc input mode
- 返回
ESP_FAIL Parameter error
ESP_OK Success
-
esp_err_t es8388_config_dac_output(es_dac_output_t output)
Set ES8388 dac output mode.
- 参数
output – dac output mode
- 返回
ESP_FAIL Parameter error
ESP_OK Success
-
esp_err_t es8388_write_reg(uint8_t reg_add, uint8_t data)
Write ES8388 register.
- 参数
reg_add – address of register
data – data of register
- 返回
ESP_FAIL Parameter error
ESP_OK Success
-
void es8388_read_all(void)
Print all ES8388 registers.
-
esp_err_t es8388_config_i2s(audio_hal_codec_mode_t mode, audio_hal_codec_i2s_iface_t *iface)
Configure ES8388 codec mode and I2S interface.
- 参数
mode – codec mode
iface – I2S config
- 返回
ESP_FAIL Parameter error
ESP_OK Success
-
esp_err_t es8388_ctrl_state(audio_hal_codec_mode_t mode, audio_hal_ctrl_t ctrl_state)
Control ES8388 codec chip.
- 参数
mode – codec mode
ctrl_state – start or stop decode or encode progress
- 返回
ESP_FAIL Parameter error
ESP_OK Success
-
esp_err_t es8388_pa_power(bool enable)
Set ES8388 PA power.
- 参数
enable – true for enable PA power, false for disable PA power
- 返回
ESP_ERR_INVALID_ARG
ESP_OK
Macros
-
ES8388_ADDR
0x22:CE=1;0x20:CE=0
-
ES8388_CONTROL1
-
ES8388_CONTROL2
-
ES8388_CHIPPOWER
-
ES8388_ADCPOWER
-
ES8388_DACPOWER
-
ES8388_CHIPLOPOW1
-
ES8388_CHIPLOPOW2
-
ES8388_ANAVOLMANAG
-
ES8388_MASTERMODE
-
ES8388_ADCCONTROL1
-
ES8388_ADCCONTROL2
-
ES8388_ADCCONTROL3
-
ES8388_ADCCONTROL4
-
ES8388_ADCCONTROL5
-
ES8388_ADCCONTROL6
-
ES8388_ADCCONTROL7
-
ES8388_ADCCONTROL8
-
ES8388_ADCCONTROL9
-
ES8388_ADCCONTROL10
-
ES8388_ADCCONTROL11
-
ES8388_ADCCONTROL12
-
ES8388_ADCCONTROL13
-
ES8388_ADCCONTROL14
-
ES8388_DACCONTROL1
-
ES8388_DACCONTROL2
-
ES8388_DACCONTROL3
-
ES8388_DACCONTROL4
-
ES8388_DACCONTROL5
-
ES8388_DACCONTROL6
-
ES8388_DACCONTROL7
-
ES8388_DACCONTROL8
-
ES8388_DACCONTROL9
-
ES8388_DACCONTROL10
-
ES8388_DACCONTROL11
-
ES8388_DACCONTROL12
-
ES8388_DACCONTROL13
-
ES8388_DACCONTROL14
-
ES8388_DACCONTROL15
-
ES8388_DACCONTROL16
-
ES8388_DACCONTROL17
-
ES8388_DACCONTROL18
-
ES8388_DACCONTROL19
-
ES8388_DACCONTROL20
-
ES8388_DACCONTROL21
-
ES8388_DACCONTROL22
-
ES8388_DACCONTROL23
-
ES8388_DACCONTROL24
-
ES8388_DACCONTROL25
-
ES8388_DACCONTROL26
-
ES8388_DACCONTROL27
-
ES8388_DACCONTROL28
-
ES8388_DACCONTROL29
-
ES8388_DACCONTROL30