Nut/OS  4.10.3
API Reference
tlv320dac.h File Reference

TLV320AIC23B driver. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define DAC_MAX_VOLUME   6
#define DAC_MIN_VOLUME   -73

Functions

int Tlv320DacInit (unsigned int rate)
 Initialize TLV320AIC23B DAC interface.
int Tlv320DacWrite (void *buf, int len)
 Add audio samples to the TLV320AIC23B transmit queue.
int Tlv320DacFlush (void)
 Wait until all buffered samples have been transmitted.
u_char Tlv320DacReadReg (unsigned int reg)
 Read value from specified DAC register.
void Tlv320DacWriteReg (unsigned int reg, unsigned int val)
 Write value to specified DAC register.
int Tlv320DacSetVolume (int left, int right)
 Set volume.
int Tlv320DacSetRate (unsigned int rate)
int Tlv320SwitchMode (void)

Left Line Input Channel Volume Control Register

#define DAC_LLI_VOL   0x00
 Register address.
#define DAC_LLI_VOL_LRS   0x0100
 Left/right simultaneous volume/mute update.
#define DAC_LLI_VOL_LIM   0x0080
 Mute.
#define DAC_LLI_VOL_LIV   0x001F
 Volume control mask.
#define DAC_LLI_VOL_LIV_LSB   0
 Volume control LSB.

Right Line Input Channel Volume Control Register

#define DAC_RLI_VOL   0x01
 Register address.
#define DAC_RLI_VOL_RLS   0x0100
 Right/left simultaneous volume/mute update.
#define DAC_RLI_VOL_RIM   0x0080
 Mute.
#define DAC_RLI_VOL_RIV   0x001F
 Volume control mask.
#define DAC_RLI_VOL_RIV_LSB   0
 Volume control LSB.

Left Channel Headphone Volume Control

#define DAC_LHP_VOL   0x02
 Register address.
#define DAC_LHP_VOL_LRS   0x0100
 Left/right simultaneous volume/mute update.
#define DAC_LHP_VOL_LZC   0x0080
 Zero cross detect.
#define DAC_LHP_VOL_LHV   0x007F
 Volume control mask.
#define DAC_LHP_VOL_LHV_LSB   0
 Volume control LSB.

Right Channel Headphone Volume Control

#define DAC_RHP_VOL   0x03
 Register address.
#define DAC_RHP_VOL_RLS   0x0100
 Right/left simultaneous volume/mute update.
#define DAC_RHP_VOL_LZC   0x0080
 Zero cross detect.
#define DAC_RHP_VOL_LHV   0x007F
 Volume control mask.
#define DAC_RHP_VOL_LHV_LSB   0
 Volume control LSB.

Analog Audio Path Control

#define DAC_ANA_PATH   0x04
 Register address.
#define DAC_ANA_PATH_STA   0x01C0
 Side tone mask.
#define DAC_ANA_PATH_STA_LSB   6
 Side tone LSB.
#define DAC_ANA_PATH_STA_0DB   0x0100
 Added side tone of 0dB.
#define DAC_ANA_PATH_STA_M6DB   0x0000
 Added side tone of -6dB.
#define DAC_ANA_PATH_STA_M9DB   0x0040
 Added side tone of -9dB.
#define DAC_ANA_PATH_STA_M12DB   0x0080
 Added side tone of -12dB.
#define DAC_ANA_PATH_STA_M18DB   0x00C0
 Added side tone of -18dB.
#define DAC_ANA_PATH_STE   0x0020
 Side tone enable.
#define DAC_ANA_PATH_DAC   0x0010
 DAC select.
#define DAC_ANA_PATH_BYP   0x0008
 Bypass.
#define DAC_ANA_PATH_INSEL   0x0004
 ADC microphone input.
#define DAC_ANA_PATH_MICM   0x0002
 Microphone mute.
#define DAC_ANA_PATH_MICB   0x0001
 Microphone boost.

Digital Audio Path Control

#define DAC_DIG_PATH   0x05
 Register address.
#define DAC_DIG_PATH_DACM   0x0008
 DAC soft mute.
#define DAC_DIG_PATH_DEEMP   0x0006
 De-emphases control mask.
#define DAC_DIG_PATH_DEEMP_LSB   1
 De-emphases control LSB.
#define DAC_DIG_PATH_DEEMP_NONE   0x0000
 De-emphases disabled.
#define DAC_DIG_PATH_DEEMP_32KHZ   0x0002
 De-emphases 32 kHz.
#define DAC_DIG_PATH_DEEMP_44_1KHZ   0x0004
 De-emphases 44.1 kHz.
#define DAC_DIG_PATH_DEEMP_48KHZ   0x0006
 De-emphases 48 kHz.
#define DAC_DIG_PATH_ADCHP   0x0001
 ADC high-pass filter.
#define DAC_PWRDN   0x06
 Register address.
#define DAC_PWRDN_OFF   0x0080
 Device power off.
#define DAC_PWRDN_CLK   0x0040
 Clock off.
#define DAC_PWRDN_OSC   0x0020
 Oscillator off.
#define DAC_PWRDN_OUT   0x0010
 Outputs off.
#define DAC_PWRDN_DAC   0x0008
 DAC off.
#define DAC_PWRDN_ADC   0x0004
 ADC off.
#define DAC_PWRDN_MIC   0x0002
 Microphone input off.
#define DAC_PWRDN_LINE   0x0001
 Line input off.

Digital Audio Interface Format

#define DAC_DAI_FMT   0x07
 Register address.
#define DAC_DAI_FMT_MS   0x0040
 Maser mode.
#define DAC_DAI_FMT_LRSWAP   0x0020
 DAC left/right swap.
#define DAC_DAI_FMT_LRP   0x0010
 DAC left/right phase.
#define DAC_DAI_FMT_IWL   0x000C
 Input bit length mask.
#define DAC_DAI_FMT_IWL_LSB   2
 Input bit length LSB.
#define DAC_DAI_FMT_IWL_16   0x0000
 16 bit input length.
#define DAC_DAI_FMT_IWL_20   0x0004
 20 bit input length.
#define DAC_DAI_FMT_IWL_24   0x0008
 24 bit input length.
#define DAC_DAI_FMT_IWL_32   0x000C
 32 bit input length.
#define DAC_DAI_FMT_FOR   0x0003
 Data format mask.
#define DAC_DAI_FMT_FOR_LSB   0
 Data format LSB.
#define DAC_DAI_FMT_FOR_RA   0x0000
 MSB first, right aligned.
#define DAC_DAI_FMT_FOR_LA   0x0001
 MSB first, left aligned.
#define DAC_DAI_FMT_FOR_I2S   0x0002
 I2S format, MSB first, left – 1 aligned.
#define DAC_DAI_FMT_FOR_DSP   0x0003
 DSP format, frame sync followed by two data words.

Sample Rate Control

#define DAC_SRATE   0x08
 Register address.
#define DAC_SRATE_CLKOUT   0x0080
 Clock output divider.
#define DAC_SRATE_CLKIN   0x0040
 Clock input divider.
#define DAC_SRATE_SR   0x003C
 Sampling rate mask.
#define DAC_SRATE_SR_LSB   2
 Sampling rate LSB.
#define DAC_SRATE_BOSR   0x0002
 Base oversampling rate.
#define DAC_SRATE_USB   0x0001
 USB clock mode.

Digital Interface Activation

#define DAC_DI_ACT   0x09
 Register address.
#define DAC_DI_ACT_ACT   0x0001
 Interface active.

Reset Register

#define DAC_RESET   0x0F
 Register address.

Detailed Description

TLV320AIC23B driver.

Copyright (C) 2007 by egnite Software GmbH. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the copyright holders nor the names of contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY EGNITE SOFTWARE GMBH AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL EGNITE SOFTWARE GMBH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

