csl_i2s.h
Go to the documentation of this file.
00001 /*  ============================================================================
00002  *   Copyright (c) Texas Instruments Inc 2002, 2003, 2004, 2005, 2008
00003  *
00004  *   Use of this software is controlled by the terms and conditions found in the
00005  *   license agreement under which this software has been supplied.
00006  *  ============================================================================
00007  */
00008 
00016 /* ============================================================================
00017  * Revision History
00018  * ================
00019  * 22-Aug-2008 Created
00020  * ============================================================================
00021  */
00022 
00035 #ifndef _CSL_I2S_H_
00036 #define _CSL_I2S_H_
00037 
00038 
00039 #ifdef __cplusplus
00040 extern "C" {
00041 #endif
00042 
00043 #include "soc.h"
00044 #include "csl_error.h"
00045 #include "csl_types.h"
00046 #include "csl_general.h"
00047 
00073 /*****************************************************************************\
00074 *         I2S global macro declarations
00075 \*****************************************************************************/
00082 #define CSL_I2S_SCRL_ENABLE_DISABLE         (Uint16)0
00083 
00084 #define CSL_I2S_SCRL_ENABLE_ENABLE          (Uint16)1
00085 
00086 #define CSL_I2S_SCRL_MONO_DISABLE           (Uint16)0
00087 
00088 #define CSL_I2S_SCRL_MONO_ENABLE            (Uint16)1
00089 
00090 #define CSL_I2S_SCRL_LOOPBACK_DISABLE       (Uint16)0
00091 
00092 #define CSL_I2S_SCRL_LOOPBACK_ENABLE        (Uint16)1
00093 
00094 #define CSL_I2S_SCRL_FSPOL_DISABLE          (Uint16)0
00095 
00096 #define CSL_I2S_SCRL_FSPOL_ENABLE           (Uint16)1
00097 
00098 #define CSL_I2S_SCRL_CLOCKPOL_DISABLE       (Uint16)0
00099 
00100 #define CSL_I2S_SCRL_CLOCKPOL_ENABLE        (Uint16)1
00101 
00102 #define CSL_I2S_SCRL_DATADELAY_DISABLE      (Uint16)0
00103 
00104 #define CSL_I2S_SCRL_DATADELAY_ENABLE       (Uint16)1
00105 
00106 #define CSL_I2S_SCRL_PACK_DISABLE           (Uint16)0
00107 
00108 #define CSL_I2S_SCRL_PACK_ENABLE            (Uint16)1
00109 
00110 #define CSL_I2S_SCRL_SIGNEXT_DISABLE        (Uint16)0
00111 
00112 #define CSL_I2S_SCRL_SIGNEXT_ENABLE         (Uint16)1
00113 
00114 #define CSL_I2S_SCRL_WORDLENGTH_DISABLE     (Uint16)0
00115 
00116 #define CSL_I2S_SCRL_WORDLENGTH_ENABLE      (Uint16)1
00117 
00118 #define CSL_I2S_SCRL_MODE_DISABLE           (Uint16)0
00119 
00120 #define CSL_I2S_SCRL_MODE_ENABLE            (Uint16)1
00121 
00122 #define CSL_I2S_SCRL_FORMAT_DISABLE         (Uint16)0
00123 
00124 #define CSL_I2S_SCRL_FORMAT_ENABLE          (Uint16)1
00125 
00127 #define CSL_I2S_ICMRL_XMIT0_DISABLE         (Uint16)0
00128 
00129 #define CSL_I2S_ICMRL_XMIT0_ENABLE          (Uint16)1
00130 
00131 #define CSL_I2S_ICMRL_XMIT1_DISABLE         (Uint16)0
00132 
00133 #define CSL_I2S_ICMRL_XMIT1_ENABLE          (Uint16)1
00134 
00135 #define CSL_I2S_ICMRL_RCV0_DISABLE          (Uint16)0
00136 
00137 #define CSL_I2S_ICMRL_RCV0_ENABLE           (Uint16)1
00138 
00139 #define CSL_I2S_ICMRL_RCV1_DISABLE          (Uint16)0
00140 
00141 #define CSL_I2S_ICMRL_RCV1_ENABLE           (Uint16)1
00142 
00143 #define CSL_I2S_ICMRL_FERR_DISABLE          (Uint16)0
00144 
00145 #define CSL_I2S_ICMRL_FERR_ENABLE           (Uint16)1
00146 
00147 #define CSL_I2S_ICMRL_O_U_DISABLE           (Uint16)0
00148 
00149 #define CSL_I2S_ICMRL_O_U_ENABLE            (Uint16)1
00150 
00152 #define CSL_I2S_LATENCY_2                   (2)
00153 
00154 #define CSL_I2S_LATENCY_3                   (3)
00155 
00156 #define CSL_I2S_LATENCY_5                   (5)
00157 
00158 #define CSL_I2S_LATENCY_6                   (6)
00159 
00163 /**************************************************************************\
00164 * I2S global enum declaration                                             *
00165 \**************************************************************************/
00176 typedef enum
00177 {
00178      I2S_INSTANCE0,         
00179      I2S_INSTANCE1,         
00180      I2S_INSTANCE2,         
00181      I2S_INSTANCE3,         
00182      I2S_INVALID            
00183 } I2S_Instance;
00184 
00190 typedef enum
00191 {
00192     I2S_CHAN_MONO,          
00193     I2S_CHAN_STEREO,        
00194     I2S_CHAN_UNDEF          
00195 } I2S_ChanType;
00196 
00202 typedef enum
00203 {
00204     I2S_POLLED,             
00205     I2S_INTERRUPT,          
00206     DMA_POLLED,             
00207     DMA_INTERRUPT,          
00208     I2S_OPMODE_OTHER        
00209 }I2S_OpMode;
00210 
00211 
00217 typedef enum
00218 {
00219     I2S_LOOPBACK_DISABLE,   
00220     I2S_LOOPBACK_ENABLE     
00221 }I2S_LoopbackType;
00222 
00223 
00229 typedef enum
00230 {
00231     I2S_SERIAL_DISABLE,     
00232     I2S_SERIAL_ENABLE       
00233 }I2S_SerialEna;
00234 
00240 typedef enum
00241 {
00242     I2S_STEREO_ENABLE ,      
00243     I2S_MONO_ENABLE          
00244 } I2S_MonoType;
00245 
00251 typedef enum
00252 {
00253     I2S_FSPOL_LOW,          
00254     I2S_FSPOL_HIGH          
00255 }I2S_FsyncPol;
00256 
00262 typedef enum
00263 {
00264     I2S_RISING_EDGE,        
00265     I2S_FALLING_EDGE        
00266 }I2S_ClkPol;
00267 
00273 typedef enum
00274 {
00275     I2S_DATADELAY_ONEBIT,   
00276     I2S_DATADELAY_TWOBIT    
00277 } I2S_DataDelay;
00278 
00284 typedef enum
00285 {
00286     I2S_DATAPACK_DISABLE,   
00287     I2S_DATAPACK_ENABLE     
00288 } I2S_DatapackType;
00289 
00295 typedef enum
00296 {
00297     I2S_SIGNEXT_DISABLE,    
00298     I2S_SIGNEXT_ENABLE      
00299 } I2S_SignextType;
00300 
00306 typedef enum
00307 {
00308     I2S_WORDLEN_8,          
00309     I2S_WORDLEN_10,         
00310     I2S_WORDLEN_12,         
00311     I2S_WORDLEN_14,         
00312     I2S_WORDLEN_16,         
00313     I2S_WORDLEN_18,         
00314     I2S_WORDLEN_20,         
00315     I2S_WORDLEN_24,         
00316     I2S_WORDLEN_32,         
00317     I2S_WORDLEN_INVALID     
00318 } I2S_WordLen;
00319 
00325 typedef enum
00326 {
00327     I2S_SLAVE,              
00328     I2S_MASTER              
00329 } I2S_Mode;
00330 
00336 typedef enum
00337 {
00338     I2S_DATAFORMAT_LJUST,   
00339     I2S_DATAFORMAT_DSP      
00340 } I2S_DataFormat;
00341 
00348 typedef enum
00349 {
00350     I2S_FSDIV8,             
00351     I2S_FSDIV16,            
00352     I2S_FSDIV32,            
00353     I2S_FSDIV64,            
00354     I2S_FSDIV128,           
00355     I2S_FSDIV256,           
00356     I2S_FSDIV_RESERVE       
00357 } I2S_Fsdiv;
00358 
00365 typedef enum
00366 {
00367     I2S_CLKDIV2,            
00368     I2S_CLKDIV4,            
00369     I2S_CLKDIV8,            
00370     I2S_CLKDIV16,           
00371     I2S_CLKDIV32,           
00372     I2S_CLKDIV64,           
00373     I2S_CLKDIV128,          
00374     I2S_CLKDIV256           
00375 } I2S_Clkdiv;
00376 
00377 
00385 typedef enum
00386 {
00387     I2S_FSERROR_DISABLE,    
00388     I2S_FSERROR_ENABLE      
00389 } I2S_FsErr;
00390 
00397 typedef enum
00398 {
00399     I2S_OUERROR_DISABLE,    
00400     I2S_OUERROR_ENABLE      
00401 } I2S_OuErr;
00402 
00407 /**************************************************************************\
00408 *               I2S global data structures                                *
00409 \**************************************************************************/
00420 typedef struct {
00421     I2S_Instance          i2sNum;       
00422     I2S_OpMode            opMode;       
00423     I2S_ChanType          chType;       
00424     ioport CSL_I2sRegs    *hwRegs;      
00425     Uint16                configured;   
00426     I2S_DatapackType      datapack;     
00427     I2S_Fsdiv             fsDiv;        
00428     I2S_WordLen           wordLen;      
00429     I2S_LoopbackType      loopBackMode; 
00430     Bool                  firstRead;    
00431 }CSL_I2sObj;
00432 
00433 
00439 typedef struct{
00440     I2S_MonoType        dataType;       
00441     I2S_LoopbackType    loopBackMode;   
00442     I2S_FsyncPol        fsPol;          
00443     I2S_ClkPol          clkPol;         
00444     I2S_DataDelay       datadelay;      
00445     I2S_DatapackType    datapack;       
00446     I2S_SignextType     signext;        
00447     I2S_WordLen         wordLen;        
00448     I2S_Mode            i2sMode;        
00449     I2S_DataFormat      dataFormat;     
00450     I2S_Fsdiv           fsDiv;          
00451     I2S_Clkdiv          clkDiv;         
00452     I2S_FsErr           FError;         
00453     I2S_OuErr           OuError;        
00454 }I2S_Config;
00455 
00461 typedef CSL_I2sObj *CSL_I2sHandle;
00462 
00472 /*****************************************************************************\
00473  * I2S function declarations                                                  *
00474 \*****************************************************************************/
00475 
00526 CSL_I2sHandle I2S_open(I2S_Instance     i2sInstNum,
00527                        I2S_OpMode       opMode,
00528                        I2S_ChanType     chType);
00529 
00573 CSL_Status I2S_setup(CSL_I2sHandle  i2sHandle,
00574                     I2S_Config      *i2sHwConfig);
00575 
00610 CSL_Status I2S_close(CSL_I2sHandle  i2sHandle);
00611 
00654 CSL_Status I2S_read (CSL_I2sHandle  i2sHandle,
00655                     Uint16 *readBuff, Uint16 buffLen);
00656 
00694 CSL_Status I2S_write(CSL_I2sHandle  i2sHandle,
00695                     Uint16 *writeBuff, Uint16 buffLen);
00696 
00730 CSL_Status I2S_reset(CSL_I2sHandle  hI2S);
00731 
00767 CSL_Status I2S_transEnable(CSL_I2sHandle    i2sHandle, Uint16 enableBit);
00772 /*****************************************************************************\
00773  * I2S Global variable                                                   *
00774 \*****************************************************************************/
00777 static CSL_I2sObj I2S_InstanceNum[4];
00783 #ifdef __cplusplus
00784 }
00785 #endif
00786 #endif /* _CSL_I2S_H_ */
00787 
00788 
00789 
00790