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

📄 main.c

📁 4003语音芯片代码。ADS1.2下面的工程文件。其中4003是用LPC2214控制的。
💻 C
字号:
/****************************************Copyright (c)**************************************************
**                               Guangzou ZLG-MCU Development Co.,LTD.
**                                      graduate school
**                                 http://www.zlgmcu.com
**
**--------------File Info-------------------------------------------------------------------------------
** File name:			main.c
** Last modified Date:  2004-09-16
** Last Version:		1.0
** Descriptions:		The main() function example template
**
**------------------------------------------------------------------------------------------------------
** Created by:			Chenmingji
** Created date:		2004-09-16
** Version:				1.0
** Descriptions:		The original version
**
**------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
** Version:
** Descriptions:
**
********************************************************************************************************/
#include "config.h"





/************************/
//DelayNS()     软件延时程序

/************************/
void DelayNS(uint32 dly)
{ uint32 i;
  for(;dly>0;dly--)
   for(i=0;i<5000;i++);
}
/************************
MSpiIni()
初始化SPI接口,设置为主机

************************************************/
void MSpiIni(void)
{ S1PCCR=0x52;         //设置SPI时钟分频
  S1PCR=0x60;          //设置SPI接口模式,MSTR=1,CPOL=1,CPHA=0,LSBF=0
}
/************************************************
MSendData()
向SPI总线发送数据,并接受从机发回的数据


************************************************/
uint8 MSendData(uint8 data)
{// IO0CLR=0x00000004;               //片选
  S1PDR=data;
  while(0==(S1PSR&0x80));          //等待SPIF置位,即等待数据发送完毕
 // IO0SET=0x00000004;
  return(S1PDR);
}



/********************************************************/
void UP(void)	    //ISD4004上电
{
 IO0CLR=0x00000004;
// MSendData(0x00);
 MSendData(0x20); 
 IO0SET=0x00000004;
 DelayNS(100);//YS50();
 DelayNS(100);//YS50();
}

void DSTOP(void) //停止当前操作并掉电
{
 IO0CLR=0x00000004;
// MSendData(0x00);
 MSendData(0x10);
 IO0SET=0x00000004;
 DelayNS(100);//YS50();
 DelayNS(100);//YS50();
}

void REC(void)		 //录音
{
 DSTOP();
 DelayNS(200);
 UP();
 DelayNS(100);//YS50();
 UP();
 DelayNS(200);//YS50();等待两个TPUD
 IO0CLR=0x00000004;
 MSendData(0x00); //从0x00地址录音
 
 MSendData(0xa0);
 IO0SET=0x00000004;
// DelayNS(200);
 DelayNS(100);//YS50();
 IO0CLR=0x00000004;
 MSendData(0x00); //从0x00地址录音
 MSendData(0xb0);
 IO0SET=0x00000004;
}

void PLAY(void)		 //放音
{
 DSTOP();
 DelayNS(200);
 UP();
 DelayNS(100);//YS50();
 IO0CLR=0x00000004;
 MSendData(0x00); //从0x00地址放音
 IO0SET=0x00000004;
 IO0CLR=0x00000004;
// MSendData(0x00);
 MSendData(0xe0);
 IO0SET=0x00000004;
 IO0CLR=0x00000004;
 //MSendData(0x00); //从0x00地址放音
// MSendData(0x00);
 MSendData(0xf0);
 IO0SET=0x00000004;
  
}

int main(void)
{
 PINSEL0=0x800555c5;
 PINSEL1=0x2a8026a9;
 PINSEL2=0x07000924;
 IO0DIR=0x00002004;
 IO1DIR=0x00000000;
 IO2DIR=0x00000000;
 IO3DIR=0x00040000;
 IO3SET=0x00040000;
// IO3CLR=0x00040000;
 IO0SET=0x00000004;
 
 MSpiIni();
 PLAY();
 while(1)
 { 
  if((IO0PIN&0x00000400)==0)
   { 
     DelayNS(10);
     if((IO0PIN&0x00000400)==0)
         
     REC();
    }
  if((IO1PIN&0x01000000)==0)       
   { DelayNS(10);
     if((IO1PIN&0x01000000)==0)  
     PLAY();
    }
  if((IO1PIN&0x02000000)==0)
   { DelayNS(10);
     if((IO1PIN&0x02000000)==0)
     DSTOP();
   }
  }
  return(0);
}
/*********************************************************************************************************
**                            End Of File
********************************************************************************************************/

⌨️ 快捷键说明

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