For additional information see http://www.ethernut.de/

 *
 * $Log$
 * Revision 1.2  2009/01/17 11:26:47  haraldkipp
 * Getting rid of two remaining BSD types in favor of stdint.
 * Replaced 'u_int' by 'unsinged int' and 'uptr_t' by 'uintptr_t'.
 *
 * Revision 1.1  2008/10/05 16:51:46  haraldkipp
 * Added suport for the TLV320 audio DAC.
 *
 *
 * 

Definition in file tlv320dac.h.


Define Documentation

#define DAC_LLI_VOL   0x00

Register address.

Definition at line 56 of file tlv320dac.h.

#define DAC_LLI_VOL_LRS   0x0100

Left/right simultaneous volume/mute update.

Definition at line 57 of file tlv320dac.h.

#define DAC_LLI_VOL_LIM   0x0080

Mute.

Definition at line 58 of file tlv320dac.h.

#define DAC_LLI_VOL_LIV   0x001F

Volume control mask.

From 0x00 (-34.5dB) to 0x1F (+12dB) in 1.5dB steps.

Definition at line 59 of file tlv320dac.h.

#define DAC_LLI_VOL_LIV_LSB   0

Volume control LSB.

Definition at line 63 of file tlv320dac.h.

#define DAC_RLI_VOL   0x01

Register address.

Definition at line 68 of file tlv320dac.h.

#define DAC_RLI_VOL_RLS   0x0100

Right/left simultaneous volume/mute update.

Definition at line 69 of file tlv320dac.h.

#define DAC_RLI_VOL_RIM   0x0080

Mute.

Definition at line 70 of file tlv320dac.h.

#define DAC_RLI_VOL_RIV   0x001F

Volume control mask.

From 0x00 (-34.5dB) to 0x1F (+12dB) in 1.5dB steps.

Definition at line 71 of file tlv320dac.h.

#define DAC_RLI_VOL_RIV_LSB   0

Volume control LSB.

Definition at line 75 of file tlv320dac.h.

#define DAC_LHP_VOL   0x02

Register address.

Definition at line 81 of file tlv320dac.h.

Referenced by Tlv320DacInit(), and Tlv320DacSetVolume().

#define DAC_LHP_VOL_LRS   0x0100

Left/right simultaneous volume/mute update.

Definition at line 82 of file tlv320dac.h.

Referenced by Tlv320DacInit().

#define DAC_LHP_VOL_LZC   0x0080

Zero cross detect.

Definition at line 83 of file tlv320dac.h.

#define DAC_LHP_VOL_LHV   0x007F

Volume control mask.

From 0x30 (-73dB, mute) to 0x3F (+6dB).

Definition at line 84 of file tlv320dac.h.

#define DAC_LHP_VOL_LHV_LSB   0

Volume control LSB.

Definition at line 88 of file tlv320dac.h.

Referenced by Tlv320DacInit().

#define DAC_RHP_VOL   0x03

Register address.

Definition at line 93 of file tlv320dac.h.

Referenced by Tlv320DacSetVolume().

#define DAC_RHP_VOL_RLS   0x0100

Right/left simultaneous volume/mute update.

Definition at line 94 of file tlv320dac.h.

#define DAC_RHP_VOL_LZC   0x0080

Zero cross detect.

Definition at line 95 of file tlv320dac.h.

#define DAC_RHP_VOL_LHV   0x007F

Volume control mask.

From 0x30 (-73dB, mute) to 0x3F (+6dB).

Definition at line 96 of file tlv320dac.h.

#define DAC_RHP_VOL_LHV_LSB   0

Volume control LSB.

Definition at line 100 of file tlv320dac.h.

#define DAC_ANA_PATH   0x04

Register address.

Definition at line 105 of file tlv320dac.h.

Referenced by Tlv320DacInit().

#define DAC_ANA_PATH_STA   0x01C0

Side tone mask.

Definition at line 106 of file tlv320dac.h.

#define DAC_ANA_PATH_STA_LSB   6

Side tone LSB.

