DAC routines. More...
#include <cfg/os.h>
#include <cfg/clock.h>
#include <dev/board.h>
#include <dev/irqreg.h>
#include <dev/twif.h>
#include <stdlib.h>
#include <string.h>
#include <memdebug.h>
#include <sys/event.h>
#include <sys/timer.h>
#include <dev/tlv320dac.h>
Go to the source code of this file.
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. | |
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. | |
int | Tlv320SwitchMode (void) |
Variables | |
volatile uint32_t | irq_counter |
unsigned int | use_pdc = 1 |
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/
* * $Log$ * Revision 1.3 2009/02/13 14:52:05 haraldkipp * Include memdebug.h for heap management debugging support. * * Revision 1.2 2009/01/17 11:26:37 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.c.
#define TWI_SLA_DAC 0x1A |
Definition at line 73 of file tlv320dac.c.
Referenced by Tlv320DacWriteReg().
#define TLV320DAC_VOL 0x18 |
Definition at line 80 of file tlv320dac.c.
#define SAMPLE_BUFFERS 3 |
Definition at line 90 of file tlv320dac.c.
Referenced by Tlv320DacWrite().
#define DACI2S_PIO_ID PIOA_ID |
Definition at line 104 of file tlv320dac.c.
#define DACI2S_PINS_A _BV(PA23_TD_A) | _BV(PA21_TF_A) | _BV(PA22_TK_A) |
Definition at line 105 of file tlv320dac.c.
#define DACI2S_PINS_B 0 |
Definition at line 106 of file tlv320dac.c.
#define DACI2S_PDR PIOA_PDR |
Definition at line 113 of file tlv320dac.c.
#define DACI2S_ASR PIOA_ASR |
Definition at line 114 of file tlv320dac.c.
#define DACI2S_BSR PIOA_BSR |
Definition at line 115 of file tlv320dac.c.
#define PCM_CHANS 2 |
Number of channels.
Definition at line 132 of file tlv320dac.c.
#define PCM_BITS 16 |
Number of bits per sample.
Definition at line 137 of file tlv320dac.c.
typedef struct _PCM_BUFFER PCM_BUFFER |
PCM buffer type.
u_char Tlv320DacReadReg | ( | unsigned int | reg | ) |
Read value from specified DAC register.
Not implemented, because the TLV320AIC23B is a write-only device.
reg | DAC register address. |
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.
reg | DAC register address. |
val | Value 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().
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().
int Tlv320DacInit | ( | unsigned int | rate | ) |
Initialize TLV320AIC23B DAC interface.
rate | Sample rate. |
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().
int Tlv320DacFlush | ( | void | ) |
Wait until all buffered samples have been transmitted.
Definition at line 419 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 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.
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 496 of file tlv320dac.c.
References DAC_LHP_VOL, DAC_MAX_VOLUME, DAC_MIN_VOLUME, DAC_RHP_VOL, and Tlv320DacWriteReg().
int Tlv320SwitchMode | ( | void | ) |
Definition at line 517 of file tlv320dac.c.
References NutIrqDisable(), sig_SSC, and use_pdc.
volatile uint32_t irq_counter |
Definition at line 122 of file tlv320dac.c.
unsigned int use_pdc = 1 |
Definition at line 149 of file tlv320dac.c.
Referenced by Tlv320SwitchMode().