Nut/OS  5.0.5
API Reference
tlv320dac.c File Reference

DAC routines. More...

#include <dev/board.h>
#include <dev/irqreg.h>
#include <sys/event.h>
#include <sys/timer.h>
#include <stdlib.h>
#include <string.h>
#include <memdebug.h>
#include <dev/tlv320dac.h>
Include dependency graph for tlv320dac.c:

Data Structures

struct  _PCM_BUFFER
 PCM buffer type. More...

Defines

#define TWI_SLA_DAC   0x1A
#define TLV320DAC_VOL   0x18
#define SAMPLE_BUFFERS   3
#define DACI2S_PIO_ID   PIOA_ID
#define DACI2S_PINS_A   _BV(PA23_TD_A) | _BV(PA21_TF_A) | _BV(PA22_TK_A)
#define DACI2S_PINS_B   0
#define DACI2S_PDR   PIOA_PDR
#define DACI2S_ASR   PIOA_ASR
#define DACI2S_BSR   PIOA_BSR
#define PCM_CHANS   2
 Number of channels.
#define PCM_BITS   16
 Number of bits per sample.
#define TWI_ENABLE()
#define SDA_LOW()
#define SDA_HIGH()
#define SCL_LOW()
#define SCL_HIGH()
#define SDA_STAT()   (1)
#define TWI_DELAY   8

Typedefs

typedef struct _PCM_BUFFER PCM_BUFFER
 PCM buffer type.

Functions

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 Tlv320DacSetRate (unsigned int rate)
int Tlv320DacInit (unsigned int rate)
 Initialize TLV320AIC23B DAC interface.
int Tlv320DacFlush (void)
 Wait until all buffered samples have been transmitted.
int Tlv320DacWrite (void *buf, int len)
 Add audio samples to the TLV320AIC23B transmit queue.
int Tlv320DacSetVolume (int left, int right)
 Set volume.

Detailed Description

DAC routines.

Copyright (C) 2008 by egnite GmbH. 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/

 * $Id: tlv320dac.c 4473 2012-08-20 15:12:45Z haraldkipp $
 * 

Define Documentation

#define TWI_SLA_DAC   0x1A

Referenced by Tlv320DacWriteReg().

#define TLV320DAC_VOL   0x18
#define SAMPLE_BUFFERS   3

Referenced by Tlv320DacWrite().

#define DACI2S_PIO_ID   PIOA_ID
#define DACI2S_PINS_A   _BV(PA23_TD_A) | _BV(PA21_TF_A) | _BV(PA22_TK_A)
#define DACI2S_PINS_B   0
#define DACI2S_PDR   PIOA_PDR
#define DACI2S_ASR   PIOA_ASR
#define DACI2S_BSR   PIOA_BSR
#define PCM_CHANS   2

Number of channels.

#define PCM_BITS   16

Number of bits per sample.

#define TWI_ENABLE ( )

Referenced by TwBbifInit().

#define SDA_LOW ( )
#define SDA_HIGH ( )

Referenced by TwBbifInit().

#define SCL_LOW ( )
#define SCL_HIGH ( )

Referenced by TwBbifInit().

#define SDA_STAT ( )    (1)
#define TWI_DELAY   8

Typedef Documentation

typedef struct _PCM_BUFFER PCM_BUFFER

PCM buffer type.


Function Documentation

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

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