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.
Diff: PreampTDA7419.h
- Revision:
- 2:34a58356394c
- Parent:
- 1:69c37f1ab7df
diff -r 69c37f1ab7df -r 34a58356394c PreampTDA7419.h --- a/PreampTDA7419.h Mon Oct 20 05:54:52 2014 +0000 +++ b/PreampTDA7419.h Sun Oct 26 22:49:34 2014 +0000 @@ -14,11 +14,6 @@ // I2C address for TDA7419 #define TDA7419_ADDRESS 0x44 -#define DEC 10 -#define HEX 16 -#define OCT 8 -#define BIN 2 - /** TDA7419 PreAmp library * * Includes the commands for volume, fader, subwoofer and tone controls @@ -27,44 +22,118 @@ class PreampTDA7419 { public: - /** Create a new Digole Serial Display interface + /** Create a new TDA7419 communication interface * * @param sda is the pin for I2C SDA * @param scl is the pin for I2C SCL - * @param address is the 7-bit address (default is 0x27 for the device) */ PreampTDA7419(PinName sda, PinName scl); - - /** Sets a new I2C address for the Preamp board (perhaps not useful as it is fixed for the TDA4719) - * @param address is the the new address - */ - void setI2CAddress(uint8_t add); - - /** Set up the TDA7419 to default values that will allow audio to pass through the device - * - */ - void initialize(); - int i2c_write(int command, int value); - - /** Set up the TDA7419 to default values that will allow audio to pass through the device - * - */ + + /** Directly set the TDA7419 Master volume (0->11) + * + */ void setVolume (int volume); + /** Read the the TDA7419 Master volume (0->11) + * + */ int readVolume (); + /** Increase the current volume (if below 11) + * + */ int increaseVolume(); + /** Decrease the current volume (if more than 0) + * + */ int decreaseVolume(); + /** Select the input (1->4) + * Stereo inputs are 1->3 + */ void setInput (int input); + /** Read currently selected input + * + */ int readInput (); + /** Increase treble level (-5 -> 5) + * + */ int increaseTreble(); + /** Decrease treble level (-5 -> 5) + * + */ int decreaseTreble(); + /** Read currently set treble level + * + */ int readTreble (); + + /** Increase middle level (-5 -> 5) + * + */ + int increaseMiddle(); + /** Decrease middle level (-5 -> 5) + * + */ + int decreaseMiddle(); + /** Read currently set middle level + * + */ + int readMiddle (); + + /** Increase Bass level (-5 -> 5) + * + */ + int increaseBass(); + /** Decrease bass level (-5 -> 5) + * + */ + int decreaseBass(); + /** Read currently set middle level + * + */ + int readBass (); + + /** Adjust the volume of each channel attenuator + * + * @param speakerNumber + * 1 - left front, + * 2 - right front, + * 3 - back left, + * 4 - back right, + * 5 - subwoofer, + * 6 - volume of mix channel + */ + int increaseSpeaker (int speakerNumber); + /** Adjust the volume of each channel attenuator + * + * @param speakerNumber + * 1 - left front, + * 2 - right front, + * 3 - back left, + * 4 - back right, + * 5 - subwoofer, + * 6 - volume of mix channel + */ + int decreaseSpeaker (int speakerNumber); + + /** Read the value that is currently set for each attenuator + * @param speakerNumber match the increase and decrease parameter values + */ + int readSpeaker (int speakerNumber); + + /** Enable the mix input (by default this mixes to the front two channels + * @return The return is the state of the mix (1 = on, 0 = 0ff) after this call + */ + int toggleMix(); + + /** Read if Mix is enabled or not + * @return The return is the state of the mix (1 = on, 0 = 0ff) after this call + */ + int readMix(); private: // Signals related to I2C communication I2C _device; - uint8_t _address; - uint8_t _Comdelay; //////////////////////////////////// // register addresses for TDA7419 // @@ -97,9 +166,9 @@ int _atten_rr; int _atten_mix; int _atten_sub; - - void writeToTDA7419 (int address, int value); - int calcAttenuationReg (int attenuation); + + void writeToTDA7419 (int command, int value); + void setAttenuationReg (int regAddr, int attenuation); int calcToneAttenuationReg(int attenuation); void updateTDA7419Reg();