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/
* * $Log: tlv320dac.c,v $ * Revision 1.1 2008/10/05 16:51:46 haraldkipp * Added suport for the TLV320 audio DAC. * * *
Definition in file tlv320dac.c.
Go to the source code of this file.
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. | |
Functions | |
u_char | Tlv320DacReadReg (u_int reg) |
Read value from specified DAC register. | |
void | Tlv320DacWriteReg (u_int reg, u_int val) |
Write value to specified DAC register. | |
int | Tlv320DacSetRate (u_int rate) |
int | Tlv320DacInit (u_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. | |
int | Tlv320SwitchMode (void) |
Variables | |
volatile uint32_t | irq_counter |
u_int | use_pdc = 1 |
#define TWI_SLA_DAC 0x1A |
#define TLV320DAC_VOL 0x18 |
Definition at line 72 of file tlv320dac.c.
#define SAMPLE_BUFFERS 3 |
#define DACI2S_PIO_ID PIOA_ID |
Definition at line 96 of file tlv320dac.c.
#define DACI2S_PINS_A _BV(PA23_TD_A) | _BV(PA21_TF_A) | _BV(PA22_TK_A) |
Definition at line 97 of file tlv320dac.c.
#define DACI2S_PINS_B 0 |
Definition at line 98 of file tlv320dac.c.
#define DACI2S_PDR PIOA_PDR |
Definition at line 105 of file tlv320dac.c.
#define DACI2S_ASR PIOA_ASR |
Definition at line 106 of file tlv320dac.c.
#define DACI2S_BSR PIOA_BSR |
Definition at line 107 of file tlv320dac.c.
#define PCM_CHANS 2 |
#define PCM_BITS 16 |
Read value from specified DAC register.
Not implemented, because the TLV320AIC23B is a write-only device.
reg | DAC register address. |
Definition at line 206 of file tlv320dac.c.
Write value to specified DAC register.
Communicates with the DAC chip via TWI.
reg | DAC register address. | |
val | Value to store in specified register. |
Definition at line 219 of file tlv320dac.c.
References TWI_SLA_DAC, and TwMasterTransact().
int Tlv320DacSetRate | ( | u_int | rate | ) |
Definition at line 315 of file tlv320dac.c.
References DAC_SRATE, DAC_SRATE_BOSR, DAC_SRATE_SR_LSB, DAC_SRATE_USB, and Tlv320DacWriteReg().
int Tlv320DacInit | ( | u_int | rate | ) |
Initialize TLV320AIC23B DAC interface.
rate | Sample rate. |
Definition at line 353 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().
int Tlv320DacFlush | ( | void | ) |
Wait until all buffered samples have been transmitted.
Definition at line 411 of file tlv320dac.c.
References NutEventWait().
int Tlv320DacWrite | ( | void * | buf, | |
int | len | |||
) |
Add audio samples to the TLV320AIC23B transmit queue.
buf | Points to PCM data. | |
len | Number of samples. |
Definition at line 432 of file tlv320dac.c.
References free, malloc, memcpy(), NutEventWait(), and SAMPLE_BUFFERS.
int Tlv320DacSetVolume | ( | int | left, | |
int | right | |||
) |
Set volume.
Sets the master playback gain. Range is +6..-73 dB.
left | Left channel gain in dB. | |
right | Right channel gain in dB. |
Definition at line 488 of file tlv320dac.c.
References DAC_LHP_VOL, DAC_MAX_VOLUME, DAC_MIN_VOLUME, DAC_RHP_VOL, and Tlv320DacWriteReg().
int Tlv320SwitchMode | ( | void | ) |
volatile uint32_t irq_counter |
Definition at line 114 of file tlv320dac.c.