Skip to content

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.

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.

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.

esp_err_t bsp_es8388_start(bsp_i2s_interface_t interface, bsp_es8388_mode_t mode)

Start ES8388 codec.

Parameters

  • interface — I2S interface identifier
  • mode — Codec mode (encode/decode/both)

Returns

  • ESP_OK on success
  • ESP_FAIL on failure

Declared in bsp_es8388.h:109.

esp_err_t bsp_es8388_stop(bsp_i2s_interface_t interface, bsp_es8388_mode_t mode)

Stop ES8388 codec.

Parameters

  • interface — I2S interface identifier
  • mode — Codec mode to stop

Returns

  • ESP_OK on success
  • ESP_FAIL on failure

Declared in bsp_es8388.h:121.

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 identifier
  • stage — 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.

esp_err_t bsp_es8388_set_volume(bsp_i2s_interface_t interface, int volume)

Set ES8388 volume.

Parameters

  • interface — I2S interface identifier
  • volume — 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.

esp_err_t bsp_es8388_get_volume(bsp_i2s_interface_t interface, int *volume)

Get ES8388 volume.

Parameters

  • interface — I2S interface identifier
  • volume — 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.

esp_err_t bsp_es8388_set_mute(bsp_i2s_interface_t interface, bool enable)

Set ES8388 mute state.

Parameters

  • interface — I2S interface identifier
  • enable — true to mute, false to unmute

Returns

  • ESP_OK on success
  • ESP_FAIL on failure

Declared in bsp_es8388.h:170.

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 identifier
  • input — ADC input selection

Returns

  • ESP_OK on success
  • ESP_FAIL on failure

Declared in bsp_es8388.h:182.

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 identifier
  • output — 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.

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.

esp_err_t bsp_es8388_write_register(bsp_i2s_interface_t interface, uint8_t reg, uint8_t value)

Declared in bsp_es8388.h:203.

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.

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.

ES8388 codec mode.

ValueValueDescription
BSP_ES8388_MODE_ENCODE1ADC working
BSP_ES8388_MODE_DECODE2DAC working
BSP_ES8388_MODE_BOTH3Both ADC and DAC working
BSP_ES8388_MODE_LINE_IN4Line in mode

Declared in bsp_es8388.h:33.

ES8388 ADC input selection.

ValueValueDescription
BSP_ES8388_ADC_INPUT_LINE10x00Line 1 input
BSP_ES8388_ADC_INPUT_LINE20x50Line 2 input
BSP_ES8388_ADC_INPUT_DIFFERENCE0xf0Differential input

Declared in bsp_es8388.h:43.

ES8388 DAC output selection: which output drivers are powered (DACPOWER bits, LOUTx/ROUTx enable). A driver powered down leaves its pins high-impedance.

ValueValueDescription
BSP_ES8388_DAC_OUTPUT_LINE10x30LOUT1/ROUT1
BSP_ES8388_DAC_OUTPUT_LINE20x0CLOUT2/ROUT2
BSP_ES8388_DAC_OUTPUT_ALL0x3CAll outputs

Declared in bsp_es8388.h:54.

ES8388 codec configuration.

FieldTypeDescription
i2c_handlei2c_master_bus_handle_tI2C master bus handle
i2c_addruint8_tI2C device address
i2s_interfacebsp_i2s_interface_tAssociated I2S interface
codec_modebsp_es8388_mode_tCodec operating mode
adc_inputbsp_es8388_adc_input_tADC input selection
dac_outputbsp_es8388_dac_output_tDAC output selection
mic_amp_gainuint8_tMicAmp PGA gain stage (0..8 → 0..+24dB in 3dB steps). 0 = line-level input.

Declared in bsp_es8388.h:63.

MacroValueDescription
BSP_ES8388_CODEC_ADDR0x10ES8388 I2C address (CE pin configuration dependent) ES8388 I2C address when CE=0
BSP_ES8388_CODEC_ADDR_ALT0x11ES8388 I2C address when CE=1