aic23.h
上传用户:dahaojd
上传日期:2008-01-29
资源大小:14357k
文件大小:11k
源码类别:

DSP编程

开发平台:

C/C++

  1. /*
  2.  *  Copyright 2003 by Texas Instruments Incorporated.
  3.  *  All rights reserved. Property of Texas Instruments Incorporated.
  4.  *  Restricted rights to use, duplicate or disclose this code are
  5.  *  granted through contract.
  6.  *  
  7.  */
  8. /* "@(#) DDK 1.10.00.23 07-02-03 (ddk-b12)" */
  9. /*
  10.  *  ======== aic23.h ========
  11.  *
  12.  *  Header file for the AIC23 codec driver implementation specific to the 
  13.  *  Spectrum Digital EVM5509 board. It contains
  14.  *  control word bit-definition macros and declaration of public functions.
  15.  */
  16. #ifndef AIC23_
  17. #define AIC23_
  18. #include <std.h>
  19. #include <csl.h>
  20. /*
  21.  *  AIC23 Control registers
  22.  *  
  23.  *  There are 10 control registers (+the reset reg.) on AIC23, each 9 bits wide.
  24.  *  The address of a control register is 7 bits wide: together,
  25.  *  the address of a register and its content form a 16-bit control word,
  26.  *  the address occupying the uppermost 7 bits and the content lowermost 9.
  27.  */
  28. #define AIC23_NUMREGS 10
  29. #define AIC23_RESET   15
  30.  
  31. /*
  32.  *  A macro that let us define 9-bit register values as array of zeroes/ones
  33.  */
  34. #define AIC23_9BITWORD( b8, b7, b6, b5, b4, b3, b2, b1, b0 )              
  35.     ((Uns)( 1*(b0) +  2*(b1) +  4*(b2) +   8*(b3) +                       
  36.            16*(b4) + 32*(b5) + 64*(b6) + 128*(b7) + 256*(b8) ))
  37. #define AIC23_REG0_DEFAULT                                                
  38.     AIC23_9BITWORD(         /* REG 0: left input ch. volume control */    
  39.         0,                  /* simultaneous left/right volume: disabled*/ 
  40.         0,                  /* left line input mute: disabled */          
  41.         0,0,                /* reserved */                                
  42.         1,0,1,1,1           /* left line input volume: 0 dB */            
  43.     )                                                                     
  44. #define AIC23_REG1_DEFAULT                                                
  45.     AIC23_9BITWORD(         /* REG 1: right input ch. volume control*/    
  46.         0,                  /* simultaneous right/left volume: disabled*/ 
  47.         0,                  /* right line input mute: disabled */         
  48.         0,0,                /* reserved */                                
  49.         1,0,1,1,1           /* right line input volume: 0 dB */           
  50.     )                                                                     
  51. #define AIC23_REG2_DEFAULT                                                
  52.     AIC23_9BITWORD(         /* REG 2: left ch. headphone volume control*/ 
  53.         1,                  /* simultaneous left/right volume: enabled */ 
  54.         1,                  /* left channel zero-cross detect: enabled */ 
  55.         1,1,1,1,0,0,1       /* left headphone volume: 0 dB */             
  56.     )                                                                     
  57. #define AIC23_REG3_DEFAULT                                                
  58.     AIC23_9BITWORD(         /* REG 3: right ch. headphone volume ctrl */  
  59.         1,                  /* simultaneous right/left volume: enabled */ 
  60.         1,                  /* right channel zero-cross detect: enabled*/ 
  61.         1,1,1,1,0,0,1       /* right headphone volume: 0 dB */            
  62.     )                                                                     
  63. #define AIC23_REG4_DEFAULT                                                
  64.     AIC23_9BITWORD(         /* REG 4: analog audio path control */        
  65.         0,                  /* reserved */                                
  66.         0,0,                /* sidetone attenuation: 6 dB */              
  67.         0,                  /* sidetone: disabled */                      
  68.         1,                  /* DAC: selected */                           
  69.         0,                  /* bypass: off */                             
  70.         0,                  /* input select for ADC: line */              
  71.         0,                  /* microphone mute: disabled */               
  72.         1                   /* microphone boost: enabled */               
  73.     )                                                                     
  74. #define AIC23_REG5_DEFAULT                                                
  75.     AIC23_9BITWORD(         /* REG 5: digital audio path control */       
  76.         0,0,0,0,0,          /* reserved */                                
  77.         0,                  /* DAC soft mute: disabled */                 
  78.         0,0,                /* deemphasis control: 48khz */             
  79.         0                   /* ADC high-pass filter: disabled */          
  80.     )                                                                     
  81. #define AIC23_REG6_DEFAULT                                                
  82.     AIC23_9BITWORD(         /* REG 6: power down control */               
  83.         0,                  /* reserved */                                
  84.         0,                  /* device power: on (i.e. not off) */         
  85.         0,                  /* clock: on */                               
  86.         0,                  /* oscillator: on */                          
  87.         0,                  /* outputs: on */                             
  88.         0,                  /* DAC: on */                                 
  89.         0,                  /* ADC: on */                                 
  90.         0,                  /* microphone: on */                          
  91.         0                   /* line input: on */                          
  92.     )                                                                     
  93. #define AIC23_REG7_DEFAULT                                                
  94.     AIC23_9BITWORD(         /* REG 7: digital audio interf. format ctrl*/ 
  95.         0,0,                /* reserved */                                
  96.         1,                  /* master/slave mode: master */               
  97.         0,                  /* DEC left/right swap: disabled */           
  98.         0,                  /* no delay before transmitting MSB */        
  99.         0,0,                /* input bit length: 16 bit */                
  100.         1,1                 /* data format: DSP format */                 
  101.     )                                                                     
  102. #define AIC23_REG8_8KHZ                                                   
  103.     AIC23_9BITWORD(         /* REG 8: sample rate control */              
  104.         0,                  /* reserved */                                
  105.         0,                  /* clock output divider: 1 (MCLK) */        
  106.         0,                  /* clock input  divider: 1 (MCLK) */        
  107.         0,0,1,1,0,          /* sampling rate: ADC 8kHz DAC 8kHz */        
  108.         1                   /* clock mode select (USB/normal): USB */     
  109.     )                                                                     
  110. #define AIC23_REG8_32KHZ                                                  
  111.     AIC23_9BITWORD(         /* REG 8: sample rate control */              
  112.         0,                  /* reserved */                                
  113.         0,                  /* clock output divider: 1 (MCLK) */        
  114.         0,                  /* clock input  divider: 1 (MCLK) */        
  115.         0,1,1,0,0,          /* sampling rate: ADC 32kHz DAC 32kHz */      
  116.         1                   /* clock mode select (USB/normal): USB */     
  117.     )                                                                     
  118. #define AIC23_REG8_44_1KHZ                                                
  119.     AIC23_9BITWORD(         /* REG 8: sample rate control */              
  120.         0,                  /* reserved */                                
  121.         0,                  /* clock output divider: 1 (MCLK) */        
  122.         0,                  /* clock input  divider: 1 (MCLK) */        
  123.         1,0,0,0,1,          /* sampling rate: ADC 44.1kHz DAC 44.1kHz */  
  124.         1                   /* clock mode select (USB/normal): USB */     
  125.     )                                                                     
  126. #define AIC23_REG8_48KHZ                                                  
  127.     AIC23_9BITWORD(         /* REG 8: sample rate control */              
  128.         0,                  /* reserved */                                
  129.         0,                  /* clock output divider: 1 (MCLK) */        
  130.         0,                  /* clock input  divider: 1 (MCLK) */        
  131.         0,0,0,0,0,          /* sampling rate: ADC 48kHz DAC 48kHz */      
  132.         1                   /* clock mode select (USB/normal): USB */     
  133.     )                                                                     
  134. #define AIC23_REG8_96KHZ                                                  
  135.     AIC23_9BITWORD(         /* REG 8: sample rate control */              
  136.         0,                  /* reserved */                                
  137.         0,                  /* clock output divider: 1 (MCLK) */        
  138.         0,                  /* clock input  divider: 1 (MCLK) */        
  139.         0,1,1,1,0,          /* sampling rate: ADC 96kHz DAC 96kHz */      
  140.         1                   /* clock mode select (USB/normal): USB */     
  141.     )                                                                     
  142. #define AIC23_REG8_DEFAULT      AIC23_REG8_48KHZ
  143. #define AIC23_REG9_DEFAULT                                                
  144.     AIC23_9BITWORD(         /* REG 9: digital interface activation */     
  145.         0,0,0,0,0,0,0,0,    /* reserved */                                
  146.         1                   /* active */                                  
  147.     )                                                                     
  148. /*
  149.  *  Codec registers are kept in an object of the structure below.
  150.  */
  151. typedef struct AIC23_Params {
  152.     Uns regs[ AIC23_NUMREGS ];
  153. } AIC23_Params;
  154. /* 
  155.  *  define an AIC23_DEFAULTPARAMS with 10 default register values 
  156.  */
  157. #define AIC23_DEFAULTPARAMS {                                           
  158.     AIC23_REG0_DEFAULT,                                                 
  159.     AIC23_REG1_DEFAULT,                                                 
  160.     AIC23_REG2_DEFAULT,                                                 
  161.     AIC23_REG3_DEFAULT,                                                 
  162.     AIC23_REG4_DEFAULT,                                                 
  163.     AIC23_REG5_DEFAULT,                                                 
  164.     AIC23_REG6_DEFAULT,                                                 
  165.     AIC23_REG7_DEFAULT,                                                 
  166.     AIC23_REG8_DEFAULT,                                                 
  167.     AIC23_REG9_DEFAULT                                                  
  168. }
  169. /*
  170.  *  Declaration of public functions
  171.  */
  172. /*
  173.  *  ======== AIC23_init ========
  174.  *
  175.  *  Initializes codec module variables, if any. (There are none.)
  176.  */
  177. extern Void AIC23_init();
  178. /*
  179.  *  ======== AIC23_setParams ========
  180.  *
  181.  *  This function takes a pointer to the object of type AIC23_Params,
  182.  *  and writes all 11 control words found in it to the codec.
  183.  */
  184. extern Int AIC23_setParams(AIC23_Params *params);
  185. #endif