Definition at line 107 of file tlv320dac.h.

#define DAC_ANA_PATH_STA_0DB   0x0100

Added side tone of 0dB.

Definition at line 108 of file tlv320dac.h.

#define DAC_ANA_PATH_STA_M6DB   0x0000

Added side tone of -6dB.

Definition at line 109 of file tlv320dac.h.

#define DAC_ANA_PATH_STA_M9DB   0x0040

Added side tone of -9dB.

Definition at line 110 of file tlv320dac.h.

#define DAC_ANA_PATH_STA_M12DB   0x0080

Added side tone of -12dB.

Definition at line 111 of file tlv320dac.h.

#define DAC_ANA_PATH_STA_M18DB   0x00C0

Added side tone of -18dB.

Definition at line 112 of file tlv320dac.h.

#define DAC_ANA_PATH_STE   0x0020

Side tone enable.

Definition at line 113 of file tlv320dac.h.

#define DAC_ANA_PATH_DAC   0x0010

DAC select.

Definition at line 114 of file tlv320dac.h.

Referenced by Tlv320DacInit().

#define DAC_ANA_PATH_BYP   0x0008

Bypass.

Definition at line 115 of file tlv320dac.h.

#define DAC_ANA_PATH_INSEL   0x0004

ADC microphone input.

Definition at line 116 of file tlv320dac.h.

Referenced by Tlv320DacInit().

#define DAC_ANA_PATH_MICM   0x0002

Microphone mute.

Definition at line 117 of file tlv320dac.h.

#define DAC_ANA_PATH_MICB   0x0001

Microphone boost.

Definition at line 118 of file tlv320dac.h.

Referenced by Tlv320DacInit().

#define DAC_DIG_PATH   0x05

Register address.

Definition at line 123 of file tlv320dac.h.

Referenced by Tlv320DacInit().

#define DAC_DIG_PATH_DACM   0x0008

DAC soft mute.

Definition at line 124 of file tlv320dac.h.

#define DAC_DIG_PATH_DEEMP   0x0006

De-emphases control mask.

Definition at line 125 of file tlv320dac.h.

#define DAC_DIG_PATH_DEEMP_LSB   1

De-emphases control LSB.

Definition at line 126 of file tlv320dac.h.

#define DAC_DIG_PATH_DEEMP_NONE   0x0000

De-emphases disabled.

Definition at line 127 of file tlv320dac.h.

#define DAC_DIG_PATH_DEEMP_32KHZ   0x0002

De-emphases 32 kHz.

Definition at line 128 of file tlv320dac.h.

#define DAC_DIG_PATH_DEEMP_44_1KHZ   0x0004

De-emphases 44.1 kHz.

Definition at line 129 of file tlv320dac.h.

#define DAC_DIG_PATH_DEEMP_48KHZ   0x0006

De-emphases 48 kHz.

Definition at line 130 of file tlv320dac.h.

#define DAC_DIG_PATH_ADCHP   0x0001

ADC high-pass filter.

Definition at line 131 of file tlv320dac.h.

#define DAC_PWRDN   0x06

Register address.

Definition at line 136 of file tlv320dac.h.

Referenced by Tlv320DacInit().

#define DAC_PWRDN_OFF   0x0080

Device power off.

Definition at line 137 of file tlv320dac.h.

#define DAC_PWRDN_CLK   0x0040

Clock off.

Definition at line 138 of file tlv320dac.h.

#define DAC_PWRDN_OSC   0x0020

Oscillator off.

Definition at line 139 of file tlv320dac.h.

#define DAC_PWRDN_OUT   0x0010

Outputs off.

Definition at line 140 of file tlv320dac.h.

#define DAC_PWRDN_DAC   0x0008

DAC off.

Definition at line 141 of file tlv320dac.h.

#define DAC_PWRDN_ADC   0x0004

ADC off.

Definition at line 142 of file tlv320dac.h.

#define DAC_PWRDN_MIC   0x0002

Microphone input off.

Definition at line 143 of file tlv320dac.h.

