This library controls a ST TDA7419 audio control IC. This is part of a project to implement an mbed controlled car stereo. The TDA7419 will take in stereo and output four channels of audio plus a subwoofer channel.

Dependents:   car_stereo

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers PreampTDA7419.h Source File

PreampTDA7419.h

00001 /** TDA7419 PreAmp library, I2C
00002  *
00003  * @Author: Dan Cohen
00004  */
00005 #ifndef DigoleSerialDisp_h
00006 #define DigoleSerialDisp_h
00007  
00008 #include "mbed.h"
00009 #include <inttypes.h>
00010 
00011 ///////////////////////////
00012 // Variables for TDA7419 // 
00013 ///////////////////////////
00014 // I2C address for TDA7419
00015 #define TDA7419_ADDRESS      0x44 
00016  
00017  /** TDA7419 PreAmp library
00018  *
00019  * Includes the commands for volume, fader, subwoofer and tone controls
00020  *
00021  */
00022 class PreampTDA7419 {
00023 public:
00024  
00025     /** Create a new TDA7419 communication interface
00026      *
00027      * @param sda is the pin for I2C SDA
00028      * @param scl is the pin for I2C SCL
00029      */
00030     PreampTDA7419(PinName sda, PinName scl);
00031 
00032     /** Directly set the TDA7419 Master volume (0->11)
00033     * 
00034     */
00035     void setVolume  (int volume);
00036     /** Read the the TDA7419 Master volume (0->11)
00037     * 
00038     */    
00039     int  readVolume ();
00040     /** Increase the current volume (if below 11) 
00041     * 
00042     */        
00043     int  increaseVolume();
00044     /** Decrease the current volume (if more than 0) 
00045     * 
00046     */         
00047     int  decreaseVolume();
00048     /** Select the input (1->4) 
00049     *   Stereo inputs are 1->3 
00050     */          
00051     void setInput   (int input);
00052     /** Read currently selected input
00053     *  
00054     */           
00055     int  readInput  ();
00056 
00057     /** Increase treble level (-5 -> 5)
00058     *  
00059     */        
00060     int  increaseTreble();
00061     /** Decrease treble level (-5 -> 5)
00062     *  
00063     */        
00064     int  decreaseTreble();
00065     /** Read currently set treble level
00066     *  
00067     */            
00068     int  readTreble    ();
00069     
00070     /** Increase middle level (-5 -> 5)
00071     *  
00072     */       
00073     int  increaseMiddle();
00074     /** Decrease middle level (-5 -> 5)
00075     *  
00076     */      
00077     int  decreaseMiddle();
00078     /** Read currently set middle level
00079     *  
00080     */        
00081     int  readMiddle    ();
00082 
00083     /** Increase Bass level (-5 -> 5)
00084     *  
00085     */           
00086     int  increaseBass();
00087     /** Decrease bass level (-5 -> 5)
00088     *  
00089     */        
00090     int  decreaseBass();
00091     /** Read currently set middle level
00092     *  
00093     */    
00094     int  readBass    ();    
00095     
00096     /** Adjust the volume of each channel attenuator
00097     * 
00098     *  @param speakerNumber  
00099     *        1 - left front,
00100     *        2 - right front,
00101     *        3 - back left,
00102     *        4 - back right,
00103     *        5 - subwoofer,
00104     *        6 - volume of mix channel
00105     */          
00106     int  increaseSpeaker (int speakerNumber);
00107     /** Adjust the volume of each channel attenuator
00108     * 
00109     *  @param speakerNumber  
00110     *        1 - left front,
00111     *        2 - right front,
00112     *        3 - back left,
00113     *        4 - back right,
00114     *        5 - subwoofer,
00115     *        6 - volume of mix channel
00116     */              
00117     int  decreaseSpeaker (int speakerNumber);
00118     
00119     /** Read the value that is currently set for each attenuator
00120     *  @param speakerNumber  match the increase and decrease parameter values
00121     */
00122     int  readSpeaker     (int speakerNumber);
00123     
00124     /** Enable the mix input (by default this mixes to the front two channels 
00125     * @return The return is the state of the mix (1 = on, 0 = 0ff) after this call
00126     */
00127     int toggleMix();
00128     
00129     /** Read if Mix is enabled or not
00130     * @return The return is the state of the mix (1 = on, 0 = 0ff) after this call
00131     */    
00132     int readMix();
00133 
00134 private:
00135     // Signals related to I2C communication
00136     I2C _device;
00137     
00138     ////////////////////////////////////
00139     // register addresses for TDA7419 //
00140     ////////////////////////////////////
00141     int _volume;
00142     int _input;
00143 
00144     int _mute;
00145     int _mix;
00146 
00147     // for register 4 Treble Filter
00148     int  _referenceInE;
00149     int  _trebleCenterFreq;
00150     int  _treble;
00151 
00152     // for middle frequecy filter
00153     int  _middleSoftStep;
00154     int  _middleQ;
00155     int  _middle;
00156 
00157     // for bass frequecy filter
00158     int  _bassSoftStep;
00159     int  _bassQ;
00160     int  _bass;
00161 
00162     // for output attenuators
00163     int _atten_lf;
00164     int _atten_rf;
00165     int _atten_lr;
00166     int _atten_rr;
00167     int _atten_mix;
00168     int _atten_sub;
00169     
00170     void writeToTDA7419     (int command, int value);
00171     void setAttenuationReg  (int regAddr, int attenuation);
00172     int  calcToneAttenuationReg(int attenuation);
00173     void updateTDA7419Reg();
00174 
00175 };
00176  
00177 #endif  
00178     
00179     
00180  
00181  
00182  
00183  
00184  
00185  
00186  
00187  
00188  
00189  
00190  
00191