2 * @brief UDA1380 Audio Codec header
\r
5 * Copyright(C) NXP Semiconductors, 2012
\r
6 * All rights reserved.
\r
9 * Software that is described herein is for illustrative purposes only
\r
10 * which provides customers with programming information regarding the
\r
11 * LPC products. This software is supplied "AS IS" without any warranties of
\r
12 * any kind, and NXP Semiconductors and its licensor disclaim any and
\r
13 * all warranties, express or implied, including all implied warranties of
\r
14 * merchantability, fitness for a particular purpose and non-infringement of
\r
15 * intellectual property rights. NXP Semiconductors assumes no responsibility
\r
16 * or liability for the use of the software, conveys no license or rights under any
\r
17 * patent, copyright, mask work right, or any other intellectual property rights in
\r
18 * or to any products. NXP Semiconductors reserves the right to make changes
\r
19 * in the software without notification. NXP Semiconductors also makes no
\r
20 * representation or warranty that such application will be suitable for the
\r
21 * specified use without further testing or modification.
\r
24 * Permission to use, copy, modify, and distribute this software and its
\r
25 * documentation is hereby granted, under NXP Semiconductors' and its
\r
26 * licensor's relevant copyrights in the software, without fee, provided that it
\r
27 * is used in conjunction with NXP Semiconductors microcontrollers. This
\r
28 * copyright, permission, and disclaimer notice must appear in all copies of
\r
32 #ifndef __UDA1380_H_
\r
33 #define __UDA1380_H_
\r
35 /** @defgroup BOARD_COMMON_UDA1380 BOARD: UDA1380 Audio codec interface module
\r
36 * UDA1380 Audio codec interface module, the module registers are accessed
\r
37 * using I2C. The board which uses this module must define #UDA1380_I2C_BUS to #I2C0
\r
38 * , #I2C1, etc, based on which I2C bus is connected to UDA1380. All the
\r
39 * functions in this modules assumes that the I2C interrupt for #UDA1380_I2C_BUS
\r
40 * is enabled and ::Chip_I2C_MasterStateHandler(#UDA1380_I2C_BUS) is called from the
\r
41 * ISR. If the functions are to be used in polling mode the caller must replace
\r
42 * the event handler to Chip_I2C_EventHandlerPolling(), by using API
\r
43 * Chip_I2C_SetMasterEventHandler(). A macro #I2CDEV_UDA1380_ADDR must be defined
\r
44 * to the appropriate slave address of UDA1380 audio codec.
\r
45 * @ingroup BOARD_Common
\r
49 /* UDA1380 Registers */
\r
50 #define UDA_EVALM_CLK 0x00
\r
51 #define UDA_BUS_CTRL 0x01
\r
52 #define UDA_POWER_CTRL 0x02
\r
53 #define UDA_ANALOG_CTRL 0x03
\r
54 #define UDA_HPAMP_CTRL 0x04
\r
55 #define UDA_MASTER_VOL_CTRL 0x10
\r
56 #define UDA_MIXER_VOL_CTRL 0x11
\r
57 #define UDA_MODE_CTRL 0x12
\r
58 #define UDA_MUTE_CTRL 0x13
\r
59 #define UDA_MIXER_FILTER_CTRL 0x14
\r
60 #define UDA_DEC_VOL_CTRL 0x20
\r
61 #define UDA_PGA_CTRL 0x21
\r
62 #define UDA_ADC_CTRL 0x22
\r
63 #define UDA_AGC_CTRL 0x23
\r
64 #define UDA_TOTAL_REG 0x24
\r
66 /** Evalutation mode and clock setting register bits */
\r
67 #define EVCLK_EV2 (1 << 15)
\r
68 #define EVCLK_EV1 (1 << 14)
\r
69 #define EVCLK_EV0 (1 << 13)
\r
70 #define EVCLK_EN_ADC (1 << 11)
\r
71 #define EVCLK_EN_DEC (1 << 10)
\r
72 #define EVCLK_EN_DAC (1 << 9)
\r
73 #define EVCLK_EN_INT (1 << 8)
\r
74 #define EVCLK_ADC_CLK (1 << 5)
\r
75 #define EVCLK_DAC_CLK (1 << 4)
\r
76 #define EVCLK_SYS_DIV1 (1 << 3)
\r
77 #define EVCLK_SYS_DIV0 (1 << 2)
\r
78 #define EVCLK_PLL1 (1 << 1)
\r
79 #define EVCLK_PLL0 (1 << 0)
\r
81 /** UDA1380 register default values */
\r
82 #define UDA1380_REG_EVALCLK_DEFAULT_VALUE (0xF << 8 | 0x3 << 4 | 1 << 1)
\r
83 #define UDA1380_REG_I2S_DEFAULT_VALUE 0x0000
\r
85 #define UDA1380_REG_PWRCTRL_DEFAULT_VALUE (1 << 15 | 1 << 13 | 1 << 10 | 1 << 8 | 1 << 6 | 1 << 4 | 0x0F)
\r
86 #define UDA1380_REG_ANAMIX_DEFAULT_VALUE 0x0000
\r
87 #define UDA1380_REG_HEADAMP_DEFAULT_VALUE ( 1 << 9 | 2)
\r
89 #define UDA1380_REG_MSTRVOL_DEFAULT_VALUE 0x0000
\r
90 #define UDA1380_REG_MIXVOL_DEFAULT_VALUE 0x0000
\r
91 #define UDA1380_REG_MODEBBT_DEFAULT_VALUE 0x0000
\r
92 #define UDA1380_REG_MSTRMUTE_DEFAULT_VALUE (2 << 8 | 2)
\r
93 #define UDA1380_REG_MIXSDO_DEFAULT_VALUE 0x0000
\r
95 #define UDA1380_REG_DECVOL_DEFAULT_VALUE 0xE4E4 /* Decrease Volume -28dB */
\r
96 #define UDA1380_REG_PGA_DEFAULT_VALUE 0x0000
\r
97 #define UDA1380_REG_ADC_DEFAULT_VALUE 0x0001 /* Apply 0bB VGA Gain, enable DC Filter */
\r
98 #define UDA1380_REG_AGC_DEFAULT_VALUE 0x0000
\r
100 #define UDA1380_REG_L3_DEFAULT_VALUE 0x0000
\r
102 /* UDA1380 Audio input selection */
\r
103 #define UDA1380_LINE_IN 0 /**< LINE_IN_L in left stream, LINE_IN_R in Right stream */
\r
104 #define UDA1380_MIC_IN_L (1 << 2) /**< MIC audio in Left stream, Line_IN_R in Right stream */
\r
105 #define UDA1380_MIC_IN_LR (3 << 2) /**< MIC audio in Left & Right stream */
\r
112 * @def UDA1380_U8(val)
\r
113 * Convert a 16 bit register value to 2 x 8 bit values that could be written
\r
114 * to the I2C bus in an efficient way.
\r
116 #define UDA1380_U8(val) (((val) >> 8) & 0xFF), ((val) & 0xFF)
\r
119 * @brief Write a 16-bit value to UDA Register
\r
120 * @param reg : Register to which @a val be written
\r
121 * @param val : 16-Bit value to be written
\r
124 void UDA1380_REG_Write(uint8_t reg, uint16_t val);
\r
127 * @brief Read a 16-bit value from UDA1380 codec register
\r
128 * @param reg : Register from which the value to be read
\r
129 * @return Returns the value read from the register
\r
131 uint16_t UDA1380_REG_Read(uint8_t reg);
\r
134 * @brief Writes a value to a UDA register, read back and verify the value
\r
135 * @param reg : Register to which the value be written
\r
136 * @param val : Value to be written
\r
137 * @return 1 On success, 0 on failure
\r
139 int UDA1380_REG_WriteVerify(uint8_t reg, uint16_t val);
\r
142 * @brief Write multiple value to UDA1380 registers
\r
143 * @param buff : Pointer to buffer (See note section)
\r
144 * @param len : Number of bytes in buff
\r
145 * @return 1 on Success, 0 on failure
\r
146 * @note buff[0] must be the address of the register to which
\r
147 * the first data i.e, buff[1], buff[2] be written, the next bytes
\r
148 * buff[3], buff[4] be written to register buff[0]+1 and so on.
\r
150 int UDA1380_REG_WriteMult(const uint8_t *buff, int len);
\r
153 * @brief Verify values in multiple UDA1380 registers
\r
154 * @param reg : Starting register from which data be read
\r
155 * @param value : Pointer to memory which contains values to be compared
\r
156 * @param buff : Pointer to memory to which data be read
\r
157 * @param len : Length of bytes in value @a buff
\r
158 * @return 1 on Success & Data is valid, 0 on Failure
\r
160 int UDA1380_REG_VerifyMult(uint8_t reg, const uint8_t *value, uint8_t *buff, int len);
\r
163 * @brief Initialize UDA1380 to its default state
\r
164 * @param input : Audio input source (Must be one of #UDA1380_LINE_IN
\r
165 * or #UDA1380_MIC_IN_L or #UDA1380_MIC_IN_LR)
\r
166 * @return 1 on Success and 0 on failure
\r
168 int UDA1380_Init(int input);
\r
178 #endif /* __UDA1380_H_ */
\r