目前在做TMS320C5517 开发板的测试工作,上面有两个AIC3204模块,
现在是想让声音从AIC3204-1的麦克风输入,然后从AIC3204-1和AIC3204-2
的3.5mm耳机接口同时输出,意思就是单通道输入多通道输出。但是 ti得测试程序只能单独运行一个AIC3204,也就是单输入单输出,想请各位大神帮帮忙。下面分别是两个AIC3204的测试程序
//AIC3204-1 #define AIC3204_I2C_ADDR 0x18 #include "evm5517.h"
- #include "evm5517_gpio.h"
- #include "evm5517_i2c.h"
- #include "evm5517_i2cgpio.h"
- #include "stdio.h"
extern Int16 aic3204_tone_headphone( );
- extern Int16 aic3204_tone_stereo_out( );
- extern Int16 aic3204_loop_stereo_in1( );
- extern Int16 aic3204_loop_stereo_in2( );
- extern Int16 aic3204_loop_mic_in( );
/*
- *
- * AIC3204_rget( regnum, regval )
- *
- * Return value of codec register regnum
- *
- */
- Int16 AIC3204_rget( Uint16 regnum, Uint16* regval )
- {
- Int16 retcode = 0;
- Uint8 cmd[2];
cmd[0] = regnum & 0x007F; // 7-bit Device Address
- cmd[1] = 0;
retcode |= EVM5517_I2C_write( AIC3204_I2C_ADDR, cmd, 1 );
- retcode |= EVM5517_I2C_read( AIC3204_I2C_ADDR, cmd, 1 );
*regval = cmd[0];
- EVM5517_wait( 10 );
- return retcode;
- }
/*
- *
- * AIC3204_rset( regnum, regval )
- *
- * Set codec register regnum to value regval
- *
- */
- Int16 AIC3204_rset( Uint16 regnum, Uint16 regval )
- {
- Uint8 cmd[2];
- cmd[0] = regnum & 0x007F; // 7-bit Register Address
- cmd[1] = regval; // 8-bit Register Data
return EVM5517_I2C_write( AIC3204_I2C_ADDR, cmd, 2 );
- }
/*
- *
- * aic3204_test( )
- *
- */
- Int16 aic3204_test( )
- {
/* Test Instructions */
- printf("For this test, make sure J27 (1-3=Off, 2-4=Off)n");
- printf(" J28 (1-3=Off, 2-4=Off)n");
- printf(" J29 (1-3=On, 2-4=On)n");
- printf(" J30 (1-3=On, 2-4=On)nn");
/* Configure Serial Port 0 */
- SYS_EXBUSSEL &= ~0x0300; //
- SYS_EXBUSSEL |= 0x0100; // Serial Port mode 1 (I2S1 and GP[11:10]).
/* Configure I2C mux for AIC3204-1 */
- EVM5517_I2CGPIO_configLine( 2, 0 );
- EVM5517_I2CGPIO_writeLine( 2, 0 ); // SEL_I2C_S0 = 0
EVM5517_I2CGPIO_configLine( 3, 0 );
- EVM5517_I2CGPIO_writeLine( 3, 0 ); // SEL_I2C_S1 = 0
/* Set AIC_MCBSP_MODE to I2S (disable McBSP) */
- EVM5517_I2CGPIO_configLine( 1, 0 );
- EVM5517_I2CGPIO_writeLine( 1, 1 ); // AIC_MCBSP_MODE = 1
/* Set SEL_MMC0_I2S to I2S */
- EVM5517_I2CGPIO_configLine( 8, 0 );
- EVM5517_I2CGPIO_writeLine( 8, 1 ); // SEL_MMC0_I2S = 1
-
- /* Release AIC3204 reset */
- EVM5517_I2CGPIO_configLine( 0, 0 );
- EVM5517_I2CGPIO_writeLine( 0, 0 ); // AIC_RST = 0
/* Codec tests */
- printf( " -> 1 KHz Tone on Headphone.n" );
- if ( aic3204_tone_headphone( ) )
- return 1;
-
- EVM5517_wait( 100 ); // Wait
- printf( " -> 1 KHz Tone on Stereo OUT.n" );
- if ( aic3204_tone_stereo_out( ) )
- return 1;
-
- EVM5517_wait( 100 ); // Wait
- printf( "<-> Audio Loopback from Stereo IN 1 --> to HPn" );
- if ( aic3204_loop_stereo_in1( ) )
- return 1;
-
- EVM5517_wait( 100 ); // Wait
- printf( "<-> Audio Loopback from Stereo IN 2 --> to Stereo OUTn" );
- if ( aic3204_loop_stereo_in2( ) )
- return 1;
-
- EVM5517_wait( 100 ); // Wait
- printf( "<-> Microphone --> to HPn" );
- if ( aic3204_loop_mic_in( ) )
- return 1;
EVM5517_GPIO_setOutput( GPIO26, 0 );
- return 0;
- }
//AIC3204-2 #define AIC3204_I2C_ADDR 0x18 #include "evm5517.h"
- #include "evm5517_gpio.h"
- #include "evm5517_i2c.h"
- #include "evm5517_i2cgpio.h"
- #include "stdio.h"
extern Int16 aic3204_tone_headphone( );
- extern Int16 aic3204_tone_stereo_out( );
- extern Int16 aic3204_loop_stereo_in1( );
- extern Int16 aic3204_loop_stereo_in2( );
- extern Int16 aic3204_loop_mic_in( );
/*
- *
- * AIC3204_rget( regnum, regval )
- *
- * Return value of codec register regnum
- *
- */
- Int16 AIC3204_rget( Uint16 regnum, Uint16* regval )
- {
- Int16 retcode = 0;
- Uint8 cmd[2];
cmd[0] = regnum & 0x007F; // 7-bit Device Address
- cmd[1] = 0;
retcode |= EVM5517_I2C_write( AIC3204_I2C_ADDR, cmd, 1 );
- retcode |= EVM5517_I2C_read( AIC3204_I2C_ADDR, cmd, 1 );
*regval = cmd[0];
- EVM5517_wait( 10 );
- return retcode;
- }
/*
- *
- * AIC3204_rset( regnum, regval )
- *
- * Set codec register regnum to value regval
- *
- */
- Int16 AIC3204_rset( Uint16 regnum, Uint16 regval )
- {
- Uint8 cmd[2];
- cmd[0] = regnum & 0x007F; // 7-bit Register Address
- cmd[1] = regval; // 8-bit Register Data
return EVM5517_I2C_write( AIC3204_I2C_ADDR, cmd, 2 );
- }
/*
- *
- * aic3204_test( )
- *
- */
- Int16 aic3204_test( )
- {
- Uint16 regval;
- Int16 i;
/* Test Instructions */
- printf("For this test, make sure J27 (1-3=Off, 2-4=Off)n");
- printf(" J28 (1-3=Off, 2-4=Off)n");
- printf(" J29 (1-3=On, 2-4=On)n");
- printf(" J30 (1-3=On, 2-4=On)nn");
/* Configure Serial Port 0 */
- SYS_EXBUSSEL &= ~0x7300; //
- SYS_EXBUSSEL |= 0x4100; // Enable I2S2 pins
/* Configure I2C mux for AIC3204-2 */
- EVM5517_I2CGPIO_configLine( 2, 0 );
- EVM5517_I2CGPIO_writeLine( 2, 1 ); // SEL_I2C_S0 = 1
EVM5517_I2CGPIO_configLine( 3, 0 );
- EVM5517_I2CGPIO_writeLine( 3, 0 ); // SEL_I2C_S1 = 0
// EVM5517_I2CGPIO_configLine( 4, 0 );
- // EVM5517_I2CGPIO_writeLine( 4, 0 ); // HPI_ON = 0
/* Configure SPI2 mux for AIC3204-2 */
- EVM5517_I2CGPIO_configLine( 5, 0 );
- EVM5517_I2CGPIO_writeLine( 5, 1 ); // SPI_I2S2_S0 = 1
EVM5517_I2CGPIO_configLine( 6, 0 );
- EVM5517_I2CGPIO_writeLine( 6, 1 ); // SPI_I2S2_S1 = 1
/* Release AIC3204 reset */
- EVM5517_I2CGPIO_configLine( 0, 0 );
- EVM5517_I2CGPIO_writeLine( 0, 0 ); // AIC_RST = 0
/* Codec tests */
- printf( " -> 1 KHz Tone on Headphone.n" );
- if ( aic3204_tone_headphone( ) )
- return 1;
-
- EVM5517_wait( 100 ); // Wait
- printf( " -> 1 KHz Tone on Stereo OUT.n" );
- if ( aic3204_tone_stereo_out( ) )
- return 1;
-
- EVM5517_wait( 100 ); // Wait
- printf( "<-> Audio Loopback from Stereo IN 1 --> to HPn" );
- if ( aic3204_loop_stereo_in1( ) )
- return 1;
-
- EVM5517_wait( 100 ); // Wait
- printf( "<-> Audio Loopback from Stereo IN 2 --> to Stereo OUTn" );
- if ( aic3204_loop_stereo_in2( ) )
- return 1;
-
- EVM5517_wait( 100 ); // Wait
- printf( "<-> Microphone --> to HPn" );
- if ( aic3204_loop_mic_in( ) )
- return 1;
EVM5517_GPIO_setOutput( GPIO26, 0 );
- return 0;
- }
复制代码
0
已退回2积分
|
|
|
|