Skip to content

Commit

Permalink
gowin: avoid multiple status register access
Browse files Browse the repository at this point in the history
  • Loading branch information
trabucayre committed Dec 4, 2023
1 parent 01d6244 commit 0dcd851
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/gowin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -657,9 +657,10 @@ bool Gowin::writeSRAM(const uint8_t *data, int length)
send_command(CONFIG_DISABLE); // config disable
send_command(NOOP); // noop

uint32_t status_reg = readStatusReg();
if (_verbose)
displayReadReg("after write sram", readStatusReg());
if (readStatusReg() & STATUS_DONE_FINAL) {
displayReadReg("after write sram", status_reg);
if (status_reg & STATUS_DONE_FINAL) {
printSuccess("DONE");
return true;
} else {
Expand Down Expand Up @@ -780,9 +781,11 @@ bool Gowin::eraseSRAM()
printError("FAIL");
return false;
}

uint32_t status_reg = readStatusReg();
if (_verbose)
displayReadReg("after erase sram", readStatusReg());
if (readStatusReg() & STATUS_DONE_FINAL) {
displayReadReg("after erase sram", status_reg);
if (status_reg & STATUS_DONE_FINAL) {
printError("FAIL");
return false;
} else {
Expand Down

0 comments on commit 0dcd851

Please sign in to comment.