WavPlayer.h changed to circuit board

Dependents:   WavPlayerSD WavPlayerUSB WavPlayerUSB WavPlayerSD_CB

Committer:
JostBaus
Date:
Sun Apr 14 16:22:17 2019 +0000
Revision:
4:b0186c8dca92
Parent:
1:3eb96771bbee
Changed pins to match the circuit board, Replaced the wav_player.h lib with another one

Who changed what in which revision?

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