NVMC driver
- group nrfx_nvmc
Non-Volatile Memory Controller (NVMC) peripheral driver.
Functions
-
nrfx_err_t nrfx_nvmc_page_erase(uint32_t address)
Function for erasing a page in flash.
This function blocks until the erase operation finishes.
Note
Depending on the source of the code being executed, the CPU may be halted during the operation. Refer to the Product Specification for more information.
- Parameters
address – Address of the first word in the page to erase.
- Return values
NRFX_SUCCESS – Page erase complete.
NRFX_ERROR_INVALID_ADDR – Address is not aligned to the size of the page.
-
nrfx_err_t nrfx_nvmc_uicr_erase(void)
Function for erasing the user information configuration register (UICR).
Note
Depending on the source of the code being executed, the CPU may be halted during the operation. Refer to the Product Specification for more information.
- Return values
NRFX_SUCCESS – UICR has been successfully erased.
NRFX_ERROR_NOT_SUPPORTED – UICR erase is not supported.
-
void nrfx_nvmc_all_erase(void)
Function for erasing the whole flash memory.
Note
All user code and UICR will be erased.
-
bool nrfx_nvmc_byte_writable_check(uint32_t address, uint8_t value)
Function for checking whether a byte is writable at the specified address.
The NVMC is only able to write ‘0’ to bits in the flash that are erased (set to ‘1’). It cannot rewrite a bit back to ‘1’. This function checks if the value currently residing at the specified address can be transformed to the desired value without any ‘0’ to ‘1’ transitions.
- Parameters
address – Address to be checked.
value – Value to be checked.
- Return values
true – Byte can be written at the specified address.
false – Byte cannot be written at the specified address. Erase the page or change the address.
-
void nrfx_nvmc_byte_write(uint32_t address, uint8_t value)
Function for writing a single byte to flash.
To determine if the flash write has been completed, use nrfx_nvmc_write_done_check().
Note
Depending on the source of the code being executed, the CPU may be halted during the operation. Refer to the Product Specification for more information.
- Parameters
address – Address to write to.
value – Value to write.
-
bool nrfx_nvmc_halfword_writable_check(uint32_t address, uint16_t value)
Function for checking whether a halfword is writable at the specified address.
The NVMC is only able to write ‘0’ to bits in the Flash that are erased (set to ‘1’). It cannot rewrite a bit back to ‘1’. This function checks if the value currently residing at the specified address can be transformed to the desired value without any ‘0’ to ‘1’ transitions.
- Parameters
address – Address to be checked. Must be halfword-aligned.
value – Value to be checked.
- Return values
true – Halfword can be written at the specified address.
false – Halfword cannot be written at the specified address. Erase page or change address.
-
void nrfx_nvmc_halfword_write(uint32_t address, uint16_t value)
Function for writing a 16-bit halfword to flash.
To determine if the flash write has been completed, use nrfx_nvmc_write_done_check().
Note
Depending on the source of the code being executed, the CPU may be halted during the operation. Refer to the Product Specification for more information.
- Parameters
address – Address to write to. Must be halfword-aligned.
value – Value to write.
-
bool nrfx_nvmc_word_writable_check(uint32_t address, uint32_t value)
Function for checking whether a word is writable at the specified address.
The NVMC is only able to write ‘0’ to bits in the Flash that are erased (set to ‘1’). It cannot rewrite a bit back to ‘1’. This function checks if the value currently residing at the specified address can be transformed to the desired value without any ‘0’ to ‘1’ transitions.
- Parameters
address – Address to be checked. Must be word-aligned.
value – Value to be checked.
- Return values
true – Word can be written at the specified address.
false – Word cannot be written at the specified address. Erase page or change address.
-
void nrfx_nvmc_word_write(uint32_t address, uint32_t value)
Function for writing a 32-bit word to flash.
To determine if the flash write has been completed, use nrfx_nvmc_write_done_check().
Note
Depending on the source of the code being executed, the CPU may be halted during the operation. Refer to the Product Specification for more information.
- Parameters
address – Address to write to. Must be word-aligned.
value – Value to write.
-
void nrfx_nvmc_bytes_write(uint32_t address, void const *src, uint32_t num_bytes)
Function for writing consecutive bytes to flash.
To determine if the last flash write has been completed, use nrfx_nvmc_write_done_check().
Note
Depending on the source of the code being executed, the CPU may be halted during the operation. Refer to the Product Specification for more information.
- Parameters
address – Address to write to.
src – Pointer to the data to copy from.
num_bytes – Number of bytes to write.
-
void nrfx_nvmc_words_write(uint32_t address, void const *src, uint32_t num_words)
Function for writing consecutive words to flash.
To determine if the last flash write has been completed, use nrfx_nvmc_write_done_check().
Note
Depending on the source of the code being executed, the CPU may be halted during the operation. Refer to the Product Specification for more information.
- Parameters
address – Address to write to. Must be word-aligned.
src – Pointer to data to copy from. Must be word-aligned.
num_words – Number of words to write.
-
uint16_t nrfx_nvmc_otp_halfword_read(uint32_t address)
Function for reading a 16-bit aligned halfword from the OTP (UICR)
OTP is a region of the UICR present in some chips. This function must be used to read halfword data from this region since unaligned accesses are not available on the OTP flash area.
- Parameters
address – Address to read from. Must be halfword-aligned.
- Return values
The – contents at
address
.
-
NRFX_STATIC_INLINE uint32_t nrfx_nvmc_uicr_word_read(uint32_t volatile const *address)
Function for reading a 32-bit aligned word from the UICR.
This function should be used to read from the UICR since reading the flash main memory area straight after reading the UICR results in undefined behaviour for nRF9160.
Note
See anomaly 7 in the errata document.
- Parameters
address – Address to read from. Must be word-aligned.
- Return values
The – contents at
address
.
-
uint32_t nrfx_nvmc_flash_size_get(void)
Function for getting the total flash size in bytes.
- Returns
Flash total size in bytes.
-
uint32_t nrfx_nvmc_flash_page_size_get(void)
Function for getting the flash page size in bytes.
- Returns
Flash page size in bytes.
-
uint32_t nrfx_nvmc_flash_page_count_get(void)
Function for getting the flash page count.
- Returns
Flash page count.
-
NRFX_STATIC_INLINE bool nrfx_nvmc_write_done_check(void)
Function for checking if the last flash write has been completed.
- Return values
true – Last write completed successfully.
false – Last write is still in progress.
-
nrfx_err_t nrfx_nvmc_page_erase(uint32_t address)