tinyusb
uda1380.h
1 #ifndef _UDA1380_H_
2 #define _UDA1380_H_
3 
4 #include "lpc_types.h"
5 
6 #define UDA1380_SYSCLK_USED 0
7 #define UDA1380_SLAVE_ADDR 0x1A
8 #define UDA1380_CMD_BUFF_SIZE 3
9 
11 #define UDA1380_REG_EVALCLK 0x00
12 #define UDA1380_REG_I2S 0x01
13 #define UDA1380_REG_PWRCTRL 0x02
14 #define UDA1380_REG_ANAMIX 0x03
15 #define UDA1380_REG_HEADAMP 0x04
16 #define UDA1380_REG_MSTRVOL 0x10
17 #define UDA1380_REG_MIXVOL 0x11
18 #define UDA1380_REG_MODEBBT 0x12
19 #define UDA1380_REG_MSTRMUTE 0x13
20 #define UDA1380_REG_MIXSDO 0x14
21 #define UDA1380_REG_DECVOL 0x20
22 #define UDA1380_REG_PGA 0x21
23 #define UDA1380_REG_ADC 0x22
24 #define UDA1380_REG_AGC 0x23
25 #define UDA1380_REG_L3 0x7f
26 #define UDA1380_REG_HEADPHONE 0x18
27 #define UDA1380_REG_DEC 0x28
28 
29 // UDA1380_REG_EVALCLK bit defines
30 #define EVALCLK_ADC_EN 0x0800 // Enable ADC clock
31 #define EVALCLK_DEC_EN 0x0400 // Enable decimator clock
32 #define EVALCLK_DAC_EN 0x0200 // Enable DAC clock
33 #define EVALCLK_INT_EN 0x0100 // Enable interpolator clock
34 #define EVALCLK_ADC_SEL_WSPLL 0x0020 // Select SYSCLK input for ADC clock
35 #define EVALCLK_ADC_SEL_SYSCLK 0x0000 // Select WSPLL clock for ADC clock
36 #define EVALCLK_DAC_SEL_WSPLL 0x0010 // Select SYSCLK input for DAC clock
37 #define EVALCLK_DAC_SEL_SYSCLK 0x0000 // Select WSPLL clock for DAC clock
38 #define EVALCLK_SYSDIV_SEL(n) ((n) << 2) // System clock input divider select
39 #define EVALCLK_WSPLL_SEL6_12K 0x0000 // WSPLL input freq selection = 6.25 to 12.5K
40 #define EVALCLK_WSPLL_SEL12_25K 0x0001 // WSPLL input freq selection = 12.5K to 25K
41 #define EVALCLK_WSPLL_SEL25_50K 0x0002 // WSPLL input freq selection = 25K to 50K
42 #define EVALCLK_WSPLL_SEL50_100K 0x0003 // WSPLL input freq selection = 50K to 100K
43 
44 // UDA1380_REG_I2S
45 #define I2S_SFORI_I2S 0x0000
46 #define I2S_SFORI_LSB16 0x0100
47 #define I2S_SFORI_LSB18 0x0200
48 #define I2S_SFORI_LSB20 0x0300
49 #define I2S_SFORI_MSB 0x0500
50 #define I2S_SFORI_MASK 0x0700
51 #define I2S_SFORO_I2S 0x0000
52 #define I2S_SFORO_LSB16 0x0001
53 #define I2S_SFORO_LSB18 0x0002
54 #define I2S_SFORO_LSB20 0x0003
55 #define I2S_SFORO_LSB24 0x0004
56 #define I2S_SFORO_MSB 0x0005
57 #define I2S_SFORO_MASK 0x0007
58 #define I2S_SEL_SOURCE 0x0040
59 #define I2S_SIM 0x0010
60 
61 // UDA1380_REG_PWRCTRL bit defines
62 #define PWR_PON_PLL_EN 0x8000 // WSPLL enable
63 #define PWR_PON_HP_EN 0x2000 // Headphone driver enable
64 #define PWR_PON_DAC_EN 0x0400 // DAC power enable
65 #define PWR_PON_BIAS_EN 0x0100 // Power on bias enable (for ADC, AVC, and FSDAC)
66 #define PWR_EN_AVC_EN 0x0080 // Analog mixer enable
67 #define PWR_PON_AVC_EN 0x0040 // Analog mixer power enable
68 #define PWR_EN_LNA_EN 0x0010 // LNA and SDC power enable
69 #define PWR_EN_PGAL_EN 0x0008 // PGA left power enable
70 #define PWR_EN_ADCL_EN 0x0004 // ADC left power enable
71 #define PWR_EN_PGAR_EN 0x0002 // PGA right power enable
72 #define PWR_EN_ADCR_EN 0x0001 // ADC right power enable
73 
74 // UDA1380_REG_MSTRMUTE bit defines
75 #define MSTRMUTE_MTM_MUTE_EN 0x4000 // Master mute enable
76 #define MSRTMUTE_CHANNEL2_MUTE_EN 0x0800
77 #define MSRTMUTE_CHANNEL1_MUTE_EN 0x0008
78 
79 
80 // UDA1380_REG_MODEBBT bit defines
81 #define MODEBBT_BOOST_FLAT 0x0000 // Bits for selecting flat boost
82 #define MODEBBT_BOOST_FULL 0xC000 // Bits for selecting maximum boost
83 #define MODEBBT_BOOST_MASK 0xC000 // Bits for selecting boost mask
84 
85 #define UDA1380_FUNC_OK 0
86 #define UDA1380_FUNC_ERR -1
87 
88 int32_t Uda1380_Init(uint32_t i2cClockFreq, uint32_t i2sClockFreq);
89 int32_t Uda1380_WriteData(uint8_t reg, uint16_t data);
90 int32_t Uda1380_ReadData(uint8_t reg, uint16_t *data);
91 
92 
93 #endif /* _UDA1380_H_ */