void wren_cmd(void)
{
x5045_SCK_Clr;
delay_us(5);
x5045_CS_Clr;
write_x5045(0x06);
x5045_SCK_Clr;
delay_us(5);
x5045_CS_Set;
}
void wrdi_cmd(void)
{
x5045_SCK_Clr;
delay_us(5);
x5045_CS_Clr;
write_x5045(0x04);
x5045_SCK_Clr;
delay_us(5);
x5045_CS_Set;
}
void write_x5045(unsigned char data)
{
unsigned char x,y;
x5045_SCK_Clr;
for(x=0;x<8;x++)
{
if((data&0x80)==0x80)
{
x5045_SI_Set;
}
else
{
x5045_SI_Clr;
}
delay_us(5);
x5045_SCK_Clr;
delay_us(5);
x5045_SCK_Set;
delay_us(5);
data<<=1;
}
x5045_SI_Clr;
}
void x5045_write_data(unsigned char data,unsigned char add) //给x5045指定地址写入数据
{
x5045_SCK_Clr;
delay_us(5);
x5045_CS_Clr;
wren_cmd();
x5045_CS_Set;
delay_us(5);
x5045_CS_Clr;
write_x5045(0x02);
write_x5045(add);
write_x5045(data);
x5045_CS_Set;
delay_us(5);
x5045_SCK_Clr;
wrdi_cmd();
}
请各位帮帮忙,看看是有问题?谢谢!!
|