ISD4004應用電路及程序
temp= temp 0x01;
if(temp) {MOSI_1;}
else {MOSI_0;}
SCLK_0;
SCLK_1;
MOSI_0;
}
}
void PowerUp(void)
{
SS_0;
Send_Data(0x20);
SS_1;
}
void Stop(void)
{
SS_0; //先把SS拉低
Send_Data( 0x10);
SS_1; //把SS拉高,
}本文引用地址:http://www.ex-cimer.com/article/150379.htm
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(!(PIND0x10)(flag==0))
{
delay_ms(5);
if(!(PIND0x10)(flag==0))
{
flag = 1;
//Record(0x600);
while(!(PIND0x10));
}
}
if(!(PIND0x10)(flag == 1))
{
delay_ms(5);
if(!(PIND0x10)(flag == 1))
{
flag=2;
Stop();
while(!(PIND0x10));
}
}
if(!(PIND0x10)(flag == 2))
{
delay_ms(5);
if(!(PIND0x10)(flag == 2))
{
flag=0;
Play(0x600);
while(!(PIND0x10));
}
}
}
}
DIY機械鍵盤相關社區(qū):機械鍵盤DIY
評論