LPCOpen Platform for LPC112X microcontrollers  112X
LPCOpen Platform for the NXP LPC112X family of Microcontrollers
wm8903.h
Go to the documentation of this file.
1 /*
2  * @brief WM8903 Audio Codec header
3  *
4  * @note
5  * Copyright(C) NXP Semiconductors, 2014
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 _WM8903_H
33 #define _WM8903_H
34 
49 #define WM8903_CLK_MCLK 1
50 #define WM8903_CLK_FLL 2
51 
52 #define WM8903_FLL_MCLK 1
53 #define WM8903_FLL_BCLK 2
54 #define WM8903_FLL_LRCLK 3
55 #define WM8903_FLL_FREE_RUNNING 4
56 
57 /*
58  * Register values.
59  */
60 #define WM8903_SW_RESET_AND_ID 0x00
61 #define WM8903_REVISION 0x01
62 #define WM8903_BIAS_CONTROL_0 0x04
63 #define WM8903_VMID_CONTROL_0 0x05
64 #define WM8903_MIC_BIAS_CONTROL_0 0x06
65 #define WM8903_ANALOGUE_DAC_0 0x08
66 #define WM8903_ANALOGUE_ADC_0 0x0A
67 #define WM8903_POWER_MANAGEMENT_0 0x0C
68 #define WM8903_POWER_MANAGEMENT_1 0x0D
69 #define WM8903_POWER_MANAGEMENT_2 0x0E
70 #define WM8903_POWER_MANAGEMENT_3 0x0F
71 #define WM8903_POWER_MANAGEMENT_4 0x10
72 #define WM8903_POWER_MANAGEMENT_5 0x11
73 #define WM8903_POWER_MANAGEMENT_6 0x12
74 #define WM8903_CLOCK_RATES_0 0x14
75 #define WM8903_CLOCK_RATES_1 0x15
76 #define WM8903_CLOCK_RATES_2 0x16
77 #define WM8903_AUDIO_INTERFACE_0 0x18
78 #define WM8903_AUDIO_INTERFACE_1 0x19
79 #define WM8903_AUDIO_INTERFACE_2 0x1A
80 #define WM8903_AUDIO_INTERFACE_3 0x1B
81 #define WM8903_DAC_DIGITAL_VOLUME_LEFT 0x1E
82 #define WM8903_DAC_DIGITAL_VOLUME_RIGHT 0x1F
83 #define WM8903_DAC_DIGITAL_0 0x20
84 #define WM8903_DAC_DIGITAL_1 0x21
85 #define WM8903_ADC_DIGITAL_VOLUME_LEFT 0x24
86 #define WM8903_ADC_DIGITAL_VOLUME_RIGHT 0x25
87 #define WM8903_ADC_DIGITAL_0 0x26
88 #define WM8903_DRC_0 0x28
89 #define WM8903_DRC_1 0x29
90 #define WM8903_DRC_2 0x2A
91 #define WM8903_DRC_3 0x2B
92 #define WM8903_ANALOGUE_LEFT_INPUT_0 0x2C
93 #define WM8903_ANALOGUE_RIGHT_INPUT_0 0x2D
94 #define WM8903_ANALOGUE_LEFT_INPUT_1 0x2E
95 #define WM8903_ANALOGUE_RIGHT_INPUT_1 0x2F
96 #define WM8903_ANALOGUE_LEFT_MIX_0 0x32
97 #define WM8903_ANALOGUE_RIGHT_MIX_0 0x33
98 #define WM8903_ANALOGUE_SPK_MIX_LEFT_0 0x34
99 #define WM8903_ANALOGUE_SPK_MIX_LEFT_1 0x35
100 #define WM8903_ANALOGUE_SPK_MIX_RIGHT_0 0x36
101 #define WM8903_ANALOGUE_SPK_MIX_RIGHT_1 0x37
102 #define WM8903_ANALOGUE_OUT1_LEFT 0x39
103 #define WM8903_ANALOGUE_OUT1_RIGHT 0x3A
104 #define WM8903_ANALOGUE_OUT2_LEFT 0x3B
105 #define WM8903_ANALOGUE_OUT2_RIGHT 0x3C
106 #define WM8903_ANALOGUE_OUT3_LEFT 0x3E
107 #define WM8903_ANALOGUE_OUT3_RIGHT 0x3F
108 #define WM8903_ANALOGUE_SPK_OUTPUT_CONTROL_0 0x41
109 #define WM8903_DC_SERVO_0 0x43
110 #define WM8903_DC_SERVO_2 0x45
111 #define WM8903_DC_SERVO_4 0x47
112 #define WM8903_DC_SERVO_5 0x48
113 #define WM8903_DC_SERVO_6 0x49
114 #define WM8903_DC_SERVO_7 0x4A
115 #define WM8903_DC_SERVO_READBACK_1 0x51
116 #define WM8903_DC_SERVO_READBACK_2 0x52
117 #define WM8903_DC_SERVO_READBACK_3 0x53
118 #define WM8903_DC_SERVO_READBACK_4 0x54
119 #define WM8903_ANALOGUE_HP_0 0x5A
120 #define WM8903_ANALOGUE_LINEOUT_0 0x5E
121 #define WM8903_CHARGE_PUMP_0 0x62
122 #define WM8903_CLASS_W_0 0x68
123 #define WM8903_WRITE_SEQUENCER_0 0x6C
124 #define WM8903_WRITE_SEQUENCER_1 0x6D
125 #define WM8903_WRITE_SEQUENCER_2 0x6E
126 #define WM8903_WRITE_SEQUENCER_3 0x6F
127 #define WM8903_WRITE_SEQUENCER_4 0x70
128 #define WM8903_GPIO_CONTROL_1 0x74
129 #define WM8903_GPIO_CONTROL_2 0x75
130 #define WM8903_GPIO_CONTROL_3 0x76
131 #define WM8903_GPIO_CONTROL_4 0x77
132 #define WM8903_GPIO_CONTROL_5 0x78
133 #define WM8903_INTERRUPT_STATUS 0x79
134 #define WM8903_INTERRUPT_STATUS_MASK 0x7A
135 #define WM8903_INTERRUPT_POLARITY_1 0x7B
136 #define WM8903_INTERRUPT_CONTROL 0x7E
137 #define WM8903_FLL_CONTROL_1 0x80
138 #define WM8903_FLL_CONTROL_2 0x81
139 #define WM8903_FLL_CONTROL_3 0x82
140 #define WM8903_FLL_CONTROL_4 0x83
141 #define WM8903_CLOCK_RATE_TEST_4 0xA4
142 #define WM8903_ANALOGUE_OUTPUT_BIAS_0 0xAC
143 #define WM8903_ANALOGUE_OUTPUT_BIAS_2 0xBB
144 
145 #define WM8903_REGISTER_COUNT 84
146 #define WM8903_MAX_REGISTER 0xBB
147 
148 /* Some bit definitions in the above registers. */
149 #define WSEQ_BUSY_BIT 0
150 #define WSEQ_BUSY_MASK (1<<WSEQ_BUSY_BIT)
151 #define FLL_LOCK_EINT_BIT 5
152 #define FLL_LOCK_EINT_MASK (1<<FLL_LOCK_EINT_BIT)
153 
154 
155 /* register setting constants */
156 #define WM8903_FLL_1288MHZ_K (0x3127)
157 #define WM8903_FLL_1288MHZ_N (0x8 << 5)
158 
159 /* DAC_MONO=0, DAC_SB_FILT=0, DAC_MUTERATE=0, DAC_UNMUTE_RAMP=1, DAC_OSR128=1, DAC_MUTE=0, DEEMPH=00 */
160 #define WM8903_DAC_DIGITAL_1_VALUE 0x0240
161 
162 
163 #ifdef __cplusplus
164 extern "C" {
165 #endif
166 
173 uint32_t WM8903_REG_Write(uint8_t reg, uint16_t val);
174 
180 uint16_t WM8903_REG_Read(uint8_t reg);
181 
188 int WM8903_Init(int input);
189 
194 void WM8903_DeInit(void);
195 
200 void WM8903_DumpAllRegisters(void);
201 
202 
203 #ifdef __cplusplus
204 }
205 #endif
206 
211 #endif /* _WM8903__ */
212