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

📄 dm642main.c

📁 dsp dm642的音频采集与回放源码
💻 C
字号:
/********************************************************************/
/*  Copyright 2004 by SSD Incorporated.							*/
/*  All rights reserved. Property of SSD Incorporated.				*/
/*  Restricted rights to use, duplicate or disclose this code are	*/
/*  granted through contract.									    */
/*  															    */
/********************************************************************/
/*
 *---------dm642main.c---------
 */


#include <stdio.h>
//#include <string.h>
#include <stdlib.h>

#include <csl.h>
#include <std.h>
#include <csl_irq.h>
#include <csl_chip.h>
#include <IIC.h>
#include <McBSP.h>

#include "dm642.h"
#include "rtciic.h"
#include "eeprom.h"
#include "io&led.h"
#include "dm642_ide.h"
#include "dm642_flash.h"
#include "dm642_uart.h"

extern far void vectors();

Uint8	PlayMode = 0,i;
Int16	y=5000;
Uint32	temp;
MCBSP_Handle hMcbsp;  
I2C_Handle hI2C;

void main()
{
  	
	Uint32	XmtEvtId;

/*-------------------------------------------------------*/
/* perform all initializations                           */
/*-------------------------------------------------------*/
	DM642_init();
/*----------------------------------------------------------*/
   GPIO_RSET(GPGC,0x0);
   GPIO_RSET(GPDIR,0x1);
   GPIO_RSET(GPVAL,0x0);    

  	hMcbsp = MCBSP_open(MCBSP_DEV1, MCBSP_OPEN_RESET);
	XmtEvtId = MCBSP_getXmtEventId(hMcbsp);
	IRQ_setVecs(vectors);     /* point to the IRQ vector table	*/
  	IRQ_globalEnable();       /* Globally enable interrupts     */ 
  	IRQ_nmiEnable();          /* Enable NMI interrupt           */	
  	IRQ_map(XmtEvtId, 14);
    IRQ_reset(XmtEvtId);
	IRQ_enable(XmtEvtId);
	
	/* Open I2C0. */
	hI2C = I2C_open(I2C_DEV0,I2C_OPEN_RESET);
	DM642_wait(100);
	I2C_write16(hI2C,Reset_Register,0x00);		
	DM642_wait(100);
	I2C_write16(hI2C,Digital_Interface_Activation,0x01);
	DM642_wait(100);
	I2C_write16(hI2C,Power_Down_Control,0x00);
	DM642_wait(100);
	I2C_write16(hI2C,Sample_Rate_Control,0x022);
	DM642_wait(100);
	I2C_write16(hI2C,Left_Line_Input_Channel_Volume_Control,0x117);
	DM642_wait(100);
	I2C_write16(hI2C,Right_Line_Input_Channel_Volume_Control,0x117);
	DM642_wait(100);
	I2C_write16(hI2C,Left_Channel_Headphone_Volume_Control,0x0180 +100);
	DM642_wait(100);
	I2C_write16(hI2C,Right_Channel_Headphone_Volume_Control,0x0180 + 100);
	DM642_wait(100);
	I2C_write16(hI2C,Analog_Audio_Path_Control,0x07d);
	DM642_wait(100);
	I2C_write16(hI2C,Digital_Audio_Path_Control,0x04);
	DM642_wait(100);
	I2C_write16(hI2C,Digital_Audio_Interface_Format,0x43);//0x52
	DM642_wait(1000);

  
  	/* We'll set it up for digital loopback, 32bit mode. We have   */
  	/* to setup the sample rate generator to allow self clocking.  */
  	MCBSP_config(hMcbsp,&ConfigMcbsp1);

  	/* Now that the port is setup, let's enable it in steps. */
  	MCBSP_start(hMcbsp,MCBSP_RCV_START | MCBSP_XMIT_START |
   					 MCBSP_SRGR_START| MCBSP_SRGR_FRAMESYNC,
   			  		 MCBSP_SRGR_DEFAULT_DELAY);
     
	

	while(1)
	{
   		for(temp=30000;temp>0;temp-=100)
		{
			for(i=0;i<2;i++)
			{
				y=5000;       
				DM642_wait(temp*2);
				y=-5000;       
    			DM642_wait(temp*2);
    			
    		}
    	} 	
	}
	
}

interrupt void    
c_int14(void)    
{
    	MCBSP_write(hMcbsp,y);    		
}

//==============================================================


⌨️ 快捷键说明

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