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

📄 fpga.c

📁 大名鼎鼎的mpc8260的bsp源代码
💻 C
📖 第 1 页 / 共 2 页
字号:

/*************************************************************************************************
 *                                                                                              *
 *                                                                                              * 	
 *                                   D20-----FPGA                                   *                        
 *                                                                                              *	
 *                                                                                              *
 *	
*************************************************************************************************/



#include "fpga.h"

#ifndef EIEIO_SYNC
#define EIEIO_SYNC  __asm__("eieio;	sync")
#endif


typedef  struct _Tone_
{
unsigned int  FTA;/*first tone start address*/
unsigned int FTC;/*first tone counter*/
unsigned int STA;/*second tone start address*/
unsigned int STC;/*second tonr counter*/
}sTone;



static  sTone Tone [] ={
{0x200000,0xFFFFFF,0xFFFFFF,0xFFFFFF},/*0:silent*/	
{0x200010,0xFFFFFF,0xFFFFFF,0xFFFFFF},/*1:Dial tone*/
{0x200010,0x000AF0,0x200000,0x000AF0},/*2:Busy tone*/
{0x200010,0x001f40,0x200000,0x007d00},									/*3:RingBack*/
{0x000000,0x000000,0x000000,0x000000},									/*4:PressingKey*/
{0x000000,0x000000,0x000000,0x000000},									/*5:Confirmation*/
{0x000000,0x000000,0x000000,0x000000},									/*6:StutteDial*/
{0x000000,0x000000,0x000000,0x000000},									/*7:ErrorTone*/
{0x000000,0x000000,0x000000,0x000000},									/*8:HoldTone*/
{0x000000,0x000000,0x000000,0x000000},									/*9:QueuePrompt*/
{0x000000,0x000000,0x000000,0x000000},									/*A:OffhookQueue*/
{0x000000,0x000000,0x000000,0x000000},									/*B:InteralCampOn*/
{0x000000,0x000000,0x000000,0x000000},									/*C:ExternalCampOn*/
{0x000000,0x000000,0x000000,0x000000},									/*D:NoNotificationCampOn*/
{0x2005a1,0x00014D,0x200000,0x00014D},		/*e:RingTone1*//*0.25--0.25*/
{0x200010,0x00014D,0x200000,0x00014D},		/*f:RingTone2*/
{0x2005a1,0x0000f9,0x200000,0x0000f9},		/*10:RingTone3*/
{0x200010,0x00029a,0x200000,0x00029a},		/*11:RingTone4*/
{0x2005a1,0x0003E8,0x200000,0x0003E8},		/*12:RingTone5*/

{0x2005a1,0x00014D,0x200010,0x00014D},		/*13:RingTone6*//*0.25--0.25*/
{0x200010,0x00029a,0x200010,0x00029a},		/*14:RingTone7*/
{0x2005a1,0x0000f9,0x200010,0x0000f9},		/*15:RingTone8*/
{0x2005a1,0x0003E8,0x200010,0x0003E8},		/*16:RingTone9*/
{0x2005a1,0x0003E8,0x200010,0x0003E8},		/*17:RingTone10*/
    
{0x200057,0xFFFFFF,0xFFFFFF,0x000000},		/*18:DTMF1*/
{0x2000D5,0xFFFFFF,0xFFFFFF,0x000000},		/*19:DTMF2*/
{0x200154,0xFFFFFF,0xFFFFFF,0x000000},		/*1A:DTMF3*/
{0x2001AF,0xFFFFFF,0xFFFFFF,0x000000},		/*1B:DTMF4*/
{0x2001F8,0xFFFFFF,0xFFFFFF,0x000000},		/*1C:DTMF5*/
{0x20026A,0xFFFFFF,0xFFFFFF,0x000000},		/*1D:DTMF6*/
{0x2002DC,0xFFFFFF,0xFFFFFF,0x000000},		/*1E:DTMF7*/
{0x20031E,0xFFFFFF,0xFFFFFF,0x000000},		/*1F:DTMF8*/
{0x200360,0xFFFFFF,0xFFFFFF,0x000000},		/*20:DTMF9*/
{0x2003C7,0xFFFFFF,0xFFFFFF,0x000000},		/*21:DTMF0*/
{0x20042D,0xFFFFFF,0xFFFFFF,0x000000},		/*22:DTMF**/
{0x2004A4,0xFFFFFF,0xFFFFFF,0x000000},		/*23:DTMF#*/
{0x000000,0x000000,0x000000,0x000000}		/*MAX*/
}; 


