bsp_es8388.h
Generated from bsp_es8388.h in platform-idf. Edit the header’s doxygen comments to change this page.
BSP ES8388 Codec Driver.
Functions
Section titled “Functions”bsp_es8388_init
Section titled “bsp_es8388_init”esp_err_t bsp_es8388_init(const bsp_es8388_config_t *config)Initialize ES8388 codec.
This function initializes the ES8388 codec with the specified configuration. The I2S interface must be initialized before calling this function. Can be called multiple times for different I2S interfaces.
Parameters
config— ES8388 configuration
Returns
- ESP_OK on success
- ESP_ERR_INVALID_ARG if config is NULL or invalid
- ESP_ERR_NOT_FOUND if ES8388 not found on I2C bus
- ESP_FAIL on other errors
Declared in bsp_es8388.h:88.
bsp_es8388_deinit
Section titled “bsp_es8388_deinit”esp_err_t bsp_es8388_deinit(void)Deinitialize ES8388 codec.
Returns
- ESP_OK on success
- ESP_FAIL on failure
Declared in bsp_es8388.h:97.
bsp_es8388_start
Section titled “bsp_es8388_start”esp_err_t bsp_es8388_start(bsp_i2s_interface_t interface, bsp_es8388_mode_t mode)Start ES8388 codec.
Parameters
interface— I2S interface identifiermode— Codec mode (encode/decode/both)
Returns
- ESP_OK on success
- ESP_FAIL on failure
Declared in bsp_es8388.h:109.
bsp_es8388_stop
Section titled “bsp_es8388_stop”esp_err_t bsp_es8388_stop(bsp_i2s_interface_t interface, bsp_es8388_mode_t mode)Stop ES8388 codec.
Parameters
interface— I2S interface identifiermode— Codec mode to stop
Returns
- ESP_OK on success
- ESP_FAIL on failure
Declared in bsp_es8388.h:121.
bsp_es8388_set_mic_gain
Section titled “bsp_es8388_set_mic_gain”esp_err_t bsp_es8388_set_mic_gain(bsp_i2s_interface_t interface, uint8_t stage)Set the ADC’s MicAmp PGA gain, both channels, while running.
Parameters
interface— I2S interface identifierstage— 0..8 = 0..+24 dB in 3 dB steps (clamped). Set before the codec is initialised, it is the gain its init applies.
Returns
ESP_OK, or the I2C write’s error
Declared in bsp_es8388.h:132.
bsp_es8388_set_volume
Section titled “bsp_es8388_set_volume”esp_err_t bsp_es8388_set_volume(bsp_i2s_interface_t interface, int volume)Set ES8388 volume.
Parameters
interface— I2S interface identifiervolume— Volume level (0-100)
Returns
- ESP_OK on success
- ESP_ERR_INVALID_ARG if volume out of range
- ESP_FAIL on failure
Declared in bsp_es8388.h:145.
bsp_es8388_get_volume
Section titled “bsp_es8388_get_volume”esp_err_t bsp_es8388_get_volume(bsp_i2s_interface_t interface, int *volume)Get ES8388 volume.
Parameters
interface— I2S interface identifiervolume— Current volume level (0-100)
Returns
- ESP_OK on success
- ESP_ERR_INVALID_ARG if volume is NULL
- ESP_FAIL on failure
Declared in bsp_es8388.h:158.
bsp_es8388_set_mute
Section titled “bsp_es8388_set_mute”esp_err_t bsp_es8388_set_mute(bsp_i2s_interface_t interface, bool enable)Set ES8388 mute state.
Parameters
interface— I2S interface identifierenable— true to mute, false to unmute
Returns
- ESP_OK on success
- ESP_FAIL on failure
Declared in bsp_es8388.h:170.
bsp_es8388_config_adc_input
Section titled “bsp_es8388_config_adc_input”esp_err_t bsp_es8388_config_adc_input(bsp_i2s_interface_t interface, bsp_es8388_adc_input_t input)Configure ES8388 ADC input.
Parameters
interface— I2S interface identifierinput— ADC input selection
Returns
- ESP_OK on success
- ESP_FAIL on failure
Declared in bsp_es8388.h:182.
bsp_es8388_config_dac_output
Section titled “bsp_es8388_config_dac_output”esp_err_t bsp_es8388_config_dac_output(bsp_i2s_interface_t interface, bsp_es8388_dac_output_t output)Configure ES8388 DAC output: which output drivers are powered.
Kept across bsp_es8388_stop()/start(): start() powers exactly these. Before start() it is only remembered.
Parameters
interface— I2S interface identifieroutput— DAC output selection, or any OR of their bits (0 = none)
Returns
- ESP_OK on success
- ESP_FAIL on failure
Declared in bsp_es8388.h:197.
bsp_es8388_read_register
Section titled “bsp_es8388_read_register”esp_err_t bsp_es8388_read_register(bsp_i2s_interface_t interface, uint8_t reg, uint8_t *value)Raw register access, for diagnostics (CDC CODEC_REG)
Declared in bsp_es8388.h:202.
bsp_es8388_write_register
Section titled “bsp_es8388_write_register”esp_err_t bsp_es8388_write_register(bsp_i2s_interface_t interface, uint8_t reg, uint8_t value)Declared in bsp_es8388.h:203.
bsp_es8388_get_codec_dev
Section titled “bsp_es8388_get_codec_dev”esp_codec_dev_handle_t bsp_es8388_get_codec_dev(bsp_i2s_interface_t interface)Get ESP-ADF codec device handle.
This function returns an ESP-ADF codec device handle that can be used with other ESP-ADF audio components.
Parameters
interface— I2S interface identifier
Returns
Pointer to codec device handle or NULL if not initialized
Declared in bsp_es8388.h:214.
bsp_es8388_deinit_interface
Section titled “bsp_es8388_deinit_interface”esp_err_t bsp_es8388_deinit_interface(bsp_i2s_interface_t interface)Deinitialize specific ES8388 codec.
Parameters
interface— I2S interface identifier
Returns
- ESP_OK on success
- ESP_FAIL on failure
Declared in bsp_es8388.h:224.
bsp_es8388_mode_t
Section titled “bsp_es8388_mode_t”ES8388 codec mode.
| Value | Value | Description |
|---|---|---|
BSP_ES8388_MODE_ENCODE | 1 | ADC working |
BSP_ES8388_MODE_DECODE | 2 | DAC working |
BSP_ES8388_MODE_BOTH | 3 | Both ADC and DAC working |
BSP_ES8388_MODE_LINE_IN | 4 | Line in mode |
Declared in bsp_es8388.h:33.
bsp_es8388_adc_input_t
Section titled “bsp_es8388_adc_input_t”ES8388 ADC input selection.
| Value | Value | Description |
|---|---|---|
BSP_ES8388_ADC_INPUT_LINE1 | 0x00 | Line 1 input |
BSP_ES8388_ADC_INPUT_LINE2 | 0x50 | Line 2 input |
BSP_ES8388_ADC_INPUT_DIFFERENCE | 0xf0 | Differential input |
Declared in bsp_es8388.h:43.
bsp_es8388_dac_output_t
Section titled “bsp_es8388_dac_output_t”ES8388 DAC output selection: which output drivers are powered (DACPOWER bits, LOUTx/ROUTx enable). A driver powered down leaves its pins high-impedance.
| Value | Value | Description |
|---|---|---|
BSP_ES8388_DAC_OUTPUT_LINE1 | 0x30 | LOUT1/ROUT1 |
BSP_ES8388_DAC_OUTPUT_LINE2 | 0x0C | LOUT2/ROUT2 |
BSP_ES8388_DAC_OUTPUT_ALL | 0x3C | All outputs |
Declared in bsp_es8388.h:54.
bsp_es8388_config_t
Section titled “bsp_es8388_config_t”ES8388 codec configuration.
| Field | Type | Description |
|---|---|---|
i2c_handle | i2c_master_bus_handle_t | I2C master bus handle |
i2c_addr | uint8_t | I2C device address |
i2s_interface | bsp_i2s_interface_t | Associated I2S interface |
codec_mode | bsp_es8388_mode_t | Codec operating mode |
adc_input | bsp_es8388_adc_input_t | ADC input selection |
dac_output | bsp_es8388_dac_output_t | DAC output selection |
mic_amp_gain | uint8_t | MicAmp PGA gain stage (0..8 → 0..+24dB in 3dB steps). 0 = line-level input. |
Declared in bsp_es8388.h:63.
Macros
Section titled “Macros”| Macro | Value | Description |
|---|---|---|
BSP_ES8388_CODEC_ADDR | 0x10 | ES8388 I2C address (CE pin configuration dependent) ES8388 I2C address when CE=0 |
BSP_ES8388_CODEC_ADDR_ALT | 0x11 | ES8388 I2C address when CE=1 |