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.
- Return
ESP_OK
ESP_FAIL
- Parameters
cfg
: configuration of ES8388
-
esp_err_t
es8388_deinit
(void)¶ Deinitialize ES8388 codec chip.
- Return
ESP_OK
ESP_FAIL
-
esp_err_t
es8388_config_fmt
(es_module_t mod, es_i2s_fmt_t cfg)¶ Configure ES8388 I2S format.
- Return
ESP_OK
ESP_FAIL
- Parameters
mod
: set ADC or DAC or bothcfg
: ES8388 I2S format
-
esp_err_t
es8388_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
es8388_set_bits_per_sample
(es_module_t mode, es_bits_length_t bit_per_sample)¶ Configure ES8388 data sample bits.
- Return
ESP_OK
ESP_FAIL
- Parameters
mode
: set ADC or DAC or bothbit_per_sample
: bit number of per sample
-
esp_err_t
es8388_start
(es_module_t mode)¶ Start ES8388 codec chip.
- Return
ESP_OK
ESP_FAIL
- Parameters
mode
: set ADC or DAC or both
-
esp_err_t
es8388_stop
(es_module_t mode)¶ Stop ES8388 codec chip.
- Return
ESP_OK
ESP_FAIL
- Parameters
mode
: set ADC or DAC or both
-
esp_err_t
es8388_set_voice_volume
(int volume)¶ Set voice volume.
- Return
ESP_OK
ESP_FAIL
- Parameters
volume
: voice volume (0~100)
-
esp_err_t
es8388_get_voice_volume
(int *volume)¶ Get voice volume.
- Return
ESP_OK
ESP_FAIL
- Parameters
[out] *volume
: voice volume (0~100)
-
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.
- Return
ESP_FAIL Parameter error
ESP_OK Success
- Parameters
enable
: enable(1) or disable(0)
-
esp_err_t
es8388_get_voice_mute
(void)¶ Get ES8388 DAC mute status.
- Return
ESP_FAIL Parameter error
ESP_OK Success
-
esp_err_t
es8388_set_mic_gain
(es_mic_gain_t gain)¶ Set ES8388 mic gain.
- Return
ESP_FAIL Parameter error
ESP_OK Success
- Parameters
gain
: db of mic gain
-
esp_err_t
es8388_config_adc_input
(es_adc_input_t input)¶ Set ES8388 adc input mode.
- Return
ESP_FAIL Parameter error
ESP_OK Success
- Parameters
input
: adc input mode
-
esp_err_t
es8388_config_dac_output
(es_dac_output_t output)¶ Set ES8388 dac output mode.
- Return
ESP_FAIL Parameter error
ESP_OK Success
- Parameters
output
: dac output mode
-
esp_err_t
es8388_write_reg
(uint8_t reg_add, uint8_t data)¶ Write ES8388 register.
- Return
ESP_FAIL Parameter error
ESP_OK Success
- Parameters
reg_add
: address of registerdata
: data of register
-
void
es8388_read_all
()¶ Print all ES8388 registers.
- Return
void
-
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.
- Return
ESP_FAIL Parameter error
ESP_OK Success
- Parameters
mode
: codec modeiface
: I2S config
-
esp_err_t
es8388_ctrl_state
(audio_hal_codec_mode_t mode, audio_hal_ctrl_t ctrl_state)¶ Control ES8388 codec chip.
- Return
ESP_FAIL Parameter error
ESP_OK Success
- Parameters
mode
: codec modectrl_state
: start or stop decode or encode progress
-
esp_err_t
es8388_pa_power
(bool enable)¶ Set ES8388 PA power.
- Return
ESP_ERR_INVALID_ARG
ESP_OK
- Parameters
enable
: true for enable PA power, false for disable PA power
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
¶