Nut/OS  5.0.5
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 THE COPYRIGHT HOLDERS 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 THE COPYRIGHT OWNER 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.
 *
 *
 * 

Define Documentation

#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.

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

#define DAC_LLI_VOL_LIV_LSB   0

Volume control LSB.

#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.

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

#define DAC_RLI_VOL_RIV_LSB   0

Volume control LSB.

#define DAC_LHP_VOL   0x02

Register address.

Referenced by Tlv320DacInit(), and Tlv320DacSetVolume().

#define DAC_LHP_VOL_LRS   0x0100

Left/right simultaneous volume/mute update.

Referenced by Tlv320DacInit().

#define DAC_LHP_VOL_LZC   0x0080

Zero cross detect.

#define DAC_LHP_VOL_LHV   0x007F

Volume control mask.

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

#define DAC_LHP_VOL_LHV_LSB   0

Volume control LSB.

Referenced by Tlv320DacInit().

#define DAC_RHP_VOL   0x03

Register address.

Referenced by Tlv320DacSetVolume().

#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.

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

#define DAC_RHP_VOL_LHV_LSB   0

Volume control LSB.

#define DAC_ANA_PATH   0x04

Register address.

Referenced by Tlv320DacInit().

#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.

Referenced by Tlv320DacInit().

#define DAC_ANA_PATH_BYP   0x0008

Bypass.

#define DAC_ANA_PATH_INSEL   0x0004

ADC microphone input.

Referenced by Tlv320DacInit().

#define DAC_ANA_PATH_MICM   0x0002

Microphone mute.

#define DAC_ANA_PATH_MICB   0x0001

Microphone boost.

Referenced by Tlv320DacInit().

#define DAC_DIG_PATH   0x05

Register address.

Referenced by Tlv320DacInit().

#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.

Referenced by Tlv320DacInit().

#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.

Referenced by Tlv320DacInit().

#define DAC_DAI_FMT   0x07

Register address.

Referenced by Tlv320DacInit().

#define DAC_DAI_FMT_MS   0x0040

Maser mode.

Referenced by Tlv320DacInit().

#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.

Referenced by Tlv320DacInit().

#define DAC_DAI_FMT_FOR_DSP   0x0003

DSP format, frame sync followed by two data words.

#define DAC_SRATE   0x08

Register address.

Referenced by Tlv320DacSetRate().

#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.

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

Referenced by Tlv320DacSetRate().

#define DAC_SRATE_USB   0x0001

USB clock mode.

Referenced by Tlv320DacSetRate().

#define DAC_DI_ACT   0x09

Register address.

Referenced by Tlv320DacInit().

#define DAC_DI_ACT_ACT   0x0001

Interface active.

Referenced by Tlv320DacInit().

#define DAC_RESET   0x0F

Register address.

Writing zero to this register triggers reset.

Referenced by Tlv320DacInit().

#define DAC_MAX_VOLUME   6

Referenced by Tlv320DacSetVolume().

#define DAC_MIN_VOLUME   -73

Referenced by Tlv320DacSetVolume().


Function Documentation

int Tlv320DacInit ( unsigned int  rate)

Initialize TLV320AIC23B DAC interface.

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

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(), and Tlv320DacWriteReg().

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.

References free(), malloc(), memcpy(), NULL, 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.

References NutEventWait(), and rc.

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.
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.

References NULL, and TWI_SLA_DAC.

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

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.

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)

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  )