NVMC HAL

group nrf_nvmc_hal

Hardware access layer (HAL) for managing the Non-Volatile Memory Controller (NVMC) peripheral.

Defines

NRF_NVMC_PARTIAL_ERASE_PRESENT

Symbol indicating whether the option of page partial erase is present.

Enums

enum nrf_nvmc_mode_t

NVMC modes.

Values:

enumerator NRF_NVMC_MODE_READONLY

NVMC in read-only mode.

enumerator NRF_NVMC_MODE_WRITE

NVMC in read and write mode.

enumerator NRF_NVMC_MODE_ERASE

NVMC in read and erase mode.

enum nrf_nvmc_ns_mode_t

Non-secure NVMC modes.

Values:

enumerator NRF_NVMC_NS_MODE_READONLY

Non-secure NVMC in read-only mode.

enumerator NRF_NVMC_NS_MODE_WRITE

Non-secure NVMC in read and write mode.

enumerator NRF_NVMC_NS_MODE_ERASE

Non-secure NVMC in read and erase mode.

Functions

NRF_STATIC_INLINE bool nrf_nvmc_ready_check(NRF_NVMC_Type const *p_reg)

Function for checking if NVMC is ready to perform write or erase operation.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

Return values:
  • true – NVMC can perform write or erase.

  • false – NVMC is busy and cannot perform next operation yet.

NRF_STATIC_INLINE bool nrf_nvmc_write_ready_check(NRF_NVMC_Type const *p_reg)

Function for checking if NVMC is ready to accept the next write operation.

NVM writing time can be reduced by using this function.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

Return values:
  • true – NVMC can accept the next write. It will be buffered and will be taken into account as soon as the ongoing write operation is completed.

  • false – NVMC is busy and cannot accept the next write yet.

NRF_STATIC_INLINE void nrf_nvmc_mode_set(NRF_NVMC_Type *p_reg, nrf_nvmc_mode_t mode)

Function for setting the NVMC mode.

Only activate erase and write modes when they are actively used. If Instruction Cache (ICache) is present, enabling write or erase will invalidate the cache and keep it invalidated.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • mode[in] Desired operating mode for NVMC.

NRF_STATIC_INLINE void nrf_nvmc_nonsecure_mode_set(NRF_NVMC_Type *p_reg, nrf_nvmc_ns_mode_t mode)

Function for setting the NVMC mode for non-secure Flash page operations.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • mode[in] Desired operating mode for NVMC.

NRF_STATIC_INLINE void nrf_nvmc_word_write(uint32_t address, uint32_t value)

Function for writing a 32-bit word to flash.

Using this function when accessing the flash gives the possibility to run the code in an environment where the flash is simulated.

Note

Before calling this function, the caller must ensure that:

Warning

It is recommended to use nrfx_nvmc_word_write function instead.

Parameters:
  • address[in] Address of the word to write.

  • value[in] Value to write.

NRF_STATIC_INLINE uint8_t nrf_nvmc_byte_read(uint32_t address)

Function for reading a byte from the flash.

Using this function when accessing the flash gives the possibility to run the code in an environment where the flash is simulated.

Parameters:
  • address[in] Address of the byte to read.

Returns:

Value read from flash.

NRF_STATIC_INLINE uint16_t nrf_nvmc_halfword_read(uint32_t address)

Function for reading a 16-bit halfword from the flash.

Using this function when accessing the flash gives the possibility to run the code in an environment where the flash is simulated.

Parameters:
  • address[in] Address of the halfword to read.

Returns:

Value read from flash.

NRF_STATIC_INLINE uint32_t nrf_nvmc_word_read(uint32_t address)

Function for reading a 32-bit word from the flash.

Using this function when accessing the flash gives the possibility to run the code in an environment where the flash is simulated.

Parameters:
  • address[in] Address of the word to read.

Returns:

Value read from flash.

NRF_STATIC_INLINE void nrf_nvmc_buffer_read(void *dst, uint32_t address, uint32_t num_bytes)

Function for reading a given number of bytes from the flash into the specified buffer.

Using this function when accessing the flash gives the possibility to run the code in an environment where the flash is simulated.

Parameters:
  • dst[in] Pointer to the buffer to store the data.

  • address[in] Address of the first byte to read.

  • num_bytes[in] Number of bytes to read.

NRF_STATIC_INLINE void nrf_nvmc_page_erase_start(NRF_NVMC_Type *p_reg, uint32_t page_addr)

Function for starting a single page erase in the Flash memory.

The NVMC mode must be correctly configured with nrf_nvmc_mode_set before starting the erase operation.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • page_addr[in] Address of the first word of the page to erase.

NRF_STATIC_INLINE void nrf_nvmc_uicr_erase_start(NRF_NVMC_Type *p_reg)

Function for starting the user information configuration registers (UICR) erase.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

NRF_STATIC_INLINE void nrf_nvmc_erase_all_start(NRF_NVMC_Type *p_reg)

Function for starting the erase of the whole NVM, including UICR.

This function purges all user code.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

NRF_STATIC_INLINE void nrf_nvmc_partial_erase_duration_set(NRF_NVMC_Type *p_reg, uint32_t duration_ms)

Function for configuring the page partial erase duration in milliseconds.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • duration_ms[in] Page partial erase duration in milliseconds.

NRF_STATIC_INLINE uint32_t nrf_nvmc_partial_erase_duration_get(NRF_NVMC_Type const *p_reg)

Function for getting the current setting for the page partial erase duration.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

Return values:

Interval – duration setting in milliseconds.

NRF_STATIC_INLINE void nrf_nvmc_page_partial_erase_start(NRF_NVMC_Type *p_reg, uint32_t page_addr)

Function for starting a partial erase operation.

It must be called successively until the page erase time is reached.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • page_addr[in] Address of the first word of the page to erase.