Hardware driver for the TLV320DAC3100 Stereo DAC with Headphone & Speaker Amplifiers.
Summary
Functions
Configures headset and button press detection.
Bang version of configure_headset_detection/3. Raises on error.
Reads and returns the real-time headset detection status.
Bang version of get_headset_status/1. Raises on error.
Performs physical hardware reset and initial clock/register setup.
Bang version of initialize/1. Raises on error.
Creates a new, uninitialized %TLV320DAC3100{} struct.
Sets the DAC Left and Right channel digital volume (range: -63.5 to 24.0 dB).
Bang version of set_dac_volume/2. Raises on error.
Sets the Analog Headphone Amplifier gain (range: 0 to 9 dB).
It automatically clamps the value to the configured headphone_max_gain safety limit.
Bang version of set_headphone_gain/2. Raises on error.
Mutes or unmutes both left and right headphone driver amplifiers.
Bang version of set_headphone_mute/2. Raises on error.
Powers up/down the headphone drivers and sets output routing.
Bang version of set_headphone_output/2. Raises on error.
Sets the headphone output volume as a pragmatic percentage from 0 to 100.
Bang version of set_headphone_volume/2. Raises on error.
Sets the headphone Left and Right analog volume in decibels (range: 0.0 to -78.3 dB).
Bang version of set_headphone_volume_db/2. Raises on error.
Sets the Analog Class-D Speaker Amplifier gain (options: 6, 12, 18, 24 dB).
It automatically clamps the value to the configured speaker_max_gain safety limit.
Bang version of set_speaker_gain/2. Raises on error.
Mutes or unmutes the speaker driver amplifier.
Bang version of set_speaker_mute/2. Raises on error.
Powers up/down the Class-D speaker amplifier and sets output routing.
Bang version of set_speaker_output/2. Raises on error.
Sets the speaker output volume as a pragmatic percentage from 0 to 100.
Bang version of set_speaker_volume/2. Raises on error.
Sets the Left Analog Volume to SPK in decibels (range: 0.0 to -78.3 dB).
Bang version of set_speaker_volume_db/2. Raises on error.
Types
@type headset_status() :: :none | :headphone | :headset | :reserved
Real-time headset/jack detection status.
@type t() :: %TLV320DAC3100{ address: Circuits.I2C.address(), dac_volume: float(), headphone_enabled: boolean(), headphone_gain: 0..9, headphone_max_gain: 0..9, headphone_max_volume: float(), headphone_muted: boolean(), headphone_volume: float(), i2c_bus: Circuits.I2C.bus() | nil, reset_pin: String.t(), speaker_enabled: boolean(), speaker_gain: 6 | 12 | 18 | 24, speaker_max_gain: 6 | 12 | 18 | 24, speaker_max_volume: float(), speaker_muted: boolean(), speaker_volume: float() }
Driver state for a TLV320DAC3100 device.
Functions
Configures headset and button press detection.
Options
:detect_debounce- Debounce setting for headset detection (0-7, defaults to 0).:button_debounce- Debounce setting for button press detection (0-3, defaults to 0).
Bang version of configure_headset_detection/3. Raises on error.
@spec get_headset_status(t()) :: {:ok, headset_status(), t()} | {:error, term()}
Reads and returns the real-time headset detection status.
Returns {:ok, status_atom, dac} where status_atom is one of:
:none- No headset is connected.:headphone- Standard headphone (no mic) is connected.:headset- Headset with a microphone is connected.:reserved- Invalid or reserved state.
@spec get_headset_status!(t()) :: {headset_status(), t()}
Bang version of get_headset_status/1. Raises on error.
Performs physical hardware reset and initial clock/register setup.
Bang version of initialize/1. Raises on error.
@spec new( Circuits.I2C.bus(), keyword() ) :: t()
Creates a new, uninitialized %TLV320DAC3100{} struct.
Options
:address- I2C address of the device (defaults to0x18).:reset_pin- GPIO pin identifier wired to the chip's reset line (defaults to"GPIO26").:speaker_max_volume- Max analog speaker volume safety limit, 0.0 to -78.3 dB (defaults to0.0).:speaker_max_gain- Max speaker Class-D PGA gain safety limit, 6, 12, 18, or 24 dB (defaults to12).:headphone_max_volume- Max analog headphone volume safety limit, 0.0 to -78.3 dB (defaults to0.0).:headphone_max_gain- Max headphone PGA gain safety limit, 0 to 9 dB (defaults to9).
Sets the DAC Left and Right channel digital volume (range: -63.5 to 24.0 dB).
Bang version of set_dac_volume/2. Raises on error.
Sets the Analog Headphone Amplifier gain (range: 0 to 9 dB).
It automatically clamps the value to the configured headphone_max_gain safety limit.
Bang version of set_headphone_gain/2. Raises on error.
Mutes or unmutes both left and right headphone driver amplifiers.
Bang version of set_headphone_mute/2. Raises on error.
Powers up/down the headphone drivers and sets output routing.
Bang version of set_headphone_output/2. Raises on error.
Sets the headphone output volume as a pragmatic percentage from 0 to 100.
- 0% will automatically mute the headphone drivers.
- 1% to 100% scales the volume dynamically across all allowable options of gain and volume configured in the struct. It prefers the lowest possible gain when overlapping.
Bang version of set_headphone_volume/2. Raises on error.
Sets the headphone Left and Right analog volume in decibels (range: 0.0 to -78.3 dB).
Bang version of set_headphone_volume_db/2. Raises on error.
Sets the Analog Class-D Speaker Amplifier gain (options: 6, 12, 18, 24 dB).
It automatically clamps the value to the configured speaker_max_gain safety limit.
Bang version of set_speaker_gain/2. Raises on error.
Mutes or unmutes the speaker driver amplifier.
Bang version of set_speaker_mute/2. Raises on error.
Powers up/down the Class-D speaker amplifier and sets output routing.
Bang version of set_speaker_output/2. Raises on error.
Sets the speaker output volume as a pragmatic percentage from 0 to 100.
- 0% will automatically mute the speaker driver.
- 1% to 100% scales the volume dynamically across all allowable options of gain and volume configured in the struct. It prefers the lowest possible gain when overlapping.
Bang version of set_speaker_volume/2. Raises on error.
Sets the Left Analog Volume to SPK in decibels (range: 0.0 to -78.3 dB).
Bang version of set_speaker_volume_db/2. Raises on error.