テスト用

Fork of nRF51822 by Nordic Semiconductor

Committer:
bogdanm
Date:
Wed Mar 26 14:38:17 2014 +0000
Revision:
0:eff01767de02
Child:
37:c29c330d942c
Initial import of the nRF51822 code

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
bogdanm 0:eff01767de02 28 #include "nordic_global.h"
bogdanm 0:eff01767de02 29 #include "pstorage_platform.h"
bogdanm 0:eff01767de02 30
bogdanm 0:eff01767de02 31
bogdanm 0:eff01767de02 32 /**@defgroup ps_opcode Persistent Storage Access Operation Codes
bogdanm 0:eff01767de02 33 * @{
bogdanm 0:eff01767de02 34 * @brief Persistent Storage Access Operation Codes. These are used to report any error during
bogdanm 0:eff01767de02 35 * a persistent storage access operation or any general error that may occur in the
bogdanm 0:eff01767de02 36 * interface.
bogdanm 0:eff01767de02 37 *
bogdanm 0:eff01767de02 38 * @details Persistent Storage Access Operation Codes used in error notification callback
bogdanm 0:eff01767de02 39 * registered with the interface to report any error during an persistent storage access
bogdanm 0:eff01767de02 40 * operation or any general error that may occur in the interface.
bogdanm 0:eff01767de02 41 */
bogdanm 0:eff01767de02 42 #define PSTORAGE_ERROR_OP_CODE 0x01 /**< General Error Code */
bogdanm 0:eff01767de02 43 #define PSTORAGE_STORE_OP_CODE 0x02 /**< Error when Store Operation was requested */
bogdanm 0:eff01767de02 44 #define PSTORAGE_LOAD_OP_CODE 0x03 /**< Error when Load Operation was requested */
bogdanm 0:eff01767de02 45 #define PSTORAGE_CLEAR_OP_CODE 0x04 /**< Error when Clear Operation was requested */
bogdanm 0:eff01767de02 46
bogdanm 0:eff01767de02 47 /**@} */
bogdanm 0:eff01767de02 48
bogdanm 0:eff01767de02 49 /**@defgroup pstorage_data_types Persistent Memory Interface Data Types
bogdanm 0:eff01767de02 50 * @{
bogdanm 0:eff01767de02 51 * @brief Data Types needed for interfacing with persistent memory.
bogdanm 0:eff01767de02 52 *
bogdanm 0:eff01767de02 53 * @details Data Types needed for interfacing with persistent memory.
bogdanm 0:eff01767de02 54 */
bogdanm 0:eff01767de02 55
bogdanm 0:eff01767de02 56 /**@brief Persistent Storage Error Reporting Callback
bogdanm 0:eff01767de02 57 *
bogdanm 0:eff01767de02 58 * @details Persistent Storage Error Reporting Callback that is used by the interface to report
bogdanm 0:eff01767de02 59 * success or failure of a flash operation. Therefore, for store operation or clear
bogdanm 0:eff01767de02 60 * operations, that take time, application can know when the procedure was complete.
bogdanm 0:eff01767de02 61 * For store operation, since no data copy is made, receiving a success or failure
bogdanm 0:eff01767de02 62 * notification, indicated by the reason parameter of callback is an indication that
bogdanm 0:eff01767de02 63 * the resident memory could now be reused or freed, as the case may be.
bogdanm 0:eff01767de02 64 * This callback is not received for load operation.
bogdanm 0:eff01767de02 65 *
bogdanm 0:eff01767de02 66 * @param handle Identifies module and block for which callback is received.
bogdanm 0:eff01767de02 67 * @param op_code Identifies the operation for which the event is notified.
bogdanm 0:eff01767de02 68 * @param result Identifies the result of flash access operation.
bogdanm 0:eff01767de02 69 * NRF_SUCCESS implies, operation succeeded.
bogdanm 0:eff01767de02 70 * @param p_data Identifies the application data pointer. In case of store operation, this points
bogdanm 0:eff01767de02 71 * to the resident source of application memory that application can now free or
bogdanm 0:eff01767de02 72 * reuse. In case of clear, this is NULL as no application pointer is needed for
bogdanm 0:eff01767de02 73 * this operation.
bogdanm 0:eff01767de02 74 * @param data_len Length data application had provided for the operation.
bogdanm 0:eff01767de02 75 *
bogdanm 0:eff01767de02 76 */
bogdanm 0:eff01767de02 77 typedef void (*pstorage_ntf_cb_t)(pstorage_handle_t * p_handle,
bogdanm 0:eff01767de02 78 uint8_t op_code,
bogdanm 0:eff01767de02 79 uint32_t result,
bogdanm 0:eff01767de02 80 uint8_t * p_data,
bogdanm 0:eff01767de02 81 uint32_t data_len);
bogdanm 0:eff01767de02 82
bogdanm 0:eff01767de02 83
bogdanm 0:eff01767de02 84 typedef struct ps_module_param
bogdanm 0:eff01767de02 85 {
bogdanm 0:eff01767de02 86
bogdanm 0:eff01767de02 87 pstorage_ntf_cb_t cb; /**< Callback registered with the module to be notified of any error occurring in persistent memory management */
bogdanm 0:eff01767de02 88 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,
bogdanm 0:eff01767de02 89 * 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
bogdanm 0:eff01767de02 90 * how it would like to access or alter memory in persistent memory.
bogdanm 0:eff01767de02 91 * First option is preferred when single entries that need to be updated often when having no impact on the other entries.
bogdanm 0:eff01767de02 92 * While second option is preferred when entries of table are not changed on individually but have common point of loading and storing
bogdanm 0:eff01767de02 93 * data.
bogdanm 0:eff01767de02 94 */
bogdanm 0:eff01767de02 95 pstorage_size_t block_count; /** Number of blocks requested by the module, minimum values is 1. */
bogdanm 0:eff01767de02 96
bogdanm 0:eff01767de02 97 } pstorage_module_param_t;
bogdanm 0:eff01767de02 98
bogdanm 0:eff01767de02 99 /**@} */
bogdanm 0:eff01767de02 100
bogdanm 0:eff01767de02 101 /**@defgroup pstorage_routines Persistent Storage Access Routines
bogdanm 0:eff01767de02 102 * @{
bogdanm 0:eff01767de02 103 * @brief Functions/Interface SDK modules use to persistently store data.
bogdanm 0:eff01767de02 104 *
bogdanm 0:eff01767de02 105 * @details Interface for Application & SDK module to load/store information persistently.
bogdanm 0:eff01767de02 106 * Note: that while implementation of each of the persistent storage access function
bogdanm 0:eff01767de02 107 * depends on the system and can specific to system/solution, the signature of the
bogdanm 0:eff01767de02 108 * interface routines should not be altered.
bogdanm 0:eff01767de02 109 */
bogdanm 0:eff01767de02 110
bogdanm 0:eff01767de02 111 /**@brief Module Initialization Routine.
bogdanm 0:eff01767de02 112 *
bogdanm 0:eff01767de02 113 * @details Initializes module. To be called once before any other APIs of the module are used.
bogdanm 0:eff01767de02 114 *
bogdanm 0:eff01767de02 115 * @retval NRF_SUCCESS on success, otherwise an appropriate error code.
bogdanm 0:eff01767de02 116 */
bogdanm 0:eff01767de02 117 uint32_t pstorage_init(void);
bogdanm 0:eff01767de02 118
bogdanm 0:eff01767de02 119
bogdanm 0:eff01767de02 120 /**@brief Register with persistent storage interface.
bogdanm 0:eff01767de02 121 *
bogdanm 0:eff01767de02 122 * @param[in] p_module_param Module registration param.
bogdanm 0:eff01767de02 123 * @param[out] p_block_id Block identifier to identify persistent memory blocks in case registration
bogdanm 0:eff01767de02 124 * succeeds. Application is expected to use the block ids for subsequent operations on
bogdanm 0:eff01767de02 125 * requested persistent memory. Maximum registrations permitted is determined by
bogdanm 0:eff01767de02 126 * configuration parameter PSTORAGE_MAX_APPLICATIONS.
bogdanm 0:eff01767de02 127 * In case more than one memory blocks are requested, the identifier provided here is
bogdanm 0:eff01767de02 128 * the base identifier for the first block and to identify subsequent block,
bogdanm 0:eff01767de02 129 * application shall use \@ref pstorage_block_identifier_get with this base identifier
bogdanm 0:eff01767de02 130 * and block number. Therefore if 10 blocks of size 64 are requested and application
bogdanm 0:eff01767de02 131 * wishes to store memory in 6th block, it shall use
bogdanm 0:eff01767de02 132 * \@ref pstorage_block_identifier_get with based id and provide a block number of 5.
bogdanm 0:eff01767de02 133 * This way application is only expected to remember the base block identifier.
bogdanm 0:eff01767de02 134 *
bogdanm 0:eff01767de02 135 * @retval NRF_SUCCESS on success, otherwise an appropriate error code.
bogdanm 0:eff01767de02 136 * @retval NRF_ERROR_INVALID_STATE is returned is API is called without module initialization.
bogdanm 0:eff01767de02 137 * @retval NRF_ERROR_NULL if NULL parameter has been passed.
bogdanm 0:eff01767de02 138 * @retval NRF_ERROR_INVALID_PARAM if invalid parameters are passed to the API.
bogdanm 0:eff01767de02 139 * @retval NRF_ERROR_NO_MEM in case no more registrations can be supported.
bogdanm 0:eff01767de02 140 */
bogdanm 0:eff01767de02 141 uint32_t pstorage_register(pstorage_module_param_t * p_module_param,
bogdanm 0:eff01767de02 142 pstorage_handle_t* p_block_id);
bogdanm 0:eff01767de02 143
bogdanm 0:eff01767de02 144
bogdanm 0:eff01767de02 145 /**
bogdanm 0:eff01767de02 146 * @brief Function to get block id with reference to base block identifier provided at time of
bogdanm 0:eff01767de02 147 * registration.
bogdanm 0:eff01767de02 148 *
bogdanm 0:eff01767de02 149 * @details Function to get block id with reference to base block identifier provided at time of
bogdanm 0:eff01767de02 150 * registration.
bogdanm 0:eff01767de02 151 * In case more than one memory blocks were requested when registering, the identifier
bogdanm 0:eff01767de02 152 * provided here is the base identifier for the first block and to identify subsequent
bogdanm 0:eff01767de02 153 * block, application shall use this routine to get block identifier providing input as
bogdanm 0:eff01767de02 154 * base identifier and block number. Therefore if 10 blocks of size 64 are requested and
bogdanm 0:eff01767de02 155 * application wishes to store memory in 6th block, it shall use
bogdanm 0:eff01767de02 156 * \@ref pstorage_block_identifier_get with based id and provide a block number of 5.
bogdanm 0:eff01767de02 157 * This way application is only expected to remember the base block identifier.
bogdanm 0:eff01767de02 158 *
bogdanm 0:eff01767de02 159 * @param[in] p_base_id Base block id received at the time of registration.
bogdanm 0:eff01767de02 160 * @param[in] block_num Block Number, with first block numbered zero.
bogdanm 0:eff01767de02 161 * @param[out] p_block_id Block identifier for the block number requested in case the API succeeds.
bogdanm 0:eff01767de02 162 *
bogdanm 0:eff01767de02 163 * @retval NRF_SUCCESS on success, else an error code indicating reason for failure.
bogdanm 0:eff01767de02 164 * @retval NRF_ERROR_INVALID_STATE is returned is API is called without module initialization.
bogdanm 0:eff01767de02 165 * @retval NRF_ERROR_NULL if NULL parameter has been passed.
bogdanm 0:eff01767de02 166 * @retval NRF_ERROR_INVALID_PARAM if invalid parameters are passed to the API.
bogdanm 0:eff01767de02 167 */
bogdanm 0:eff01767de02 168 uint32_t pstorage_block_identifier_get(pstorage_handle_t * p_base_id,
bogdanm 0:eff01767de02 169 pstorage_size_t block_num,
bogdanm 0:eff01767de02 170 pstorage_handle_t * p_block_id);
bogdanm 0:eff01767de02 171
bogdanm 0:eff01767de02 172
bogdanm 0:eff01767de02 173 /**@brief Routine to persistently store data of length 'size' contained in 'p_src' address
bogdanm 0:eff01767de02 174 * in storage module at 'p_dest' address; Equivalent to Storage Write.
bogdanm 0:eff01767de02 175 *
bogdanm 0:eff01767de02 176 * @param[in] p_dest Destination address where data is to be stored persistently.
bogdanm 0:eff01767de02 177 * @param[in] p_src Source address containing data to be stored. API assumes this to be resident
bogdanm 0:eff01767de02 178 * memory and no intermediate copy of data is made by the API.
bogdanm 0:eff01767de02 179 * @param[in] size Size of data to be stored expressed in bytes. Should be word aligned.
bogdanm 0:eff01767de02 180 * @param[in] offset Offset in bytes to be applied when writing to the block.
bogdanm 0:eff01767de02 181 * For example, if within a block of 100 bytes, application wishes to
bogdanm 0:eff01767de02 182 * write 20 bytes at offset of 12, then this field should be set to 12.
bogdanm 0:eff01767de02 183 * Should be word aligned.
bogdanm 0:eff01767de02 184 *
bogdanm 0:eff01767de02 185 * @retval NRF_SUCCESS on success, otherwise an appropriate error code.
bogdanm 0:eff01767de02 186 * @retval NRF_ERROR_INVALID_STATE is returned is API is called without module initialization.
bogdanm 0:eff01767de02 187 * @retval NRF_ERROR_NULL if NULL parameter has been passed.
bogdanm 0:eff01767de02 188 * @retval NRF_ERROR_INVALID_PARAM if invalid parameters are passed to the API.
bogdanm 0:eff01767de02 189 * @retval NRF_ERROR_INVALID_ADDR in case data address 'p_src' is not aligned.
bogdanm 0:eff01767de02 190 * @retval NRF_ERROR_NO_MEM in case request cannot be processed.
bogdanm 0:eff01767de02 191 *
bogdanm 0:eff01767de02 192 * @warning No copy of the data is made, and hence memory provided for data source to be written
bogdanm 0:eff01767de02 193 * to flash cannot be freed or reused by the application until this procedure
bogdanm 0:eff01767de02 194 * is complete. End of this procedure is notified to the application using the
bogdanm 0:eff01767de02 195 * notification callback registered by the application.
bogdanm 0:eff01767de02 196 */
bogdanm 0:eff01767de02 197 uint32_t pstorage_store(pstorage_handle_t * p_dest,
bogdanm 0:eff01767de02 198 uint8_t * p_src,
bogdanm 0:eff01767de02 199 pstorage_size_t size,
bogdanm 0:eff01767de02 200 pstorage_size_t offset);
bogdanm 0:eff01767de02 201
bogdanm 0:eff01767de02 202
bogdanm 0:eff01767de02 203 /**@brief Routine to load persistently stored data of length 'size' from 'p_src' address
bogdanm 0:eff01767de02 204 * to 'p_dest' address; Equivalent to Storage Read.
bogdanm 0:eff01767de02 205 *
bogdanm 0:eff01767de02 206 * @param[in] p_dest Destination address where persistently stored data is to be loaded.
bogdanm 0:eff01767de02 207 * @param[in] p_src Source from where data is to be loaded from persistent memory.
bogdanm 0:eff01767de02 208 * @param[in] size Size of data to be loaded from persistent memory expressed in bytes.
bogdanm 0:eff01767de02 209 * Should be word aligned.
bogdanm 0:eff01767de02 210 * @param[in] offset Offset in bytes to be applied when loading from the block.
bogdanm 0:eff01767de02 211 * For example, if within a block of 100 bytes, application wishes to
bogdanm 0:eff01767de02 212 * load 20 bytes from offset of 12, then this field should be set to 12.
bogdanm 0:eff01767de02 213 * Should be word aligned.
bogdanm 0:eff01767de02 214 *
bogdanm 0:eff01767de02 215 *
bogdanm 0:eff01767de02 216 * @retval NRF_SUCCESS on success, otherwise an appropriate error code.
bogdanm 0:eff01767de02 217 * @retval NRF_ERROR_INVALID_STATE is returned is API is called without module initialization.
bogdanm 0:eff01767de02 218 * @retval NRF_ERROR_NULL if NULL parameter has been passed.
bogdanm 0:eff01767de02 219 * @retval NRF_ERROR_INVALID_PARAM if invalid parameters are passed to the API.
bogdanm 0:eff01767de02 220 * @retval NRF_ERROR_INVALID_ADDR in case data address 'p_dst' is not aligned.
bogdanm 0:eff01767de02 221 */
bogdanm 0:eff01767de02 222 uint32_t pstorage_load(uint8_t * p_dest,
bogdanm 0:eff01767de02 223 pstorage_handle_t * p_src,
bogdanm 0:eff01767de02 224 pstorage_size_t size,
bogdanm 0:eff01767de02 225 pstorage_size_t offset);
bogdanm 0:eff01767de02 226
bogdanm 0:eff01767de02 227
bogdanm 0:eff01767de02 228 /**@brief Routine to clear data in persistent memory.
bogdanm 0:eff01767de02 229 *
bogdanm 0:eff01767de02 230 * @param[in] p_base_id Base block identifier in persistent memory that needs to cleared;
bogdanm 0:eff01767de02 231 * Equivalent to an Erase Operation.
bogdanm 0:eff01767de02 232 *
bogdanm 0:eff01767de02 233 * @param[in] size Size of data to be cleared from persistent memory expressed in bytes.
bogdanm 0:eff01767de02 234 * This is currently unused. And a clear would mean clearing all blocks,
bogdanm 0:eff01767de02 235 * however, this parameter is to provision for clearing of certain blocks
bogdanm 0:eff01767de02 236 * of memory only and not all if need be.
bogdanm 0:eff01767de02 237 *
bogdanm 0:eff01767de02 238 * @retval NRF_SUCCESS on success, otherwise an appropriate error code.
bogdanm 0:eff01767de02 239 * @retval NRF_ERROR_INVALID_STATE is returned is API is called without module initialization.
bogdanm 0:eff01767de02 240 * @retval NRF_ERROR_NULL if NULL parameter has been passed.
bogdanm 0:eff01767de02 241 * @retval NRF_ERROR_INVALID_PARAM if invalid parameters are passed to the API.
bogdanm 0:eff01767de02 242 * @retval NRF_ERROR_NO_MEM in case request cannot be processed.
bogdanm 0:eff01767de02 243 *
bogdanm 0:eff01767de02 244 * @note Clear operations may take time. This API however, does not block until the clear
bogdanm 0:eff01767de02 245 * procedure is complete. Application is notified of procedure completion using
bogdanm 0:eff01767de02 246 * notification callback registered by the application. 'result' parameter of the
bogdanm 0:eff01767de02 247 * callback suggests if the procedure was successful or not.
bogdanm 0:eff01767de02 248 */
bogdanm 0:eff01767de02 249 uint32_t pstorage_clear(pstorage_handle_t * p_base_id, pstorage_size_t size);
bogdanm 0:eff01767de02 250
bogdanm 0:eff01767de02 251 #ifdef PSTORAGE_RAW_MODE_ENABLE
bogdanm 0:eff01767de02 252
bogdanm 0:eff01767de02 253 /**@brief Function for registering with persistent storage interface.
bogdanm 0:eff01767de02 254 *
bogdanm 0:eff01767de02 255 * @param[in] p_module_param Module registration param.
bogdanm 0:eff01767de02 256 * @param[out] p_block_id Block identifier to identify persistent memory blocks in case
bogdanm 0:eff01767de02 257 * registration succeeds. Application is expected to use the block ids for subsequent
bogdanm 0:eff01767de02 258 * operations on requested persistent memory.
bogdanm 0:eff01767de02 259 * In case more than one memory blocks are requested, the identifier provided here is
bogdanm 0:eff01767de02 260 * the base identifier for the first block and to identify subsequent block,
bogdanm 0:eff01767de02 261 * application shall use \@ref pstorage_block_identifier_get with this base identifier
bogdanm 0:eff01767de02 262 * and block number. Therefore if 10 blocks of size 64 are requested and application
bogdanm 0:eff01767de02 263 * wishes to store memory in 6th block, it shall use
bogdanm 0:eff01767de02 264 * \@ref pstorage_block_identifier_get with based id and provide a block number of 5.
bogdanm 0:eff01767de02 265 * This way application is only expected to remember the base block identifier.
bogdanm 0:eff01767de02 266 *
bogdanm 0:eff01767de02 267 * @retval NRF_SUCCESS on success, otherwise an appropriate error code.
bogdanm 0:eff01767de02 268 * @retval NRF_ERROR_INVALID_STATE is returned is API is called without module initialization.
bogdanm 0:eff01767de02 269 * @retval NRF_ERROR_NULL if NULL parameter has been passed.
bogdanm 0:eff01767de02 270 * @retval NRF_ERROR_INVALID_PARAM if invalid parameters are passed to the API.
bogdanm 0:eff01767de02 271 * @retval NRF_ERROR_NO_MEM in case no more registrations can be supported.
bogdanm 0:eff01767de02 272 */
bogdanm 0:eff01767de02 273 uint32_t pstorage_raw_register(pstorage_module_param_t * p_module_param,
bogdanm 0:eff01767de02 274 pstorage_handle_t * p_block_id);
bogdanm 0:eff01767de02 275
bogdanm 0:eff01767de02 276 /**@brief Raw mode function for persistently storing data of length 'size' contained in 'p_src'
bogdanm 0:eff01767de02 277 * address in storage module at 'p_dest' address; Equivalent to Storage Write.
bogdanm 0:eff01767de02 278 *
bogdanm 0:eff01767de02 279 * @param[in] p_dest Destination address where data is to be stored persistently.
bogdanm 0:eff01767de02 280 * @param[in] p_src Source address containing data to be stored. API assumes this to be resident
bogdanm 0:eff01767de02 281 * memory and no intermediate copy of data is made by the API.
bogdanm 0:eff01767de02 282 * @param[in] size Size of data to be stored expressed in bytes. Should be word aligned.
bogdanm 0:eff01767de02 283 * @param[in] offset Offset in bytes to be applied when writing to the block.
bogdanm 0:eff01767de02 284 * For example, if within a block of 100 bytes, application wishes to
bogdanm 0:eff01767de02 285 * write 20 bytes at offset of 12, then this field should be set to 12.
bogdanm 0:eff01767de02 286 * Should be word aligned.
bogdanm 0:eff01767de02 287 *
bogdanm 0:eff01767de02 288 * @retval NRF_SUCCESS on success, otherwise an appropriate error code.
bogdanm 0:eff01767de02 289 * @retval NRF_ERROR_INVALID_STATE is returned is API is called without module initialization.
bogdanm 0:eff01767de02 290 * @retval NRF_ERROR_NULL if NULL parameter has been passed.
bogdanm 0:eff01767de02 291 * @retval NRF_ERROR_INVALID_PARAM if invalid parameters are passed to the API.
bogdanm 0:eff01767de02 292 * @retval NRF_ERROR_INVALID_ADDR in case data address 'p_src' is not aligned.
bogdanm 0:eff01767de02 293 * @retval NRF_ERROR_NO_MEM in case request cannot be processed.
bogdanm 0:eff01767de02 294 *
bogdanm 0:eff01767de02 295 * @warning No copy of the data is made, and hence memory provided for data source to be written
bogdanm 0:eff01767de02 296 * to flash cannot be freed or reused by the application until this procedure
bogdanm 0:eff01767de02 297 * is complete. End of this procedure is notified to the application using the
bogdanm 0:eff01767de02 298 * notification callback registered by the application.
bogdanm 0:eff01767de02 299 */
bogdanm 0:eff01767de02 300 uint32_t pstorage_raw_store(pstorage_handle_t * p_dest,
bogdanm 0:eff01767de02 301 uint8_t * p_src,
bogdanm 0:eff01767de02 302 pstorage_size_t size,
bogdanm 0:eff01767de02 303 pstorage_size_t offset);
bogdanm 0:eff01767de02 304
bogdanm 0:eff01767de02 305 /**@brief Function for clearing data in persistent memory in raw mode.
bogdanm 0:eff01767de02 306 *
bogdanm 0:eff01767de02 307 * @param[in] p_base_id Base block identifier in persistent memory that needs to cleared;
bogdanm 0:eff01767de02 308 * Equivalent to an Erase Operation.
bogdanm 0:eff01767de02 309 *
bogdanm 0:eff01767de02 310 * @param[in] size Size of data to be cleared from persistent memory expressed in bytes.
bogdanm 0:eff01767de02 311 * This is currently unused. And a clear would mean clearing all blocks,
bogdanm 0:eff01767de02 312 * however, this parameter is to provision for clearing of certain blocks
bogdanm 0:eff01767de02 313 * of memory only and not all if need be.
bogdanm 0:eff01767de02 314 *
bogdanm 0:eff01767de02 315 * @retval NRF_SUCCESS on success, otherwise an appropriate error code.
bogdanm 0:eff01767de02 316 * @retval NRF_ERROR_INVALID_STATE is returned is API is called without module initialization.
bogdanm 0:eff01767de02 317 * @retval NRF_ERROR_NULL if NULL parameter has been passed.
bogdanm 0:eff01767de02 318 * @retval NRF_ERROR_INVALID_PARAM if invalid parameters are passed to the API.
bogdanm 0:eff01767de02 319 * @retval NRF_ERROR_NO_MEM in case request cannot be processed.
bogdanm 0:eff01767de02 320 *
bogdanm 0:eff01767de02 321 * @note Clear operations may take time. This API however, does not block until the clear
bogdanm 0:eff01767de02 322 * procedure is complete. Application is notified of procedure completion using
bogdanm 0:eff01767de02 323 * notification callback registered by the application. 'result' parameter of the
bogdanm 0:eff01767de02 324 * callback suggests if the procedure was successful or not.
bogdanm 0:eff01767de02 325 */
bogdanm 0:eff01767de02 326 uint32_t pstorage_raw_clear(pstorage_handle_t * p_dest, pstorage_size_t size);
bogdanm 0:eff01767de02 327
bogdanm 0:eff01767de02 328 #endif // PSTORAGE_RAW_MODE_ENABLE
bogdanm 0:eff01767de02 329
bogdanm 0:eff01767de02 330 /**@} */
bogdanm 0:eff01767de02 331 /**@} */
bogdanm 0:eff01767de02 332
bogdanm 0:eff01767de02 333 #endif // PSTORAGE_H__
bogdanm 0:eff01767de02 334