SAMV71 Xplained Ultra Software Package 1.5

wm8904.c

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