#define DAC_PWRDN_LINE   0x0001

Line input off.

Definition at line 144 of file tlv320dac.h.

Referenced by Tlv320DacInit().

#define DAC_DAI_FMT   0x07

Register address.

Definition at line 149 of file tlv320dac.h.

Referenced by Tlv320DacInit().

#define DAC_DAI_FMT_MS   0x0040

Maser mode.

Definition at line 150 of file tlv320dac.h.

Referenced by Tlv320DacInit().

#define DAC_DAI_FMT_LRSWAP   0x0020

DAC left/right swap.

Definition at line 151 of file tlv320dac.h.

#define DAC_DAI_FMT_LRP   0x0010

DAC left/right phase.

Definition at line 152 of file tlv320dac.h.

#define DAC_DAI_FMT_IWL   0x000C

Input bit length mask.

Definition at line 153 of file tlv320dac.h.

#define DAC_DAI_FMT_IWL_LSB   2

Input bit length LSB.

Definition at line 154 of file tlv320dac.h.

#define DAC_DAI_FMT_IWL_16   0x0000

16 bit input length.

Definition at line 155 of file tlv320dac.h.

#define DAC_DAI_FMT_IWL_20   0x0004

20 bit input length.

Definition at line 156 of file tlv320dac.h.

#define DAC_DAI_FMT_IWL_24   0x0008

24 bit input length.

Definition at line 157 of file tlv320dac.h.

#define DAC_DAI_FMT_IWL_32   0x000C

32 bit input length.

Definition at line 158 of file tlv320dac.h.

#define DAC_DAI_FMT_FOR   0x0003

Data format mask.

Definition at line 159 of file tlv320dac.h.

#define DAC_DAI_FMT_FOR_LSB   0

Data format LSB.

Definition at line 160 of file tlv320dac.h.

#define DAC_DAI_FMT_FOR_RA   0x0000

MSB first, right aligned.

Definition at line 161 of file tlv320dac.h.

#define DAC_DAI_FMT_FOR_LA   0x0001

MSB first, left aligned.

Definition at line 162 of file tlv320dac.h.

#define DAC_DAI_FMT_FOR_I2S   0x0002

I2S format, MSB first, left – 1 aligned.

Definition at line 163 of file tlv320dac.h.

Referenced by Tlv320DacInit().

#define DAC_DAI_FMT_FOR_DSP   0x0003

DSP format, frame sync followed by two data words.

Definition at line 164 of file tlv320dac.h.

#define DAC_SRATE   0x08

Register address.

Definition at line 169 of file tlv320dac.h.

Referenced by Tlv320DacSetRate().

#define DAC_SRATE_CLKOUT   0x0080

Clock output divider.

Definition at line 170 of file tlv320dac.h.

#define DAC_SRATE_CLKIN   0x0040

Clock input divider.

Definition at line 171 of file tlv320dac.h.

#define DAC_SRATE_SR   0x003C

Sampling rate mask.

Definition at line 172 of file tlv320dac.h.

#define DAC_SRATE_SR_LSB   2

Sampling rate LSB.

Definition at line 173 of file tlv320dac.h.

Referenced by Tlv320DacSetRate().

#define DAC_SRATE_BOSR   0x0002

Base oversampling rate.

USB mode : 0=250 fs, 1=272 fs Normal mode: 0=256 fs, 1=384 fs

Definition at line 174 of file tlv320dac.h.

Referenced by Tlv320DacSetRate().

#define DAC_SRATE_USB   0x0001

USB clock mode.

Definition at line 179 of file tlv320dac.h.

Referenced by Tlv320DacSetRate().

#define DAC_DI_ACT   0x09

Register address.

Definition at line 184 of file tlv320dac.h.

Referenced by Tlv320DacInit().

#define DAC_DI_ACT_ACT   0x0001

Interface active.

Definition at line 185 of file tlv320dac.h.

Referenced by Tlv320DacInit().

#define DAC_RESET   0x0F

