RRAMC driver

group nrfx_rramc

Resistive Random Access Memory Controller (RRAMC) peripheral driver.

Defines

NRFX_RRAMC_DEFAULT_CONFIG(_write_buff_size)

RRAMC driver default configuration.

This configuration sets up RRAMC with the following options:

  • Write mode disabled

  • Preload timeout value: 0x80

  • Write to the RRAM on the next timeout enabled

  • Access timeout: 0x100

  • Write operation is to be aborted on the power failure

Parameters:
  • _write_buff_size[in] Size of write buffer.

Typedefs

typedef void (*nrfx_rramc_evt_handler_t)(nrf_rramc_event_t const event_type)

RRAMC driver event handler type.

Param event_type:

[in] RRAMC event.

Functions

void nrfx_rramc_all_erase(void)

Function for erasing the whole RRAM memory.

Note

All user code and UICR will be erased.

void nrfx_rramc_byte_write(uint32_t address, uint8_t value)

Function for writing a single byte to RRAM.

To determine if the last RRAM write operation has been completed, use nrfx_rramc_ready_check(). The status is not updated during writes to write-buffer.

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[in] Address to where data is to be written.

  • value[in] Value to be written.

void nrfx_rramc_bytes_write(uint32_t address, void const *src, uint32_t num_bytes)

Function for writing consecutive bytes to RRAM.

To determine if the last RRAM write operation has been completed, use nrfx_rramc_ready_check(). The status is not updated during writes to write-buffer.

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[in] Address to where data is to be written.

  • src[in] Pointer to data to be copied.

  • num_bytes[in] Number of bytes to be written.

void nrfx_rramc_word_write(uint32_t address, uint32_t value)

Function for writing a 32-bit word to RRAM.

To determine if the last RRAM write operation has been completed, use nrfx_rramc_ready_check(). The status is not updated during writes to write-buffer.

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[in] Address to where data is to be written. Must be word-aligned.

  • value[in] Value to be written.

void nrfx_rramc_words_write(uint32_t address, void const *src, uint32_t num_words)

Function for writing consecutive 32-bit words to RRAM.

To determine if the last RRAM write operation has been completed, use nrfx_rramc_ready_check(). The status is not updated during writes to write-buffer.

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[in] Address to where data is to be written. Must be word-aligned.

  • src[in] Pointer to data to be copied. Must be word-aligned.

  • num_words[in] Number of words to be written.

void nrfx_rramc_write_enable_set(bool enable, uint32_t write_buff_size)

Function for enabling write mode and setting size of write buffer.

Parameters:
  • enable[in] True if write mode is to be enabled, false otherwise.

  • write_buff_size[in] Size of write buffer. If set to 0, buffering is disabled.

bool nrfx_rramc_write_enable_check(void)

Function for checking if write mode is enabled.

Returns:

True if write mode is enabled, false otherwise.

nrfx_err_t nrfx_rramc_init(nrfx_rramc_config_t const *p_config, nrfx_rramc_evt_handler_t handler)

Function for initializing the RRAMC driver instance.

Parameters:
  • p_config[in] Pointer to the structure containing configuration.

  • handler[in] Event handler provided by the user.

Return values:
  • NRFX_SUCCESS – Initialization was successful.

  • NRFX_ERROR_ALREADY – The driver has already been initialized.

nrfx_err_t nrfx_rramc_reconfigure(nrfx_rramc_config_t const *p_config)

Function for reconfiguring the RRAMC driver instance.

Parameters:
  • p_config[in] Pointer to the structure containing configuration.

Return values:
  • NRFX_SUCCESS – Reconfiguration was successful.

  • NRFX_ERROR_INVALID_STATE – The driver is uninitialized.

void nrfx_rramc_uninit(void)

Function for uninitializing the RRAMC driver instance.

uint32_t nrfx_rramc_memory_size_get(void)

Function for getting the total RRAM size in bytes.

Note

The function will return FICR_INFO_RRAM_RRAM_Unspecified value if the total RRAM size cannot be determined based on the FICR data.

Returns:

RRAM total size in bytes.

NRFX_STATIC_INLINE uint32_t nrfx_rramc_otp_word_read(uint32_t index)

Function for reading a word from the OTP in UICR.

OTP is a region of the UICR present in some chips. This function must be used to read word data from this region since unaligned accesses are not available on the OTP RRAM area.

Parameters:
  • index[in] Address (index) in OTP table from which a word is to be read.

Return values:

The – contents at index.

NRFX_STATIC_INLINE bool nrfx_rramc_otp_word_write(uint32_t index, uint32_t value)

Function for writing a 32-bit word at index position to OTP region in UICR.

The OTP is only able to write ‘0’ to bits in the UICR 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 index can be transformed to the desired value without any ‘0’ to ‘1’ transitions. If yes, then perform the write operation.

Parameters:
  • index[in] Address (index) in OTP table to which a word it to be written.

  • value[in] Value to be written.

Return values:
  • true – Word can be written into the specified OTP index address.

  • false – Word cannot be written into the specified OTP index address. Erase UICR or change index address.

NRFX_STATIC_INLINE uint8_t nrfx_rramc_byte_read(uint32_t address)

Function for reading a byte from the RRAM.

Use this function in case accessing the RRAM gives the possibility to run the code in an environment where the flash is simulated.

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

Returns:

Value read from RRAM.

NRFX_STATIC_INLINE uint32_t nrfx_rramc_word_read(uint32_t address)

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

Use this function in case accessing the RRAM gives the possibility to run the code in an environment where the flash is simulated.

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

Returns:

Value read from RRAM.

NRFX_STATIC_INLINE void nrfx_rramc_buffer_read(void *dst, uint32_t address, uint32_t num_bytes)

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

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

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

  • num_bytes[in] Number of bytes to be read.

NRFX_STATIC_INLINE bool nrfx_rramc_ready_check(void)

Function for checking current RRAMC operation status.

The status is updated for all RRAMC operations except during read and writes to write-buffer.

Return values:
  • true – Current operation is completed, and RRAMC is ready.

  • false – RRAMC is busy.

struct nrfx_rramc_config_t
#include <nrfx_rramc.h>

Configuration structure of the RRAMC driver instance.

Public Members

bool mode_write

True if write mode is to be enabled, false otherwise.

uint8_t write_buff_size

Size of write buffer. If set to 0, buffering is disabled.

uint16_t preload_timeout

Preload value expressed in clock cycles.

bool preload_timeout_enable

True if writing to RRAM is to be triggered on the next timeout, false otherwise.

uint16_t access_timeout

Access timeout used either for going into standby power mode or to remain active on wake up, expressed in clock cycles.

bool abort_on_pof

True if the current RRAM write operation is to be aborted on the power failure, false otherwise.

uint8_t irq_priority

Interrupt priority.