Hi champion,
I have a question about SDK API 'QSPIFlashReadSFDP'. The input parameter dataLen is 8 which means reading 8 bytes SFDP parameter. Why we use dataLen + 3 as the SFDP command writing data length, dataLen + 2 as the address offest length, and dataLen + 1 as the Dummy cycles length? I checked the datasheet of Cyoress Flash, but could not find any requirement about it.
static void QSPIFlashReadSFDP(QSPI_Handle QSPIHandle, uint32_t addr, uint32_t dataLen, uint8_t *receiveData)
{
uint8_t index;
uint32_t status;
/* Write SFDP Command */
QSPIFlashWriteCmd(QSPIHandle, FLASH_CMD_SFDP, dataLen + 3U);
/* Write Address offset */
QSPIFlashWriteAddr(QSPIHandle, addr, dataLen + 2U);
/* 8 Dummy cycles - 1 byte */
QSPI_cfgWrite (QSPIHandle, QSPI_CMD_4PIN_WRITE_SINGLE, QSPI_WORDLEN_8BIT, 0x0, dataLen + 1U);
/* Read Bytes */
for(index = 0U; index < dataLen; index++)
{
receiveData[index] = QSPIFlashReadByte(QSPIHandle);
}
/* Check BUSY flag */
do
{
status = QSPIFlashGetStatus(QSPIHandle, FLASH_CMD_RDSR1);
}while((status & 0x1U) != 0x0U);
}