Register address.

Writing zero to this register triggers reset.

Definition at line 190 of file tlv320dac.h.

Referenced by Tlv320DacInit().

#define DAC_MAX_VOLUME   6

Definition at line 196 of file tlv320dac.h.

Referenced by Tlv320DacSetVolume().

#define DAC_MIN_VOLUME   -73

Definition at line 197 of file tlv320dac.h.

Referenced by Tlv320DacSetVolume().


Function Documentation

int Tlv320DacInit ( unsigned int  rate)

Initialize TLV320AIC23B DAC interface.

Parameters:
rateSample rate.
Returns:
0 on success, -1 otherwise.

Definition at line 361 of file tlv320dac.c.

References DAC_ANA_PATH, DAC_ANA_PATH_DAC, DAC_ANA_PATH_INSEL, DAC_ANA_PATH_MICB, DAC_DAI_FMT, DAC_DAI_FMT_FOR_I2S, DAC_DAI_FMT_MS, DAC_DI_ACT, DAC_DI_ACT_ACT, DAC_DIG_PATH, DAC_LHP_VOL, DAC_LHP_VOL_LHV_LSB, DAC_LHP_VOL_LRS, DAC_PWRDN, DAC_PWRDN_LINE, DAC_RESET, Tlv320DacSetRate(), Tlv320DacWriteReg(), and TwInit().

Here is the call graph for this function:

int Tlv320DacWrite ( void *  buf,
int  len 
)

Add audio samples to the TLV320AIC23B transmit queue.

Parameters:
bufPoints to PCM data.
lenNumber of samples.
Returns:
0 on success or -1 if out of memory.

Definition at line 440 of file tlv320dac.c.

References free(), malloc(), memcpy(), NutEventWait(), SAMPLE_BUFFERS, _PCM_BUFFER::wbf_dat, _PCM_BUFFER::wbf_len, and _PCM_BUFFER::wbf_siz.

Here is the call graph for this function:

int Tlv320DacFlush ( void  )

Wait until all buffered samples have been transmitted.

Returns:
Always 0.

Definition at line 419 of file tlv320dac.c.

References NutEventWait().

Here is the call graph for this function:

u_char Tlv320DacReadReg ( unsigned int  reg)

Read value from specified DAC register.

Not implemented, because the TLV320AIC23B is a write-only device.

Parameters:
regDAC register address.
Returns:
Always 0xFF.

Definition at line 214 of file tlv320dac.c.

void Tlv320DacWriteReg ( unsigned int  reg,
unsigned int  val 
)

Write value to specified DAC register.

Communicates with the DAC chip via TWI.

Parameters:
regDAC register address.
valValue to store in specified register.

Definition at line 227 of file tlv320dac.c.

References TWI_SLA_DAC, and TwMasterTransact().

Referenced by Tlv320DacInit(), Tlv320DacSetRate(), and Tlv320DacSetVolume().

Here is the call graph for this function:

int Tlv320DacSetVolume ( int  left,
int  right 
)

Set volume.

Sets the master playback gain. Range is +6..-73 dB.

Parameters:
leftLeft channel gain in dB.
rightRight channel gain in dB.
Returns:
0 on success, -1 otherwise.

Definition at line 496 of file tlv320dac.c.

References DAC_LHP_VOL, DAC_MAX_VOLUME, DAC_MIN_VOLUME, DAC_RHP_VOL, and Tlv320DacWriteReg().

Here is the call graph for this function:

int Tlv320DacSetRate ( unsigned int  rate)

Definition at line 323 of file tlv320dac.c.

References DAC_SRATE, DAC_SRATE_BOSR, DAC_SRATE_SR_LSB, DAC_SRATE_USB, and Tlv320DacWriteReg().

Referenced by Tlv320DacInit().

Here is the call graph for this function:

int Tlv320SwitchMode ( void  )

Definition at line 517 of file tlv320dac.c.

References NutIrqDisable(), sig_SSC, and use_pdc.

Here is the call graph for this function: