nrfx 3.3
Data Structures | Functions
Register Retention API

Helper that allows preserving important data from peripheral's registers. More...

Data Structures

struct  nrfx_rtn_ctrl_list_t
 Type that handles information about registers to be preserved. More...
 

Functions

void nrfx_rtn_backup (void const *p_reg, nrfx_rtn_ctrl_list_t const *p_ctrl_list, void *p_dest)
 Function for creating backup of the registers of a given peripheral.
 
void nrfx_rtn_restore (void *p_reg, nrfx_rtn_ctrl_list_t const *p_ctrl_list, void const *p_src)
 Function for restoring values of the registers of a given peripheral.
 

Detailed Description

Helper that allows preserving important data from peripheral's registers.

Register retention solution consists of:

Building register description list

Register description list consist of two symbols:

Main descriptions are stored in the soc/retention directory.

NRF_RTN_REG_ITEM(0x200, 1)
NRF_RTN_REG_ITEM(0x304, 1)
NRF_RTN_REG_ITEM(0x504, 1)
NRF_RTN_REG_FINISH

Creating register retention types and structures

In order to use the register retention list, the developer must first create types and structures in the header file, using the following scheme:

#ifndef HEADER_GUARD_H__
#define HEADER_GUARD_H__
#include <soc/nrfx_rtn_type.h>
#ifdef __cplusplus
extern "C" {
#endif
// Filename of the list that contains all described registers
#define REGS_LIST_FILE "retention/nrfx_rtn_PERIPH.regdef"
// Name of the type that creates space to store all registers
#define REGS_ITEMS_SPACE_TYPE_NAME nrfx_rtn_PERIPH_t
// Name of the control list that contains offsets and number of 32bit words to operate on
#define REGS_ITEMS_CTRL_ARR_NAME nrfx_rtn_PERIPH_ctrl_list
#include "nrfx_rtn_template.h"
#ifdef __cplusplus
}
#endif
#endif // HEADER_GUARD_H__

API usage

After creating of the structures and types developer can easily use them to reserve place to register backup statically:

nrfx_rtn_PERIPH_t rtn_registers __attribute__((section("RETAINED_SECTION")));

or dynamically using some allocator:

nrfx_rtn_PERIPH_t * rtn_registers = allocator(sizeof(nrfx_rtn_PERIPH_t));

Registers can be preserved using nrfx_rtn_backup() function:

nrfx_rtn_backup((void *)NRF_PERIPH,
nrfx_rtn_PERIPH_ctrl_list,
(void *)&rtn_registers);
void nrfx_rtn_backup(void const *p_reg, nrfx_rtn_ctrl_list_t const *p_ctrl_list, void *p_dest)
Function for creating backup of the registers of a given peripheral.

To restore registers use nrfx_rtn_restore() function:

nrfx_rtn_restore((void *)NRF_PERIPH,
nrfx_rtn_PERIPH_ctrl_list,
(void *)&rtn_registers);
void nrfx_rtn_restore(void *p_reg, nrfx_rtn_ctrl_list_t const *p_ctrl_list, void const *p_src)
Function for restoring values of the registers of a given peripheral.

Function Documentation

◆ nrfx_rtn_backup()

void nrfx_rtn_backup ( void const *  p_reg,
nrfx_rtn_ctrl_list_t const *  p_ctrl_list,
void *  p_dest 
)

Function for creating backup of the registers of a given peripheral.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]p_ctrl_listPointer to the control list structure.
[out]p_destPointer to the destination memory.

◆ nrfx_rtn_restore()

void nrfx_rtn_restore ( void *  p_reg,
nrfx_rtn_ctrl_list_t const *  p_ctrl_list,
void const *  p_src 
)

Function for restoring values of the registers of a given peripheral.

Parameters
[out]p_regPointer to the structure of registers of the peripheral.
[in]p_ctrl_listPointer to the control list structure.
[in]p_srcPointer to the source memory.

Documentation feedback | Developer Zone | Subscribe | Updated