void TestSpiFlash(void)
{
//W25Q128测试程序
uint16_t deviceId = 0;
uint8_t readBuf[50] = {0};
uint8_t i = 0;
uint8_t ret = 0;
ret = W25qxx_Init();
deviceId = W25qxx_ReadID_M();
printf("\r\nW25Q128 Device ID is 0x%04x, init ret=0x%02x\r\n", deviceId,ret);
//W25qxx_EraseSector(0);
//HAL_Delay(50);
/* 为了验证,首先读取要写入地址处的数据 */
printf("-------- read data before write -----------\r\n");
W25qxx_Read(readBuf, 0, 10);
for(i = 0; i < 10; i++)
{
printf("[0x%08x]:0x%02x\n", i, *(readBuf+i));
}
printf("-------- write data before write -----------\r\n");
for(i = 0; i < 50; i++)
{
readBuf[i] = 0x99 + i;
printf("[0x%08x]:0x%02x\n", i, *(readBuf+i));
}
// W25qxx_WritePro(readBuf, 0x10, 20);
W25qxx_Write(readBuf, 0x10, 20);
HAL_Delay(50);
printf("-------- read back -----------\r\n");
W25qxx_Read(readBuf, 0x20, 10);
for(i = 0; i < 10; i++)
{
printf("[0x%08x]:0x%02x\n", i, *(readBuf+i));
}
}