stm32g0: Refactored the wait code in the flash write routine
This commit is contained in:
parent
d6c1d8a1cc
commit
d4d6218234
|
@ -418,16 +418,13 @@ static int stm32g0_flash_write(target_flash_s *f, target_addr dest, const void *
|
||||||
target_mem_write32(t, FLASH_CR, FLASH_CR_PG);
|
target_mem_write32(t, FLASH_CR, FLASH_CR_PG);
|
||||||
target_mem_write(t, dest, src, len);
|
target_mem_write(t, dest, src, len);
|
||||||
/* Wait for completion or an error */
|
/* Wait for completion or an error */
|
||||||
uint32_t status = FLASH_SR_BSY_MASK;
|
if (!stm32g0_wait_busy(t)) {
|
||||||
while (status & FLASH_SR_BSY_MASK) {
|
DEBUG_WARN("stm32g0 flash write: comm error\n");
|
||||||
status = target_mem_read32(t, FLASH_SR);
|
stm32g0_flash_op_finish(t);
|
||||||
if (target_check_error(t)) {
|
return -1;
|
||||||
DEBUG_WARN("stm32g0 flash write: comm error\n");
|
|
||||||
stm32g0_flash_op_finish(t);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const uint32_t status = target_mem_read32(t, FLASH_SR);
|
||||||
if (status & FLASH_SR_ERROR_MASK) {
|
if (status & FLASH_SR_ERROR_MASK) {
|
||||||
DEBUG_WARN("stm32g0 flash write error: sr 0x%" PRIx32 "\n", status);
|
DEBUG_WARN("stm32g0 flash write error: sr 0x%" PRIx32 "\n", status);
|
||||||
stm32g0_flash_op_finish(t);
|
stm32g0_flash_op_finish(t);
|
||||||
|
|
Loading…
Reference in New Issue