00001 /*This file is prepared for Doxygen automatic documentation generation.*/ 00015 /* Copyright (c) 2009 Atmel Corporation. All rights reserved. 00016 * 00017 * Redistribution and use in source and binary forms, with or without 00018 * modification, are permitted provided that the following conditions are met: 00019 * 00020 * 1. Redistributions of source code must retain the above copyright notice, this 00021 * list of conditions and the following disclaimer. 00022 * 00023 * 2. Redistributions in binary form must reproduce the above copyright notice, 00024 * this list of conditions and the following disclaimer in the documentation 00025 * and/or other materials provided with the distribution. 00026 * 00027 * 3. The name of Atmel may not be used to endorse or promote products derived 00028 * from this software without specific prior written permission. 00029 * 00030 * 4. This software may only be redistributed and used in connection with an Atmel 00031 * AVR product. 00032 * 00033 * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 00034 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 00035 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 00036 * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR 00037 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 00038 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00039 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 00040 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00041 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00042 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE 00043 * 00044 */ 00045 00046 #ifndef _TPA6130_H_ 00047 #define _TPA6130_H_ 00048 00049 #include <stddef.h> 00050 #include "compiler.h" 00051 00052 /* Set TPA6130_MODE to one of the following selections 00053 * TPA6130_MODE_STEREO, left and right channels are connected to DAC 00054 * TPA6130_MODE_DUAL_MONO, left channel is connected but this signal is 00055 * used to feed both amplifiers for right and left channel output 00056 * TPA6130_MONO_L, only left channel is used with the DAC 00057 * TPA6130_MONO_R, only right channel is used with the DAC 00058 */ 00059 #define TPA6130_MODE_STEREO 0 00060 #define TPA6130_MODE_MONO 1 00061 /* 00062 #define TPA6130_MODE_MONO_L 2 00063 #define TPA6130_MODE_MONO_R 3 00064 */ 00065 /* Set TPA6130_SIG to: 00066 * TPA6130_SIG_DIFF, both, normal and inverted, signales are used from the DAC 00067 * TPA6130_SIG_POS, uses only the positive signals from the DAC 00068 */ 00069 00070 #define TPA6130_SIG_DIFF 0 00071 #define TPA6130_SIG_POS 1 00072 00073 00074 /*#define TPA6130_SIG_NEG 2*/ 00075 00076 /* TWI slave address of the amplifier 00077 * This device has a fixed slave address. 00078 * -> No hardware option to change it 00079 */ 00080 #define TPA6130_TWI_ADDRESS 0x60 00081 00082 00085 00086 00087 #define TPA6130_VOL_MIN ((S8)( 0)) // -59dB 00088 #define TPA6130_VOL_MAX ((S8)( 63)) // : +4dB 00089 00091 00092 00098 extern void tpa6130_dac_setup(U32 sample_rate_hz, 00099 U8 num_channels, 00100 U8 bits_per_sample, 00101 Bool swap_channels, 00102 void (*callback)(U32 arg), 00103 U32 callback_opt, 00104 U32 pba_hz); 00105 00106 00107 extern void tpa6130_dac_start(U32 sample_rate_hz, 00108 U8 num_channels, 00109 U8 bits_per_sample, 00110 Bool swap_channels, 00111 void (*callback)(U32 arg), 00112 U32 callback_opt, 00113 U32 pba_hz); 00114 00119 extern Bool tpa6130_dac_output(void *sample_buffer, size_t sample_length); 00120 00123 extern U8 tpa6130_dac_get_volume(void); 00124 00127 extern void tpa6130_dac_set_volume(U8 volume); 00128 00133 extern void tpa6130_dac_increase_volume(void); 00134 00139 extern void tpa6130_dac_decrease_volume(void); 00140 00143 extern void tpa6130_dac_flush(void); 00144 00147 extern void tpa6130_dac_stop(void); 00148 00154 extern void tpa6130_set_volume(S8 volume); 00155 00160 extern Bool tpa6130_dac_is_volume_muted(void); 00161 00166 extern Bool tpa6130_dac_is_volume_boosted(void); 00167 00172 extern S8 tpa6130_get_volume(void); 00173 00177 extern void tpa6130_shutdown(void); 00178 00182 extern void tpa6130_powerup(void); 00183 00187 extern void tpa6130_dac_mute(Bool mute); 00188 00201 extern S8 tpa6130_init(void); 00202 00203 #endif // _TPA6130_H_ 00204