static  sTone Tone2 [] ={
{0x300000,0xFFFFFF,0xFFFFFF,0xFFFFFF},/*0:silent*/	
{0x300010,0xFFFFFF,0xFFFFFF,0xFFFFFF},/*1:Dial tone*/
{0x300010,0x000AF0,0x300000,0x000AF0},/*2:Busy tone*/
{0x300010,0x001f40,0x300000,0x007d00},									/*3:RingBack*/
{0x000000,0x000000,0x000000,0x000000},									/*4:PressingKey*/
{0x000000,0x000000,0x000000,0x000000},									/*5:Confirmation*/
{0x000000,0x000000,0x000000,0x000000},									/*6:StutteDial*/
{0x000000,0x000000,0x000000,0x000000},									/*7:ErrorTone*/
{0x000000,0x000000,0x000000,0x000000},									/*8:HoldTone*/
{0x000000,0x000000,0x000000,0x000000},									/*9:QueuePrompt*/
{0x000000,0x000000,0x000000,0x000000},									/*A:OffhookQueue*/
{0x000000,0x000000,0x000000,0x000000},									/*B:InteralCampOn*/
{0x000000,0x000000,0x000000,0x000000},									/*C:ExternalCampOn*/
{0x000000,0x000000,0x000000,0x000000},									/*D:NoNotificationCampOn*/
{0x2005a1,0x00014D,0x200000,0x00014D},		/*e:RingTone1*//*0.25--0.25*/
{0x200010,0x00014D,0x200000,0x00014D},		/*f:RingTone2*/
{0x2005a1,0x0000f9,0x200000,0x0000f9},		/*10:RingTone3*/
{0x200010,0x00029a,0x200000,0x00029a},		/*11:RingTone4*/
{0x2005a1,0x0003E8,0x200000,0x0003E8},		/*12:RingTone5*/

{0x2005a1,0x00014D,0x200010,0x00014D},		/*13:RingTone6*//*0.25--0.25*/
{0x200010,0x00029a,0x200010,0x00029a},		/*14:RingTone7*/
{0x2005a1,0x0000f9,0x200010,0x0000f9},		/*15:RingTone8*/
{0x2005a1,0x0003E8,0x200010,0x0003E8},		/*16:RingTone9*/
{0x2005a1,0x0003E8,0x200010,0x0003E8},		/*17:RingTone10*/
    
{0x300057,0xFFFFFF,0xFFFFFF,0x000000},		/*18:DTMF1*/
{0x3000D5,0xFFFFFF,0xFFFFFF,0x000000},		/*19:DTMF2*/
{0x300154,0xFFFFFF,0xFFFFFF,0x000000},		/*1A:DTMF3*/
{0x3001AF,0xFFFFFF,0xFFFFFF,0x000000},		/*1B:DTMF4*/
{0x3001F8,0xFFFFFF,0xFFFFFF,0x000000},		/*1C:DTMF5*/
{0x30026A,0xFFFFFF,0xFFFFFF,0x000000},		/*1D:DTMF6*/
{0x3002DC,0xFFFFFF,0xFFFFFF,0x000000},		/*1E:DTMF7*/
{0x30031E,0xFFFFFF,0xFFFFFF,0x000000},		/*1F:DTMF8*/
{0x300360,0xFFFFFF,0xFFFFFF,0x000000},		/*20:DTMF9*/
{0x3003C7,0xFFFFFF,0xFFFFFF,0x000000},		/*21:DTMF0*/
{0x30042D,0xFFFFFF,0xFFFFFF,0x000000},		/*22:DTMF**/
{0x3004A4,0xFFFFFF,0xFFFFFF,0x000000},		/*23:DTMF#*/
{0x000000,0x000000,0x000000,0x000000}		/*MAX*/
}; 

/*************************************************************
 *The routine Play tone indeed
 *Input:tone_type,PlayFlag,Codec_Sel,Play_Second_tone
 *Output:void
 *
 *ref:tone_type  range 0x0~0x23;
 	PlayFlag:start/stop flag 1: start  0:stop
 	dev:  	0 :left handset, 
 			1 right handset
			2: Left Speaker 
			3: Right Spraker
 	Play_Second_tone:the second dial tone  start /stop bit 1: start  0:stop
 	
	PlayFlag and Play_Second_tone can not =1 at the same time.
 ***************************************************************/
