2023/12/13 14:46
通过读取status register2 判断是否CMP被设置为1
UINT8 usiStatus2Read()
{
uint8_t volatile u8Val;
QSPI_ClearRxFIFO(QSPI_FLASH_PORT);
// /CS: active
QSPI_SET_SS_LOW(QSPI_FLASH_PORT);
// send Command: 0x05, Read status register
QSPI_WRITE_TX(QSPI_FLASH_PORT, 0x35);
// wait tx finish
usiActive();
// read status
QSPI_WRITE_TX(QSPI_FLASH_PORT, 0x00);
// wait tx finish
usiActive();
// /CS: de-active
QSPI_SET_SS_HIGH(QSPI_FLASH_PORT);
// skip first rx data
u8Val = QSPI_READ_RX(QSPI_FLASH_PORT);
u8Val = QSPI_READ_RX(QSPI_FLASH_PORT);
return u8Val;
}
若设置为1,通过指令改写status register 2
int usiStatusWrite(UINT8 data)
{
// Write enable
usiWriteEnable();
///////////////////////////////////////
// /CS: active
QSPI_SET_SS_LOW(QSPI_FLASH_PORT);
// send Command: 0x01, Write status register
QSPI_WRITE_TX(QSPI_FLASH_PORT, 0x01);
// wait tx finish
usiActive();
// write status
QSPI_WRITE_TX(QSPI_FLASH_PORT, data);
// wait tx finish
usiActive();
// write status 2
QSPI_WRITE_TX(QSPI_FLASH_PORT, 0x02);
// wait tx finish
usiActive();
// /CS: de-active
QSPI_SET_SS_HIGH(QSPI_FLASH_PORT);
return Successful;
}