1

Тема: TDA7449

Данный контент доступен только зарегистрированным пользователям.


TDA7449.h

//VS Supply voltage 6 9 10.2 V
//VCL Max input signal handling 2 VRMS
//THD Total harmonic distortion V = 0.1 Vrms f = 1 kHz 0.01 0.1 %
//S/N Signal-to-noise ratio Vout = 1 Vrms (mode = OFF) 106 dB
//SC Channel separation f = 1 KHz 90 dB
//Input gain (2 dB step) 0 30 dB
//Volume control (1 dB step) -47 0 dB
//Treble control (2 dB step) -14 14 dB
//Bass control (2 dB step) -14 14 dB
//Balance control 1 dB step -79 0 dB
//Mute attenuation 100 dB
////////////////////////////////////////////////////////////////////////////
// TDA7449 | rcl-radio.ru | liman324@yandex.ru | Автор: Лиман А.А.
// Пример использования - http://rcl-radio.ru/?p=56015

#ifndef TDA7449_H
#define TDA7449_H
// address 7 bit
#define TDA7449_address 0x44 // адрес HEX 88 > 0b10001000 > 7 bit = 0b1000100 = 0x44

//Sub addresses
#define TDA7449_INP_SEL    0b00000000
#define TDA7449_INP_GAIN   0b00000001
#define TDA7449_VOLUME     0b00000010
#define TDA7449_BASS       0b00000100
#define TDA7449_TREBLE     0b00000101
#define TDA7449_ATT_RIGHT  0b00000110
#define TDA7449_ATT_LEFT   0b00000111

#include <Arduino.h>
class TDA7449
{
  public:
    TDA7449();
        void setInput(int input); //        int 1...2 //// номер входа
	void inputGain(int gain); //        int 0...15 (шаг 2дБ)    0...30 дБ  //// усиление
	void setVolume(int volume); //      int 0...47 (шаг 1 дБ)  -47...0 дБ  //// громкость
        void setBass(int bass); //          int -7...+7 (шаг 2 дБ) -14...14 дБ //// тембр НЧ
        void setTreble(int treble); //      int -7...+7 (шаг 2 дБ) -14...14 дБ //// тембр ВЧ
/////////////////////// для регулировки баланса до -79 дБ /////////////////////////////////
        void setAttL(int att_l); //         int 0...72 (шаг 1дБ)    -72...0 дБ 
        void setAttR(int att_r); //         int 0...72 (шаг 1дБ)    -72...0 дБ
/////////////////////////////////////////////////////////////////////////////////	
  private:
	void writeWire(char a, char b);
};
	
#endif //TDA7449_H

TDA7449.cpp

#include <Arduino.h>
#include <Wire.h>
#include "TDA7449.h"

TDA7449::TDA7449(){
	Wire.begin();
}

void TDA7449::setVolume(int volume){
  volume = 47 - volume;
  writeWire(TDA7449_VOLUME, volume);
}

void TDA7449::setBass(int bass){
  switch (bass){
        case -7:bass = 0;break;
	case -6:bass = 1;break;
	case -5:bass = 2;break;
	case -4:bass = 3;break;
	case -3:bass = 4;break;
	case -2:bass = 5;break;
	case -1:bass = 6;break;
	case 0 :bass = 15;break;
	case 1 :bass = 14;break;
	case 2 :bass = 13;break;
	case 3 :bass = 12;break;
	case 4 :bass = 11;break;
	case 5 :bass = 10;break;
	case 6 :bass = 9;break;
	case 7 :bass = 8;break;}
  writeWire(TDA7449_BASS, bass);
}

void TDA7449::setTreble(int treble){
  switch (treble){
        case -7:treble = 0;break;
	case -6:treble = 1;break;
	case -5:treble = 2;break;
	case -4:treble = 3;break;
	case -3:treble = 4;break;
	case -2:treble = 5;break;
	case -1:treble = 6;break;
	case 0 :treble = 15;break;
	case 1 :treble = 14;break;
	case 2 :treble = 13;break;
	case 3 :treble = 12;break;
	case 4 :treble = 11;break;
	case 5 :treble = 10;break;
	case 6 :treble = 9;break;
	case 7 :treble = 8;break;}
  writeWire(TDA7449_TREBLE, treble);
}

void TDA7449::setInput(int input){
  switch (input) {
        case 1: input = 0x02;break;
	case 2: input = 0x03;break;}
  writeWire(TDA7449_INP_SEL,input);	
  } 

void TDA7449::inputGain(int gain){
  writeWire(TDA7449_INP_GAIN, gain);
}

void TDA7449::setAttR(int att_r){
  writeWire(TDA7449_ATT_RIGHT, att_r);
}

void TDA7449::setAttL(int att_l){
  writeWire(TDA7449_ATT_LEFT, att_l);
}

void TDA7449::writeWire(char a, char b){
  Wire.beginTransmission(TDA7449_address);
  Wire.write (a);
  Wire.write (b);
  Wire.endTransmission();
}

tda7449.ino

#include <Wire.h>
#include <TDA7449.h>
  TDA7449 tda;

void setup(){ 
  Serial.begin(9600);Wire.begin();
}

void loop(){
  audio();
  delay(1000);
}

void audio(){
  tda.setInput(1); //         int 1...2 //// номер входа
  tda.inputGain(0); //        int 0...15 (шаг 2дБ)    0...30 дБ  //// усиление
  tda.setVolume(30); //       int 0...47 (шаг 1 дБ)  -47...0 дБ  //// громкость
  tda.setBass(0); //          int -7...+7 (шаг 2 дБ) -14...14 дБ //// тембр НЧ
  tda.setTreble(0); //        int -7...+7 (шаг 2 дБ) -14...14 дБ //// тембр ВЧ
  tda.setAttL(10); //          int 0...72 (шаг 1дБ)    -72...0 дБ 
  tda.setAttR(10); //          int 0...72 (шаг 1дБ)    -72...0 дБ
}

Библиотека по работе с микросхемой TDA7449 из среды Arduino Пример использования http://rcl-radio.ru/?p=56015