main()函数
uint8_t TxBuf[] = "HelloWorld";
#define BUFSZ (sizeof(TxBuf) / sizeof(uint8_t))
uint8_t RxBuf[BUFSZ];
int main(void)
{
LED_GPIO_Config();
USART1_Config();
SPI_FLASH_Init();
printf("SPI测试实践: \r\n\r\n");
if (SPI_FLASH_ReadID() == FLASHID)
{
printf("找到FLASH设备,型号为W25X64\r\n\r\n");
LED_Flicker();
//printf("擦出扇区中...\r\n\r\n");
//SPI_FLASH_Erase_Sector(0x00);
//printf("擦除完毕!\r\n\r\n");
printf("写入的数据为: %s \r\n\r\n", TxBuf);
SPI_FLASH_Write(TxBuf, 0x00000, BUFSZ);
SPI_FLASH_Read(RxBuf, 0x00000, BUFSZ);
printf("读出的数据为: %s \r\n\r\n", TxBuf);
}
else
{
printf("找不到FLASH设备\r\n\r\n");
}
while (1);
return 0;
}
|