NSSMD0=1; NSSMD0=0; SPI0DAT=0xC7; while(SPIF!=1); SPIF=0; NSSMD0=1; NSSMD0=0; SPI0DAT=0x05; while(SPIF!=1); SPIF=0;
while(men_status==0x01) {
SPI0DAT=0xFF; while(SPIF!=1); SPIF=0;
men_status=SPI0DAT&0x01; }
NSSMD0=1; }
/********************************************* M25P16写一字节
/**********************************************/ void WR_flash(ulong addr,uchar data_byte) {
ADDRESS temp_addr;
temp_addr.addrlong=addr; NSSMD0=0; SPI0DAT=0x06; while(SPIF!=1); SPIF=0; NSSMD0=1; NSSMD0=0; SPI0DAT=0x02; while(SPIF!=1); SPIF=0;
SPI0DAT=temp_addr.addrbyte[1]; while(SPIF!=1); SPIF=0;
SPI0DAT=temp_addr.addrbyte[2]; while(SPIF!=1); SPIF=0;
SPI0DAT=temp_addr.addrbyte[3]; while(SPIF!=1); SPIF=0;
SPI0DAT=data_byte; while(SPIF!=1); SPIF=0; NSSMD0=1; }
/********************************************* M25P16读一字节
/**********************************************/ uchar Read_flash(ulong addr) {
ADDRESS temp_addr;
temp_addr.addrlong=addr; NSSMD0=0; SPI0DAT=0x06; while(SPIF!=1); SPIF=0; NSSMD0=1; NSSMD0=0; SPI0DAT=0x03; while(SPIF!=1); SPIF=0;
SPI0DAT=temp_addr.addrbyte[1]; while(SPIF!=1); SPIF=0;
SPI0DAT=temp_addr.addrbyte[2]; while(SPIF!=1); SPIF=0;
SPI0DAT=temp_addr.addrbyte[3]; while(SPIF!=1); SPIF=0;
SPI0DAT=0xFF; while(SPIF!=1); SPIF=0; NSSMD0=1;
return SPI0DAT; }