A fairly well tested TLV320 library for I2C configuration and control of the TI TLV320 part

Dependents:   TLV320_Write_test

Committer:
p07gbar
Date:
Wed Sep 19 10:56:31 2012 +0000
Revision:
0:a68f7c573e8c
Child:
1:3ee50344f8f4
Working stably

Who changed what in which revision?

UserRevisionLine numberNew contents of line
p07gbar 0:a68f7c573e8c 1 #include "TLV320.h"
p07gbar 0:a68f7c573e8c 2
p07gbar 0:a68f7c573e8c 3 #define TLV320_HP_VOL_DF_MASK 0x80
p07gbar 0:a68f7c573e8c 4
p07gbar 0:a68f7c573e8c 5
p07gbar 0:a68f7c573e8c 6 #define TLV320_DF_hp_vol_left 0.5
p07gbar 0:a68f7c573e8c 7 #define TLV320_DF_hp_vol_right 0.5
p07gbar 0:a68f7c573e8c 8 #define TLV320_DF_li_vol_left 0.5
p07gbar 0:a68f7c573e8c 9 #define TLV320_DF_li_vol_right 0.5
p07gbar 0:a68f7c573e8c 10 #define TLV320_DF_sdt_vol 0
p07gbar 0:a68f7c573e8c 11
p07gbar 0:a68f7c573e8c 12 const uint8_t base_address = 0x1A;
p07gbar 0:a68f7c573e8c 13
p07gbar 0:a68f7c573e8c 14
p07gbar 0:a68f7c573e8c 15 TLV320::TLV320(PinName i2c_sda, PinName i2c_scl): i2c(i2c_sda,i2c_scl) {
p07gbar 0:a68f7c573e8c 16 address = base_address;
p07gbar 0:a68f7c573e8c 17 defaulter();
p07gbar 0:a68f7c573e8c 18 form_cmd(all);
p07gbar 0:a68f7c573e8c 19 }
p07gbar 0:a68f7c573e8c 20
p07gbar 0:a68f7c573e8c 21 TLV320::TLV320(PinName i2c_sda, PinName i2c_scl, bool cs_level): i2c(i2c_sda,i2c_scl) {
p07gbar 0:a68f7c573e8c 22 address = base_address + (1*cs_level);
p07gbar 0:a68f7c573e8c 23 defaulter();
p07gbar 0:a68f7c573e8c 24 form_cmd(all);
p07gbar 0:a68f7c573e8c 25 }
p07gbar 0:a68f7c573e8c 26
p07gbar 0:a68f7c573e8c 27 void TLV320::power(bool on_off) {
p07gbar 0:a68f7c573e8c 28 device_all_pwr = on_off;
p07gbar 0:a68f7c573e8c 29 form_cmd(power_control);
p07gbar 0:a68f7c573e8c 30 }
p07gbar 0:a68f7c573e8c 31
p07gbar 0:a68f7c573e8c 32 void TLV320::input_select(int input) {
p07gbar 0:a68f7c573e8c 33
p07gbar 0:a68f7c573e8c 34 switch(input)
p07gbar 0:a68f7c573e8c 35 {
p07gbar 0:a68f7c573e8c 36 case TLV320_NO_IN:
p07gbar 0:a68f7c573e8c 37 device_adc_pwr = false;
p07gbar 0:a68f7c573e8c 38 device_mic_pwr = false;
p07gbar 0:a68f7c573e8c 39 device_lni_pwr = false;
p07gbar 0:a68f7c573e8c 40 form_cmd(power_control);
p07gbar 0:a68f7c573e8c 41 break;
p07gbar 0:a68f7c573e8c 42 case TLV320_LINE:
p07gbar 0:a68f7c573e8c 43 device_adc_pwr = true;
p07gbar 0:a68f7c573e8c 44 device_lni_pwr = true;
p07gbar 0:a68f7c573e8c 45 device_mic_pwr = false;
p07gbar 0:a68f7c573e8c 46 ADC_source = TLV320_LINE;
p07gbar 0:a68f7c573e8c 47 form_cmd(power_control);
p07gbar 0:a68f7c573e8c 48 form_cmd(path_analog);
p07gbar 0:a68f7c573e8c 49 break;
p07gbar 0:a68f7c573e8c 50 case TLV320_MIC:
p07gbar 0:a68f7c573e8c 51 device_adc_pwr = true;
p07gbar 0:a68f7c573e8c 52 device_lni_pwr = false;
p07gbar 0:a68f7c573e8c 53 device_mic_pwr = true;
p07gbar 0:a68f7c573e8c 54 ADC_source = TLV320_MIC;
p07gbar 0:a68f7c573e8c 55 form_cmd(power_control);
p07gbar 0:a68f7c573e8c 56 form_cmd(path_analog);
p07gbar 0:a68f7c573e8c 57 break;
p07gbar 0:a68f7c573e8c 58 default:
p07gbar 0:a68f7c573e8c 59 device_adc_pwr = df_device_adc_pwr;
p07gbar 0:a68f7c573e8c 60 device_mic_pwr = df_device_mic_pwr;
p07gbar 0:a68f7c573e8c 61 device_lni_pwr = df_device_lni_pwr;
p07gbar 0:a68f7c573e8c 62 ADC_source = df_ADC_source;
p07gbar 0:a68f7c573e8c 63 form_cmd(power_control);
p07gbar 0:a68f7c573e8c 64 form_cmd(path_analog);
p07gbar 0:a68f7c573e8c 65 break;
p07gbar 0:a68f7c573e8c 66 }
p07gbar 0:a68f7c573e8c 67 ADC_source_old = ADC_source;
p07gbar 0:a68f7c573e8c 68 }
p07gbar 0:a68f7c573e8c 69
p07gbar 0:a68f7c573e8c 70 void TLV320::headphone_volume(float h_volume) {
p07gbar 0:a68f7c573e8c 71 hp_vol_left = h_volume;
p07gbar 0:a68f7c573e8c 72 hp_vol_right = h_volume;
p07gbar 0:a68f7c573e8c 73 form_cmd(headphone_vol_left);
p07gbar 0:a68f7c573e8c 74 form_cmd(headphone_vol_right);
p07gbar 0:a68f7c573e8c 75 }
p07gbar 0:a68f7c573e8c 76
p07gbar 0:a68f7c573e8c 77 void TLV320::linein_volume(float li_volume) {
p07gbar 0:a68f7c573e8c 78 li_vol_left = li_volume;
p07gbar 0:a68f7c573e8c 79 li_vol_right = li_volume;
p07gbar 0:a68f7c573e8c 80 form_cmd(line_in_vol_left);
p07gbar 0:a68f7c573e8c 81 form_cmd(line_in_vol_right);
p07gbar 0:a68f7c573e8c 82 }
p07gbar 0:a68f7c573e8c 83
p07gbar 0:a68f7c573e8c 84 void TLV320::microphone_boost(bool mic_boost) {
p07gbar 0:a68f7c573e8c 85 mic_boost_ = mic_boost;
p07gbar 0:a68f7c573e8c 86 }
p07gbar 0:a68f7c573e8c 87
p07gbar 0:a68f7c573e8c 88 void TLV320::input_mute(bool mute) {
p07gbar 0:a68f7c573e8c 89 if(ADC_source == TLV320_MIC)
p07gbar 0:a68f7c573e8c 90 {
p07gbar 0:a68f7c573e8c 91 mic_mute = mute;
p07gbar 0:a68f7c573e8c 92 form_cmd(path_analog);
p07gbar 0:a68f7c573e8c 93 }
p07gbar 0:a68f7c573e8c 94 else
p07gbar 0:a68f7c573e8c 95 {
p07gbar 0:a68f7c573e8c 96 li_mute_left = mute;
p07gbar 0:a68f7c573e8c 97 li_mute_right = mute;
p07gbar 0:a68f7c573e8c 98 form_cmd(line_in_vol_left);
p07gbar 0:a68f7c573e8c 99 form_cmd(line_in_vol_right);
p07gbar 0:a68f7c573e8c 100 }
p07gbar 0:a68f7c573e8c 101 }
p07gbar 0:a68f7c573e8c 102
p07gbar 0:a68f7c573e8c 103 void TLV320::output_mute(bool mute) {
p07gbar 0:a68f7c573e8c 104 out_mute = mute;
p07gbar 0:a68f7c573e8c 105 form_cmd(path_digital);
p07gbar 0:a68f7c573e8c 106 }
p07gbar 0:a68f7c573e8c 107
p07gbar 0:a68f7c573e8c 108 void TLV320::input_power(bool on_off) {
p07gbar 0:a68f7c573e8c 109
p07gbar 0:a68f7c573e8c 110 device_adc_pwr = on_off;
p07gbar 0:a68f7c573e8c 111
p07gbar 0:a68f7c573e8c 112 if(ADC_source == TLV320_MIC)
p07gbar 0:a68f7c573e8c 113 {
p07gbar 0:a68f7c573e8c 114 device_mic_pwr = on_off;
p07gbar 0:a68f7c573e8c 115 device_lni_pwr = false;
p07gbar 0:a68f7c573e8c 116 }
p07gbar 0:a68f7c573e8c 117 else
p07gbar 0:a68f7c573e8c 118 {
p07gbar 0:a68f7c573e8c 119 device_mic_pwr = false;
p07gbar 0:a68f7c573e8c 120 device_lni_pwr = on_off;
p07gbar 0:a68f7c573e8c 121 }
p07gbar 0:a68f7c573e8c 122
p07gbar 0:a68f7c573e8c 123 form_cmd(power_control);
p07gbar 0:a68f7c573e8c 124 }
p07gbar 0:a68f7c573e8c 125
p07gbar 0:a68f7c573e8c 126 void TLV320::output_power(bool on_off) {
p07gbar 0:a68f7c573e8c 127 device_dac_pwr = on_off;
p07gbar 0:a68f7c573e8c 128 device_out_pwr = on_off;
p07gbar 0:a68f7c573e8c 129
p07gbar 0:a68f7c573e8c 130 form_cmd(power_control);
p07gbar 0:a68f7c573e8c 131 }
p07gbar 0:a68f7c573e8c 132
p07gbar 0:a68f7c573e8c 133 void TLV320::wordsize(int words) {
p07gbar 0:a68f7c573e8c 134 device_bitlength = words;
p07gbar 0:a68f7c573e8c 135 form_cmd(interface_format);
p07gbar 0:a68f7c573e8c 136 }
p07gbar 0:a68f7c573e8c 137
p07gbar 0:a68f7c573e8c 138 void TLV320::master(bool master) {
p07gbar 0:a68f7c573e8c 139 device_master = master;
p07gbar 0:a68f7c573e8c 140 form_cmd(interface_format);
p07gbar 0:a68f7c573e8c 141 }
p07gbar 0:a68f7c573e8c 142
p07gbar 0:a68f7c573e8c 143 void TLV320::frequency(int freq) {
p07gbar 0:a68f7c573e8c 144 ADC_rate = freq;
p07gbar 0:a68f7c573e8c 145 DAC_rate = freq;
p07gbar 0:a68f7c573e8c 146 form_cmd(sample_rate);
p07gbar 0:a68f7c573e8c 147 }
p07gbar 0:a68f7c573e8c 148
p07gbar 0:a68f7c573e8c 149 void TLV320::input_highpass(bool enabled) {
p07gbar 0:a68f7c573e8c 150 ADC_highpass_enable = enabled;
p07gbar 0:a68f7c573e8c 151 form_cmd(path_digital);
p07gbar 0:a68f7c573e8c 152 }
p07gbar 0:a68f7c573e8c 153
p07gbar 0:a68f7c573e8c 154 void TLV320::output_softmute(bool enabled) {
p07gbar 0:a68f7c573e8c 155 out_mute = enabled;
p07gbar 0:a68f7c573e8c 156 form_cmd(path_digital);
p07gbar 0:a68f7c573e8c 157 }
p07gbar 0:a68f7c573e8c 158
p07gbar 0:a68f7c573e8c 159 void TLV320::interface_switch(bool on_off) {
p07gbar 0:a68f7c573e8c 160 device_interface_active = on_off;
p07gbar 0:a68f7c573e8c 161 form_cmd(interface_activation);
p07gbar 0:a68f7c573e8c 162 }
p07gbar 0:a68f7c573e8c 163
p07gbar 0:a68f7c573e8c 164 void TLV320::sidetone(float sidetone_vol) {
p07gbar 0:a68f7c573e8c 165 sdt_vol = sidetone_vol;
p07gbar 0:a68f7c573e8c 166 form_cmd(path_analog);
p07gbar 0:a68f7c573e8c 167 }
p07gbar 0:a68f7c573e8c 168
p07gbar 0:a68f7c573e8c 169 void TLV320::deemphasis(char code) {
p07gbar 0:a68f7c573e8c 170 de_emph_code = code & 0x03;
p07gbar 0:a68f7c573e8c 171 form_cmd(path_digital);
p07gbar 0:a68f7c573e8c 172 }
p07gbar 0:a68f7c573e8c 173
p07gbar 0:a68f7c573e8c 174 void TLV320::reset() {
p07gbar 0:a68f7c573e8c 175 form_cmd(reset_reg);
p07gbar 0:a68f7c573e8c 176 }
p07gbar 0:a68f7c573e8c 177
p07gbar 0:a68f7c573e8c 178 void TLV320::start() {
p07gbar 0:a68f7c573e8c 179 interface_switch(true);
p07gbar 0:a68f7c573e8c 180 }
p07gbar 0:a68f7c573e8c 181
p07gbar 0:a68f7c573e8c 182 void TLV320::bypass(bool enable) {
p07gbar 0:a68f7c573e8c 183 bypass_ = enable;
p07gbar 0:a68f7c573e8c 184 form_cmd(path_analog);
p07gbar 0:a68f7c573e8c 185 }
p07gbar 0:a68f7c573e8c 186
p07gbar 0:a68f7c573e8c 187 void TLV320::stop() {
p07gbar 0:a68f7c573e8c 188 interface_switch(false);
p07gbar 0:a68f7c573e8c 189 }
p07gbar 0:a68f7c573e8c 190
p07gbar 0:a68f7c573e8c 191 void TLV320::command(reg_address add, uint16_t cmd) {
p07gbar 0:a68f7c573e8c 192 char temp[2];
p07gbar 0:a68f7c573e8c 193 temp[0] = (char(add)<<1) | ((cmd >> 6) & 0x01);
p07gbar 0:a68f7c573e8c 194 temp[1] = (cmd & 0xFF);
p07gbar 0:a68f7c573e8c 195 i2c.write((address<<1), temp, 2);
p07gbar 0:a68f7c573e8c 196 }
p07gbar 0:a68f7c573e8c 197
p07gbar 0:a68f7c573e8c 198 void TLV320::form_cmd(reg_address add) {
p07gbar 0:a68f7c573e8c 199 uint16_t cmd = 0;
p07gbar 0:a68f7c573e8c 200 int temp = 0;
p07gbar 0:a68f7c573e8c 201 bool mute;
p07gbar 0:a68f7c573e8c 202 switch(add)
p07gbar 0:a68f7c573e8c 203 {
p07gbar 0:a68f7c573e8c 204 case line_in_vol_left:
p07gbar 0:a68f7c573e8c 205 temp = int(li_vol_left * 32) - 1;
p07gbar 0:a68f7c573e8c 206 mute = li_mute_left;
p07gbar 0:a68f7c573e8c 207
p07gbar 0:a68f7c573e8c 208 if(temp < 0)
p07gbar 0:a68f7c573e8c 209 {
p07gbar 0:a68f7c573e8c 210 temp = 0;
p07gbar 0:a68f7c573e8c 211 mute = true;
p07gbar 0:a68f7c573e8c 212 }
p07gbar 0:a68f7c573e8c 213 cmd = temp & 0x1F;
p07gbar 0:a68f7c573e8c 214 cmd |= mute << 7;
p07gbar 0:a68f7c573e8c 215 break;
p07gbar 0:a68f7c573e8c 216 case line_in_vol_right:
p07gbar 0:a68f7c573e8c 217 temp = int(li_vol_right * 32) - 1;
p07gbar 0:a68f7c573e8c 218 mute = li_mute_right;
p07gbar 0:a68f7c573e8c 219 if(temp < 0)
p07gbar 0:a68f7c573e8c 220 {
p07gbar 0:a68f7c573e8c 221 temp = 0;
p07gbar 0:a68f7c573e8c 222 mute = true;
p07gbar 0:a68f7c573e8c 223 }
p07gbar 0:a68f7c573e8c 224 cmd = temp & 0x1F;
p07gbar 0:a68f7c573e8c 225 cmd |= mute << 7;
p07gbar 0:a68f7c573e8c 226 break;
p07gbar 0:a68f7c573e8c 227
p07gbar 0:a68f7c573e8c 228 case headphone_vol_left:
p07gbar 0:a68f7c573e8c 229 temp = int(hp_vol_left * 80) + 47;
p07gbar 0:a68f7c573e8c 230 cmd = TLV320_HP_VOL_DF_MASK;
p07gbar 0:a68f7c573e8c 231 cmd |= temp & 0x7F;
p07gbar 0:a68f7c573e8c 232 break;
p07gbar 0:a68f7c573e8c 233 case headphone_vol_right:
p07gbar 0:a68f7c573e8c 234 temp = int(hp_vol_right * 80) + 47;
p07gbar 0:a68f7c573e8c 235 cmd = TLV320_HP_VOL_DF_MASK;
p07gbar 0:a68f7c573e8c 236 cmd |= temp & 0x7F;
p07gbar 0:a68f7c573e8c 237 break;
p07gbar 0:a68f7c573e8c 238
p07gbar 0:a68f7c573e8c 239 case path_analog:
p07gbar 0:a68f7c573e8c 240 temp = int(sdt_vol * 5);
p07gbar 0:a68f7c573e8c 241 char vol_code = 0;
p07gbar 0:a68f7c573e8c 242 switch(temp)
p07gbar 0:a68f7c573e8c 243 {
p07gbar 0:a68f7c573e8c 244 case 5:
p07gbar 0:a68f7c573e8c 245 vol_code = 0x0C;
p07gbar 0:a68f7c573e8c 246 break;
p07gbar 0:a68f7c573e8c 247 case 0:
p07gbar 0:a68f7c573e8c 248 vol_code = 0x00;
p07gbar 0:a68f7c573e8c 249 break;
p07gbar 0:a68f7c573e8c 250 default:
p07gbar 0:a68f7c573e8c 251 vol_code = ((0x04 - temp)&0x07) | 0x08;
p07gbar 0:a68f7c573e8c 252 break;
p07gbar 0:a68f7c573e8c 253 }
p07gbar 0:a68f7c573e8c 254 cmd = vol_code << 5;
p07gbar 0:a68f7c573e8c 255 cmd |= 1 << 4;
p07gbar 0:a68f7c573e8c 256 cmd |= bypass_ << 3;
p07gbar 0:a68f7c573e8c 257 cmd |= ADC_source << 2;
p07gbar 0:a68f7c573e8c 258 cmd |= mic_mute << 1;
p07gbar 0:a68f7c573e8c 259 cmd |= mic_boost_;
p07gbar 0:a68f7c573e8c 260 break;
p07gbar 0:a68f7c573e8c 261
p07gbar 0:a68f7c573e8c 262 case path_digital:
p07gbar 0:a68f7c573e8c 263 cmd |= out_mute << 3;
p07gbar 0:a68f7c573e8c 264 cmd |= ((de_emph_code & 0x3) << 1);
p07gbar 0:a68f7c573e8c 265 cmd |= ADC_highpass_enable;
p07gbar 0:a68f7c573e8c 266 break;
p07gbar 0:a68f7c573e8c 267
p07gbar 0:a68f7c573e8c 268 case power_control:
p07gbar 0:a68f7c573e8c 269 cmd |= !device_all_pwr << 7;
p07gbar 0:a68f7c573e8c 270 cmd |= !device_clk_pwr << 6;
p07gbar 0:a68f7c573e8c 271 cmd |= !device_osc_pwr << 5;
p07gbar 0:a68f7c573e8c 272 cmd |= !device_out_pwr << 4;
p07gbar 0:a68f7c573e8c 273 cmd |= !device_dac_pwr << 3;
p07gbar 0:a68f7c573e8c 274 cmd |= !device_adc_pwr << 2;
p07gbar 0:a68f7c573e8c 275 cmd |= !device_mic_pwr << 1;
p07gbar 0:a68f7c573e8c 276 cmd |= !device_lni_pwr << 0;
p07gbar 0:a68f7c573e8c 277 break;
p07gbar 0:a68f7c573e8c 278
p07gbar 0:a68f7c573e8c 279 case interface_format:
p07gbar 0:a68f7c573e8c 280 cmd |= device_master << 6;
p07gbar 0:a68f7c573e8c 281 cmd |= device_lrswap << 5;
p07gbar 0:a68f7c573e8c 282 cmd |= device_lrws << 4;
p07gbar 0:a68f7c573e8c 283 temp = 0;
p07gbar 0:a68f7c573e8c 284 switch(device_bitlength)
p07gbar 0:a68f7c573e8c 285 {
p07gbar 0:a68f7c573e8c 286 case 16:
p07gbar 0:a68f7c573e8c 287 temp = 0;
p07gbar 0:a68f7c573e8c 288 break;
p07gbar 0:a68f7c573e8c 289 case 20:
p07gbar 0:a68f7c573e8c 290 temp = 1;
p07gbar 0:a68f7c573e8c 291 break;
p07gbar 0:a68f7c573e8c 292 case 24:
p07gbar 0:a68f7c573e8c 293 temp = 2;
p07gbar 0:a68f7c573e8c 294 break;
p07gbar 0:a68f7c573e8c 295 case 32:
p07gbar 0:a68f7c573e8c 296 temp = 3;
p07gbar 0:a68f7c573e8c 297 break;
p07gbar 0:a68f7c573e8c 298 }
p07gbar 0:a68f7c573e8c 299 cmd |= (temp & 0x03) << 2;
p07gbar 0:a68f7c573e8c 300 cmd |= (device_data_form & 0x03);
p07gbar 0:a68f7c573e8c 301 break;
p07gbar 0:a68f7c573e8c 302
p07gbar 0:a68f7c573e8c 303 case sample_rate:
p07gbar 0:a68f7c573e8c 304 temp = gen_samplerate();
p07gbar 0:a68f7c573e8c 305 cmd = device_usb_mode;
p07gbar 0:a68f7c573e8c 306 cmd |= (temp & 0x03) << 1;
p07gbar 0:a68f7c573e8c 307 cmd |= device_clk_in_div << 6;
p07gbar 0:a68f7c573e8c 308 cmd |= device_clk_out_div << 7;
p07gbar 0:a68f7c573e8c 309 break;
p07gbar 0:a68f7c573e8c 310
p07gbar 0:a68f7c573e8c 311 case interface_activation:
p07gbar 0:a68f7c573e8c 312 cmd = device_interface_active;
p07gbar 0:a68f7c573e8c 313 break;
p07gbar 0:a68f7c573e8c 314
p07gbar 0:a68f7c573e8c 315 case reset_reg:
p07gbar 0:a68f7c573e8c 316 cmd = 0;
p07gbar 0:a68f7c573e8c 317 break;
p07gbar 0:a68f7c573e8c 318
p07gbar 0:a68f7c573e8c 319 case all:
p07gbar 0:a68f7c573e8c 320 for( int i = line_in_vol_left; i <= reset_reg; i++)
p07gbar 0:a68f7c573e8c 321 {
p07gbar 0:a68f7c573e8c 322 form_cmd((reg_address)i);
p07gbar 0:a68f7c573e8c 323 }
p07gbar 0:a68f7c573e8c 324 break;
p07gbar 0:a68f7c573e8c 325 }
p07gbar 0:a68f7c573e8c 326 if(add != all) command(add , cmd);
p07gbar 0:a68f7c573e8c 327 }
p07gbar 0:a68f7c573e8c 328
p07gbar 0:a68f7c573e8c 329 void TLV320::defaulter() {
p07gbar 0:a68f7c573e8c 330 hp_vol_left = TLV320_DF_hp_vol_left;
p07gbar 0:a68f7c573e8c 331 hp_vol_right = TLV320_DF_hp_vol_right;
p07gbar 0:a68f7c573e8c 332 li_vol_left = TLV320_DF_li_vol_left;
p07gbar 0:a68f7c573e8c 333 li_vol_right = TLV320_DF_li_vol_right;
p07gbar 0:a68f7c573e8c 334 sdt_vol = TLV320_DF_sdt_vol;
p07gbar 0:a68f7c573e8c 335 bypass_ = df_bypass_;
p07gbar 0:a68f7c573e8c 336
p07gbar 0:a68f7c573e8c 337 ADC_source = df_ADC_source;
p07gbar 0:a68f7c573e8c 338 ADC_source_old = df_ADC_source;
p07gbar 0:a68f7c573e8c 339
p07gbar 0:a68f7c573e8c 340 mic_mute = df_mic_mute;
p07gbar 0:a68f7c573e8c 341 li_mute_left = df_li_mute_left;
p07gbar 0:a68f7c573e8c 342 li_mute_right = df_li_mute_right;
p07gbar 0:a68f7c573e8c 343
p07gbar 0:a68f7c573e8c 344
p07gbar 0:a68f7c573e8c 345 mic_boost_ = df_mic_boost_;
p07gbar 0:a68f7c573e8c 346 out_mute = df_out_mute;
p07gbar 0:a68f7c573e8c 347 de_emph_code = df_de_emph_code;
p07gbar 0:a68f7c573e8c 348 ADC_highpass_enable = df_ADC_highpass_enable;
p07gbar 0:a68f7c573e8c 349
p07gbar 0:a68f7c573e8c 350 device_all_pwr = df_device_all_pwr;
p07gbar 0:a68f7c573e8c 351 device_clk_pwr = df_device_clk_pwr;
p07gbar 0:a68f7c573e8c 352 device_osc_pwr = df_device_osc_pwr;
p07gbar 0:a68f7c573e8c 353 device_out_pwr = df_device_out_pwr;
p07gbar 0:a68f7c573e8c 354 device_dac_pwr = df_device_dac_pwr;
p07gbar 0:a68f7c573e8c 355 device_adc_pwr = df_device_dac_pwr;
p07gbar 0:a68f7c573e8c 356 device_mic_pwr = df_device_mic_pwr;
p07gbar 0:a68f7c573e8c 357 device_lni_pwr = df_device_lni_pwr;
p07gbar 0:a68f7c573e8c 358
p07gbar 0:a68f7c573e8c 359 device_master = df_device_master;
p07gbar 0:a68f7c573e8c 360 device_lrswap = df_device_lrswap;
p07gbar 0:a68f7c573e8c 361 device_lrws = df_device_lrws;
p07gbar 0:a68f7c573e8c 362 device_bitlength = df_device_bitlength;
p07gbar 0:a68f7c573e8c 363
p07gbar 0:a68f7c573e8c 364
p07gbar 0:a68f7c573e8c 365 ADC_rate = df_ADC_rate;
p07gbar 0:a68f7c573e8c 366 DAC_rate = df_DAC_rate;
p07gbar 0:a68f7c573e8c 367
p07gbar 0:a68f7c573e8c 368 device_interface_active = df_device_interface_active;
p07gbar 0:a68f7c573e8c 369 }
p07gbar 0:a68f7c573e8c 370
p07gbar 0:a68f7c573e8c 371 char TLV320::gen_samplerate() {
p07gbar 0:a68f7c573e8c 372 char temp = 0;
p07gbar 0:a68f7c573e8c 373 switch(ADC_rate)
p07gbar 0:a68f7c573e8c 374 {
p07gbar 0:a68f7c573e8c 375 case 96000:
p07gbar 0:a68f7c573e8c 376 temp = 0x0E;
p07gbar 0:a68f7c573e8c 377 break;
p07gbar 0:a68f7c573e8c 378 case 48000:
p07gbar 0:a68f7c573e8c 379 temp = 0x00;
p07gbar 0:a68f7c573e8c 380 if(DAC_rate == 8000) temp = 0x02;
p07gbar 0:a68f7c573e8c 381 break;
p07gbar 0:a68f7c573e8c 382 case 32000:
p07gbar 0:a68f7c573e8c 383 temp = 0x0C;
p07gbar 0:a68f7c573e8c 384 break;
p07gbar 0:a68f7c573e8c 385 case 8000:
p07gbar 0:a68f7c573e8c 386 temp = 0x03;
p07gbar 0:a68f7c573e8c 387 if(DAC_rate == 48000) temp = 0x04;
p07gbar 0:a68f7c573e8c 388 break;
p07gbar 0:a68f7c573e8c 389 default:
p07gbar 0:a68f7c573e8c 390 temp = 0x00;
p07gbar 0:a68f7c573e8c 391 break;
p07gbar 0:a68f7c573e8c 392 }
p07gbar 0:a68f7c573e8c 393 return temp;
p07gbar 0:a68f7c573e8c 394 }
p07gbar 0:a68f7c573e8c 395
p07gbar 0:a68f7c573e8c 396