Тема: TDA7461
http://forum.rcl-radio.ru/uploads/image … 7e1373.pdf
Требуется тестирование!!!
TDA7461.h
// liman324@yandex.ru
// rcl-radio.ru
#ifndef TDA7461_H
#define TDA7461_H
// address 7 bit
#define TDA7461_address 0b1000110
//Sub addresses
#define TDA7461_INPUT 0b0000 // Input selector
#define TDA7461_LOUD 0b0001 // Loudness / Auto-Zero
#define TDA7461_VOLUME 0b0010 // Volume
#define TDA7461_SOFT_MUTE 0b0011 // Softmute / Beep
#define TDA7461_BASS_TREB_ATT 0b0100 // Bass / Treble Attenuator
#define TDA7461_BASS_TREB_CONF 0b0101 // Bass / Treble Configuration
#define TDA7461_LF_ATT 0b0110 // Speaker attenuator LF
#define TDA7461_LR_ATT 0b0111 // Speaker attenuator LR
#define TDA7461_RF_ATT 0b1000 // Speaker attenuator RF
#define TDA7461_RR_ATT 0b1001 // Speaker attenuator RR / Blank time adjust
#define TDA7461_STEREO_DEC 0b1010 // Stereo decoder
#define TDA7461_NOISE_BLANKER 0b1011 // Noise blanker
#define TDA7461_FIELD_CONTR 0b1100 // Fieldstrength Control
#define TDA7461_CONF 0b1101 // Configuration
#define TDA7461_STEREO_DEC_ADJ 0b1110 // Stereo decoder Adjustment
#define TDA7461_TEST 0b1111 // Testing
#include <Arduino.h>
class TDA7461
{
public:
TDA7461();
/// Input selector
void setInput(int source, bool cd, int am_fm, int in_gain);
// int source = 0...7 >>> CD
// Cassette
// Phone
// AM
// Stereo Decoder
// Input FM
// Mute
// AC inputs
// bool cd = 0...1 >>> CD Full-differential...CD Quasi-diff
// int am_fm = 0...3 >>> AM mono
// AM stereo
// AM through Stereo decoder
// FM- Stereo decoder
// int in_gain = 0...7 >>> 14...0 dB step 2 dB
/// Loudness
void setLoudness(int loud_att, bool loud_filter, bool loud_f, bool loud_q);
// int loud_att = 0...15 >>> 0...-15 dB
// bool loud_filter = 0...1 >>> on...off
// bool loud_f = 0...1 >>> 200...400 Hz
// bool loud_q = 0...1 >>> low...normal
/// Mute, Beep and Mixing
void setSoftmute(bool mute, int mute_time, bool stereo_dec, bool beep, bool mixing_0, int mixing_1);
// int mute = 0...1 >>> Softmute = Enable...Disable
// int mute_time 0...3 >> Mute time = 0.48, 0.96, 40.4, 324 ms
// bool stereo_dec = 0...1 >>> Stereo decoder softmute influence = off...on
// bool beep = 0...1 >>> Beep Frequency = 600 Hz...1.2 kHz
// bool mixing_0 = 0...1 >>> Mix-Source = Beep...Phone
// bool mixing_1 = 0...3 >>> Full Mix Signal
// Source -12 dB + Mix-Signal -2.5 dB
// Source -6 dB + Mix-Signal -6 dB
// Full Source
/// Volume
void setVolume(int vol, bool soft_step);
// int vol = 0...111 >>> +32...-79 dB
// bool soft_step = 0...1 >>> Soft step volume = off...on
/// Bass and treble attenuation
void setBassTreb(int bass, int treb);
// int bass = -14...14 >>> -14...+14 dB step 2 dB
// int treb = -14...14 >>> -14...+14 dB step 2 dB
/// Bass and treble filter characteristics
void setBassTrebConf(int treb_f, int bass_f, int bass_q, bool dc_gain, bool ac_coupling);
// int treb_f = 0...3 >>> 10, 12.5, 15, 17.5 kHz
// int bass_f = 0...4 >>> 60, 70, 80, 100, 150 Hz
// int bass_q = 0...3 >>> 1, 1.25, 1.5, 2
// bool dc_gain 0...1 >>> DC-Gain = 0 dB ... ±4.4 dB
// bool ac_coupling = 0...1 >>> For External Connection...Internally Connection
/// ATT (LF, LR, RF, RR)
void attLF(int lf); // int 0...31 >>> 0...-50 dB
void attLR(int lr); // int 0...31 >>> 0...-50 dB
void attRF(int rf); // int 0...31 >>> 0...-50 dB
void attRR(int rr); // int 0...31 >>> 0...-50 dB
/// Stereo decoder
void setStereo(bool std, int in_gain_dec, bool dec, bool mono_stereo, bool pilot, bool emp);
// bool std = 0..1 >>> STD unmuted...muted
// int in_gain_dec = 0...3 >>> IN-Gain 11, 8.5, 6, 3.5 dB
// bool dec = 0...1 >>> Stereo decoder Unmuted with Stdec.
// Stereo decoder Unmuted whichever is the selected source.
// bool mono_stereo = 0...1 >>> Forced mono...Mono/stereo switch automatically
// bool pilot = 0...1 >>> Pilot threshold high...low
// bool emp = 0...1 >>> De-emphasis 50...75 μs
/// Noise blanker
void setBlanker(int threshold_0, int threshold_1, bool blank, int over);
// int threshold_0 = 0...7 >>> Low threshold 65, 60, 55, 50, 45, 40, 35, 30 mV
// int threshold_1 = 0...3 >>> Noise controlled threshold 320, 260, 200, 140 mV
// bool blank = 0...1 >>> Noise blanker off...on
// int over = 0...3 >>> Over deviation adjust 2.8V, 2.0V, 1.2V, off
/// Field strength control
void setField(int adj, int vsbl, int vhch, bool vhcl, bool cut);
// int adj = 0...3 >>> Noise blanker Field strength Adj 2.3V, 1.8V, 1.3V, off
// int vsbl = 0...3 >>> VSBL at 33%, 42%, 50%, 58%
// int vhch = 0...3 >>> VHCH at 42%, 50%, 58%, 66%
// bool vhcl = 0...1 >>> VHCL at 17%, 33%
// bool cut = 0...1 >>> High cut OFF...ON
/// Configuration
void setConf(int rez, int band_gain, bool mult, int mult_gain);
// int rez = 0...3 >>> infinite, 56kOm, 33kOm, 18kOm
// int band_gain = 0...3 >>> 6, 16, 12, 18 dB
// bool mult = 0...1 >>> Multipath detector internal influence On...Off
// int mult_gain = 0...3 >>> Gain = 7.6 dB 4.6 dB, 0 dB, Off
/// Stereo decoder adjustment
void setSDecoder(int compens, int level_gain, bool temp);
// int compens = 0...7 >>> not...31%
// int level_gain = 0...15 >>> 0...10 dB step 0.66dB
// bool temp = 0...1 >>> TC = 0...16.7 mV/K (3300 ppm)
/// Testing
void setTest(byte test);
// default test = 0b11111110 (Table 25)
private:
void writeWire(byte a, byte b);
};
#endif //TDA7461_H
TDA7461.cpp
#include <Arduino.h>
#include <Wire.h>
#include "TDA7461.h"
TDA7461::TDA7461(){
Wire.begin();
}
void TDA7461::setInput(int source, bool cd, int am_fm, int in_gain){
byte data_ = (in_gain << 5)+(am_fm << 4)+(cd << 3)+source;
writeWire(TDA7461_INPUT,data_);
}
void TDA7461::setLoudness(int loud_att, bool loud_filter, bool loud_f, bool loud_q){
byte data_= 0b10000000+(loud_q << 6)+(loud_f << 5)+(loud_filter << 4)+loud_att;
writeWire(TDA7461_LOUD,data_);
}
void TDA7461::setSoftmute(bool mute, int mute_time, bool stereo_dec, bool beep, bool mixing_0, int mixing_1){
byte data_= (mixing_1 << 6)+(mixing_0 << 5)+(beep << 4)+(stereo_dec << 3)+(mute_time << 1)+mute;
writeWire(TDA7461_SOFT_MUTE,data_);
}
void TDA7461::setVolume(int vol, bool soft_step){
byte data_= (soft_step << 7)+vol;
writeWire(TDA7461_VOLUME,data_);
}
void TDA7461::setBassTreb(int bass, int treb){
switch(treb){
case -14: treb = 0b0000;break;
case -12: treb = 0b0001;break;
case -10: treb = 0b0010;break;
case -8 : treb = 0b0011;break;
case -6 : treb = 0b0100;break;
case -4 : treb = 0b0101;break;
case -2 : treb = 0b0110;break;
case -0 : treb = 0b0111;break;
case 2 : treb = 0b1110;break;
case 4 : treb = 0b1101;break;
case 6 : treb = 0b1100;break;
case 8 : treb = 0b1011;break;
case 10: treb = 0b1010;break;
case 12: treb = 0b1001;break;
case 14: treb = 0b1000;break;
}
switch(bass){
case -14: bass = 0b0000;break;
case -12: bass = 0b0001;break;
case -10: bass = 0b0010;break;
case -8 : bass = 0b0011;break;
case -6 : bass = 0b0100;break;
case -4 : bass = 0b0101;break;
case -2 : bass = 0b0110;break;
case -0 : bass = 0b0111;break;
case 2 : bass = 0b1110;break;
case 4 : bass = 0b1101;break;
case 6 : bass = 0b1100;break;
case 8 : bass = 0b1011;break;
case 10: bass = 0b1010;break;
case 12: bass = 0b1001;break;
case 14: bass = 0b1000;break;
}
byte data_ = (bass << 4)+treb;
writeWire(TDA7461_BASS_TREB_ATT,data_);
}
void TDA7461::setBassTrebConf(int treb_f, int bass_f, int bass_q, bool dc_gain, bool ac_coupling){
byte data_ = (ac_coupling << 7)+(dc_gain << 6)+(bass_q << 4)+(bass_f << 2)+treb_f;
writeWire(TDA7461_BASS_TREB_CONF,data_);
}
void TDA7461::attLF(int lf){byte data_ = 0b11000000+lf;writeWire(TDA7461_LF_ATT,data_);}
void TDA7461::attLR(int lr){byte data_ = 0b11000000+lr;writeWire(TDA7461_LR_ATT,data_);}
void TDA7461::attRF(int rf){writeWire(TDA7461_RF_ATT,rf);}
void TDA7461::attRR(int rr){writeWire(TDA7461_RR_ATT,rr);}
void TDA7461::setStereo(bool std, int in_gain_dec, bool dec, bool mono_stereo, bool pilot, bool emp){
byte data_ = (emp << 7)+(pilot << 6)+(mono_stereo << 5)+(1 << 4)+(dec << 3)+(in_gain_dec << 1)+std;
writeWire(TDA7461_STEREO_DEC,data_);
}
void TDA7461::setBlanker(int threshold_0, int threshold_1, bool blank, int over){
byte data_ = (over << 6)+(blank << 5)+(threshold_1 << 3)+threshold_0;
writeWire(TDA7461_NOISE_BLANKER,data_);
}
void TDA7461::setField(int adj, int vsbl, int vhch, bool vhcl, bool cut){
byte data_ = (cut << 7)+(vhcl << 6)+(vhch << 4)+(vsbl << 2)+adj;
writeWire(TDA7461_FIELD_CONTR,data_);
}
void TDA7461::setConf(int rez, int band_gain, bool mult, int mult_gain){
byte data_ = (mult_gain << 6)+(1 << 5)+(mult << 4)+(band_gain << 2)+rez;
writeWire(TDA7461_CONF,data_);
}
void TDA7461::setSDecoder(int compens, int level_gain, bool temp){
byte data_ = (temp << 7)+(level_gain << 3)+compens;
writeWire(TDA7461_STEREO_DEC_ADJ,data_);
}
void TDA7461::setTest(byte test){writeWire(TDA7461_TEST,test);}
void TDA7461::writeWire(byte a, byte b){
Wire.beginTransmission(TDA7461_address);
Wire.write (a);
Wire.write (b);
Wire.endTransmission();
}
test.ino
#include <Wire.h>
#include <TDA7461.h>
TDA7461 tda;
void setup(){
Serial.begin(9600);
Wire.begin();
}
void loop(){
audio();
delay(1000);
}
void audio(){
/// Input selector
tda.setInput(0, 0, 0, 0);
// int source = 0...7 >>> CD
// Cassette
// Phone
// AM
// Stereo Decoder
// Input FM
// Mute
// AC inputs
// bool cd = 0...1 >>> CD Full-differential...CD Quasi-diff
// int am_fm = 0...3 >>> AM mono
// AM stereo
// AM through Stereo decoder
// FM- Stereo decoder
// int in_gain = 0...15 >>> 14...0 dB step 2 dB
/// Loudness
tda.setLoudness(0, 0, 0, 0);
// int loud_att = 0...15 >>> 0...-15 dB
// bool loud_filter = 0...1 >>> on...off
// bool loud_f = 0...1 >>> 200...400 Hz
// bool loud_q = 0...1 >>> low...normal
/// Mute, Beep and Mixing
tda.setSoftmute(1, 0, 1, 0, 0, 0);
// int mute = 0...1 >>> Softmute = Enable...Disable
// int mute_time 0...3 >> Mute time = 0.48, 0.96, 40.4, 324 ms
// bool stereo_dec = 0...1 >>> Stereo decoder softmute influence = off...on
// bool beep = 0...1 >>> Beep Frequency = 600 Hz...1.2 kHz
// bool mixing_0 = 0...1 >>> Mix-Source = Beep...Phone
// bool mixing_1 = 0...3 >>> Full Mix Signal
// Source -12 dB + Mix-Signal -2.5 dB
// Source -6 dB + Mix-Signal -6 dB
// Full Source
/// Volume
tda.setVolume(32, 1);
// int vol = 0...111 >>> +32...-79 dB
// bool soft_step = 0...1 >>> Soft step volume = off...on
/// Bass and treble attenuation
tda.setBassTreb(0, 0);
// int bass = -14...14 >>> -14...+14 dB step 2 dB
// int treb = -14...14 >>> -14...+14 dB step 2 dB
/// Bass and treble filter characteristics
tda.setBassTrebConf(0, 0, 0, 0, 0);
// int treb_f = 0...3 >>> 10, 12.5, 15, 17.5 kHz
// int bass_f = 0...4 >>> 60, 70, 80, 100, 150 Hz
// int bass_q = 0...3 >>> 1, 1.25, 1.5, 2
// bool dc_gain 0...1 >>> DC-Gain = 0 dB ... ±4.4 dB
// bool ac_coupling = 0...1 >>> For External Connection...Internally Connection
/// ATT (LF, LR, RF, RR)
tda.attLF(0); // int 0...31 >>> 0...-50 dB
tda.attLR(0); // int 0...31 >>> 0...-50 dB
tda.attRF(0); // int 0...31 >>> 0...-50 dB
tda.attRR(0); // int 0...31 >>> 0...-50 dB
/// Stereo decoder
tda.setStereo(0, 0, 0, 1, 1, 0);
// bool std = 0..1 >>> STD unmuted...muted
// int in_gain_dec = 0...3 >>> IN-Gain 11, 8.5, 6, 3.5 dB
// bool dec = 0...1 >>> Stereo decoder Unmuted with Stdec.
// Stereo decoder Unmuted whichever is the selected source.
// bool mono_stereo = 0...1 >>> Forced mono...Mono/stereo switch automatically
// bool pilot = 0...1 >>> Pilot threshold high...low
// bool emp = 0...1 >>> De-emphasis 50...75 μs
/// Noise blanker
tda.setBlanker(0, 0, 0, 3);
// int threshold_0 = 0...7 >>> Low threshold 65, 60, 55, 50, 45, 40, 35, 30 mV
// int threshold_1 = 0...3 >>> Noise controlled threshold 320, 260, 200, 140 mV
// bool blank = 0...1 >>> Noise blanker off...on
// int over = 0...3 >>> Over deviation adjust 2.8V, 2.0V, 1.2V, off
/// Field strength control
tda.setField(3, 0, 0, 0, 0);
// int adj = 0...3 >>> Noise blanker Field strength Adj 2.3V, 1.8V, 1.3V, off
// int vsbl = 0...3 >>> VSBL at 33%, 42%, 50%, 58%
// int vhch = 0...3 >>> VHCH at 42%, 50%, 58%, 66%
// bool vhcl = 0...1 >>> VHCL at 17%, 33%
// bool cut = 0...1 >>> High cut OFF...ON
/// Configuration
tda.setConf(0, 0, 1, 3);
// int rez = 0...3 >>> infinite, 56kOm, 33kOm, 18kOm
// int band_gain = 0...3 >>> 6, 16, 12, 18 dB
// bool mult = 0...1 >>> Multipath detector internal influence On...Off
// int mult_gain = 0...3 >>> Gain = 7.6 dB 4.6 dB, 0 dB, Off
/// Stereo decoder adjustment
tda.setSDecoder(0,0, 1);
// int compens = 0...7 >>> not...31%
// int level_gain = 0...15 >>> 0...10 dB step 0.66dB
// bool temp = 0...1 >>> TC = 0...16.7 mV/K (3300 ppm)
/// Testing
tda.setTest(0b11111110);
// default test = 0b11111110 (Table 25)
}
Данный контент доступен только зарегистрированным пользователям.