📄 codec.h
字号:
/*****************************************************************/
/* Copyright (c) Texas Instruments, Incorporated 2000 */
/*****************************************************************/
/******************************************************************************/
/******************************************************************************/
/* CODEC.H - AD50 Audio Codec driver routines */
/* */
/* This module is the device library for the AD50 Audio Codec on the */
/* DSK board. */
/* */
/* MACRO FUNCTIONS: */
/* */
/* FUNCTIONS: */
/* */
/* codec_open() - allocate an identifing handle for an instance of a codec */
/* codec_close() - release a codec handle */
/* codec_reset() - Reset the codec to the default configuration. */
/* codec_read_reg() - Read an AD50 control register */
/* codec_write_reg() - Write an AD50 control register */
/* codec_read() - Read one or more words from the AD50 data stream */
/* codec_write() - Write one or more words to the AD50 data stream */
/* codec_power() - Power up/down the analog and filter functions */
/* codec_monitor_gain() - Sets the monitor amp gain */
/* codec_digital_loopback() - Enables digital loopback */
/* codec_dac_mode() - Set either 16-bit or 15-bit mode for DAC */
/* codec_adc_mode() - Set either 16-bit or 15-bit mode for adc */
/* codec_analog_loopback() - Enables analog loopback */
/* codec_ain_gain() - Sets analog input gain */
/* codec_aout_gain() - Sets analog output gain */
/* codec_sample_rate() - change capture and playback sample rates */
/* codec_fir_flag() - Read decimation filter overflow flag */
/* int codec_cont_play() - Sets continuous play (D/A) mode */
/* int codec_cont_capture() - Sets continuous capture (A/D) mode */
/* */
/******************************************************************************/
#ifndef _CODEC_H_
#define _CODEC_H_
#include <type.h>
#include <board.h> /* public header file */
/*****************************************************************************/
/* DEFINES */
/*****************************************************************************/
#undef OK
#define OK 0
#undef ERROR
#define ERROR -1
/*****************************************************************************/
/* typedefs & enums */
/*****************************************************************************/
typedef void* HANDLE;
typedef void (*FunctPtr)(void);
// Codec state
typedef enum
{
CODEC_CLOSED = 0,
CODEC_OPENED = 1,
CODEC_TX_DMA = 2,
CODEC_RX_DMA = 3
} CodecState, *PCodecState;
// Codec instance enumeration
typedef enum
{
DAA_CODEC = 0,
HANDSET_CODEC = 1,
SLIC_CODEC = 2
} CodecId, *PCodecId;
// Codec mode of operation
typedef enum
{
MODE_INT,
MODE_DMA
} CodecMode, *PCodecMode;
// Codec actions
typedef enum
{
PLAY,
CAPTURE
} CodecAction, *PCodecAction;
// Codec register enumeration
typedef enum
{
NoOp = 0x00,
Cntrl1 = 0x01,
Cntrl2 = 0x02,
Cntrl3 = 0x03,
Cntrl4 = 0x04
} CodecReg, *PCodecReg;
// Codec Power
typedef enum
{
CODEC_POWER_ON = 0x00, // Disable powerdown mode
CODEC_POWER_OFF = 0x40 // Enable powerdown mode
} CodecPower, *PCodecPower;
// Codec Monitor amplifier gain
typedef enum
{
CODEC_MON_MUTE = 0x00, // mute
CODEC_MON_MINUS_0dB = 0x04, // 0 dB
CODEC_MON_MINUS_8dB = 0x08, // -8 dB
CODEC_MON_MINUS_18dB = 0x0C // -18 dB
} CodecMonGain, *PCodecMonGain;
// Codec loopback
typedef enum
{
CODEC_LOOP_NONE = 0x00, // mute
CODEC_LOOP_DIGITAL = 0x02, // digital loopback
CODEC_LOOP_ANALOG = 0x08 // analog loopback
} CodecLoopback, *PCodecLoopback;
// Codec DAC mode
typedef enum
{
CODEC_DAC_16BIT, // 16 bit DAC mode (HW sec. comm.)
CODEC_DAC_15BIT // 15+1 bit DAC mode
} CodecDacMode, *PCodecDacMode;
// Codec ADC mode
typedef enum
{
CODEC_ADC_16BIT, // 16 bit ADC mode (HW sec. comm.)
CODEC_ADC_15BIT // 15+1 bit ADC mode
} CodecAdcMode, *PCodecAdcMode;
// Codec analog input gain
typedef enum
{
CODEC_AIN_MUTE = 0x03, // mute
CODEC_AIN_12dB = 0x02, // 12 dB
CODEC_AIN_6dB = 0x01, // 6 dB
CODEC_AIN_0dB = 0x00 // 0 dB
} CodecAinGain, *PCodecAinGain;
// Codec analog output gain
typedef enum
{
CODEC_AOUT_MUTE = 0x03, // mute
CODEC_AOUT_MINUS_12dB = 0x02, // -12 dB
CODEC_AOUT_MINUS_6dB = 0x01, // -6 dB
CODEC_AOUT_MINUS_0dB = 0x00 // 0 dB
} CodecAoutGain, *PCodecAoutGain;
// Codec sample rates (Twelve rates from 2000-16000 Hz)
typedef enum
{
SR_2000 = 0x80, // 2000 Hz
SR_2285 = 0xF0, // 2285 Hz
SR_2667 = 0xE0, // 2667 Hz
SR_3200 = 0xD0, // 3200 Hz
SR_4000 = 0xC0, // 4000 Hz
SR_5333 = 0xB0, // 5333 Hz
SR_8000 = 0xA0, // 8000 Hz
SR_9142 = 0x70, // 9142 Hz
SR_10667 = 0x60, // 10667 Hz
SR_12800 = 0x50, // 12800 Hz
SR_16000 = 0x90 // 16000 Hz
} CodecSampleRate, *PCodecSampleRate;
/*****************************************************************************/
/* GLOBAL VARIABLES */
/*****************************************************************************/
/*****************************************************************************/
/* PUBLIC FUNCTION PROTOTYPES */
/*****************************************************************************/
/******************************************************************************/
/* codec_open() - Acquire a handle to a specific codec and connect codec to */
/* respective McBSP. */
/* */
/* Parameters - */
/* codec - an element of an enumeration indicating the codec to open . */
/* */
/* Returns - a handle to the codec or -1 on failure */
/* */
/******************************************************************************/
HANDLE codec_open(CodecId codec);
/******************************************************************************/
/* codec_close() - Closes codec connection to the McBSP and releases a */
/* previously acquired handle */
/* */
/* Parameters - */
/* hDevice - a handle to a specific instance of codec. */
/* */
/* Returns - */
/* */
/******************************************************************************/
int codec_close(HANDLE hDevice);
/******************************************************************************/
/* codec_reset() - Reset chip to Power On Reset Configuration */
/* */
/* This function resets the AD50 codec by asserting then de-asserting */
/* the PWDN pin. All registers are configured to their POR values. */
/* */
/* Parameters - */
/* hDevice - a handle to a specific instance of codec. . */
/* */
/* Returns - */
/* */
/******************************************************************************/
int codec_reset(HANDLE hDevice);
/******************************************************************************/
/* codec_read_reg() - Read an AD50 control register */
/* */
/* Parameters - */
/* hDevice - a handle to a specific instance of codec. . */
/* reg - an element of an enumeration indicating the register to read. */
/* */
/* Returns - Content of the indicated register, or 0 if register invalid */
/* */
/* WARNING: This function is not compatible with DSP/BIOS */
/* */
/******************************************************************************/
u16 codec_read_reg(HANDLE hDevice, CodecReg reg);
/******************************************************************************/
/* codec_write_reg() - Write an AD50 control register */
/* */
/* Parameters - */
/* hDevice - a handle to a specific instance of codec. . */
/* reg - an element of an enumeration indicating the register to write. */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -