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

📄 test_program.c

📁 YAMAHA的铃音芯片的测试程序
💻 C
字号:
#include "pccdef.h"
#include "OMAP_MPU_Addr.h"

#include "B_test.h"

void Keyboard_test(void)
{
    Keyboard_Init();
}

void Timer1_Init(void)	
{
  MPU_LOAD_TIMER1 = 5000/2*195-1;	 //TIME(uS)/2*Fclk(MHz)-1
  MPU_CNTL_TIMER1 = 0x00000023;          //bit 6    FREE=0
                                         //bit 5    CLOCK_ENABLE=1
                                         //bit 4:2  PTV=0
                                         //bit 1    AR=1 autoload
                                         //bit 0    ST=0 not start
}

void LCD_test(void)
{
  Dlcd00_02Clear();
  Dlcd00_03DispString(24,1,"重邮信科",0);
  Dlcd00_03DispString(40,6,"Test",0);
  Dlcd00_03DispString(18,7,"Successed!",0);
}

void LCD_test2(void)
{	

  LCD_Init();
  LCD_SetMode(0);
  Dlcd00_02Clear();
  Dlcd00_03DispString(0,1,"重邮信科",0);
  Dlcd00_03DispString(66,7,"进入",0);
}

void LCD_test3(void)
{
  char volume;
  
  LCD_SetMode(0);
  Dlcd00_02Clear();
  Dlcd00_03DispString(24,1,"铃声选择:",0);
  Dlcd00_03DispString(46,4,"1.",0);
  Dlcd00_03DispString(46,5,"2.",0);
  Dlcd00_03DispString(46,6,"3.",0);
  volume = 0x18;
  PWT_Vol(volume);  
}



void music1(void)
{
  int i=0,jj=0,length;
  u8 temp;	
	
  LCD_SetMode(0);
  Dlcd00_02Clear();
  Dlcd00_03DispString(32,4,"铃声  1",0);

  length=music01[1]+(music01[0]<<8);
  for(i=0;i<length;i++)
  {
    temp=music01[i+2]-0x10;
    PWT_Freq(temp);
    PWT_on();
    for(jj=0;jj<50000;jj++){}
    if(music01flag[i+2]==0)
    PWT_off();
    for(jj=0;jj<10000;jj++){}    
  }
  PWT_off();
}

void music2(void)
{
  int i=0,jj=0,length;
  u8 temp;
    
  LCD_SetMode(0);
  Dlcd00_02Clear();
  Dlcd00_03DispString(32,4,"铃声  2",0);
 
  length=music02[1]+(music02[0]<<8);
  for(i=0;i<length;i++)
  {
    temp=music02[i+2]-0x10;
    PWT_Freq(temp);
    PWT_on();
    for(jj=0;jj<70000;jj++){}
    if(music02flag[i+2]==0)
    PWT_off();
    for(jj=0;jj<10000;jj++){}    
  }
  PWT_off();    
}



void music3(void)
{
  int i=0,jj=0,length;
  u8 temp;	
  LCD_SetMode(0);	
  Dlcd00_02Clear();
  Dlcd00_03DispString(32,4,"铃声  3",0);

  length=music03[1]+(music03[0]<<8);
  
  for(i=0;i<length;i++)
  {
    temp=music03[i+2]-0x10;
    PWT_Freq(temp);
    PWT_on();
    for(jj=0;jj<60000;jj++){}
    if(music03flag[i+2]==0)
    PWT_off();
    for(jj=0;jj<10000;jj++){}    
  }
  PWT_off();
}


void UART3_test(void)
{
  char status;
  short i;
  IRQ_Enable(0x0f);
  IRQ_Enable(0x13);      

  //disable uart
  UART3_LCR = 0xBF;
  UART3_EFR |= 0x10;   //ENHANCED_EN=1,enables writing to IER and FCR
  UART3_LCR &= 0x7F;
  UART3_IER = 0x00;   //disable interrupt
  UART3_MCR = 0x00;   //Force control signals inactive
  //UART3_LCR &= 0xBF;  //LCR[6] = 0; Here, remove UART breaks.
  UART3_MDR1 = 0x07;  //UART is in reset or disabled.
  UART3_SYSC = 0x02;
  do
  {
    status = UART3_SYSS;
  }
  while((status&0x00000001)==0);


  //FIFO configure
  UART3_SCR = 0x03;    
  //UART3_MCR |= 0x40;  //enable to write TCR TLR and FCR
  //TCR TLR FCR write
  //UART3_TLR = 0x00;   //transmit FIFO trigger level is 4 bytes;
  UART3_FCR = 0x37;   //DMA_MODE=1,FIFO_EN=1
  UART3_LCR = 0xBF;   //Provides access to EFR
  UART3_EFR &= 0xEF;
  UART3_LCR &= 0x7F;
  //UART3_MCR &= 0xBF;

  //set baud rate
  UART3_LCR |= 0x80;   //LCR[7] to 1;enable write DLH and DLL 
  UART3_DLH = 0x01;
  UART3_DLL = 0x56;      //DIV =48M/(16*13M/(372*4))=0x0157
  UART3_LCR &= 0x7F;     //LCR[7] = 0,disable access to DLH and DLL
                                      //enable RHR interrupt
  UART3_MDR1 = 0x00;     // MDR1[2:0] = 0; Enables UART without autobauding
                                    
  //transmite a data

  
  UART3_LCR = 0x3F;
 

  //for(i=0;i<0x200;i++)
  //{
  //  UART3_IER = 0x03;
  //  UART3_THR = 0x01;
  //}
  for(i=0;i<1000;i++)
  *((char *)(0x10000000+i))=i;
  //DMA_UART3_TX(200,0x10000020);
}


void Add_Voicevolume(void)
{
  short i,k,status;
  char data[6],temp;
  int  Txdata[3]; 
                 
  /*I2c Init*/
  for(i=0;i<6;i++)
  data[i]=0xff;
  for(i=0;i<4;i++)
  temp=0;
  I2C_PSC = 0x00;
  I2C_SCLL = 0x80;
  I2C_SCLH = 0x80;
  I2C_CON = 0x80;
  /*receive the data in STw5094 register*/
  I2C_CNT = 1;  
  I2C_SA = 0x71; 
  do
  {
    status = I2C_STAT;
  }
  while(status&0x1000!=0);
  I2C_STAT = 0xffff;  
  for(i=0;i<6;i++)
  {
    I2C_CNT = 1; 
    I2C_CON = 0x8403;   
    do
    {
      status = I2C_STAT;
    }
    while(status&0x0008==0);  
    I2C_STAT = 0xffff;
    data[i]=I2C_DATA; 
    for(k=0;k<300;k++){}; 
  } 
  for(k=0;k<300;k++){};
  temp=data[5]&0x0f;
  if((temp+2)<=0x0f)
  temp=(data[5]&0xf0)+((temp+2)&0x0f);
  
  /*write new volum data in STw5094 register*/
  Txdata[0]=0x0012;
  Txdata[1]=(temp<<8)+0x04;
  Txdata[2]=0x0112;
  I2C_CNT = 2;  
  do
  {
    status = I2C_STAT;
  }
  while(status&0x1000!=0);
  I2C_STAT = 0xffff;  
  I2C_CON = 0x8603; 
    
  for(i=0;i<3;i++)
  {
    I2C_CNT = 2;
    I2C_DATA=Txdata[i];
    do
    {
      status = I2C_STAT;
    }
    while(status&0x0010==0);  
    I2C_STAT = 0xffff;      
    for(k=0;k<1000;k++){};        
    I2C_CON = 0x8603;  //I2C enable,master mode,transmitter,10bits address,S-A-D...D-P mode      
  }
  do
  {
    status = I2C_STAT;
  }
  while(status&0x0010==0);  
  I2C_STAT = 0xffff;      
  for(k=0;k<500;k++){};
}


void Sub_Voicevolume(void)
{
  short i,k,status;
  char data[6],temp;
  int  Txdata[3]; 
                 
  //I2c Init
  for(i=0;i<6;i++)
  data[i]=0xff;
  for(i=0;i<4;i++)
  temp=0;
  I2C_PSC = 0x00;
  I2C_SCLL = 0x80;
  I2C_SCLH = 0x80;
  I2C_CON = 0x80;
  /*receive the data in STw5094 register*/
  I2C_CNT = 1;  
  I2C_SA = 0x71; 
  do
  {
    status = I2C_STAT;
  }
  while(status&0x1000!=0);
  I2C_STAT = 0xffff;  
  for(i=0;i<6;i++)
  {
    I2C_CNT = 1; 
    I2C_CON = 0x8403;   
    do
    {
      status = I2C_STAT;
    }
    while(status&0x0008==0);  
    I2C_STAT = 0xffff;
    data[i]=I2C_DATA; 
    for(k=0;k<300;k++){}; 
  } 
  for(k=0;k<300;k++){};
  temp=data[5]&0x0f;
  if((temp-2)>=0x00)
  temp=(data[5]&0xf0)+((temp-2)&0x0f);
  
  /*write new volum data in STw5094 register*/
  Txdata[0]=0x0012;
  Txdata[1]=(temp<<8)+0x04;
  Txdata[2]=0x0112;
  I2C_CNT = 2;  
  do
  {
    status = I2C_STAT;
  }
  while(status&0x1000!=0);
  I2C_STAT = 0xffff;  
  I2C_CON = 0x8603; 
    
  for(i=0;i<3;i++)
  {
    I2C_CNT = 2;
    I2C_DATA=Txdata[i];
    do
    {
      status = I2C_STAT;
    }
    while(status&0x0010==0);  
    I2C_STAT = 0xffff;      
    for(k=0;k<1000;k++){};        
    I2C_CON = 0x8603;  //I2C enable,master mode,transmitter,10bits address,S-A-D...D-P mode      
  }
  do
  {
    status = I2C_STAT;
  }
  while(status&0x0010==0);  
  I2C_STAT = 0xffff;      
  for(k=0;k<500;k++){};
}


void Add_PWTvolume(void)
{
  u8 temp;
  
  temp = PWT_VRC;
  if((temp+8)<=0x7f)
  PWT_VRC += 8;  
}


void Sub_PWTvolume(void)
{
  u8 temp;
  
  temp = PWT_VRC;
  if((temp-8)>=0x01)
  PWT_VRC -= 8;  
}
/*
#pragma DATA_SECTION(McuCmd1,"arm2dsp");
#pragma DATA_SECTION(McuCmd2,"arm2dsp");
#pragma DATA_SECTION(McuCmd3,"arm2dsp");
#pragma DATA_SECTION(McuCmd4,"arm2dsp");

u16 McuCmd1[512];
u16 McuCmd2[512];
u16 McuCmd3[512];
u16 McuCmd4[512];

void test_ARM2DSP(void)
{
	static u16 counter=0;
	u32 addr[4];
	
	addr[0]=(u32)McuCmd1;
	addr[1]=(u32)McuCmd2;
	addr[2]=(u32)McuCmd3;
	addr[3]=(u32)McuCmd4;
	
	counter=counter+1;
	if(counter==4) counter=0;
	B_IntDsp(addr[counter]);

    SetXF1();
    ClrXF1();
	
}

*/


⌨️ 快捷键说明

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