*spi isd4004.h*/
#i nclude "reg51.h"
#i nclude "intrins.h"
sbit _cs = p0^0;
sbit _sclk= p0^3;
sbit _mosi= p0^1;
sbit _miso= p0^2;
sbit _rac = p0^4;
sbit _int = p0^5;
void delay(unsigned int i) //延时程序
{
while(i--);
}
void stopmode() //停止
{
unsigned char m,i,j;
_cs=1;
_sclk=0;
_cs=0;
m=0x30;
for(i=0;i<8;i++)
{
m=_cror_(m,1);
j=m<<1;
_mosi=cy;
_sclk=0;
_sclk=1;
}
_cs=1;
}
void powerdown() //下电
{
unsigned char m,i,j;
_cs=1;
_sclk=0;
_cs=0;
m=0x10;
for(i=0;i<8;i++)
{
m=_cror_(m,1);
j=m<<1;
_mosi=cy;
_sclk=0;
_sclk=1;
}
_cs=1;
}
void powerup() 上电
{
unsigned char m,i,j;
_cs=1;
_sclk=0;
_cs=0;
m=0x20;
for(i=0;i<8;i++)
{
m=_cror_(m,1);
j=m<<1;
_mosi=cy;
_sclk=0;
_sclk=1;
}
_cs=1;
}
void record4004(unsigned int address) 录音 address--录音地址 0---2400
{
unsigned char i,m,j;
unsigned int datasoute=0;
powerup();
delay(5118);//上电延时
powerup();
delay(5118);//上电延时
delay(5118);//上电延时
_cs=1;
_sclk=0;
m=0xa0;
_cs=0;
for(i=0;i<16;i++)
{
address=_iror_(address,1);
datasoute=address<<1;
_mosi=cy;
_sclk=0;
_sclk=1;
}
for(i=0;i<8;i++)
{
m=_cror_(m