nochanges

Dependents:   BLE_Acceleration_Statejudging

Fork of nRF51822 by Nordic Semiconductor

Committer:
rgrover1
Date:
Mon Mar 23 16:26:59 2015 +0000
Revision:
100:422b051b7151
Parent:
65:98215c4f3a25
Synchronized with git rev 6dd1e0b6
Author: Rohit Grover
add #ifdef __cplusplus to pstorage.h

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bogdanm 0:eff01767de02 1 /* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved.
bogdanm 0:eff01767de02 2 *
bogdanm 0:eff01767de02 3 * The information contained herein is property of Nordic Semiconductor ASA.
bogdanm 0:eff01767de02 4 * Terms and conditions of usage are described in detail in NORDIC
bogdanm 0:eff01767de02 5 * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
bogdanm 0:eff01767de02 6 *
bogdanm 0:eff01767de02 7 * Licensees are granted free, non-transferable use of the information. NO
bogdanm 0:eff01767de02 8 * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
bogdanm 0:eff01767de02 9 * the file.
bogdanm 0:eff01767de02 10 *
bogdanm 0:eff01767de02 11 */
bogdanm 0:eff01767de02 12
bogdanm 0:eff01767de02 13 /**@file
bogdanm 0:eff01767de02 14 *
bogdanm 0:eff01767de02 15 * @defgroup persistent_storage Persistent Storage Interface
bogdanm 0:eff01767de02 16 * @{
bogdanm 0:eff01767de02 17 * @ingroup app_common
bogdanm 0:eff01767de02 18 * @brief Abstracted flash interface.
bogdanm 0:eff01767de02 19 *
bogdanm 0:eff01767de02 20 * @details In order to ensure that the SDK and application be moved to alternate persistent storage
bogdanm 0:eff01767de02 21 * options other than the default provided with NRF solution, an abstracted interface is provided
bogdanm 0:eff01767de02 22 * by the module to ensure SDK modules and application can be ported to alternate option with ease.
bogdanm 0:eff01767de02 23 */
bogdanm 0:eff01767de02 24
bogdanm 0:eff01767de02 25 #ifndef PSTORAGE_H__
bogdanm 0:eff01767de02 26 #define PSTORAGE_H__
bogdanm 0:eff01767de02 27
Rohit Grover 48:895748db3357 28 #ifdef __cplusplus
Rohit Grover 48:895748db3357 29 extern "C" {
Rohit Grover 48:895748db3357 30 #endif /* #ifdef __cplusplus */
Rohit Grover 48:895748db3357 31
bogdanm 0:eff01767de02 32 #include "pstorage_platform.h"
bogdanm 0:eff01767de02 33
rgrover1 100:422b051b7151 34 #ifdef __cplusplus
rgrover1 100:422b051b7151 35 extern "C" {
rgrover1 100:422b051b7151 36 #endif /* #ifdef __cplusplus */
rgrover1 100:422b051b7151 37
bogdanm 0:eff01767de02 38
bogdanm 0:eff01767de02 39 /**@defgroup ps_opcode Persistent Storage Access Operation Codes
bogdanm 0:eff01767de02 40 * @{
bogdanm 0:eff01767de02 41 * @brief Persistent Storage Access Operation Codes. These are used to report any error during
bogdanm 0:eff01767de02 42 * a persistent storage access operation or any general error that may occur in the
bogdanm 0:eff01767de02 43 * interface.
bogdanm 0:eff01767de02 44 *
bogdanm 0:eff01767de02 45 * @details Persistent Storage Access Operation Codes used in error notification callback
bogdanm 0:eff01767de02 46 * registered with the interface to report any error during an persistent storage access
bogdanm 0:eff01767de02 47 * operation or any general error that may occur in the interface.
bogdanm 0:eff01767de02 48 */
Rohit Grover 37:c29c330d942c 49 #define PSTORAGE_ERROR_OP_CODE 0x01 /**< General Error Code */
Rohit Grover 37:c29c330d942c 50 #define PSTORAGE_STORE_OP_CODE 0x02 /**< Error when Store Operation was requested */
Rohit Grover 37:c29c330d942c 51 #define PSTORAGE_LOAD_OP_CODE 0x03 /**< Error when Load Operation was requested */
Rohit Grover 37:c29c330d942c 52 #define PSTORAGE_CLEAR_OP_CODE 0x04 /**< Error when Clear Operation was requested */
Rohit Grover 37:c29c330d942c 53 #define PSTORAGE_UPDATE_OP_CODE 0x05 /**< Update an already touched storage block */
bogdanm 0:eff01767de02 54
bogdanm 0:eff01767de02 55 /**@} */
bogdanm 0:eff01767de02 56
bogdanm 0:eff01767de02 57 /**@defgroup pstorage_data_types Persistent Memory Interface Data Types
bogdanm 0:eff01767de02 58 * @{
bogdanm 0:eff01767de02 59 * @brief Data Types needed for interfacing with persistent memory.
bogdanm 0:eff01767de02 60 *
bogdanm 0:eff01767de02 61 * @details Data Types needed for interfacing with persistent memory.
bogdanm 0:eff01767de02 62 */
bogdanm 0:eff01767de02 63
bogdanm 0:eff01767de02 64 /**@brief Persistent Storage Error Reporting Callback
bogdanm 0:eff01767de02 65 *
bogdanm 0:eff01767de02 66 * @details Persistent Storage Error Reporting Callback that is used by the interface to report
Rohit Grover 65:98215c4f3a25 67 * success or failure of a flash operation. Therefore, for any operations, application
Rohit Grover 65:98215c4f3a25 68 * can know when the procedure was complete. For store operation, since no data copy
Rohit Grover 65:98215c4f3a25 69 * is made, receiving a success or failure notification, indicated by the reason
Rohit Grover 65:98215c4f3a25 70 * parameter of callback is an indication that the resident memory could now be reused
Rohit Grover 37:c29c330d942c 71 * or freed, as the case may be.
Rohit Grover 65:98215c4f3a25 72 *
Rohit Grover 37:c29c330d942c 73 * @param[in] handle Identifies module and block for which callback is received.
Rohit Grover 37:c29c330d942c 74 * @param[in] op_code Identifies the operation for which the event is notified.
Rohit Grover 37:c29c330d942c 75 * @param[in] result Identifies the result of flash access operation.
Rohit Grover 37:c29c330d942c 76 * NRF_SUCCESS implies, operation succeeded.
Rohit Grover 65:98215c4f3a25 77 * @param[in] p_data Identifies the application data pointer. In case of store operation, this
Rohit Grover 65:98215c4f3a25 78 * points to the resident source of application memory that application can now
Rohit Grover 65:98215c4f3a25 79 * free or reuse. In case of clear, this is NULL as no application pointer is
Rohit Grover 37:c29c330d942c 80 * needed for this operation.
Rohit Grover 37:c29c330d942c 81 * @param[in] data_len Length data application had provided for the operation.
Rohit Grover 65:98215c4f3a25 82 *
bogdanm 0:eff01767de02 83 */
bogdanm 0:eff01767de02 84 typedef void (*pstorage_ntf_cb_t)(pstorage_handle_t * p_handle,
bogdanm 0:eff01767de02 85 uint8_t op_code,
bogdanm 0:eff01767de02 86 uint32_t result,
bogdanm 0:eff01767de02 87 uint8_t * p_data,
bogdanm 0:eff01767de02 88 uint32_t data_len);
bogdanm 0:eff01767de02 89
bogdanm 0:eff01767de02 90
Rohit Grover 37:c29c330d942c 91 typedef struct
bogdanm 0:eff01767de02 92 {
Rohit Grover 37:c29c330d942c 93 pstorage_ntf_cb_t cb; /**< Callback registered with the module to be notified of any error occurring in persistent memory management */
Rohit Grover 37:c29c330d942c 94 pstorage_size_t block_size; /**< Desired block size for persistent memory storage, for example, if a module has a table with 10 entries, each entry is size 64 bytes,
Rohit Grover 37:c29c330d942c 95 * it can request 10 blocks with block size 64 bytes. On the other hand, the module can also request one block of size 640 based on
Rohit Grover 37:c29c330d942c 96 * how it would like to access or alter memory in persistent memory.
Rohit Grover 37:c29c330d942c 97 * First option is preferred when single entries that need to be updated often when having no impact on the other entries.
Rohit Grover 37:c29c330d942c 98 * While second option is preferred when entries of table are not changed on individually but have common point of loading and storing
Rohit Grover 37:c29c330d942c 99 * data. */
Rohit Grover 37:c29c330d942c 100 pstorage_size_t block_count; /** Number of blocks requested by the module, minimum values is 1. */
bogdanm 0:eff01767de02 101 } pstorage_module_param_t;
bogdanm 0:eff01767de02 102
bogdanm 0:eff01767de02 103 /**@} */
bogdanm 0:eff01767de02 104
bogdanm 0:eff01767de02 105 /**@defgroup pstorage_routines Persistent Storage Access Routines
bogdanm 0:eff01767de02 106 * @{
bogdanm 0:eff01767de02 107 * @brief Functions/Interface SDK modules use to persistently store data.
bogdanm 0:eff01767de02 108 *
bogdanm 0:eff01767de02 109 * @details Interface for Application & SDK module to load/store information persistently.
bogdanm 0:eff01767de02 110 * Note: that while implementation of each of the persistent storage access function
bogdanm 0:eff01767de02 111 * depends on the system and can specific to system/solution, the signature of the
bogdanm 0:eff01767de02 112 * interface routines should not be altered.
bogdanm 0:eff01767de02 113 */
bogdanm 0:eff01767de02 114
bogdanm 0:eff01767de02 115 /**@brief Module Initialization Routine.
bogdanm 0:eff01767de02 116 *
bogdanm 0:eff01767de02 117 * @details Initializes module. To be called once before any other APIs of the module are used.
bogdanm 0:eff01767de02 118 *
Rohit Grover 37:c29c330d942c 119 * @retval NRF_SUCCESS on success, else an error code indicating reason for failure.
bogdanm 0:eff01767de02 120 */
bogdanm 0:eff01767de02 121 uint32_t pstorage_init(void);
bogdanm 0:eff01767de02 122
bogdanm 0:eff01767de02 123
bogdanm 0:eff01767de02 124 /**@brief Register with persistent storage interface.
bogdanm 0:eff01767de02 125 *
bogdanm 0:eff01767de02 126 * @param[in] p_module_param Module registration param.
Rohit Grover 65:98215c4f3a25 127 * @param[out] p_block_id Block identifier to identify persistent memory blocks in case
Rohit Grover 65:98215c4f3a25 128 * registration succeeds. Application is expected to use the block ids
Rohit Grover 65:98215c4f3a25 129 * for subsequent operations on requested persistent memory. Maximum
Rohit Grover 65:98215c4f3a25 130 * registrations permitted is determined by configuration parameter
Rohit Grover 65:98215c4f3a25 131 * PSTORAGE_MAX_APPLICATIONS.
bogdanm 0:eff01767de02 132 * In case more than one memory blocks are requested, the identifier provided here is
bogdanm 0:eff01767de02 133 * the base identifier for the first block and to identify subsequent block,
bogdanm 0:eff01767de02 134 * application shall use \@ref pstorage_block_identifier_get with this base identifier
bogdanm 0:eff01767de02 135 * and block number. Therefore if 10 blocks of size 64 are requested and application
bogdanm 0:eff01767de02 136 * wishes to store memory in 6th block, it shall use
bogdanm 0:eff01767de02 137 * \@ref pstorage_block_identifier_get with based id and provide a block number of 5.
bogdanm 0:eff01767de02 138 * This way application is only expected to remember the base block identifier.
bogdanm 0:eff01767de02 139 *
Rohit Grover 65:98215c4f3a25 140 * @note To register an area with a total size (block count * block size) larger than the
Rohit Grover 65:98215c4f3a25 141 * page size (usually 1024 bytes), the block size must be a divisor of the page size
Rohit Grover 65:98215c4f3a25 142 * (page size % block size == 0).
Rohit Grover 65:98215c4f3a25 143 *
Rohit Grover 37:c29c330d942c 144 * @retval NRF_SUCCESS on success, else an error code indicating reason for failure.
bogdanm 0:eff01767de02 145 * @retval NRF_ERROR_INVALID_STATE is returned is API is called without module initialization.
Rohit Grover 37:c29c330d942c 146 * @retval NRF_ERROR_NULL if NULL parameter has been passed.
bogdanm 0:eff01767de02 147 * @retval NRF_ERROR_INVALID_PARAM if invalid parameters are passed to the API.
Rohit Grover 37:c29c330d942c 148 * @retval NRF_ERROR_NO_MEM in case no more registrations can be supported.
bogdanm 0:eff01767de02 149 */
bogdanm 0:eff01767de02 150 uint32_t pstorage_register(pstorage_module_param_t * p_module_param,
Rohit Grover 37:c29c330d942c 151 pstorage_handle_t * p_block_id);
bogdanm 0:eff01767de02 152
bogdanm 0:eff01767de02 153
bogdanm 0:eff01767de02 154 /**
bogdanm 0:eff01767de02 155 * @brief Function to get block id with reference to base block identifier provided at time of
bogdanm 0:eff01767de02 156 * registration.
bogdanm 0:eff01767de02 157 *
bogdanm 0:eff01767de02 158 * @details Function to get block id with reference to base block identifier provided at time of
bogdanm 0:eff01767de02 159 * registration.
bogdanm 0:eff01767de02 160 * In case more than one memory blocks were requested when registering, the identifier
bogdanm 0:eff01767de02 161 * provided here is the base identifier for the first block and to identify subsequent
bogdanm 0:eff01767de02 162 * block, application shall use this routine to get block identifier providing input as
bogdanm 0:eff01767de02 163 * base identifier and block number. Therefore if 10 blocks of size 64 are requested and
bogdanm 0:eff01767de02 164 * application wishes to store memory in 6th block, it shall use
bogdanm 0:eff01767de02 165 * \@ref pstorage_block_identifier_get with based id and provide a block number of 5.
bogdanm 0:eff01767de02 166 * This way application is only expected to remember the base block identifier.
bogdanm 0:eff01767de02 167 *
Rohit Grover 37:c29c330d942c 168 * @param[in] p_base_id Base block id received at the time of registration.
Rohit Grover 37:c29c330d942c 169 * @param[in] block_num Block Number, with first block numbered zero.
bogdanm 0:eff01767de02 170 * @param[out] p_block_id Block identifier for the block number requested in case the API succeeds.
bogdanm 0:eff01767de02 171 *
Rohit Grover 37:c29c330d942c 172 * @retval NRF_SUCCESS on success, else an error code indicating reason for failure.
bogdanm 0:eff01767de02 173 * @retval NRF_ERROR_INVALID_STATE is returned is API is called without module initialization.
Rohit Grover 37:c29c330d942c 174 * @retval NRF_ERROR_NULL if NULL parameter has been passed.
bogdanm 0:eff01767de02 175 * @retval NRF_ERROR_INVALID_PARAM if invalid parameters are passed to the API.
bogdanm 0:eff01767de02 176 */
bogdanm 0:eff01767de02 177 uint32_t pstorage_block_identifier_get(pstorage_handle_t * p_base_id,
bogdanm 0:eff01767de02 178 pstorage_size_t block_num,
bogdanm 0:eff01767de02 179 pstorage_handle_t * p_block_id);
bogdanm 0:eff01767de02 180
bogdanm 0:eff01767de02 181
bogdanm 0:eff01767de02 182 /**@brief Routine to persistently store data of length 'size' contained in 'p_src' address
bogdanm 0:eff01767de02 183 * in storage module at 'p_dest' address; Equivalent to Storage Write.
bogdanm 0:eff01767de02 184 *
bogdanm 0:eff01767de02 185 * @param[in] p_dest Destination address where data is to be stored persistently.
bogdanm 0:eff01767de02 186 * @param[in] p_src Source address containing data to be stored. API assumes this to be resident
bogdanm 0:eff01767de02 187 * memory and no intermediate copy of data is made by the API.
bogdanm 0:eff01767de02 188 * @param[in] size Size of data to be stored expressed in bytes. Should be word aligned.
bogdanm 0:eff01767de02 189 * @param[in] offset Offset in bytes to be applied when writing to the block.
bogdanm 0:eff01767de02 190 * For example, if within a block of 100 bytes, application wishes to
bogdanm 0:eff01767de02 191 * write 20 bytes at offset of 12, then this field should be set to 12.
bogdanm 0:eff01767de02 192 * Should be word aligned.
bogdanm 0:eff01767de02 193 *
Rohit Grover 37:c29c330d942c 194 * @retval NRF_SUCCESS on success, else an error code indicating reason for failure.
bogdanm 0:eff01767de02 195 * @retval NRF_ERROR_INVALID_STATE is returned is API is called without module initialization.
Rohit Grover 37:c29c330d942c 196 * @retval NRF_ERROR_NULL if NULL parameter has been passed.
bogdanm 0:eff01767de02 197 * @retval NRF_ERROR_INVALID_PARAM if invalid parameters are passed to the API.
Rohit Grover 37:c29c330d942c 198 * @retval NRF_ERROR_INVALID_ADDR in case data address 'p_src' is not aligned.
Rohit Grover 37:c29c330d942c 199 * @retval NRF_ERROR_NO_MEM in case request cannot be processed.
bogdanm 0:eff01767de02 200 *
bogdanm 0:eff01767de02 201 * @warning No copy of the data is made, and hence memory provided for data source to be written
bogdanm 0:eff01767de02 202 * to flash cannot be freed or reused by the application until this procedure
bogdanm 0:eff01767de02 203 * is complete. End of this procedure is notified to the application using the
bogdanm 0:eff01767de02 204 * notification callback registered by the application.
bogdanm 0:eff01767de02 205 */
bogdanm 0:eff01767de02 206 uint32_t pstorage_store(pstorage_handle_t * p_dest,
bogdanm 0:eff01767de02 207 uint8_t * p_src,
bogdanm 0:eff01767de02 208 pstorage_size_t size,
bogdanm 0:eff01767de02 209 pstorage_size_t offset);
bogdanm 0:eff01767de02 210
Rohit Grover 37:c29c330d942c 211 /**@brief Routine to update persistently stored data of length 'size' contained in 'p_src' address
Rohit Grover 37:c29c330d942c 212 * in storage module at 'p_dest' address.
Rohit Grover 37:c29c330d942c 213 *
Rohit Grover 37:c29c330d942c 214 * @param[in] p_dest Destination address where data is to be updated.
Rohit Grover 37:c29c330d942c 215 * @param[in] p_src Source address containing data to be stored. API assumes this to be resident
Rohit Grover 37:c29c330d942c 216 * memory and no intermediate copy of data is made by the API.
Rohit Grover 37:c29c330d942c 217 * @param[in] size Size of data to be stored expressed in bytes. Should be word aligned.
Rohit Grover 37:c29c330d942c 218 * @param[in] offset Offset in bytes to be applied when writing to the block.
Rohit Grover 37:c29c330d942c 219 * For example, if within a block of 100 bytes, application wishes to
Rohit Grover 37:c29c330d942c 220 * write 20 bytes at offset of 12, then this field should be set to 12.
Rohit Grover 37:c29c330d942c 221 * Should be word aligned.
Rohit Grover 37:c29c330d942c 222 *
Rohit Grover 37:c29c330d942c 223 * @retval NRF_SUCCESS on success, else an error code indicating reason for failure.
Rohit Grover 37:c29c330d942c 224 * @retval NRF_ERROR_INVALID_STATE is returned is API is called without module initialization.
Rohit Grover 37:c29c330d942c 225 * @retval NRF_ERROR_NULL if NULL parameter has been passed.
Rohit Grover 37:c29c330d942c 226 * @retval NRF_ERROR_INVALID_PARAM if invalid parameters are passed to the API.
Rohit Grover 37:c29c330d942c 227 * @retval NRF_ERROR_INVALID_ADDR in case data address 'p_src' is not aligned.
Rohit Grover 37:c29c330d942c 228 * @retval NRF_ERROR_NO_MEM in case request cannot be processed.
Rohit Grover 37:c29c330d942c 229 *
Rohit Grover 37:c29c330d942c 230 * @warning No copy of the data is made, and hence memory provided for data source to be written
Rohit Grover 37:c29c330d942c 231 * to flash cannot be freed or reused by the application until this procedure
Rohit Grover 37:c29c330d942c 232 * is complete. End of this procedure is notified to the application using the
Rohit Grover 37:c29c330d942c 233 * notification callback registered by the application.
Rohit Grover 37:c29c330d942c 234 */
Rohit Grover 37:c29c330d942c 235 uint32_t pstorage_update(pstorage_handle_t * p_dest,
Rohit Grover 37:c29c330d942c 236 uint8_t * p_src,
Rohit Grover 37:c29c330d942c 237 pstorage_size_t size,
Rohit Grover 37:c29c330d942c 238 pstorage_size_t offset);
bogdanm 0:eff01767de02 239
bogdanm 0:eff01767de02 240 /**@brief Routine to load persistently stored data of length 'size' from 'p_src' address
bogdanm 0:eff01767de02 241 * to 'p_dest' address; Equivalent to Storage Read.
bogdanm 0:eff01767de02 242 *
bogdanm 0:eff01767de02 243 * @param[in] p_dest Destination address where persistently stored data is to be loaded.
bogdanm 0:eff01767de02 244 * @param[in] p_src Source from where data is to be loaded from persistent memory.
bogdanm 0:eff01767de02 245 * @param[in] size Size of data to be loaded from persistent memory expressed in bytes.
bogdanm 0:eff01767de02 246 * Should be word aligned.
bogdanm 0:eff01767de02 247 * @param[in] offset Offset in bytes to be applied when loading from the block.
bogdanm 0:eff01767de02 248 * For example, if within a block of 100 bytes, application wishes to
bogdanm 0:eff01767de02 249 * load 20 bytes from offset of 12, then this field should be set to 12.
bogdanm 0:eff01767de02 250 * Should be word aligned.
bogdanm 0:eff01767de02 251 *
Rohit Grover 37:c29c330d942c 252 * @retval NRF_SUCCESS on success, else an error code indicating reason for failure.
bogdanm 0:eff01767de02 253 * @retval NRF_ERROR_INVALID_STATE is returned is API is called without module initialization.
Rohit Grover 37:c29c330d942c 254 * @retval NRF_ERROR_NULL if NULL parameter has been passed.
bogdanm 0:eff01767de02 255 * @retval NRF_ERROR_INVALID_PARAM if invalid parameters are passed to the API.
Rohit Grover 37:c29c330d942c 256 * @retval NRF_ERROR_INVALID_ADDR in case data address 'p_dst' is not aligned.
Rohit Grover 37:c29c330d942c 257 * @retval NRF_ERROR_NO_MEM in case request cannot be processed.
bogdanm 0:eff01767de02 258 */
bogdanm 0:eff01767de02 259 uint32_t pstorage_load(uint8_t * p_dest,
bogdanm 0:eff01767de02 260 pstorage_handle_t * p_src,
bogdanm 0:eff01767de02 261 pstorage_size_t size,
bogdanm 0:eff01767de02 262 pstorage_size_t offset);
bogdanm 0:eff01767de02 263
bogdanm 0:eff01767de02 264 /**@brief Routine to clear data in persistent memory.
bogdanm 0:eff01767de02 265 *
bogdanm 0:eff01767de02 266 * @param[in] p_base_id Base block identifier in persistent memory that needs to cleared;
bogdanm 0:eff01767de02 267 * Equivalent to an Erase Operation.
bogdanm 0:eff01767de02 268 *
bogdanm 0:eff01767de02 269 * @param[in] size Size of data to be cleared from persistent memory expressed in bytes.
Rohit Grover 37:c29c330d942c 270 * This parameter is to provision for clearing of certain blocks
Rohit Grover 65:98215c4f3a25 271 * of memory, or all memory blocks in a registered module. If the total size
Rohit Grover 37:c29c330d942c 272 * of the application module is used (blocks * block size) in combination with
Rohit Grover 65:98215c4f3a25 273 * the identifier for the first block in the module, all blocks in the
Rohit Grover 37:c29c330d942c 274 * module will be erased.
bogdanm 0:eff01767de02 275 *
Rohit Grover 37:c29c330d942c 276 * @retval NRF_SUCCESS on success, else an error code indicating reason for failure.
bogdanm 0:eff01767de02 277 * @retval NRF_ERROR_INVALID_STATE is returned is API is called without module initialization.
Rohit Grover 37:c29c330d942c 278 * @retval NRF_ERROR_NULL if NULL parameter has been passed.
bogdanm 0:eff01767de02 279 * @retval NRF_ERROR_INVALID_PARAM if invalid parameters are passed to the API.
Rohit Grover 37:c29c330d942c 280 * @retval NRF_ERROR_INVALID_ADDR in case data address 'p_dst' is not aligned.
Rohit Grover 37:c29c330d942c 281 * @retval NRF_ERROR_NO_MEM in case request cannot be processed.
bogdanm 0:eff01767de02 282 *
bogdanm 0:eff01767de02 283 * @note Clear operations may take time. This API however, does not block until the clear
bogdanm 0:eff01767de02 284 * procedure is complete. Application is notified of procedure completion using
bogdanm 0:eff01767de02 285 * notification callback registered by the application. 'result' parameter of the
bogdanm 0:eff01767de02 286 * callback suggests if the procedure was successful or not.
bogdanm 0:eff01767de02 287 */
bogdanm 0:eff01767de02 288 uint32_t pstorage_clear(pstorage_handle_t * p_base_id, pstorage_size_t size);
bogdanm 0:eff01767de02 289
Rohit Grover 37:c29c330d942c 290 /**
Rohit Grover 37:c29c330d942c 291 * @brief API to get status of number of pending operations with the module.
Rohit Grover 37:c29c330d942c 292 *
Rohit Grover 37:c29c330d942c 293 * @param[out] p_count Number of storage operations pending with the module, if 0,
Rohit Grover 37:c29c330d942c 294 * there are no outstanding requests.
Rohit Grover 37:c29c330d942c 295 *
Rohit Grover 37:c29c330d942c 296 * @retval NRF_SUCCESS on success, else an error code indicating reason for failure.
Rohit Grover 37:c29c330d942c 297 * @retval NRF_ERROR_INVALID_STATE is returned is API is called without module initialization.
Rohit Grover 37:c29c330d942c 298 * @retval NRF_ERROR_NULL if NULL parameter has been passed.
Rohit Grover 37:c29c330d942c 299 */
Rohit Grover 37:c29c330d942c 300 uint32_t pstorage_access_status_get(uint32_t * p_count);
Rohit Grover 37:c29c330d942c 301
bogdanm 0:eff01767de02 302 #ifdef PSTORAGE_RAW_MODE_ENABLE
bogdanm 0:eff01767de02 303
bogdanm 0:eff01767de02 304 /**@brief Function for registering with persistent storage interface.
bogdanm 0:eff01767de02 305 *
bogdanm 0:eff01767de02 306 * @param[in] p_module_param Module registration param.
Rohit Grover 65:98215c4f3a25 307 * @param[out] p_block_id Block identifier to identify persistent memory blocks in case
Rohit Grover 65:98215c4f3a25 308 * registration succeeds. Application is expected to use the block ids
Rohit Grover 37:c29c330d942c 309 * for subsequent operations on requested persistent memory.
bogdanm 0:eff01767de02 310 * In case more than one memory blocks are requested, the identifier provided here is
bogdanm 0:eff01767de02 311 * the base identifier for the first block and to identify subsequent block,
bogdanm 0:eff01767de02 312 * application shall use \@ref pstorage_block_identifier_get with this base identifier
bogdanm 0:eff01767de02 313 * and block number. Therefore if 10 blocks of size 64 are requested and application
bogdanm 0:eff01767de02 314 * wishes to store memory in 6th block, it shall use
bogdanm 0:eff01767de02 315 * \@ref pstorage_block_identifier_get with based id and provide a block number of 5.
bogdanm 0:eff01767de02 316 * This way application is only expected to remember the base block identifier.
bogdanm 0:eff01767de02 317 *
Rohit Grover 37:c29c330d942c 318 * @retval NRF_SUCCESS on success, else an error code indicating reason for failure.
bogdanm 0:eff01767de02 319 * @retval NRF_ERROR_INVALID_STATE is returned is API is called without module initialization.
Rohit Grover 37:c29c330d942c 320 * @retval NRF_ERROR_NULL if NULL parameter has been passed.
bogdanm 0:eff01767de02 321 * @retval NRF_ERROR_INVALID_PARAM if invalid parameters are passed to the API.
Rohit Grover 37:c29c330d942c 322 * @retval NRF_ERROR_NO_MEM in case no more registrations can be supported.
bogdanm 0:eff01767de02 323 */
bogdanm 0:eff01767de02 324 uint32_t pstorage_raw_register(pstorage_module_param_t * p_module_param,
bogdanm 0:eff01767de02 325 pstorage_handle_t * p_block_id);
bogdanm 0:eff01767de02 326
bogdanm 0:eff01767de02 327 /**@brief Raw mode function for persistently storing data of length 'size' contained in 'p_src'
bogdanm 0:eff01767de02 328 * address in storage module at 'p_dest' address; Equivalent to Storage Write.
bogdanm 0:eff01767de02 329 *
bogdanm 0:eff01767de02 330 * @param[in] p_dest Destination address where data is to be stored persistently.
bogdanm 0:eff01767de02 331 * @param[in] p_src Source address containing data to be stored. API assumes this to be resident
bogdanm 0:eff01767de02 332 * memory and no intermediate copy of data is made by the API.
bogdanm 0:eff01767de02 333 * @param[in] size Size of data to be stored expressed in bytes. Should be word aligned.
Rohit Grover 37:c29c330d942c 334 * @param[in] offset Offset in bytes to be applied when writing to the block.
bogdanm 0:eff01767de02 335 * For example, if within a block of 100 bytes, application wishes to
bogdanm 0:eff01767de02 336 * write 20 bytes at offset of 12, then this field should be set to 12.
bogdanm 0:eff01767de02 337 * Should be word aligned.
bogdanm 0:eff01767de02 338 *
Rohit Grover 37:c29c330d942c 339 * @retval NRF_SUCCESS on success, else an error code indicating reason for failure.
bogdanm 0:eff01767de02 340 * @retval NRF_ERROR_INVALID_STATE is returned is API is called without module initialization.
Rohit Grover 37:c29c330d942c 341 * @retval NRF_ERROR_NULL if NULL parameter has been passed.
bogdanm 0:eff01767de02 342 * @retval NRF_ERROR_INVALID_PARAM if invalid parameters are passed to the API.
Rohit Grover 37:c29c330d942c 343 * @retval NRF_ERROR_INVALID_ADDR in case data address 'p_src' is not aligned.
Rohit Grover 37:c29c330d942c 344 * @retval NRF_ERROR_NO_MEM in case request cannot be processed.
bogdanm 0:eff01767de02 345 *
bogdanm 0:eff01767de02 346 * @warning No copy of the data is made, and hence memory provided for data source to be written
bogdanm 0:eff01767de02 347 * to flash cannot be freed or reused by the application until this procedure
bogdanm 0:eff01767de02 348 * is complete. End of this procedure is notified to the application using the
bogdanm 0:eff01767de02 349 * notification callback registered by the application.
bogdanm 0:eff01767de02 350 */
bogdanm 0:eff01767de02 351 uint32_t pstorage_raw_store(pstorage_handle_t * p_dest,
bogdanm 0:eff01767de02 352 uint8_t * p_src,
bogdanm 0:eff01767de02 353 pstorage_size_t size,
bogdanm 0:eff01767de02 354 pstorage_size_t offset);
bogdanm 0:eff01767de02 355
bogdanm 0:eff01767de02 356 /**@brief Function for clearing data in persistent memory in raw mode.
bogdanm 0:eff01767de02 357 *
Rohit Grover 37:c29c330d942c 358 * @param[in] p_dest Base block identifier in persistent memory that needs to cleared;
Rohit Grover 37:c29c330d942c 359 * Equivalent to an Erase Operation.
Rohit Grover 37:c29c330d942c 360 * @param[in] size Size of data to be cleared from persistent memory expressed in bytes.
Rohit Grover 37:c29c330d942c 361 * This is currently unused. And a clear would mean clearing all blocks,
Rohit Grover 37:c29c330d942c 362 * however, this parameter is to provision for clearing of certain blocks
Rohit Grover 37:c29c330d942c 363 * of memory only and not all if need be.
bogdanm 0:eff01767de02 364 *
Rohit Grover 37:c29c330d942c 365 * @retval NRF_SUCCESS on success, else an error code indicating reason for failure.
bogdanm 0:eff01767de02 366 * @retval NRF_ERROR_INVALID_STATE is returned is API is called without module initialization.
Rohit Grover 37:c29c330d942c 367 * @retval NRF_ERROR_NULL if NULL parameter has been passed.
bogdanm 0:eff01767de02 368 * @retval NRF_ERROR_INVALID_PARAM if invalid parameters are passed to the API.
Rohit Grover 37:c29c330d942c 369 * @retval NRF_ERROR_NO_MEM in case request cannot be processed.
bogdanm 0:eff01767de02 370 *
bogdanm 0:eff01767de02 371 * @note Clear operations may take time. This API however, does not block until the clear
bogdanm 0:eff01767de02 372 * procedure is complete. Application is notified of procedure completion using
bogdanm 0:eff01767de02 373 * notification callback registered by the application. 'result' parameter of the
bogdanm 0:eff01767de02 374 * callback suggests if the procedure was successful or not.
bogdanm 0:eff01767de02 375 */
bogdanm 0:eff01767de02 376 uint32_t pstorage_raw_clear(pstorage_handle_t * p_dest, pstorage_size_t size);
bogdanm 0:eff01767de02 377
bogdanm 0:eff01767de02 378 #endif // PSTORAGE_RAW_MODE_ENABLE
bogdanm 0:eff01767de02 379
Rohit Grover 48:895748db3357 380 #ifdef __cplusplus
Rohit Grover 48:895748db3357 381 }
Rohit Grover 48:895748db3357 382 #endif /* #ifdef __cplusplus */
Rohit Grover 48:895748db3357 383
bogdanm 0:eff01767de02 384 /**@} */
bogdanm 0:eff01767de02 385 /**@} */
bogdanm 0:eff01767de02 386
rgrover1 100:422b051b7151 387 #ifdef __cplusplus
rgrover1 100:422b051b7151 388 }
rgrover1 100:422b051b7151 389 #endif /* #ifdef __cplusplus */
rgrover1 100:422b051b7151 390
bogdanm 0:eff01767de02 391 #endif // PSTORAGE_H__
rgrover1 100:422b051b7151 392