LPCOpen Platform for LPC112X microcontrollers  112X
LPCOpen Platform for the NXP LPC112X family of Microcontrollers
wm8904.h
Go to the documentation of this file.
1 /*
2  * @brief WM894 Audio Codec header
3  *
4  * @note
5  * Copyright(C) NXP Semiconductors, 2012
6  * All rights reserved.
7  *
8  * @par
9  * Software that is described herein is for illustrative purposes only
10  * which provides customers with programming information regarding the
11  * LPC products. This software is supplied "AS IS" without any warranties of
12  * any kind, and NXP Semiconductors and its licensor disclaim any and
13  * all warranties, express or implied, including all implied warranties of
14  * merchantability, fitness for a particular purpose and non-infringement of
15  * intellectual property rights. NXP Semiconductors assumes no responsibility
16  * or liability for the use of the software, conveys no license or rights under any
17  * patent, copyright, mask work right, or any other intellectual property rights in
18  * or to any products. NXP Semiconductors reserves the right to make changes
19  * in the software without notification. NXP Semiconductors also makes no
20  * representation or warranty that such application will be suitable for the
21  * specified use without further testing or modification.
22  *
23  * @par
24  * Permission to use, copy, modify, and distribute this software and its
25  * documentation is hereby granted, under NXP Semiconductors' and its
26  * licensor's relevant copyrights in the software, without fee, provided that it
27  * is used in conjunction with NXP Semiconductors microcontrollers. This
28  * copyright, permission, and disclaimer notice must appear in all copies of
29  * this code.
30  */
31 
32 #ifndef _WM8904_H
33 #define _WM8904_H
34 
49 #define WM8904_CLK_MCLK 1
50 #define WM8904_CLK_FLL 2
51 
52 #define WM8904_FLL_MCLK 1
53 #define WM8904_FLL_BCLK 2
54 #define WM8904_FLL_LRCLK 3
55 #define WM8904_FLL_FREE_RUNNING 4
56 
57 /*
58  * Register values.
59  */
60 #define WM8904_SW_RESET_AND_ID 0x00
61 #define WM8904_REVISION 0x01
62 #define WM8904_BIAS_CONTROL_0 0x04
63 #define WM8904_VMID_CONTROL_0 0x05
64 #define WM8904_MIC_BIAS_CONTROL_0 0x06
65 #define WM8904_MIC_BIAS_CONTROL_1 0x07
66 #define WM8904_ANALOGUE_DAC_0 0x08
67 #define WM8904_MIC_FILTER_CONTROL 0x09
68 #define WM8904_ANALOGUE_ADC_0 0x0A
69 #define WM8904_POWER_MANAGEMENT_0 0x0C
70 #define WM8904_POWER_MANAGEMENT_2 0x0E
71 #define WM8904_POWER_MANAGEMENT_3 0x0F
72 #define WM8904_POWER_MANAGEMENT_6 0x12
73 #define WM8904_CLOCK_RATES_0 0x14
74 #define WM8904_CLOCK_RATES_1 0x15
75 #define WM8904_CLOCK_RATES_2 0x16
76 #define WM8904_AUDIO_INTERFACE_0 0x18
77 #define WM8904_AUDIO_INTERFACE_1 0x19
78 #define WM8904_AUDIO_INTERFACE_2 0x1A
79 #define WM8904_AUDIO_INTERFACE_3 0x1B
80 #define WM8904_DAC_DIGITAL_VOLUME_LEFT 0x1E
81 #define WM8904_DAC_DIGITAL_VOLUME_RIGHT 0x1F
82 #define WM8904_DAC_DIGITAL_0 0x20
83 #define WM8904_DAC_DIGITAL_1 0x21
84 #define WM8904_ADC_DIGITAL_VOLUME_LEFT 0x24
85 #define WM8904_ADC_DIGITAL_VOLUME_RIGHT 0x25
86 #define WM8904_ADC_DIGITAL_0 0x26
87 #define WM8904_DIGITAL_MICROPHONE_0 0x27
88 #define WM8904_DRC_0 0x28
89 #define WM8904_DRC_1 0x29
90 #define WM8904_DRC_2 0x2A
91 #define WM8904_DRC_3 0x2B
92 #define WM8904_ANALOGUE_LEFT_INPUT_0 0x2C
93 #define WM8904_ANALOGUE_RIGHT_INPUT_0 0x2D
94 #define WM8904_ANALOGUE_LEFT_INPUT_1 0x2E
95 #define WM8904_ANALOGUE_RIGHT_INPUT_1 0x2F
96 #define WM8904_ANALOGUE_OUT1_LEFT 0x39
97 #define WM8904_ANALOGUE_OUT1_RIGHT 0x3A
98 #define WM8904_ANALOGUE_OUT2_LEFT 0x3B
99 #define WM8904_ANALOGUE_OUT2_RIGHT 0x3C
100 #define WM8904_ANALOGUE_OUT12_ZC 0x3D
101 #define WM8904_DC_SERVO_0 0x43
102 #define WM8904_DC_SERVO_1 0x44
103 #define WM8904_DC_SERVO_2 0x45
104 #define WM8904_DC_SERVO_4 0x47
105 #define WM8904_DC_SERVO_5 0x48
106 #define WM8904_DC_SERVO_6 0x49
107 #define WM8904_DC_SERVO_7 0x4A
108 #define WM8904_DC_SERVO_8 0x4B
109 #define WM8904_DC_SERVO_9 0x4C
110 #define WM8904_DC_SERVO_READBACK_0 0x4D
111 #define WM8904_ANALOGUE_HP_0 0x5A
112 #define WM8904_ANALOGUE_LINEOUT_0 0x5E
113 #define WM8904_CHARGE_PUMP_0 0x62
114 #define WM8904_CLASS_W_0 0x68
115 #define WM8904_WRITE_SEQUENCER_0 0x6C
116 #define WM8904_WRITE_SEQUENCER_1 0x6D
117 #define WM8904_WRITE_SEQUENCER_2 0x6E
118 #define WM8904_WRITE_SEQUENCER_3 0x6F
119 #define WM8904_WRITE_SEQUENCER_4 0x70
120 #define WM8904_FLL_CONTROL_1 0x74
121 #define WM8904_FLL_CONTROL_2 0x75
122 #define WM8904_FLL_CONTROL_3 0x76
123 #define WM8904_FLL_CONTROL_4 0x77
124 #define WM8904_FLL_CONTROL_5 0x78
125 #define WM8904_GPIO_CONTROL_1 0x79
126 #define WM8904_GPIO_CONTROL_2 0x7A
127 #define WM8904_GPIO_CONTROL_3 0x7B
128 #define WM8904_GPIO_CONTROL_4 0x7C
129 #define WM8904_DIGITAL_PULLS 0x7E
130 #define WM8904_INTERRUPT_STATUS 0x7F
131 #define WM8904_INTERRUPT_STATUS_MASK 0x80
132 #define WM8904_INTERRUPT_POLARITY 0x81
133 #define WM8904_INTERRUPT_DEBOUNCE 0x82
134 #define WM8904_EQ1 0x86
135 #define WM8904_EQ2 0x87
136 #define WM8904_EQ3 0x88
137 #define WM8904_EQ4 0x89
138 #define WM8904_EQ5 0x8A
139 #define WM8904_EQ6 0x8B
140 #define WM8904_EQ7 0x8C
141 #define WM8904_EQ8 0x8D
142 #define WM8904_EQ9 0x8E
143 #define WM8904_EQ10 0x8F
144 #define WM8904_EQ11 0x90
145 #define WM8904_EQ12 0x91
146 #define WM8904_EQ13 0x92
147 #define WM8904_EQ14 0x93
148 #define WM8904_EQ15 0x94
149 #define WM8904_EQ16 0x95
150 #define WM8904_EQ17 0x96
151 #define WM8904_EQ18 0x97
152 #define WM8904_EQ19 0x98
153 #define WM8904_EQ20 0x99
154 #define WM8904_EQ21 0x9A
155 #define WM8904_EQ22 0x9B
156 #define WM8904_EQ23 0x9C
157 #define WM8904_EQ24 0x9D
158 #define WM8904_CONTROL_INTERFACE_TEST_1 0xA1
159 #define WM8904_ADC_TEST_0 0xC6
160 #define WM8904_ANALOGUE_OUTPUT_BIAS_0 0xCC
161 #define WM8904_FLL_NCO_TEST_0 0xF7
162 #define WM8904_FLL_NCO_TEST_1 0xF8
163 
164 #define WM8904_REGISTER_COUNT 101
165 #define WM8904_MAX_REGISTER 0xF8
166 
167 
168 /* register setting constants */
169 #define WM8904_FLL_1288MHZ_K (0x3127)
170 #define WM8904_FLL_1288MHZ_N (0x8 << 5)
171 #define WM8904_FLL_1128MHZ_K (0x86C2)
172 #define WM8904_FLL_1128MHZ_N (0x7 << 5)
173 
174 #define WM8904_BDIV_256FS_2_64FS (0x0004)
175 #define WM8904_BDIV_256FS_2_32FS (0x0008)
176 #define WM8904_BDIV_384FS_2_64FS (0x0007)
177 #define WM8904_BDIV_384FS_2_32FS (0x000B)
178 #define WM8904_LRDIV_64FS (0x0840)
179 #define WM8904_LRDIV_32FS (0x0820)
180 
181 #define WM8904_AIF123_256FS_2_32FS { 0x4042, WM8904_BDIV_256FS_2_32FS, WM8904_LRDIV_32FS}
182 #define WM8904_AIF123_256FS_2_64FS { 0x404A, WM8904_BDIV_256FS_2_64FS, WM8904_LRDIV_64FS}
183 #define WM8904_AIF123_384FS_2_32FS { 0x4042, WM8904_BDIV_384FS_2_32FS, WM8904_LRDIV_32FS}
184 #define WM8904_AIF123_384FS_2_64FS { 0x404A, WM8904_BDIV_384FS_2_64FS, WM8904_LRDIV_64FS}
185 
186 #define WM8904_DAC_DIGITAL_1_VALUE 0x0240
187 
188 #ifdef __cplusplus
189 extern "C" {
190 #endif
191 
197 #define WM8904_U8(val) (((val) >> 8) & 0xFF), ((val) & 0xFF)
198 
205 void WM8904_REG_Write(uint8_t reg, uint16_t val);
206 
212 uint16_t WM8904_REG_Read(uint8_t reg);
213 
220 int WM8904_REG_WriteVerify(uint8_t reg, uint16_t val);
221 
231 int WM8904_REG_WriteMult(const uint8_t *buff, int len);
232 
241 int WM8904_REG_VerifyMult(uint8_t reg, const uint8_t *value, uint8_t *buff, int len);
242 
249 int WM8904_Init(int input);
250 
251 #ifdef __cplusplus
252 }
253 #endif
254 
259 #endif /* _WM8904__ */
260