Skip to content

Commit

Permalink
nrf91 flash without readynext
Browse files Browse the repository at this point in the history
  • Loading branch information
maxd-nordic committed Mar 22, 2024
1 parent c0f4903 commit a7a9b63
Showing 1 changed file with 4 additions and 22 deletions.
26 changes: 4 additions & 22 deletions src/target/nrf91.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,18 +84,6 @@ static bool nrf91_wait_ready(target_s *const target, platform_timeout_s *const t
return true;
}

static bool nrf91_wait_readynext(target_s *const target, platform_timeout_s *const timeout)
{
/* Poll for NVMC_READY */
while (target_mem_read32(target, NRF91_NVMC_READYNEXT) == 0) {
if (target_check_error(target))
return false;
if (timeout)
target_print_progress(timeout);
}
return true;
}

static bool nrf91_flash_erase(target_flash_s *flash, target_addr_t addr, size_t len)
{
target_s *target = flash->t;
Expand Down Expand Up @@ -140,20 +128,14 @@ static bool nrf91_uicr_flash_erase(target_flash_s *flash, target_addr_t addr, si
static bool nrf91_flash_write(target_flash_s *flash, target_addr_t dest, const void *src, size_t len)
{
target_s *target = flash->t;
platform_timeout_s timeout;

/* Enable write */
target_mem_write32(target, NRF91_NVMC_CONFIG, NRF91_NVMC_CONFIG_WEN);

if (!nrf91_wait_ready(target, &timeout))
if (!nrf91_wait_ready(target, NULL))
return false;
/* Write the data */
for (size_t offset = 0; offset < len; offset += 4) {
target_mem_write32(target, dest + offset, src + offset);
if (!nrf91_wait_readynext(target, &timeout))
return false;
}
//target_mem_write(target, dest, src, len);
if (!nrf91_wait_ready(target, &timeout))
target_mem_write(target, dest, src, len);
if (!nrf91_wait_ready(target, NULL))
return false;
/* Return to read-only */
target_mem_write32(target, NRF91_NVMC_CONFIG, NRF91_NVMC_CONFIG_REN);
Expand Down

0 comments on commit a7a9b63

Please sign in to comment.