tda74xx - Driver for TDA7439/TDA7439DS/TDA7440D audioprocessors

group tda74xx

ESP-IDF driver for TDA7439/TDA7439DS/TDA7440 audioprocessors.

Copyright (C) 2018, 2020 Ruslan V. Uss unclerus@gmail.com

MIT Licensed as described in the file LICENSE

Defines

TDA74XX_ADDR

I2C address.

TDA74XX_MAX_INPUT

Maximum input number.

TDA74XX_MIN_VOLUME

Mute volume level, dB.

TDA74XX_MAX_VOLUME

Maximum colume level, dB.

TDA74XX_MAX_INPUT_GAIN

Maximum input gain, dB.

TDA74XX_MIN_EQ_GAIN

Minimum equalizer gain, dB.

TDA74XX_MAX_EQ_GAIN

Maximum equalizer gain, dB.

TDA74XX_MAX_ATTEN

Maximum speaker attenuation level, dB.

Enums

enum tda74xx_channel_t

Audio channel.

Values:

enumerator TDA74XX_CHANNEL_LEFT
enumerator TDA74XX_CHANNEL_RIGHT
enum tda74xx_band_t

Equalizer band.

Values:

enumerator TDA74XX_BAND_BASS
enumerator TDA74XX_BAND_MIDDLE

Not supported on TDA7440.

enumerator TDA74XX_BAND_TREBLE

Functions

esp_err_t tda74xx_init_desc(i2c_dev_t *dev, i2c_port_t port, gpio_num_t sda_gpio, gpio_num_t scl_gpio)

Initialize device descriptor.

Return

ESP_OK on success

Parameters
  • dev: Device descriptor

  • port: I2C port number

  • sda_gpio: GPIO pin number for SDA

  • scl_gpio: GPIO pin number for SCL

esp_err_t tda74xx_free_desc(i2c_dev_t *dev)

Free device descriptor.

Return

ESP_OK on success

Parameters
  • dev: Device descriptor

esp_err_t tda74xx_set_input(i2c_dev_t *dev, uint8_t input)

Switch input.

Return

ESP_OK on success

Parameters
  • dev: Device descriptor

  • input: Input #, 0..3

esp_err_t tda74xx_get_input(i2c_dev_t *dev, uint8_t *input)

Get current input.

Return

ESP_OK on success

Parameters
  • dev: Device descriptor

  • [out] input: Input #, 0..3

esp_err_t tda74xx_set_input_gain(i2c_dev_t *dev, uint8_t gain_db)

Set input gain, dB.

Return

ESP_OK on success

Parameters
  • dev: Device descriptor

  • gain_db: Gain, 0..30 dB

esp_err_t tda74xx_get_input_gain(i2c_dev_t *dev, uint8_t *gain_db)

Get input gain.

Return

ESP_OK on success

Parameters
  • dev: Device descriptor

  • [out] gain_db: Gain, 0..30 dB

esp_err_t tda74xx_set_volume(i2c_dev_t *dev, int8_t volume_db)

Set master volume.

Return

ESP_OK on success

Parameters
  • dev: Device descriptor

  • volume_db: Volume, -48..0 dB

esp_err_t tda74xx_get_volume(i2c_dev_t *dev, int8_t *volume_db)

Get master volume.

Return

ESP_OK on success

Parameters
  • dev: Device descriptor

  • [out] volume_db: Volume, -48..0 dB

esp_err_t tda74xx_set_equalizer_gain(i2c_dev_t *dev, tda74xx_band_t band, int8_t gain_db)

Set equalizer gain.

Return

ESP_OK on success

Parameters
  • dev: Device descriptor

  • band: Band

  • gain_db: Gain, -14..14 dB in 2 dB step

esp_err_t tda74xx_get_equalizer_gain(i2c_dev_t *dev, tda74xx_band_t band, int8_t *gain_db)

Get equlizer gain.

Return

ESP_OK on success

Parameters
  • dev: Device descriptor

  • band: Band

  • [out] gain_db: Gain, -14..14 dB in 2 dB step

esp_err_t tda74xx_set_speaker_attenuation(i2c_dev_t *dev, tda74xx_channel_t channel, uint8_t atten_db)

Attenuate speaker.

Return

ESP_OK on success

Parameters
  • dev: Device descriptor

  • channel: Audio channel

  • atten_db: Attenuation, 0..56 dB

esp_err_t tda74xx_get_speaker_attenuation(i2c_dev_t *dev, tda74xx_channel_t channel, uint8_t *atten_db)

Get speaker attenuation.

Return

ESP_OK on success

Parameters
  • dev: Device descriptor

  • channel: Audio channel

  • atten_db: Attenuation, 0..56 dB