M25P20, M25P40, M25P80, M25P16, M25P32, M25P64 SPI FLASH C语言软件驱动源码
void InitSPIMaster(void)
{
/*
P4SFS0 |= 0x70;
P4SFS1 |= 0x70; // Setup P4[4..6] Port as SPI
// P4.7 works in GPIO mode as the Slave Select signal
SPICON1=0x00; //bit3:TEIE=0. SPI transmission end interrupt disable
//bit2:RORIE=0. SPI receive overrun interrupt disable
//bit1:TIE=0. SPI transmission interrupt disable
//bit0:RIE=0 SPI reception interrupt disable
SPICLKD=0x2C; //select frequency divider=0x2C
SPICON0=0x72; //bit6:TE=1. SPI Transmitter enable
//bit5:RE=1. SPI Receiver enable
//bit4:SPIEN=1. SPI enable
//bit3:SSEL=0. SPI Slave select output is disabled,use P4.7 as the Select Slave signal
//bit2:FLSB=0. SPI Transfer the MSB first
//bit1:SPO=1. SPI Sample data on the rising edge of the clock
*/
}