gowin: avoid multiple status register access

This commit is contained in:
Gwenhael Goavec-Merou 2023-12-04 07:05:40 +01:00
parent 01d6244a0f
commit 0dcd851187
1 changed files with 7 additions and 4 deletions

View File

@ -657,9 +657,10 @@ bool Gowin::writeSRAM(const uint8_t *data, int length)
send_command(CONFIG_DISABLE); // config disable send_command(CONFIG_DISABLE); // config disable
send_command(NOOP); // noop send_command(NOOP); // noop
uint32_t status_reg = readStatusReg();
if (_verbose) if (_verbose)
displayReadReg("after write sram", readStatusReg()); displayReadReg("after write sram", status_reg);
if (readStatusReg() & STATUS_DONE_FINAL) { if (status_reg & STATUS_DONE_FINAL) {
printSuccess("DONE"); printSuccess("DONE");
return true; return true;
} else { } else {
@ -780,9 +781,11 @@ bool Gowin::eraseSRAM()
printError("FAIL"); printError("FAIL");
return false; return false;
} }
uint32_t status_reg = readStatusReg();
if (_verbose) if (_verbose)
displayReadReg("after erase sram", readStatusReg()); displayReadReg("after erase sram", status_reg);
if (readStatusReg() & STATUS_DONE_FINAL) { if (status_reg & STATUS_DONE_FINAL) {
printError("FAIL"); printError("FAIL");
return false; return false;
} else { } else {