target/nrf51: flash read write return bool
This commit is contained in:
parent
232b6dd376
commit
220293abc6
|
@ -27,8 +27,8 @@
|
||||||
#include "cortexm.h"
|
#include "cortexm.h"
|
||||||
#include "adiv5.h"
|
#include "adiv5.h"
|
||||||
|
|
||||||
static int nrf51_flash_erase(target_flash_s *f, target_addr_t addr, size_t len);
|
static bool nrf51_flash_erase(target_flash_s *f, target_addr_t addr, size_t len);
|
||||||
static int nrf51_flash_write(target_flash_s *f, target_addr_t dest, const void *src, size_t len);
|
static bool nrf51_flash_write(target_flash_s *f, target_addr_t dest, const void *src, size_t len);
|
||||||
static bool nrf51_mass_erase(target *t);
|
static bool nrf51_mass_erase(target *t);
|
||||||
|
|
||||||
static bool nrf51_cmd_erase_uicr(target *t, int argc, const char **argv);
|
static bool nrf51_cmd_erase_uicr(target *t, int argc, const char **argv);
|
||||||
|
@ -159,7 +159,7 @@ bool nrf51_probe(target *t)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int nrf51_flash_erase(target_flash_s *f, target_addr_t addr, size_t len)
|
static bool nrf51_flash_erase(target_flash_s *f, target_addr_t addr, size_t len)
|
||||||
{
|
{
|
||||||
target *t = f->t;
|
target *t = f->t;
|
||||||
/* Enable erase */
|
/* Enable erase */
|
||||||
|
@ -168,7 +168,7 @@ static int nrf51_flash_erase(target_flash_s *f, target_addr_t addr, size_t len)
|
||||||
/* Poll for NVMC_READY */
|
/* Poll for NVMC_READY */
|
||||||
while (target_mem_read32(t, NRF51_NVMC_READY) == 0)
|
while (target_mem_read32(t, NRF51_NVMC_READY) == 0)
|
||||||
if(target_check_error(t))
|
if(target_check_error(t))
|
||||||
return -1;
|
return false;
|
||||||
|
|
||||||
while (len) {
|
while (len) {
|
||||||
if (addr == NRF51_UICR) // Special Case
|
if (addr == NRF51_UICR) // Special Case
|
||||||
|
@ -181,7 +181,7 @@ static int nrf51_flash_erase(target_flash_s *f, target_addr_t addr, size_t len)
|
||||||
/* Poll for NVMC_READY */
|
/* Poll for NVMC_READY */
|
||||||
while (target_mem_read32(t, NRF51_NVMC_READY) == 0) {
|
while (target_mem_read32(t, NRF51_NVMC_READY) == 0) {
|
||||||
if (target_check_error(t))
|
if (target_check_error(t))
|
||||||
return -1;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
addr += f->blocksize;
|
addr += f->blocksize;
|
||||||
|
@ -197,13 +197,13 @@ static int nrf51_flash_erase(target_flash_s *f, target_addr_t addr, size_t len)
|
||||||
/* Poll for NVMC_READY */
|
/* Poll for NVMC_READY */
|
||||||
while (target_mem_read32(t, NRF51_NVMC_READY) == 0) {
|
while (target_mem_read32(t, NRF51_NVMC_READY) == 0) {
|
||||||
if (target_check_error(t))
|
if (target_check_error(t))
|
||||||
return -1;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int nrf51_flash_write(target_flash_s *f, target_addr_t dest, const void *src, size_t len)
|
static bool nrf51_flash_write(target_flash_s *f, target_addr_t dest, const void *src, size_t len)
|
||||||
{
|
{
|
||||||
target *t = f->t;
|
target *t = f->t;
|
||||||
|
|
||||||
|
@ -212,15 +212,15 @@ static int nrf51_flash_write(target_flash_s *f, target_addr_t dest, const void *
|
||||||
/* Poll for NVMC_READY */
|
/* Poll for NVMC_READY */
|
||||||
while (target_mem_read32(t, NRF51_NVMC_READY) == 0)
|
while (target_mem_read32(t, NRF51_NVMC_READY) == 0)
|
||||||
if(target_check_error(t))
|
if(target_check_error(t))
|
||||||
return -1;
|
return false;
|
||||||
target_mem_write(t, dest, src, len);
|
target_mem_write(t, dest, src, len);
|
||||||
/* Poll for NVMC_READY */
|
/* Poll for NVMC_READY */
|
||||||
while (target_mem_read32(t, NRF51_NVMC_READY) == 0)
|
while (target_mem_read32(t, NRF51_NVMC_READY) == 0)
|
||||||
if(target_check_error(t))
|
if(target_check_error(t))
|
||||||
return -1;
|
return false;
|
||||||
/* Return to read-only */
|
/* Return to read-only */
|
||||||
target_mem_write32(t, NRF51_NVMC_CONFIG, NRF51_NVMC_CONFIG_REN);
|
target_mem_write32(t, NRF51_NVMC_CONFIG, NRF51_NVMC_CONFIG_REN);
|
||||||
return 0;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool nrf51_mass_erase(target *t)
|
static bool nrf51_mass_erase(target *t)
|
||||||
|
|
Loading…
Reference in New Issue