void Record(uint RecAddr)
{
PowerUp();
delay_ms(50);
PowerUp();
delay_ms(100);
SS_0;
Send_Data((uchar)RecAddr);
Send_Data((uchar)(RecAddr>>8));
Send_Data(0xA0);
SS_1;
SS_0;
Send_Data(0xB0);
SS_1;
}
void Play(uint Address)
{
PowerUp();
delay_ms(50);
SS_0;
Send_Data((uchar)Address);
Send_Data((uchar)(Address>>8));
Send_Data( 0xE0);
SS_1;
SS_0;
Send_Data(0xF0);
SS_1;
}
//*************************单片机端口初始化***************************
void port_init()
{
DDRA = 0xFF;
PORTA = 0x00;
DDRB = 0xFF;
PORTB = 0xFF;
DDRC = 0x00;
PORTC = 0xFF;
PINC = 0xff;
DDRD = 0x00;
PORTD = 0xff;
}
////////////////////////
void main()
{
port_init();
while(1)
{
if(!(PIND&0x10)&&(flag==0))
{
delay_ms(5);
if(!(PIND&0x10)&&(flag==0))
{
flag = 1;
//Record(0x600);
while(!(PIND&0x10));
}
}
if(!(PIND&0x10)&&(flag == 1))
{
delay_ms(5);
if(!(PIND&0x10)&&(flag == 1))
{
flag=2;
Stop();
while(!(PIND&0x10));
}
}
if(!(PIND&0x10)&&(flag == 2))
{
delay_ms(5);
if(!(PIND&0x10)&&(flag == 2))
{
flag=0;
Play(0x600);
while(!(PIND&0x10));
}
}
}
}