#if 1
void HW_Play_Tone(unsigned char postion ,unsigned short tone_type,unsigned char PlayFlag,unsigned char dev,unsigned char Play_Second_tone)
{
postion =0;

if((dev ==0) ||(dev==2))
{
WriteByte(FR_FTALH,((unsigned short )(Tone[tone_type].FTA))>>8);/*write first tone address high 15~8 bit*/
WriteByte(FR_FTALL,(unsigned char)(Tone[tone_type].FTA));/*write first tone address high 7~0 bit*/

WriteByte(FR_FTTLH,((unsigned short )(Tone[tone_type].FTC))>>8);/*write first tone timer1 high 15~8 bit*/
WriteByte(FR_FTTLL,(unsigned char)(Tone[tone_type].FTC));/*write first tone timer1 high 7~0 bit*/

WriteByte(FR_STALH,((unsigned short )(Tone[tone_type].STA))>>8);/*write second tone address high 15~8 bit*/
WriteByte(FR_STALL,(unsigned char)(Tone[tone_type].STA));/*write second tone address  high 7~0 bit*/
WriteByte(FR_STTLH,((unsigned short )(Tone[tone_type].STC))>>8);/*write second tone timer1 high 15~8 bit*/
WriteByte(FR_STTLL,(unsigned char)(Tone[tone_type].STC));/*write second tone timer2 high 7~0 bit*/
#if 1
WriteByte(FR_PTC,PlayFlag);/*放音源write start /stop bit 1: start  0:stop*/
#else
WriteByte(FR_PTC,0x1);/*放音源write start /stop bit 1: start  0:stop*/
#endif

if(dev == 0)
{
    if(PlayFlag == 0)
	WriteByte(FR_LEFT_HANDSET_REG,0xff);
    else
	WriteByte(FR_LEFT_HANDSET_REG,0x08);
}
else if(dev == 2)
{
    if(PlayFlag == 0)
	WriteByte(FR_MICRO_SPEAKER_REG,0xff);
    else
	WriteByte(FR_MICRO_SPEAKER_REG,0x08);
}
else
	;
}
else  if((dev == 1 ) ||(dev==3))
{
	WriteByte(FR_FTALH2,((unsigned short )(Tone2[tone_type].FTA))>>8);/*write first tone address high 15~8 bit*/
	WriteByte(FR_FTALL2,(unsigned char)(Tone2[tone_type].FTA));/*write first tone address high 7~0 bit*/

	WriteByte(FR_FTTLH2,((unsigned short )(Tone2[tone_type].FTC))>>8);/*write first tone timer1 high 15~8 bit*/
	WriteByte(FR_FTTLL2,(unsigned char)(Tone2[tone_type].FTC));/*write first tone timer1 high 7~0 bit*/

	WriteByte(FR_STALH2,((unsigned short )(Tone2[tone_type].STA))>>8);/*write second tone address high 15~8 bit*/
	WriteByte(FR_STALL2,(unsigned char)(Tone2[tone_type].STA));/*write second tone address  high 7~0 bit*/
	WriteByte(FR_STTLH2,((unsigned short )(Tone2[tone_type].STC))>>8);/*write second tone timer1 high 15~8 bit*/
	WriteByte(FR_STTLL2,(unsigned char)(Tone2[tone_type].STC));/*write second tone timer2 high 7~0 bit*/
#if 1
	WriteByte(FR_PTC2,PlayFlag);/*放音源write start /stop bit 1: start  0:stop*/
#else
	WriteByte(FR_PTC2,0x1);/*放音源write start /stop bit 1: start  0:stop*/
#endif

	  if(dev == 1)
	 {
		 if(PlayFlag == 0)
		 WriteByte(FR_RIGHT_HANDSET_REG,0xff);
		 else
		 WriteByte(FR_RIGHT_HANDSET_REG,0x09);
		
	 }
	  else if(dev == 3)
	  {
		  if(PlayFlag == 0)
		  WriteByte(FR_MICRO_SPEAKER_REG,0xff);
		  else
		  WriteByte(FR_MICRO_SPEAKER_REG,0x09);
	  }
	  else
		  ;
}
}
#else
void HW_Play_Tone(unsigned short tone_type,unsigned char PlayFlag,unsigned char dev,unsigned char Play_Second_tone)
{

if((dev ==0) ||(dev==2))
{
WriteByte(FR_FTALH,((unsigned short )(Tone[tone_type].FTA))>>8);/*write first tone address high 15~8 bit*/
WriteByte(FR_FTALL,(unsigned char)(Tone[tone_type].FTA));/*write first tone address high 7~0 bit*/

WriteByte(FR_FTTLH,((unsigned short )(Tone[tone_type].FTC))>>8);/*write first tone timer1 high 15~8 bit*/
WriteByte(FR_FTTLL,(unsigned char)(Tone[tone_type].FTC));/*write first tone timer1 high 7~0 bit*/

WriteByte(FR_STALH,((unsigned short )(Tone[tone_type].STA))>>8);/*write second tone address high 15~8 bit*/
WriteByte(FR_STALL,(unsigned char)(Tone[tone_type].STA));/*write second tone address  high 7~0 bit*/
WriteByte(FR_STTLH,((unsigned short )(Tone[tone_type].STC))>>8);/*write second tone timer1 high 15~8 bit*/
WriteByte(FR_STTLL,(unsigned char)(Tone[tone_type].STC));/*write second tone timer2 high 7~0 bit*/
#if 1
WriteByte(FR_PTC,PlayFlag);/*放音源write start /stop bit 1: start  0:stop*/
#else
WriteByte(FR_PTC,0x1);/*放音源write start /stop bit 1: start  0:stop*/
#endif

if(dev == 0)
{
    if(PlayFlag == 0)
	WriteByte(FR_LEFT_HANDSET_REG,0xff);
    else
	WriteByte(FR_LEFT_HANDSET_REG,0x08);
}
else if(dev == 2)
{
    if(PlayFlag == 0)
	WriteByte(FR_MICRO_SPEAKER_REG,0xff);
    else
	WriteByte(FR_MICRO_SPEAKER_REG,0x08);
}
else
	;
}
else  if((dev == 1 ) ||(dev==3))
{
	WriteByte(FR_FTALH2,((unsigned short )(Tone2[tone_type].FTA))>>8);/*write first tone address high 15~8 bit*/
	WriteByte(FR_FTALL2,(unsigned char)(Tone2[tone_type].FTA));/*write first tone address high 7~0 bit*/

	WriteByte(FR_FTTLH2,((unsigned short )(Tone2[tone_type].FTC))>>8);/*write first tone timer1 high 15~8 bit*/
	WriteByte(FR_FTTLL2,(unsigned char)(Tone2[tone_type].FTC));/*write first tone timer1 high 7~0 bit*/

	WriteByte(FR_STALH2,((unsigned short )(Tone2[tone_type].STA))>>8);/*write second tone address high 15~8 bit*/
	WriteByte(FR_STALL2,(unsigned char)(Tone2[tone_type].STA));/*write second tone address  high 7~0 bit*/
	WriteByte(FR_STTLH2,((unsigned short )(Tone2[tone_type].STC))>>8);/*write second tone timer1 high 15~8 bit*/
	WriteByte(FR_STTLL2,(unsigned char)(Tone2[tone_type].STC));/*write second tone timer2 high 7~0 bit*/
#if 1
	WriteByte(FR_PTC2,PlayFlag);/*放音源write start /stop bit 1: start  0:stop*/
#else
	WriteByte(FR_PTC2,0x1);/*放音源write start /stop bit 1: start  0:stop*/
#endif

	  if(dev == 1)
	 {
		 if(PlayFlag == 0)
		 WriteByte(FR_RIGHT_HANDSET_REG,0xff);
		 else
		 WriteByte(FR_RIGHT_HANDSET_REG,0x09);
		
	 }
	  else if(dev == 3)
	  {
		  if(PlayFlag == 0)
		  WriteByte(FR_MICRO_SPEAKER_REG,0xff);
		  else
		  WriteByte(FR_MICRO_SPEAKER_REG,0x09);
	  }
	  else
		  ;
}
}

#endif

#if 1
void HW_PlaySecondDialTone(unsigned char postion ,unsigned short tone_type,unsigned char PlayFlag,unsigned char dev)
{
	postion =0;

if((dev == 0) ||(dev==2))
{
WriteByte(FR_FTALH,((unsigned short )(Tone[tone_type].FTA))>>8);/*write first tone address high 15~8 bit*/
WriteByte(FR_FTALL,(unsigned char)(Tone[tone_type].FTA));/*write first tone address high 7~0 bit*/
WriteByte(FR_FTTLH,((unsigned short )(Tone[tone_type].FTC))>>8);/*write first tone timer1 high 15~8 bit*/
WriteByte(FR_FTTLL,(unsigned char)(Tone[tone_type].FTC));/*write first tone timer1 high 7~0 bit*/

⌨️ 快捷键说明

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