⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tone.c

📁 給 DSK5510 DIP LED AIC23
💻 C
字号:
/************************************************************
* init.asm
*-----------------------------------------------------------
* Objective:
*	1) Understand the DSP/BIOS, McBSP, and AIC chip;
*   2) Understand the peripheral settings of DSK5510.
*-----------------------------------------------------------
* By Jwusheng Hu, Tzung-Min Su, Wei-Han Liu, Ming-Chien Tsai
*  	 			                       CopyRight  2004/08/03
************************************************************/

#include "tonecfg.h"
#include <stdio.h>
/*
 *  The 5510 DSK Board Support Library is divided into several modules, each
 *  of which has its own include file.  The file dsk5510.h must be included
 *  in every program that uses the BSL.  This example also includes
 *  dsk5510_aic23.h because it uses the AIC23 codec module.
 */
#include "dsk5510.h"
#include "dsk5510_led.h"
#include "dsk5510_dip.h"
#include "dsk5510_aic23.h"

/* Codec configuration settings */
DSK5510_AIC23_Config config = { 
    0x0017,  /* 0 DSK5510_AIC23_LEFTINVOL  Left line input channel volume */ 
    0x0017,  /* 1 DSK5510_AIC23_RIGHTINVOL Right line input channel volume */
    0x01f9,  /* 2 DSK5510_AIC23_LEFTHPVOL  Left channel headphone volume */  
    0x01f9,  /* 3 DSK5510_AIC23_RIGHTHPVOL Right channel headphone volume */ 
    0x0014,  /* 4 DSK5510_AIC23_ANAPATH    Analog audio path control */      
    0x0000,  /* 5 DSK5510_AIC23_DIGPATH    Digital audio path control */     
    0x0000,  /* 6 DSK5510_AIC23_POWERDOWN  Power down control */             
    0x0043,  /* 7 DSK5510_AIC23_DIGIF      Digital audio interface format */ 
    0x008D,  /* 8 DSK5510_AIC23_SAMPLERATE Sample rate control * 8KHz*/            
    0x0001   /* 9 DSK5510_AIC23_DIGACT     Digital interface activation */   
};

Int16 inputdata1;
Int16 inputdata2;
Int16 in_addr1=0,out_addr1=128;
Int16 in_addr2=0,out_addr2=128;
Int16 temp_data1[8000]={0},temp_data2[8000]={0};
Int16 plus;


/*
 *  main() - Main code routine, initializes BSL and generates tone
 */

void main()
{
    DSK5510_AIC23_CodecHandle hCodec;
    Int16 i;
    Int16 switch0,switch1,switch2,switch3;
    Int16 N,ct;
    for(i=1;i<8000;i++)
    {
    	temp_data1[i]=0;
    	temp_data2[i]=0;
    }
	
    /* Initialize the board support library, must be called first */
    DSK5510_init();    
    
    // Initialize LEDs and DIP switches
    DSK5510_LED_init();
    DSK5510_DIP_init();     
    /* Start the codec */
    hCodec = DSK5510_AIC23_openCodec(0, &config);	
    	
    /*Setting the required sizeof circular buffer */	
    init(); 
    N=128;
    ct=5000;
    while(1)
        {        	
        	switch0 = DSK5510_DIP_get(0); /* Retrieve the DIP switch value */
        	if(switch0){        	
        		DSK5510_LED_on(0);
        		N=128;
        		in_addr1=out_addr1-128;
				if(in_addr1<0)
					in_addr1+=8000;     
        		in_addr2=out_addr2-128;
        		if(in_addr2<0)
					in_addr2+=8000;}       		
        	
        	else{
        		DSK5510_LED_off(0);}
        	
        	switch1 = DSK5510_DIP_get(1);
        	if(switch1){        	
        		DSK5510_LED_on(1);
        		ct-=2;
        		}        		
        	else{
        		DSK5510_LED_off(1);}
        	
        	switch2 = DSK5510_DIP_get(2);        	
        	if(switch2){        	
        		DSK5510_LED_on(2);
        		ct-=10;
        		}        	
        	else{
        		DSK5510_LED_off(2);}
        
        	switch3 = DSK5510_DIP_get(3);
        	if(switch3){
        		DSK5510_LED_off(0);
        		DSK5510_LED_off(1);
        		DSK5510_LED_off(2);
				DSK5510_LED_on(3);
				ct-=20;
				}
        	else{
        		DSK5510_LED_off(3);}
        	
        	if(ct<=0)
        	{
        		if(N==128)
        			plus=1;
        		if(N==0)
        			plus=0;
        	
        		if(plus)
        		{	in_addr1++;
        			if(in_addr1>8000)
						in_addr1-=8000;
        			in_addr2++;
        			if(in_addr2>8000)
						in_addr2-=8000;
        			N--;}
        		else 	
        		{	in_addr1--;
        			if(in_addr1<0)
						in_addr1+=8000;
        			in_addr2--;
        			if(in_addr2<0)
						in_addr2+=8000;
        			N++;}
        		ct=5000;	
        	}
        	/* Receive a sample from the left channel */
        	while(!DSK5510_AIC23_read16(hCodec, &inputdata1));
        	/* Receive a sample from the right channel */
        	while(!DSK5510_AIC23_read16(hCodec, &inputdata2));
        	
        	/*Set the start address of circular bufferof the L-channel*/
        	setbuffer(temp_data1); 
        
        	
        	/*Delay for 4000 samples of L-channel*/
        	inputdata1=echo(inputdata1,&in_addr1,&out_addr1); 
        	
        	/*Set the start address of circular bufferof the R-channel*/
        	setbuffer(temp_data2); 
        	/*Delay for 4000 samples of R-channel*/
        	inputdata2=echo(inputdata2,&in_addr2,&out_addr2); 
        
        	/* Send a sample to the left channel */
        	while(!DSK5510_AIC23_write16(hCodec, inputdata1));
        	/* Send a sample to the right channel */
        	while(!DSK5510_AIC23_write16(hCodec, inputdata2));            
        }

    	/* Close the codec */
         //DSK5510_AIC23_closeCodec(hCodec);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -