SAMV71 Xplained Ultra Software Package 1.3

wm8904.c

Go to the documentation of this file.
00001 /* ----------------------------------------------------------------------------
00002  *         SAM Software Package License 
00003  * ----------------------------------------------------------------------------
00004  * Copyright (c) 2014, Atmel Corporation
00005  *
00006  * All rights reserved.
00007  *
00008  * Redistribution and use in source and binary forms, with or without
00009  * modification, are permitted provided that the following conditions are met:
00010  *
00011  * - Redistributions of source code must retain the above copyright notice,
00012  * this list of conditions and the disclaimer below.
00013  *
00014  * Atmel's name may not be used to endorse or promote products derived from
00015  * this software without specific prior written permission.
00016  *
00017  * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
00018  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
00019  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
00020  * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
00021  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00022  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
00023  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00024  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00025  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
00026  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00027  * ----------------------------------------------------------------------------
00028  */
00029 
00030 /**
00031  * \file
00032  *
00033  * Implementation WM8904 driver.
00034  *
00035  */
00036 
00037 /*----------------------------------------------------------------------------
00038  *        Headers
00039  *----------------------------------------------------------------------------*/
00040 
00041 #include "board.h"
00042 
00043 /*----------------------------------------------------------------------------
00044  *        Type
00045  *----------------------------------------------------------------------------*/
00046 typedef struct {
00047                 uint16_t value;
00048                 uint8_t address;
00049         }WM8904_PARA;
00050 
00051 /*----------------------------------------------------------------------------
00052  *        Exported functions
00053  *----------------------------------------------------------------------------*/
00054 /**
00055  * \brief Read data from WM8904 Register.
00056  *
00057  * \param pTwid   Pointer to twi driver structure
00058  * \param device  Twi slave address.
00059  * \param regAddr Register address to read.
00060  * \return value in the given register.
00061  */
00062 uint16_t WM8904_Read(Twid *pTwid,
00063         uint32_t device,
00064         uint32_t regAddr)
00065 {
00066     uint16_t bitsDataRegister;
00067     uint8_t Tdata[2]={0,0};
00068 
00069     TWID_Read(pTwid, device, regAddr, 1, Tdata, 2, 0);
00070     bitsDataRegister = (Tdata[0] << 8) | Tdata[1];
00071     return bitsDataRegister;
00072 }
00073 
00074 /**
00075  * \brief  Write data to WM8904 Register.
00076  *
00077  * \param pTwid   Pointer to twi driver structure
00078  * \param device  Twi slave address.
00079  * \param regAddr Register address to read.
00080  * \param data    Data to write
00081  */
00082 void WM8904_Write(Twid *pTwid,
00083         uint32_t device,
00084         uint32_t regAddr,
00085         uint16_t data)
00086 {
00087     uint8_t tmpData[2];
00088 
00089     tmpData[0] = (data & 0xff00) >> 8;
00090     tmpData[1] = data & 0xff;
00091     TWID_Write(pTwid, device, regAddr, 1, tmpData, 2, 0);
00092 }
00093 
00094 static WM8904_PARA wm8904_access_slow[]=
00095 { 
00096     { 0x0000, 0},         /** R0   - SW Reset and ID */ 
00097     { 0x001A, 4},         /** R4   - Bias Control 0 */ 
00098     { 0x0047, 5},         /** R5   - VMID Control 0 */     /*insert_delay_ms 5*/
00099 
00100     { 0x0043, 5},         /** R5   - VMID Control 0 */ 
00101     { 0x000B, 4},         /** R4   - Bias Control 0 */ 
00102 
00103     { 0x0003, 0x0C},      /** R12  - Power Management 0 CC */ 
00104 
00105     { 0x0003, 0x0E},      /** R14  - Power Management 2 */ 
00106     { 0x000C, 0x12},      /** R18  - Power Management 6 */
00107     { 0x0000, 0x21},      /** R33  - DAC Digital 1 */ 
00108     { 0x0000, 0x3D},      /** R61  - Analogue OUT12 ZC */ 
00109     { 0x0001, 0x62},      /** R98  - Charge Pump 0 */ 
00110     { 0x0005, 0x68},     /** R104 - Class W 0 */ 
00111 
00112     //FLL setting,32.768KHZ MCLK input,12.288M output.
00113     { 0x0000, 0x74},     /** R116 - FLL Control 1 */ 
00114     { 0x0704, 0x75},     /** R117 - FLL Control 2 */ 
00115     { 0x8000, 0x76},     /** R118 - FLL Control 3 */ 
00116     { 0x1760, 0x77},     /** R119 - FLL Control 4 */ 
00117     { 0x0005, 0x74},     /** R116 - FLL Control 1 */     /*insert_delay_ms 5*/
00118 
00119     { 0x0C05, 0x15},      /** R21  - Clock Rates 1 */ 
00120     { 0x845E, 0x14},      /** R20  - Clock Rates 0 */     
00121     { 0x4006, 0x16},      /** R22  - Clock Rates 2 */
00122 
00123     //WM8904 IIS master
00124     //BCLK=12.288MHz/8=1.536MHz
00125     //LRCK=1.536MHz/32=48KHz
00126     //{ 0x0042, 0x18},    /** R24  - Audio Interface 0 */ 
00127     { 0x0042, 0x19},      /** R25  - Audio Interface 1 */ 
00128     { 0x00E8, 0x1A},      /** R26  - Audio Interface 2 */ 
00129     { 0x0820, 0x1B},      /** R27  - Audio Interface 3 */ 
00130     ////////////////ADC
00131 
00132     { 0x0003, 0x0C},      /** R12  - Power Management 0 */ 
00133     { 0x000F, 0x12},      /** R18  - Power Management 6 */     /*insert_delay_ms 5*/
00134 
00135     { 0x0010, 0x2C},      /** R44  - Analogue Left Input 0 */ 
00136     { 0x0010, 0x2D},      /** R45  - Analogue Right Input 0 */ 
00137     { 0x0044, 0x2E},      /** R46  - Analogue Left Input 1 */ 
00138     { 0x0044, 0x2F},      /** R47  - Analogue Right Input 1 */
00139 
00140     { 0x0011, 0x5A},      /** R90  - Analogue HP 0 */ 
00141     { 0x0033, 0x5A},      /** R90  - Analogue HP 0 */ 
00142 
00143     { 0x000F, 0x43},      /** R67  - DC Servo 0 */ 
00144     { 0x00F0, 0x44},      /** R68  - DC Servo 1 */     /*insert_delay_ms 100*/
00145 
00146     { 0x0077, 0x5A},      /** R90  - Analogue HP 0 */ 
00147     { 0x00FF, 0x5A},      /** R90  - Analogue HP 0 */ 
00148     { 0x00B9, 0x39},      /** R57  - Analogue OUT1 Left */ 
00149     { 0x00B9, 0x3A},      /** R58  - Analogue OUT1 Right */  
00150 };
00151 
00152 static WM8904_PARA wm8904_access_main[] = 
00153 { 
00154     //{ 0x8904, 0}, /** R0   - SW Reset and ID */ 
00155     //{ 0x0000, 1}, /** R1   - Revision */ 
00156     //{ 0x0000, 2}, /** R2 */ 
00157     //{ 0x0000, 3}, /** R3 */ 
00158     { 0x0019, 4},   /** R4   - Bias Control 0 */ 
00159     { 0x0043, 5},   /** R5   - VMID Control 0 */ 
00160     //{ 0x0003, 6},   /** R6   - Mic Bias Control 0 */ 
00161     //{ 0xC000, 7},   /** R7   - Mic Bias Control 1 */ 
00162     //{ 0x001E, 8},   /** R8   - Analogue DAC 0 */ 
00163     //{ 0xFFFF, 9},   /** R9   - mic Filter Control */ 
00164     //{ 0x0001, 10},  /** R10  - Analogue ADC 0 */ 
00165     //{ 0x0000, 11},  /** R11 */ 
00166     { 0x0003, 12},  /** R12  - Power Management 0 */ 
00167     //{ 0x0000, 13},  /** R13 */ 
00168     { 0x0003, 14},  /** R14  - Power Management 2 */ 
00169     //{ 0x0003, 15},  /** R15  - Power Management 3 */ 
00170     //{ 0x0000, 16},  /** R16 */ 
00171     //{ 0x0000, 17},  /** R17 */ 
00172     { 0x000F, 18},  /** R18  - Power Management 6 */ 
00173     //{ 0x0000, 19},  /** R19 */ 
00174     { 0x845E, 20},  /** R20  - Clock Rates 0 */ 
00175     //{ 0x3C07, 21},  /** R21  - Clock Rates 1 */ 
00176     { 0x0006, 22},  /** R22  - Clock Rates 2 */ 
00177     //{ 0x0000, 23},  /** R23 */ 
00178     //{ 0x1FFF, 24},  /** R24  - Audio Interface 0 */ 
00179     { 0x404A, 25},  /** R25  - Audio Interface 1 */ 
00180     //{ 0x0004, 26},  /** R26  - Audio Interface 2 */ 
00181     { 0x0840, 27},  /** R27  - Audio Interface 3 */ 
00182     //{ 0x0000, 28},  /** R28 */ 
00183     //{ 0x0000, 29},  /** R29 */ 
00184     //{ 0x00FF, 30},  /** R30  - DAC Digital Volume Left */ 
00185     //{ 0x00FF, 31},  /** R31  - DAC Digital Volume Right */ 
00186     //{ 0x0FFF, 32},  /** R32  - DAC Digital 0 */ 
00187     { 0x0000, 33},  /** R33  - DAC Digital 1 */ 
00188     //{ 0x0000, 34},  /** R34 */ 
00189     //{ 0x0000, 35},  /** R35 */ 
00190     //{ 0x00FF, 36},  /** R36  - ADC Digital Volume Left */ 
00191     //{ 0x00FF, 37},  /** R37  - ADC Digital Volume Right */ 
00192     //{ 0x0073, 38},  /** R38  - ADC Digital 0 */ 
00193     //{ 0x1800, 39},  /** R39  - Digital Microphone 0 */ 
00194     //{ 0xDFEF, 40},  /** R40  - DRC 0 */ 
00195     //{ 0xFFFF, 41},  /** R41  - DRC 1 */ 
00196     //{ 0x003F, 42},  /** R42  - DRC 2 */ 
00197     //{ 0x07FF, 43},  /** R43  - DRC 3 */ 
00198     { 0x0005, 44},  /** R44  - Analogue Left Input 0 */ 
00199     { 0x0005, 45},  /** R45  - Analogue Right Input 0 */ 
00200     { 0x0000, 46},  /** R46  - Analogue Left Input 1 */ 
00201     { 0x0000, 47},  /** R47  - Analogue Right Input 1 */ 
00202     //{ 0x0000, 48},  /** R48 */ 
00203     //{ 0x0000, 49},  /** R49 */ 
00204     //{ 0x0000, 50},  /** R50 */ 
00205     //{ 0x0000, 51},  /** R51 */ 
00206     //{ 0x0000, 52},  /** R52 */ 
00207     //{ 0x0000, 53},  /** R53 */ 
00208     //{ 0x0000, 54},  /** R54 */ 
00209     //{ 0x0000, 55},  /** R55 */ 
00210     //{ 0x0000, 56},  /** R56 */ 
00211     //{ 0x017F, 57},  /** R57  - Analogue OUT1 Left */ 
00212     { 0x00AD, 58},  /** R58  - Analogue OUT1 Right */ 
00213     //{ 0x017F, 59},  /** R59  - Analogue OUT2 Left */ 
00214     //{ 0x017F, 60},  /** R60  - Analogue OUT2 Right */ 
00215     //{ 0x000F, 61},  /** R61  - Analogue OUT12 ZC */ 
00216     //{ 0x0000, 62},  /** R62 */ 
00217     //{ 0x0000, 63},  /** R63 */ 
00218     //{ 0x0000, 64},  /** R64 */ 
00219     //{ 0x0000, 65},  /** R65 */ 
00220     //{ 0x0000, 66},  /** R66 */ 
00221     { 0x0003, 67},  /** R67  - DC Servo 0 */ 
00222     //{ 0xFFFF, 68},  /** R68  - DC Servo 1 */ 
00223     //{ 0x0F0F, 69},  /** R69  - DC Servo 2 */ 
00224     //{ 0x0000, 70},  /** R70 */ 
00225     //{ 0x007F, 71},  /** R71  - DC Servo 4 */ 
00226     //{ 0x007F, 72},  /** R72  - DC Servo 5 */ 
00227     //{ 0x00FF, 73},  /** R73  - DC Servo 6 */ 
00228     //{ 0x00FF, 74},  /** R74  - DC Servo 7 */ 
00229     //{ 0x00FF, 75},  /** R75  - DC Servo 8 */ 
00230     //{ 0x00FF, 76},  /** R76  - DC Servo 9 */ 
00231     //{ 0x0FFF, 77},  /** R77  - DC Servo Readback 0 */ 
00232     //{ 0x0000, 78},  /** R78 */ 
00233     //{ 0x0000, 79},  /** R79 */ 
00234     //{ 0x0000, 80},  /** R80 */ 
00235     //{ 0x0000, 81},  /** R81 */ 
00236     //{ 0x0000, 82},  /** R82 */ 
00237     //{ 0x0000, 83},  /** R83 */ 
00238     //{ 0x0000, 84},  /** R84 */ 
00239     //{ 0x0000, 85},  /** R85 */ 
00240     //{ 0x0000, 86},  /** R86 */ 
00241     //{ 0x0000, 87},  /** R87 */ 
00242     //{ 0x0000, 88},  /** R88 */ 
00243     //{ 0x0000, 89},  /** R89 */ 
00244     { 0x00FF, 90},  /** R90  - Analogue HP 0 */ 
00245     //{ 0x0000, 91},  /** R91 */ 
00246     //{ 0x0000, 92},  /** R92 */ 
00247     //{ 0x0000, 93},  /** R93 */ 
00248     //{ 0x00FF, 94},  /** R94  - Analogue Lineout 0 */ 
00249     //{ 0x0000, 95},  /** R95 */ 
00250     //{ 0x0000, 96},  /** R96 */ 
00251     //{ 0x0000, 97},  /** R97 */ 
00252     { 0x0001, 98},  /** R98  - Charge Pump 0 */ 
00253     //{ 0x0000, 99},  /** R99 */ 
00254     //{ 0x0000, 100}, /** R100 */
00255     //{ 0x0000, 101}, /** R101 */ 
00256     //{ 0x0000, 102}, /** R102 */ 
00257     //{ 0x0000, 103}, /** R103 */ 
00258     { 0x0005, 104}, /** R104 - Class W 0 */ 
00259     //{ 0x0000, 105}, /** R105 */ 
00260     //{ 0x0000, 106}, /** R106 */ 
00261     //{ 0x0000, 107}, /** R107 */ 
00262     //{ 0x011F, 108}, /** R108 - Write Sequencer 0 */ 
00263     //{ 0x7FFF, 109}, /** R109 - Write Sequencer 1 */ 
00264     //{ 0x4FFF, 110}, /** R110 - Write Sequencer 2 */ 
00265     //{ 0x003F, 111}, /** R111 - Write Sequencer 3 */ 
00266     //{ 0x03F1, 112}, /** R112 - Write Sequencer 4 */ 
00267     //{ 0x0000, 113}, /** R113 */ 
00268     //{ 0x0000, 114}, /** R114 */ 
00269     //{ 0x0000, 115}, /** R115 */ 
00270     { 0x0004, 116}, /** R116 - FLL Control 1 */ 
00271     { 0x0704, 117}, /** R117 - FLL Control 2 */ 
00272     { 0x8000, 118}, /** R118 - FLL Control 3 */ 
00273     { 0x1760, 119}, /** R119 - FLL Control 4 */ 
00274     //{ 0x001B, 120}, /** R120 - FLL Control 5 */ 
00275     //{ 0x0014, 121}, /** R121 - GPIO Control 1 */ 
00276     //{ 0x0010, 122}, /** R122 - GPIO Control 2 */ 
00277     //{ 0x0010, 123}, /** R123 - GPIO Control 3 */ 
00278     //{ 0x0000, 124}, /** R124 - GPIO Control 4 */ 
00279     //{ 0x0000, 125}, /** R125 */ 
00280     //{ 0x000A, 126}, /** R126 - Digital Pulls */ 
00281     //{ 0x07FF, 127}, /** R127 - Interrupt Status */ 
00282     //{ 0x03FF, 128}, /** R128 - Interrupt Status Mask */ 
00283     //{ 0x03FF, 129}, /** R129 - Interrupt Polarity */ 
00284     //{ 0x03FF, 130}, /** R130 - Interrupt Debounce */
00285     //{ 0x0000, 131}, /** R131 */ 
00286     //{ 0x0000, 132}, /** R132 */ 
00287     //{ 0x0000, 133}, /** R133 */ 
00288     //{ 0x0001, 134}, /** R134 - EQ1 */ 
00289     //{ 0x001F, 135}, /** R135 - EQ2 */ 
00290     //{ 0x001F, 136}, /** R136 - EQ3 */ 
00291     //{ 0x001F, 137}, /** R137 - EQ4 */ 
00292     //{ 0x001F, 138}, /** R138 - EQ5 */ 
00293     //{ 0x001F, 139}, /** R139 - EQ6 */ 
00294     //{ 0xFFFF, 140}, /** R140 - EQ7 */ 
00295     //{ 0xFFFF, 141}, /** R141 - EQ8 */ 
00296     //{ 0xFFFF, 142}, /** R142 - EQ9 */ 
00297     //{ 0xFFFF, 143}, /** R143 - EQ10 */ 
00298     //{ 0xFFFF, 144}, /** R144 - EQ11 */ 
00299     //{ 0xFFFF, 145}, /** R145 - EQ12 */ 
00300     //{ 0xFFFF, 146}, /** R146 - EQ13 */ 
00301     //{ 0xFFFF, 147}, /** R147 - EQ14 */ 
00302     //{ 0xFFFF, 148}, /** R148 - EQ15 */ 
00303     //{ 0xFFFF, 149}, /** R149 - EQ16 */ 
00304     //{ 0xFFFF, 150}, /** R150 - EQ17 */ 
00305     //{ 0xFFFF, 151}, /** R151wm8523_dai - EQ18 */ 
00306     //{ 0xFFFF, 152}, /** R152 - EQ19 */ 
00307     //{ 0xFFFF, 153}, /** R153 - EQ20 */ 
00308     //{ 0xFFFF, 154}, /** R154 - EQ21 */ 
00309     //{ 0xFFFF, 155}, /** R155 - EQ22 */ 
00310     //{ 0xFFFF, 156}, /** R156 - EQ23 */ 
00311     //{ 0xFFFF, 157}, /** R157 - EQ24 */ 
00312     //{ 0x0000, 158}, /** R158 */ 
00313     //{ 0x0000, 159}, /** R159 */ 
00314     //{ 0x0000, 160}, /** R160 */ 
00315     //{ 0x0002, 161}, /** R161 - Control Interface Test 1 */ 
00316     //{ 0x0000, 162}, /** R162 */ 
00317     //{ 0x0000, 163}, /** R163 */ 
00318     //{ 0x0000, 164}, /** R164 */ 
00319     //{ 0x0000, 165}, /** R165 */ 
00320     //{ 0x0000, 166}, /** R166 */ 
00321     //{ 0x0000, 167}, /** R167 */ 
00322     //{ 0x0000, 168}, /** R168 */ 
00323     //{ 0x0000, 169}, /** R169 */ 
00324     //{ 0x0000, 170}, /** R170 */ 
00325     //{ 0x0000, 171}, /** R171 */ 
00326     //{ 0x0000, 172}, /** R172 */ 
00327     //{ 0x0000, 173}, /** R173 */ 
00328     //{ 0x0000, 174}, /** R174 */ 
00329     //{ 0x0000, 175}, /** R175 */ 
00330     //{ 0x0000, 176}, /** R176 */ 
00331     //{ 0x0000, 177}, /** R177 */ 
00332     //{ 0x0000, 178}, /** R178 */ 
00333     //{ 0x0000, 179}, /** R179 */ 
00334     //{ 0x0000, 180}, /** R180 */ 
00335     //{ 0x0000, 181}, /** R181 */ 
00336     //{ 0x0000, 182}, /** R182 */ 
00337     //{ 0x0000, 183}, /** R183 */ 
00338     //{ 0x0000, 184}, /** R184 */ 
00339     //{ 0x0000, 185}, /** R185 */ 
00340     //{ 0x0000, 186}, /** R186 */ 
00341     //{ 0x0000, 187}, /** R187 */ 
00342     //{ 0x0000, 188}, /** R188 */ 
00343     //{ 0x0000, 189}, /** R189 */ 
00344     //{ 0x0000, 190}, /** R190 */ 
00345     //{ 0x0000, 191}, /** R191 */ 
00346     //{ 0x0000, 192}, /** R192 */ 
00347     //{ 0x0000, 193}, /** R193 */ 
00348     //{ 0x0000, 194}, /** R194 */ 
00349     //{ 0x0000, 195}, /** R195 */ 
00350     //{ 0x0000, 196}, /** R196 */ 
00351     //{ 0x0000, 197}, /** R197 */ 
00352     //{ 0x0000, 198}, /** R198 */ 
00353     //{ 0x0000, 199}, /** R199 */ 
00354     //{ 0x0000, 200}, /** R200 */ 
00355     //{ 0x0000, 201}, /** R201 */ 
00356     //{ 0x0000, 202}, /** R202 */ 
00357     //{ 0x0000, 203}, /** R203 */ 
00358     //{ 0x0070, 204}, /** R204 - Analogue Output Bias 0 */ 
00359     //{ 0x0000, 205}, /** R205 */ 
00360     //{ 0x0000, 206}, /** R206 */ 
00361     //{ 0x0000, 207}, /** R207 */ 
00362     //{ 0x0000, 208}, /** R208 */ 
00363     //{ 0x0000, 209}, /** R209 */ 
00364     //{ 0x0000, 210}, /** R210 */ 
00365     //{ 0x0000, 211}, /** R211 */ 
00366     //{ 0x0000, 212}, /** R212 */ 
00367     //{ 0x0000, 213}, /** R213 */ 
00368     //{ 0x0000, 214}, /** R214 */ 
00369     //{ 0x0000, 215}, /** R215 */ 
00370     //{ 0x0000, 216}, /** R216 */ 
00371     //{ 0x0000, 217}, /** R217 */ 
00372     //{ 0x0000, 218}, /** R218 */ 
00373     //{ 0x0000, 219}, /** R219 */ 
00374     //{ 0x0000, 220}, /** R220 */ 
00375     //{ 0x0000, 221}, /** R221 */ 
00376     //{ 0x0000, 222}, /** R222 */ 
00377     //{ 0x0000, 223}, /** R223 */ 
00378     //{ 0x0000, 224}, /** R224 */ 
00379     //{ 0x0000, 225}, /** R225 */ 
00380     //{ 0x0000, 226}, /** R226 */ 
00381     //{ 0x0000, 227}, /** R227 */ 
00382     //{ 0x0000, 228}, /** R228 */ 
00383     //{ 0x0000, 229}, /** R229 */ 
00384     //{ 0x0000, 230}, /** R230 */ 
00385     //{ 0x0000, 231}, /** R231 */ 
00386     //{ 0x0000, 232}, /** R232 */ 
00387     //{ 0x0000, 233}, /** R233 */ 
00388     //{ 0x0000, 234}, /** R234 */ 
00389     //{ 0x0000, 235}, /** R235 */ 
00390     //{ 0x0000, 236}, /** R236 */ 
00391     //{ 0x0000, 237}, /** R237 */ 
00392     //{ 0x0000, 238}, /** R238 */ 
00393     //{ 0x0000, 239}, /** R239 */ 
00394     //{ 0x0000, 240}, /** R240 */ 
00395     //{ 0x0000, 241}, /** R241 */ 
00396     //{ 0x0000, 242}, /** R242 */ 
00397     //{ 0x0000, 243}, /** R243 */ 
00398     //{ 0x0000, 244}, /** R244 */ 
00399     //{ 0x0000, 245}, /** R245 */ 
00400     //{ 0x0000, 246}, /** R246 */ 
00401     //{ 0x0000, 247}, /** R247 - FLL NCO Test 0 */ 
00402     //{ 0x0019, 248}, /** R248 - FLL NCO Test 1 */ 
00403     { 0x55AA, 255}  /** end */ 
00404 };
00405 
00406 uint8_t WM8904_Init(Twid *pTwid, uint32_t device,  uint32_t PCK)
00407 {
00408     uint8_t count, size;
00409     uint16_t data = 0;
00410 
00411     // Reset (write Reg@0x0 to reset)
00412     WM8904_Write(pTwid, device, 0, 0xFFFF);
00413 
00414     for(data=0;data<1000;data++);
00415     //wait ready    
00416     while(data!=0x8904)
00417         data=WM8904_Read(pTwid, device, 0);
00418 
00419     if (PMC_MCKR_CSS_SLOW_CLK == PCK) {
00420         size = sizeof(wm8904_access_slow) / 4 + 1;
00421         for(count=0; count<size; count++) {
00422             WM8904_Write(pTwid, device, wm8904_access_slow[count].address,
00423                             wm8904_access_slow[count].value);
00424             if(((wm8904_access_slow[count].address==0x05)
00425                             &&(wm8904_access_slow[count].value==0x0047))
00426                     ||((wm8904_access_slow[count].address==0x74)
00427                             &&(wm8904_access_slow[count].value==0x0005))
00428                     ||((wm8904_access_slow[count].address==0x12)
00429                             &&(wm8904_access_slow[count].value==0x000F))) {
00430                 Wait(5);
00431             }
00432             if (((wm8904_access_slow[count].address==0x44)
00433                             &&(wm8904_access_slow[count].value==0x00F0))
00434                     ||((wm8904_access_slow[count].address==0x3A)
00435                             &&(wm8904_access_slow[count].value==0x00B9))) {
00436                 Wait(100);
00437             }
00438         } 
00439     }
00440     else if (PMC_MCKR_CSS_MAIN_CLK == PCK) {
00441         for(count = 0; count < 255; count++) {
00442             if(wm8904_access_main[count].address < 255) {
00443                 WM8904_Write(pTwid, device, wm8904_access_main[count].address, 
00444                                 wm8904_access_main[count].value);
00445             } else {
00446                 break;
00447             }
00448         }
00449     } else {
00450         printf("W: PCK not supported! \n\r");
00451         while(1);
00452     }
00453     return 0;
00454 }
00455 
00456 void WM8904_IN2R_IN1L(Twid *pTwid, uint32_t device)
00457 {
00458     //{ 0x0005, 44},  /** R44  - Analogue Left Input 0 */ 
00459     //{ 0x0005, 45},  /** R45  - Analogue Right Input 0 */ 
00460     //{ 0x0000, 46},  /** R46  - Analogue Left Input 1 */ 
00461     //{ 0x0010, 47},  /** R47  - Analogue Right Input 1 */
00462     WM8904_Write(pTwid, device, 0x2C, 0x0008);
00463     WM8904_Write(pTwid, device, 0x2D, 0x0005);
00464     WM8904_Write(pTwid, device, 0x2E, 0x0000);
00465     WM8904_Write(pTwid, device, 0x2F, 0x0010);
00466 }
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines