华邦W25系列SPI FLASH读写C语语言动源码(单片机),已在STM32单片机调试测试,可以做为你的学习设计参考。
ain.c文件:
#include "stm32f10x_it.h"
#include"hw_conf.h"
#include "spi_flash.h"
void delay(int d);
u8 DataByte=0;
u8 Tx_Buffer[] = {0x72,0x62,0x02,0x78,0x60,0x96,0x86,0x79,0x85,0x24,0x36,0x48};
u8 Rx_Buffer[BufferSize];
vu32 FLASH_ID = 0;
int main(void)
{
#ifdef DEBUG
debug();
#endif
Setup_System();
SPI_FLASH_Init();
//SPI_FLASH_ByteWrite(0x72, 0x01F01F);
//DataByte = SPI_FLASH_ByteRead(0x01F01F);
//DataByte = SPI_Flash_ReadStatusRegister();
//SPI_FLASH_SectorErase(0x01F01F);
//SPI_FLASH_BulkErase(0x01F01F);
//SPI_FLASH_ChipErase();
//DataByte = SPI_FLASH_FasttRead(0x01F01F);
//DataByte = SPI_Flash_ReadStatusRegister();
//DataByte = SPI_FLASH_ReadDeviceID();
//SPI_FLASH_ReadManuID_DeviceID(0x000000);
//SPI_FLASH_ReadJedecID();
SPI_FLASH_PageWrite(Tx_Buffer, 0x01F01F, 10);
SPI_FLASH_BufferRead(Rx_Buffer, 0x01F01F, 4);
while (1)
{
if(Rx_Buffer[0]==0x72)
{
GPIO_WriteBit(GPIOC,GPIO_Pin_6,(BitAction)(1-GPIO_ReadOutputDataBit(GPIOC,GPIO_Pin_6)));
delay(100);
}
if(Rx_Buffer[1]==0x62)
{
GPIO_WriteBit(GPIOC,GPIO_Pin_7,(BitAction)(1-GPIO_ReadOutputDataBit(GPIOC,GPIO_Pin_7)));
delay(100);
}
if(Rx_Buffer[2]==0x02)
{
GPIO_WriteBit(GPIOC,GPIO_Pin_4,(BitAction)(1-GPIO_ReadOutputDataBit(GPIOC,GPIO_Pin_4)));
delay(100);
}
if(Rx_Buffer[3]==0x78)
{
GPIO_WriteBit(GPIOC,GPIO_Pin_5,(BitAction)(1-GPIO_ReadOutputDataBit(GPIOC,GPIO_Pin_5)));
delay(100);
}
}
}